1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
122 NETGEN_1D2D3D = FULL_NETGEN
123 NETGEN_FULL = FULL_NETGEN
128 # MirrorType enumeration
129 POINT = SMESH_MeshEditor.POINT
130 AXIS = SMESH_MeshEditor.AXIS
131 PLANE = SMESH_MeshEditor.PLANE
133 # Smooth_Method enumeration
134 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
135 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
137 # Fineness enumeration (for NETGEN)
145 # Optimization level of GHS3D
146 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
148 # Topology treatment way of BLSURF
149 FromCAD, PreProcess, PreProcessPlus = 0,1,2
151 # Element size flag of BLSURF
152 DefaultSize, DefaultGeom, Custom = 0,0,1
154 PrecisionConfusion = 1e-07
156 def IsEqual(val1, val2, tol=PrecisionConfusion):
157 if abs(val1 - val2) < tol:
165 ior = salome.orb.object_to_string(obj)
166 sobj = salome.myStudy.FindObjectIOR(ior)
170 attr = sobj.FindAttribute("AttributeName")[1]
173 ## Sets a name to the object
174 def SetName(obj, name):
175 ior = salome.orb.object_to_string(obj)
176 sobj = salome.myStudy.FindObjectIOR(ior)
178 attr = sobj.FindAttribute("AttributeName")[1]
181 ## Prints error message if a hypothesis was not assigned.
182 def TreatHypoStatus(status, hypName, geomName, isAlgo):
184 hypType = "algorithm"
186 hypType = "hypothesis"
188 if status == HYP_UNKNOWN_FATAL :
189 reason = "for unknown reason"
190 elif status == HYP_INCOMPATIBLE :
191 reason = "this hypothesis mismatches the algorithm"
192 elif status == HYP_NOTCONFORM :
193 reason = "a non-conform mesh would be built"
194 elif status == HYP_ALREADY_EXIST :
195 reason = hypType + " of the same dimension is already assigned to this shape"
196 elif status == HYP_BAD_DIM :
197 reason = hypType + " mismatches the shape"
198 elif status == HYP_CONCURENT :
199 reason = "there are concurrent hypotheses on sub-shapes"
200 elif status == HYP_BAD_SUBSHAPE :
201 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
202 elif status == HYP_BAD_GEOMETRY:
203 reason = "geometry mismatches the expectation of the algorithm"
204 elif status == HYP_HIDDEN_ALGO:
205 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
206 elif status == HYP_HIDING_ALGO:
207 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
210 hypName = '"' + hypName + '"'
211 geomName= '"' + geomName+ '"'
212 if status < HYP_UNKNOWN_FATAL:
213 print hypName, "was assigned to", geomName,"but", reason
215 print hypName, "was not assigned to",geomName,":", reason
218 ## Converts an angle from degrees to radians
219 def DegreesToRadians(AngleInDegrees):
221 return AngleInDegrees * pi / 180.0
223 # end of l1_auxiliary
226 # All methods of this class are accessible directly from the smesh.py package.
227 class smeshDC(SMESH._objref_SMESH_Gen):
229 ## Sets the current study and Geometry component
230 # @ingroup l1_auxiliary
231 def init_smesh(self,theStudy,geompyD):
233 self.SetGeomEngine(geompyD)
234 self.SetCurrentStudy(theStudy)
236 ## Creates an empty Mesh. This mesh can have an underlying geometry.
237 # @param obj the Geometrical object on which the mesh is built. If not defined,
238 # the mesh will have no underlying geometry.
239 # @param name the name for the new mesh.
240 # @return an instance of Mesh class.
241 # @ingroup l2_construct
242 def Mesh(self, obj=0, name=0):
243 return Mesh(self,self.geompyD,obj,name)
245 ## Returns a long value from enumeration
246 # Should be used for SMESH.FunctorType enumeration
247 # @ingroup l1_controls
248 def EnumToLong(self,theItem):
251 ## Gets PointStruct from vertex
252 # @param theVertex a GEOM object(vertex)
253 # @return SMESH.PointStruct
254 # @ingroup l1_auxiliary
255 def GetPointStruct(self,theVertex):
256 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
257 return PointStruct(x,y,z)
259 ## Gets DirStruct from vector
260 # @param theVector a GEOM object(vector)
261 # @return SMESH.DirStruct
262 # @ingroup l1_auxiliary
263 def GetDirStruct(self,theVector):
264 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
265 if(len(vertices) != 2):
266 print "Error: vector object is incorrect."
268 p1 = self.geompyD.PointCoordinates(vertices[0])
269 p2 = self.geompyD.PointCoordinates(vertices[1])
270 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
271 dirst = DirStruct(pnt)
274 ## Makes DirStruct from a triplet
275 # @param x,y,z vector components
276 # @return SMESH.DirStruct
277 # @ingroup l1_auxiliary
278 def MakeDirStruct(self,x,y,z):
279 pnt = PointStruct(x,y,z)
280 return DirStruct(pnt)
282 ## Get AxisStruct from object
283 # @param theObj a GEOM object (line or plane)
284 # @return SMESH.AxisStruct
285 # @ingroup l1_auxiliary
286 def GetAxisStruct(self,theObj):
287 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
289 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
290 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
291 vertex1 = self.geompyD.PointCoordinates(vertex1)
292 vertex2 = self.geompyD.PointCoordinates(vertex2)
293 vertex3 = self.geompyD.PointCoordinates(vertex3)
294 vertex4 = self.geompyD.PointCoordinates(vertex4)
295 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
296 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
297 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] ]
298 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
300 elif len(edges) == 1:
301 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
302 p1 = self.geompyD.PointCoordinates( vertex1 )
303 p2 = self.geompyD.PointCoordinates( vertex2 )
304 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
308 # From SMESH_Gen interface:
309 # ------------------------
311 ## Sets the current mode
312 # @ingroup l1_auxiliary
313 def SetEmbeddedMode( self,theMode ):
314 #self.SetEmbeddedMode(theMode)
315 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
317 ## Gets the current mode
318 # @ingroup l1_auxiliary
319 def IsEmbeddedMode(self):
320 #return self.IsEmbeddedMode()
321 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
323 ## Sets the current study
324 # @ingroup l1_auxiliary
325 def SetCurrentStudy( self, theStudy ):
326 #self.SetCurrentStudy(theStudy)
327 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
329 ## Gets the current study
330 # @ingroup l1_auxiliary
331 def GetCurrentStudy(self):
332 #return self.GetCurrentStudy()
333 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
335 ## Creates a Mesh object importing data from the given UNV file
336 # @return an instance of Mesh class
338 def CreateMeshesFromUNV( self,theFileName ):
339 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
340 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
343 ## Creates a Mesh object(s) importing data from the given MED file
344 # @return a list of Mesh class instances
346 def CreateMeshesFromMED( self,theFileName ):
347 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
349 for iMesh in range(len(aSmeshMeshes)) :
350 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
351 aMeshes.append(aMesh)
352 return aMeshes, aStatus
354 ## Creates a Mesh object importing data from the given STL file
355 # @return an instance of Mesh class
357 def CreateMeshesFromSTL( self, theFileName ):
358 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
359 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
362 ## From SMESH_Gen interface
363 # @return the list of integer values
364 # @ingroup l1_auxiliary
365 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
366 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
368 ## From SMESH_Gen interface. Creates a pattern
369 # @return an instance of SMESH_Pattern
371 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
372 # @ingroup l2_modif_patterns
373 def GetPattern(self):
374 return SMESH._objref_SMESH_Gen.GetPattern(self)
377 # Filtering. Auxiliary functions:
378 # ------------------------------
380 ## Creates an empty criterion
381 # @return SMESH.Filter.Criterion
382 # @ingroup l1_controls
383 def GetEmptyCriterion(self):
384 Type = self.EnumToLong(FT_Undefined)
385 Compare = self.EnumToLong(FT_Undefined)
389 UnaryOp = self.EnumToLong(FT_Undefined)
390 BinaryOp = self.EnumToLong(FT_Undefined)
393 Precision = -1 ##@1e-07
394 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
395 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
397 ## Creates a criterion by the given parameters
398 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
399 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
400 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
401 # @param Treshold the threshold value (range of ids as string, shape, numeric)
402 # @param UnaryOp FT_LogicalNOT or FT_Undefined
403 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
404 # FT_Undefined (must be for the last criterion of all criteria)
405 # @return SMESH.Filter.Criterion
406 # @ingroup l1_controls
407 def GetCriterion(self,elementType,
409 Compare = FT_EqualTo,
411 UnaryOp=FT_Undefined,
412 BinaryOp=FT_Undefined):
413 aCriterion = self.GetEmptyCriterion()
414 aCriterion.TypeOfElement = elementType
415 aCriterion.Type = self.EnumToLong(CritType)
419 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
420 aCriterion.Compare = self.EnumToLong(Compare)
421 elif Compare == "=" or Compare == "==":
422 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
424 aCriterion.Compare = self.EnumToLong(FT_LessThan)
426 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
428 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
431 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
432 FT_BelongToCylinder, FT_LyingOnGeom]:
433 # Checks the treshold
434 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
435 aCriterion.ThresholdStr = GetName(aTreshold)
436 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
438 print "Error: The treshold should be a shape."
440 elif CritType == FT_RangeOfIds:
441 # Checks the treshold
442 if isinstance(aTreshold, str):
443 aCriterion.ThresholdStr = aTreshold
445 print "Error: The treshold should be a string."
447 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
448 # At this point the treshold is unnecessary
449 if aTreshold == FT_LogicalNOT:
450 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
451 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
452 aCriterion.BinaryOp = aTreshold
456 aTreshold = float(aTreshold)
457 aCriterion.Threshold = aTreshold
459 print "Error: The treshold should be a number."
462 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
463 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
465 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
466 aCriterion.BinaryOp = self.EnumToLong(Treshold)
468 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
469 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
471 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
472 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
476 ## Creates a filter with the given parameters
477 # @param elementType the type of elements in the group
478 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
479 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
480 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
481 # @param UnaryOp FT_LogicalNOT or FT_Undefined
482 # @return SMESH_Filter
483 # @ingroup l1_controls
484 def GetFilter(self,elementType,
485 CritType=FT_Undefined,
488 UnaryOp=FT_Undefined):
489 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
490 aFilterMgr = self.CreateFilterManager()
491 aFilter = aFilterMgr.CreateFilter()
493 aCriteria.append(aCriterion)
494 aFilter.SetCriteria(aCriteria)
497 ## Creates a numerical functor by its type
498 # @param theCriterion FT_...; functor type
499 # @return SMESH_NumericalFunctor
500 # @ingroup l1_controls
501 def GetFunctor(self,theCriterion):
502 aFilterMgr = self.CreateFilterManager()
503 if theCriterion == FT_AspectRatio:
504 return aFilterMgr.CreateAspectRatio()
505 elif theCriterion == FT_AspectRatio3D:
506 return aFilterMgr.CreateAspectRatio3D()
507 elif theCriterion == FT_Warping:
508 return aFilterMgr.CreateWarping()
509 elif theCriterion == FT_MinimumAngle:
510 return aFilterMgr.CreateMinimumAngle()
511 elif theCriterion == FT_Taper:
512 return aFilterMgr.CreateTaper()
513 elif theCriterion == FT_Skew:
514 return aFilterMgr.CreateSkew()
515 elif theCriterion == FT_Area:
516 return aFilterMgr.CreateArea()
517 elif theCriterion == FT_Volume3D:
518 return aFilterMgr.CreateVolume3D()
519 elif theCriterion == FT_MultiConnection:
520 return aFilterMgr.CreateMultiConnection()
521 elif theCriterion == FT_MultiConnection2D:
522 return aFilterMgr.CreateMultiConnection2D()
523 elif theCriterion == FT_Length:
524 return aFilterMgr.CreateLength()
525 elif theCriterion == FT_Length2D:
526 return aFilterMgr.CreateLength2D()
528 print "Error: given parameter is not numerucal functor type."
532 #Registering the new proxy for SMESH_Gen
533 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
539 ## This class allows defining and managing a mesh.
540 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
541 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
542 # new nodes and elements and by changing the existing entities), to get information
543 # about a mesh and to export a mesh into different formats.
552 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
553 # sets the GUI name of this mesh to \a name.
554 # @param smeshpyD an instance of smeshDC class
555 # @param geompyD an instance of geompyDC class
556 # @param obj Shape to be meshed or SMESH_Mesh object
557 # @param name Study name of the mesh
558 # @ingroup l2_construct
559 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
560 self.smeshpyD=smeshpyD
565 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
567 self.mesh = self.smeshpyD.CreateMesh(self.geom)
568 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
571 self.mesh = self.smeshpyD.CreateEmptyMesh()
573 SetName(self.mesh, name)
575 SetName(self.mesh, GetName(obj))
577 self.editor = self.mesh.GetMeshEditor()
579 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
580 # @param theMesh a SMESH_Mesh object
581 # @ingroup l2_construct
582 def SetMesh(self, theMesh):
584 self.geom = self.mesh.GetShapeToMesh()
586 ## Returns the mesh, that is an instance of SMESH_Mesh interface
587 # @return a SMESH_Mesh object
588 # @ingroup l2_construct
592 ## Gets the name of the mesh
593 # @return the name of the mesh as a string
594 # @ingroup l2_construct
596 name = GetName(self.GetMesh())
599 ## Sets a name to the mesh
600 # @param name a new name of the mesh
601 # @ingroup l2_construct
602 def SetName(self, name):
603 SetName(self.GetMesh(), name)
605 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
606 # The subMesh object gives access to the IDs of nodes and elements.
607 # @param theSubObject a geometrical object (shape)
608 # @param theName a name for the submesh
609 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
610 # @ingroup l2_submeshes
611 def GetSubMesh(self, theSubObject, theName):
612 submesh = self.mesh.GetSubMesh(theSubObject, theName)
615 ## Returns the shape associated to the mesh
616 # @return a GEOM_Object
617 # @ingroup l2_construct
621 ## Associates the given shape to the mesh (entails the recreation of the mesh)
622 # @param geom the shape to be meshed (GEOM_Object)
623 # @ingroup l2_construct
624 def SetShape(self, geom):
625 self.mesh = self.smeshpyD.CreateMesh(geom)
627 ## Returns true if the hypotheses are defined well
628 # @param theSubObject a subshape of a mesh shape
629 # @return True or False
630 # @ingroup l2_construct
631 def IsReadyToCompute(self, theSubObject):
632 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
634 ## Returns errors of hypotheses definition.
635 # The list of errors is empty if everything is OK.
636 # @param theSubObject a subshape of a mesh shape
637 # @return a list of errors
638 # @ingroup l2_construct
639 def GetAlgoState(self, theSubObject):
640 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
642 ## Returns a geometrical object on which the given element was built.
643 # The returned geometrical object, if not nil, is either found in the
644 # study or published by this method with the given name
645 # @param theElementID the id of the mesh element
646 # @param theGeomName the user-defined name of the geometrical object
647 # @return GEOM::GEOM_Object instance
648 # @ingroup l2_construct
649 def GetGeometryByMeshElement(self, theElementID, theGeomName):
650 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
652 ## Returns the mesh dimension depending on the dimension of the underlying shape
653 # @return mesh dimension as an integer value [0,3]
654 # @ingroup l1_auxiliary
655 def MeshDimension(self):
656 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
657 if len( shells ) > 0 :
659 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
661 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
667 ## Creates a segment discretization 1D algorithm.
668 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
669 # \n If the optional \a geom parameter is not set, this algorithm is global.
670 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
671 # @param algo the type of the required algorithm. Possible values are:
673 # - smesh.PYTHON for discretization via a python function,
674 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
675 # @param geom If defined is the subshape to be meshed
676 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
677 # @ingroup l3_algos_basic
678 def Segment(self, algo=REGULAR, geom=0):
679 ## if Segment(geom) is called by mistake
680 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
681 algo, geom = geom, algo
682 if not algo: algo = REGULAR
685 return Mesh_Segment(self, geom)
687 return Mesh_Segment_Python(self, geom)
688 elif algo == COMPOSITE:
689 return Mesh_CompositeSegment(self, geom)
691 return Mesh_Segment(self, geom)
693 ## Enables creation of nodes and segments usable by 2D algoritms.
694 # The added nodes and segments must be bound to edges and vertices by
695 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
696 # If the optional \a geom parameter is not set, this algorithm is global.
697 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
698 # @param geom the subshape to be manually meshed
699 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
700 # @ingroup l3_algos_basic
701 def UseExistingSegments(self, geom=0):
702 algo = Mesh_UseExisting(1,self,geom)
703 return algo.GetAlgorithm()
705 ## Enables creation of nodes and faces usable by 3D algoritms.
706 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
707 # and SetMeshElementOnShape()
708 # If the optional \a geom parameter is not set, this algorithm is global.
709 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
710 # @param geom the subshape to be manually meshed
711 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
712 # @ingroup l3_algos_basic
713 def UseExistingFaces(self, geom=0):
714 algo = Mesh_UseExisting(2,self,geom)
715 return algo.GetAlgorithm()
717 ## Creates a triangle 2D algorithm for faces.
718 # If the optional \a geom parameter is not set, this algorithm is global.
719 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
720 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
721 # @param geom If defined, the subshape to be meshed (GEOM_Object)
722 # @return an instance of Mesh_Triangle algorithm
723 # @ingroup l3_algos_basic
724 def Triangle(self, algo=MEFISTO, geom=0):
725 ## if Triangle(geom) is called by mistake
726 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
730 return Mesh_Triangle(self, algo, geom)
732 ## Creates a quadrangle 2D algorithm for faces.
733 # If the optional \a geom parameter is not set, this algorithm is global.
734 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
735 # @param geom If defined, the subshape to be meshed (GEOM_Object)
736 # @return an instance of Mesh_Quadrangle algorithm
737 # @ingroup l3_algos_basic
738 def Quadrangle(self, geom=0):
739 return Mesh_Quadrangle(self, geom)
741 ## Creates a tetrahedron 3D algorithm for solids.
742 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
743 # If the optional \a geom parameter is not set, this algorithm is global.
744 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
745 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
746 # @param geom If defined, the subshape to be meshed (GEOM_Object)
747 # @return an instance of Mesh_Tetrahedron algorithm
748 # @ingroup l3_algos_basic
749 def Tetrahedron(self, algo=NETGEN, geom=0):
750 ## if Tetrahedron(geom) is called by mistake
751 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
752 algo, geom = geom, algo
753 if not algo: algo = NETGEN
755 return Mesh_Tetrahedron(self, algo, geom)
757 ## Creates a hexahedron 3D algorithm for solids.
758 # If the optional \a geom parameter is not set, this algorithm is global.
759 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
760 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
761 # @param geom If defined, the subshape to be meshed (GEOM_Object)
762 # @return an instance of Mesh_Hexahedron algorithm
763 # @ingroup l3_algos_basic
764 def Hexahedron(self, algo=Hexa, geom=0):
765 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
766 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
767 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
768 elif geom == 0: algo, geom = Hexa, algo
769 return Mesh_Hexahedron(self, algo, geom)
771 ## Deprecated, used only for compatibility!
772 # @return an instance of Mesh_Netgen algorithm
773 # @ingroup l3_algos_basic
774 def Netgen(self, is3D, geom=0):
775 return Mesh_Netgen(self, is3D, geom)
777 ## Creates a projection 1D algorithm for edges.
778 # If the optional \a geom parameter is not set, this algorithm is global.
779 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
780 # @param geom If defined, the subshape to be meshed
781 # @return an instance of Mesh_Projection1D algorithm
782 # @ingroup l3_algos_proj
783 def Projection1D(self, geom=0):
784 return Mesh_Projection1D(self, geom)
786 ## Creates a projection 2D algorithm for faces.
787 # If the optional \a geom parameter is not set, this algorithm is global.
788 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
789 # @param geom If defined, the subshape to be meshed
790 # @return an instance of Mesh_Projection2D algorithm
791 # @ingroup l3_algos_proj
792 def Projection2D(self, geom=0):
793 return Mesh_Projection2D(self, geom)
795 ## Creates a projection 3D algorithm for solids.
796 # If the optional \a geom parameter is not set, this algorithm is global.
797 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
798 # @param geom If defined, the subshape to be meshed
799 # @return an instance of Mesh_Projection3D algorithm
800 # @ingroup l3_algos_proj
801 def Projection3D(self, geom=0):
802 return Mesh_Projection3D(self, geom)
804 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
805 # If the optional \a geom parameter is not set, this algorithm is global.
806 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
807 # @param geom If defined, the subshape to be meshed
808 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
809 # @ingroup l3_algos_radialp l3_algos_3dextr
810 def Prism(self, geom=0):
814 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
815 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
816 if nbSolids == 0 or nbSolids == nbShells:
817 return Mesh_Prism3D(self, geom)
818 return Mesh_RadialPrism3D(self, geom)
820 ## Computes the mesh and returns the status of the computation
821 # @return True or False
822 # @ingroup l2_construct
823 def Compute(self, geom=0):
824 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
826 geom = self.mesh.GetShapeToMesh()
831 ok = self.smeshpyD.Compute(self.mesh, geom)
832 except SALOME.SALOME_Exception, ex:
833 print "Mesh computation failed, exception caught:"
834 print " ", ex.details.text
837 print "Mesh computation failed, exception caught:"
838 traceback.print_exc()
840 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
851 reason = '%s %sD algorithm is missing' % (glob, dim)
852 elif err.state == HYP_MISSING:
853 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
854 % (glob, dim, name, dim))
855 elif err.state == HYP_NOTCONFORM:
856 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
857 elif err.state == HYP_BAD_PARAMETER:
858 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
859 % ( glob, dim, name ))
860 elif err.state == HYP_BAD_GEOMETRY:
861 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
862 'geometry' % ( glob, dim, name ))
864 reason = "For unknown reason."+\
865 " Revise Mesh.Compute() implementation in smeshDC.py!"
873 print '"' + GetName(self.mesh) + '"',"has not been computed:"
877 print '"' + GetName(self.mesh) + '"',"has not been computed."
880 if salome.sg.hasDesktop():
881 smeshgui = salome.ImportComponentGUI("SMESH")
882 smeshgui.Init(salome.myStudyId)
883 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
884 salome.sg.updateObjBrowser(1)
888 ## Removes all nodes and elements
889 # @ingroup l2_construct
892 if salome.sg.hasDesktop():
893 smeshgui = salome.ImportComponentGUI("SMESH")
894 smeshgui.Init(salome.myStudyId)
895 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
896 salome.sg.updateObjBrowser(1)
898 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
899 # @param fineness [0,-1] defines mesh fineness
900 # @return True or False
901 # @ingroup l3_algos_basic
902 def AutomaticTetrahedralization(self, fineness=0):
903 dim = self.MeshDimension()
905 self.RemoveGlobalHypotheses()
906 self.Segment().AutomaticLength(fineness)
908 self.Triangle().LengthFromEdges()
911 self.Tetrahedron(NETGEN)
913 return self.Compute()
915 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
916 # @param fineness [0,-1] defines mesh fineness
917 # @return True or False
918 # @ingroup l3_algos_basic
919 def AutomaticHexahedralization(self, fineness=0):
920 dim = self.MeshDimension()
921 # assign the hypotheses
922 self.RemoveGlobalHypotheses()
923 self.Segment().AutomaticLength(fineness)
930 return self.Compute()
932 ## Assigns a hypothesis
933 # @param hyp a hypothesis to assign
934 # @param geom a subhape of mesh geometry
935 # @return SMESH.Hypothesis_Status
936 # @ingroup l2_hypotheses
937 def AddHypothesis(self, hyp, geom=0):
938 if isinstance( hyp, Mesh_Algorithm ):
939 hyp = hyp.GetAlgorithm()
944 geom = self.mesh.GetShapeToMesh()
946 status = self.mesh.AddHypothesis(geom, hyp)
947 isAlgo = hyp._narrow( SMESH_Algo )
948 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
951 ## Unassigns a hypothesis
952 # @param hyp a hypothesis to unassign
953 # @param geom a subshape of mesh geometry
954 # @return SMESH.Hypothesis_Status
955 # @ingroup l2_hypotheses
956 def RemoveHypothesis(self, hyp, geom=0):
957 if isinstance( hyp, Mesh_Algorithm ):
958 hyp = hyp.GetAlgorithm()
963 status = self.mesh.RemoveHypothesis(geom, hyp)
966 ## Gets the list of hypotheses added on a geometry
967 # @param geom a subshape of mesh geometry
968 # @return the sequence of SMESH_Hypothesis
969 # @ingroup l2_hypotheses
970 def GetHypothesisList(self, geom):
971 return self.mesh.GetHypothesisList( geom )
973 ## Removes all global hypotheses
974 # @ingroup l2_hypotheses
975 def RemoveGlobalHypotheses(self):
976 current_hyps = self.mesh.GetHypothesisList( self.geom )
977 for hyp in current_hyps:
978 self.mesh.RemoveHypothesis( self.geom, hyp )
982 ## Creates a mesh group based on the geometric object \a grp
983 # and gives a \a name, \n if this parameter is not defined
984 # the name is the same as the geometric group name \n
985 # Note: Works like GroupOnGeom().
986 # @param grp a geometric group, a vertex, an edge, a face or a solid
987 # @param name the name of the mesh group
988 # @return SMESH_GroupOnGeom
989 # @ingroup l2_grps_create
990 def Group(self, grp, name=""):
991 return self.GroupOnGeom(grp, name)
993 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
994 # Exports the mesh in a file in MED format and chooses the \a version of MED format
995 # @param f the file name
996 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
998 def ExportToMED(self, f, version, opt=0):
999 self.mesh.ExportToMED(f, opt, version)
1001 ## Exports the mesh in a file in MED format
1002 # @param f is the file name
1003 # @param auto_groups boolean parameter for creating/not creating
1004 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1005 # the typical use is auto_groups=false.
1006 # @param version MED format version(MED_V2_1 or MED_V2_2)
1007 # @ingroup l2_impexp
1008 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1009 self.mesh.ExportToMED(f, auto_groups, version)
1011 ## Exports the mesh in a file in DAT format
1012 # @param f the file name
1013 # @ingroup l2_impexp
1014 def ExportDAT(self, f):
1015 self.mesh.ExportDAT(f)
1017 ## Exports the mesh in a file in UNV format
1018 # @param f the file name
1019 # @ingroup l2_impexp
1020 def ExportUNV(self, f):
1021 self.mesh.ExportUNV(f)
1023 ## Export the mesh in a file in STL format
1024 # @param f the file name
1025 # @param ascii defines the file encoding
1026 # @ingroup l2_impexp
1027 def ExportSTL(self, f, ascii=1):
1028 self.mesh.ExportSTL(f, ascii)
1031 # Operations with groups:
1032 # ----------------------
1034 ## Creates an empty mesh group
1035 # @param elementType the type of elements in the group
1036 # @param name the name of the mesh group
1037 # @return SMESH_Group
1038 # @ingroup l2_grps_create
1039 def CreateEmptyGroup(self, elementType, name):
1040 return self.mesh.CreateGroup(elementType, name)
1042 ## Creates a mesh group based on the geometrical object \a grp
1043 # and gives a \a name, \n if this parameter is not defined
1044 # the name is the same as the geometrical group name
1045 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1046 # @param name the name of the mesh group
1047 # @param typ the type of elements in the group. If not set, it is
1048 # automatically detected by the type of the geometry
1049 # @return SMESH_GroupOnGeom
1050 # @ingroup l2_grps_create
1051 def GroupOnGeom(self, grp, name="", typ=None):
1053 name = grp.GetName()
1056 tgeo = str(grp.GetShapeType())
1057 if tgeo == "VERTEX":
1059 elif tgeo == "EDGE":
1061 elif tgeo == "FACE":
1063 elif tgeo == "SOLID":
1065 elif tgeo == "SHELL":
1067 elif tgeo == "COMPOUND":
1068 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1069 print "Mesh.Group: empty geometric group", GetName( grp )
1071 tgeo = self.geompyD.GetType(grp)
1072 if tgeo == geompyDC.ShapeType["VERTEX"]:
1074 elif tgeo == geompyDC.ShapeType["EDGE"]:
1076 elif tgeo == geompyDC.ShapeType["FACE"]:
1078 elif tgeo == geompyDC.ShapeType["SOLID"]:
1082 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1085 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1087 ## Creates a mesh group by the given ids of elements
1088 # @param groupName the name of the mesh group
1089 # @param elementType the type of elements in the group
1090 # @param elemIDs the list of ids
1091 # @return SMESH_Group
1092 # @ingroup l2_grps_create
1093 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1094 group = self.mesh.CreateGroup(elementType, groupName)
1098 ## Creates a mesh group by the given conditions
1099 # @param groupName the name of the mesh group
1100 # @param elementType the type of elements in the group
1101 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1102 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1103 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1104 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1105 # @return SMESH_Group
1106 # @ingroup l2_grps_create
1110 CritType=FT_Undefined,
1113 UnaryOp=FT_Undefined):
1114 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1115 group = self.MakeGroupByCriterion(groupName, aCriterion)
1118 ## Creates a mesh group by the given criterion
1119 # @param groupName the name of the mesh group
1120 # @param Criterion the instance of Criterion class
1121 # @return SMESH_Group
1122 # @ingroup l2_grps_create
1123 def MakeGroupByCriterion(self, groupName, Criterion):
1124 aFilterMgr = self.smeshpyD.CreateFilterManager()
1125 aFilter = aFilterMgr.CreateFilter()
1127 aCriteria.append(Criterion)
1128 aFilter.SetCriteria(aCriteria)
1129 group = self.MakeGroupByFilter(groupName, aFilter)
1132 ## Creates a mesh group by the given criteria (list of criteria)
1133 # @param groupName the name of the mesh group
1134 # @param theCriteria the list of criteria
1135 # @return SMESH_Group
1136 # @ingroup l2_grps_create
1137 def MakeGroupByCriteria(self, groupName, theCriteria):
1138 aFilterMgr = self.smeshpyD.CreateFilterManager()
1139 aFilter = aFilterMgr.CreateFilter()
1140 aFilter.SetCriteria(theCriteria)
1141 group = self.MakeGroupByFilter(groupName, aFilter)
1144 ## Creates a mesh group by the given filter
1145 # @param groupName the name of the mesh group
1146 # @param theFilter the instance of Filter class
1147 # @return SMESH_Group
1148 # @ingroup l2_grps_create
1149 def MakeGroupByFilter(self, groupName, theFilter):
1150 anIds = theFilter.GetElementsId(self.mesh)
1151 anElemType = theFilter.GetElementType()
1152 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1155 ## Passes mesh elements through the given filter and return IDs of fitting elements
1156 # @param theFilter SMESH_Filter
1157 # @return a list of ids
1158 # @ingroup l1_controls
1159 def GetIdsFromFilter(self, theFilter):
1160 return theFilter.GetElementsId(self.mesh)
1162 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1163 # Returns a list of special structures (borders).
1164 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1165 # @ingroup l1_controls
1166 def GetFreeBorders(self):
1167 aFilterMgr = self.smeshpyD.CreateFilterManager()
1168 aPredicate = aFilterMgr.CreateFreeEdges()
1169 aPredicate.SetMesh(self.mesh)
1170 aBorders = aPredicate.GetBorders()
1174 # @ingroup l2_grps_delete
1175 def RemoveGroup(self, group):
1176 self.mesh.RemoveGroup(group)
1178 ## Removes a group with its contents
1179 # @ingroup l2_grps_delete
1180 def RemoveGroupWithContents(self, group):
1181 self.mesh.RemoveGroupWithContents(group)
1183 ## Gets the list of groups existing in the mesh
1184 # @return a sequence of SMESH_GroupBase
1185 # @ingroup l2_grps_create
1186 def GetGroups(self):
1187 return self.mesh.GetGroups()
1189 ## Gets the number of groups existing in the mesh
1190 # @return the quantity of groups as an integer value
1191 # @ingroup l2_grps_create
1193 return self.mesh.NbGroups()
1195 ## Gets the list of names of groups existing in the mesh
1196 # @return list of strings
1197 # @ingroup l2_grps_create
1198 def GetGroupNames(self):
1199 groups = self.GetGroups()
1201 for group in groups:
1202 names.append(group.GetName())
1205 ## Produces a union of two groups
1206 # A new group is created. All mesh elements that are
1207 # present in the initial groups are added to the new one
1208 # @return an instance of SMESH_Group
1209 # @ingroup l2_grps_operon
1210 def UnionGroups(self, group1, group2, name):
1211 return self.mesh.UnionGroups(group1, group2, name)
1213 ## Prodices an intersection of two groups
1214 # A new group is created. All mesh elements that are common
1215 # for the two initial groups are added to the new one.
1216 # @return an instance of SMESH_Group
1217 # @ingroup l2_grps_operon
1218 def IntersectGroups(self, group1, group2, name):
1219 return self.mesh.IntersectGroups(group1, group2, name)
1221 ## Produces a cut of two groups
1222 # A new group is created. All mesh elements that are present in
1223 # the main group but are not present in the tool group are added to the new one
1224 # @return an instance of SMESH_Group
1225 # @ingroup l2_grps_operon
1226 def CutGroups(self, mainGroup, toolGroup, name):
1227 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1230 # Get some info about mesh:
1231 # ------------------------
1233 ## Returns the log of nodes and elements added or removed
1234 # since the previous clear of the log.
1235 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1236 # @return list of log_block structures:
1241 # @ingroup l1_auxiliary
1242 def GetLog(self, clearAfterGet):
1243 return self.mesh.GetLog(clearAfterGet)
1245 ## Clears the log of nodes and elements added or removed since the previous
1246 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1247 # @ingroup l1_auxiliary
1249 self.mesh.ClearLog()
1251 ## Toggles auto color mode on the object.
1252 # @param theAutoColor the flag which toggles auto color mode.
1253 # @ingroup l1_auxiliary
1254 def SetAutoColor(self, theAutoColor):
1255 self.mesh.SetAutoColor(theAutoColor)
1257 ## Gets flag of object auto color mode.
1258 # @return True or False
1259 # @ingroup l1_auxiliary
1260 def GetAutoColor(self):
1261 return self.mesh.GetAutoColor()
1263 ## Gets the internal ID
1264 # @return integer value, which is the internal Id of the mesh
1265 # @ingroup l1_auxiliary
1267 return self.mesh.GetId()
1270 # @return integer value, which is the study Id of the mesh
1271 # @ingroup l1_auxiliary
1272 def GetStudyId(self):
1273 return self.mesh.GetStudyId()
1275 ## Checks the group names for duplications.
1276 # Consider the maximum group name length stored in MED file.
1277 # @return True or False
1278 # @ingroup l1_auxiliary
1279 def HasDuplicatedGroupNamesMED(self):
1280 return self.mesh.HasDuplicatedGroupNamesMED()
1282 ## Obtains the mesh editor tool
1283 # @return an instance of SMESH_MeshEditor
1284 # @ingroup l1_modifying
1285 def GetMeshEditor(self):
1286 return self.mesh.GetMeshEditor()
1289 # @return an instance of SALOME_MED::MESH
1290 # @ingroup l1_auxiliary
1291 def GetMEDMesh(self):
1292 return self.mesh.GetMEDMesh()
1295 # Get informations about mesh contents:
1296 # ------------------------------------
1298 ## Returns the number of nodes in the mesh
1299 # @return an integer value
1300 # @ingroup l1_meshinfo
1302 return self.mesh.NbNodes()
1304 ## Returns the number of elements in the mesh
1305 # @return an integer value
1306 # @ingroup l1_meshinfo
1307 def NbElements(self):
1308 return self.mesh.NbElements()
1310 ## Returns the number of edges in the mesh
1311 # @return an integer value
1312 # @ingroup l1_meshinfo
1314 return self.mesh.NbEdges()
1316 ## Returns the number of edges with the given order in the mesh
1317 # @param elementOrder the order of elements:
1318 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1319 # @return an integer value
1320 # @ingroup l1_meshinfo
1321 def NbEdgesOfOrder(self, elementOrder):
1322 return self.mesh.NbEdgesOfOrder(elementOrder)
1324 ## Returns the number of faces in the mesh
1325 # @return an integer value
1326 # @ingroup l1_meshinfo
1328 return self.mesh.NbFaces()
1330 ## Returns the number of faces with the given order in the mesh
1331 # @param elementOrder the order of elements:
1332 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1333 # @return an integer value
1334 # @ingroup l1_meshinfo
1335 def NbFacesOfOrder(self, elementOrder):
1336 return self.mesh.NbFacesOfOrder(elementOrder)
1338 ## Returns the number of triangles in the mesh
1339 # @return an integer value
1340 # @ingroup l1_meshinfo
1341 def NbTriangles(self):
1342 return self.mesh.NbTriangles()
1344 ## Returns the number of triangles with the given order in the mesh
1345 # @param elementOrder is the order of elements:
1346 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1347 # @return an integer value
1348 # @ingroup l1_meshinfo
1349 def NbTrianglesOfOrder(self, elementOrder):
1350 return self.mesh.NbTrianglesOfOrder(elementOrder)
1352 ## Returns the number of quadrangles in the mesh
1353 # @return an integer value
1354 # @ingroup l1_meshinfo
1355 def NbQuadrangles(self):
1356 return self.mesh.NbQuadrangles()
1358 ## Returns the number of quadrangles with the given order in the mesh
1359 # @param elementOrder the order of elements:
1360 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1361 # @return an integer value
1362 # @ingroup l1_meshinfo
1363 def NbQuadranglesOfOrder(self, elementOrder):
1364 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1366 ## Returns the number of polygons in the mesh
1367 # @return an integer value
1368 # @ingroup l1_meshinfo
1369 def NbPolygons(self):
1370 return self.mesh.NbPolygons()
1372 ## Returns the number of volumes in the mesh
1373 # @return an integer value
1374 # @ingroup l1_meshinfo
1375 def NbVolumes(self):
1376 return self.mesh.NbVolumes()
1378 ## Returns the number of volumes with the given order in the mesh
1379 # @param elementOrder the order of elements:
1380 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1381 # @return an integer value
1382 # @ingroup l1_meshinfo
1383 def NbVolumesOfOrder(self, elementOrder):
1384 return self.mesh.NbVolumesOfOrder(elementOrder)
1386 ## Returns the number of tetrahedrons in the mesh
1387 # @return an integer value
1388 # @ingroup l1_meshinfo
1390 return self.mesh.NbTetras()
1392 ## Returns the number of tetrahedrons with the given order in the mesh
1393 # @param elementOrder the order of elements:
1394 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1395 # @return an integer value
1396 # @ingroup l1_meshinfo
1397 def NbTetrasOfOrder(self, elementOrder):
1398 return self.mesh.NbTetrasOfOrder(elementOrder)
1400 ## Returns the number of hexahedrons in the mesh
1401 # @return an integer value
1402 # @ingroup l1_meshinfo
1404 return self.mesh.NbHexas()
1406 ## Returns the number of hexahedrons with the given order in the mesh
1407 # @param elementOrder the order of elements:
1408 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1409 # @return an integer value
1410 # @ingroup l1_meshinfo
1411 def NbHexasOfOrder(self, elementOrder):
1412 return self.mesh.NbHexasOfOrder(elementOrder)
1414 ## Returns the number of pyramids in the mesh
1415 # @return an integer value
1416 # @ingroup l1_meshinfo
1417 def NbPyramids(self):
1418 return self.mesh.NbPyramids()
1420 ## Returns the number of pyramids with the given order in the mesh
1421 # @param elementOrder the order of elements:
1422 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1423 # @return an integer value
1424 # @ingroup l1_meshinfo
1425 def NbPyramidsOfOrder(self, elementOrder):
1426 return self.mesh.NbPyramidsOfOrder(elementOrder)
1428 ## Returns the number of prisms in the mesh
1429 # @return an integer value
1430 # @ingroup l1_meshinfo
1432 return self.mesh.NbPrisms()
1434 ## Returns the number of prisms with the given order in the mesh
1435 # @param elementOrder the order of elements:
1436 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1437 # @return an integer value
1438 # @ingroup l1_meshinfo
1439 def NbPrismsOfOrder(self, elementOrder):
1440 return self.mesh.NbPrismsOfOrder(elementOrder)
1442 ## Returns the number of polyhedrons in the mesh
1443 # @return an integer value
1444 # @ingroup l1_meshinfo
1445 def NbPolyhedrons(self):
1446 return self.mesh.NbPolyhedrons()
1448 ## Returns the number of submeshes in the mesh
1449 # @return an integer value
1450 # @ingroup l1_meshinfo
1451 def NbSubMesh(self):
1452 return self.mesh.NbSubMesh()
1454 ## Returns the list of mesh elements IDs
1455 # @return the list of integer values
1456 # @ingroup l1_meshinfo
1457 def GetElementsId(self):
1458 return self.mesh.GetElementsId()
1460 ## Returns the list of IDs of mesh elements with the given type
1461 # @param elementType the required type of elements
1462 # @return list of integer values
1463 # @ingroup l1_meshinfo
1464 def GetElementsByType(self, elementType):
1465 return self.mesh.GetElementsByType(elementType)
1467 ## Returns the list of mesh nodes IDs
1468 # @return the list of integer values
1469 # @ingroup l1_meshinfo
1470 def GetNodesId(self):
1471 return self.mesh.GetNodesId()
1473 # Get the information about mesh elements:
1474 # ------------------------------------
1476 ## Returns the type of mesh element
1477 # @return the value from SMESH::ElementType enumeration
1478 # @ingroup l1_meshinfo
1479 def GetElementType(self, id, iselem):
1480 return self.mesh.GetElementType(id, iselem)
1482 ## Returns the list of submesh elements IDs
1483 # @param Shape a geom object(subshape) IOR
1484 # Shape must be the subshape of a ShapeToMesh()
1485 # @return the list of integer values
1486 # @ingroup l1_meshinfo
1487 def GetSubMeshElementsId(self, Shape):
1488 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1489 ShapeID = Shape.GetSubShapeIndices()[0]
1492 return self.mesh.GetSubMeshElementsId(ShapeID)
1494 ## Returns the list of submesh nodes IDs
1495 # @param Shape a geom object(subshape) IOR
1496 # Shape must be the subshape of a ShapeToMesh()
1497 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1498 # @return the list of integer values
1499 # @ingroup l1_meshinfo
1500 def GetSubMeshNodesId(self, Shape, all):
1501 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1502 ShapeID = Shape.GetSubShapeIndices()[0]
1505 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1507 ## Returns the list of IDs of submesh elements with the given type
1508 # @param Shape a geom object(subshape) IOR
1509 # Shape must be a subshape of a ShapeToMesh()
1510 # @return the list of integer values
1511 # @ingroup l1_meshinfo
1512 def GetSubMeshElementType(self, Shape):
1513 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1514 ShapeID = Shape.GetSubShapeIndices()[0]
1517 return self.mesh.GetSubMeshElementType(ShapeID)
1519 ## Gets the mesh description
1520 # @return string value
1521 # @ingroup l1_meshinfo
1523 return self.mesh.Dump()
1526 # Get the information about nodes and elements of a mesh by its IDs:
1527 # -----------------------------------------------------------
1529 ## Gets XYZ coordinates of a node
1530 # \n If there is no nodes for the given ID - returns an empty list
1531 # @return a list of double precision values
1532 # @ingroup l1_meshinfo
1533 def GetNodeXYZ(self, id):
1534 return self.mesh.GetNodeXYZ(id)
1536 ## Returns list of IDs of inverse elements for the given node
1537 # \n If there is no node for the given ID - returns an empty list
1538 # @return a list of integer values
1539 # @ingroup l1_meshinfo
1540 def GetNodeInverseElements(self, id):
1541 return self.mesh.GetNodeInverseElements(id)
1543 ## @brief Returns the position of a node on the shape
1544 # @return SMESH::NodePosition
1545 # @ingroup l1_meshinfo
1546 def GetNodePosition(self,NodeID):
1547 return self.mesh.GetNodePosition(NodeID)
1549 ## If the given element is a node, returns the ID of shape
1550 # \n If there is no node for the given ID - returns -1
1551 # @return an integer value
1552 # @ingroup l1_meshinfo
1553 def GetShapeID(self, id):
1554 return self.mesh.GetShapeID(id)
1556 ## Returns the ID of the result shape after
1557 # FindShape() from SMESH_MeshEditor for the given element
1558 # \n If there is no element for the given ID - returns -1
1559 # @return an integer value
1560 # @ingroup l1_meshinfo
1561 def GetShapeIDForElem(self,id):
1562 return self.mesh.GetShapeIDForElem(id)
1564 ## Returns the number of nodes for the given element
1565 # \n If there is no element for the given ID - returns -1
1566 # @return an integer value
1567 # @ingroup l1_meshinfo
1568 def GetElemNbNodes(self, id):
1569 return self.mesh.GetElemNbNodes(id)
1571 ## Returns the node ID the given index for the given element
1572 # \n If there is no element for the given ID - returns -1
1573 # \n If there is no node for the given index - returns -2
1574 # @return an integer value
1575 # @ingroup l1_meshinfo
1576 def GetElemNode(self, id, index):
1577 return self.mesh.GetElemNode(id, index)
1579 ## Returns the IDs of nodes of the given element
1580 # @return a list of integer values
1581 # @ingroup l1_meshinfo
1582 def GetElemNodes(self, id):
1583 return self.mesh.GetElemNodes(id)
1585 ## Returns true if the given node is the medium node in the given quadratic element
1586 # @ingroup l1_meshinfo
1587 def IsMediumNode(self, elementID, nodeID):
1588 return self.mesh.IsMediumNode(elementID, nodeID)
1590 ## Returns true if the given node is the medium node in one of quadratic elements
1591 # @ingroup l1_meshinfo
1592 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1593 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1595 ## Returns the number of edges for the given element
1596 # @ingroup l1_meshinfo
1597 def ElemNbEdges(self, id):
1598 return self.mesh.ElemNbEdges(id)
1600 ## Returns the number of faces for the given element
1601 # @ingroup l1_meshinfo
1602 def ElemNbFaces(self, id):
1603 return self.mesh.ElemNbFaces(id)
1605 ## Returns true if the given element is a polygon
1606 # @ingroup l1_meshinfo
1607 def IsPoly(self, id):
1608 return self.mesh.IsPoly(id)
1610 ## Returns true if the given element is quadratic
1611 # @ingroup l1_meshinfo
1612 def IsQuadratic(self, id):
1613 return self.mesh.IsQuadratic(id)
1615 ## Returns XYZ coordinates of the barycenter of the given element
1616 # \n If there is no element for the given ID - returns an empty list
1617 # @return a list of three double values
1618 # @ingroup l1_meshinfo
1619 def BaryCenter(self, id):
1620 return self.mesh.BaryCenter(id)
1623 # Mesh edition (SMESH_MeshEditor functionality):
1624 # ---------------------------------------------
1626 ## Removes the elements from the mesh by ids
1627 # @param IDsOfElements is a list of ids of elements to remove
1628 # @return True or False
1629 # @ingroup l2_modif_del
1630 def RemoveElements(self, IDsOfElements):
1631 return self.editor.RemoveElements(IDsOfElements)
1633 ## Removes nodes from mesh by ids
1634 # @param IDsOfNodes is a list of ids of nodes to remove
1635 # @return True or False
1636 # @ingroup l2_modif_del
1637 def RemoveNodes(self, IDsOfNodes):
1638 return self.editor.RemoveNodes(IDsOfNodes)
1640 ## Add a node to the mesh by coordinates
1641 # @return Id of the new node
1642 # @ingroup l2_modif_add
1643 def AddNode(self, x, y, z):
1644 return self.editor.AddNode( x, y, z)
1646 ## Creates a linear or quadratic edge (this is determined
1647 # by the number of given nodes).
1648 # @param IDsOfNodes the list of node IDs for creation of the element.
1649 # The order of nodes in this list should correspond to the description
1650 # of MED. \n This description is located by the following link:
1651 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1652 # @return the Id of the new edge
1653 # @ingroup l2_modif_add
1654 def AddEdge(self, IDsOfNodes):
1655 return self.editor.AddEdge(IDsOfNodes)
1657 ## Creates a linear or quadratic face (this is determined
1658 # by the number of given nodes).
1659 # @param IDsOfNodes the list of node IDs for creation of the element.
1660 # The order of nodes in this list should correspond to the description
1661 # of MED. \n This description is located by the following link:
1662 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1663 # @return the Id of the new face
1664 # @ingroup l2_modif_add
1665 def AddFace(self, IDsOfNodes):
1666 return self.editor.AddFace(IDsOfNodes)
1668 ## Adds a polygonal face to the mesh by the list of node IDs
1669 # @param IdsOfNodes the list of node IDs for creation of the element.
1670 # @return the Id of the new face
1671 # @ingroup l2_modif_add
1672 def AddPolygonalFace(self, IdsOfNodes):
1673 return self.editor.AddPolygonalFace(IdsOfNodes)
1675 ## Creates both simple and quadratic volume (this is determined
1676 # by the number of given nodes).
1677 # @param IDsOfNodes the list of node IDs for creation of the element.
1678 # The order of nodes in this list should correspond to the description
1679 # of MED. \n This description is located by the following link:
1680 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1681 # @return the Id of the new volumic element
1682 # @ingroup l2_modif_add
1683 def AddVolume(self, IDsOfNodes):
1684 return self.editor.AddVolume(IDsOfNodes)
1686 ## Creates a volume of many faces, giving nodes for each face.
1687 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1688 # @param Quantities the list of integer values, Quantities[i]
1689 # gives the quantity of nodes in face number i.
1690 # @return the Id of the new volumic element
1691 # @ingroup l2_modif_add
1692 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1693 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1695 ## Creates a volume of many faces, giving the IDs of the existing faces.
1696 # @param IdsOfFaces the list of face IDs for volume creation.
1698 # Note: The created volume will refer only to the nodes
1699 # of the given faces, not to the faces themselves.
1700 # @return the Id of the new volumic element
1701 # @ingroup l2_modif_add
1702 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1703 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1706 ## @brief Binds a node to a vertex
1707 # @param NodeID a node ID
1708 # @param Vertex a vertex or vertex ID
1709 # @return True if succeed else raises an exception
1710 # @ingroup l2_modif_add
1711 def SetNodeOnVertex(self, NodeID, Vertex):
1712 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1713 VertexID = Vertex.GetSubShapeIndices()[0]
1717 self.editor.SetNodeOnVertex(NodeID, VertexID)
1718 except SALOME.SALOME_Exception, inst:
1719 raise ValueError, inst.details.text
1723 ## @brief Stores the node position on an edge
1724 # @param NodeID a node ID
1725 # @param Edge an edge or edge ID
1726 # @param paramOnEdge a parameter on the edge where the node is located
1727 # @return True if succeed else raises an exception
1728 # @ingroup l2_modif_add
1729 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1730 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1731 EdgeID = Edge.GetSubShapeIndices()[0]
1735 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1736 except SALOME.SALOME_Exception, inst:
1737 raise ValueError, inst.details.text
1740 ## @brief Stores node position on a face
1741 # @param NodeID a node ID
1742 # @param Face a face or face ID
1743 # @param u U parameter on the face where the node is located
1744 # @param v V parameter on the face where the node is located
1745 # @return True if succeed else raises an exception
1746 # @ingroup l2_modif_add
1747 def SetNodeOnFace(self, NodeID, Face, u, v):
1748 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1749 FaceID = Face.GetSubShapeIndices()[0]
1753 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1754 except SALOME.SALOME_Exception, inst:
1755 raise ValueError, inst.details.text
1758 ## @brief Binds a node to a solid
1759 # @param NodeID a node ID
1760 # @param Solid a solid or solid ID
1761 # @return True if succeed else raises an exception
1762 # @ingroup l2_modif_add
1763 def SetNodeInVolume(self, NodeID, Solid):
1764 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1765 SolidID = Solid.GetSubShapeIndices()[0]
1769 self.editor.SetNodeInVolume(NodeID, SolidID)
1770 except SALOME.SALOME_Exception, inst:
1771 raise ValueError, inst.details.text
1774 ## @brief Bind an element to a shape
1775 # @param ElementID an element ID
1776 # @param Shape a shape or shape ID
1777 # @return True if succeed else raises an exception
1778 # @ingroup l2_modif_add
1779 def SetMeshElementOnShape(self, ElementID, Shape):
1780 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1781 ShapeID = Shape.GetSubShapeIndices()[0]
1785 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1786 except SALOME.SALOME_Exception, inst:
1787 raise ValueError, inst.details.text
1791 ## Moves the node with the given id
1792 # @param NodeID the id of the node
1793 # @param x a new X coordinate
1794 # @param y a new Y coordinate
1795 # @param z a new Z coordinate
1796 # @return True if succeed else False
1797 # @ingroup l2_modif_movenode
1798 def MoveNode(self, NodeID, x, y, z):
1799 return self.editor.MoveNode(NodeID, x, y, z)
1801 ## Finds the node closest to a point
1802 # @param x the X coordinate of a point
1803 # @param y the Y coordinate of a point
1804 # @param z the Z coordinate of a point
1805 # @return the ID of a node
1806 # @ingroup l2_modif_throughp
1807 def FindNodeClosestTo(self, x, y, z):
1808 preview = self.mesh.GetMeshEditPreviewer()
1809 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1811 ## Finds the node closest to a point and moves it to a point location
1812 # @param x the X coordinate of a point
1813 # @param y the Y coordinate of a point
1814 # @param z the Z coordinate of a point
1815 # @return the ID of a moved node
1816 # @ingroup l2_modif_throughp
1817 def MeshToPassThroughAPoint(self, x, y, z):
1818 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1820 ## Replaces two neighbour triangles sharing Node1-Node2 link
1821 # with the triangles built on the same 4 nodes but having other common link.
1822 # @param NodeID1 the ID of the first node
1823 # @param NodeID2 the ID of the second node
1824 # @return false if proper faces were not found
1825 # @ingroup l2_modif_invdiag
1826 def InverseDiag(self, NodeID1, NodeID2):
1827 return self.editor.InverseDiag(NodeID1, NodeID2)
1829 ## Replaces two neighbour triangles sharing Node1-Node2 link
1830 # with a quadrangle built on the same 4 nodes.
1831 # @param NodeID1 the ID of the first node
1832 # @param NodeID2 the ID of the second node
1833 # @return false if proper faces were not found
1834 # @ingroup l2_modif_unitetri
1835 def DeleteDiag(self, NodeID1, NodeID2):
1836 return self.editor.DeleteDiag(NodeID1, NodeID2)
1838 ## Reorients elements by ids
1839 # @param IDsOfElements if undefined reorients all mesh elements
1840 # @return True if succeed else False
1841 # @ingroup l2_modif_changori
1842 def Reorient(self, IDsOfElements=None):
1843 if IDsOfElements == None:
1844 IDsOfElements = self.GetElementsId()
1845 return self.editor.Reorient(IDsOfElements)
1847 ## Reorients all elements of the object
1848 # @param theObject mesh, submesh or group
1849 # @return True if succeed else False
1850 # @ingroup l2_modif_changori
1851 def ReorientObject(self, theObject):
1852 if ( isinstance( theObject, Mesh )):
1853 theObject = theObject.GetMesh()
1854 return self.editor.ReorientObject(theObject)
1856 ## Fuses the neighbouring triangles into quadrangles.
1857 # @param IDsOfElements The triangles to be fused,
1858 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1859 # @param MaxAngle is the maximum angle between element normals at which the fusion
1860 # is still performed; theMaxAngle is mesured in radians.
1861 # @return TRUE in case of success, FALSE otherwise.
1862 # @ingroup l2_modif_unitetri
1863 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1864 if IDsOfElements == []:
1865 IDsOfElements = self.GetElementsId()
1866 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1868 ## Fuses the neighbouring triangles of the object into quadrangles
1869 # @param theObject is mesh, submesh or group
1870 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1871 # @param MaxAngle a max angle between element normals at which the fusion
1872 # is still performed; theMaxAngle is mesured in radians.
1873 # @return TRUE in case of success, FALSE otherwise.
1874 # @ingroup l2_modif_unitetri
1875 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1876 if ( isinstance( theObject, Mesh )):
1877 theObject = theObject.GetMesh()
1878 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1880 ## Splits quadrangles into triangles.
1881 # @param IDsOfElements the faces to be splitted.
1882 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1883 # @return TRUE in case of success, FALSE otherwise.
1884 # @ingroup l2_modif_cutquadr
1885 def QuadToTri (self, IDsOfElements, theCriterion):
1886 if IDsOfElements == []:
1887 IDsOfElements = self.GetElementsId()
1888 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1890 ## Splits quadrangles into triangles.
1891 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1892 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1893 # @return TRUE in case of success, FALSE otherwise.
1894 # @ingroup l2_modif_cutquadr
1895 def QuadToTriObject (self, theObject, theCriterion):
1896 if ( isinstance( theObject, Mesh )):
1897 theObject = theObject.GetMesh()
1898 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1900 ## Splits quadrangles into triangles.
1901 # @param IDsOfElements the faces to be splitted
1902 # @param Diag13 is used to choose a diagonal for splitting.
1903 # @return TRUE in case of success, FALSE otherwise.
1904 # @ingroup l2_modif_cutquadr
1905 def SplitQuad (self, IDsOfElements, Diag13):
1906 if IDsOfElements == []:
1907 IDsOfElements = self.GetElementsId()
1908 return self.editor.SplitQuad(IDsOfElements, Diag13)
1910 ## Splits quadrangles into triangles.
1911 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1912 # @param Diag13 is used to choose a diagonal for splitting.
1913 # @return TRUE in case of success, FALSE otherwise.
1914 # @ingroup l2_modif_cutquadr
1915 def SplitQuadObject (self, theObject, Diag13):
1916 if ( isinstance( theObject, Mesh )):
1917 theObject = theObject.GetMesh()
1918 return self.editor.SplitQuadObject(theObject, Diag13)
1920 ## Finds a better splitting of the given quadrangle.
1921 # @param IDOfQuad the ID of the quadrangle to be splitted.
1922 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1923 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1924 # diagonal is better, 0 if error occurs.
1925 # @ingroup l2_modif_cutquadr
1926 def BestSplit (self, IDOfQuad, theCriterion):
1927 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1929 ## Splits quadrangle faces near triangular facets of volumes
1931 # @ingroup l1_auxiliary
1932 def SplitQuadsNearTriangularFacets(self):
1933 faces_array = self.GetElementsByType(SMESH.FACE)
1934 for face_id in faces_array:
1935 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1936 quad_nodes = self.mesh.GetElemNodes(face_id)
1937 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1938 isVolumeFound = False
1939 for node1_elem in node1_elems:
1940 if not isVolumeFound:
1941 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1942 nb_nodes = self.GetElemNbNodes(node1_elem)
1943 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1944 volume_elem = node1_elem
1945 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1946 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1947 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1948 isVolumeFound = True
1949 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1950 self.SplitQuad([face_id], False) # diagonal 2-4
1951 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1952 isVolumeFound = True
1953 self.SplitQuad([face_id], True) # diagonal 1-3
1954 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1955 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1956 isVolumeFound = True
1957 self.SplitQuad([face_id], True) # diagonal 1-3
1959 ## @brief Splits hexahedrons into tetrahedrons.
1961 # This operation uses pattern mapping functionality for splitting.
1962 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1963 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1964 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1965 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1966 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
1967 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1968 # @return TRUE in case of success, FALSE otherwise.
1969 # @ingroup l1_auxiliary
1970 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1971 # Pattern: 5.---------.6
1976 # (0,0,1) 4.---------.7 * |
1983 # (0,0,0) 0.---------.3
1984 pattern_tetra = "!!! Nb of points: \n 8 \n\
1994 !!! Indices of points of 6 tetras: \n\
2002 pattern = self.smeshpyD.GetPattern()
2003 isDone = pattern.LoadFromFile(pattern_tetra)
2005 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2008 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2009 isDone = pattern.MakeMesh(self.mesh, False, False)
2010 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2012 # split quafrangle faces near triangular facets of volumes
2013 self.SplitQuadsNearTriangularFacets()
2017 ## @brief Split hexahedrons into prisms.
2019 # Uses the pattern mapping functionality for splitting.
2020 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2021 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2022 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2023 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2024 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2025 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2026 # @return TRUE in case of success, FALSE otherwise.
2027 # @ingroup l1_auxiliary
2028 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2029 # Pattern: 5.---------.6
2034 # (0,0,1) 4.---------.7 |
2041 # (0,0,0) 0.---------.3
2042 pattern_prism = "!!! Nb of points: \n 8 \n\
2052 !!! Indices of points of 2 prisms: \n\
2056 pattern = self.smeshpyD.GetPattern()
2057 isDone = pattern.LoadFromFile(pattern_prism)
2059 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2062 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2063 isDone = pattern.MakeMesh(self.mesh, False, False)
2064 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2066 # Splits quafrangle faces near triangular facets of volumes
2067 self.SplitQuadsNearTriangularFacets()
2071 ## Smoothes elements
2072 # @param IDsOfElements the list if ids of elements to smooth
2073 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2074 # Note that nodes built on edges and boundary nodes are always fixed.
2075 # @param MaxNbOfIterations the maximum number of iterations
2076 # @param MaxAspectRatio varies in range [1.0, inf]
2077 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2078 # @return TRUE in case of success, FALSE otherwise.
2079 # @ingroup l2_modif_smooth
2080 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2081 MaxNbOfIterations, MaxAspectRatio, Method):
2082 if IDsOfElements == []:
2083 IDsOfElements = self.GetElementsId()
2084 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2085 MaxNbOfIterations, MaxAspectRatio, Method)
2087 ## Smoothes elements which belong to the given object
2088 # @param theObject the object to smooth
2089 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2090 # Note that nodes built on edges and boundary nodes are always fixed.
2091 # @param MaxNbOfIterations the maximum number of iterations
2092 # @param MaxAspectRatio varies in range [1.0, inf]
2093 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2094 # @return TRUE in case of success, FALSE otherwise.
2095 # @ingroup l2_modif_smooth
2096 def SmoothObject(self, theObject, IDsOfFixedNodes,
2097 MaxNbOfIterations, MaxAspectRatio, Method):
2098 if ( isinstance( theObject, Mesh )):
2099 theObject = theObject.GetMesh()
2100 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2101 MaxNbOfIterations, MaxAspectRatio, Method)
2103 ## Parametrically smoothes the given elements
2104 # @param IDsOfElements the list if ids of elements to smooth
2105 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2106 # Note that nodes built on edges and boundary nodes are always fixed.
2107 # @param MaxNbOfIterations the maximum number of iterations
2108 # @param MaxAspectRatio varies in range [1.0, inf]
2109 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2110 # @return TRUE in case of success, FALSE otherwise.
2111 # @ingroup l2_modif_smooth
2112 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2113 MaxNbOfIterations, MaxAspectRatio, Method):
2114 if IDsOfElements == []:
2115 IDsOfElements = self.GetElementsId()
2116 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2117 MaxNbOfIterations, MaxAspectRatio, Method)
2119 ## Parametrically smoothes the elements which belong to the given object
2120 # @param theObject the object to smooth
2121 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2122 # Note that nodes built on edges and boundary nodes are always fixed.
2123 # @param MaxNbOfIterations the maximum number of iterations
2124 # @param MaxAspectRatio varies in range [1.0, inf]
2125 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2126 # @return TRUE in case of success, FALSE otherwise.
2127 # @ingroup l2_modif_smooth
2128 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2129 MaxNbOfIterations, MaxAspectRatio, Method):
2130 if ( isinstance( theObject, Mesh )):
2131 theObject = theObject.GetMesh()
2132 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2133 MaxNbOfIterations, MaxAspectRatio, Method)
2135 ## Converts the mesh to quadratic, deletes old elements, replacing
2136 # them with quadratic with the same id.
2137 # @ingroup l2_modif_tofromqu
2138 def ConvertToQuadratic(self, theForce3d):
2139 self.editor.ConvertToQuadratic(theForce3d)
2141 ## Converts the mesh from quadratic to ordinary,
2142 # deletes old quadratic elements, \n replacing
2143 # them with ordinary mesh elements with the same id.
2144 # @return TRUE in case of success, FALSE otherwise.
2145 # @ingroup l2_modif_tofromqu
2146 def ConvertFromQuadratic(self):
2147 return self.editor.ConvertFromQuadratic()
2149 ## Renumber mesh nodes
2150 # @ingroup l2_modif_renumber
2151 def RenumberNodes(self):
2152 self.editor.RenumberNodes()
2154 ## Renumber mesh elements
2155 # @ingroup l2_modif_renumber
2156 def RenumberElements(self):
2157 self.editor.RenumberElements()
2159 ## Generates new elements by rotation of the elements around the axis
2160 # @param IDsOfElements the list of ids of elements to sweep
2161 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2162 # @param AngleInRadians the angle of Rotation
2163 # @param NbOfSteps the number of steps
2164 # @param Tolerance tolerance
2165 # @param MakeGroups forces the generation of new groups from existing ones
2166 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2167 # of all steps, else - size of each step
2168 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2169 # @ingroup l2_modif_extrurev
2170 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2171 MakeGroups=False, TotalAngle=False):
2172 if IDsOfElements == []:
2173 IDsOfElements = self.GetElementsId()
2174 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2175 Axis = self.smeshpyD.GetAxisStruct(Axis)
2176 if TotalAngle and NbOfSteps:
2177 AngleInRadians /= NbOfSteps
2179 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2180 AngleInRadians, NbOfSteps, Tolerance)
2181 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2184 ## Generates new elements by rotation of the elements of object around the axis
2185 # @param theObject object which elements should be sweeped
2186 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2187 # @param AngleInRadians the angle of Rotation
2188 # @param NbOfSteps number of steps
2189 # @param Tolerance tolerance
2190 # @param MakeGroups forces the generation of new groups from existing ones
2191 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2192 # of all steps, else - size of each step
2193 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2194 # @ingroup l2_modif_extrurev
2195 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2196 MakeGroups=False, TotalAngle=False):
2197 if ( isinstance( theObject, Mesh )):
2198 theObject = theObject.GetMesh()
2199 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2200 Axis = self.smeshpyD.GetAxisStruct(Axis)
2201 if TotalAngle and NbOfSteps:
2202 AngleInRadians /= NbOfSteps
2204 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2205 NbOfSteps, Tolerance)
2206 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2209 ## Generates new elements by extrusion of the elements with given ids
2210 # @param IDsOfElements the list of elements ids for extrusion
2211 # @param StepVector vector, defining the direction and value of extrusion
2212 # @param NbOfSteps the number of steps
2213 # @param MakeGroups forces the generation of new groups from existing ones
2214 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2215 # @ingroup l2_modif_extrurev
2216 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2217 if IDsOfElements == []:
2218 IDsOfElements = self.GetElementsId()
2219 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2220 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2222 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2223 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2226 ## Generates new elements by extrusion of the elements with given ids
2227 # @param IDsOfElements is ids of elements
2228 # @param StepVector vector, defining the direction and value of extrusion
2229 # @param NbOfSteps the number of steps
2230 # @param ExtrFlags sets flags for extrusion
2231 # @param SewTolerance uses for comparing locations of nodes if flag
2232 # EXTRUSION_FLAG_SEW is set
2233 # @param MakeGroups forces the generation of new groups from existing ones
2234 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2235 # @ingroup l2_modif_extrurev
2236 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2237 ExtrFlags, SewTolerance, MakeGroups=False):
2238 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2239 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2241 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2242 ExtrFlags, SewTolerance)
2243 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2244 ExtrFlags, SewTolerance)
2247 ## Generates new elements by extrusion of the elements which belong to the object
2248 # @param theObject the object which elements should be processed
2249 # @param StepVector vector, defining the direction and value of extrusion
2250 # @param NbOfSteps the number of steps
2251 # @param MakeGroups forces the generation of new groups from existing ones
2252 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2253 # @ingroup l2_modif_extrurev
2254 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2255 if ( isinstance( theObject, Mesh )):
2256 theObject = theObject.GetMesh()
2257 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2258 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2260 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2261 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2264 ## Generates new elements by extrusion of the elements which belong to the object
2265 # @param theObject object which elements should be processed
2266 # @param StepVector vector, defining the direction and value of extrusion
2267 # @param NbOfSteps the number of steps
2268 # @param MakeGroups to generate new groups from existing ones
2269 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2270 # @ingroup l2_modif_extrurev
2271 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2272 if ( isinstance( theObject, Mesh )):
2273 theObject = theObject.GetMesh()
2274 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2275 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2277 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2278 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2281 ## Generates new elements by extrusion of the elements which belong to the object
2282 # @param theObject object which elements should be processed
2283 # @param StepVector vector, defining the direction and value of extrusion
2284 # @param NbOfSteps the number of steps
2285 # @param MakeGroups forces the generation of new groups from existing ones
2286 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2287 # @ingroup l2_modif_extrurev
2288 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2289 if ( isinstance( theObject, Mesh )):
2290 theObject = theObject.GetMesh()
2291 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2292 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2294 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2295 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2298 ## Generates new elements by extrusion of the given elements
2299 # The path of extrusion must be a meshed edge.
2300 # @param IDsOfElements ids of elements
2301 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2302 # @param PathShape shape(edge) defines the sub-mesh for the path
2303 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2304 # @param HasAngles allows the shape to be rotated around the path
2305 # to get the resulting mesh in a helical fashion
2306 # @param Angles list of angles
2307 # @param HasRefPoint allows using the reference point
2308 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2309 # The User can specify any point as the Reference Point.
2310 # @param MakeGroups forces the generation of new groups from existing ones
2311 # @param LinearVariation forces the computation of rotation angles as linear
2312 # variation of the given Angles along path steps
2313 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2314 # only SMESH::Extrusion_Error otherwise
2315 # @ingroup l2_modif_extrurev
2316 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2317 HasAngles, Angles, HasRefPoint, RefPoint,
2318 MakeGroups=False, LinearVariation=False):
2319 if IDsOfElements == []:
2320 IDsOfElements = self.GetElementsId()
2321 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2322 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2324 if ( isinstance( PathMesh, Mesh )):
2325 PathMesh = PathMesh.GetMesh()
2326 if HasAngles and Angles and LinearVariation:
2327 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2330 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2331 PathShape, NodeStart, HasAngles,
2332 Angles, HasRefPoint, RefPoint)
2333 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2334 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2336 ## Generates new elements by extrusion of the elements which belong to the object
2337 # The path of extrusion must be a meshed edge.
2338 # @param theObject the object which elements should be processed
2339 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2340 # @param PathShape shape(edge) defines the sub-mesh for the path
2341 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2342 # @param HasAngles allows the shape to be rotated around the path
2343 # to get the resulting mesh in a helical fashion
2344 # @param Angles list of angles
2345 # @param HasRefPoint allows using the reference point
2346 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2347 # The User can specify any point as the Reference Point.
2348 # @param MakeGroups forces the generation of new groups from existing ones
2349 # @param LinearVariation forces the computation of rotation angles as linear
2350 # variation of the given Angles along path steps
2351 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2352 # only SMESH::Extrusion_Error otherwise
2353 # @ingroup l2_modif_extrurev
2354 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2355 HasAngles, Angles, HasRefPoint, RefPoint,
2356 MakeGroups=False, LinearVariation=False):
2357 if ( isinstance( theObject, Mesh )):
2358 theObject = theObject.GetMesh()
2359 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2360 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2361 if ( isinstance( PathMesh, Mesh )):
2362 PathMesh = PathMesh.GetMesh()
2363 if HasAngles and Angles and LinearVariation:
2364 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2367 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2368 PathShape, NodeStart, HasAngles,
2369 Angles, HasRefPoint, RefPoint)
2370 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2371 NodeStart, HasAngles, Angles, HasRefPoint,
2374 ## Creates a symmetrical copy of mesh elements
2375 # @param IDsOfElements list of elements ids
2376 # @param Mirror is AxisStruct or geom object(point, line, plane)
2377 # @param theMirrorType is POINT, AXIS or PLANE
2378 # If the Mirror is a geom object this parameter is unnecessary
2379 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2380 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2381 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2382 # @ingroup l2_modif_trsf
2383 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2384 if IDsOfElements == []:
2385 IDsOfElements = self.GetElementsId()
2386 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2387 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2388 if Copy and MakeGroups:
2389 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2390 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2393 ## Creates a new mesh by a symmetrical copy of mesh elements
2394 # @param IDsOfElements the list of elements ids
2395 # @param Mirror is AxisStruct or geom object (point, line, plane)
2396 # @param theMirrorType is POINT, AXIS or PLANE
2397 # If the Mirror is a geom object this parameter is unnecessary
2398 # @param MakeGroups to generate new groups from existing ones
2399 # @param NewMeshName a name of the new mesh to create
2400 # @return instance of Mesh class
2401 # @ingroup l2_modif_trsf
2402 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2403 if IDsOfElements == []:
2404 IDsOfElements = self.GetElementsId()
2405 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2406 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2407 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2408 MakeGroups, NewMeshName)
2409 return Mesh(self.smeshpyD,self.geompyD,mesh)
2411 ## Creates a symmetrical copy of the object
2412 # @param theObject mesh, submesh or group
2413 # @param Mirror AxisStruct or geom object (point, line, plane)
2414 # @param theMirrorType is POINT, AXIS or PLANE
2415 # If the Mirror is a geom object this parameter is unnecessary
2416 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2417 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2418 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2419 # @ingroup l2_modif_trsf
2420 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2421 if ( isinstance( theObject, Mesh )):
2422 theObject = theObject.GetMesh()
2423 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2424 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2425 if Copy and MakeGroups:
2426 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2427 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2430 ## Creates a new mesh by a symmetrical copy of the object
2431 # @param theObject mesh, submesh or group
2432 # @param Mirror AxisStruct or geom object (point, line, plane)
2433 # @param theMirrorType POINT, AXIS or PLANE
2434 # If the Mirror is a geom object this parameter is unnecessary
2435 # @param MakeGroups forces the generation of new groups from existing ones
2436 # @param NewMeshName the name of the new mesh to create
2437 # @return instance of Mesh class
2438 # @ingroup l2_modif_trsf
2439 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2440 if ( isinstance( theObject, Mesh )):
2441 theObject = theObject.GetMesh()
2442 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2443 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2444 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2445 MakeGroups, NewMeshName)
2446 return Mesh( self.smeshpyD,self.geompyD,mesh )
2448 ## Translates the elements
2449 # @param IDsOfElements list of elements ids
2450 # @param Vector the direction of translation (DirStruct or vector)
2451 # @param Copy allows copying the translated elements
2452 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2453 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2454 # @ingroup l2_modif_trsf
2455 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2456 if IDsOfElements == []:
2457 IDsOfElements = self.GetElementsId()
2458 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2459 Vector = self.smeshpyD.GetDirStruct(Vector)
2460 if Copy and MakeGroups:
2461 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2462 self.editor.Translate(IDsOfElements, Vector, Copy)
2465 ## Creates a new mesh of translated elements
2466 # @param IDsOfElements list of elements ids
2467 # @param Vector the direction of translation (DirStruct or vector)
2468 # @param MakeGroups forces the generation of new groups from existing ones
2469 # @param NewMeshName the name of the newly created mesh
2470 # @return instance of Mesh class
2471 # @ingroup l2_modif_trsf
2472 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2473 if IDsOfElements == []:
2474 IDsOfElements = self.GetElementsId()
2475 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2476 Vector = self.smeshpyD.GetDirStruct(Vector)
2477 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2478 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2480 ## Translates the object
2481 # @param theObject the object to translate (mesh, submesh, or group)
2482 # @param Vector direction of translation (DirStruct or geom vector)
2483 # @param Copy allows copying the translated elements
2484 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2485 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2486 # @ingroup l2_modif_trsf
2487 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2488 if ( isinstance( theObject, Mesh )):
2489 theObject = theObject.GetMesh()
2490 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2491 Vector = self.smeshpyD.GetDirStruct(Vector)
2492 if Copy and MakeGroups:
2493 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2494 self.editor.TranslateObject(theObject, Vector, Copy)
2497 ## Creates a new mesh from the translated object
2498 # @param theObject the object to translate (mesh, submesh, or group)
2499 # @param Vector the direction of translation (DirStruct or geom vector)
2500 # @param MakeGroups forces the generation of new groups from existing ones
2501 # @param NewMeshName the name of the newly created mesh
2502 # @return instance of Mesh class
2503 # @ingroup l2_modif_trsf
2504 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2505 if (isinstance(theObject, Mesh)):
2506 theObject = theObject.GetMesh()
2507 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2508 Vector = self.smeshpyD.GetDirStruct(Vector)
2509 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2510 return Mesh( self.smeshpyD, self.geompyD, mesh )
2512 ## Rotates the elements
2513 # @param IDsOfElements list of elements ids
2514 # @param Axis the axis of rotation (AxisStruct or geom line)
2515 # @param AngleInRadians the angle of rotation (in radians)
2516 # @param Copy allows copying the rotated elements
2517 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2518 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2519 # @ingroup l2_modif_trsf
2520 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2521 if IDsOfElements == []:
2522 IDsOfElements = self.GetElementsId()
2523 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2524 Axis = self.smeshpyD.GetAxisStruct(Axis)
2525 if Copy and MakeGroups:
2526 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2527 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2530 ## Creates a new mesh of rotated elements
2531 # @param IDsOfElements list of element ids
2532 # @param Axis the axis of rotation (AxisStruct or geom line)
2533 # @param AngleInRadians the angle of rotation (in radians)
2534 # @param MakeGroups forces the generation of new groups from existing ones
2535 # @param NewMeshName the name of the newly created mesh
2536 # @return instance of Mesh class
2537 # @ingroup l2_modif_trsf
2538 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2539 if IDsOfElements == []:
2540 IDsOfElements = self.GetElementsId()
2541 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2542 Axis = self.smeshpyD.GetAxisStruct(Axis)
2543 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2544 MakeGroups, NewMeshName)
2545 return Mesh( self.smeshpyD, self.geompyD, mesh )
2547 ## Rotates the object
2548 # @param theObject the object to rotate( mesh, submesh, or group)
2549 # @param Axis the axis of rotation (AxisStruct or geom line)
2550 # @param AngleInRadians the angle of rotation (in radians)
2551 # @param Copy allows copying the rotated elements
2552 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2553 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2554 # @ingroup l2_modif_trsf
2555 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2556 if (isinstance(theObject, Mesh)):
2557 theObject = theObject.GetMesh()
2558 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2559 Axis = self.smeshpyD.GetAxisStruct(Axis)
2560 if Copy and MakeGroups:
2561 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2562 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2565 ## Creates a new mesh from the rotated object
2566 # @param theObject the object to rotate (mesh, submesh, or group)
2567 # @param Axis the axis of rotation (AxisStruct or geom line)
2568 # @param AngleInRadians the angle of rotation (in radians)
2569 # @param MakeGroups forces the generation of new groups from existing ones
2570 # @param NewMeshName the name of the newly created mesh
2571 # @return instance of Mesh class
2572 # @ingroup l2_modif_trsf
2573 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2574 if (isinstance( theObject, Mesh )):
2575 theObject = theObject.GetMesh()
2576 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2577 Axis = self.smeshpyD.GetAxisStruct(Axis)
2578 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2579 MakeGroups, NewMeshName)
2580 return Mesh( self.smeshpyD, self.geompyD, mesh )
2582 ## Finds groups of ajacent nodes within Tolerance.
2583 # @param Tolerance the value of tolerance
2584 # @return the list of groups of nodes
2585 # @ingroup l2_modif_trsf
2586 def FindCoincidentNodes (self, Tolerance):
2587 return self.editor.FindCoincidentNodes(Tolerance)
2589 ## Finds groups of ajacent nodes within Tolerance.
2590 # @param Tolerance the value of tolerance
2591 # @param SubMeshOrGroup SubMesh or Group
2592 # @return the list of groups of nodes
2593 # @ingroup l2_modif_trsf
2594 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2595 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2598 # @param GroupsOfNodes the list of groups of nodes
2599 # @ingroup l2_modif_trsf
2600 def MergeNodes (self, GroupsOfNodes):
2601 self.editor.MergeNodes(GroupsOfNodes)
2603 ## Finds the elements built on the same nodes.
2604 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2605 # @return a list of groups of equal elements
2606 # @ingroup l2_modif_trsf
2607 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2608 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2610 ## Merges elements in each given group.
2611 # @param GroupsOfElementsID groups of elements for merging
2612 # @ingroup l2_modif_trsf
2613 def MergeElements(self, GroupsOfElementsID):
2614 self.editor.MergeElements(GroupsOfElementsID)
2616 ## Leaves one element and removes all other elements built on the same nodes.
2617 # @ingroup l2_modif_trsf
2618 def MergeEqualElements(self):
2619 self.editor.MergeEqualElements()
2621 ## Sews free borders
2622 # @return SMESH::Sew_Error
2623 # @ingroup l2_modif_trsf
2624 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2625 FirstNodeID2, SecondNodeID2, LastNodeID2,
2626 CreatePolygons, CreatePolyedrs):
2627 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2628 FirstNodeID2, SecondNodeID2, LastNodeID2,
2629 CreatePolygons, CreatePolyedrs)
2631 ## Sews conform free borders
2632 # @return SMESH::Sew_Error
2633 # @ingroup l2_modif_trsf
2634 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2635 FirstNodeID2, SecondNodeID2):
2636 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2637 FirstNodeID2, SecondNodeID2)
2639 ## Sews border to side
2640 # @return SMESH::Sew_Error
2641 # @ingroup l2_modif_trsf
2642 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2643 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2644 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2645 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2647 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2648 # merged with the nodes of elements of Side2.
2649 # The number of elements in theSide1 and in theSide2 must be
2650 # equal and they should have similar nodal connectivity.
2651 # The nodes to merge should belong to side borders and
2652 # the first node should be linked to the second.
2653 # @return SMESH::Sew_Error
2654 # @ingroup l2_modif_trsf
2655 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2656 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2657 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2658 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2659 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2660 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2662 ## Sets new nodes for the given element.
2663 # @param ide the element id
2664 # @param newIDs nodes ids
2665 # @return If the number of nodes does not correspond to the type of element - returns false
2666 # @ingroup l2_modif_edit
2667 def ChangeElemNodes(self, ide, newIDs):
2668 return self.editor.ChangeElemNodes(ide, newIDs)
2670 ## If during the last operation of MeshEditor some nodes were
2671 # created, this method returns the list of their IDs, \n
2672 # if new nodes were not created - returns empty list
2673 # @return the list of integer values (can be empty)
2674 # @ingroup l1_auxiliary
2675 def GetLastCreatedNodes(self):
2676 return self.editor.GetLastCreatedNodes()
2678 ## If during the last operation of MeshEditor some elements were
2679 # created this method returns the list of their IDs, \n
2680 # if new elements were not created - returns empty list
2681 # @return the list of integer values (can be empty)
2682 # @ingroup l1_auxiliary
2683 def GetLastCreatedElems(self):
2684 return self.editor.GetLastCreatedElems()
2686 ## The mother class to define algorithm, it is not recommended to use it directly.
2689 # @ingroup l2_algorithms
2690 class Mesh_Algorithm:
2691 # @class Mesh_Algorithm
2692 # @brief Class Mesh_Algorithm
2694 #def __init__(self,smesh):
2702 ## Finds a hypothesis in the study by its type name and parameters.
2703 # Finds only the hypotheses created in smeshpyD engine.
2704 # @return SMESH.SMESH_Hypothesis
2705 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2706 study = smeshpyD.GetCurrentStudy()
2707 #to do: find component by smeshpyD object, not by its data type
2708 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2709 if scomp is not None:
2710 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2711 # Check if the root label of the hypotheses exists
2712 if res and hypRoot is not None:
2713 iter = study.NewChildIterator(hypRoot)
2714 # Check all published hypotheses
2716 hypo_so_i = iter.Value()
2717 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2718 if attr is not None:
2719 anIOR = attr.Value()
2720 hypo_o_i = salome.orb.string_to_object(anIOR)
2721 if hypo_o_i is not None:
2722 # Check if this is a hypothesis
2723 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2724 if hypo_i is not None:
2725 # Check if the hypothesis belongs to current engine
2726 if smeshpyD.GetObjectId(hypo_i) > 0:
2727 # Check if this is the required hypothesis
2728 if hypo_i.GetName() == hypname:
2730 if CompareMethod(hypo_i, args):
2744 ## Finds the algorithm in the study by its type name.
2745 # Finds only the algorithms, which have been created in smeshpyD engine.
2746 # @return SMESH.SMESH_Algo
2747 def FindAlgorithm (self, algoname, smeshpyD):
2748 study = smeshpyD.GetCurrentStudy()
2749 #to do: find component by smeshpyD object, not by its data type
2750 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2751 if scomp is not None:
2752 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2753 # Check if the root label of the algorithms exists
2754 if res and hypRoot is not None:
2755 iter = study.NewChildIterator(hypRoot)
2756 # Check all published algorithms
2758 algo_so_i = iter.Value()
2759 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2760 if attr is not None:
2761 anIOR = attr.Value()
2762 algo_o_i = salome.orb.string_to_object(anIOR)
2763 if algo_o_i is not None:
2764 # Check if this is an algorithm
2765 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2766 if algo_i is not None:
2767 # Checks if the algorithm belongs to the current engine
2768 if smeshpyD.GetObjectId(algo_i) > 0:
2769 # Check if this is the required algorithm
2770 if algo_i.GetName() == algoname:
2783 ## If the algorithm is global, returns 0; \n
2784 # else returns the submesh associated to this algorithm.
2785 def GetSubMesh(self):
2788 ## Returns the wrapped mesher.
2789 def GetAlgorithm(self):
2792 ## Gets the list of hypothesis that can be used with this algorithm
2793 def GetCompatibleHypothesis(self):
2796 mylist = self.algo.GetCompatibleHypothesis()
2799 ## Gets the name of the algorithm
2803 ## Sets the name to the algorithm
2804 def SetName(self, name):
2805 SetName(self.algo, name)
2807 ## Gets the id of the algorithm
2809 return self.algo.GetId()
2812 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2814 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2815 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2817 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2819 self.Assign(algo, mesh, geom)
2823 def Assign(self, algo, mesh, geom):
2825 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2832 name = GetName(geom)
2834 name = mesh.geompyD.SubShapeName(geom, piece)
2835 mesh.geompyD.addToStudyInFather(piece, geom, name)
2836 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2839 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2840 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2842 def CompareHyp (self, hyp, args):
2843 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2846 def CompareEqualHyp (self, hyp, args):
2850 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2851 UseExisting=0, CompareMethod=""):
2854 if CompareMethod == "": CompareMethod = self.CompareHyp
2855 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2858 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2864 a = a + s + str(args[i])
2868 SetName(hypo, hyp + a)
2870 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2871 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2875 # Public class: Mesh_Segment
2876 # --------------------------
2878 ## Class to define a segment 1D algorithm for discretization
2881 # @ingroup l3_algos_basic
2882 class Mesh_Segment(Mesh_Algorithm):
2884 ## Private constructor.
2885 def __init__(self, mesh, geom=0):
2886 Mesh_Algorithm.__init__(self)
2887 self.Create(mesh, geom, "Regular_1D")
2889 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2890 # @param l for the length of segments that cut an edge
2891 # @param UseExisting if ==true - searches for an existing hypothesis created with
2892 # the same parameters, else (default) - creates a new one
2893 # @param p precision, used for calculation of the number of segments.
2894 # The precision should be a positive, meaningful value within the range [0,1].
2895 # In general, the number of segments is calculated with the formula:
2896 # nb = ceil((edge_length / l) - p)
2897 # Function ceil rounds its argument to the higher integer.
2898 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2899 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2900 # p=1 means rounding of (edge_length / l) to the lower integer.
2901 # Default value is 1e-07.
2902 # @return an instance of StdMeshers_LocalLength hypothesis
2903 # @ingroup l3_hypos_1dhyps
2904 def LocalLength(self, l, UseExisting=0, p=1e-07):
2905 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2906 CompareMethod=self.CompareLocalLength)
2912 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2913 def CompareLocalLength(self, hyp, args):
2914 if IsEqual(hyp.GetLength(), args[0]):
2915 return IsEqual(hyp.GetPrecision(), args[1])
2918 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2919 # @param n for the number of segments that cut an edge
2920 # @param s for the scale factor (optional)
2921 # @param UseExisting if ==true - searches for an existing hypothesis created with
2922 # the same parameters, else (default) - create a new one
2923 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2924 # @ingroup l3_hypos_1dhyps
2925 def NumberOfSegments(self, n, s=[], UseExisting=0):
2927 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2928 CompareMethod=self.CompareNumberOfSegments)
2930 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2931 CompareMethod=self.CompareNumberOfSegments)
2932 hyp.SetDistrType( 1 )
2933 hyp.SetScaleFactor(s)
2934 hyp.SetNumberOfSegments(n)
2938 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2939 def CompareNumberOfSegments(self, hyp, args):
2940 if hyp.GetNumberOfSegments() == args[0]:
2944 if hyp.GetDistrType() == 1:
2945 if IsEqual(hyp.GetScaleFactor(), args[1]):
2949 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2950 # @param start defines the length of the first segment
2951 # @param end defines the length of the last segment
2952 # @param UseExisting if ==true - searches for an existing hypothesis created with
2953 # the same parameters, else (default) - creates a new one
2954 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2955 # @ingroup l3_hypos_1dhyps
2956 def Arithmetic1D(self, start, end, UseExisting=0):
2957 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2958 CompareMethod=self.CompareArithmetic1D)
2959 hyp.SetLength(start, 1)
2960 hyp.SetLength(end , 0)
2964 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2965 def CompareArithmetic1D(self, hyp, args):
2966 if IsEqual(hyp.GetLength(1), args[0]):
2967 if IsEqual(hyp.GetLength(0), args[1]):
2971 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2972 # @param start defines the length of the first segment
2973 # @param end defines the length of the last segment
2974 # @param UseExisting if ==true - searches for an existing hypothesis created with
2975 # the same parameters, else (default) - creates a new one
2976 # @return an instance of StdMeshers_StartEndLength hypothesis
2977 # @ingroup l3_hypos_1dhyps
2978 def StartEndLength(self, start, end, UseExisting=0):
2979 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
2980 CompareMethod=self.CompareStartEndLength)
2981 hyp.SetLength(start, 1)
2982 hyp.SetLength(end , 0)
2985 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
2986 def CompareStartEndLength(self, hyp, args):
2987 if IsEqual(hyp.GetLength(1), args[0]):
2988 if IsEqual(hyp.GetLength(0), args[1]):
2992 ## Defines "Deflection1D" hypothesis
2993 # @param d for the deflection
2994 # @param UseExisting if ==true - searches for an existing hypothesis created with
2995 # the same parameters, else (default) - create a new one
2996 # @ingroup l3_hypos_1dhyps
2997 def Deflection1D(self, d, UseExisting=0):
2998 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
2999 CompareMethod=self.CompareDeflection1D)
3000 hyp.SetDeflection(d)
3003 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3004 def CompareDeflection1D(self, hyp, args):
3005 return IsEqual(hyp.GetDeflection(), args[0])
3007 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3008 # the opposite side in case of quadrangular faces
3009 # @ingroup l3_hypos_additi
3010 def Propagation(self):
3011 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3013 ## Defines "AutomaticLength" hypothesis
3014 # @param fineness for the fineness [0-1]
3015 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3016 # same parameters, else (default) - create a new one
3017 # @ingroup l3_hypos_1dhyps
3018 def AutomaticLength(self, fineness=0, UseExisting=0):
3019 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3020 CompareMethod=self.CompareAutomaticLength)
3021 hyp.SetFineness( fineness )
3024 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3025 def CompareAutomaticLength(self, hyp, args):
3026 return IsEqual(hyp.GetFineness(), args[0])
3028 ## Defines "SegmentLengthAroundVertex" hypothesis
3029 # @param length for the segment length
3030 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3031 # Any other integer value means that the hypothesis will be set on the
3032 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3033 # @param UseExisting if ==true - searches for an existing hypothesis created with
3034 # the same parameters, else (default) - creates a new one
3035 # @ingroup l3_algos_segmarv
3036 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3038 store_geom = self.geom
3039 if type(vertex) is types.IntType:
3040 if vertex == 0 or vertex == 1:
3041 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3049 if self.geom is None:
3050 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3051 name = GetName(self.geom)
3053 piece = self.mesh.geom
3054 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3055 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3056 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3058 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3060 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3061 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3063 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3064 CompareMethod=self.CompareLengthNearVertex)
3065 self.geom = store_geom
3066 hyp.SetLength( length )
3069 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3070 # @ingroup l3_algos_segmarv
3071 def CompareLengthNearVertex(self, hyp, args):
3072 return IsEqual(hyp.GetLength(), args[0])
3074 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3075 # If the 2D mesher sees that all boundary edges are quadratic,
3076 # it generates quadratic faces, else it generates linear faces using
3077 # medium nodes as if they are vertices.
3078 # The 3D mesher generates quadratic volumes only if all boundary faces
3079 # are quadratic, else it fails.
3081 # @ingroup l3_hypos_additi
3082 def QuadraticMesh(self):
3083 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3086 # Public class: Mesh_CompositeSegment
3087 # --------------------------
3089 ## Defines a segment 1D algorithm for discretization
3091 # @ingroup l3_algos_basic
3092 class Mesh_CompositeSegment(Mesh_Segment):
3094 ## Private constructor.
3095 def __init__(self, mesh, geom=0):
3096 self.Create(mesh, geom, "CompositeSegment_1D")
3099 # Public class: Mesh_Segment_Python
3100 # ---------------------------------
3102 ## Defines a segment 1D algorithm for discretization with python function
3104 # @ingroup l3_algos_basic
3105 class Mesh_Segment_Python(Mesh_Segment):
3107 ## Private constructor.
3108 def __init__(self, mesh, geom=0):
3109 import Python1dPlugin
3110 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3112 ## Defines "PythonSplit1D" hypothesis
3113 # @param n for the number of segments that cut an edge
3114 # @param func for the python function that calculates the length of all segments
3115 # @param UseExisting if ==true - searches for the existing hypothesis created with
3116 # the same parameters, else (default) - creates a new one
3117 # @ingroup l3_hypos_1dhyps
3118 def PythonSplit1D(self, n, func, UseExisting=0):
3119 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3120 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3121 hyp.SetNumberOfSegments(n)
3122 hyp.SetPythonLog10RatioFunction(func)
3125 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3126 def ComparePythonSplit1D(self, hyp, args):
3127 #if hyp.GetNumberOfSegments() == args[0]:
3128 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3132 # Public class: Mesh_Triangle
3133 # ---------------------------
3135 ## Defines a triangle 2D algorithm
3137 # @ingroup l3_algos_basic
3138 class Mesh_Triangle(Mesh_Algorithm):
3147 ## Private constructor.
3148 def __init__(self, mesh, algoType, geom=0):
3149 Mesh_Algorithm.__init__(self)
3151 self.algoType = algoType
3152 if algoType == MEFISTO:
3153 self.Create(mesh, geom, "MEFISTO_2D")
3155 elif algoType == BLSURF:
3157 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3158 #self.SetPhysicalMesh() - PAL19680
3159 elif algoType == NETGEN:
3161 print "Warning: NETGENPlugin module unavailable"
3163 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3165 elif algoType == NETGEN_2D:
3167 print "Warning: NETGENPlugin module unavailable"
3169 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3172 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3173 # @param area for the maximum area of each triangle
3174 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3175 # same parameters, else (default) - creates a new one
3177 # Only for algoType == MEFISTO || NETGEN_2D
3178 # @ingroup l3_hypos_2dhyps
3179 def MaxElementArea(self, area, UseExisting=0):
3180 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3181 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3182 CompareMethod=self.CompareMaxElementArea)
3183 hyp.SetMaxElementArea(area)
3185 elif self.algoType == NETGEN:
3186 print "Netgen 1D-2D algo doesn't support this hypothesis"
3189 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3190 def CompareMaxElementArea(self, hyp, args):
3191 return IsEqual(hyp.GetMaxElementArea(), args[0])
3193 ## Defines "LengthFromEdges" hypothesis to build triangles
3194 # based on the length of the edges taken from the wire
3196 # Only for algoType == MEFISTO || NETGEN_2D
3197 # @ingroup l3_hypos_2dhyps
3198 def LengthFromEdges(self):
3199 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3200 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3202 elif self.algoType == NETGEN:
3203 print "Netgen 1D-2D algo doesn't support this hypothesis"
3206 ## Sets a way to define size of mesh elements to generate.
3207 # @param thePhysicalMesh is: DefaultSize or Custom.
3208 # @ingroup l3_hypos_blsurf
3209 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3210 # Parameter of BLSURF algo
3211 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3213 ## Sets size of mesh elements to generate.
3214 # @ingroup l3_hypos_blsurf
3215 def SetPhySize(self, theVal):
3216 # Parameter of BLSURF algo
3217 self.Parameters().SetPhySize(theVal)
3219 ## Sets lower boundary of mesh element size (PhySize).
3220 # @ingroup l3_hypos_blsurf
3221 def SetPhyMin(self, theVal=-1):
3222 # Parameter of BLSURF algo
3223 self.Parameters().SetPhyMin(theVal)
3225 ## Sets upper boundary of mesh element size (PhySize).
3226 # @ingroup l3_hypos_blsurf
3227 def SetPhyMax(self, theVal=-1):
3228 # Parameter of BLSURF algo
3229 self.Parameters().SetPhyMax(theVal)
3231 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3232 # @param theGeometricMesh is: DefaultGeom or Custom
3233 # @ingroup l3_hypos_blsurf
3234 def SetGeometricMesh(self, theGeometricMesh=0):
3235 # Parameter of BLSURF algo
3236 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3237 self.params.SetGeometricMesh(theGeometricMesh)
3239 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3240 # @ingroup l3_hypos_blsurf
3241 def SetAngleMeshS(self, theVal=_angleMeshS):
3242 # Parameter of BLSURF algo
3243 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3244 self.params.SetAngleMeshS(theVal)
3246 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3247 # @ingroup l3_hypos_blsurf
3248 def SetAngleMeshC(self, theVal=_angleMeshS):
3249 # Parameter of BLSURF algo
3250 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3251 self.params.SetAngleMeshC(theVal)
3253 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3254 # @ingroup l3_hypos_blsurf
3255 def SetGeoMin(self, theVal=-1):
3256 # Parameter of BLSURF algo
3257 self.Parameters().SetGeoMin(theVal)
3259 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3260 # @ingroup l3_hypos_blsurf
3261 def SetGeoMax(self, theVal=-1):
3262 # Parameter of BLSURF algo
3263 self.Parameters().SetGeoMax(theVal)
3265 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3266 # @ingroup l3_hypos_blsurf
3267 def SetGradation(self, theVal=_gradation):
3268 # Parameter of BLSURF algo
3269 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3270 self.params.SetGradation(theVal)
3272 ## Sets topology usage way.
3273 # @param way defines how mesh conformity is assured <ul>
3274 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3275 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3276 # @ingroup l3_hypos_blsurf
3277 def SetTopology(self, way):
3278 # Parameter of BLSURF algo
3279 self.Parameters().SetTopology(way)
3281 ## To respect geometrical edges or not.
3282 # @ingroup l3_hypos_blsurf
3283 def SetDecimesh(self, toIgnoreEdges=False):
3284 # Parameter of BLSURF algo
3285 self.Parameters().SetDecimesh(toIgnoreEdges)
3287 ## Sets verbosity level in the range 0 to 100.
3288 # @ingroup l3_hypos_blsurf
3289 def SetVerbosity(self, level):
3290 # Parameter of BLSURF algo
3291 self.Parameters().SetVerbosity(level)
3293 ## Sets advanced option value.
3294 # @ingroup l3_hypos_blsurf
3295 def SetOptionValue(self, optionName, level):
3296 # Parameter of BLSURF algo
3297 self.Parameters().SetOptionValue(optionName,level)
3299 ## Sets QuadAllowed flag.
3300 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3301 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3302 def SetQuadAllowed(self, toAllow=True):
3303 if self.algoType == NETGEN_2D:
3304 if toAllow: # add QuadranglePreference
3305 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3306 else: # remove QuadranglePreference
3307 for hyp in self.mesh.GetHypothesisList( self.geom ):
3308 if hyp.GetName() == "QuadranglePreference":
3309 self.mesh.RemoveHypothesis( self.geom, hyp )
3314 if self.Parameters():
3315 self.params.SetQuadAllowed(toAllow)
3318 ## Defines "Netgen 2D Parameters" hypothesis
3320 # @ingroup l3_hypos_netgen
3321 def Parameters(self):
3322 # Only for algoType == NETGEN
3325 if self.algoType == NETGEN:
3326 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3327 "libNETGENEngine.so", UseExisting=0)
3329 elif self.algoType == MEFISTO:
3330 print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
3332 elif self.algoType == NETGEN_2D:
3333 print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
3334 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3336 elif self.algoType == BLSURF:
3337 self.params = self.Hypothesis("BLSURF_Parameters", [],
3338 "libBLSURFEngine.so", UseExisting=0)
3344 # Only for algoType == NETGEN
3345 # @ingroup l3_hypos_netgen
3346 def SetMaxSize(self, theSize):
3347 if self.Parameters():
3348 self.params.SetMaxSize(theSize)
3350 ## Sets SecondOrder flag
3352 # Only for algoType == NETGEN
3353 # @ingroup l3_hypos_netgen
3354 def SetSecondOrder(self, theVal):
3355 if self.Parameters():
3356 self.params.SetSecondOrder(theVal)
3358 ## Sets Optimize flag
3360 # Only for algoType == NETGEN
3361 # @ingroup l3_hypos_netgen
3362 def SetOptimize(self, theVal):
3363 if self.Parameters():
3364 self.params.SetOptimize(theVal)
3367 # @param theFineness is:
3368 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3370 # Only for algoType == NETGEN
3371 # @ingroup l3_hypos_netgen
3372 def SetFineness(self, theFineness):
3373 if self.Parameters():
3374 self.params.SetFineness(theFineness)
3378 # Only for algoType == NETGEN
3379 # @ingroup l3_hypos_netgen
3380 def SetGrowthRate(self, theRate):
3381 if self.Parameters():
3382 self.params.SetGrowthRate(theRate)
3384 ## Sets NbSegPerEdge
3386 # Only for algoType == NETGEN
3387 # @ingroup l3_hypos_netgen
3388 def SetNbSegPerEdge(self, theVal):
3389 if self.Parameters():
3390 self.params.SetNbSegPerEdge(theVal)
3392 ## Sets NbSegPerRadius
3394 # Only for algoType == NETGEN
3395 # @ingroup l3_hypos_netgen
3396 def SetNbSegPerRadius(self, theVal):
3397 if self.Parameters():
3398 self.params.SetNbSegPerRadius(theVal)
3403 # Public class: Mesh_Quadrangle
3404 # -----------------------------
3406 ## Defines a quadrangle 2D algorithm
3408 # @ingroup l3_algos_basic
3409 class Mesh_Quadrangle(Mesh_Algorithm):
3411 ## Private constructor.
3412 def __init__(self, mesh, geom=0):
3413 Mesh_Algorithm.__init__(self)
3414 self.Create(mesh, geom, "Quadrangle_2D")
3416 ## Defines "QuadranglePreference" hypothesis, forcing construction
3417 # of quadrangles if the number of nodes on the opposite edges is not the same
3418 # while the total number of nodes on edges is even
3420 # @ingroup l3_hypos_additi
3421 def QuadranglePreference(self):
3422 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3423 CompareMethod=self.CompareEqualHyp)
3426 # Public class: Mesh_Tetrahedron
3427 # ------------------------------
3429 ## Defines a tetrahedron 3D algorithm
3431 # @ingroup l3_algos_basic
3432 class Mesh_Tetrahedron(Mesh_Algorithm):
3437 ## Private constructor.
3438 def __init__(self, mesh, algoType, geom=0):
3439 Mesh_Algorithm.__init__(self)
3441 if algoType == NETGEN:
3442 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3445 elif algoType == FULL_NETGEN:
3447 print "Warning: NETGENPlugin module has not been imported."
3448 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3451 elif algoType == GHS3D:
3453 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3456 self.algoType = algoType
3458 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3459 # @param vol for the maximum volume of each tetrahedron
3460 # @param UseExisting if ==true - searches for the existing hypothesis created with
3461 # the same parameters, else (default) - creates a new one
3462 # @ingroup l3_hypos_maxvol
3463 def MaxElementVolume(self, vol, UseExisting=0):
3464 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3465 CompareMethod=self.CompareMaxElementVolume)
3466 hyp.SetMaxElementVolume(vol)
3469 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3470 def CompareMaxElementVolume(self, hyp, args):
3471 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3473 ## Defines "Netgen 3D Parameters" hypothesis
3474 # @ingroup l3_hypos_netgen
3475 def Parameters(self):
3478 if (self.algoType == FULL_NETGEN):
3479 self.params = self.Hypothesis("NETGEN_Parameters", [],
3480 "libNETGENEngine.so", UseExisting=0)
3482 if (self.algoType == GHS3D):
3483 self.params = self.Hypothesis("GHS3D_Parameters", [],
3484 "libGHS3DEngine.so", UseExisting=0)
3487 print "Algo doesn't support this hypothesis"
3491 # Parameter of FULL_NETGEN
3492 # @ingroup l3_hypos_netgen
3493 def SetMaxSize(self, theSize):
3494 self.Parameters().SetMaxSize(theSize)
3496 ## Sets SecondOrder flag
3497 # Parameter of FULL_NETGEN
3498 # @ingroup l3_hypos_netgen
3499 def SetSecondOrder(self, theVal):
3500 self.Parameters().SetSecondOrder(theVal)
3502 ## Sets Optimize flag
3503 # Parameter of FULL_NETGEN
3504 # @ingroup l3_hypos_netgen
3505 def SetOptimize(self, theVal):
3506 self.Parameters().SetOptimize(theVal)
3509 # @param theFineness is:
3510 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3511 # Parameter of FULL_NETGEN
3512 # @ingroup l3_hypos_netgen
3513 def SetFineness(self, theFineness):
3514 self.Parameters().SetFineness(theFineness)
3517 # Parameter of FULL_NETGEN
3518 # @ingroup l3_hypos_netgen
3519 def SetGrowthRate(self, theRate):
3520 self.Parameters().SetGrowthRate(theRate)
3522 ## Sets NbSegPerEdge
3523 # Parameter of FULL_NETGEN
3524 # @ingroup l3_hypos_netgen
3525 def SetNbSegPerEdge(self, theVal):
3526 self.Parameters().SetNbSegPerEdge(theVal)
3528 ## Sets NbSegPerRadius
3529 # Parameter of FULL_NETGEN
3530 # @ingroup l3_hypos_netgen
3531 def SetNbSegPerRadius(self, theVal):
3532 self.Parameters().SetNbSegPerRadius(theVal)
3534 ## To mesh "holes" in a solid or not. Default is to mesh.
3535 # @ingroup l3_hypos_ghs3dh
3536 def SetToMeshHoles(self, toMesh):
3537 # Parameter of GHS3D
3538 self.Parameters().SetToMeshHoles(toMesh)
3540 ## Set Optimization level:
3541 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3542 # Default is Medium_Optimization
3543 # @ingroup l3_hypos_ghs3dh
3544 def SetOptimizationLevel(self, level):
3545 # Parameter of GHS3D
3546 self.Parameters().SetOptimizationLevel(level)
3548 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3549 # @ingroup l3_hypos_ghs3dh
3550 def SetMaximumMemory(self, MB):
3551 # Advanced parameter of GHS3D
3552 self.Parameters().SetMaximumMemory(MB)
3554 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3555 # automatic memory adjustment mode.
3556 # @ingroup l3_hypos_ghs3dh
3557 def SetInitialMemory(self, MB):
3558 # Advanced parameter of GHS3D
3559 self.Parameters().SetInitialMemory(MB)
3561 ## Path to working directory.
3562 # @ingroup l3_hypos_ghs3dh
3563 def SetWorkingDirectory(self, path):
3564 # Advanced parameter of GHS3D
3565 self.Parameters().SetWorkingDirectory(path)
3567 ## To keep working files or remove them. Log file remains in case of errors anyway.
3568 # @ingroup l3_hypos_ghs3dh
3569 def SetKeepFiles(self, toKeep):
3570 # Advanced parameter of GHS3D
3571 self.Parameters().SetKeepFiles(toKeep)
3573 ## To set verbose level [0-10]. <ul>
3574 #<li> 0 - no standard output,
3575 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3576 # indicates when the final mesh is being saved. In addition the software
3577 # gives indication regarding the CPU time.
3578 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3579 # histogram of the skin mesh, quality statistics histogram together with
3580 # the characteristics of the final mesh.</ul>
3581 # @ingroup l3_hypos_ghs3dh
3582 def SetVerboseLevel(self, level):
3583 # Advanced parameter of GHS3D
3584 self.Parameters().SetVerboseLevel(level)
3586 ## To create new nodes.
3587 # @ingroup l3_hypos_ghs3dh
3588 def SetToCreateNewNodes(self, toCreate):
3589 # Advanced parameter of GHS3D
3590 self.Parameters().SetToCreateNewNodes(toCreate)
3592 ## To use boundary recovery version which tries to create mesh on a very poor
3593 # quality surface mesh.
3594 # @ingroup l3_hypos_ghs3dh
3595 def SetToUseBoundaryRecoveryVersion(self, toUse):
3596 # Advanced parameter of GHS3D
3597 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3599 ## Sets command line option as text.
3600 # @ingroup l3_hypos_ghs3dh
3601 def SetTextOption(self, option):
3602 # Advanced parameter of GHS3D
3603 self.Parameters().SetTextOption(option)
3605 # Public class: Mesh_Hexahedron
3606 # ------------------------------
3608 ## Defines a hexahedron 3D algorithm
3610 # @ingroup l3_algos_basic
3611 class Mesh_Hexahedron(Mesh_Algorithm):
3616 ## Private constructor.
3617 def __init__(self, mesh, algoType=Hexa, geom=0):
3618 Mesh_Algorithm.__init__(self)
3620 self.algoType = algoType
3622 if algoType == Hexa:
3623 self.Create(mesh, geom, "Hexa_3D")
3626 elif algoType == Hexotic:
3627 import HexoticPlugin
3628 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3631 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3632 # @ingroup l3_hypos_hexotic
3633 def MinMaxQuad(self, min=3, max=8, quad=True):
3634 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3636 self.params.SetHexesMinLevel(min)
3637 self.params.SetHexesMaxLevel(max)
3638 self.params.SetHexoticQuadrangles(quad)
3641 # Deprecated, only for compatibility!
3642 # Public class: Mesh_Netgen
3643 # ------------------------------
3645 ## Defines a NETGEN-based 2D or 3D algorithm
3646 # that needs no discrete boundary (i.e. independent)
3648 # This class is deprecated, only for compatibility!
3651 # @ingroup l3_algos_basic
3652 class Mesh_Netgen(Mesh_Algorithm):
3656 ## Private constructor.
3657 def __init__(self, mesh, is3D, geom=0):
3658 Mesh_Algorithm.__init__(self)
3661 print "Warning: NETGENPlugin module has not been imported."
3665 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3669 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3672 ## Defines the hypothesis containing parameters of the algorithm
3673 def Parameters(self):
3675 hyp = self.Hypothesis("NETGEN_Parameters", [],
3676 "libNETGENEngine.so", UseExisting=0)
3678 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3679 "libNETGENEngine.so", UseExisting=0)
3682 # Public class: Mesh_Projection1D
3683 # ------------------------------
3685 ## Defines a projection 1D algorithm
3686 # @ingroup l3_algos_proj
3688 class Mesh_Projection1D(Mesh_Algorithm):
3690 ## Private constructor.
3691 def __init__(self, mesh, geom=0):
3692 Mesh_Algorithm.__init__(self)
3693 self.Create(mesh, geom, "Projection_1D")
3695 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3696 # a mesh pattern is taken, and, optionally, the association of vertices
3697 # between the source edge and a target edge (to which a hypothesis is assigned)
3698 # @param edge from which nodes distribution is taken
3699 # @param mesh from which nodes distribution is taken (optional)
3700 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3701 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3702 # to associate with \a srcV (optional)
3703 # @param UseExisting if ==true - searches for the existing hypothesis created with
3704 # the same parameters, else (default) - creates a new one
3705 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3706 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3708 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3709 hyp.SetSourceEdge( edge )
3710 if not mesh is None and isinstance(mesh, Mesh):
3711 mesh = mesh.GetMesh()
3712 hyp.SetSourceMesh( mesh )
3713 hyp.SetVertexAssociation( srcV, tgtV )
3716 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3717 #def CompareSourceEdge(self, hyp, args):
3718 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3722 # Public class: Mesh_Projection2D
3723 # ------------------------------
3725 ## Defines a projection 2D algorithm
3726 # @ingroup l3_algos_proj
3728 class Mesh_Projection2D(Mesh_Algorithm):
3730 ## Private constructor.
3731 def __init__(self, mesh, geom=0):
3732 Mesh_Algorithm.__init__(self)
3733 self.Create(mesh, geom, "Projection_2D")
3735 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3736 # a mesh pattern is taken, and, optionally, the association of vertices
3737 # between the source face and the target face (to which a hypothesis is assigned)
3738 # @param face from which the mesh pattern is taken
3739 # @param mesh from which the mesh pattern is taken (optional)
3740 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3741 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3742 # to associate with \a srcV1 (optional)
3743 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3744 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3745 # to associate with \a srcV2 (optional)
3746 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3747 # the same parameters, else (default) - forces the creation a new one
3749 # Note: all association vertices must belong to one edge of a face
3750 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3751 srcV2=None, tgtV2=None, UseExisting=0):
3752 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3754 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3755 hyp.SetSourceFace( face )
3756 if not mesh is None and isinstance(mesh, Mesh):
3757 mesh = mesh.GetMesh()
3758 hyp.SetSourceMesh( mesh )
3759 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3762 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3763 #def CompareSourceFace(self, hyp, args):
3764 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3767 # Public class: Mesh_Projection3D
3768 # ------------------------------
3770 ## Defines a projection 3D algorithm
3771 # @ingroup l3_algos_proj
3773 class Mesh_Projection3D(Mesh_Algorithm):
3775 ## Private constructor.
3776 def __init__(self, mesh, geom=0):
3777 Mesh_Algorithm.__init__(self)
3778 self.Create(mesh, geom, "Projection_3D")
3780 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3781 # the mesh pattern is taken, and, optionally, the association of vertices
3782 # between the source and the target solid (to which a hipothesis is assigned)
3783 # @param solid from where the mesh pattern is taken
3784 # @param mesh from where the mesh pattern is taken (optional)
3785 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3786 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3787 # to associate with \a srcV1 (optional)
3788 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3789 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3790 # to associate with \a srcV2 (optional)
3791 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3792 # the same parameters, else (default) - creates a new one
3794 # Note: association vertices must belong to one edge of a solid
3795 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3796 srcV2=0, tgtV2=0, UseExisting=0):
3797 hyp = self.Hypothesis("ProjectionSource3D",
3798 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3800 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3801 hyp.SetSource3DShape( solid )
3802 if not mesh is None and isinstance(mesh, Mesh):
3803 mesh = mesh.GetMesh()
3804 hyp.SetSourceMesh( mesh )
3805 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3808 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3809 #def CompareSourceShape3D(self, hyp, args):
3810 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3814 # Public class: Mesh_Prism
3815 # ------------------------
3817 ## Defines a 3D extrusion algorithm
3818 # @ingroup l3_algos_3dextr
3820 class Mesh_Prism3D(Mesh_Algorithm):
3822 ## Private constructor.
3823 def __init__(self, mesh, geom=0):
3824 Mesh_Algorithm.__init__(self)
3825 self.Create(mesh, geom, "Prism_3D")
3827 # Public class: Mesh_RadialPrism
3828 # -------------------------------
3830 ## Defines a Radial Prism 3D algorithm
3831 # @ingroup l3_algos_radialp
3833 class Mesh_RadialPrism3D(Mesh_Algorithm):
3835 ## Private constructor.
3836 def __init__(self, mesh, geom=0):
3837 Mesh_Algorithm.__init__(self)
3838 self.Create(mesh, geom, "RadialPrism_3D")
3840 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3841 self.nbLayers = None
3843 ## Return 3D hypothesis holding the 1D one
3844 def Get3DHypothesis(self):
3845 return self.distribHyp
3847 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3848 # hypothesis. Returns the created hypothesis
3849 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3850 #print "OwnHypothesis",hypType
3851 if not self.nbLayers is None:
3852 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3853 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3854 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3855 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3856 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3857 self.distribHyp.SetLayerDistribution( hyp )
3860 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3861 # prisms to build between the inner and outer shells
3862 # @param n number of layers
3863 # @param UseExisting if ==true - searches for the existing hypothesis created with
3864 # the same parameters, else (default) - creates a new one
3865 def NumberOfLayers(self, n, UseExisting=0):
3866 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3867 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3868 CompareMethod=self.CompareNumberOfLayers)
3869 self.nbLayers.SetNumberOfLayers( n )
3870 return self.nbLayers
3872 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3873 def CompareNumberOfLayers(self, hyp, args):
3874 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3876 ## Defines "LocalLength" hypothesis, specifying the segment length
3877 # to build between the inner and the outer shells
3878 # @param l the length of segments
3879 # @param p the precision of rounding
3880 def LocalLength(self, l, p=1e-07):
3881 hyp = self.OwnHypothesis("LocalLength", [l,p])
3886 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3887 # prisms to build between the inner and the outer shells.
3888 # @param n the number of layers
3889 # @param s the scale factor (optional)
3890 def NumberOfSegments(self, n, s=[]):
3892 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3894 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3895 hyp.SetDistrType( 1 )
3896 hyp.SetScaleFactor(s)
3897 hyp.SetNumberOfSegments(n)
3900 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3901 # to build between the inner and the outer shells with a length that changes in arithmetic progression
3902 # @param start the length of the first segment
3903 # @param end the length of the last segment
3904 def Arithmetic1D(self, start, end ):
3905 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
3906 hyp.SetLength(start, 1)
3907 hyp.SetLength(end , 0)
3910 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
3911 # to build between the inner and the outer shells as geometric length increasing
3912 # @param start for the length of the first segment
3913 # @param end for the length of the last segment
3914 def StartEndLength(self, start, end):
3915 hyp = self.OwnHypothesis("StartEndLength", [start, end])
3916 hyp.SetLength(start, 1)
3917 hyp.SetLength(end , 0)
3920 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
3921 # to build between the inner and outer shells
3922 # @param fineness defines the quality of the mesh within the range [0-1]
3923 def AutomaticLength(self, fineness=0):
3924 hyp = self.OwnHypothesis("AutomaticLength")
3925 hyp.SetFineness( fineness )
3928 # Private class: Mesh_UseExisting
3929 # -------------------------------
3930 class Mesh_UseExisting(Mesh_Algorithm):
3932 def __init__(self, dim, mesh, geom=0):
3934 self.Create(mesh, geom, "UseExisting_1D")
3936 self.Create(mesh, geom, "UseExisting_2D")