1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 def IsEqual(val1, val2, tol=PrecisionConfusion):
159 if abs(val1 - val2) < tol:
167 ior = salome.orb.object_to_string(obj)
168 sobj = salome.myStudy.FindObjectIOR(ior)
172 attr = sobj.FindAttribute("AttributeName")[1]
175 ## Sets a name to the object
176 def SetName(obj, name):
177 ior = salome.orb.object_to_string(obj)
178 sobj = salome.myStudy.FindObjectIOR(ior)
180 attr = sobj.FindAttribute("AttributeName")[1]
183 ## Prints error message if a hypothesis was not assigned.
184 def TreatHypoStatus(status, hypName, geomName, isAlgo):
186 hypType = "algorithm"
188 hypType = "hypothesis"
190 if status == HYP_UNKNOWN_FATAL :
191 reason = "for unknown reason"
192 elif status == HYP_INCOMPATIBLE :
193 reason = "this hypothesis mismatches the algorithm"
194 elif status == HYP_NOTCONFORM :
195 reason = "a non-conform mesh would be built"
196 elif status == HYP_ALREADY_EXIST :
197 reason = hypType + " of the same dimension is already assigned to this shape"
198 elif status == HYP_BAD_DIM :
199 reason = hypType + " mismatches the shape"
200 elif status == HYP_CONCURENT :
201 reason = "there are concurrent hypotheses on sub-shapes"
202 elif status == HYP_BAD_SUBSHAPE :
203 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
204 elif status == HYP_BAD_GEOMETRY:
205 reason = "geometry mismatches the expectation of the algorithm"
206 elif status == HYP_HIDDEN_ALGO:
207 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
208 elif status == HYP_HIDING_ALGO:
209 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
210 elif status == HYP_NEED_SHAPE:
211 reason = "Algorithm can't work without shape"
214 hypName = '"' + hypName + '"'
215 geomName= '"' + geomName+ '"'
216 if status < HYP_UNKNOWN_FATAL:
217 print hypName, "was assigned to", geomName,"but", reason
219 print hypName, "was not assigned to",geomName,":", reason
222 ## Converts an angle from degrees to radians
223 def DegreesToRadians(AngleInDegrees):
225 return AngleInDegrees * pi / 180.0
227 # end of l1_auxiliary
230 # All methods of this class are accessible directly from the smesh.py package.
231 class smeshDC(SMESH._objref_SMESH_Gen):
233 ## Sets the current study and Geometry component
234 # @ingroup l1_auxiliary
235 def init_smesh(self,theStudy,geompyD):
237 self.SetGeomEngine(geompyD)
238 self.SetCurrentStudy(theStudy)
240 ## Creates an empty Mesh. This mesh can have an underlying geometry.
241 # @param obj the Geometrical object on which the mesh is built. If not defined,
242 # the mesh will have no underlying geometry.
243 # @param name the name for the new mesh.
244 # @return an instance of Mesh class.
245 # @ingroup l2_construct
246 def Mesh(self, obj=0, name=0):
247 return Mesh(self,self.geompyD,obj,name)
249 ## Returns a long value from enumeration
250 # Should be used for SMESH.FunctorType enumeration
251 # @ingroup l1_controls
252 def EnumToLong(self,theItem):
255 ## Gets PointStruct from vertex
256 # @param theVertex a GEOM object(vertex)
257 # @return SMESH.PointStruct
258 # @ingroup l1_auxiliary
259 def GetPointStruct(self,theVertex):
260 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
261 return PointStruct(x,y,z)
263 ## Gets DirStruct from vector
264 # @param theVector a GEOM object(vector)
265 # @return SMESH.DirStruct
266 # @ingroup l1_auxiliary
267 def GetDirStruct(self,theVector):
268 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
269 if(len(vertices) != 2):
270 print "Error: vector object is incorrect."
272 p1 = self.geompyD.PointCoordinates(vertices[0])
273 p2 = self.geompyD.PointCoordinates(vertices[1])
274 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
275 dirst = DirStruct(pnt)
278 ## Makes DirStruct from a triplet
279 # @param x,y,z vector components
280 # @return SMESH.DirStruct
281 # @ingroup l1_auxiliary
282 def MakeDirStruct(self,x,y,z):
283 pnt = PointStruct(x,y,z)
284 return DirStruct(pnt)
286 ## Get AxisStruct from object
287 # @param theObj a GEOM object (line or plane)
288 # @return SMESH.AxisStruct
289 # @ingroup l1_auxiliary
290 def GetAxisStruct(self,theObj):
291 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
293 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
294 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
295 vertex1 = self.geompyD.PointCoordinates(vertex1)
296 vertex2 = self.geompyD.PointCoordinates(vertex2)
297 vertex3 = self.geompyD.PointCoordinates(vertex3)
298 vertex4 = self.geompyD.PointCoordinates(vertex4)
299 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
300 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
301 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] ]
302 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
304 elif len(edges) == 1:
305 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
306 p1 = self.geompyD.PointCoordinates( vertex1 )
307 p2 = self.geompyD.PointCoordinates( vertex2 )
308 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
312 # From SMESH_Gen interface:
313 # ------------------------
315 ## Sets the current mode
316 # @ingroup l1_auxiliary
317 def SetEmbeddedMode( self,theMode ):
318 #self.SetEmbeddedMode(theMode)
319 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
321 ## Gets the current mode
322 # @ingroup l1_auxiliary
323 def IsEmbeddedMode(self):
324 #return self.IsEmbeddedMode()
325 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
327 ## Sets the current study
328 # @ingroup l1_auxiliary
329 def SetCurrentStudy( self, theStudy ):
330 #self.SetCurrentStudy(theStudy)
331 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
333 ## Gets the current study
334 # @ingroup l1_auxiliary
335 def GetCurrentStudy(self):
336 #return self.GetCurrentStudy()
337 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
339 ## Creates a Mesh object importing data from the given UNV file
340 # @return an instance of Mesh class
342 def CreateMeshesFromUNV( self,theFileName ):
343 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
344 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
347 ## Creates a Mesh object(s) importing data from the given MED file
348 # @return a list of Mesh class instances
350 def CreateMeshesFromMED( self,theFileName ):
351 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
353 for iMesh in range(len(aSmeshMeshes)) :
354 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
355 aMeshes.append(aMesh)
356 return aMeshes, aStatus
358 ## Creates a Mesh object importing data from the given STL file
359 # @return an instance of Mesh class
361 def CreateMeshesFromSTL( self, theFileName ):
362 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
363 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
366 ## From SMESH_Gen interface
367 # @return the list of integer values
368 # @ingroup l1_auxiliary
369 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
370 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
372 ## From SMESH_Gen interface. Creates a pattern
373 # @return an instance of SMESH_Pattern
375 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
376 # @ingroup l2_modif_patterns
377 def GetPattern(self):
378 return SMESH._objref_SMESH_Gen.GetPattern(self)
381 # Filtering. Auxiliary functions:
382 # ------------------------------
384 ## Creates an empty criterion
385 # @return SMESH.Filter.Criterion
386 # @ingroup l1_controls
387 def GetEmptyCriterion(self):
388 Type = self.EnumToLong(FT_Undefined)
389 Compare = self.EnumToLong(FT_Undefined)
393 UnaryOp = self.EnumToLong(FT_Undefined)
394 BinaryOp = self.EnumToLong(FT_Undefined)
397 Precision = -1 ##@1e-07
398 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
399 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
401 ## Creates a criterion by the given parameters
402 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
403 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
404 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
405 # @param Treshold the threshold value (range of ids as string, shape, numeric)
406 # @param UnaryOp FT_LogicalNOT or FT_Undefined
407 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
408 # FT_Undefined (must be for the last criterion of all criteria)
409 # @return SMESH.Filter.Criterion
410 # @ingroup l1_controls
411 def GetCriterion(self,elementType,
413 Compare = FT_EqualTo,
415 UnaryOp=FT_Undefined,
416 BinaryOp=FT_Undefined):
417 aCriterion = self.GetEmptyCriterion()
418 aCriterion.TypeOfElement = elementType
419 aCriterion.Type = self.EnumToLong(CritType)
423 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
424 aCriterion.Compare = self.EnumToLong(Compare)
425 elif Compare == "=" or Compare == "==":
426 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
428 aCriterion.Compare = self.EnumToLong(FT_LessThan)
430 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
432 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
435 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
436 FT_BelongToCylinder, FT_LyingOnGeom]:
437 # Checks the treshold
438 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
439 aCriterion.ThresholdStr = GetName(aTreshold)
440 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
442 print "Error: The treshold should be a shape."
444 elif CritType == FT_RangeOfIds:
445 # Checks the treshold
446 if isinstance(aTreshold, str):
447 aCriterion.ThresholdStr = aTreshold
449 print "Error: The treshold should be a string."
451 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
452 # At this point the treshold is unnecessary
453 if aTreshold == FT_LogicalNOT:
454 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
455 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
456 aCriterion.BinaryOp = aTreshold
460 aTreshold = float(aTreshold)
461 aCriterion.Threshold = aTreshold
463 print "Error: The treshold should be a number."
466 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
467 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
469 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
470 aCriterion.BinaryOp = self.EnumToLong(Treshold)
472 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
473 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
475 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
476 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
480 ## Creates a filter with the given parameters
481 # @param elementType the type of elements in the group
482 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
483 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
484 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
485 # @param UnaryOp FT_LogicalNOT or FT_Undefined
486 # @return SMESH_Filter
487 # @ingroup l1_controls
488 def GetFilter(self,elementType,
489 CritType=FT_Undefined,
492 UnaryOp=FT_Undefined):
493 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
494 aFilterMgr = self.CreateFilterManager()
495 aFilter = aFilterMgr.CreateFilter()
497 aCriteria.append(aCriterion)
498 aFilter.SetCriteria(aCriteria)
501 ## Creates a numerical functor by its type
502 # @param theCriterion FT_...; functor type
503 # @return SMESH_NumericalFunctor
504 # @ingroup l1_controls
505 def GetFunctor(self,theCriterion):
506 aFilterMgr = self.CreateFilterManager()
507 if theCriterion == FT_AspectRatio:
508 return aFilterMgr.CreateAspectRatio()
509 elif theCriterion == FT_AspectRatio3D:
510 return aFilterMgr.CreateAspectRatio3D()
511 elif theCriterion == FT_Warping:
512 return aFilterMgr.CreateWarping()
513 elif theCriterion == FT_MinimumAngle:
514 return aFilterMgr.CreateMinimumAngle()
515 elif theCriterion == FT_Taper:
516 return aFilterMgr.CreateTaper()
517 elif theCriterion == FT_Skew:
518 return aFilterMgr.CreateSkew()
519 elif theCriterion == FT_Area:
520 return aFilterMgr.CreateArea()
521 elif theCriterion == FT_Volume3D:
522 return aFilterMgr.CreateVolume3D()
523 elif theCriterion == FT_MultiConnection:
524 return aFilterMgr.CreateMultiConnection()
525 elif theCriterion == FT_MultiConnection2D:
526 return aFilterMgr.CreateMultiConnection2D()
527 elif theCriterion == FT_Length:
528 return aFilterMgr.CreateLength()
529 elif theCriterion == FT_Length2D:
530 return aFilterMgr.CreateLength2D()
532 print "Error: given parameter is not numerucal functor type."
536 #Registering the new proxy for SMESH_Gen
537 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
543 ## This class allows defining and managing a mesh.
544 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
545 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
546 # new nodes and elements and by changing the existing entities), to get information
547 # about a mesh and to export a mesh into different formats.
556 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
557 # sets the GUI name of this mesh to \a name.
558 # @param smeshpyD an instance of smeshDC class
559 # @param geompyD an instance of geompyDC class
560 # @param obj Shape to be meshed or SMESH_Mesh object
561 # @param name Study name of the mesh
562 # @ingroup l2_construct
563 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
564 self.smeshpyD=smeshpyD
569 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
571 self.mesh = self.smeshpyD.CreateMesh(self.geom)
572 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
575 self.mesh = self.smeshpyD.CreateEmptyMesh()
577 SetName(self.mesh, name)
579 SetName(self.mesh, GetName(obj))
582 self.geom = self.mesh.GetShapeToMesh()
584 self.editor = self.mesh.GetMeshEditor()
586 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
587 # @param theMesh a SMESH_Mesh object
588 # @ingroup l2_construct
589 def SetMesh(self, theMesh):
591 self.geom = self.mesh.GetShapeToMesh()
593 ## Returns the mesh, that is an instance of SMESH_Mesh interface
594 # @return a SMESH_Mesh object
595 # @ingroup l2_construct
599 ## Gets the name of the mesh
600 # @return the name of the mesh as a string
601 # @ingroup l2_construct
603 name = GetName(self.GetMesh())
606 ## Sets a name to the mesh
607 # @param name a new name of the mesh
608 # @ingroup l2_construct
609 def SetName(self, name):
610 SetName(self.GetMesh(), name)
612 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
613 # The subMesh object gives access to the IDs of nodes and elements.
614 # @param theSubObject a geometrical object (shape)
615 # @param theName a name for the submesh
616 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
617 # @ingroup l2_submeshes
618 def GetSubMesh(self, theSubObject, theName):
619 submesh = self.mesh.GetSubMesh(theSubObject, theName)
622 ## Returns the shape associated to the mesh
623 # @return a GEOM_Object
624 # @ingroup l2_construct
628 ## Associates the given shape to the mesh (entails the recreation of the mesh)
629 # @param geom the shape to be meshed (GEOM_Object)
630 # @ingroup l2_construct
631 def SetShape(self, geom):
632 self.mesh = self.smeshpyD.CreateMesh(geom)
634 ## Returns true if the hypotheses are defined well
635 # @param theSubObject a subshape of a mesh shape
636 # @return True or False
637 # @ingroup l2_construct
638 def IsReadyToCompute(self, theSubObject):
639 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
641 ## Returns errors of hypotheses definition.
642 # The list of errors is empty if everything is OK.
643 # @param theSubObject a subshape of a mesh shape
644 # @return a list of errors
645 # @ingroup l2_construct
646 def GetAlgoState(self, theSubObject):
647 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
649 ## Returns a geometrical object on which the given element was built.
650 # The returned geometrical object, if not nil, is either found in the
651 # study or published by this method with the given name
652 # @param theElementID the id of the mesh element
653 # @param theGeomName the user-defined name of the geometrical object
654 # @return GEOM::GEOM_Object instance
655 # @ingroup l2_construct
656 def GetGeometryByMeshElement(self, theElementID, theGeomName):
657 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
659 ## Returns the mesh dimension depending on the dimension of the underlying shape
660 # @return mesh dimension as an integer value [0,3]
661 # @ingroup l1_auxiliary
662 def MeshDimension(self):
663 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
664 if len( shells ) > 0 :
666 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
668 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
674 ## Creates a segment discretization 1D algorithm.
675 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
676 # \n If the optional \a geom parameter is not set, this algorithm is global.
677 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
678 # @param algo the type of the required algorithm. Possible values are:
680 # - smesh.PYTHON for discretization via a python function,
681 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
682 # @param geom If defined is the subshape to be meshed
683 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
684 # @ingroup l3_algos_basic
685 def Segment(self, algo=REGULAR, geom=0):
686 ## if Segment(geom) is called by mistake
687 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
688 algo, geom = geom, algo
689 if not algo: algo = REGULAR
692 return Mesh_Segment(self, geom)
694 return Mesh_Segment_Python(self, geom)
695 elif algo == COMPOSITE:
696 return Mesh_CompositeSegment(self, geom)
698 return Mesh_Segment(self, geom)
700 ## Enables creation of nodes and segments usable by 2D algoritms.
701 # The added nodes and segments must be bound to edges and vertices by
702 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
703 # If the optional \a geom parameter is not set, this algorithm is global.
704 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
705 # @param geom the subshape to be manually meshed
706 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
707 # @ingroup l3_algos_basic
708 def UseExistingSegments(self, geom=0):
709 algo = Mesh_UseExisting(1,self,geom)
710 return algo.GetAlgorithm()
712 ## Enables creation of nodes and faces usable by 3D algoritms.
713 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
714 # and SetMeshElementOnShape()
715 # If the optional \a geom parameter is not set, this algorithm is global.
716 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
717 # @param geom the subshape to be manually meshed
718 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
719 # @ingroup l3_algos_basic
720 def UseExistingFaces(self, geom=0):
721 algo = Mesh_UseExisting(2,self,geom)
722 return algo.GetAlgorithm()
724 ## Creates a triangle 2D algorithm for faces.
725 # If the optional \a geom parameter is not set, this algorithm is global.
726 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
727 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
728 # @param geom If defined, the subshape to be meshed (GEOM_Object)
729 # @return an instance of Mesh_Triangle algorithm
730 # @ingroup l3_algos_basic
731 def Triangle(self, algo=MEFISTO, geom=0):
732 ## if Triangle(geom) is called by mistake
733 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
737 return Mesh_Triangle(self, algo, geom)
739 ## Creates a quadrangle 2D algorithm for faces.
740 # If the optional \a geom parameter is not set, this algorithm is global.
741 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
742 # @param geom If defined, the subshape to be meshed (GEOM_Object)
743 # @return an instance of Mesh_Quadrangle algorithm
744 # @ingroup l3_algos_basic
745 def Quadrangle(self, geom=0):
746 return Mesh_Quadrangle(self, geom)
748 ## Creates a tetrahedron 3D algorithm for solids.
749 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
750 # If the optional \a geom parameter is not set, this algorithm is global.
751 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
752 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
753 # @param geom If defined, the subshape to be meshed (GEOM_Object)
754 # @return an instance of Mesh_Tetrahedron algorithm
755 # @ingroup l3_algos_basic
756 def Tetrahedron(self, algo=NETGEN, geom=0):
757 ## if Tetrahedron(geom) is called by mistake
758 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
759 algo, geom = geom, algo
760 if not algo: algo = NETGEN
762 return Mesh_Tetrahedron(self, algo, geom)
764 ## Creates a hexahedron 3D algorithm for solids.
765 # If the optional \a geom parameter is not set, this algorithm is global.
766 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
767 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
768 # @param geom If defined, the subshape to be meshed (GEOM_Object)
769 # @return an instance of Mesh_Hexahedron algorithm
770 # @ingroup l3_algos_basic
771 def Hexahedron(self, algo=Hexa, geom=0):
772 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
773 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
774 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
775 elif geom == 0: algo, geom = Hexa, algo
776 return Mesh_Hexahedron(self, algo, geom)
778 ## Deprecated, used only for compatibility!
779 # @return an instance of Mesh_Netgen algorithm
780 # @ingroup l3_algos_basic
781 def Netgen(self, is3D, geom=0):
782 return Mesh_Netgen(self, is3D, geom)
784 ## Creates a projection 1D algorithm for edges.
785 # If the optional \a geom parameter is not set, this algorithm is global.
786 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
787 # @param geom If defined, the subshape to be meshed
788 # @return an instance of Mesh_Projection1D algorithm
789 # @ingroup l3_algos_proj
790 def Projection1D(self, geom=0):
791 return Mesh_Projection1D(self, geom)
793 ## Creates a projection 2D algorithm for faces.
794 # If the optional \a geom parameter is not set, this algorithm is global.
795 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
796 # @param geom If defined, the subshape to be meshed
797 # @return an instance of Mesh_Projection2D algorithm
798 # @ingroup l3_algos_proj
799 def Projection2D(self, geom=0):
800 return Mesh_Projection2D(self, geom)
802 ## Creates a projection 3D algorithm for solids.
803 # If the optional \a geom parameter is not set, this algorithm is global.
804 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
805 # @param geom If defined, the subshape to be meshed
806 # @return an instance of Mesh_Projection3D algorithm
807 # @ingroup l3_algos_proj
808 def Projection3D(self, geom=0):
809 return Mesh_Projection3D(self, geom)
811 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
812 # If the optional \a geom parameter is not set, this algorithm is global.
813 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
814 # @param geom If defined, the subshape to be meshed
815 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
816 # @ingroup l3_algos_radialp l3_algos_3dextr
817 def Prism(self, geom=0):
821 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
822 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
823 if nbSolids == 0 or nbSolids == nbShells:
824 return Mesh_Prism3D(self, geom)
825 return Mesh_RadialPrism3D(self, geom)
827 ## Computes the mesh and returns the status of the computation
828 # @return True or False
829 # @ingroup l2_construct
830 def Compute(self, geom=0):
831 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
833 geom = self.mesh.GetShapeToMesh()
838 ok = self.smeshpyD.Compute(self.mesh, geom)
839 except SALOME.SALOME_Exception, ex:
840 print "Mesh computation failed, exception caught:"
841 print " ", ex.details.text
844 print "Mesh computation failed, exception caught:"
845 traceback.print_exc()
847 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
858 reason = '%s %sD algorithm is missing' % (glob, dim)
859 elif err.state == HYP_MISSING:
860 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
861 % (glob, dim, name, dim))
862 elif err.state == HYP_NOTCONFORM:
863 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
864 elif err.state == HYP_BAD_PARAMETER:
865 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
866 % ( glob, dim, name ))
867 elif err.state == HYP_BAD_GEOMETRY:
868 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
869 'geometry' % ( glob, dim, name ))
871 reason = "For unknown reason."+\
872 " Revise Mesh.Compute() implementation in smeshDC.py!"
880 print '"' + GetName(self.mesh) + '"',"has not been computed:"
884 print '"' + GetName(self.mesh) + '"',"has not been computed."
887 if salome.sg.hasDesktop():
888 smeshgui = salome.ImportComponentGUI("SMESH")
889 smeshgui.Init(salome.myStudyId)
890 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
891 salome.sg.updateObjBrowser(1)
895 ## Removes all nodes and elements
896 # @ingroup l2_construct
899 if salome.sg.hasDesktop():
900 smeshgui = salome.ImportComponentGUI("SMESH")
901 smeshgui.Init(salome.myStudyId)
902 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
903 salome.sg.updateObjBrowser(1)
905 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
906 # @param fineness [0,-1] defines mesh fineness
907 # @return True or False
908 # @ingroup l3_algos_basic
909 def AutomaticTetrahedralization(self, fineness=0):
910 dim = self.MeshDimension()
912 self.RemoveGlobalHypotheses()
913 self.Segment().AutomaticLength(fineness)
915 self.Triangle().LengthFromEdges()
918 self.Tetrahedron(NETGEN)
920 return self.Compute()
922 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
923 # @param fineness [0,-1] defines mesh fineness
924 # @return True or False
925 # @ingroup l3_algos_basic
926 def AutomaticHexahedralization(self, fineness=0):
927 dim = self.MeshDimension()
928 # assign the hypotheses
929 self.RemoveGlobalHypotheses()
930 self.Segment().AutomaticLength(fineness)
937 return self.Compute()
939 ## Assigns a hypothesis
940 # @param hyp a hypothesis to assign
941 # @param geom a subhape of mesh geometry
942 # @return SMESH.Hypothesis_Status
943 # @ingroup l2_hypotheses
944 def AddHypothesis(self, hyp, geom=0):
945 if isinstance( hyp, Mesh_Algorithm ):
946 hyp = hyp.GetAlgorithm()
951 geom = self.mesh.GetShapeToMesh()
953 status = self.mesh.AddHypothesis(geom, hyp)
954 isAlgo = hyp._narrow( SMESH_Algo )
955 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
958 ## Unassigns a hypothesis
959 # @param hyp a hypothesis to unassign
960 # @param geom a subshape of mesh geometry
961 # @return SMESH.Hypothesis_Status
962 # @ingroup l2_hypotheses
963 def RemoveHypothesis(self, hyp, geom=0):
964 if isinstance( hyp, Mesh_Algorithm ):
965 hyp = hyp.GetAlgorithm()
970 status = self.mesh.RemoveHypothesis(geom, hyp)
973 ## Gets the list of hypotheses added on a geometry
974 # @param geom a subshape of mesh geometry
975 # @return the sequence of SMESH_Hypothesis
976 # @ingroup l2_hypotheses
977 def GetHypothesisList(self, geom):
978 return self.mesh.GetHypothesisList( geom )
980 ## Removes all global hypotheses
981 # @ingroup l2_hypotheses
982 def RemoveGlobalHypotheses(self):
983 current_hyps = self.mesh.GetHypothesisList( self.geom )
984 for hyp in current_hyps:
985 self.mesh.RemoveHypothesis( self.geom, hyp )
989 ## Creates a mesh group based on the geometric object \a grp
990 # and gives a \a name, \n if this parameter is not defined
991 # the name is the same as the geometric group name \n
992 # Note: Works like GroupOnGeom().
993 # @param grp a geometric group, a vertex, an edge, a face or a solid
994 # @param name the name of the mesh group
995 # @return SMESH_GroupOnGeom
996 # @ingroup l2_grps_create
997 def Group(self, grp, name=""):
998 return self.GroupOnGeom(grp, name)
1000 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1001 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1002 # @param f the file name
1003 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1004 # @ingroup l2_impexp
1005 def ExportToMED(self, f, version, opt=0):
1006 self.mesh.ExportToMED(f, opt, version)
1008 ## Exports the mesh in a file in MED format
1009 # @param f is the file name
1010 # @param auto_groups boolean parameter for creating/not creating
1011 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1012 # the typical use is auto_groups=false.
1013 # @param version MED format version(MED_V2_1 or MED_V2_2)
1014 # @ingroup l2_impexp
1015 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1016 self.mesh.ExportToMED(f, auto_groups, version)
1018 ## Exports the mesh in a file in DAT format
1019 # @param f the file name
1020 # @ingroup l2_impexp
1021 def ExportDAT(self, f):
1022 self.mesh.ExportDAT(f)
1024 ## Exports the mesh in a file in UNV format
1025 # @param f the file name
1026 # @ingroup l2_impexp
1027 def ExportUNV(self, f):
1028 self.mesh.ExportUNV(f)
1030 ## Export the mesh in a file in STL format
1031 # @param f the file name
1032 # @param ascii defines the file encoding
1033 # @ingroup l2_impexp
1034 def ExportSTL(self, f, ascii=1):
1035 self.mesh.ExportSTL(f, ascii)
1038 # Operations with groups:
1039 # ----------------------
1041 ## Creates an empty mesh group
1042 # @param elementType the type of elements in the group
1043 # @param name the name of the mesh group
1044 # @return SMESH_Group
1045 # @ingroup l2_grps_create
1046 def CreateEmptyGroup(self, elementType, name):
1047 return self.mesh.CreateGroup(elementType, name)
1049 ## Creates a mesh group based on the geometrical object \a grp
1050 # and gives a \a name, \n if this parameter is not defined
1051 # the name is the same as the geometrical group name
1052 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1053 # @param name the name of the mesh group
1054 # @param typ the type of elements in the group. If not set, it is
1055 # automatically detected by the type of the geometry
1056 # @return SMESH_GroupOnGeom
1057 # @ingroup l2_grps_create
1058 def GroupOnGeom(self, grp, name="", typ=None):
1060 name = grp.GetName()
1063 tgeo = str(grp.GetShapeType())
1064 if tgeo == "VERTEX":
1066 elif tgeo == "EDGE":
1068 elif tgeo == "FACE":
1070 elif tgeo == "SOLID":
1072 elif tgeo == "SHELL":
1074 elif tgeo == "COMPOUND":
1075 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1076 print "Mesh.Group: empty geometric group", GetName( grp )
1078 tgeo = self.geompyD.GetType(grp)
1079 if tgeo == geompyDC.ShapeType["VERTEX"]:
1081 elif tgeo == geompyDC.ShapeType["EDGE"]:
1083 elif tgeo == geompyDC.ShapeType["FACE"]:
1085 elif tgeo == geompyDC.ShapeType["SOLID"]:
1089 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1092 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1094 ## Creates a mesh group by the given ids of elements
1095 # @param groupName the name of the mesh group
1096 # @param elementType the type of elements in the group
1097 # @param elemIDs the list of ids
1098 # @return SMESH_Group
1099 # @ingroup l2_grps_create
1100 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1101 group = self.mesh.CreateGroup(elementType, groupName)
1105 ## Creates a mesh group by the given conditions
1106 # @param groupName the name of the mesh group
1107 # @param elementType the type of elements in the group
1108 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1109 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1110 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1111 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1112 # @return SMESH_Group
1113 # @ingroup l2_grps_create
1117 CritType=FT_Undefined,
1120 UnaryOp=FT_Undefined):
1121 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1122 group = self.MakeGroupByCriterion(groupName, aCriterion)
1125 ## Creates a mesh group by the given criterion
1126 # @param groupName the name of the mesh group
1127 # @param Criterion the instance of Criterion class
1128 # @return SMESH_Group
1129 # @ingroup l2_grps_create
1130 def MakeGroupByCriterion(self, groupName, Criterion):
1131 aFilterMgr = self.smeshpyD.CreateFilterManager()
1132 aFilter = aFilterMgr.CreateFilter()
1134 aCriteria.append(Criterion)
1135 aFilter.SetCriteria(aCriteria)
1136 group = self.MakeGroupByFilter(groupName, aFilter)
1139 ## Creates a mesh group by the given criteria (list of criteria)
1140 # @param groupName the name of the mesh group
1141 # @param theCriteria the list of criteria
1142 # @return SMESH_Group
1143 # @ingroup l2_grps_create
1144 def MakeGroupByCriteria(self, groupName, theCriteria):
1145 aFilterMgr = self.smeshpyD.CreateFilterManager()
1146 aFilter = aFilterMgr.CreateFilter()
1147 aFilter.SetCriteria(theCriteria)
1148 group = self.MakeGroupByFilter(groupName, aFilter)
1151 ## Creates a mesh group by the given filter
1152 # @param groupName the name of the mesh group
1153 # @param theFilter the instance of Filter class
1154 # @return SMESH_Group
1155 # @ingroup l2_grps_create
1156 def MakeGroupByFilter(self, groupName, theFilter):
1157 anIds = theFilter.GetElementsId(self.mesh)
1158 anElemType = theFilter.GetElementType()
1159 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1162 ## Passes mesh elements through the given filter and return IDs of fitting elements
1163 # @param theFilter SMESH_Filter
1164 # @return a list of ids
1165 # @ingroup l1_controls
1166 def GetIdsFromFilter(self, theFilter):
1167 return theFilter.GetElementsId(self.mesh)
1169 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1170 # Returns a list of special structures (borders).
1171 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1172 # @ingroup l1_controls
1173 def GetFreeBorders(self):
1174 aFilterMgr = self.smeshpyD.CreateFilterManager()
1175 aPredicate = aFilterMgr.CreateFreeEdges()
1176 aPredicate.SetMesh(self.mesh)
1177 aBorders = aPredicate.GetBorders()
1181 # @ingroup l2_grps_delete
1182 def RemoveGroup(self, group):
1183 self.mesh.RemoveGroup(group)
1185 ## Removes a group with its contents
1186 # @ingroup l2_grps_delete
1187 def RemoveGroupWithContents(self, group):
1188 self.mesh.RemoveGroupWithContents(group)
1190 ## Gets the list of groups existing in the mesh
1191 # @return a sequence of SMESH_GroupBase
1192 # @ingroup l2_grps_create
1193 def GetGroups(self):
1194 return self.mesh.GetGroups()
1196 ## Gets the number of groups existing in the mesh
1197 # @return the quantity of groups as an integer value
1198 # @ingroup l2_grps_create
1200 return self.mesh.NbGroups()
1202 ## Gets the list of names of groups existing in the mesh
1203 # @return list of strings
1204 # @ingroup l2_grps_create
1205 def GetGroupNames(self):
1206 groups = self.GetGroups()
1208 for group in groups:
1209 names.append(group.GetName())
1212 ## Produces a union of two groups
1213 # A new group is created. All mesh elements that are
1214 # present in the initial groups are added to the new one
1215 # @return an instance of SMESH_Group
1216 # @ingroup l2_grps_operon
1217 def UnionGroups(self, group1, group2, name):
1218 return self.mesh.UnionGroups(group1, group2, name)
1220 ## Prodices an intersection of two groups
1221 # A new group is created. All mesh elements that are common
1222 # for the two initial groups are added to the new one.
1223 # @return an instance of SMESH_Group
1224 # @ingroup l2_grps_operon
1225 def IntersectGroups(self, group1, group2, name):
1226 return self.mesh.IntersectGroups(group1, group2, name)
1228 ## Produces a cut of two groups
1229 # A new group is created. All mesh elements that are present in
1230 # the main group but are not present in the tool group are added to the new one
1231 # @return an instance of SMESH_Group
1232 # @ingroup l2_grps_operon
1233 def CutGroups(self, mainGroup, toolGroup, name):
1234 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1237 # Get some info about mesh:
1238 # ------------------------
1240 ## Returns the log of nodes and elements added or removed
1241 # since the previous clear of the log.
1242 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1243 # @return list of log_block structures:
1248 # @ingroup l1_auxiliary
1249 def GetLog(self, clearAfterGet):
1250 return self.mesh.GetLog(clearAfterGet)
1252 ## Clears the log of nodes and elements added or removed since the previous
1253 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1254 # @ingroup l1_auxiliary
1256 self.mesh.ClearLog()
1258 ## Toggles auto color mode on the object.
1259 # @param theAutoColor the flag which toggles auto color mode.
1260 # @ingroup l1_auxiliary
1261 def SetAutoColor(self, theAutoColor):
1262 self.mesh.SetAutoColor(theAutoColor)
1264 ## Gets flag of object auto color mode.
1265 # @return True or False
1266 # @ingroup l1_auxiliary
1267 def GetAutoColor(self):
1268 return self.mesh.GetAutoColor()
1270 ## Gets the internal ID
1271 # @return integer value, which is the internal Id of the mesh
1272 # @ingroup l1_auxiliary
1274 return self.mesh.GetId()
1277 # @return integer value, which is the study Id of the mesh
1278 # @ingroup l1_auxiliary
1279 def GetStudyId(self):
1280 return self.mesh.GetStudyId()
1282 ## Checks the group names for duplications.
1283 # Consider the maximum group name length stored in MED file.
1284 # @return True or False
1285 # @ingroup l1_auxiliary
1286 def HasDuplicatedGroupNamesMED(self):
1287 return self.mesh.HasDuplicatedGroupNamesMED()
1289 ## Obtains the mesh editor tool
1290 # @return an instance of SMESH_MeshEditor
1291 # @ingroup l1_modifying
1292 def GetMeshEditor(self):
1293 return self.mesh.GetMeshEditor()
1296 # @return an instance of SALOME_MED::MESH
1297 # @ingroup l1_auxiliary
1298 def GetMEDMesh(self):
1299 return self.mesh.GetMEDMesh()
1302 # Get informations about mesh contents:
1303 # ------------------------------------
1305 ## Returns the number of nodes in the mesh
1306 # @return an integer value
1307 # @ingroup l1_meshinfo
1309 return self.mesh.NbNodes()
1311 ## Returns the number of elements in the mesh
1312 # @return an integer value
1313 # @ingroup l1_meshinfo
1314 def NbElements(self):
1315 return self.mesh.NbElements()
1317 ## Returns the number of edges in the mesh
1318 # @return an integer value
1319 # @ingroup l1_meshinfo
1321 return self.mesh.NbEdges()
1323 ## Returns the number of edges with the given order in the mesh
1324 # @param elementOrder the order of elements:
1325 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1326 # @return an integer value
1327 # @ingroup l1_meshinfo
1328 def NbEdgesOfOrder(self, elementOrder):
1329 return self.mesh.NbEdgesOfOrder(elementOrder)
1331 ## Returns the number of faces in the mesh
1332 # @return an integer value
1333 # @ingroup l1_meshinfo
1335 return self.mesh.NbFaces()
1337 ## Returns the number of faces with the given order in the mesh
1338 # @param elementOrder the order of elements:
1339 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1340 # @return an integer value
1341 # @ingroup l1_meshinfo
1342 def NbFacesOfOrder(self, elementOrder):
1343 return self.mesh.NbFacesOfOrder(elementOrder)
1345 ## Returns the number of triangles in the mesh
1346 # @return an integer value
1347 # @ingroup l1_meshinfo
1348 def NbTriangles(self):
1349 return self.mesh.NbTriangles()
1351 ## Returns the number of triangles with the given order in the mesh
1352 # @param elementOrder is the order of elements:
1353 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1354 # @return an integer value
1355 # @ingroup l1_meshinfo
1356 def NbTrianglesOfOrder(self, elementOrder):
1357 return self.mesh.NbTrianglesOfOrder(elementOrder)
1359 ## Returns the number of quadrangles in the mesh
1360 # @return an integer value
1361 # @ingroup l1_meshinfo
1362 def NbQuadrangles(self):
1363 return self.mesh.NbQuadrangles()
1365 ## Returns the number of quadrangles with the given order in the mesh
1366 # @param elementOrder the order of elements:
1367 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1368 # @return an integer value
1369 # @ingroup l1_meshinfo
1370 def NbQuadranglesOfOrder(self, elementOrder):
1371 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1373 ## Returns the number of polygons in the mesh
1374 # @return an integer value
1375 # @ingroup l1_meshinfo
1376 def NbPolygons(self):
1377 return self.mesh.NbPolygons()
1379 ## Returns the number of volumes in the mesh
1380 # @return an integer value
1381 # @ingroup l1_meshinfo
1382 def NbVolumes(self):
1383 return self.mesh.NbVolumes()
1385 ## Returns the number of volumes with the given order in the mesh
1386 # @param elementOrder the order of elements:
1387 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1388 # @return an integer value
1389 # @ingroup l1_meshinfo
1390 def NbVolumesOfOrder(self, elementOrder):
1391 return self.mesh.NbVolumesOfOrder(elementOrder)
1393 ## Returns the number of tetrahedrons in the mesh
1394 # @return an integer value
1395 # @ingroup l1_meshinfo
1397 return self.mesh.NbTetras()
1399 ## Returns the number of tetrahedrons with the given order in the mesh
1400 # @param elementOrder the order of elements:
1401 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1402 # @return an integer value
1403 # @ingroup l1_meshinfo
1404 def NbTetrasOfOrder(self, elementOrder):
1405 return self.mesh.NbTetrasOfOrder(elementOrder)
1407 ## Returns the number of hexahedrons in the mesh
1408 # @return an integer value
1409 # @ingroup l1_meshinfo
1411 return self.mesh.NbHexas()
1413 ## Returns the number of hexahedrons with the given order in the mesh
1414 # @param elementOrder the order of elements:
1415 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1416 # @return an integer value
1417 # @ingroup l1_meshinfo
1418 def NbHexasOfOrder(self, elementOrder):
1419 return self.mesh.NbHexasOfOrder(elementOrder)
1421 ## Returns the number of pyramids in the mesh
1422 # @return an integer value
1423 # @ingroup l1_meshinfo
1424 def NbPyramids(self):
1425 return self.mesh.NbPyramids()
1427 ## Returns the number of pyramids with the given order in the mesh
1428 # @param elementOrder the order of elements:
1429 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1430 # @return an integer value
1431 # @ingroup l1_meshinfo
1432 def NbPyramidsOfOrder(self, elementOrder):
1433 return self.mesh.NbPyramidsOfOrder(elementOrder)
1435 ## Returns the number of prisms in the mesh
1436 # @return an integer value
1437 # @ingroup l1_meshinfo
1439 return self.mesh.NbPrisms()
1441 ## Returns the number of prisms with the given order in the mesh
1442 # @param elementOrder the order of elements:
1443 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1444 # @return an integer value
1445 # @ingroup l1_meshinfo
1446 def NbPrismsOfOrder(self, elementOrder):
1447 return self.mesh.NbPrismsOfOrder(elementOrder)
1449 ## Returns the number of polyhedrons in the mesh
1450 # @return an integer value
1451 # @ingroup l1_meshinfo
1452 def NbPolyhedrons(self):
1453 return self.mesh.NbPolyhedrons()
1455 ## Returns the number of submeshes in the mesh
1456 # @return an integer value
1457 # @ingroup l1_meshinfo
1458 def NbSubMesh(self):
1459 return self.mesh.NbSubMesh()
1461 ## Returns the list of mesh elements IDs
1462 # @return the list of integer values
1463 # @ingroup l1_meshinfo
1464 def GetElementsId(self):
1465 return self.mesh.GetElementsId()
1467 ## Returns the list of IDs of mesh elements with the given type
1468 # @param elementType the required type of elements
1469 # @return list of integer values
1470 # @ingroup l1_meshinfo
1471 def GetElementsByType(self, elementType):
1472 return self.mesh.GetElementsByType(elementType)
1474 ## Returns the list of mesh nodes IDs
1475 # @return the list of integer values
1476 # @ingroup l1_meshinfo
1477 def GetNodesId(self):
1478 return self.mesh.GetNodesId()
1480 # Get the information about mesh elements:
1481 # ------------------------------------
1483 ## Returns the type of mesh element
1484 # @return the value from SMESH::ElementType enumeration
1485 # @ingroup l1_meshinfo
1486 def GetElementType(self, id, iselem):
1487 return self.mesh.GetElementType(id, iselem)
1489 ## Returns the list of submesh elements IDs
1490 # @param Shape a geom object(subshape) IOR
1491 # Shape must be the subshape of a ShapeToMesh()
1492 # @return the list of integer values
1493 # @ingroup l1_meshinfo
1494 def GetSubMeshElementsId(self, Shape):
1495 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1496 ShapeID = Shape.GetSubShapeIndices()[0]
1499 return self.mesh.GetSubMeshElementsId(ShapeID)
1501 ## Returns the list of submesh nodes IDs
1502 # @param Shape a geom object(subshape) IOR
1503 # Shape must be the subshape of a ShapeToMesh()
1504 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1505 # @return the list of integer values
1506 # @ingroup l1_meshinfo
1507 def GetSubMeshNodesId(self, Shape, all):
1508 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1509 ShapeID = Shape.GetSubShapeIndices()[0]
1512 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1514 ## Returns the list of IDs of submesh elements with the given type
1515 # @param Shape a geom object(subshape) IOR
1516 # Shape must be a subshape of a ShapeToMesh()
1517 # @return the list of integer values
1518 # @ingroup l1_meshinfo
1519 def GetSubMeshElementType(self, Shape):
1520 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1521 ShapeID = Shape.GetSubShapeIndices()[0]
1524 return self.mesh.GetSubMeshElementType(ShapeID)
1526 ## Gets the mesh description
1527 # @return string value
1528 # @ingroup l1_meshinfo
1530 return self.mesh.Dump()
1533 # Get the information about nodes and elements of a mesh by its IDs:
1534 # -----------------------------------------------------------
1536 ## Gets XYZ coordinates of a node
1537 # \n If there is no nodes for the given ID - returns an empty list
1538 # @return a list of double precision values
1539 # @ingroup l1_meshinfo
1540 def GetNodeXYZ(self, id):
1541 return self.mesh.GetNodeXYZ(id)
1543 ## Returns list of IDs of inverse elements for the given node
1544 # \n If there is no node for the given ID - returns an empty list
1545 # @return a list of integer values
1546 # @ingroup l1_meshinfo
1547 def GetNodeInverseElements(self, id):
1548 return self.mesh.GetNodeInverseElements(id)
1550 ## @brief Returns the position of a node on the shape
1551 # @return SMESH::NodePosition
1552 # @ingroup l1_meshinfo
1553 def GetNodePosition(self,NodeID):
1554 return self.mesh.GetNodePosition(NodeID)
1556 ## If the given element is a node, returns the ID of shape
1557 # \n If there is no node for the given ID - returns -1
1558 # @return an integer value
1559 # @ingroup l1_meshinfo
1560 def GetShapeID(self, id):
1561 return self.mesh.GetShapeID(id)
1563 ## Returns the ID of the result shape after
1564 # FindShape() from SMESH_MeshEditor 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 GetShapeIDForElem(self,id):
1569 return self.mesh.GetShapeIDForElem(id)
1571 ## Returns the number of nodes for the given element
1572 # \n If there is no element for the given ID - returns -1
1573 # @return an integer value
1574 # @ingroup l1_meshinfo
1575 def GetElemNbNodes(self, id):
1576 return self.mesh.GetElemNbNodes(id)
1578 ## Returns the node ID the given index for the given element
1579 # \n If there is no element for the given ID - returns -1
1580 # \n If there is no node for the given index - returns -2
1581 # @return an integer value
1582 # @ingroup l1_meshinfo
1583 def GetElemNode(self, id, index):
1584 return self.mesh.GetElemNode(id, index)
1586 ## Returns the IDs of nodes of the given element
1587 # @return a list of integer values
1588 # @ingroup l1_meshinfo
1589 def GetElemNodes(self, id):
1590 return self.mesh.GetElemNodes(id)
1592 ## Returns true if the given node is the medium node in the given quadratic element
1593 # @ingroup l1_meshinfo
1594 def IsMediumNode(self, elementID, nodeID):
1595 return self.mesh.IsMediumNode(elementID, nodeID)
1597 ## Returns true if the given node is the medium node in one of quadratic elements
1598 # @ingroup l1_meshinfo
1599 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1600 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1602 ## Returns the number of edges for the given element
1603 # @ingroup l1_meshinfo
1604 def ElemNbEdges(self, id):
1605 return self.mesh.ElemNbEdges(id)
1607 ## Returns the number of faces for the given element
1608 # @ingroup l1_meshinfo
1609 def ElemNbFaces(self, id):
1610 return self.mesh.ElemNbFaces(id)
1612 ## Returns true if the given element is a polygon
1613 # @ingroup l1_meshinfo
1614 def IsPoly(self, id):
1615 return self.mesh.IsPoly(id)
1617 ## Returns true if the given element is quadratic
1618 # @ingroup l1_meshinfo
1619 def IsQuadratic(self, id):
1620 return self.mesh.IsQuadratic(id)
1622 ## Returns XYZ coordinates of the barycenter of the given element
1623 # \n If there is no element for the given ID - returns an empty list
1624 # @return a list of three double values
1625 # @ingroup l1_meshinfo
1626 def BaryCenter(self, id):
1627 return self.mesh.BaryCenter(id)
1630 # Mesh edition (SMESH_MeshEditor functionality):
1631 # ---------------------------------------------
1633 ## Removes the elements from the mesh by ids
1634 # @param IDsOfElements is a list of ids of elements to remove
1635 # @return True or False
1636 # @ingroup l2_modif_del
1637 def RemoveElements(self, IDsOfElements):
1638 return self.editor.RemoveElements(IDsOfElements)
1640 ## Removes nodes from mesh by ids
1641 # @param IDsOfNodes is a list of ids of nodes to remove
1642 # @return True or False
1643 # @ingroup l2_modif_del
1644 def RemoveNodes(self, IDsOfNodes):
1645 return self.editor.RemoveNodes(IDsOfNodes)
1647 ## Add a node to the mesh by coordinates
1648 # @return Id of the new node
1649 # @ingroup l2_modif_add
1650 def AddNode(self, x, y, z):
1651 return self.editor.AddNode( x, y, z)
1653 ## Creates a linear or quadratic edge (this is determined
1654 # by the number of given nodes).
1655 # @param IDsOfNodes the list of node IDs for creation of the element.
1656 # The order of nodes in this list should correspond to the description
1657 # of MED. \n This description is located by the following link:
1658 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1659 # @return the Id of the new edge
1660 # @ingroup l2_modif_add
1661 def AddEdge(self, IDsOfNodes):
1662 return self.editor.AddEdge(IDsOfNodes)
1664 ## Creates a linear or quadratic face (this is determined
1665 # by the number of given nodes).
1666 # @param IDsOfNodes the list of node IDs for creation of the element.
1667 # The order of nodes in this list should correspond to the description
1668 # of MED. \n This description is located by the following link:
1669 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1670 # @return the Id of the new face
1671 # @ingroup l2_modif_add
1672 def AddFace(self, IDsOfNodes):
1673 return self.editor.AddFace(IDsOfNodes)
1675 ## Adds a polygonal face to the mesh by the list of node IDs
1676 # @param IdsOfNodes the list of node IDs for creation of the element.
1677 # @return the Id of the new face
1678 # @ingroup l2_modif_add
1679 def AddPolygonalFace(self, IdsOfNodes):
1680 return self.editor.AddPolygonalFace(IdsOfNodes)
1682 ## Creates both simple and quadratic volume (this is determined
1683 # by the number of given nodes).
1684 # @param IDsOfNodes the list of node IDs for creation of the element.
1685 # The order of nodes in this list should correspond to the description
1686 # of MED. \n This description is located by the following link:
1687 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1688 # @return the Id of the new volumic element
1689 # @ingroup l2_modif_add
1690 def AddVolume(self, IDsOfNodes):
1691 return self.editor.AddVolume(IDsOfNodes)
1693 ## Creates a volume of many faces, giving nodes for each face.
1694 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1695 # @param Quantities the list of integer values, Quantities[i]
1696 # gives the quantity of nodes in face number i.
1697 # @return the Id of the new volumic element
1698 # @ingroup l2_modif_add
1699 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1700 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1702 ## Creates a volume of many faces, giving the IDs of the existing faces.
1703 # @param IdsOfFaces the list of face IDs for volume creation.
1705 # Note: The created volume will refer only to the nodes
1706 # of the given faces, not to the faces themselves.
1707 # @return the Id of the new volumic element
1708 # @ingroup l2_modif_add
1709 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1710 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1713 ## @brief Binds a node to a vertex
1714 # @param NodeID a node ID
1715 # @param Vertex a vertex or vertex ID
1716 # @return True if succeed else raises an exception
1717 # @ingroup l2_modif_add
1718 def SetNodeOnVertex(self, NodeID, Vertex):
1719 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1720 VertexID = Vertex.GetSubShapeIndices()[0]
1724 self.editor.SetNodeOnVertex(NodeID, VertexID)
1725 except SALOME.SALOME_Exception, inst:
1726 raise ValueError, inst.details.text
1730 ## @brief Stores the node position on an edge
1731 # @param NodeID a node ID
1732 # @param Edge an edge or edge ID
1733 # @param paramOnEdge a parameter on the edge where the node is located
1734 # @return True if succeed else raises an exception
1735 # @ingroup l2_modif_add
1736 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1737 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1738 EdgeID = Edge.GetSubShapeIndices()[0]
1742 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1743 except SALOME.SALOME_Exception, inst:
1744 raise ValueError, inst.details.text
1747 ## @brief Stores node position on a face
1748 # @param NodeID a node ID
1749 # @param Face a face or face ID
1750 # @param u U parameter on the face where the node is located
1751 # @param v V parameter on the face where the node is located
1752 # @return True if succeed else raises an exception
1753 # @ingroup l2_modif_add
1754 def SetNodeOnFace(self, NodeID, Face, u, v):
1755 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1756 FaceID = Face.GetSubShapeIndices()[0]
1760 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1761 except SALOME.SALOME_Exception, inst:
1762 raise ValueError, inst.details.text
1765 ## @brief Binds a node to a solid
1766 # @param NodeID a node ID
1767 # @param Solid a solid or solid ID
1768 # @return True if succeed else raises an exception
1769 # @ingroup l2_modif_add
1770 def SetNodeInVolume(self, NodeID, Solid):
1771 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1772 SolidID = Solid.GetSubShapeIndices()[0]
1776 self.editor.SetNodeInVolume(NodeID, SolidID)
1777 except SALOME.SALOME_Exception, inst:
1778 raise ValueError, inst.details.text
1781 ## @brief Bind an element to a shape
1782 # @param ElementID an element ID
1783 # @param Shape a shape or shape ID
1784 # @return True if succeed else raises an exception
1785 # @ingroup l2_modif_add
1786 def SetMeshElementOnShape(self, ElementID, Shape):
1787 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1788 ShapeID = Shape.GetSubShapeIndices()[0]
1792 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1793 except SALOME.SALOME_Exception, inst:
1794 raise ValueError, inst.details.text
1798 ## Moves the node with the given id
1799 # @param NodeID the id of the node
1800 # @param x a new X coordinate
1801 # @param y a new Y coordinate
1802 # @param z a new Z coordinate
1803 # @return True if succeed else False
1804 # @ingroup l2_modif_movenode
1805 def MoveNode(self, NodeID, x, y, z):
1806 return self.editor.MoveNode(NodeID, x, y, z)
1808 ## Finds the node closest to a point
1809 # @param x the X coordinate of a point
1810 # @param y the Y coordinate of a point
1811 # @param z the Z coordinate of a point
1812 # @return the ID of a node
1813 # @ingroup l2_modif_throughp
1814 def FindNodeClosestTo(self, x, y, z):
1815 preview = self.mesh.GetMeshEditPreviewer()
1816 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1818 ## Finds the node closest to a point and moves it to a point location
1819 # @param x the X coordinate of a point
1820 # @param y the Y coordinate of a point
1821 # @param z the Z coordinate of a point
1822 # @return the ID of a moved node
1823 # @ingroup l2_modif_throughp
1824 def MeshToPassThroughAPoint(self, x, y, z):
1825 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1827 ## Replaces two neighbour triangles sharing Node1-Node2 link
1828 # with the triangles built on the same 4 nodes but having other common link.
1829 # @param NodeID1 the ID of the first node
1830 # @param NodeID2 the ID of the second node
1831 # @return false if proper faces were not found
1832 # @ingroup l2_modif_invdiag
1833 def InverseDiag(self, NodeID1, NodeID2):
1834 return self.editor.InverseDiag(NodeID1, NodeID2)
1836 ## Replaces two neighbour triangles sharing Node1-Node2 link
1837 # with a quadrangle built on the same 4 nodes.
1838 # @param NodeID1 the ID of the first node
1839 # @param NodeID2 the ID of the second node
1840 # @return false if proper faces were not found
1841 # @ingroup l2_modif_unitetri
1842 def DeleteDiag(self, NodeID1, NodeID2):
1843 return self.editor.DeleteDiag(NodeID1, NodeID2)
1845 ## Reorients elements by ids
1846 # @param IDsOfElements if undefined reorients all mesh elements
1847 # @return True if succeed else False
1848 # @ingroup l2_modif_changori
1849 def Reorient(self, IDsOfElements=None):
1850 if IDsOfElements == None:
1851 IDsOfElements = self.GetElementsId()
1852 return self.editor.Reorient(IDsOfElements)
1854 ## Reorients all elements of the object
1855 # @param theObject mesh, submesh or group
1856 # @return True if succeed else False
1857 # @ingroup l2_modif_changori
1858 def ReorientObject(self, theObject):
1859 if ( isinstance( theObject, Mesh )):
1860 theObject = theObject.GetMesh()
1861 return self.editor.ReorientObject(theObject)
1863 ## Fuses the neighbouring triangles into quadrangles.
1864 # @param IDsOfElements The triangles to be fused,
1865 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1866 # @param MaxAngle is the maximum angle between element normals at which the fusion
1867 # is still performed; theMaxAngle is mesured in radians.
1868 # @return TRUE in case of success, FALSE otherwise.
1869 # @ingroup l2_modif_unitetri
1870 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1871 if IDsOfElements == []:
1872 IDsOfElements = self.GetElementsId()
1873 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1875 ## Fuses the neighbouring triangles of the object into quadrangles
1876 # @param theObject is mesh, submesh or group
1877 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1878 # @param MaxAngle a max angle between element normals at which the fusion
1879 # is still performed; theMaxAngle is mesured in radians.
1880 # @return TRUE in case of success, FALSE otherwise.
1881 # @ingroup l2_modif_unitetri
1882 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1883 if ( isinstance( theObject, Mesh )):
1884 theObject = theObject.GetMesh()
1885 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1887 ## Splits quadrangles into triangles.
1888 # @param IDsOfElements the faces to be splitted.
1889 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1890 # @return TRUE in case of success, FALSE otherwise.
1891 # @ingroup l2_modif_cutquadr
1892 def QuadToTri (self, IDsOfElements, theCriterion):
1893 if IDsOfElements == []:
1894 IDsOfElements = self.GetElementsId()
1895 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1897 ## Splits quadrangles into triangles.
1898 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1899 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1900 # @return TRUE in case of success, FALSE otherwise.
1901 # @ingroup l2_modif_cutquadr
1902 def QuadToTriObject (self, theObject, theCriterion):
1903 if ( isinstance( theObject, Mesh )):
1904 theObject = theObject.GetMesh()
1905 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1907 ## Splits quadrangles into triangles.
1908 # @param IDsOfElements the faces to be splitted
1909 # @param Diag13 is used to choose a diagonal for splitting.
1910 # @return TRUE in case of success, FALSE otherwise.
1911 # @ingroup l2_modif_cutquadr
1912 def SplitQuad (self, IDsOfElements, Diag13):
1913 if IDsOfElements == []:
1914 IDsOfElements = self.GetElementsId()
1915 return self.editor.SplitQuad(IDsOfElements, Diag13)
1917 ## Splits quadrangles into triangles.
1918 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1919 # @param Diag13 is used to choose a diagonal for splitting.
1920 # @return TRUE in case of success, FALSE otherwise.
1921 # @ingroup l2_modif_cutquadr
1922 def SplitQuadObject (self, theObject, Diag13):
1923 if ( isinstance( theObject, Mesh )):
1924 theObject = theObject.GetMesh()
1925 return self.editor.SplitQuadObject(theObject, Diag13)
1927 ## Finds a better splitting of the given quadrangle.
1928 # @param IDOfQuad the ID of the quadrangle to be splitted.
1929 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1930 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1931 # diagonal is better, 0 if error occurs.
1932 # @ingroup l2_modif_cutquadr
1933 def BestSplit (self, IDOfQuad, theCriterion):
1934 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1936 ## Splits quadrangle faces near triangular facets of volumes
1938 # @ingroup l1_auxiliary
1939 def SplitQuadsNearTriangularFacets(self):
1940 faces_array = self.GetElementsByType(SMESH.FACE)
1941 for face_id in faces_array:
1942 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1943 quad_nodes = self.mesh.GetElemNodes(face_id)
1944 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1945 isVolumeFound = False
1946 for node1_elem in node1_elems:
1947 if not isVolumeFound:
1948 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1949 nb_nodes = self.GetElemNbNodes(node1_elem)
1950 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1951 volume_elem = node1_elem
1952 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1953 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1954 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1955 isVolumeFound = True
1956 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1957 self.SplitQuad([face_id], False) # diagonal 2-4
1958 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1959 isVolumeFound = True
1960 self.SplitQuad([face_id], True) # diagonal 1-3
1961 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1962 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1963 isVolumeFound = True
1964 self.SplitQuad([face_id], True) # diagonal 1-3
1966 ## @brief Splits hexahedrons into tetrahedrons.
1968 # This operation uses pattern mapping functionality for splitting.
1969 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1970 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1971 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1972 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1973 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
1974 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1975 # @return TRUE in case of success, FALSE otherwise.
1976 # @ingroup l1_auxiliary
1977 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1978 # Pattern: 5.---------.6
1983 # (0,0,1) 4.---------.7 * |
1990 # (0,0,0) 0.---------.3
1991 pattern_tetra = "!!! Nb of points: \n 8 \n\
2001 !!! Indices of points of 6 tetras: \n\
2009 pattern = self.smeshpyD.GetPattern()
2010 isDone = pattern.LoadFromFile(pattern_tetra)
2012 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2015 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2016 isDone = pattern.MakeMesh(self.mesh, False, False)
2017 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2019 # split quafrangle faces near triangular facets of volumes
2020 self.SplitQuadsNearTriangularFacets()
2024 ## @brief Split hexahedrons into prisms.
2026 # Uses the pattern mapping functionality for splitting.
2027 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2028 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2029 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2030 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2031 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2032 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2033 # @return TRUE in case of success, FALSE otherwise.
2034 # @ingroup l1_auxiliary
2035 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2036 # Pattern: 5.---------.6
2041 # (0,0,1) 4.---------.7 |
2048 # (0,0,0) 0.---------.3
2049 pattern_prism = "!!! Nb of points: \n 8 \n\
2059 !!! Indices of points of 2 prisms: \n\
2063 pattern = self.smeshpyD.GetPattern()
2064 isDone = pattern.LoadFromFile(pattern_prism)
2066 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2069 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2070 isDone = pattern.MakeMesh(self.mesh, False, False)
2071 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2073 # Splits quafrangle faces near triangular facets of volumes
2074 self.SplitQuadsNearTriangularFacets()
2078 ## Smoothes elements
2079 # @param IDsOfElements the list if ids of elements to smooth
2080 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2081 # Note that nodes built on edges and boundary nodes are always fixed.
2082 # @param MaxNbOfIterations the maximum number of iterations
2083 # @param MaxAspectRatio varies in range [1.0, inf]
2084 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2085 # @return TRUE in case of success, FALSE otherwise.
2086 # @ingroup l2_modif_smooth
2087 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2088 MaxNbOfIterations, MaxAspectRatio, Method):
2089 if IDsOfElements == []:
2090 IDsOfElements = self.GetElementsId()
2091 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2092 MaxNbOfIterations, MaxAspectRatio, Method)
2094 ## Smoothes elements which belong to the given object
2095 # @param theObject the object to smooth
2096 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2097 # Note that nodes built on edges and boundary nodes are always fixed.
2098 # @param MaxNbOfIterations the maximum number of iterations
2099 # @param MaxAspectRatio varies in range [1.0, inf]
2100 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2101 # @return TRUE in case of success, FALSE otherwise.
2102 # @ingroup l2_modif_smooth
2103 def SmoothObject(self, theObject, IDsOfFixedNodes,
2104 MaxNbOfIterations, MaxAspectRatio, Method):
2105 if ( isinstance( theObject, Mesh )):
2106 theObject = theObject.GetMesh()
2107 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2108 MaxNbOfIterations, MaxAspectRatio, Method)
2110 ## Parametrically smoothes the given elements
2111 # @param IDsOfElements the list if ids of elements to smooth
2112 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2113 # Note that nodes built on edges and boundary nodes are always fixed.
2114 # @param MaxNbOfIterations the maximum number of iterations
2115 # @param MaxAspectRatio varies in range [1.0, inf]
2116 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2117 # @return TRUE in case of success, FALSE otherwise.
2118 # @ingroup l2_modif_smooth
2119 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2120 MaxNbOfIterations, MaxAspectRatio, Method):
2121 if IDsOfElements == []:
2122 IDsOfElements = self.GetElementsId()
2123 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2124 MaxNbOfIterations, MaxAspectRatio, Method)
2126 ## Parametrically smoothes the elements which belong to the given object
2127 # @param theObject the object to smooth
2128 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2129 # Note that nodes built on edges and boundary nodes are always fixed.
2130 # @param MaxNbOfIterations the maximum number of iterations
2131 # @param MaxAspectRatio varies in range [1.0, inf]
2132 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2133 # @return TRUE in case of success, FALSE otherwise.
2134 # @ingroup l2_modif_smooth
2135 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2136 MaxNbOfIterations, MaxAspectRatio, Method):
2137 if ( isinstance( theObject, Mesh )):
2138 theObject = theObject.GetMesh()
2139 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2140 MaxNbOfIterations, MaxAspectRatio, Method)
2142 ## Converts the mesh to quadratic, deletes old elements, replacing
2143 # them with quadratic with the same id.
2144 # @ingroup l2_modif_tofromqu
2145 def ConvertToQuadratic(self, theForce3d):
2146 self.editor.ConvertToQuadratic(theForce3d)
2148 ## Converts the mesh from quadratic to ordinary,
2149 # deletes old quadratic elements, \n replacing
2150 # them with ordinary mesh elements with the same id.
2151 # @return TRUE in case of success, FALSE otherwise.
2152 # @ingroup l2_modif_tofromqu
2153 def ConvertFromQuadratic(self):
2154 return self.editor.ConvertFromQuadratic()
2156 ## Renumber mesh nodes
2157 # @ingroup l2_modif_renumber
2158 def RenumberNodes(self):
2159 self.editor.RenumberNodes()
2161 ## Renumber mesh elements
2162 # @ingroup l2_modif_renumber
2163 def RenumberElements(self):
2164 self.editor.RenumberElements()
2166 ## Generates new elements by rotation of the elements around the axis
2167 # @param IDsOfElements the list of ids of elements to sweep
2168 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2169 # @param AngleInRadians the angle of Rotation
2170 # @param NbOfSteps the number of steps
2171 # @param Tolerance tolerance
2172 # @param MakeGroups forces the generation of new groups from existing ones
2173 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2174 # of all steps, else - size of each step
2175 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2176 # @ingroup l2_modif_extrurev
2177 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2178 MakeGroups=False, TotalAngle=False):
2179 if IDsOfElements == []:
2180 IDsOfElements = self.GetElementsId()
2181 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2182 Axis = self.smeshpyD.GetAxisStruct(Axis)
2183 if TotalAngle and NbOfSteps:
2184 AngleInRadians /= NbOfSteps
2186 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2187 AngleInRadians, NbOfSteps, Tolerance)
2188 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2191 ## Generates new elements by rotation of the elements of object around the axis
2192 # @param theObject object which elements should be sweeped
2193 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2194 # @param AngleInRadians the angle of Rotation
2195 # @param NbOfSteps number of steps
2196 # @param Tolerance tolerance
2197 # @param MakeGroups forces the generation of new groups from existing ones
2198 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2199 # of all steps, else - size of each step
2200 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2201 # @ingroup l2_modif_extrurev
2202 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2203 MakeGroups=False, TotalAngle=False):
2204 if ( isinstance( theObject, Mesh )):
2205 theObject = theObject.GetMesh()
2206 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2207 Axis = self.smeshpyD.GetAxisStruct(Axis)
2208 if TotalAngle and NbOfSteps:
2209 AngleInRadians /= NbOfSteps
2211 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2212 NbOfSteps, Tolerance)
2213 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2216 ## Generates new elements by extrusion of the elements with given ids
2217 # @param IDsOfElements the list of elements ids for extrusion
2218 # @param StepVector vector, defining the direction and value of extrusion
2219 # @param NbOfSteps the number of steps
2220 # @param MakeGroups forces the generation of new groups from existing ones
2221 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2222 # @ingroup l2_modif_extrurev
2223 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2224 if IDsOfElements == []:
2225 IDsOfElements = self.GetElementsId()
2226 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2227 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2229 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2230 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2233 ## Generates new elements by extrusion of the elements with given ids
2234 # @param IDsOfElements is ids of elements
2235 # @param StepVector vector, defining the direction and value of extrusion
2236 # @param NbOfSteps the number of steps
2237 # @param ExtrFlags sets flags for extrusion
2238 # @param SewTolerance uses for comparing locations of nodes if flag
2239 # EXTRUSION_FLAG_SEW is set
2240 # @param MakeGroups forces the generation of new groups from existing ones
2241 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2242 # @ingroup l2_modif_extrurev
2243 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2244 ExtrFlags, SewTolerance, MakeGroups=False):
2245 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2246 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2248 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2249 ExtrFlags, SewTolerance)
2250 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2251 ExtrFlags, SewTolerance)
2254 ## Generates new elements by extrusion of the elements which belong to the object
2255 # @param theObject the object which elements should be processed
2256 # @param StepVector vector, defining the direction and value of extrusion
2257 # @param NbOfSteps the number of steps
2258 # @param MakeGroups forces the generation of new groups from existing ones
2259 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2260 # @ingroup l2_modif_extrurev
2261 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2262 if ( isinstance( theObject, Mesh )):
2263 theObject = theObject.GetMesh()
2264 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2265 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2267 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2268 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2271 ## Generates new elements by extrusion of the elements which belong to the object
2272 # @param theObject object which elements should be processed
2273 # @param StepVector vector, defining the direction and value of extrusion
2274 # @param NbOfSteps the number of steps
2275 # @param MakeGroups to generate new groups from existing ones
2276 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2277 # @ingroup l2_modif_extrurev
2278 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2279 if ( isinstance( theObject, Mesh )):
2280 theObject = theObject.GetMesh()
2281 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2282 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2284 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2285 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2288 ## Generates new elements by extrusion of the elements which belong to the object
2289 # @param theObject object which elements should be processed
2290 # @param StepVector vector, defining the direction and value of extrusion
2291 # @param NbOfSteps the number of steps
2292 # @param MakeGroups forces the generation of new groups from existing ones
2293 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2294 # @ingroup l2_modif_extrurev
2295 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2296 if ( isinstance( theObject, Mesh )):
2297 theObject = theObject.GetMesh()
2298 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2299 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2301 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2302 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2305 ## Generates new elements by extrusion of the given elements
2306 # The path of extrusion must be a meshed edge.
2307 # @param IDsOfElements ids of elements
2308 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2309 # @param PathShape shape(edge) defines the sub-mesh for the path
2310 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2311 # @param HasAngles allows the shape to be rotated around the path
2312 # to get the resulting mesh in a helical fashion
2313 # @param Angles list of angles
2314 # @param HasRefPoint allows using the reference point
2315 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2316 # The User can specify any point as the Reference Point.
2317 # @param MakeGroups forces the generation of new groups from existing ones
2318 # @param LinearVariation forces the computation of rotation angles as linear
2319 # variation of the given Angles along path steps
2320 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2321 # only SMESH::Extrusion_Error otherwise
2322 # @ingroup l2_modif_extrurev
2323 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2324 HasAngles, Angles, HasRefPoint, RefPoint,
2325 MakeGroups=False, LinearVariation=False):
2326 if IDsOfElements == []:
2327 IDsOfElements = self.GetElementsId()
2328 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2329 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2331 if ( isinstance( PathMesh, Mesh )):
2332 PathMesh = PathMesh.GetMesh()
2333 if HasAngles and Angles and LinearVariation:
2334 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2337 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2338 PathShape, NodeStart, HasAngles,
2339 Angles, HasRefPoint, RefPoint)
2340 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2341 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2343 ## Generates new elements by extrusion of the elements which belong to the object
2344 # The path of extrusion must be a meshed edge.
2345 # @param theObject the object which elements should be processed
2346 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2347 # @param PathShape shape(edge) defines the sub-mesh for the path
2348 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2349 # @param HasAngles allows the shape to be rotated around the path
2350 # to get the resulting mesh in a helical fashion
2351 # @param Angles list of angles
2352 # @param HasRefPoint allows using the reference point
2353 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2354 # The User can specify any point as the Reference Point.
2355 # @param MakeGroups forces the generation of new groups from existing ones
2356 # @param LinearVariation forces the computation of rotation angles as linear
2357 # variation of the given Angles along path steps
2358 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2359 # only SMESH::Extrusion_Error otherwise
2360 # @ingroup l2_modif_extrurev
2361 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2362 HasAngles, Angles, HasRefPoint, RefPoint,
2363 MakeGroups=False, LinearVariation=False):
2364 if ( isinstance( theObject, Mesh )):
2365 theObject = theObject.GetMesh()
2366 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2367 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2368 if ( isinstance( PathMesh, Mesh )):
2369 PathMesh = PathMesh.GetMesh()
2370 if HasAngles and Angles and LinearVariation:
2371 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2374 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2375 PathShape, NodeStart, HasAngles,
2376 Angles, HasRefPoint, RefPoint)
2377 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2378 NodeStart, HasAngles, Angles, HasRefPoint,
2381 ## Creates a symmetrical copy of mesh elements
2382 # @param IDsOfElements list of elements ids
2383 # @param Mirror is AxisStruct or geom object(point, line, plane)
2384 # @param theMirrorType is POINT, AXIS or PLANE
2385 # If the Mirror is a geom object this parameter is unnecessary
2386 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2387 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2388 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2389 # @ingroup l2_modif_trsf
2390 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2391 if IDsOfElements == []:
2392 IDsOfElements = self.GetElementsId()
2393 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2394 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2395 if Copy and MakeGroups:
2396 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2397 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2400 ## Creates a new mesh by a symmetrical copy of mesh elements
2401 # @param IDsOfElements the list of elements ids
2402 # @param Mirror is AxisStruct or geom object (point, line, plane)
2403 # @param theMirrorType is POINT, AXIS or PLANE
2404 # If the Mirror is a geom object this parameter is unnecessary
2405 # @param MakeGroups to generate new groups from existing ones
2406 # @param NewMeshName a name of the new mesh to create
2407 # @return instance of Mesh class
2408 # @ingroup l2_modif_trsf
2409 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2410 if IDsOfElements == []:
2411 IDsOfElements = self.GetElementsId()
2412 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2413 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2414 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2415 MakeGroups, NewMeshName)
2416 return Mesh(self.smeshpyD,self.geompyD,mesh)
2418 ## Creates a symmetrical copy of the object
2419 # @param theObject mesh, submesh or group
2420 # @param Mirror AxisStruct or geom object (point, line, plane)
2421 # @param theMirrorType is POINT, AXIS or PLANE
2422 # If the Mirror is a geom object this parameter is unnecessary
2423 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2424 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2425 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2426 # @ingroup l2_modif_trsf
2427 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2428 if ( isinstance( theObject, Mesh )):
2429 theObject = theObject.GetMesh()
2430 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2431 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2432 if Copy and MakeGroups:
2433 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2434 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2437 ## Creates a new mesh by a symmetrical copy of the object
2438 # @param theObject mesh, submesh or group
2439 # @param Mirror AxisStruct or geom object (point, line, plane)
2440 # @param theMirrorType POINT, AXIS or PLANE
2441 # If the Mirror is a geom object this parameter is unnecessary
2442 # @param MakeGroups forces the generation of new groups from existing ones
2443 # @param NewMeshName the name of the new mesh to create
2444 # @return instance of Mesh class
2445 # @ingroup l2_modif_trsf
2446 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2447 if ( isinstance( theObject, Mesh )):
2448 theObject = theObject.GetMesh()
2449 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2450 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2451 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2452 MakeGroups, NewMeshName)
2453 return Mesh( self.smeshpyD,self.geompyD,mesh )
2455 ## Translates the elements
2456 # @param IDsOfElements list of elements ids
2457 # @param Vector the direction of translation (DirStruct or vector)
2458 # @param Copy allows copying the translated elements
2459 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2460 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2461 # @ingroup l2_modif_trsf
2462 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2463 if IDsOfElements == []:
2464 IDsOfElements = self.GetElementsId()
2465 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2466 Vector = self.smeshpyD.GetDirStruct(Vector)
2467 if Copy and MakeGroups:
2468 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2469 self.editor.Translate(IDsOfElements, Vector, Copy)
2472 ## Creates a new mesh of translated elements
2473 # @param IDsOfElements list of elements ids
2474 # @param Vector the direction of translation (DirStruct or vector)
2475 # @param MakeGroups forces the generation of new groups from existing ones
2476 # @param NewMeshName the name of the newly created mesh
2477 # @return instance of Mesh class
2478 # @ingroup l2_modif_trsf
2479 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2480 if IDsOfElements == []:
2481 IDsOfElements = self.GetElementsId()
2482 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2483 Vector = self.smeshpyD.GetDirStruct(Vector)
2484 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2485 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2487 ## Translates the object
2488 # @param theObject the object to translate (mesh, submesh, or group)
2489 # @param Vector direction of translation (DirStruct or geom vector)
2490 # @param Copy allows copying the translated elements
2491 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2492 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2493 # @ingroup l2_modif_trsf
2494 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2495 if ( isinstance( theObject, Mesh )):
2496 theObject = theObject.GetMesh()
2497 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2498 Vector = self.smeshpyD.GetDirStruct(Vector)
2499 if Copy and MakeGroups:
2500 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2501 self.editor.TranslateObject(theObject, Vector, Copy)
2504 ## Creates a new mesh from the translated object
2505 # @param theObject the object to translate (mesh, submesh, or group)
2506 # @param Vector the direction of translation (DirStruct or geom vector)
2507 # @param MakeGroups forces the generation of new groups from existing ones
2508 # @param NewMeshName the name of the newly created mesh
2509 # @return instance of Mesh class
2510 # @ingroup l2_modif_trsf
2511 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2512 if (isinstance(theObject, Mesh)):
2513 theObject = theObject.GetMesh()
2514 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2515 Vector = self.smeshpyD.GetDirStruct(Vector)
2516 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2517 return Mesh( self.smeshpyD, self.geompyD, mesh )
2519 ## Rotates the elements
2520 # @param IDsOfElements list of elements ids
2521 # @param Axis the axis of rotation (AxisStruct or geom line)
2522 # @param AngleInRadians the angle of rotation (in radians)
2523 # @param Copy allows copying the rotated elements
2524 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2525 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2526 # @ingroup l2_modif_trsf
2527 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2528 if IDsOfElements == []:
2529 IDsOfElements = self.GetElementsId()
2530 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2531 Axis = self.smeshpyD.GetAxisStruct(Axis)
2532 if Copy and MakeGroups:
2533 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2534 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2537 ## Creates a new mesh of rotated elements
2538 # @param IDsOfElements list of element ids
2539 # @param Axis the axis of rotation (AxisStruct or geom line)
2540 # @param AngleInRadians the angle of rotation (in radians)
2541 # @param MakeGroups forces the generation of new groups from existing ones
2542 # @param NewMeshName the name of the newly created mesh
2543 # @return instance of Mesh class
2544 # @ingroup l2_modif_trsf
2545 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2546 if IDsOfElements == []:
2547 IDsOfElements = self.GetElementsId()
2548 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2549 Axis = self.smeshpyD.GetAxisStruct(Axis)
2550 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2551 MakeGroups, NewMeshName)
2552 return Mesh( self.smeshpyD, self.geompyD, mesh )
2554 ## Rotates the object
2555 # @param theObject the object to rotate( mesh, submesh, or group)
2556 # @param Axis the axis of rotation (AxisStruct or geom line)
2557 # @param AngleInRadians the angle of rotation (in radians)
2558 # @param Copy allows copying the rotated elements
2559 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2560 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2561 # @ingroup l2_modif_trsf
2562 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2563 if (isinstance(theObject, Mesh)):
2564 theObject = theObject.GetMesh()
2565 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2566 Axis = self.smeshpyD.GetAxisStruct(Axis)
2567 if Copy and MakeGroups:
2568 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2569 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2572 ## Creates a new mesh from the rotated object
2573 # @param theObject the object to rotate (mesh, submesh, or group)
2574 # @param Axis the axis of rotation (AxisStruct or geom line)
2575 # @param AngleInRadians the angle of rotation (in radians)
2576 # @param MakeGroups forces the generation of new groups from existing ones
2577 # @param NewMeshName the name of the newly created mesh
2578 # @return instance of Mesh class
2579 # @ingroup l2_modif_trsf
2580 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2581 if (isinstance( theObject, Mesh )):
2582 theObject = theObject.GetMesh()
2583 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2584 Axis = self.smeshpyD.GetAxisStruct(Axis)
2585 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2586 MakeGroups, NewMeshName)
2587 return Mesh( self.smeshpyD, self.geompyD, mesh )
2589 ## Finds groups of ajacent nodes within Tolerance.
2590 # @param Tolerance the value of tolerance
2591 # @return the list of groups of nodes
2592 # @ingroup l2_modif_trsf
2593 def FindCoincidentNodes (self, Tolerance):
2594 return self.editor.FindCoincidentNodes(Tolerance)
2596 ## Finds groups of ajacent nodes within Tolerance.
2597 # @param Tolerance the value of tolerance
2598 # @param SubMeshOrGroup SubMesh or Group
2599 # @return the list of groups of nodes
2600 # @ingroup l2_modif_trsf
2601 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2602 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2605 # @param GroupsOfNodes the list of groups of nodes
2606 # @ingroup l2_modif_trsf
2607 def MergeNodes (self, GroupsOfNodes):
2608 self.editor.MergeNodes(GroupsOfNodes)
2610 ## Finds the elements built on the same nodes.
2611 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2612 # @return a list of groups of equal elements
2613 # @ingroup l2_modif_trsf
2614 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2615 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2617 ## Merges elements in each given group.
2618 # @param GroupsOfElementsID groups of elements for merging
2619 # @ingroup l2_modif_trsf
2620 def MergeElements(self, GroupsOfElementsID):
2621 self.editor.MergeElements(GroupsOfElementsID)
2623 ## Leaves one element and removes all other elements built on the same nodes.
2624 # @ingroup l2_modif_trsf
2625 def MergeEqualElements(self):
2626 self.editor.MergeEqualElements()
2628 ## Sews free borders
2629 # @return SMESH::Sew_Error
2630 # @ingroup l2_modif_trsf
2631 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2632 FirstNodeID2, SecondNodeID2, LastNodeID2,
2633 CreatePolygons, CreatePolyedrs):
2634 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2635 FirstNodeID2, SecondNodeID2, LastNodeID2,
2636 CreatePolygons, CreatePolyedrs)
2638 ## Sews conform free borders
2639 # @return SMESH::Sew_Error
2640 # @ingroup l2_modif_trsf
2641 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2642 FirstNodeID2, SecondNodeID2):
2643 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2644 FirstNodeID2, SecondNodeID2)
2646 ## Sews border to side
2647 # @return SMESH::Sew_Error
2648 # @ingroup l2_modif_trsf
2649 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2650 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2651 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2652 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2654 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2655 # merged with the nodes of elements of Side2.
2656 # The number of elements in theSide1 and in theSide2 must be
2657 # equal and they should have similar nodal connectivity.
2658 # The nodes to merge should belong to side borders and
2659 # the first node should be linked to the second.
2660 # @return SMESH::Sew_Error
2661 # @ingroup l2_modif_trsf
2662 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2663 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2664 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2665 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2666 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2667 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2669 ## Sets new nodes for the given element.
2670 # @param ide the element id
2671 # @param newIDs nodes ids
2672 # @return If the number of nodes does not correspond to the type of element - returns false
2673 # @ingroup l2_modif_edit
2674 def ChangeElemNodes(self, ide, newIDs):
2675 return self.editor.ChangeElemNodes(ide, newIDs)
2677 ## If during the last operation of MeshEditor some nodes were
2678 # created, this method returns the list of their IDs, \n
2679 # if new nodes were not created - returns empty list
2680 # @return the list of integer values (can be empty)
2681 # @ingroup l1_auxiliary
2682 def GetLastCreatedNodes(self):
2683 return self.editor.GetLastCreatedNodes()
2685 ## If during the last operation of MeshEditor some elements were
2686 # created this method returns the list of their IDs, \n
2687 # if new elements were not created - returns empty list
2688 # @return the list of integer values (can be empty)
2689 # @ingroup l1_auxiliary
2690 def GetLastCreatedElems(self):
2691 return self.editor.GetLastCreatedElems()
2693 ## The mother class to define algorithm, it is not recommended to use it directly.
2696 # @ingroup l2_algorithms
2697 class Mesh_Algorithm:
2698 # @class Mesh_Algorithm
2699 # @brief Class Mesh_Algorithm
2701 #def __init__(self,smesh):
2709 ## Finds a hypothesis in the study by its type name and parameters.
2710 # Finds only the hypotheses created in smeshpyD engine.
2711 # @return SMESH.SMESH_Hypothesis
2712 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2713 study = smeshpyD.GetCurrentStudy()
2714 #to do: find component by smeshpyD object, not by its data type
2715 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2716 if scomp is not None:
2717 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2718 # Check if the root label of the hypotheses exists
2719 if res and hypRoot is not None:
2720 iter = study.NewChildIterator(hypRoot)
2721 # Check all published hypotheses
2723 hypo_so_i = iter.Value()
2724 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2725 if attr is not None:
2726 anIOR = attr.Value()
2727 hypo_o_i = salome.orb.string_to_object(anIOR)
2728 if hypo_o_i is not None:
2729 # Check if this is a hypothesis
2730 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2731 if hypo_i is not None:
2732 # Check if the hypothesis belongs to current engine
2733 if smeshpyD.GetObjectId(hypo_i) > 0:
2734 # Check if this is the required hypothesis
2735 if hypo_i.GetName() == hypname:
2737 if CompareMethod(hypo_i, args):
2751 ## Finds the algorithm in the study by its type name.
2752 # Finds only the algorithms, which have been created in smeshpyD engine.
2753 # @return SMESH.SMESH_Algo
2754 def FindAlgorithm (self, algoname, smeshpyD):
2755 study = smeshpyD.GetCurrentStudy()
2756 #to do: find component by smeshpyD object, not by its data type
2757 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2758 if scomp is not None:
2759 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2760 # Check if the root label of the algorithms exists
2761 if res and hypRoot is not None:
2762 iter = study.NewChildIterator(hypRoot)
2763 # Check all published algorithms
2765 algo_so_i = iter.Value()
2766 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2767 if attr is not None:
2768 anIOR = attr.Value()
2769 algo_o_i = salome.orb.string_to_object(anIOR)
2770 if algo_o_i is not None:
2771 # Check if this is an algorithm
2772 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2773 if algo_i is not None:
2774 # Checks if the algorithm belongs to the current engine
2775 if smeshpyD.GetObjectId(algo_i) > 0:
2776 # Check if this is the required algorithm
2777 if algo_i.GetName() == algoname:
2790 ## If the algorithm is global, returns 0; \n
2791 # else returns the submesh associated to this algorithm.
2792 def GetSubMesh(self):
2795 ## Returns the wrapped mesher.
2796 def GetAlgorithm(self):
2799 ## Gets the list of hypothesis that can be used with this algorithm
2800 def GetCompatibleHypothesis(self):
2803 mylist = self.algo.GetCompatibleHypothesis()
2806 ## Gets the name of the algorithm
2810 ## Sets the name to the algorithm
2811 def SetName(self, name):
2812 SetName(self.algo, name)
2814 ## Gets the id of the algorithm
2816 return self.algo.GetId()
2819 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2821 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2822 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2824 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2826 self.Assign(algo, mesh, geom)
2830 def Assign(self, algo, mesh, geom):
2832 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2839 name = GetName(geom)
2841 name = mesh.geompyD.SubShapeName(geom, piece)
2842 mesh.geompyD.addToStudyInFather(piece, geom, name)
2843 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2846 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2847 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2849 def CompareHyp (self, hyp, args):
2850 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2853 def CompareEqualHyp (self, hyp, args):
2857 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2858 UseExisting=0, CompareMethod=""):
2861 if CompareMethod == "": CompareMethod = self.CompareHyp
2862 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2865 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2871 a = a + s + str(args[i])
2875 SetName(hypo, hyp + a)
2877 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2878 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2882 # Public class: Mesh_Segment
2883 # --------------------------
2885 ## Class to define a segment 1D algorithm for discretization
2888 # @ingroup l3_algos_basic
2889 class Mesh_Segment(Mesh_Algorithm):
2891 ## Private constructor.
2892 def __init__(self, mesh, geom=0):
2893 Mesh_Algorithm.__init__(self)
2894 self.Create(mesh, geom, "Regular_1D")
2896 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2897 # @param l for the length of segments that cut an edge
2898 # @param UseExisting if ==true - searches for an existing hypothesis created with
2899 # the same parameters, else (default) - creates a new one
2900 # @param p precision, used for calculation of the number of segments.
2901 # The precision should be a positive, meaningful value within the range [0,1].
2902 # In general, the number of segments is calculated with the formula:
2903 # nb = ceil((edge_length / l) - p)
2904 # Function ceil rounds its argument to the higher integer.
2905 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2906 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2907 # p=1 means rounding of (edge_length / l) to the lower integer.
2908 # Default value is 1e-07.
2909 # @return an instance of StdMeshers_LocalLength hypothesis
2910 # @ingroup l3_hypos_1dhyps
2911 def LocalLength(self, l, UseExisting=0, p=1e-07):
2912 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2913 CompareMethod=self.CompareLocalLength)
2919 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2920 def CompareLocalLength(self, hyp, args):
2921 if IsEqual(hyp.GetLength(), args[0]):
2922 return IsEqual(hyp.GetPrecision(), args[1])
2925 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2926 # @param n for the number of segments that cut an edge
2927 # @param s for the scale factor (optional)
2928 # @param UseExisting if ==true - searches for an existing hypothesis created with
2929 # the same parameters, else (default) - create a new one
2930 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2931 # @ingroup l3_hypos_1dhyps
2932 def NumberOfSegments(self, n, s=[], UseExisting=0):
2934 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2935 CompareMethod=self.CompareNumberOfSegments)
2937 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2938 CompareMethod=self.CompareNumberOfSegments)
2939 hyp.SetDistrType( 1 )
2940 hyp.SetScaleFactor(s)
2941 hyp.SetNumberOfSegments(n)
2945 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2946 def CompareNumberOfSegments(self, hyp, args):
2947 if hyp.GetNumberOfSegments() == args[0]:
2951 if hyp.GetDistrType() == 1:
2952 if IsEqual(hyp.GetScaleFactor(), args[1]):
2956 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2957 # @param start defines the length of the first segment
2958 # @param end defines the length of the last segment
2959 # @param UseExisting if ==true - searches for an existing hypothesis created with
2960 # the same parameters, else (default) - creates a new one
2961 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2962 # @ingroup l3_hypos_1dhyps
2963 def Arithmetic1D(self, start, end, UseExisting=0):
2964 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2965 CompareMethod=self.CompareArithmetic1D)
2966 hyp.SetLength(start, 1)
2967 hyp.SetLength(end , 0)
2971 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2972 def CompareArithmetic1D(self, hyp, args):
2973 if IsEqual(hyp.GetLength(1), args[0]):
2974 if IsEqual(hyp.GetLength(0), args[1]):
2978 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2979 # @param start defines the length of the first segment
2980 # @param end defines the length of the last segment
2981 # @param UseExisting if ==true - searches for an existing hypothesis created with
2982 # the same parameters, else (default) - creates a new one
2983 # @return an instance of StdMeshers_StartEndLength hypothesis
2984 # @ingroup l3_hypos_1dhyps
2985 def StartEndLength(self, start, end, UseExisting=0):
2986 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
2987 CompareMethod=self.CompareStartEndLength)
2988 hyp.SetLength(start, 1)
2989 hyp.SetLength(end , 0)
2992 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
2993 def CompareStartEndLength(self, hyp, args):
2994 if IsEqual(hyp.GetLength(1), args[0]):
2995 if IsEqual(hyp.GetLength(0), args[1]):
2999 ## Defines "Deflection1D" hypothesis
3000 # @param d for the deflection
3001 # @param UseExisting if ==true - searches for an existing hypothesis created with
3002 # the same parameters, else (default) - create a new one
3003 # @ingroup l3_hypos_1dhyps
3004 def Deflection1D(self, d, UseExisting=0):
3005 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3006 CompareMethod=self.CompareDeflection1D)
3007 hyp.SetDeflection(d)
3010 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3011 def CompareDeflection1D(self, hyp, args):
3012 return IsEqual(hyp.GetDeflection(), args[0])
3014 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3015 # the opposite side in case of quadrangular faces
3016 # @ingroup l3_hypos_additi
3017 def Propagation(self):
3018 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3020 ## Defines "AutomaticLength" hypothesis
3021 # @param fineness for the fineness [0-1]
3022 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3023 # same parameters, else (default) - create a new one
3024 # @ingroup l3_hypos_1dhyps
3025 def AutomaticLength(self, fineness=0, UseExisting=0):
3026 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3027 CompareMethod=self.CompareAutomaticLength)
3028 hyp.SetFineness( fineness )
3031 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3032 def CompareAutomaticLength(self, hyp, args):
3033 return IsEqual(hyp.GetFineness(), args[0])
3035 ## Defines "SegmentLengthAroundVertex" hypothesis
3036 # @param length for the segment length
3037 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3038 # Any other integer value means that the hypothesis will be set on the
3039 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3040 # @param UseExisting if ==true - searches for an existing hypothesis created with
3041 # the same parameters, else (default) - creates a new one
3042 # @ingroup l3_algos_segmarv
3043 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3045 store_geom = self.geom
3046 if type(vertex) is types.IntType:
3047 if vertex == 0 or vertex == 1:
3048 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3056 if self.geom is None:
3057 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3058 name = GetName(self.geom)
3060 piece = self.mesh.geom
3061 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3062 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3063 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3065 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3067 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3068 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3070 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3071 CompareMethod=self.CompareLengthNearVertex)
3072 self.geom = store_geom
3073 hyp.SetLength( length )
3076 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3077 # @ingroup l3_algos_segmarv
3078 def CompareLengthNearVertex(self, hyp, args):
3079 return IsEqual(hyp.GetLength(), args[0])
3081 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3082 # If the 2D mesher sees that all boundary edges are quadratic,
3083 # it generates quadratic faces, else it generates linear faces using
3084 # medium nodes as if they are vertices.
3085 # The 3D mesher generates quadratic volumes only if all boundary faces
3086 # are quadratic, else it fails.
3088 # @ingroup l3_hypos_additi
3089 def QuadraticMesh(self):
3090 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3093 # Public class: Mesh_CompositeSegment
3094 # --------------------------
3096 ## Defines a segment 1D algorithm for discretization
3098 # @ingroup l3_algos_basic
3099 class Mesh_CompositeSegment(Mesh_Segment):
3101 ## Private constructor.
3102 def __init__(self, mesh, geom=0):
3103 self.Create(mesh, geom, "CompositeSegment_1D")
3106 # Public class: Mesh_Segment_Python
3107 # ---------------------------------
3109 ## Defines a segment 1D algorithm for discretization with python function
3111 # @ingroup l3_algos_basic
3112 class Mesh_Segment_Python(Mesh_Segment):
3114 ## Private constructor.
3115 def __init__(self, mesh, geom=0):
3116 import Python1dPlugin
3117 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3119 ## Defines "PythonSplit1D" hypothesis
3120 # @param n for the number of segments that cut an edge
3121 # @param func for the python function that calculates the length of all segments
3122 # @param UseExisting if ==true - searches for the existing hypothesis created with
3123 # the same parameters, else (default) - creates a new one
3124 # @ingroup l3_hypos_1dhyps
3125 def PythonSplit1D(self, n, func, UseExisting=0):
3126 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3127 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3128 hyp.SetNumberOfSegments(n)
3129 hyp.SetPythonLog10RatioFunction(func)
3132 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3133 def ComparePythonSplit1D(self, hyp, args):
3134 #if hyp.GetNumberOfSegments() == args[0]:
3135 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3139 # Public class: Mesh_Triangle
3140 # ---------------------------
3142 ## Defines a triangle 2D algorithm
3144 # @ingroup l3_algos_basic
3145 class Mesh_Triangle(Mesh_Algorithm):
3154 ## Private constructor.
3155 def __init__(self, mesh, algoType, geom=0):
3156 Mesh_Algorithm.__init__(self)
3158 self.algoType = algoType
3159 if algoType == MEFISTO:
3160 self.Create(mesh, geom, "MEFISTO_2D")
3162 elif algoType == BLSURF:
3164 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3165 #self.SetPhysicalMesh() - PAL19680
3166 elif algoType == NETGEN:
3168 print "Warning: NETGENPlugin module unavailable"
3170 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3172 elif algoType == NETGEN_2D:
3174 print "Warning: NETGENPlugin module unavailable"
3176 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3179 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3180 # @param area for the maximum area of each triangle
3181 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3182 # same parameters, else (default) - creates a new one
3184 # Only for algoType == MEFISTO || NETGEN_2D
3185 # @ingroup l3_hypos_2dhyps
3186 def MaxElementArea(self, area, UseExisting=0):
3187 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3188 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3189 CompareMethod=self.CompareMaxElementArea)
3190 elif self.algoType == NETGEN:
3191 hyp = self.Parameters(SIMPLE)
3192 hyp.SetMaxElementArea(area)
3195 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3196 def CompareMaxElementArea(self, hyp, args):
3197 return IsEqual(hyp.GetMaxElementArea(), args[0])
3199 ## Defines "LengthFromEdges" hypothesis to build triangles
3200 # based on the length of the edges taken from the wire
3202 # Only for algoType == MEFISTO || NETGEN_2D
3203 # @ingroup l3_hypos_2dhyps
3204 def LengthFromEdges(self):
3205 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3206 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3208 elif self.algoType == NETGEN:
3209 hyp = self.Parameters(SIMPLE)
3210 hyp.LengthFromEdges()
3213 ## Sets a way to define size of mesh elements to generate.
3214 # @param thePhysicalMesh is: DefaultSize or Custom.
3215 # @ingroup l3_hypos_blsurf
3216 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3217 # Parameter of BLSURF algo
3218 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3220 ## Sets size of mesh elements to generate.
3221 # @ingroup l3_hypos_blsurf
3222 def SetPhySize(self, theVal):
3223 # Parameter of BLSURF algo
3224 self.Parameters().SetPhySize(theVal)
3226 ## Sets lower boundary of mesh element size (PhySize).
3227 # @ingroup l3_hypos_blsurf
3228 def SetPhyMin(self, theVal=-1):
3229 # Parameter of BLSURF algo
3230 self.Parameters().SetPhyMin(theVal)
3232 ## Sets upper boundary of mesh element size (PhySize).
3233 # @ingroup l3_hypos_blsurf
3234 def SetPhyMax(self, theVal=-1):
3235 # Parameter of BLSURF algo
3236 self.Parameters().SetPhyMax(theVal)
3238 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3239 # @param theGeometricMesh is: DefaultGeom or Custom
3240 # @ingroup l3_hypos_blsurf
3241 def SetGeometricMesh(self, theGeometricMesh=0):
3242 # Parameter of BLSURF algo
3243 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3244 self.params.SetGeometricMesh(theGeometricMesh)
3246 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3247 # @ingroup l3_hypos_blsurf
3248 def SetAngleMeshS(self, theVal=_angleMeshS):
3249 # Parameter of BLSURF algo
3250 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3251 self.params.SetAngleMeshS(theVal)
3253 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3254 # @ingroup l3_hypos_blsurf
3255 def SetAngleMeshC(self, theVal=_angleMeshS):
3256 # Parameter of BLSURF algo
3257 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3258 self.params.SetAngleMeshC(theVal)
3260 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3261 # @ingroup l3_hypos_blsurf
3262 def SetGeoMin(self, theVal=-1):
3263 # Parameter of BLSURF algo
3264 self.Parameters().SetGeoMin(theVal)
3266 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3267 # @ingroup l3_hypos_blsurf
3268 def SetGeoMax(self, theVal=-1):
3269 # Parameter of BLSURF algo
3270 self.Parameters().SetGeoMax(theVal)
3272 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3273 # @ingroup l3_hypos_blsurf
3274 def SetGradation(self, theVal=_gradation):
3275 # Parameter of BLSURF algo
3276 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3277 self.params.SetGradation(theVal)
3279 ## Sets topology usage way.
3280 # @param way defines how mesh conformity is assured <ul>
3281 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3282 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3283 # @ingroup l3_hypos_blsurf
3284 def SetTopology(self, way):
3285 # Parameter of BLSURF algo
3286 self.Parameters().SetTopology(way)
3288 ## To respect geometrical edges or not.
3289 # @ingroup l3_hypos_blsurf
3290 def SetDecimesh(self, toIgnoreEdges=False):
3291 # Parameter of BLSURF algo
3292 self.Parameters().SetDecimesh(toIgnoreEdges)
3294 ## Sets verbosity level in the range 0 to 100.
3295 # @ingroup l3_hypos_blsurf
3296 def SetVerbosity(self, level):
3297 # Parameter of BLSURF algo
3298 self.Parameters().SetVerbosity(level)
3300 ## Sets advanced option value.
3301 # @ingroup l3_hypos_blsurf
3302 def SetOptionValue(self, optionName, level):
3303 # Parameter of BLSURF algo
3304 self.Parameters().SetOptionValue(optionName,level)
3306 ## Sets QuadAllowed flag.
3307 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3308 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3309 def SetQuadAllowed(self, toAllow=True):
3310 if self.algoType == NETGEN_2D:
3311 if toAllow: # add QuadranglePreference
3312 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3313 else: # remove QuadranglePreference
3314 for hyp in self.mesh.GetHypothesisList( self.geom ):
3315 if hyp.GetName() == "QuadranglePreference":
3316 self.mesh.RemoveHypothesis( self.geom, hyp )
3321 if self.Parameters():
3322 self.params.SetQuadAllowed(toAllow)
3325 ## Defines hypothesis having several parameters
3327 # @ingroup l3_hypos_netgen
3328 def Parameters(self, which=SOLE):
3331 if self.algoType == NETGEN:
3333 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3334 "libNETGENEngine.so", UseExisting=0)
3336 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3337 "libNETGENEngine.so", UseExisting=0)
3339 elif self.algoType == MEFISTO:
3340 print "Mefisto algo support no multi-parameter hypothesis"
3342 elif self.algoType == NETGEN_2D:
3343 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3344 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3346 elif self.algoType == BLSURF:
3347 self.params = self.Hypothesis("BLSURF_Parameters", [],
3348 "libBLSURFEngine.so", UseExisting=0)
3351 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3356 # Only for algoType == NETGEN
3357 # @ingroup l3_hypos_netgen
3358 def SetMaxSize(self, theSize):
3359 if self.Parameters():
3360 self.params.SetMaxSize(theSize)
3362 ## Sets SecondOrder flag
3364 # Only for algoType == NETGEN
3365 # @ingroup l3_hypos_netgen
3366 def SetSecondOrder(self, theVal):
3367 if self.Parameters():
3368 self.params.SetSecondOrder(theVal)
3370 ## Sets Optimize flag
3372 # Only for algoType == NETGEN
3373 # @ingroup l3_hypos_netgen
3374 def SetOptimize(self, theVal):
3375 if self.Parameters():
3376 self.params.SetOptimize(theVal)
3379 # @param theFineness is:
3380 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3382 # Only for algoType == NETGEN
3383 # @ingroup l3_hypos_netgen
3384 def SetFineness(self, theFineness):
3385 if self.Parameters():
3386 self.params.SetFineness(theFineness)
3390 # Only for algoType == NETGEN
3391 # @ingroup l3_hypos_netgen
3392 def SetGrowthRate(self, theRate):
3393 if self.Parameters():
3394 self.params.SetGrowthRate(theRate)
3396 ## Sets NbSegPerEdge
3398 # Only for algoType == NETGEN
3399 # @ingroup l3_hypos_netgen
3400 def SetNbSegPerEdge(self, theVal):
3401 if self.Parameters():
3402 self.params.SetNbSegPerEdge(theVal)
3404 ## Sets NbSegPerRadius
3406 # Only for algoType == NETGEN
3407 # @ingroup l3_hypos_netgen
3408 def SetNbSegPerRadius(self, theVal):
3409 if self.Parameters():
3410 self.params.SetNbSegPerRadius(theVal)
3412 ## Sets number of segments overriding value set by SetLocalLength()
3414 # Only for algoType == NETGEN
3415 # @ingroup l3_hypos_netgen
3416 def SetNumberOfSegments(self, theVal):
3417 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3419 ## Sets number of segments overriding value set by SetNumberOfSegments()
3421 # Only for algoType == NETGEN
3422 # @ingroup l3_hypos_netgen
3423 def SetLocalLength(self, theVal):
3424 self.Parameters(SIMPLE).SetLocalLength(theVal)
3429 # Public class: Mesh_Quadrangle
3430 # -----------------------------
3432 ## Defines a quadrangle 2D algorithm
3434 # @ingroup l3_algos_basic
3435 class Mesh_Quadrangle(Mesh_Algorithm):
3437 ## Private constructor.
3438 def __init__(self, mesh, geom=0):
3439 Mesh_Algorithm.__init__(self)
3440 self.Create(mesh, geom, "Quadrangle_2D")
3442 ## Defines "QuadranglePreference" hypothesis, forcing construction
3443 # of quadrangles if the number of nodes on the opposite edges is not the same
3444 # while the total number of nodes on edges is even
3446 # @ingroup l3_hypos_additi
3447 def QuadranglePreference(self):
3448 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3449 CompareMethod=self.CompareEqualHyp)
3452 ## Defines "TrianglePreference" hypothesis, forcing construction
3453 # of triangles in the refinement area if the number of nodes
3454 # on the opposite edges is not the same
3456 # @ingroup l3_hypos_additi
3457 def TrianglePreference(self):
3458 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3459 CompareMethod=self.CompareEqualHyp)
3462 # Public class: Mesh_Tetrahedron
3463 # ------------------------------
3465 ## Defines a tetrahedron 3D algorithm
3467 # @ingroup l3_algos_basic
3468 class Mesh_Tetrahedron(Mesh_Algorithm):
3473 ## Private constructor.
3474 def __init__(self, mesh, algoType, geom=0):
3475 Mesh_Algorithm.__init__(self)
3477 if algoType == NETGEN:
3478 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3481 elif algoType == FULL_NETGEN:
3483 print "Warning: NETGENPlugin module has not been imported."
3484 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3487 elif algoType == GHS3D:
3489 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3492 self.algoType = algoType
3494 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3495 # @param vol for the maximum volume of each tetrahedron
3496 # @param UseExisting if ==true - searches for the existing hypothesis created with
3497 # the same parameters, else (default) - creates a new one
3498 # @ingroup l3_hypos_maxvol
3499 def MaxElementVolume(self, vol, UseExisting=0):
3500 if self.algoType == NETGEN:
3501 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3502 CompareMethod=self.CompareMaxElementVolume)
3503 hyp.SetMaxElementVolume(vol)
3505 elif self.algoType == FULL_NETGEN:
3506 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3509 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3510 def CompareMaxElementVolume(self, hyp, args):
3511 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3513 ## Defines hypothesis having several parameters
3515 # @ingroup l3_hypos_netgen
3516 def Parameters(self, which=SOLE):
3519 if self.algoType == FULL_NETGEN:
3521 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3522 "libNETGENEngine.so", UseExisting=0)
3524 self.params = self.Hypothesis("NETGEN_Parameters", [],
3525 "libNETGENEngine.so", UseExisting=0)
3527 if self.algoType == GHS3D:
3528 self.params = self.Hypothesis("GHS3D_Parameters", [],
3529 "libGHS3DEngine.so", UseExisting=0)
3532 print "Algo supports no multi-parameter hypothesis"
3536 # Parameter of FULL_NETGEN
3537 # @ingroup l3_hypos_netgen
3538 def SetMaxSize(self, theSize):
3539 self.Parameters().SetMaxSize(theSize)
3541 ## Sets SecondOrder flag
3542 # Parameter of FULL_NETGEN
3543 # @ingroup l3_hypos_netgen
3544 def SetSecondOrder(self, theVal):
3545 self.Parameters().SetSecondOrder(theVal)
3547 ## Sets Optimize flag
3548 # Parameter of FULL_NETGEN
3549 # @ingroup l3_hypos_netgen
3550 def SetOptimize(self, theVal):
3551 self.Parameters().SetOptimize(theVal)
3554 # @param theFineness is:
3555 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3556 # Parameter of FULL_NETGEN
3557 # @ingroup l3_hypos_netgen
3558 def SetFineness(self, theFineness):
3559 self.Parameters().SetFineness(theFineness)
3562 # Parameter of FULL_NETGEN
3563 # @ingroup l3_hypos_netgen
3564 def SetGrowthRate(self, theRate):
3565 self.Parameters().SetGrowthRate(theRate)
3567 ## Sets NbSegPerEdge
3568 # Parameter of FULL_NETGEN
3569 # @ingroup l3_hypos_netgen
3570 def SetNbSegPerEdge(self, theVal):
3571 self.Parameters().SetNbSegPerEdge(theVal)
3573 ## Sets NbSegPerRadius
3574 # Parameter of FULL_NETGEN
3575 # @ingroup l3_hypos_netgen
3576 def SetNbSegPerRadius(self, theVal):
3577 self.Parameters().SetNbSegPerRadius(theVal)
3579 ## Sets number of segments overriding value set by SetLocalLength()
3580 # Only for algoType == NETGEN_FULL
3581 # @ingroup l3_hypos_netgen
3582 def SetNumberOfSegments(self, theVal):
3583 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3585 ## Sets number of segments overriding value set by SetNumberOfSegments()
3586 # Only for algoType == NETGEN_FULL
3587 # @ingroup l3_hypos_netgen
3588 def SetLocalLength(self, theVal):
3589 self.Parameters(SIMPLE).SetLocalLength(theVal)
3591 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3592 # Overrides value set by LengthFromEdges()
3593 # Only for algoType == NETGEN_FULL
3594 # @ingroup l3_hypos_netgen
3595 def MaxElementArea(self, area):
3596 self.Parameters(SIMPLE).SetMaxElementArea(area)
3598 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3599 # Overrides value set by MaxElementArea()
3600 # Only for algoType == NETGEN_FULL
3601 # @ingroup l3_hypos_netgen
3602 def LengthFromEdges(self):
3603 self.Parameters(SIMPLE).LengthFromEdges()
3605 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3606 # Overrides value set by MaxElementVolume()
3607 # Only for algoType == NETGEN_FULL
3608 # @ingroup l3_hypos_netgen
3609 def LengthFromFaces(self):
3610 self.Parameters(SIMPLE).LengthFromFaces()
3612 ## To mesh "holes" in a solid or not. Default is to mesh.
3613 # @ingroup l3_hypos_ghs3dh
3614 def SetToMeshHoles(self, toMesh):
3615 # Parameter of GHS3D
3616 self.Parameters().SetToMeshHoles(toMesh)
3618 ## Set Optimization level:
3619 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3620 # Default is Medium_Optimization
3621 # @ingroup l3_hypos_ghs3dh
3622 def SetOptimizationLevel(self, level):
3623 # Parameter of GHS3D
3624 self.Parameters().SetOptimizationLevel(level)
3626 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3627 # @ingroup l3_hypos_ghs3dh
3628 def SetMaximumMemory(self, MB):
3629 # Advanced parameter of GHS3D
3630 self.Parameters().SetMaximumMemory(MB)
3632 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3633 # automatic memory adjustment mode.
3634 # @ingroup l3_hypos_ghs3dh
3635 def SetInitialMemory(self, MB):
3636 # Advanced parameter of GHS3D
3637 self.Parameters().SetInitialMemory(MB)
3639 ## Path to working directory.
3640 # @ingroup l3_hypos_ghs3dh
3641 def SetWorkingDirectory(self, path):
3642 # Advanced parameter of GHS3D
3643 self.Parameters().SetWorkingDirectory(path)
3645 ## To keep working files or remove them. Log file remains in case of errors anyway.
3646 # @ingroup l3_hypos_ghs3dh
3647 def SetKeepFiles(self, toKeep):
3648 # Advanced parameter of GHS3D
3649 self.Parameters().SetKeepFiles(toKeep)
3651 ## To set verbose level [0-10]. <ul>
3652 #<li> 0 - no standard output,
3653 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3654 # indicates when the final mesh is being saved. In addition the software
3655 # gives indication regarding the CPU time.
3656 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3657 # histogram of the skin mesh, quality statistics histogram together with
3658 # the characteristics of the final mesh.</ul>
3659 # @ingroup l3_hypos_ghs3dh
3660 def SetVerboseLevel(self, level):
3661 # Advanced parameter of GHS3D
3662 self.Parameters().SetVerboseLevel(level)
3664 ## To create new nodes.
3665 # @ingroup l3_hypos_ghs3dh
3666 def SetToCreateNewNodes(self, toCreate):
3667 # Advanced parameter of GHS3D
3668 self.Parameters().SetToCreateNewNodes(toCreate)
3670 ## To use boundary recovery version which tries to create mesh on a very poor
3671 # quality surface mesh.
3672 # @ingroup l3_hypos_ghs3dh
3673 def SetToUseBoundaryRecoveryVersion(self, toUse):
3674 # Advanced parameter of GHS3D
3675 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3677 ## Sets command line option as text.
3678 # @ingroup l3_hypos_ghs3dh
3679 def SetTextOption(self, option):
3680 # Advanced parameter of GHS3D
3681 self.Parameters().SetTextOption(option)
3683 # Public class: Mesh_Hexahedron
3684 # ------------------------------
3686 ## Defines a hexahedron 3D algorithm
3688 # @ingroup l3_algos_basic
3689 class Mesh_Hexahedron(Mesh_Algorithm):
3694 ## Private constructor.
3695 def __init__(self, mesh, algoType=Hexa, geom=0):
3696 Mesh_Algorithm.__init__(self)
3698 self.algoType = algoType
3700 if algoType == Hexa:
3701 self.Create(mesh, geom, "Hexa_3D")
3704 elif algoType == Hexotic:
3705 import HexoticPlugin
3706 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3709 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3710 # @ingroup l3_hypos_hexotic
3711 def MinMaxQuad(self, min=3, max=8, quad=True):
3712 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3714 self.params.SetHexesMinLevel(min)
3715 self.params.SetHexesMaxLevel(max)
3716 self.params.SetHexoticQuadrangles(quad)
3719 # Deprecated, only for compatibility!
3720 # Public class: Mesh_Netgen
3721 # ------------------------------
3723 ## Defines a NETGEN-based 2D or 3D algorithm
3724 # that needs no discrete boundary (i.e. independent)
3726 # This class is deprecated, only for compatibility!
3729 # @ingroup l3_algos_basic
3730 class Mesh_Netgen(Mesh_Algorithm):
3734 ## Private constructor.
3735 def __init__(self, mesh, is3D, geom=0):
3736 Mesh_Algorithm.__init__(self)
3739 print "Warning: NETGENPlugin module has not been imported."
3743 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3747 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3750 ## Defines the hypothesis containing parameters of the algorithm
3751 def Parameters(self):
3753 hyp = self.Hypothesis("NETGEN_Parameters", [],
3754 "libNETGENEngine.so", UseExisting=0)
3756 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3757 "libNETGENEngine.so", UseExisting=0)
3760 # Public class: Mesh_Projection1D
3761 # ------------------------------
3763 ## Defines a projection 1D algorithm
3764 # @ingroup l3_algos_proj
3766 class Mesh_Projection1D(Mesh_Algorithm):
3768 ## Private constructor.
3769 def __init__(self, mesh, geom=0):
3770 Mesh_Algorithm.__init__(self)
3771 self.Create(mesh, geom, "Projection_1D")
3773 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3774 # a mesh pattern is taken, and, optionally, the association of vertices
3775 # between the source edge and a target edge (to which a hypothesis is assigned)
3776 # @param edge from which nodes distribution is taken
3777 # @param mesh from which nodes distribution is taken (optional)
3778 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3779 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3780 # to associate with \a srcV (optional)
3781 # @param UseExisting if ==true - searches for the existing hypothesis created with
3782 # the same parameters, else (default) - creates a new one
3783 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3784 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3786 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3787 hyp.SetSourceEdge( edge )
3788 if not mesh is None and isinstance(mesh, Mesh):
3789 mesh = mesh.GetMesh()
3790 hyp.SetSourceMesh( mesh )
3791 hyp.SetVertexAssociation( srcV, tgtV )
3794 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3795 #def CompareSourceEdge(self, hyp, args):
3796 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3800 # Public class: Mesh_Projection2D
3801 # ------------------------------
3803 ## Defines a projection 2D algorithm
3804 # @ingroup l3_algos_proj
3806 class Mesh_Projection2D(Mesh_Algorithm):
3808 ## Private constructor.
3809 def __init__(self, mesh, geom=0):
3810 Mesh_Algorithm.__init__(self)
3811 self.Create(mesh, geom, "Projection_2D")
3813 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3814 # a mesh pattern is taken, and, optionally, the association of vertices
3815 # between the source face and the target face (to which a hypothesis is assigned)
3816 # @param face from which the mesh pattern is taken
3817 # @param mesh from which the mesh pattern is taken (optional)
3818 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3819 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3820 # to associate with \a srcV1 (optional)
3821 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3822 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3823 # to associate with \a srcV2 (optional)
3824 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3825 # the same parameters, else (default) - forces the creation a new one
3827 # Note: all association vertices must belong to one edge of a face
3828 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3829 srcV2=None, tgtV2=None, UseExisting=0):
3830 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3832 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3833 hyp.SetSourceFace( face )
3834 if not mesh is None and isinstance(mesh, Mesh):
3835 mesh = mesh.GetMesh()
3836 hyp.SetSourceMesh( mesh )
3837 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3840 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3841 #def CompareSourceFace(self, hyp, args):
3842 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3845 # Public class: Mesh_Projection3D
3846 # ------------------------------
3848 ## Defines a projection 3D algorithm
3849 # @ingroup l3_algos_proj
3851 class Mesh_Projection3D(Mesh_Algorithm):
3853 ## Private constructor.
3854 def __init__(self, mesh, geom=0):
3855 Mesh_Algorithm.__init__(self)
3856 self.Create(mesh, geom, "Projection_3D")
3858 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3859 # the mesh pattern is taken, and, optionally, the association of vertices
3860 # between the source and the target solid (to which a hipothesis is assigned)
3861 # @param solid from where the mesh pattern is taken
3862 # @param mesh from where the mesh pattern is taken (optional)
3863 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3864 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3865 # to associate with \a srcV1 (optional)
3866 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3867 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3868 # to associate with \a srcV2 (optional)
3869 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3870 # the same parameters, else (default) - creates a new one
3872 # Note: association vertices must belong to one edge of a solid
3873 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3874 srcV2=0, tgtV2=0, UseExisting=0):
3875 hyp = self.Hypothesis("ProjectionSource3D",
3876 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3878 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3879 hyp.SetSource3DShape( solid )
3880 if not mesh is None and isinstance(mesh, Mesh):
3881 mesh = mesh.GetMesh()
3882 hyp.SetSourceMesh( mesh )
3883 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3886 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3887 #def CompareSourceShape3D(self, hyp, args):
3888 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3892 # Public class: Mesh_Prism
3893 # ------------------------
3895 ## Defines a 3D extrusion algorithm
3896 # @ingroup l3_algos_3dextr
3898 class Mesh_Prism3D(Mesh_Algorithm):
3900 ## Private constructor.
3901 def __init__(self, mesh, geom=0):
3902 Mesh_Algorithm.__init__(self)
3903 self.Create(mesh, geom, "Prism_3D")
3905 # Public class: Mesh_RadialPrism
3906 # -------------------------------
3908 ## Defines a Radial Prism 3D algorithm
3909 # @ingroup l3_algos_radialp
3911 class Mesh_RadialPrism3D(Mesh_Algorithm):
3913 ## Private constructor.
3914 def __init__(self, mesh, geom=0):
3915 Mesh_Algorithm.__init__(self)
3916 self.Create(mesh, geom, "RadialPrism_3D")
3918 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3919 self.nbLayers = None
3921 ## Return 3D hypothesis holding the 1D one
3922 def Get3DHypothesis(self):
3923 return self.distribHyp
3925 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3926 # hypothesis. Returns the created hypothesis
3927 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3928 #print "OwnHypothesis",hypType
3929 if not self.nbLayers is None:
3930 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3931 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3932 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3933 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3934 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3935 self.distribHyp.SetLayerDistribution( hyp )
3938 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3939 # prisms to build between the inner and outer shells
3940 # @param n number of layers
3941 # @param UseExisting if ==true - searches for the existing hypothesis created with
3942 # the same parameters, else (default) - creates a new one
3943 def NumberOfLayers(self, n, UseExisting=0):
3944 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3945 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3946 CompareMethod=self.CompareNumberOfLayers)
3947 self.nbLayers.SetNumberOfLayers( n )
3948 return self.nbLayers
3950 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3951 def CompareNumberOfLayers(self, hyp, args):
3952 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3954 ## Defines "LocalLength" hypothesis, specifying the segment length
3955 # to build between the inner and the outer shells
3956 # @param l the length of segments
3957 # @param p the precision of rounding
3958 def LocalLength(self, l, p=1e-07):
3959 hyp = self.OwnHypothesis("LocalLength", [l,p])
3964 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3965 # prisms to build between the inner and the outer shells.
3966 # @param n the number of layers
3967 # @param s the scale factor (optional)
3968 def NumberOfSegments(self, n, s=[]):
3970 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3972 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3973 hyp.SetDistrType( 1 )
3974 hyp.SetScaleFactor(s)
3975 hyp.SetNumberOfSegments(n)
3978 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3979 # to build between the inner and the outer shells with a length that changes in arithmetic progression
3980 # @param start the length of the first segment
3981 # @param end the length of the last segment
3982 def Arithmetic1D(self, start, end ):
3983 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
3984 hyp.SetLength(start, 1)
3985 hyp.SetLength(end , 0)
3988 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
3989 # to build between the inner and the outer shells as geometric length increasing
3990 # @param start for the length of the first segment
3991 # @param end for the length of the last segment
3992 def StartEndLength(self, start, end):
3993 hyp = self.OwnHypothesis("StartEndLength", [start, end])
3994 hyp.SetLength(start, 1)
3995 hyp.SetLength(end , 0)
3998 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
3999 # to build between the inner and outer shells
4000 # @param fineness defines the quality of the mesh within the range [0-1]
4001 def AutomaticLength(self, fineness=0):
4002 hyp = self.OwnHypothesis("AutomaticLength")
4003 hyp.SetFineness( fineness )
4006 # Private class: Mesh_UseExisting
4007 # -------------------------------
4008 class Mesh_UseExisting(Mesh_Algorithm):
4010 def __init__(self, dim, mesh, geom=0):
4012 self.Create(mesh, geom, "UseExisting_1D")
4014 self.Create(mesh, geom, "UseExisting_2D")