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 ## Concatenate the given meshes into one mesh.
367 # @return an instance of Mesh class
368 # @param meshes the meshes to combine into one mesh
369 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
370 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
371 # @param mergeTolerance tolerance for merging nodes
372 # @param allGroups forces creation of groups of all elements
373 def Concatenate( self, meshes, uniteIdenticalGroups,
374 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
376 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
377 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
379 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
380 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
381 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
384 ## From SMESH_Gen interface
385 # @return the list of integer values
386 # @ingroup l1_auxiliary
387 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
388 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
390 ## From SMESH_Gen interface. Creates a pattern
391 # @return an instance of SMESH_Pattern
393 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
394 # @ingroup l2_modif_patterns
395 def GetPattern(self):
396 return SMESH._objref_SMESH_Gen.GetPattern(self)
399 # Filtering. Auxiliary functions:
400 # ------------------------------
402 ## Creates an empty criterion
403 # @return SMESH.Filter.Criterion
404 # @ingroup l1_controls
405 def GetEmptyCriterion(self):
406 Type = self.EnumToLong(FT_Undefined)
407 Compare = self.EnumToLong(FT_Undefined)
411 UnaryOp = self.EnumToLong(FT_Undefined)
412 BinaryOp = self.EnumToLong(FT_Undefined)
415 Precision = -1 ##@1e-07
416 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
417 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
419 ## Creates a criterion by the given parameters
420 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
421 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
422 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
423 # @param Treshold the threshold value (range of ids as string, shape, numeric)
424 # @param UnaryOp FT_LogicalNOT or FT_Undefined
425 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
426 # FT_Undefined (must be for the last criterion of all criteria)
427 # @return SMESH.Filter.Criterion
428 # @ingroup l1_controls
429 def GetCriterion(self,elementType,
431 Compare = FT_EqualTo,
433 UnaryOp=FT_Undefined,
434 BinaryOp=FT_Undefined):
435 aCriterion = self.GetEmptyCriterion()
436 aCriterion.TypeOfElement = elementType
437 aCriterion.Type = self.EnumToLong(CritType)
441 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
442 aCriterion.Compare = self.EnumToLong(Compare)
443 elif Compare == "=" or Compare == "==":
444 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
446 aCriterion.Compare = self.EnumToLong(FT_LessThan)
448 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
450 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
453 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
454 FT_BelongToCylinder, FT_LyingOnGeom]:
455 # Checks the treshold
456 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
457 aCriterion.ThresholdStr = GetName(aTreshold)
458 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
460 print "Error: The treshold should be a shape."
462 elif CritType == FT_RangeOfIds:
463 # Checks the treshold
464 if isinstance(aTreshold, str):
465 aCriterion.ThresholdStr = aTreshold
467 print "Error: The treshold should be a string."
469 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
470 # At this point the treshold is unnecessary
471 if aTreshold == FT_LogicalNOT:
472 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
473 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
474 aCriterion.BinaryOp = aTreshold
478 aTreshold = float(aTreshold)
479 aCriterion.Threshold = aTreshold
481 print "Error: The treshold should be a number."
484 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
485 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
487 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
488 aCriterion.BinaryOp = self.EnumToLong(Treshold)
490 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
491 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
493 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
494 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
498 ## Creates a filter with the given parameters
499 # @param elementType the type of elements in the group
500 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
501 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
502 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
503 # @param UnaryOp FT_LogicalNOT or FT_Undefined
504 # @return SMESH_Filter
505 # @ingroup l1_controls
506 def GetFilter(self,elementType,
507 CritType=FT_Undefined,
510 UnaryOp=FT_Undefined):
511 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
512 aFilterMgr = self.CreateFilterManager()
513 aFilter = aFilterMgr.CreateFilter()
515 aCriteria.append(aCriterion)
516 aFilter.SetCriteria(aCriteria)
519 ## Creates a numerical functor by its type
520 # @param theCriterion FT_...; functor type
521 # @return SMESH_NumericalFunctor
522 # @ingroup l1_controls
523 def GetFunctor(self,theCriterion):
524 aFilterMgr = self.CreateFilterManager()
525 if theCriterion == FT_AspectRatio:
526 return aFilterMgr.CreateAspectRatio()
527 elif theCriterion == FT_AspectRatio3D:
528 return aFilterMgr.CreateAspectRatio3D()
529 elif theCriterion == FT_Warping:
530 return aFilterMgr.CreateWarping()
531 elif theCriterion == FT_MinimumAngle:
532 return aFilterMgr.CreateMinimumAngle()
533 elif theCriterion == FT_Taper:
534 return aFilterMgr.CreateTaper()
535 elif theCriterion == FT_Skew:
536 return aFilterMgr.CreateSkew()
537 elif theCriterion == FT_Area:
538 return aFilterMgr.CreateArea()
539 elif theCriterion == FT_Volume3D:
540 return aFilterMgr.CreateVolume3D()
541 elif theCriterion == FT_MultiConnection:
542 return aFilterMgr.CreateMultiConnection()
543 elif theCriterion == FT_MultiConnection2D:
544 return aFilterMgr.CreateMultiConnection2D()
545 elif theCriterion == FT_Length:
546 return aFilterMgr.CreateLength()
547 elif theCriterion == FT_Length2D:
548 return aFilterMgr.CreateLength2D()
550 print "Error: given parameter is not numerucal functor type."
554 #Registering the new proxy for SMESH_Gen
555 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
561 ## This class allows defining and managing a mesh.
562 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
563 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
564 # new nodes and elements and by changing the existing entities), to get information
565 # about a mesh and to export a mesh into different formats.
574 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
575 # sets the GUI name of this mesh to \a name.
576 # @param smeshpyD an instance of smeshDC class
577 # @param geompyD an instance of geompyDC class
578 # @param obj Shape to be meshed or SMESH_Mesh object
579 # @param name Study name of the mesh
580 # @ingroup l2_construct
581 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
582 self.smeshpyD=smeshpyD
587 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
589 self.mesh = self.smeshpyD.CreateMesh(self.geom)
590 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
593 self.mesh = self.smeshpyD.CreateEmptyMesh()
595 SetName(self.mesh, name)
597 SetName(self.mesh, GetName(obj))
600 self.geom = self.mesh.GetShapeToMesh()
602 self.editor = self.mesh.GetMeshEditor()
604 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
605 # @param theMesh a SMESH_Mesh object
606 # @ingroup l2_construct
607 def SetMesh(self, theMesh):
609 self.geom = self.mesh.GetShapeToMesh()
611 ## Returns the mesh, that is an instance of SMESH_Mesh interface
612 # @return a SMESH_Mesh object
613 # @ingroup l2_construct
617 ## Gets the name of the mesh
618 # @return the name of the mesh as a string
619 # @ingroup l2_construct
621 name = GetName(self.GetMesh())
624 ## Sets a name to the mesh
625 # @param name a new name of the mesh
626 # @ingroup l2_construct
627 def SetName(self, name):
628 SetName(self.GetMesh(), name)
630 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
631 # The subMesh object gives access to the IDs of nodes and elements.
632 # @param theSubObject a geometrical object (shape)
633 # @param theName a name for the submesh
634 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
635 # @ingroup l2_submeshes
636 def GetSubMesh(self, theSubObject, theName):
637 submesh = self.mesh.GetSubMesh(theSubObject, theName)
640 ## Returns the shape associated to the mesh
641 # @return a GEOM_Object
642 # @ingroup l2_construct
646 ## Associates the given shape to the mesh (entails the recreation of the mesh)
647 # @param geom the shape to be meshed (GEOM_Object)
648 # @ingroup l2_construct
649 def SetShape(self, geom):
650 self.mesh = self.smeshpyD.CreateMesh(geom)
652 ## Returns true if the hypotheses are defined well
653 # @param theSubObject a subshape of a mesh shape
654 # @return True or False
655 # @ingroup l2_construct
656 def IsReadyToCompute(self, theSubObject):
657 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
659 ## Returns errors of hypotheses definition.
660 # The list of errors is empty if everything is OK.
661 # @param theSubObject a subshape of a mesh shape
662 # @return a list of errors
663 # @ingroup l2_construct
664 def GetAlgoState(self, theSubObject):
665 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
667 ## Returns a geometrical object on which the given element was built.
668 # The returned geometrical object, if not nil, is either found in the
669 # study or published by this method with the given name
670 # @param theElementID the id of the mesh element
671 # @param theGeomName the user-defined name of the geometrical object
672 # @return GEOM::GEOM_Object instance
673 # @ingroup l2_construct
674 def GetGeometryByMeshElement(self, theElementID, theGeomName):
675 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
677 ## Returns the mesh dimension depending on the dimension of the underlying shape
678 # @return mesh dimension as an integer value [0,3]
679 # @ingroup l1_auxiliary
680 def MeshDimension(self):
681 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
682 if len( shells ) > 0 :
684 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
686 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
692 ## Creates a segment discretization 1D algorithm.
693 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
694 # \n If the optional \a geom parameter is not set, this algorithm is global.
695 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
696 # @param algo the type of the required algorithm. Possible values are:
698 # - smesh.PYTHON for discretization via a python function,
699 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
700 # @param geom If defined is the subshape to be meshed
701 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
702 # @ingroup l3_algos_basic
703 def Segment(self, algo=REGULAR, geom=0):
704 ## if Segment(geom) is called by mistake
705 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
706 algo, geom = geom, algo
707 if not algo: algo = REGULAR
710 return Mesh_Segment(self, geom)
712 return Mesh_Segment_Python(self, geom)
713 elif algo == COMPOSITE:
714 return Mesh_CompositeSegment(self, geom)
716 return Mesh_Segment(self, geom)
718 ## Enables creation of nodes and segments usable by 2D algoritms.
719 # The added nodes and segments must be bound to edges and vertices by
720 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
721 # If the optional \a geom parameter is not set, this algorithm is global.
722 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
723 # @param geom the subshape to be manually meshed
724 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
725 # @ingroup l3_algos_basic
726 def UseExistingSegments(self, geom=0):
727 algo = Mesh_UseExisting(1,self,geom)
728 return algo.GetAlgorithm()
730 ## Enables creation of nodes and faces usable by 3D algoritms.
731 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
732 # and SetMeshElementOnShape()
733 # If the optional \a geom parameter is not set, this algorithm is global.
734 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
735 # @param geom the subshape to be manually meshed
736 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
737 # @ingroup l3_algos_basic
738 def UseExistingFaces(self, geom=0):
739 algo = Mesh_UseExisting(2,self,geom)
740 return algo.GetAlgorithm()
742 ## Creates a triangle 2D algorithm for faces.
743 # If the optional \a geom parameter is not set, this algorithm is global.
744 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
745 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
746 # @param geom If defined, the subshape to be meshed (GEOM_Object)
747 # @return an instance of Mesh_Triangle algorithm
748 # @ingroup l3_algos_basic
749 def Triangle(self, algo=MEFISTO, geom=0):
750 ## if Triangle(geom) is called by mistake
751 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
755 return Mesh_Triangle(self, algo, geom)
757 ## Creates a quadrangle 2D algorithm for faces.
758 # If the optional \a geom parameter is not set, this algorithm is global.
759 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
760 # @param geom If defined, the subshape to be meshed (GEOM_Object)
761 # @return an instance of Mesh_Quadrangle algorithm
762 # @ingroup l3_algos_basic
763 def Quadrangle(self, geom=0):
764 return Mesh_Quadrangle(self, geom)
766 ## Creates a tetrahedron 3D algorithm for solids.
767 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
768 # If the optional \a geom parameter is not set, this algorithm is global.
769 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
770 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
771 # @param geom If defined, the subshape to be meshed (GEOM_Object)
772 # @return an instance of Mesh_Tetrahedron algorithm
773 # @ingroup l3_algos_basic
774 def Tetrahedron(self, algo=NETGEN, geom=0):
775 ## if Tetrahedron(geom) is called by mistake
776 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
777 algo, geom = geom, algo
778 if not algo: algo = NETGEN
780 return Mesh_Tetrahedron(self, algo, geom)
782 ## Creates a hexahedron 3D algorithm for solids.
783 # If the optional \a geom parameter is not set, this algorithm is global.
784 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
785 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
786 # @param geom If defined, the subshape to be meshed (GEOM_Object)
787 # @return an instance of Mesh_Hexahedron algorithm
788 # @ingroup l3_algos_basic
789 def Hexahedron(self, algo=Hexa, geom=0):
790 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
791 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
792 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
793 elif geom == 0: algo, geom = Hexa, algo
794 return Mesh_Hexahedron(self, algo, geom)
796 ## Deprecated, used only for compatibility!
797 # @return an instance of Mesh_Netgen algorithm
798 # @ingroup l3_algos_basic
799 def Netgen(self, is3D, geom=0):
800 return Mesh_Netgen(self, is3D, geom)
802 ## Creates a projection 1D algorithm for edges.
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_Projection1D algorithm
807 # @ingroup l3_algos_proj
808 def Projection1D(self, geom=0):
809 return Mesh_Projection1D(self, geom)
811 ## Creates a projection 2D algorithm for faces.
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_Projection2D algorithm
816 # @ingroup l3_algos_proj
817 def Projection2D(self, geom=0):
818 return Mesh_Projection2D(self, geom)
820 ## Creates a projection 3D algorithm for solids.
821 # If the optional \a geom parameter is not set, this algorithm is global.
822 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
823 # @param geom If defined, the subshape to be meshed
824 # @return an instance of Mesh_Projection3D algorithm
825 # @ingroup l3_algos_proj
826 def Projection3D(self, geom=0):
827 return Mesh_Projection3D(self, geom)
829 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
830 # If the optional \a geom parameter is not set, this algorithm is global.
831 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
832 # @param geom If defined, the subshape to be meshed
833 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
834 # @ingroup l3_algos_radialp l3_algos_3dextr
835 def Prism(self, geom=0):
839 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
840 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
841 if nbSolids == 0 or nbSolids == nbShells:
842 return Mesh_Prism3D(self, geom)
843 return Mesh_RadialPrism3D(self, geom)
845 ## Computes the mesh and returns the status of the computation
846 # @return True or False
847 # @ingroup l2_construct
848 def Compute(self, geom=0):
849 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
851 geom = self.mesh.GetShapeToMesh()
856 ok = self.smeshpyD.Compute(self.mesh, geom)
857 except SALOME.SALOME_Exception, ex:
858 print "Mesh computation failed, exception caught:"
859 print " ", ex.details.text
862 print "Mesh computation failed, exception caught:"
863 traceback.print_exc()
865 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
876 reason = '%s %sD algorithm is missing' % (glob, dim)
877 elif err.state == HYP_MISSING:
878 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
879 % (glob, dim, name, dim))
880 elif err.state == HYP_NOTCONFORM:
881 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
882 elif err.state == HYP_BAD_PARAMETER:
883 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
884 % ( glob, dim, name ))
885 elif err.state == HYP_BAD_GEOMETRY:
886 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
887 'geometry' % ( glob, dim, name ))
889 reason = "For unknown reason."+\
890 " Revise Mesh.Compute() implementation in smeshDC.py!"
898 print '"' + GetName(self.mesh) + '"',"has not been computed:"
902 print '"' + GetName(self.mesh) + '"',"has not been computed."
905 if salome.sg.hasDesktop():
906 smeshgui = salome.ImportComponentGUI("SMESH")
907 smeshgui.Init(salome.myStudyId)
908 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
909 salome.sg.updateObjBrowser(1)
913 ## Removes all nodes and elements
914 # @ingroup l2_construct
917 if salome.sg.hasDesktop():
918 smeshgui = salome.ImportComponentGUI("SMESH")
919 smeshgui.Init(salome.myStudyId)
920 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
921 salome.sg.updateObjBrowser(1)
923 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
924 # @param fineness [0,-1] defines mesh fineness
925 # @return True or False
926 # @ingroup l3_algos_basic
927 def AutomaticTetrahedralization(self, fineness=0):
928 dim = self.MeshDimension()
930 self.RemoveGlobalHypotheses()
931 self.Segment().AutomaticLength(fineness)
933 self.Triangle().LengthFromEdges()
936 self.Tetrahedron(NETGEN)
938 return self.Compute()
940 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
941 # @param fineness [0,-1] defines mesh fineness
942 # @return True or False
943 # @ingroup l3_algos_basic
944 def AutomaticHexahedralization(self, fineness=0):
945 dim = self.MeshDimension()
946 # assign the hypotheses
947 self.RemoveGlobalHypotheses()
948 self.Segment().AutomaticLength(fineness)
955 return self.Compute()
957 ## Assigns a hypothesis
958 # @param hyp a hypothesis to assign
959 # @param geom a subhape of mesh geometry
960 # @return SMESH.Hypothesis_Status
961 # @ingroup l2_hypotheses
962 def AddHypothesis(self, hyp, geom=0):
963 if isinstance( hyp, Mesh_Algorithm ):
964 hyp = hyp.GetAlgorithm()
969 geom = self.mesh.GetShapeToMesh()
971 status = self.mesh.AddHypothesis(geom, hyp)
972 isAlgo = hyp._narrow( SMESH_Algo )
973 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
976 ## Unassigns a hypothesis
977 # @param hyp a hypothesis to unassign
978 # @param geom a subshape of mesh geometry
979 # @return SMESH.Hypothesis_Status
980 # @ingroup l2_hypotheses
981 def RemoveHypothesis(self, hyp, geom=0):
982 if isinstance( hyp, Mesh_Algorithm ):
983 hyp = hyp.GetAlgorithm()
988 status = self.mesh.RemoveHypothesis(geom, hyp)
991 ## Gets the list of hypotheses added on a geometry
992 # @param geom a subshape of mesh geometry
993 # @return the sequence of SMESH_Hypothesis
994 # @ingroup l2_hypotheses
995 def GetHypothesisList(self, geom):
996 return self.mesh.GetHypothesisList( geom )
998 ## Removes all global hypotheses
999 # @ingroup l2_hypotheses
1000 def RemoveGlobalHypotheses(self):
1001 current_hyps = self.mesh.GetHypothesisList( self.geom )
1002 for hyp in current_hyps:
1003 self.mesh.RemoveHypothesis( self.geom, hyp )
1007 ## Creates a mesh group based on the geometric object \a grp
1008 # and gives a \a name, \n if this parameter is not defined
1009 # the name is the same as the geometric group name \n
1010 # Note: Works like GroupOnGeom().
1011 # @param grp a geometric group, a vertex, an edge, a face or a solid
1012 # @param name the name of the mesh group
1013 # @return SMESH_GroupOnGeom
1014 # @ingroup l2_grps_create
1015 def Group(self, grp, name=""):
1016 return self.GroupOnGeom(grp, name)
1018 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1019 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1020 # @param f the file name
1021 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1022 # @ingroup l2_impexp
1023 def ExportToMED(self, f, version, opt=0):
1024 self.mesh.ExportToMED(f, opt, version)
1026 ## Exports the mesh in a file in MED format
1027 # @param f is the file name
1028 # @param auto_groups boolean parameter for creating/not creating
1029 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1030 # the typical use is auto_groups=false.
1031 # @param version MED format version(MED_V2_1 or MED_V2_2)
1032 # @ingroup l2_impexp
1033 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1034 self.mesh.ExportToMED(f, auto_groups, version)
1036 ## Exports the mesh in a file in DAT format
1037 # @param f the file name
1038 # @ingroup l2_impexp
1039 def ExportDAT(self, f):
1040 self.mesh.ExportDAT(f)
1042 ## Exports the mesh in a file in UNV format
1043 # @param f the file name
1044 # @ingroup l2_impexp
1045 def ExportUNV(self, f):
1046 self.mesh.ExportUNV(f)
1048 ## Export the mesh in a file in STL format
1049 # @param f the file name
1050 # @param ascii defines the file encoding
1051 # @ingroup l2_impexp
1052 def ExportSTL(self, f, ascii=1):
1053 self.mesh.ExportSTL(f, ascii)
1056 # Operations with groups:
1057 # ----------------------
1059 ## Creates an empty mesh group
1060 # @param elementType the type of elements in the group
1061 # @param name the name of the mesh group
1062 # @return SMESH_Group
1063 # @ingroup l2_grps_create
1064 def CreateEmptyGroup(self, elementType, name):
1065 return self.mesh.CreateGroup(elementType, name)
1067 ## Creates a mesh group based on the geometrical object \a grp
1068 # and gives a \a name, \n if this parameter is not defined
1069 # the name is the same as the geometrical group name
1070 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1071 # @param name the name of the mesh group
1072 # @param typ the type of elements in the group. If not set, it is
1073 # automatically detected by the type of the geometry
1074 # @return SMESH_GroupOnGeom
1075 # @ingroup l2_grps_create
1076 def GroupOnGeom(self, grp, name="", typ=None):
1078 name = grp.GetName()
1081 tgeo = str(grp.GetShapeType())
1082 if tgeo == "VERTEX":
1084 elif tgeo == "EDGE":
1086 elif tgeo == "FACE":
1088 elif tgeo == "SOLID":
1090 elif tgeo == "SHELL":
1092 elif tgeo == "COMPOUND":
1093 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1094 print "Mesh.Group: empty geometric group", GetName( grp )
1096 tgeo = self.geompyD.GetType(grp)
1097 if tgeo == geompyDC.ShapeType["VERTEX"]:
1099 elif tgeo == geompyDC.ShapeType["EDGE"]:
1101 elif tgeo == geompyDC.ShapeType["FACE"]:
1103 elif tgeo == geompyDC.ShapeType["SOLID"]:
1107 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1110 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1112 ## Creates a mesh group by the given ids of elements
1113 # @param groupName the name of the mesh group
1114 # @param elementType the type of elements in the group
1115 # @param elemIDs the list of ids
1116 # @return SMESH_Group
1117 # @ingroup l2_grps_create
1118 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1119 group = self.mesh.CreateGroup(elementType, groupName)
1123 ## Creates a mesh group by the given conditions
1124 # @param groupName the name of the mesh group
1125 # @param elementType the type of elements in the group
1126 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1127 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1128 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1129 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1130 # @return SMESH_Group
1131 # @ingroup l2_grps_create
1135 CritType=FT_Undefined,
1138 UnaryOp=FT_Undefined):
1139 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1140 group = self.MakeGroupByCriterion(groupName, aCriterion)
1143 ## Creates a mesh group by the given criterion
1144 # @param groupName the name of the mesh group
1145 # @param Criterion the instance of Criterion class
1146 # @return SMESH_Group
1147 # @ingroup l2_grps_create
1148 def MakeGroupByCriterion(self, groupName, Criterion):
1149 aFilterMgr = self.smeshpyD.CreateFilterManager()
1150 aFilter = aFilterMgr.CreateFilter()
1152 aCriteria.append(Criterion)
1153 aFilter.SetCriteria(aCriteria)
1154 group = self.MakeGroupByFilter(groupName, aFilter)
1157 ## Creates a mesh group by the given criteria (list of criteria)
1158 # @param groupName the name of the mesh group
1159 # @param theCriteria the list of criteria
1160 # @return SMESH_Group
1161 # @ingroup l2_grps_create
1162 def MakeGroupByCriteria(self, groupName, theCriteria):
1163 aFilterMgr = self.smeshpyD.CreateFilterManager()
1164 aFilter = aFilterMgr.CreateFilter()
1165 aFilter.SetCriteria(theCriteria)
1166 group = self.MakeGroupByFilter(groupName, aFilter)
1169 ## Creates a mesh group by the given filter
1170 # @param groupName the name of the mesh group
1171 # @param theFilter the instance of Filter class
1172 # @return SMESH_Group
1173 # @ingroup l2_grps_create
1174 def MakeGroupByFilter(self, groupName, theFilter):
1175 anIds = theFilter.GetElementsId(self.mesh)
1176 anElemType = theFilter.GetElementType()
1177 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1180 ## Passes mesh elements through the given filter and return IDs of fitting elements
1181 # @param theFilter SMESH_Filter
1182 # @return a list of ids
1183 # @ingroup l1_controls
1184 def GetIdsFromFilter(self, theFilter):
1185 return theFilter.GetElementsId(self.mesh)
1187 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1188 # Returns a list of special structures (borders).
1189 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1190 # @ingroup l1_controls
1191 def GetFreeBorders(self):
1192 aFilterMgr = self.smeshpyD.CreateFilterManager()
1193 aPredicate = aFilterMgr.CreateFreeEdges()
1194 aPredicate.SetMesh(self.mesh)
1195 aBorders = aPredicate.GetBorders()
1199 # @ingroup l2_grps_delete
1200 def RemoveGroup(self, group):
1201 self.mesh.RemoveGroup(group)
1203 ## Removes a group with its contents
1204 # @ingroup l2_grps_delete
1205 def RemoveGroupWithContents(self, group):
1206 self.mesh.RemoveGroupWithContents(group)
1208 ## Gets the list of groups existing in the mesh
1209 # @return a sequence of SMESH_GroupBase
1210 # @ingroup l2_grps_create
1211 def GetGroups(self):
1212 return self.mesh.GetGroups()
1214 ## Gets the number of groups existing in the mesh
1215 # @return the quantity of groups as an integer value
1216 # @ingroup l2_grps_create
1218 return self.mesh.NbGroups()
1220 ## Gets the list of names of groups existing in the mesh
1221 # @return list of strings
1222 # @ingroup l2_grps_create
1223 def GetGroupNames(self):
1224 groups = self.GetGroups()
1226 for group in groups:
1227 names.append(group.GetName())
1230 ## Produces a union of two groups
1231 # A new group is created. All mesh elements that are
1232 # present in the initial groups are added to the new one
1233 # @return an instance of SMESH_Group
1234 # @ingroup l2_grps_operon
1235 def UnionGroups(self, group1, group2, name):
1236 return self.mesh.UnionGroups(group1, group2, name)
1238 ## Prodices an intersection of two groups
1239 # A new group is created. All mesh elements that are common
1240 # for the two initial groups are added to the new one.
1241 # @return an instance of SMESH_Group
1242 # @ingroup l2_grps_operon
1243 def IntersectGroups(self, group1, group2, name):
1244 return self.mesh.IntersectGroups(group1, group2, name)
1246 ## Produces a cut of two groups
1247 # A new group is created. All mesh elements that are present in
1248 # the main group but are not present in the tool group are added to the new one
1249 # @return an instance of SMESH_Group
1250 # @ingroup l2_grps_operon
1251 def CutGroups(self, mainGroup, toolGroup, name):
1252 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1255 # Get some info about mesh:
1256 # ------------------------
1258 ## Returns the log of nodes and elements added or removed
1259 # since the previous clear of the log.
1260 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1261 # @return list of log_block structures:
1266 # @ingroup l1_auxiliary
1267 def GetLog(self, clearAfterGet):
1268 return self.mesh.GetLog(clearAfterGet)
1270 ## Clears the log of nodes and elements added or removed since the previous
1271 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1272 # @ingroup l1_auxiliary
1274 self.mesh.ClearLog()
1276 ## Toggles auto color mode on the object.
1277 # @param theAutoColor the flag which toggles auto color mode.
1278 # @ingroup l1_auxiliary
1279 def SetAutoColor(self, theAutoColor):
1280 self.mesh.SetAutoColor(theAutoColor)
1282 ## Gets flag of object auto color mode.
1283 # @return True or False
1284 # @ingroup l1_auxiliary
1285 def GetAutoColor(self):
1286 return self.mesh.GetAutoColor()
1288 ## Gets the internal ID
1289 # @return integer value, which is the internal Id of the mesh
1290 # @ingroup l1_auxiliary
1292 return self.mesh.GetId()
1295 # @return integer value, which is the study Id of the mesh
1296 # @ingroup l1_auxiliary
1297 def GetStudyId(self):
1298 return self.mesh.GetStudyId()
1300 ## Checks the group names for duplications.
1301 # Consider the maximum group name length stored in MED file.
1302 # @return True or False
1303 # @ingroup l1_auxiliary
1304 def HasDuplicatedGroupNamesMED(self):
1305 return self.mesh.HasDuplicatedGroupNamesMED()
1307 ## Obtains the mesh editor tool
1308 # @return an instance of SMESH_MeshEditor
1309 # @ingroup l1_modifying
1310 def GetMeshEditor(self):
1311 return self.mesh.GetMeshEditor()
1314 # @return an instance of SALOME_MED::MESH
1315 # @ingroup l1_auxiliary
1316 def GetMEDMesh(self):
1317 return self.mesh.GetMEDMesh()
1320 # Get informations about mesh contents:
1321 # ------------------------------------
1323 ## Returns the number of nodes in the mesh
1324 # @return an integer value
1325 # @ingroup l1_meshinfo
1327 return self.mesh.NbNodes()
1329 ## Returns the number of elements in the mesh
1330 # @return an integer value
1331 # @ingroup l1_meshinfo
1332 def NbElements(self):
1333 return self.mesh.NbElements()
1335 ## Returns the number of edges in the mesh
1336 # @return an integer value
1337 # @ingroup l1_meshinfo
1339 return self.mesh.NbEdges()
1341 ## Returns the number of edges with the given order in the mesh
1342 # @param elementOrder the order of elements:
1343 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1344 # @return an integer value
1345 # @ingroup l1_meshinfo
1346 def NbEdgesOfOrder(self, elementOrder):
1347 return self.mesh.NbEdgesOfOrder(elementOrder)
1349 ## Returns the number of faces in the mesh
1350 # @return an integer value
1351 # @ingroup l1_meshinfo
1353 return self.mesh.NbFaces()
1355 ## Returns the number of faces with the given order in the mesh
1356 # @param elementOrder the order of elements:
1357 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1358 # @return an integer value
1359 # @ingroup l1_meshinfo
1360 def NbFacesOfOrder(self, elementOrder):
1361 return self.mesh.NbFacesOfOrder(elementOrder)
1363 ## Returns the number of triangles in the mesh
1364 # @return an integer value
1365 # @ingroup l1_meshinfo
1366 def NbTriangles(self):
1367 return self.mesh.NbTriangles()
1369 ## Returns the number of triangles with the given order in the mesh
1370 # @param elementOrder is the order of elements:
1371 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1372 # @return an integer value
1373 # @ingroup l1_meshinfo
1374 def NbTrianglesOfOrder(self, elementOrder):
1375 return self.mesh.NbTrianglesOfOrder(elementOrder)
1377 ## Returns the number of quadrangles in the mesh
1378 # @return an integer value
1379 # @ingroup l1_meshinfo
1380 def NbQuadrangles(self):
1381 return self.mesh.NbQuadrangles()
1383 ## Returns the number of quadrangles with the given order in the mesh
1384 # @param elementOrder the order of elements:
1385 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1386 # @return an integer value
1387 # @ingroup l1_meshinfo
1388 def NbQuadranglesOfOrder(self, elementOrder):
1389 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1391 ## Returns the number of polygons in the mesh
1392 # @return an integer value
1393 # @ingroup l1_meshinfo
1394 def NbPolygons(self):
1395 return self.mesh.NbPolygons()
1397 ## Returns the number of volumes in the mesh
1398 # @return an integer value
1399 # @ingroup l1_meshinfo
1400 def NbVolumes(self):
1401 return self.mesh.NbVolumes()
1403 ## Returns the number of volumes with the given order in the mesh
1404 # @param elementOrder the order of elements:
1405 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1406 # @return an integer value
1407 # @ingroup l1_meshinfo
1408 def NbVolumesOfOrder(self, elementOrder):
1409 return self.mesh.NbVolumesOfOrder(elementOrder)
1411 ## Returns the number of tetrahedrons in the mesh
1412 # @return an integer value
1413 # @ingroup l1_meshinfo
1415 return self.mesh.NbTetras()
1417 ## Returns the number of tetrahedrons with the given order in the mesh
1418 # @param elementOrder the order of elements:
1419 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1420 # @return an integer value
1421 # @ingroup l1_meshinfo
1422 def NbTetrasOfOrder(self, elementOrder):
1423 return self.mesh.NbTetrasOfOrder(elementOrder)
1425 ## Returns the number of hexahedrons in the mesh
1426 # @return an integer value
1427 # @ingroup l1_meshinfo
1429 return self.mesh.NbHexas()
1431 ## Returns the number of hexahedrons with the given order in the mesh
1432 # @param elementOrder the order of elements:
1433 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1434 # @return an integer value
1435 # @ingroup l1_meshinfo
1436 def NbHexasOfOrder(self, elementOrder):
1437 return self.mesh.NbHexasOfOrder(elementOrder)
1439 ## Returns the number of pyramids in the mesh
1440 # @return an integer value
1441 # @ingroup l1_meshinfo
1442 def NbPyramids(self):
1443 return self.mesh.NbPyramids()
1445 ## Returns the number of pyramids with the given order in the mesh
1446 # @param elementOrder the order of elements:
1447 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1448 # @return an integer value
1449 # @ingroup l1_meshinfo
1450 def NbPyramidsOfOrder(self, elementOrder):
1451 return self.mesh.NbPyramidsOfOrder(elementOrder)
1453 ## Returns the number of prisms in the mesh
1454 # @return an integer value
1455 # @ingroup l1_meshinfo
1457 return self.mesh.NbPrisms()
1459 ## Returns the number of prisms with the given order in the mesh
1460 # @param elementOrder the order of elements:
1461 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1462 # @return an integer value
1463 # @ingroup l1_meshinfo
1464 def NbPrismsOfOrder(self, elementOrder):
1465 return self.mesh.NbPrismsOfOrder(elementOrder)
1467 ## Returns the number of polyhedrons in the mesh
1468 # @return an integer value
1469 # @ingroup l1_meshinfo
1470 def NbPolyhedrons(self):
1471 return self.mesh.NbPolyhedrons()
1473 ## Returns the number of submeshes in the mesh
1474 # @return an integer value
1475 # @ingroup l1_meshinfo
1476 def NbSubMesh(self):
1477 return self.mesh.NbSubMesh()
1479 ## Returns the list of mesh elements IDs
1480 # @return the list of integer values
1481 # @ingroup l1_meshinfo
1482 def GetElementsId(self):
1483 return self.mesh.GetElementsId()
1485 ## Returns the list of IDs of mesh elements with the given type
1486 # @param elementType the required type of elements
1487 # @return list of integer values
1488 # @ingroup l1_meshinfo
1489 def GetElementsByType(self, elementType):
1490 return self.mesh.GetElementsByType(elementType)
1492 ## Returns the list of mesh nodes IDs
1493 # @return the list of integer values
1494 # @ingroup l1_meshinfo
1495 def GetNodesId(self):
1496 return self.mesh.GetNodesId()
1498 # Get the information about mesh elements:
1499 # ------------------------------------
1501 ## Returns the type of mesh element
1502 # @return the value from SMESH::ElementType enumeration
1503 # @ingroup l1_meshinfo
1504 def GetElementType(self, id, iselem):
1505 return self.mesh.GetElementType(id, iselem)
1507 ## Returns the list of submesh elements IDs
1508 # @param Shape a geom object(subshape) IOR
1509 # Shape must be the subshape of a ShapeToMesh()
1510 # @return the list of integer values
1511 # @ingroup l1_meshinfo
1512 def GetSubMeshElementsId(self, Shape):
1513 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1514 ShapeID = Shape.GetSubShapeIndices()[0]
1517 return self.mesh.GetSubMeshElementsId(ShapeID)
1519 ## Returns the list of submesh nodes IDs
1520 # @param Shape a geom object(subshape) IOR
1521 # Shape must be the subshape of a ShapeToMesh()
1522 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1523 # @return the list of integer values
1524 # @ingroup l1_meshinfo
1525 def GetSubMeshNodesId(self, Shape, all):
1526 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1527 ShapeID = Shape.GetSubShapeIndices()[0]
1530 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1532 ## Returns the list of IDs of submesh elements with the given type
1533 # @param Shape a geom object(subshape) IOR
1534 # Shape must be a subshape of a ShapeToMesh()
1535 # @return the list of integer values
1536 # @ingroup l1_meshinfo
1537 def GetSubMeshElementType(self, Shape):
1538 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1539 ShapeID = Shape.GetSubShapeIndices()[0]
1542 return self.mesh.GetSubMeshElementType(ShapeID)
1544 ## Gets the mesh description
1545 # @return string value
1546 # @ingroup l1_meshinfo
1548 return self.mesh.Dump()
1551 # Get the information about nodes and elements of a mesh by its IDs:
1552 # -----------------------------------------------------------
1554 ## Gets XYZ coordinates of a node
1555 # \n If there is no nodes for the given ID - returns an empty list
1556 # @return a list of double precision values
1557 # @ingroup l1_meshinfo
1558 def GetNodeXYZ(self, id):
1559 return self.mesh.GetNodeXYZ(id)
1561 ## Returns list of IDs of inverse elements for the given node
1562 # \n If there is no node for the given ID - returns an empty list
1563 # @return a list of integer values
1564 # @ingroup l1_meshinfo
1565 def GetNodeInverseElements(self, id):
1566 return self.mesh.GetNodeInverseElements(id)
1568 ## @brief Returns the position of a node on the shape
1569 # @return SMESH::NodePosition
1570 # @ingroup l1_meshinfo
1571 def GetNodePosition(self,NodeID):
1572 return self.mesh.GetNodePosition(NodeID)
1574 ## If the given element is a node, returns the ID of shape
1575 # \n If there is no node for the given ID - returns -1
1576 # @return an integer value
1577 # @ingroup l1_meshinfo
1578 def GetShapeID(self, id):
1579 return self.mesh.GetShapeID(id)
1581 ## Returns the ID of the result shape after
1582 # FindShape() from SMESH_MeshEditor for the given element
1583 # \n If there is no element for the given ID - returns -1
1584 # @return an integer value
1585 # @ingroup l1_meshinfo
1586 def GetShapeIDForElem(self,id):
1587 return self.mesh.GetShapeIDForElem(id)
1589 ## Returns the number of nodes for the given element
1590 # \n If there is no element for the given ID - returns -1
1591 # @return an integer value
1592 # @ingroup l1_meshinfo
1593 def GetElemNbNodes(self, id):
1594 return self.mesh.GetElemNbNodes(id)
1596 ## Returns the node ID the given index for the given element
1597 # \n If there is no element for the given ID - returns -1
1598 # \n If there is no node for the given index - returns -2
1599 # @return an integer value
1600 # @ingroup l1_meshinfo
1601 def GetElemNode(self, id, index):
1602 return self.mesh.GetElemNode(id, index)
1604 ## Returns the IDs of nodes of the given element
1605 # @return a list of integer values
1606 # @ingroup l1_meshinfo
1607 def GetElemNodes(self, id):
1608 return self.mesh.GetElemNodes(id)
1610 ## Returns true if the given node is the medium node in the given quadratic element
1611 # @ingroup l1_meshinfo
1612 def IsMediumNode(self, elementID, nodeID):
1613 return self.mesh.IsMediumNode(elementID, nodeID)
1615 ## Returns true if the given node is the medium node in one of quadratic elements
1616 # @ingroup l1_meshinfo
1617 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1618 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1620 ## Returns the number of edges for the given element
1621 # @ingroup l1_meshinfo
1622 def ElemNbEdges(self, id):
1623 return self.mesh.ElemNbEdges(id)
1625 ## Returns the number of faces for the given element
1626 # @ingroup l1_meshinfo
1627 def ElemNbFaces(self, id):
1628 return self.mesh.ElemNbFaces(id)
1630 ## Returns true if the given element is a polygon
1631 # @ingroup l1_meshinfo
1632 def IsPoly(self, id):
1633 return self.mesh.IsPoly(id)
1635 ## Returns true if the given element is quadratic
1636 # @ingroup l1_meshinfo
1637 def IsQuadratic(self, id):
1638 return self.mesh.IsQuadratic(id)
1640 ## Returns XYZ coordinates of the barycenter of the given element
1641 # \n If there is no element for the given ID - returns an empty list
1642 # @return a list of three double values
1643 # @ingroup l1_meshinfo
1644 def BaryCenter(self, id):
1645 return self.mesh.BaryCenter(id)
1648 # Mesh edition (SMESH_MeshEditor functionality):
1649 # ---------------------------------------------
1651 ## Removes the elements from the mesh by ids
1652 # @param IDsOfElements is a list of ids of elements to remove
1653 # @return True or False
1654 # @ingroup l2_modif_del
1655 def RemoveElements(self, IDsOfElements):
1656 return self.editor.RemoveElements(IDsOfElements)
1658 ## Removes nodes from mesh by ids
1659 # @param IDsOfNodes is a list of ids of nodes to remove
1660 # @return True or False
1661 # @ingroup l2_modif_del
1662 def RemoveNodes(self, IDsOfNodes):
1663 return self.editor.RemoveNodes(IDsOfNodes)
1665 ## Add a node to the mesh by coordinates
1666 # @return Id of the new node
1667 # @ingroup l2_modif_add
1668 def AddNode(self, x, y, z):
1669 return self.editor.AddNode( x, y, z)
1671 ## Creates a linear or quadratic edge (this is determined
1672 # by the number of given nodes).
1673 # @param IDsOfNodes the list of node IDs for creation of the element.
1674 # The order of nodes in this list should correspond to the description
1675 # of MED. \n This description is located by the following link:
1676 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1677 # @return the Id of the new edge
1678 # @ingroup l2_modif_add
1679 def AddEdge(self, IDsOfNodes):
1680 return self.editor.AddEdge(IDsOfNodes)
1682 ## Creates a linear or quadratic face (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 face
1689 # @ingroup l2_modif_add
1690 def AddFace(self, IDsOfNodes):
1691 return self.editor.AddFace(IDsOfNodes)
1693 ## Adds a polygonal face to the mesh by the list of node IDs
1694 # @param IdsOfNodes the list of node IDs for creation of the element.
1695 # @return the Id of the new face
1696 # @ingroup l2_modif_add
1697 def AddPolygonalFace(self, IdsOfNodes):
1698 return self.editor.AddPolygonalFace(IdsOfNodes)
1700 ## Creates both simple and quadratic volume (this is determined
1701 # by the number of given nodes).
1702 # @param IDsOfNodes the list of node IDs for creation of the element.
1703 # The order of nodes in this list should correspond to the description
1704 # of MED. \n This description is located by the following link:
1705 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1706 # @return the Id of the new volumic element
1707 # @ingroup l2_modif_add
1708 def AddVolume(self, IDsOfNodes):
1709 return self.editor.AddVolume(IDsOfNodes)
1711 ## Creates a volume of many faces, giving nodes for each face.
1712 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1713 # @param Quantities the list of integer values, Quantities[i]
1714 # gives the quantity of nodes in face number i.
1715 # @return the Id of the new volumic element
1716 # @ingroup l2_modif_add
1717 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1718 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1720 ## Creates a volume of many faces, giving the IDs of the existing faces.
1721 # @param IdsOfFaces the list of face IDs for volume creation.
1723 # Note: The created volume will refer only to the nodes
1724 # of the given faces, not to the faces themselves.
1725 # @return the Id of the new volumic element
1726 # @ingroup l2_modif_add
1727 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1728 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1731 ## @brief Binds a node to a vertex
1732 # @param NodeID a node ID
1733 # @param Vertex a vertex or vertex ID
1734 # @return True if succeed else raises an exception
1735 # @ingroup l2_modif_add
1736 def SetNodeOnVertex(self, NodeID, Vertex):
1737 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1738 VertexID = Vertex.GetSubShapeIndices()[0]
1742 self.editor.SetNodeOnVertex(NodeID, VertexID)
1743 except SALOME.SALOME_Exception, inst:
1744 raise ValueError, inst.details.text
1748 ## @brief Stores the node position on an edge
1749 # @param NodeID a node ID
1750 # @param Edge an edge or edge ID
1751 # @param paramOnEdge a parameter on the edge where the node is located
1752 # @return True if succeed else raises an exception
1753 # @ingroup l2_modif_add
1754 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1755 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1756 EdgeID = Edge.GetSubShapeIndices()[0]
1760 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1761 except SALOME.SALOME_Exception, inst:
1762 raise ValueError, inst.details.text
1765 ## @brief Stores node position on a face
1766 # @param NodeID a node ID
1767 # @param Face a face or face ID
1768 # @param u U parameter on the face where the node is located
1769 # @param v V parameter on the face where the node is located
1770 # @return True if succeed else raises an exception
1771 # @ingroup l2_modif_add
1772 def SetNodeOnFace(self, NodeID, Face, u, v):
1773 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1774 FaceID = Face.GetSubShapeIndices()[0]
1778 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1779 except SALOME.SALOME_Exception, inst:
1780 raise ValueError, inst.details.text
1783 ## @brief Binds a node to a solid
1784 # @param NodeID a node ID
1785 # @param Solid a solid or solid ID
1786 # @return True if succeed else raises an exception
1787 # @ingroup l2_modif_add
1788 def SetNodeInVolume(self, NodeID, Solid):
1789 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1790 SolidID = Solid.GetSubShapeIndices()[0]
1794 self.editor.SetNodeInVolume(NodeID, SolidID)
1795 except SALOME.SALOME_Exception, inst:
1796 raise ValueError, inst.details.text
1799 ## @brief Bind an element to a shape
1800 # @param ElementID an element ID
1801 # @param Shape a shape or shape ID
1802 # @return True if succeed else raises an exception
1803 # @ingroup l2_modif_add
1804 def SetMeshElementOnShape(self, ElementID, Shape):
1805 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1806 ShapeID = Shape.GetSubShapeIndices()[0]
1810 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1811 except SALOME.SALOME_Exception, inst:
1812 raise ValueError, inst.details.text
1816 ## Moves the node with the given id
1817 # @param NodeID the id of the node
1818 # @param x a new X coordinate
1819 # @param y a new Y coordinate
1820 # @param z a new Z coordinate
1821 # @return True if succeed else False
1822 # @ingroup l2_modif_movenode
1823 def MoveNode(self, NodeID, x, y, z):
1824 return self.editor.MoveNode(NodeID, x, y, z)
1826 ## Finds the node closest to a point
1827 # @param x the X coordinate of a point
1828 # @param y the Y coordinate of a point
1829 # @param z the Z coordinate of a point
1830 # @return the ID of a node
1831 # @ingroup l2_modif_throughp
1832 def FindNodeClosestTo(self, x, y, z):
1833 preview = self.mesh.GetMeshEditPreviewer()
1834 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1836 ## Finds the node closest to a point and moves it to a point location
1837 # @param x the X coordinate of a point
1838 # @param y the Y coordinate of a point
1839 # @param z the Z coordinate of a point
1840 # @return the ID of a moved node
1841 # @ingroup l2_modif_throughp
1842 def MeshToPassThroughAPoint(self, x, y, z):
1843 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1845 ## Replaces two neighbour triangles sharing Node1-Node2 link
1846 # with the triangles built on the same 4 nodes but having other common link.
1847 # @param NodeID1 the ID of the first node
1848 # @param NodeID2 the ID of the second node
1849 # @return false if proper faces were not found
1850 # @ingroup l2_modif_invdiag
1851 def InverseDiag(self, NodeID1, NodeID2):
1852 return self.editor.InverseDiag(NodeID1, NodeID2)
1854 ## Replaces two neighbour triangles sharing Node1-Node2 link
1855 # with a quadrangle built on the same 4 nodes.
1856 # @param NodeID1 the ID of the first node
1857 # @param NodeID2 the ID of the second node
1858 # @return false if proper faces were not found
1859 # @ingroup l2_modif_unitetri
1860 def DeleteDiag(self, NodeID1, NodeID2):
1861 return self.editor.DeleteDiag(NodeID1, NodeID2)
1863 ## Reorients elements by ids
1864 # @param IDsOfElements if undefined reorients all mesh elements
1865 # @return True if succeed else False
1866 # @ingroup l2_modif_changori
1867 def Reorient(self, IDsOfElements=None):
1868 if IDsOfElements == None:
1869 IDsOfElements = self.GetElementsId()
1870 return self.editor.Reorient(IDsOfElements)
1872 ## Reorients all elements of the object
1873 # @param theObject mesh, submesh or group
1874 # @return True if succeed else False
1875 # @ingroup l2_modif_changori
1876 def ReorientObject(self, theObject):
1877 if ( isinstance( theObject, Mesh )):
1878 theObject = theObject.GetMesh()
1879 return self.editor.ReorientObject(theObject)
1881 ## Fuses the neighbouring triangles into quadrangles.
1882 # @param IDsOfElements The triangles to be fused,
1883 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1884 # @param MaxAngle is the maximum angle between element normals at which the fusion
1885 # is still performed; theMaxAngle is mesured in radians.
1886 # @return TRUE in case of success, FALSE otherwise.
1887 # @ingroup l2_modif_unitetri
1888 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1889 if IDsOfElements == []:
1890 IDsOfElements = self.GetElementsId()
1891 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1893 ## Fuses the neighbouring triangles of the object into quadrangles
1894 # @param theObject is mesh, submesh or group
1895 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1896 # @param MaxAngle a max angle between element normals at which the fusion
1897 # is still performed; theMaxAngle is mesured in radians.
1898 # @return TRUE in case of success, FALSE otherwise.
1899 # @ingroup l2_modif_unitetri
1900 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1901 if ( isinstance( theObject, Mesh )):
1902 theObject = theObject.GetMesh()
1903 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1905 ## Splits quadrangles into triangles.
1906 # @param IDsOfElements the faces to be splitted.
1907 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1908 # @return TRUE in case of success, FALSE otherwise.
1909 # @ingroup l2_modif_cutquadr
1910 def QuadToTri (self, IDsOfElements, theCriterion):
1911 if IDsOfElements == []:
1912 IDsOfElements = self.GetElementsId()
1913 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1915 ## Splits quadrangles into triangles.
1916 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1917 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1918 # @return TRUE in case of success, FALSE otherwise.
1919 # @ingroup l2_modif_cutquadr
1920 def QuadToTriObject (self, theObject, theCriterion):
1921 if ( isinstance( theObject, Mesh )):
1922 theObject = theObject.GetMesh()
1923 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1925 ## Splits quadrangles into triangles.
1926 # @param IDsOfElements the faces to be splitted
1927 # @param Diag13 is used to choose a diagonal for splitting.
1928 # @return TRUE in case of success, FALSE otherwise.
1929 # @ingroup l2_modif_cutquadr
1930 def SplitQuad (self, IDsOfElements, Diag13):
1931 if IDsOfElements == []:
1932 IDsOfElements = self.GetElementsId()
1933 return self.editor.SplitQuad(IDsOfElements, Diag13)
1935 ## Splits quadrangles into triangles.
1936 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1937 # @param Diag13 is used to choose a diagonal for splitting.
1938 # @return TRUE in case of success, FALSE otherwise.
1939 # @ingroup l2_modif_cutquadr
1940 def SplitQuadObject (self, theObject, Diag13):
1941 if ( isinstance( theObject, Mesh )):
1942 theObject = theObject.GetMesh()
1943 return self.editor.SplitQuadObject(theObject, Diag13)
1945 ## Finds a better splitting of the given quadrangle.
1946 # @param IDOfQuad the ID of the quadrangle to be splitted.
1947 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1948 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1949 # diagonal is better, 0 if error occurs.
1950 # @ingroup l2_modif_cutquadr
1951 def BestSplit (self, IDOfQuad, theCriterion):
1952 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1954 ## Splits quadrangle faces near triangular facets of volumes
1956 # @ingroup l1_auxiliary
1957 def SplitQuadsNearTriangularFacets(self):
1958 faces_array = self.GetElementsByType(SMESH.FACE)
1959 for face_id in faces_array:
1960 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1961 quad_nodes = self.mesh.GetElemNodes(face_id)
1962 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1963 isVolumeFound = False
1964 for node1_elem in node1_elems:
1965 if not isVolumeFound:
1966 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1967 nb_nodes = self.GetElemNbNodes(node1_elem)
1968 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1969 volume_elem = node1_elem
1970 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1971 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1972 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1973 isVolumeFound = True
1974 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1975 self.SplitQuad([face_id], False) # diagonal 2-4
1976 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1977 isVolumeFound = True
1978 self.SplitQuad([face_id], True) # diagonal 1-3
1979 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1980 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1981 isVolumeFound = True
1982 self.SplitQuad([face_id], True) # diagonal 1-3
1984 ## @brief Splits hexahedrons into tetrahedrons.
1986 # This operation uses pattern mapping functionality for splitting.
1987 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1988 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1989 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1990 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1991 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
1992 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1993 # @return TRUE in case of success, FALSE otherwise.
1994 # @ingroup l1_auxiliary
1995 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1996 # Pattern: 5.---------.6
2001 # (0,0,1) 4.---------.7 * |
2008 # (0,0,0) 0.---------.3
2009 pattern_tetra = "!!! Nb of points: \n 8 \n\
2019 !!! Indices of points of 6 tetras: \n\
2027 pattern = self.smeshpyD.GetPattern()
2028 isDone = pattern.LoadFromFile(pattern_tetra)
2030 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2033 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2034 isDone = pattern.MakeMesh(self.mesh, False, False)
2035 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2037 # split quafrangle faces near triangular facets of volumes
2038 self.SplitQuadsNearTriangularFacets()
2042 ## @brief Split hexahedrons into prisms.
2044 # Uses the pattern mapping functionality for splitting.
2045 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2046 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2047 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2048 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2049 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2050 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2051 # @return TRUE in case of success, FALSE otherwise.
2052 # @ingroup l1_auxiliary
2053 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2054 # Pattern: 5.---------.6
2059 # (0,0,1) 4.---------.7 |
2066 # (0,0,0) 0.---------.3
2067 pattern_prism = "!!! Nb of points: \n 8 \n\
2077 !!! Indices of points of 2 prisms: \n\
2081 pattern = self.smeshpyD.GetPattern()
2082 isDone = pattern.LoadFromFile(pattern_prism)
2084 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2087 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2088 isDone = pattern.MakeMesh(self.mesh, False, False)
2089 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2091 # Splits quafrangle faces near triangular facets of volumes
2092 self.SplitQuadsNearTriangularFacets()
2096 ## Smoothes elements
2097 # @param IDsOfElements the list if ids of elements to smooth
2098 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2099 # Note that nodes built on edges and boundary nodes are always fixed.
2100 # @param MaxNbOfIterations the maximum number of iterations
2101 # @param MaxAspectRatio varies in range [1.0, inf]
2102 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2103 # @return TRUE in case of success, FALSE otherwise.
2104 # @ingroup l2_modif_smooth
2105 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2106 MaxNbOfIterations, MaxAspectRatio, Method):
2107 if IDsOfElements == []:
2108 IDsOfElements = self.GetElementsId()
2109 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2110 MaxNbOfIterations, MaxAspectRatio, Method)
2112 ## Smoothes elements which belong to the given object
2113 # @param theObject the object to smooth
2114 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2115 # Note that nodes built on edges and boundary nodes are always fixed.
2116 # @param MaxNbOfIterations the maximum number of iterations
2117 # @param MaxAspectRatio varies in range [1.0, inf]
2118 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2119 # @return TRUE in case of success, FALSE otherwise.
2120 # @ingroup l2_modif_smooth
2121 def SmoothObject(self, theObject, IDsOfFixedNodes,
2122 MaxNbOfIterations, MaxAspectRatio, Method):
2123 if ( isinstance( theObject, Mesh )):
2124 theObject = theObject.GetMesh()
2125 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2126 MaxNbOfIterations, MaxAspectRatio, Method)
2128 ## Parametrically smoothes the given elements
2129 # @param IDsOfElements the list if ids of elements to smooth
2130 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2131 # Note that nodes built on edges and boundary nodes are always fixed.
2132 # @param MaxNbOfIterations the maximum number of iterations
2133 # @param MaxAspectRatio varies in range [1.0, inf]
2134 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2135 # @return TRUE in case of success, FALSE otherwise.
2136 # @ingroup l2_modif_smooth
2137 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2138 MaxNbOfIterations, MaxAspectRatio, Method):
2139 if IDsOfElements == []:
2140 IDsOfElements = self.GetElementsId()
2141 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2142 MaxNbOfIterations, MaxAspectRatio, Method)
2144 ## Parametrically smoothes the elements which belong to the given object
2145 # @param theObject the object to smooth
2146 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2147 # Note that nodes built on edges and boundary nodes are always fixed.
2148 # @param MaxNbOfIterations the maximum number of iterations
2149 # @param MaxAspectRatio varies in range [1.0, inf]
2150 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2151 # @return TRUE in case of success, FALSE otherwise.
2152 # @ingroup l2_modif_smooth
2153 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2154 MaxNbOfIterations, MaxAspectRatio, Method):
2155 if ( isinstance( theObject, Mesh )):
2156 theObject = theObject.GetMesh()
2157 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2158 MaxNbOfIterations, MaxAspectRatio, Method)
2160 ## Converts the mesh to quadratic, deletes old elements, replacing
2161 # them with quadratic with the same id.
2162 # @ingroup l2_modif_tofromqu
2163 def ConvertToQuadratic(self, theForce3d):
2164 self.editor.ConvertToQuadratic(theForce3d)
2166 ## Converts the mesh from quadratic to ordinary,
2167 # deletes old quadratic elements, \n replacing
2168 # them with ordinary mesh elements with the same id.
2169 # @return TRUE in case of success, FALSE otherwise.
2170 # @ingroup l2_modif_tofromqu
2171 def ConvertFromQuadratic(self):
2172 return self.editor.ConvertFromQuadratic()
2174 ## Renumber mesh nodes
2175 # @ingroup l2_modif_renumber
2176 def RenumberNodes(self):
2177 self.editor.RenumberNodes()
2179 ## Renumber mesh elements
2180 # @ingroup l2_modif_renumber
2181 def RenumberElements(self):
2182 self.editor.RenumberElements()
2184 ## Generates new elements by rotation of the elements around the axis
2185 # @param IDsOfElements the list of ids of elements to sweep
2186 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2187 # @param AngleInRadians the angle of Rotation
2188 # @param NbOfSteps the number of steps
2189 # @param Tolerance tolerance
2190 # @param MakeGroups forces the generation of new groups from existing ones
2191 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2192 # of all steps, else - size of each step
2193 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2194 # @ingroup l2_modif_extrurev
2195 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2196 MakeGroups=False, TotalAngle=False):
2197 if IDsOfElements == []:
2198 IDsOfElements = self.GetElementsId()
2199 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2200 Axis = self.smeshpyD.GetAxisStruct(Axis)
2201 if TotalAngle and NbOfSteps:
2202 AngleInRadians /= NbOfSteps
2204 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2205 AngleInRadians, NbOfSteps, Tolerance)
2206 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2209 ## Generates new elements by rotation of the elements of object around the axis
2210 # @param theObject object which elements should be sweeped
2211 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2212 # @param AngleInRadians the angle of Rotation
2213 # @param NbOfSteps number of steps
2214 # @param Tolerance tolerance
2215 # @param MakeGroups forces the generation of new groups from existing ones
2216 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2217 # of all steps, else - size of each step
2218 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2219 # @ingroup l2_modif_extrurev
2220 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2221 MakeGroups=False, TotalAngle=False):
2222 if ( isinstance( theObject, Mesh )):
2223 theObject = theObject.GetMesh()
2224 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2225 Axis = self.smeshpyD.GetAxisStruct(Axis)
2226 if TotalAngle and NbOfSteps:
2227 AngleInRadians /= NbOfSteps
2229 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2230 NbOfSteps, Tolerance)
2231 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2234 ## Generates new elements by extrusion of the elements with given ids
2235 # @param IDsOfElements the list of elements ids for extrusion
2236 # @param StepVector vector, defining the direction and value of extrusion
2237 # @param NbOfSteps the number of steps
2238 # @param MakeGroups forces the generation of new groups from existing ones
2239 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2240 # @ingroup l2_modif_extrurev
2241 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2242 if IDsOfElements == []:
2243 IDsOfElements = self.GetElementsId()
2244 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2245 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2247 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2248 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2251 ## Generates new elements by extrusion of the elements with given ids
2252 # @param IDsOfElements is ids of elements
2253 # @param StepVector vector, defining the direction and value of extrusion
2254 # @param NbOfSteps the number of steps
2255 # @param ExtrFlags sets flags for extrusion
2256 # @param SewTolerance uses for comparing locations of nodes if flag
2257 # EXTRUSION_FLAG_SEW is set
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 AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2262 ExtrFlags, SewTolerance, MakeGroups=False):
2263 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2264 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2266 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2267 ExtrFlags, SewTolerance)
2268 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2269 ExtrFlags, SewTolerance)
2272 ## Generates new elements by extrusion of the elements which belong to the object
2273 # @param theObject the object which elements should be processed
2274 # @param StepVector vector, defining the direction and value of extrusion
2275 # @param NbOfSteps the number of steps
2276 # @param MakeGroups forces the generation of new groups from existing ones
2277 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2278 # @ingroup l2_modif_extrurev
2279 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2280 if ( isinstance( theObject, Mesh )):
2281 theObject = theObject.GetMesh()
2282 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2283 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2285 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2286 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2289 ## Generates new elements by extrusion of the elements which belong to the object
2290 # @param theObject object which elements should be processed
2291 # @param StepVector vector, defining the direction and value of extrusion
2292 # @param NbOfSteps the number of steps
2293 # @param MakeGroups to generate new groups from existing ones
2294 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2295 # @ingroup l2_modif_extrurev
2296 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2297 if ( isinstance( theObject, Mesh )):
2298 theObject = theObject.GetMesh()
2299 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2300 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2302 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2303 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2306 ## Generates new elements by extrusion of the elements which belong to the object
2307 # @param theObject object which elements should be processed
2308 # @param StepVector vector, defining the direction and value of extrusion
2309 # @param NbOfSteps the number of steps
2310 # @param MakeGroups forces the generation of new groups from existing ones
2311 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2312 # @ingroup l2_modif_extrurev
2313 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2314 if ( isinstance( theObject, Mesh )):
2315 theObject = theObject.GetMesh()
2316 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2317 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2319 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2320 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2323 ## Generates new elements by extrusion of the given elements
2324 # The path of extrusion must be a meshed edge.
2325 # @param IDsOfElements ids of elements
2326 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2327 # @param PathShape shape(edge) defines the sub-mesh for the path
2328 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2329 # @param HasAngles allows the shape to be rotated around the path
2330 # to get the resulting mesh in a helical fashion
2331 # @param Angles list of angles
2332 # @param HasRefPoint allows using the reference point
2333 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2334 # The User can specify any point as the Reference Point.
2335 # @param MakeGroups forces the generation of new groups from existing ones
2336 # @param LinearVariation forces the computation of rotation angles as linear
2337 # variation of the given Angles along path steps
2338 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2339 # only SMESH::Extrusion_Error otherwise
2340 # @ingroup l2_modif_extrurev
2341 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2342 HasAngles, Angles, HasRefPoint, RefPoint,
2343 MakeGroups=False, LinearVariation=False):
2344 if IDsOfElements == []:
2345 IDsOfElements = self.GetElementsId()
2346 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2347 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2349 if ( isinstance( PathMesh, Mesh )):
2350 PathMesh = PathMesh.GetMesh()
2351 if HasAngles and Angles and LinearVariation:
2352 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2355 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2356 PathShape, NodeStart, HasAngles,
2357 Angles, HasRefPoint, RefPoint)
2358 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2359 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2361 ## Generates new elements by extrusion of the elements which belong to the object
2362 # The path of extrusion must be a meshed edge.
2363 # @param theObject the object which elements should be processed
2364 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2365 # @param PathShape shape(edge) defines the sub-mesh for the path
2366 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2367 # @param HasAngles allows the shape to be rotated around the path
2368 # to get the resulting mesh in a helical fashion
2369 # @param Angles list of angles
2370 # @param HasRefPoint allows using the reference point
2371 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2372 # The User can specify any point as the Reference Point.
2373 # @param MakeGroups forces the generation of new groups from existing ones
2374 # @param LinearVariation forces the computation of rotation angles as linear
2375 # variation of the given Angles along path steps
2376 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2377 # only SMESH::Extrusion_Error otherwise
2378 # @ingroup l2_modif_extrurev
2379 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2380 HasAngles, Angles, HasRefPoint, RefPoint,
2381 MakeGroups=False, LinearVariation=False):
2382 if ( isinstance( theObject, Mesh )):
2383 theObject = theObject.GetMesh()
2384 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2385 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2386 if ( isinstance( PathMesh, Mesh )):
2387 PathMesh = PathMesh.GetMesh()
2388 if HasAngles and Angles and LinearVariation:
2389 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2392 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2393 PathShape, NodeStart, HasAngles,
2394 Angles, HasRefPoint, RefPoint)
2395 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2396 NodeStart, HasAngles, Angles, HasRefPoint,
2399 ## Creates a symmetrical copy of mesh elements
2400 # @param IDsOfElements list of elements ids
2401 # @param Mirror is AxisStruct or geom object(point, line, plane)
2402 # @param theMirrorType is POINT, AXIS or PLANE
2403 # If the Mirror is a geom object this parameter is unnecessary
2404 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2405 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2406 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2407 # @ingroup l2_modif_trsf
2408 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2409 if IDsOfElements == []:
2410 IDsOfElements = self.GetElementsId()
2411 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2412 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2413 if Copy and MakeGroups:
2414 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2415 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2418 ## Creates a new mesh by a symmetrical copy of mesh elements
2419 # @param IDsOfElements the list of elements ids
2420 # @param Mirror is 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 MakeGroups to generate new groups from existing ones
2424 # @param NewMeshName a name of the new mesh to create
2425 # @return instance of Mesh class
2426 # @ingroup l2_modif_trsf
2427 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2428 if IDsOfElements == []:
2429 IDsOfElements = self.GetElementsId()
2430 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2431 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2432 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2433 MakeGroups, NewMeshName)
2434 return Mesh(self.smeshpyD,self.geompyD,mesh)
2436 ## Creates a symmetrical copy of the object
2437 # @param theObject mesh, submesh or group
2438 # @param Mirror AxisStruct or geom object (point, line, plane)
2439 # @param theMirrorType is POINT, AXIS or PLANE
2440 # If the Mirror is a geom object this parameter is unnecessary
2441 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2442 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2443 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2444 # @ingroup l2_modif_trsf
2445 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2446 if ( isinstance( theObject, Mesh )):
2447 theObject = theObject.GetMesh()
2448 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2449 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2450 if Copy and MakeGroups:
2451 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2452 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2455 ## Creates a new mesh by a symmetrical copy of the object
2456 # @param theObject mesh, submesh or group
2457 # @param Mirror AxisStruct or geom object (point, line, plane)
2458 # @param theMirrorType POINT, AXIS or PLANE
2459 # If the Mirror is a geom object this parameter is unnecessary
2460 # @param MakeGroups forces the generation of new groups from existing ones
2461 # @param NewMeshName the name of the new mesh to create
2462 # @return instance of Mesh class
2463 # @ingroup l2_modif_trsf
2464 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2465 if ( isinstance( theObject, Mesh )):
2466 theObject = theObject.GetMesh()
2467 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2468 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2469 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2470 MakeGroups, NewMeshName)
2471 return Mesh( self.smeshpyD,self.geompyD,mesh )
2473 ## Translates the elements
2474 # @param IDsOfElements list of elements ids
2475 # @param Vector the direction of translation (DirStruct or vector)
2476 # @param Copy allows copying the translated elements
2477 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2478 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2479 # @ingroup l2_modif_trsf
2480 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2481 if IDsOfElements == []:
2482 IDsOfElements = self.GetElementsId()
2483 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2484 Vector = self.smeshpyD.GetDirStruct(Vector)
2485 if Copy and MakeGroups:
2486 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2487 self.editor.Translate(IDsOfElements, Vector, Copy)
2490 ## Creates a new mesh of translated elements
2491 # @param IDsOfElements list of elements ids
2492 # @param Vector the direction of translation (DirStruct or vector)
2493 # @param MakeGroups forces the generation of new groups from existing ones
2494 # @param NewMeshName the name of the newly created mesh
2495 # @return instance of Mesh class
2496 # @ingroup l2_modif_trsf
2497 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2498 if IDsOfElements == []:
2499 IDsOfElements = self.GetElementsId()
2500 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2501 Vector = self.smeshpyD.GetDirStruct(Vector)
2502 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2503 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2505 ## Translates the object
2506 # @param theObject the object to translate (mesh, submesh, or group)
2507 # @param Vector direction of translation (DirStruct or geom vector)
2508 # @param Copy allows copying the translated elements
2509 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2510 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2511 # @ingroup l2_modif_trsf
2512 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2513 if ( isinstance( theObject, Mesh )):
2514 theObject = theObject.GetMesh()
2515 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2516 Vector = self.smeshpyD.GetDirStruct(Vector)
2517 if Copy and MakeGroups:
2518 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2519 self.editor.TranslateObject(theObject, Vector, Copy)
2522 ## Creates a new mesh from the translated object
2523 # @param theObject the object to translate (mesh, submesh, or group)
2524 # @param Vector the direction of translation (DirStruct or geom vector)
2525 # @param MakeGroups forces the generation of new groups from existing ones
2526 # @param NewMeshName the name of the newly created mesh
2527 # @return instance of Mesh class
2528 # @ingroup l2_modif_trsf
2529 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2530 if (isinstance(theObject, Mesh)):
2531 theObject = theObject.GetMesh()
2532 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2533 Vector = self.smeshpyD.GetDirStruct(Vector)
2534 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2535 return Mesh( self.smeshpyD, self.geompyD, mesh )
2537 ## Rotates the elements
2538 # @param IDsOfElements list of elements ids
2539 # @param Axis the axis of rotation (AxisStruct or geom line)
2540 # @param AngleInRadians the angle of rotation (in radians)
2541 # @param Copy allows copying the rotated elements
2542 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2543 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2544 # @ingroup l2_modif_trsf
2545 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2546 if IDsOfElements == []:
2547 IDsOfElements = self.GetElementsId()
2548 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2549 Axis = self.smeshpyD.GetAxisStruct(Axis)
2550 if Copy and MakeGroups:
2551 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2552 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2555 ## Creates a new mesh of rotated elements
2556 # @param IDsOfElements list of element ids
2557 # @param Axis the axis of rotation (AxisStruct or geom line)
2558 # @param AngleInRadians the angle of rotation (in radians)
2559 # @param MakeGroups forces the generation of new groups from existing ones
2560 # @param NewMeshName the name of the newly created mesh
2561 # @return instance of Mesh class
2562 # @ingroup l2_modif_trsf
2563 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2564 if IDsOfElements == []:
2565 IDsOfElements = self.GetElementsId()
2566 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2567 Axis = self.smeshpyD.GetAxisStruct(Axis)
2568 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2569 MakeGroups, NewMeshName)
2570 return Mesh( self.smeshpyD, self.geompyD, mesh )
2572 ## Rotates the 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 Copy allows copying the rotated elements
2577 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2578 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2579 # @ingroup l2_modif_trsf
2580 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
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 if Copy and MakeGroups:
2586 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2587 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2590 ## Creates a new mesh from the rotated object
2591 # @param theObject the object to rotate (mesh, submesh, or group)
2592 # @param Axis the axis of rotation (AxisStruct or geom line)
2593 # @param AngleInRadians the angle of rotation (in radians)
2594 # @param MakeGroups forces the generation of new groups from existing ones
2595 # @param NewMeshName the name of the newly created mesh
2596 # @return instance of Mesh class
2597 # @ingroup l2_modif_trsf
2598 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2599 if (isinstance( theObject, Mesh )):
2600 theObject = theObject.GetMesh()
2601 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2602 Axis = self.smeshpyD.GetAxisStruct(Axis)
2603 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2604 MakeGroups, NewMeshName)
2605 return Mesh( self.smeshpyD, self.geompyD, mesh )
2607 ## Finds groups of ajacent nodes within Tolerance.
2608 # @param Tolerance the value of tolerance
2609 # @return the list of groups of nodes
2610 # @ingroup l2_modif_trsf
2611 def FindCoincidentNodes (self, Tolerance):
2612 return self.editor.FindCoincidentNodes(Tolerance)
2614 ## Finds groups of ajacent nodes within Tolerance.
2615 # @param Tolerance the value of tolerance
2616 # @param SubMeshOrGroup SubMesh or Group
2617 # @return the list of groups of nodes
2618 # @ingroup l2_modif_trsf
2619 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2620 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2623 # @param GroupsOfNodes the list of groups of nodes
2624 # @ingroup l2_modif_trsf
2625 def MergeNodes (self, GroupsOfNodes):
2626 self.editor.MergeNodes(GroupsOfNodes)
2628 ## Finds the elements built on the same nodes.
2629 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2630 # @return a list of groups of equal elements
2631 # @ingroup l2_modif_trsf
2632 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2633 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2635 ## Merges elements in each given group.
2636 # @param GroupsOfElementsID groups of elements for merging
2637 # @ingroup l2_modif_trsf
2638 def MergeElements(self, GroupsOfElementsID):
2639 self.editor.MergeElements(GroupsOfElementsID)
2641 ## Leaves one element and removes all other elements built on the same nodes.
2642 # @ingroup l2_modif_trsf
2643 def MergeEqualElements(self):
2644 self.editor.MergeEqualElements()
2646 ## Sews free borders
2647 # @return SMESH::Sew_Error
2648 # @ingroup l2_modif_trsf
2649 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2650 FirstNodeID2, SecondNodeID2, LastNodeID2,
2651 CreatePolygons, CreatePolyedrs):
2652 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2653 FirstNodeID2, SecondNodeID2, LastNodeID2,
2654 CreatePolygons, CreatePolyedrs)
2656 ## Sews conform free borders
2657 # @return SMESH::Sew_Error
2658 # @ingroup l2_modif_trsf
2659 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2660 FirstNodeID2, SecondNodeID2):
2661 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2662 FirstNodeID2, SecondNodeID2)
2664 ## Sews border to side
2665 # @return SMESH::Sew_Error
2666 # @ingroup l2_modif_trsf
2667 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2668 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2669 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2670 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2672 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2673 # merged with the nodes of elements of Side2.
2674 # The number of elements in theSide1 and in theSide2 must be
2675 # equal and they should have similar nodal connectivity.
2676 # The nodes to merge should belong to side borders and
2677 # the first node should be linked to the second.
2678 # @return SMESH::Sew_Error
2679 # @ingroup l2_modif_trsf
2680 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2681 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2682 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2683 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2684 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2685 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2687 ## Sets new nodes for the given element.
2688 # @param ide the element id
2689 # @param newIDs nodes ids
2690 # @return If the number of nodes does not correspond to the type of element - returns false
2691 # @ingroup l2_modif_edit
2692 def ChangeElemNodes(self, ide, newIDs):
2693 return self.editor.ChangeElemNodes(ide, newIDs)
2695 ## If during the last operation of MeshEditor some nodes were
2696 # created, this method returns the list of their IDs, \n
2697 # if new nodes were not created - returns empty list
2698 # @return the list of integer values (can be empty)
2699 # @ingroup l1_auxiliary
2700 def GetLastCreatedNodes(self):
2701 return self.editor.GetLastCreatedNodes()
2703 ## If during the last operation of MeshEditor some elements were
2704 # created this method returns the list of their IDs, \n
2705 # if new elements were not created - returns empty list
2706 # @return the list of integer values (can be empty)
2707 # @ingroup l1_auxiliary
2708 def GetLastCreatedElems(self):
2709 return self.editor.GetLastCreatedElems()
2711 ## The mother class to define algorithm, it is not recommended to use it directly.
2714 # @ingroup l2_algorithms
2715 class Mesh_Algorithm:
2716 # @class Mesh_Algorithm
2717 # @brief Class Mesh_Algorithm
2719 #def __init__(self,smesh):
2727 ## Finds a hypothesis in the study by its type name and parameters.
2728 # Finds only the hypotheses created in smeshpyD engine.
2729 # @return SMESH.SMESH_Hypothesis
2730 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2731 study = smeshpyD.GetCurrentStudy()
2732 #to do: find component by smeshpyD object, not by its data type
2733 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2734 if scomp is not None:
2735 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2736 # Check if the root label of the hypotheses exists
2737 if res and hypRoot is not None:
2738 iter = study.NewChildIterator(hypRoot)
2739 # Check all published hypotheses
2741 hypo_so_i = iter.Value()
2742 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2743 if attr is not None:
2744 anIOR = attr.Value()
2745 hypo_o_i = salome.orb.string_to_object(anIOR)
2746 if hypo_o_i is not None:
2747 # Check if this is a hypothesis
2748 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2749 if hypo_i is not None:
2750 # Check if the hypothesis belongs to current engine
2751 if smeshpyD.GetObjectId(hypo_i) > 0:
2752 # Check if this is the required hypothesis
2753 if hypo_i.GetName() == hypname:
2755 if CompareMethod(hypo_i, args):
2769 ## Finds the algorithm in the study by its type name.
2770 # Finds only the algorithms, which have been created in smeshpyD engine.
2771 # @return SMESH.SMESH_Algo
2772 def FindAlgorithm (self, algoname, smeshpyD):
2773 study = smeshpyD.GetCurrentStudy()
2774 #to do: find component by smeshpyD object, not by its data type
2775 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2776 if scomp is not None:
2777 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2778 # Check if the root label of the algorithms exists
2779 if res and hypRoot is not None:
2780 iter = study.NewChildIterator(hypRoot)
2781 # Check all published algorithms
2783 algo_so_i = iter.Value()
2784 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2785 if attr is not None:
2786 anIOR = attr.Value()
2787 algo_o_i = salome.orb.string_to_object(anIOR)
2788 if algo_o_i is not None:
2789 # Check if this is an algorithm
2790 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2791 if algo_i is not None:
2792 # Checks if the algorithm belongs to the current engine
2793 if smeshpyD.GetObjectId(algo_i) > 0:
2794 # Check if this is the required algorithm
2795 if algo_i.GetName() == algoname:
2808 ## If the algorithm is global, returns 0; \n
2809 # else returns the submesh associated to this algorithm.
2810 def GetSubMesh(self):
2813 ## Returns the wrapped mesher.
2814 def GetAlgorithm(self):
2817 ## Gets the list of hypothesis that can be used with this algorithm
2818 def GetCompatibleHypothesis(self):
2821 mylist = self.algo.GetCompatibleHypothesis()
2824 ## Gets the name of the algorithm
2828 ## Sets the name to the algorithm
2829 def SetName(self, name):
2830 SetName(self.algo, name)
2832 ## Gets the id of the algorithm
2834 return self.algo.GetId()
2837 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2839 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2840 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2842 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2844 self.Assign(algo, mesh, geom)
2848 def Assign(self, algo, mesh, geom):
2850 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2857 name = GetName(geom)
2859 name = mesh.geompyD.SubShapeName(geom, piece)
2860 mesh.geompyD.addToStudyInFather(piece, geom, name)
2861 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2864 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2865 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2867 def CompareHyp (self, hyp, args):
2868 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2871 def CompareEqualHyp (self, hyp, args):
2875 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2876 UseExisting=0, CompareMethod=""):
2879 if CompareMethod == "": CompareMethod = self.CompareHyp
2880 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2883 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2889 a = a + s + str(args[i])
2893 SetName(hypo, hyp + a)
2895 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2896 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2900 # Public class: Mesh_Segment
2901 # --------------------------
2903 ## Class to define a segment 1D algorithm for discretization
2906 # @ingroup l3_algos_basic
2907 class Mesh_Segment(Mesh_Algorithm):
2909 ## Private constructor.
2910 def __init__(self, mesh, geom=0):
2911 Mesh_Algorithm.__init__(self)
2912 self.Create(mesh, geom, "Regular_1D")
2914 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2915 # @param l for the length of segments that cut an edge
2916 # @param UseExisting if ==true - searches for an existing hypothesis created with
2917 # the same parameters, else (default) - creates a new one
2918 # @param p precision, used for calculation of the number of segments.
2919 # The precision should be a positive, meaningful value within the range [0,1].
2920 # In general, the number of segments is calculated with the formula:
2921 # nb = ceil((edge_length / l) - p)
2922 # Function ceil rounds its argument to the higher integer.
2923 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2924 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2925 # p=1 means rounding of (edge_length / l) to the lower integer.
2926 # Default value is 1e-07.
2927 # @return an instance of StdMeshers_LocalLength hypothesis
2928 # @ingroup l3_hypos_1dhyps
2929 def LocalLength(self, l, UseExisting=0, p=1e-07):
2930 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2931 CompareMethod=self.CompareLocalLength)
2937 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2938 def CompareLocalLength(self, hyp, args):
2939 if IsEqual(hyp.GetLength(), args[0]):
2940 return IsEqual(hyp.GetPrecision(), args[1])
2943 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2944 # @param n for the number of segments that cut an edge
2945 # @param s for the scale factor (optional)
2946 # @param UseExisting if ==true - searches for an existing hypothesis created with
2947 # the same parameters, else (default) - create a new one
2948 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2949 # @ingroup l3_hypos_1dhyps
2950 def NumberOfSegments(self, n, s=[], UseExisting=0):
2952 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2953 CompareMethod=self.CompareNumberOfSegments)
2955 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2956 CompareMethod=self.CompareNumberOfSegments)
2957 hyp.SetDistrType( 1 )
2958 hyp.SetScaleFactor(s)
2959 hyp.SetNumberOfSegments(n)
2963 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2964 def CompareNumberOfSegments(self, hyp, args):
2965 if hyp.GetNumberOfSegments() == args[0]:
2969 if hyp.GetDistrType() == 1:
2970 if IsEqual(hyp.GetScaleFactor(), args[1]):
2974 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2975 # @param start defines the length of the first segment
2976 # @param end defines the length of the last segment
2977 # @param UseExisting if ==true - searches for an existing hypothesis created with
2978 # the same parameters, else (default) - creates a new one
2979 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2980 # @ingroup l3_hypos_1dhyps
2981 def Arithmetic1D(self, start, end, UseExisting=0):
2982 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2983 CompareMethod=self.CompareArithmetic1D)
2984 hyp.SetLength(start, 1)
2985 hyp.SetLength(end , 0)
2989 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2990 def CompareArithmetic1D(self, hyp, args):
2991 if IsEqual(hyp.GetLength(1), args[0]):
2992 if IsEqual(hyp.GetLength(0), args[1]):
2996 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2997 # @param start defines the length of the first segment
2998 # @param end defines the length of the last segment
2999 # @param UseExisting if ==true - searches for an existing hypothesis created with
3000 # the same parameters, else (default) - creates a new one
3001 # @return an instance of StdMeshers_StartEndLength hypothesis
3002 # @ingroup l3_hypos_1dhyps
3003 def StartEndLength(self, start, end, UseExisting=0):
3004 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3005 CompareMethod=self.CompareStartEndLength)
3006 hyp.SetLength(start, 1)
3007 hyp.SetLength(end , 0)
3010 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3011 def CompareStartEndLength(self, hyp, args):
3012 if IsEqual(hyp.GetLength(1), args[0]):
3013 if IsEqual(hyp.GetLength(0), args[1]):
3017 ## Defines "Deflection1D" hypothesis
3018 # @param d for the deflection
3019 # @param UseExisting if ==true - searches for an existing hypothesis created with
3020 # the same parameters, else (default) - create a new one
3021 # @ingroup l3_hypos_1dhyps
3022 def Deflection1D(self, d, UseExisting=0):
3023 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3024 CompareMethod=self.CompareDeflection1D)
3025 hyp.SetDeflection(d)
3028 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3029 def CompareDeflection1D(self, hyp, args):
3030 return IsEqual(hyp.GetDeflection(), args[0])
3032 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3033 # the opposite side in case of quadrangular faces
3034 # @ingroup l3_hypos_additi
3035 def Propagation(self):
3036 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3038 ## Defines "AutomaticLength" hypothesis
3039 # @param fineness for the fineness [0-1]
3040 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3041 # same parameters, else (default) - create a new one
3042 # @ingroup l3_hypos_1dhyps
3043 def AutomaticLength(self, fineness=0, UseExisting=0):
3044 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3045 CompareMethod=self.CompareAutomaticLength)
3046 hyp.SetFineness( fineness )
3049 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3050 def CompareAutomaticLength(self, hyp, args):
3051 return IsEqual(hyp.GetFineness(), args[0])
3053 ## Defines "SegmentLengthAroundVertex" hypothesis
3054 # @param length for the segment length
3055 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3056 # Any other integer value means that the hypothesis will be set on the
3057 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3058 # @param UseExisting if ==true - searches for an existing hypothesis created with
3059 # the same parameters, else (default) - creates a new one
3060 # @ingroup l3_algos_segmarv
3061 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3063 store_geom = self.geom
3064 if type(vertex) is types.IntType:
3065 if vertex == 0 or vertex == 1:
3066 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3074 if self.geom is None:
3075 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3076 name = GetName(self.geom)
3078 piece = self.mesh.geom
3079 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3080 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3081 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3083 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3085 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3086 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3088 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3089 CompareMethod=self.CompareLengthNearVertex)
3090 self.geom = store_geom
3091 hyp.SetLength( length )
3094 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3095 # @ingroup l3_algos_segmarv
3096 def CompareLengthNearVertex(self, hyp, args):
3097 return IsEqual(hyp.GetLength(), args[0])
3099 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3100 # If the 2D mesher sees that all boundary edges are quadratic,
3101 # it generates quadratic faces, else it generates linear faces using
3102 # medium nodes as if they are vertices.
3103 # The 3D mesher generates quadratic volumes only if all boundary faces
3104 # are quadratic, else it fails.
3106 # @ingroup l3_hypos_additi
3107 def QuadraticMesh(self):
3108 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3111 # Public class: Mesh_CompositeSegment
3112 # --------------------------
3114 ## Defines a segment 1D algorithm for discretization
3116 # @ingroup l3_algos_basic
3117 class Mesh_CompositeSegment(Mesh_Segment):
3119 ## Private constructor.
3120 def __init__(self, mesh, geom=0):
3121 self.Create(mesh, geom, "CompositeSegment_1D")
3124 # Public class: Mesh_Segment_Python
3125 # ---------------------------------
3127 ## Defines a segment 1D algorithm for discretization with python function
3129 # @ingroup l3_algos_basic
3130 class Mesh_Segment_Python(Mesh_Segment):
3132 ## Private constructor.
3133 def __init__(self, mesh, geom=0):
3134 import Python1dPlugin
3135 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3137 ## Defines "PythonSplit1D" hypothesis
3138 # @param n for the number of segments that cut an edge
3139 # @param func for the python function that calculates the length of all segments
3140 # @param UseExisting if ==true - searches for the existing hypothesis created with
3141 # the same parameters, else (default) - creates a new one
3142 # @ingroup l3_hypos_1dhyps
3143 def PythonSplit1D(self, n, func, UseExisting=0):
3144 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3145 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3146 hyp.SetNumberOfSegments(n)
3147 hyp.SetPythonLog10RatioFunction(func)
3150 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3151 def ComparePythonSplit1D(self, hyp, args):
3152 #if hyp.GetNumberOfSegments() == args[0]:
3153 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3157 # Public class: Mesh_Triangle
3158 # ---------------------------
3160 ## Defines a triangle 2D algorithm
3162 # @ingroup l3_algos_basic
3163 class Mesh_Triangle(Mesh_Algorithm):
3172 ## Private constructor.
3173 def __init__(self, mesh, algoType, geom=0):
3174 Mesh_Algorithm.__init__(self)
3176 self.algoType = algoType
3177 if algoType == MEFISTO:
3178 self.Create(mesh, geom, "MEFISTO_2D")
3180 elif algoType == BLSURF:
3182 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3183 #self.SetPhysicalMesh() - PAL19680
3184 elif algoType == NETGEN:
3186 print "Warning: NETGENPlugin module unavailable"
3188 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3190 elif algoType == NETGEN_2D:
3192 print "Warning: NETGENPlugin module unavailable"
3194 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3197 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3198 # @param area for the maximum area of each triangle
3199 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3200 # same parameters, else (default) - creates a new one
3202 # Only for algoType == MEFISTO || NETGEN_2D
3203 # @ingroup l3_hypos_2dhyps
3204 def MaxElementArea(self, area, UseExisting=0):
3205 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3206 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3207 CompareMethod=self.CompareMaxElementArea)
3208 elif self.algoType == NETGEN:
3209 hyp = self.Parameters(SIMPLE)
3210 hyp.SetMaxElementArea(area)
3213 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3214 def CompareMaxElementArea(self, hyp, args):
3215 return IsEqual(hyp.GetMaxElementArea(), args[0])
3217 ## Defines "LengthFromEdges" hypothesis to build triangles
3218 # based on the length of the edges taken from the wire
3220 # Only for algoType == MEFISTO || NETGEN_2D
3221 # @ingroup l3_hypos_2dhyps
3222 def LengthFromEdges(self):
3223 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3224 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3226 elif self.algoType == NETGEN:
3227 hyp = self.Parameters(SIMPLE)
3228 hyp.LengthFromEdges()
3231 ## Sets a way to define size of mesh elements to generate.
3232 # @param thePhysicalMesh is: DefaultSize or Custom.
3233 # @ingroup l3_hypos_blsurf
3234 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3235 # Parameter of BLSURF algo
3236 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3238 ## Sets size of mesh elements to generate.
3239 # @ingroup l3_hypos_blsurf
3240 def SetPhySize(self, theVal):
3241 # Parameter of BLSURF algo
3242 self.Parameters().SetPhySize(theVal)
3244 ## Sets lower boundary of mesh element size (PhySize).
3245 # @ingroup l3_hypos_blsurf
3246 def SetPhyMin(self, theVal=-1):
3247 # Parameter of BLSURF algo
3248 self.Parameters().SetPhyMin(theVal)
3250 ## Sets upper boundary of mesh element size (PhySize).
3251 # @ingroup l3_hypos_blsurf
3252 def SetPhyMax(self, theVal=-1):
3253 # Parameter of BLSURF algo
3254 self.Parameters().SetPhyMax(theVal)
3256 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3257 # @param theGeometricMesh is: DefaultGeom or Custom
3258 # @ingroup l3_hypos_blsurf
3259 def SetGeometricMesh(self, theGeometricMesh=0):
3260 # Parameter of BLSURF algo
3261 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3262 self.params.SetGeometricMesh(theGeometricMesh)
3264 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3265 # @ingroup l3_hypos_blsurf
3266 def SetAngleMeshS(self, theVal=_angleMeshS):
3267 # Parameter of BLSURF algo
3268 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3269 self.params.SetAngleMeshS(theVal)
3271 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3272 # @ingroup l3_hypos_blsurf
3273 def SetAngleMeshC(self, theVal=_angleMeshS):
3274 # Parameter of BLSURF algo
3275 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3276 self.params.SetAngleMeshC(theVal)
3278 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3279 # @ingroup l3_hypos_blsurf
3280 def SetGeoMin(self, theVal=-1):
3281 # Parameter of BLSURF algo
3282 self.Parameters().SetGeoMin(theVal)
3284 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3285 # @ingroup l3_hypos_blsurf
3286 def SetGeoMax(self, theVal=-1):
3287 # Parameter of BLSURF algo
3288 self.Parameters().SetGeoMax(theVal)
3290 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3291 # @ingroup l3_hypos_blsurf
3292 def SetGradation(self, theVal=_gradation):
3293 # Parameter of BLSURF algo
3294 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3295 self.params.SetGradation(theVal)
3297 ## Sets topology usage way.
3298 # @param way defines how mesh conformity is assured <ul>
3299 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3300 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3301 # @ingroup l3_hypos_blsurf
3302 def SetTopology(self, way):
3303 # Parameter of BLSURF algo
3304 self.Parameters().SetTopology(way)
3306 ## To respect geometrical edges or not.
3307 # @ingroup l3_hypos_blsurf
3308 def SetDecimesh(self, toIgnoreEdges=False):
3309 # Parameter of BLSURF algo
3310 self.Parameters().SetDecimesh(toIgnoreEdges)
3312 ## Sets verbosity level in the range 0 to 100.
3313 # @ingroup l3_hypos_blsurf
3314 def SetVerbosity(self, level):
3315 # Parameter of BLSURF algo
3316 self.Parameters().SetVerbosity(level)
3318 ## Sets advanced option value.
3319 # @ingroup l3_hypos_blsurf
3320 def SetOptionValue(self, optionName, level):
3321 # Parameter of BLSURF algo
3322 self.Parameters().SetOptionValue(optionName,level)
3324 ## Sets QuadAllowed flag.
3325 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3326 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3327 def SetQuadAllowed(self, toAllow=True):
3328 if self.algoType == NETGEN_2D:
3329 if toAllow: # add QuadranglePreference
3330 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3331 else: # remove QuadranglePreference
3332 for hyp in self.mesh.GetHypothesisList( self.geom ):
3333 if hyp.GetName() == "QuadranglePreference":
3334 self.mesh.RemoveHypothesis( self.geom, hyp )
3339 if self.Parameters():
3340 self.params.SetQuadAllowed(toAllow)
3343 ## Defines hypothesis having several parameters
3345 # @ingroup l3_hypos_netgen
3346 def Parameters(self, which=SOLE):
3349 if self.algoType == NETGEN:
3351 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3352 "libNETGENEngine.so", UseExisting=0)
3354 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3355 "libNETGENEngine.so", UseExisting=0)
3357 elif self.algoType == MEFISTO:
3358 print "Mefisto algo support no multi-parameter hypothesis"
3360 elif self.algoType == NETGEN_2D:
3361 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3362 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3364 elif self.algoType == BLSURF:
3365 self.params = self.Hypothesis("BLSURF_Parameters", [],
3366 "libBLSURFEngine.so", UseExisting=0)
3369 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3374 # Only for algoType == NETGEN
3375 # @ingroup l3_hypos_netgen
3376 def SetMaxSize(self, theSize):
3377 if self.Parameters():
3378 self.params.SetMaxSize(theSize)
3380 ## Sets SecondOrder flag
3382 # Only for algoType == NETGEN
3383 # @ingroup l3_hypos_netgen
3384 def SetSecondOrder(self, theVal):
3385 if self.Parameters():
3386 self.params.SetSecondOrder(theVal)
3388 ## Sets Optimize flag
3390 # Only for algoType == NETGEN
3391 # @ingroup l3_hypos_netgen
3392 def SetOptimize(self, theVal):
3393 if self.Parameters():
3394 self.params.SetOptimize(theVal)
3397 # @param theFineness is:
3398 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3400 # Only for algoType == NETGEN
3401 # @ingroup l3_hypos_netgen
3402 def SetFineness(self, theFineness):
3403 if self.Parameters():
3404 self.params.SetFineness(theFineness)
3408 # Only for algoType == NETGEN
3409 # @ingroup l3_hypos_netgen
3410 def SetGrowthRate(self, theRate):
3411 if self.Parameters():
3412 self.params.SetGrowthRate(theRate)
3414 ## Sets NbSegPerEdge
3416 # Only for algoType == NETGEN
3417 # @ingroup l3_hypos_netgen
3418 def SetNbSegPerEdge(self, theVal):
3419 if self.Parameters():
3420 self.params.SetNbSegPerEdge(theVal)
3422 ## Sets NbSegPerRadius
3424 # Only for algoType == NETGEN
3425 # @ingroup l3_hypos_netgen
3426 def SetNbSegPerRadius(self, theVal):
3427 if self.Parameters():
3428 self.params.SetNbSegPerRadius(theVal)
3430 ## Sets number of segments overriding value set by SetLocalLength()
3432 # Only for algoType == NETGEN
3433 # @ingroup l3_hypos_netgen
3434 def SetNumberOfSegments(self, theVal):
3435 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3437 ## Sets number of segments overriding value set by SetNumberOfSegments()
3439 # Only for algoType == NETGEN
3440 # @ingroup l3_hypos_netgen
3441 def SetLocalLength(self, theVal):
3442 self.Parameters(SIMPLE).SetLocalLength(theVal)
3447 # Public class: Mesh_Quadrangle
3448 # -----------------------------
3450 ## Defines a quadrangle 2D algorithm
3452 # @ingroup l3_algos_basic
3453 class Mesh_Quadrangle(Mesh_Algorithm):
3455 ## Private constructor.
3456 def __init__(self, mesh, geom=0):
3457 Mesh_Algorithm.__init__(self)
3458 self.Create(mesh, geom, "Quadrangle_2D")
3460 ## Defines "QuadranglePreference" hypothesis, forcing construction
3461 # of quadrangles if the number of nodes on the opposite edges is not the same
3462 # while the total number of nodes on edges is even
3464 # @ingroup l3_hypos_additi
3465 def QuadranglePreference(self):
3466 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3467 CompareMethod=self.CompareEqualHyp)
3470 ## Defines "TrianglePreference" hypothesis, forcing construction
3471 # of triangles in the refinement area if the number of nodes
3472 # on the opposite edges is not the same
3474 # @ingroup l3_hypos_additi
3475 def TrianglePreference(self):
3476 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3477 CompareMethod=self.CompareEqualHyp)
3480 # Public class: Mesh_Tetrahedron
3481 # ------------------------------
3483 ## Defines a tetrahedron 3D algorithm
3485 # @ingroup l3_algos_basic
3486 class Mesh_Tetrahedron(Mesh_Algorithm):
3491 ## Private constructor.
3492 def __init__(self, mesh, algoType, geom=0):
3493 Mesh_Algorithm.__init__(self)
3495 if algoType == NETGEN:
3496 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3499 elif algoType == FULL_NETGEN:
3501 print "Warning: NETGENPlugin module has not been imported."
3502 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3505 elif algoType == GHS3D:
3507 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3510 self.algoType = algoType
3512 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3513 # @param vol for the maximum volume of each tetrahedron
3514 # @param UseExisting if ==true - searches for the existing hypothesis created with
3515 # the same parameters, else (default) - creates a new one
3516 # @ingroup l3_hypos_maxvol
3517 def MaxElementVolume(self, vol, UseExisting=0):
3518 if self.algoType == NETGEN:
3519 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3520 CompareMethod=self.CompareMaxElementVolume)
3521 hyp.SetMaxElementVolume(vol)
3523 elif self.algoType == FULL_NETGEN:
3524 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3527 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3528 def CompareMaxElementVolume(self, hyp, args):
3529 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3531 ## Defines hypothesis having several parameters
3533 # @ingroup l3_hypos_netgen
3534 def Parameters(self, which=SOLE):
3537 if self.algoType == FULL_NETGEN:
3539 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3540 "libNETGENEngine.so", UseExisting=0)
3542 self.params = self.Hypothesis("NETGEN_Parameters", [],
3543 "libNETGENEngine.so", UseExisting=0)
3545 if self.algoType == GHS3D:
3546 self.params = self.Hypothesis("GHS3D_Parameters", [],
3547 "libGHS3DEngine.so", UseExisting=0)
3550 print "Algo supports no multi-parameter hypothesis"
3554 # Parameter of FULL_NETGEN
3555 # @ingroup l3_hypos_netgen
3556 def SetMaxSize(self, theSize):
3557 self.Parameters().SetMaxSize(theSize)
3559 ## Sets SecondOrder flag
3560 # Parameter of FULL_NETGEN
3561 # @ingroup l3_hypos_netgen
3562 def SetSecondOrder(self, theVal):
3563 self.Parameters().SetSecondOrder(theVal)
3565 ## Sets Optimize flag
3566 # Parameter of FULL_NETGEN
3567 # @ingroup l3_hypos_netgen
3568 def SetOptimize(self, theVal):
3569 self.Parameters().SetOptimize(theVal)
3572 # @param theFineness is:
3573 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3574 # Parameter of FULL_NETGEN
3575 # @ingroup l3_hypos_netgen
3576 def SetFineness(self, theFineness):
3577 self.Parameters().SetFineness(theFineness)
3580 # Parameter of FULL_NETGEN
3581 # @ingroup l3_hypos_netgen
3582 def SetGrowthRate(self, theRate):
3583 self.Parameters().SetGrowthRate(theRate)
3585 ## Sets NbSegPerEdge
3586 # Parameter of FULL_NETGEN
3587 # @ingroup l3_hypos_netgen
3588 def SetNbSegPerEdge(self, theVal):
3589 self.Parameters().SetNbSegPerEdge(theVal)
3591 ## Sets NbSegPerRadius
3592 # Parameter of FULL_NETGEN
3593 # @ingroup l3_hypos_netgen
3594 def SetNbSegPerRadius(self, theVal):
3595 self.Parameters().SetNbSegPerRadius(theVal)
3597 ## Sets number of segments overriding value set by SetLocalLength()
3598 # Only for algoType == NETGEN_FULL
3599 # @ingroup l3_hypos_netgen
3600 def SetNumberOfSegments(self, theVal):
3601 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3603 ## Sets number of segments overriding value set by SetNumberOfSegments()
3604 # Only for algoType == NETGEN_FULL
3605 # @ingroup l3_hypos_netgen
3606 def SetLocalLength(self, theVal):
3607 self.Parameters(SIMPLE).SetLocalLength(theVal)
3609 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3610 # Overrides value set by LengthFromEdges()
3611 # Only for algoType == NETGEN_FULL
3612 # @ingroup l3_hypos_netgen
3613 def MaxElementArea(self, area):
3614 self.Parameters(SIMPLE).SetMaxElementArea(area)
3616 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3617 # Overrides value set by MaxElementArea()
3618 # Only for algoType == NETGEN_FULL
3619 # @ingroup l3_hypos_netgen
3620 def LengthFromEdges(self):
3621 self.Parameters(SIMPLE).LengthFromEdges()
3623 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3624 # Overrides value set by MaxElementVolume()
3625 # Only for algoType == NETGEN_FULL
3626 # @ingroup l3_hypos_netgen
3627 def LengthFromFaces(self):
3628 self.Parameters(SIMPLE).LengthFromFaces()
3630 ## To mesh "holes" in a solid or not. Default is to mesh.
3631 # @ingroup l3_hypos_ghs3dh
3632 def SetToMeshHoles(self, toMesh):
3633 # Parameter of GHS3D
3634 self.Parameters().SetToMeshHoles(toMesh)
3636 ## Set Optimization level:
3637 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3638 # Default is Medium_Optimization
3639 # @ingroup l3_hypos_ghs3dh
3640 def SetOptimizationLevel(self, level):
3641 # Parameter of GHS3D
3642 self.Parameters().SetOptimizationLevel(level)
3644 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3645 # @ingroup l3_hypos_ghs3dh
3646 def SetMaximumMemory(self, MB):
3647 # Advanced parameter of GHS3D
3648 self.Parameters().SetMaximumMemory(MB)
3650 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3651 # automatic memory adjustment mode.
3652 # @ingroup l3_hypos_ghs3dh
3653 def SetInitialMemory(self, MB):
3654 # Advanced parameter of GHS3D
3655 self.Parameters().SetInitialMemory(MB)
3657 ## Path to working directory.
3658 # @ingroup l3_hypos_ghs3dh
3659 def SetWorkingDirectory(self, path):
3660 # Advanced parameter of GHS3D
3661 self.Parameters().SetWorkingDirectory(path)
3663 ## To keep working files or remove them. Log file remains in case of errors anyway.
3664 # @ingroup l3_hypos_ghs3dh
3665 def SetKeepFiles(self, toKeep):
3666 # Advanced parameter of GHS3D
3667 self.Parameters().SetKeepFiles(toKeep)
3669 ## To set verbose level [0-10]. <ul>
3670 #<li> 0 - no standard output,
3671 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3672 # indicates when the final mesh is being saved. In addition the software
3673 # gives indication regarding the CPU time.
3674 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3675 # histogram of the skin mesh, quality statistics histogram together with
3676 # the characteristics of the final mesh.</ul>
3677 # @ingroup l3_hypos_ghs3dh
3678 def SetVerboseLevel(self, level):
3679 # Advanced parameter of GHS3D
3680 self.Parameters().SetVerboseLevel(level)
3682 ## To create new nodes.
3683 # @ingroup l3_hypos_ghs3dh
3684 def SetToCreateNewNodes(self, toCreate):
3685 # Advanced parameter of GHS3D
3686 self.Parameters().SetToCreateNewNodes(toCreate)
3688 ## To use boundary recovery version which tries to create mesh on a very poor
3689 # quality surface mesh.
3690 # @ingroup l3_hypos_ghs3dh
3691 def SetToUseBoundaryRecoveryVersion(self, toUse):
3692 # Advanced parameter of GHS3D
3693 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3695 ## Sets command line option as text.
3696 # @ingroup l3_hypos_ghs3dh
3697 def SetTextOption(self, option):
3698 # Advanced parameter of GHS3D
3699 self.Parameters().SetTextOption(option)
3701 # Public class: Mesh_Hexahedron
3702 # ------------------------------
3704 ## Defines a hexahedron 3D algorithm
3706 # @ingroup l3_algos_basic
3707 class Mesh_Hexahedron(Mesh_Algorithm):
3712 ## Private constructor.
3713 def __init__(self, mesh, algoType=Hexa, geom=0):
3714 Mesh_Algorithm.__init__(self)
3716 self.algoType = algoType
3718 if algoType == Hexa:
3719 self.Create(mesh, geom, "Hexa_3D")
3722 elif algoType == Hexotic:
3723 import HexoticPlugin
3724 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3727 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3728 # @ingroup l3_hypos_hexotic
3729 def MinMaxQuad(self, min=3, max=8, quad=True):
3730 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3732 self.params.SetHexesMinLevel(min)
3733 self.params.SetHexesMaxLevel(max)
3734 self.params.SetHexoticQuadrangles(quad)
3737 # Deprecated, only for compatibility!
3738 # Public class: Mesh_Netgen
3739 # ------------------------------
3741 ## Defines a NETGEN-based 2D or 3D algorithm
3742 # that needs no discrete boundary (i.e. independent)
3744 # This class is deprecated, only for compatibility!
3747 # @ingroup l3_algos_basic
3748 class Mesh_Netgen(Mesh_Algorithm):
3752 ## Private constructor.
3753 def __init__(self, mesh, is3D, geom=0):
3754 Mesh_Algorithm.__init__(self)
3757 print "Warning: NETGENPlugin module has not been imported."
3761 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3765 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3768 ## Defines the hypothesis containing parameters of the algorithm
3769 def Parameters(self):
3771 hyp = self.Hypothesis("NETGEN_Parameters", [],
3772 "libNETGENEngine.so", UseExisting=0)
3774 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3775 "libNETGENEngine.so", UseExisting=0)
3778 # Public class: Mesh_Projection1D
3779 # ------------------------------
3781 ## Defines a projection 1D algorithm
3782 # @ingroup l3_algos_proj
3784 class Mesh_Projection1D(Mesh_Algorithm):
3786 ## Private constructor.
3787 def __init__(self, mesh, geom=0):
3788 Mesh_Algorithm.__init__(self)
3789 self.Create(mesh, geom, "Projection_1D")
3791 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3792 # a mesh pattern is taken, and, optionally, the association of vertices
3793 # between the source edge and a target edge (to which a hypothesis is assigned)
3794 # @param edge from which nodes distribution is taken
3795 # @param mesh from which nodes distribution is taken (optional)
3796 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3797 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3798 # to associate with \a srcV (optional)
3799 # @param UseExisting if ==true - searches for the existing hypothesis created with
3800 # the same parameters, else (default) - creates a new one
3801 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3802 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3804 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3805 hyp.SetSourceEdge( edge )
3806 if not mesh is None and isinstance(mesh, Mesh):
3807 mesh = mesh.GetMesh()
3808 hyp.SetSourceMesh( mesh )
3809 hyp.SetVertexAssociation( srcV, tgtV )
3812 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3813 #def CompareSourceEdge(self, hyp, args):
3814 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3818 # Public class: Mesh_Projection2D
3819 # ------------------------------
3821 ## Defines a projection 2D algorithm
3822 # @ingroup l3_algos_proj
3824 class Mesh_Projection2D(Mesh_Algorithm):
3826 ## Private constructor.
3827 def __init__(self, mesh, geom=0):
3828 Mesh_Algorithm.__init__(self)
3829 self.Create(mesh, geom, "Projection_2D")
3831 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3832 # a mesh pattern is taken, and, optionally, the association of vertices
3833 # between the source face and the target face (to which a hypothesis is assigned)
3834 # @param face from which the mesh pattern is taken
3835 # @param mesh from which the mesh pattern is taken (optional)
3836 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3837 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3838 # to associate with \a srcV1 (optional)
3839 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3840 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3841 # to associate with \a srcV2 (optional)
3842 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3843 # the same parameters, else (default) - forces the creation a new one
3845 # Note: all association vertices must belong to one edge of a face
3846 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3847 srcV2=None, tgtV2=None, UseExisting=0):
3848 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3850 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3851 hyp.SetSourceFace( face )
3852 if not mesh is None and isinstance(mesh, Mesh):
3853 mesh = mesh.GetMesh()
3854 hyp.SetSourceMesh( mesh )
3855 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3858 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3859 #def CompareSourceFace(self, hyp, args):
3860 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3863 # Public class: Mesh_Projection3D
3864 # ------------------------------
3866 ## Defines a projection 3D algorithm
3867 # @ingroup l3_algos_proj
3869 class Mesh_Projection3D(Mesh_Algorithm):
3871 ## Private constructor.
3872 def __init__(self, mesh, geom=0):
3873 Mesh_Algorithm.__init__(self)
3874 self.Create(mesh, geom, "Projection_3D")
3876 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3877 # the mesh pattern is taken, and, optionally, the association of vertices
3878 # between the source and the target solid (to which a hipothesis is assigned)
3879 # @param solid from where the mesh pattern is taken
3880 # @param mesh from where the mesh pattern is taken (optional)
3881 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3882 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3883 # to associate with \a srcV1 (optional)
3884 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3885 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3886 # to associate with \a srcV2 (optional)
3887 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3888 # the same parameters, else (default) - creates a new one
3890 # Note: association vertices must belong to one edge of a solid
3891 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3892 srcV2=0, tgtV2=0, UseExisting=0):
3893 hyp = self.Hypothesis("ProjectionSource3D",
3894 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3896 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3897 hyp.SetSource3DShape( solid )
3898 if not mesh is None and isinstance(mesh, Mesh):
3899 mesh = mesh.GetMesh()
3900 hyp.SetSourceMesh( mesh )
3901 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3904 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3905 #def CompareSourceShape3D(self, hyp, args):
3906 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3910 # Public class: Mesh_Prism
3911 # ------------------------
3913 ## Defines a 3D extrusion algorithm
3914 # @ingroup l3_algos_3dextr
3916 class Mesh_Prism3D(Mesh_Algorithm):
3918 ## Private constructor.
3919 def __init__(self, mesh, geom=0):
3920 Mesh_Algorithm.__init__(self)
3921 self.Create(mesh, geom, "Prism_3D")
3923 # Public class: Mesh_RadialPrism
3924 # -------------------------------
3926 ## Defines a Radial Prism 3D algorithm
3927 # @ingroup l3_algos_radialp
3929 class Mesh_RadialPrism3D(Mesh_Algorithm):
3931 ## Private constructor.
3932 def __init__(self, mesh, geom=0):
3933 Mesh_Algorithm.__init__(self)
3934 self.Create(mesh, geom, "RadialPrism_3D")
3936 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3937 self.nbLayers = None
3939 ## Return 3D hypothesis holding the 1D one
3940 def Get3DHypothesis(self):
3941 return self.distribHyp
3943 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3944 # hypothesis. Returns the created hypothesis
3945 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3946 #print "OwnHypothesis",hypType
3947 if not self.nbLayers is None:
3948 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3949 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3950 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3951 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3952 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3953 self.distribHyp.SetLayerDistribution( hyp )
3956 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3957 # prisms to build between the inner and outer shells
3958 # @param n number of layers
3959 # @param UseExisting if ==true - searches for the existing hypothesis created with
3960 # the same parameters, else (default) - creates a new one
3961 def NumberOfLayers(self, n, UseExisting=0):
3962 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3963 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3964 CompareMethod=self.CompareNumberOfLayers)
3965 self.nbLayers.SetNumberOfLayers( n )
3966 return self.nbLayers
3968 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3969 def CompareNumberOfLayers(self, hyp, args):
3970 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3972 ## Defines "LocalLength" hypothesis, specifying the segment length
3973 # to build between the inner and the outer shells
3974 # @param l the length of segments
3975 # @param p the precision of rounding
3976 def LocalLength(self, l, p=1e-07):
3977 hyp = self.OwnHypothesis("LocalLength", [l,p])
3982 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3983 # prisms to build between the inner and the outer shells.
3984 # @param n the number of layers
3985 # @param s the scale factor (optional)
3986 def NumberOfSegments(self, n, s=[]):
3988 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3990 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3991 hyp.SetDistrType( 1 )
3992 hyp.SetScaleFactor(s)
3993 hyp.SetNumberOfSegments(n)
3996 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3997 # to build between the inner and the outer shells with a length that changes in arithmetic progression
3998 # @param start the length of the first segment
3999 # @param end the length of the last segment
4000 def Arithmetic1D(self, start, end ):
4001 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4002 hyp.SetLength(start, 1)
4003 hyp.SetLength(end , 0)
4006 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4007 # to build between the inner and the outer shells as geometric length increasing
4008 # @param start for the length of the first segment
4009 # @param end for the length of the last segment
4010 def StartEndLength(self, start, end):
4011 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4012 hyp.SetLength(start, 1)
4013 hyp.SetLength(end , 0)
4016 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4017 # to build between the inner and outer shells
4018 # @param fineness defines the quality of the mesh within the range [0-1]
4019 def AutomaticLength(self, fineness=0):
4020 hyp = self.OwnHypothesis("AutomaticLength")
4021 hyp.SetFineness( fineness )
4024 # Private class: Mesh_UseExisting
4025 # -------------------------------
4026 class Mesh_UseExisting(Mesh_Algorithm):
4028 def __init__(self, dim, mesh, geom=0):
4030 self.Create(mesh, geom, "UseExisting_1D")
4032 self.Create(mesh, geom, "UseExisting_2D")