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 if isinstance(obj, BaseWrapper):
168 obj = obj.GetAlgorithm()
169 ior = salome.orb.object_to_string(obj)
170 sobj = salome.myStudy.FindObjectIOR(ior)
174 attr = sobj.FindAttribute("AttributeName")[1]
177 ## Sets a name to the object
178 def SetName(obj, name):
179 if isinstance(obj, BaseWrapper):
180 obj = obj.GetAlgorithm()
181 ior = salome.orb.object_to_string(obj)
182 sobj = salome.myStudy.FindObjectIOR(ior)
184 attr = sobj.FindAttribute("AttributeName")[1]
187 ## Prints error message if a hypothesis was not assigned.
188 def TreatHypoStatus(status, hypName, geomName, isAlgo):
190 hypType = "algorithm"
192 hypType = "hypothesis"
194 if status == HYP_UNKNOWN_FATAL :
195 reason = "for unknown reason"
196 elif status == HYP_INCOMPATIBLE :
197 reason = "this hypothesis mismatches the algorithm"
198 elif status == HYP_NOTCONFORM :
199 reason = "a non-conform mesh would be built"
200 elif status == HYP_ALREADY_EXIST :
201 reason = hypType + " of the same dimension is already assigned to this shape"
202 elif status == HYP_BAD_DIM :
203 reason = hypType + " mismatches the shape"
204 elif status == HYP_CONCURENT :
205 reason = "there are concurrent hypotheses on sub-shapes"
206 elif status == HYP_BAD_SUBSHAPE :
207 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
208 elif status == HYP_BAD_GEOMETRY:
209 reason = "geometry mismatches the expectation of the algorithm"
210 elif status == HYP_HIDDEN_ALGO:
211 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
212 elif status == HYP_HIDING_ALGO:
213 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
214 elif status == HYP_NEED_SHAPE:
215 reason = "Algorithm can't work without shape"
218 hypName = '"' + hypName + '"'
219 geomName= '"' + geomName+ '"'
220 if status < HYP_UNKNOWN_FATAL:
221 print hypName, "was assigned to", geomName,"but", reason
223 print hypName, "was not assigned to",geomName,":", reason
226 ## Converts an angle from degrees to radians
227 def DegreesToRadians(AngleInDegrees):
229 return AngleInDegrees * pi / 180.0
231 # end of l1_auxiliary
234 # All methods of this class are accessible directly from the smesh.py package.
235 class smeshDC(SMESH._objref_SMESH_Gen):
237 ## Sets the current study and Geometry component
238 # @ingroup l1_auxiliary
239 def init_smesh(self,theStudy,geompyD):
241 self.SetGeomEngine(geompyD)
242 self.SetCurrentStudy(theStudy)
244 ## Creates an empty Mesh. This mesh can have an underlying geometry.
245 # @param obj the Geometrical object on which the mesh is built. If not defined,
246 # the mesh will have no underlying geometry.
247 # @param name the name for the new mesh.
248 # @return an instance of Mesh class.
249 # @ingroup l2_construct
250 def Mesh(self, obj=0, name=0):
251 return Mesh(self,self.geompyD,obj,name)
253 ## Returns a long value from enumeration
254 # Should be used for SMESH.FunctorType enumeration
255 # @ingroup l1_controls
256 def EnumToLong(self,theItem):
259 ## Gets PointStruct from vertex
260 # @param theVertex a GEOM object(vertex)
261 # @return SMESH.PointStruct
262 # @ingroup l1_auxiliary
263 def GetPointStruct(self,theVertex):
264 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
265 return PointStruct(x,y,z)
267 ## Gets DirStruct from vector
268 # @param theVector a GEOM object(vector)
269 # @return SMESH.DirStruct
270 # @ingroup l1_auxiliary
271 def GetDirStruct(self,theVector):
272 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
273 if(len(vertices) != 2):
274 print "Error: vector object is incorrect."
276 p1 = self.geompyD.PointCoordinates(vertices[0])
277 p2 = self.geompyD.PointCoordinates(vertices[1])
278 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
279 dirst = DirStruct(pnt)
282 ## Makes DirStruct from a triplet
283 # @param x,y,z vector components
284 # @return SMESH.DirStruct
285 # @ingroup l1_auxiliary
286 def MakeDirStruct(self,x,y,z):
287 pnt = PointStruct(x,y,z)
288 return DirStruct(pnt)
290 ## Get AxisStruct from object
291 # @param theObj a GEOM object (line or plane)
292 # @return SMESH.AxisStruct
293 # @ingroup l1_auxiliary
294 def GetAxisStruct(self,theObj):
295 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
297 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
298 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
299 vertex1 = self.geompyD.PointCoordinates(vertex1)
300 vertex2 = self.geompyD.PointCoordinates(vertex2)
301 vertex3 = self.geompyD.PointCoordinates(vertex3)
302 vertex4 = self.geompyD.PointCoordinates(vertex4)
303 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
304 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
305 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] ]
306 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
308 elif len(edges) == 1:
309 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
310 p1 = self.geompyD.PointCoordinates( vertex1 )
311 p2 = self.geompyD.PointCoordinates( vertex2 )
312 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
316 # From SMESH_Gen interface:
317 # ------------------------
319 ## Sets the current mode
320 # @ingroup l1_auxiliary
321 def SetEmbeddedMode( self,theMode ):
322 #self.SetEmbeddedMode(theMode)
323 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
325 ## Gets the current mode
326 # @ingroup l1_auxiliary
327 def IsEmbeddedMode(self):
328 #return self.IsEmbeddedMode()
329 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
331 ## Sets the current study
332 # @ingroup l1_auxiliary
333 def SetCurrentStudy( self, theStudy ):
334 #self.SetCurrentStudy(theStudy)
335 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
337 ## Gets the current study
338 # @ingroup l1_auxiliary
339 def GetCurrentStudy(self):
340 #return self.GetCurrentStudy()
341 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
343 ## Creates a Mesh object importing data from the given UNV file
344 # @return an instance of Mesh class
346 def CreateMeshesFromUNV( self,theFileName ):
347 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
348 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
351 ## Create hyporthesis
352 # @return an instance of hypothesis
354 def CreateHypothesis(self, hyp, so):
355 hypo = SMESH._objref_SMESH_Gen.CreateHypothesis(self, hyp, so)
356 if hyp == "LocalLength":
357 hypo = LocalLength(hypo)
362 ## Creates a Mesh object(s) importing data from the given MED file
363 # @return a list of Mesh class instances
365 def CreateMeshesFromMED( self,theFileName ):
366 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
368 for iMesh in range(len(aSmeshMeshes)) :
369 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
370 aMeshes.append(aMesh)
371 return aMeshes, aStatus
373 ## Creates a Mesh object importing data from the given STL file
374 # @return an instance of Mesh class
376 def CreateMeshesFromSTL( self, theFileName ):
377 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
378 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
381 ## From SMESH_Gen interface
382 # @return the list of integer values
383 # @ingroup l1_auxiliary
384 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
385 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
387 ## From SMESH_Gen interface. Creates a pattern
388 # @return an instance of SMESH_Pattern
390 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
391 # @ingroup l2_modif_patterns
392 def GetPattern(self):
393 return SMESH._objref_SMESH_Gen.GetPattern(self)
396 # Filtering. Auxiliary functions:
397 # ------------------------------
399 ## Creates an empty criterion
400 # @return SMESH.Filter.Criterion
401 # @ingroup l1_controls
402 def GetEmptyCriterion(self):
403 Type = self.EnumToLong(FT_Undefined)
404 Compare = self.EnumToLong(FT_Undefined)
408 UnaryOp = self.EnumToLong(FT_Undefined)
409 BinaryOp = self.EnumToLong(FT_Undefined)
412 Precision = -1 ##@1e-07
413 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
414 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
416 ## Creates a criterion by the given parameters
417 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
418 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
419 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
420 # @param Treshold the threshold value (range of ids as string, shape, numeric)
421 # @param UnaryOp FT_LogicalNOT or FT_Undefined
422 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
423 # FT_Undefined (must be for the last criterion of all criteria)
424 # @return SMESH.Filter.Criterion
425 # @ingroup l1_controls
426 def GetCriterion(self,elementType,
428 Compare = FT_EqualTo,
430 UnaryOp=FT_Undefined,
431 BinaryOp=FT_Undefined):
432 aCriterion = self.GetEmptyCriterion()
433 aCriterion.TypeOfElement = elementType
434 aCriterion.Type = self.EnumToLong(CritType)
438 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
439 aCriterion.Compare = self.EnumToLong(Compare)
440 elif Compare == "=" or Compare == "==":
441 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
443 aCriterion.Compare = self.EnumToLong(FT_LessThan)
445 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
447 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
450 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
451 FT_BelongToCylinder, FT_LyingOnGeom]:
452 # Checks the treshold
453 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
454 aCriterion.ThresholdStr = GetName(aTreshold)
455 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
457 print "Error: The treshold should be a shape."
459 elif CritType == FT_RangeOfIds:
460 # Checks the treshold
461 if isinstance(aTreshold, str):
462 aCriterion.ThresholdStr = aTreshold
464 print "Error: The treshold should be a string."
466 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
467 # At this point the treshold is unnecessary
468 if aTreshold == FT_LogicalNOT:
469 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
470 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
471 aCriterion.BinaryOp = aTreshold
475 aTreshold = float(aTreshold)
476 aCriterion.Threshold = aTreshold
478 print "Error: The treshold should be a number."
481 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
482 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
484 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
485 aCriterion.BinaryOp = self.EnumToLong(Treshold)
487 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
488 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
490 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
491 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
495 ## Creates a filter with the given parameters
496 # @param elementType the type of elements in the group
497 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
498 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
499 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
500 # @param UnaryOp FT_LogicalNOT or FT_Undefined
501 # @return SMESH_Filter
502 # @ingroup l1_controls
503 def GetFilter(self,elementType,
504 CritType=FT_Undefined,
507 UnaryOp=FT_Undefined):
508 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
509 aFilterMgr = self.CreateFilterManager()
510 aFilter = aFilterMgr.CreateFilter()
512 aCriteria.append(aCriterion)
513 aFilter.SetCriteria(aCriteria)
516 ## Creates a numerical functor by its type
517 # @param theCriterion FT_...; functor type
518 # @return SMESH_NumericalFunctor
519 # @ingroup l1_controls
520 def GetFunctor(self,theCriterion):
521 aFilterMgr = self.CreateFilterManager()
522 if theCriterion == FT_AspectRatio:
523 return aFilterMgr.CreateAspectRatio()
524 elif theCriterion == FT_AspectRatio3D:
525 return aFilterMgr.CreateAspectRatio3D()
526 elif theCriterion == FT_Warping:
527 return aFilterMgr.CreateWarping()
528 elif theCriterion == FT_MinimumAngle:
529 return aFilterMgr.CreateMinimumAngle()
530 elif theCriterion == FT_Taper:
531 return aFilterMgr.CreateTaper()
532 elif theCriterion == FT_Skew:
533 return aFilterMgr.CreateSkew()
534 elif theCriterion == FT_Area:
535 return aFilterMgr.CreateArea()
536 elif theCriterion == FT_Volume3D:
537 return aFilterMgr.CreateVolume3D()
538 elif theCriterion == FT_MultiConnection:
539 return aFilterMgr.CreateMultiConnection()
540 elif theCriterion == FT_MultiConnection2D:
541 return aFilterMgr.CreateMultiConnection2D()
542 elif theCriterion == FT_Length:
543 return aFilterMgr.CreateLength()
544 elif theCriterion == FT_Length2D:
545 return aFilterMgr.CreateLength2D()
547 print "Error: given parameter is not numerucal functor type."
551 #Registering the new proxy for SMESH_Gen
552 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
558 ## This class allows defining and managing a mesh.
559 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
560 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
561 # new nodes and elements and by changing the existing entities), to get information
562 # about a mesh and to export a mesh into different formats.
571 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
572 # sets the GUI name of this mesh to \a name.
573 # @param smeshpyD an instance of smeshDC class
574 # @param geompyD an instance of geompyDC class
575 # @param obj Shape to be meshed or SMESH_Mesh object
576 # @param name Study name of the mesh
577 # @ingroup l2_construct
578 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
579 self.smeshpyD=smeshpyD
584 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
586 self.mesh = self.smeshpyD.CreateMesh(self.geom)
587 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
590 self.mesh = self.smeshpyD.CreateEmptyMesh()
592 SetName(self.mesh, name)
594 SetName(self.mesh, GetName(obj))
597 self.geom = self.mesh.GetShapeToMesh()
599 self.editor = self.mesh.GetMeshEditor()
601 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
602 # @param theMesh a SMESH_Mesh object
603 # @ingroup l2_construct
604 def SetMesh(self, theMesh):
606 self.geom = self.mesh.GetShapeToMesh()
608 ## Returns the mesh, that is an instance of SMESH_Mesh interface
609 # @return a SMESH_Mesh object
610 # @ingroup l2_construct
614 ## Gets the name of the mesh
615 # @return the name of the mesh as a string
616 # @ingroup l2_construct
618 name = GetName(self.GetMesh())
621 ## Sets a name to the mesh
622 # @param name a new name of the mesh
623 # @ingroup l2_construct
624 def SetName(self, name):
625 SetName(self.GetMesh(), name)
627 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
628 # The subMesh object gives access to the IDs of nodes and elements.
629 # @param theSubObject a geometrical object (shape)
630 # @param theName a name for the submesh
631 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
632 # @ingroup l2_submeshes
633 def GetSubMesh(self, theSubObject, theName):
634 submesh = self.mesh.GetSubMesh(theSubObject, theName)
637 ## Returns the shape associated to the mesh
638 # @return a GEOM_Object
639 # @ingroup l2_construct
643 ## Associates the given shape to the mesh (entails the recreation of the mesh)
644 # @param geom the shape to be meshed (GEOM_Object)
645 # @ingroup l2_construct
646 def SetShape(self, geom):
647 self.mesh = self.smeshpyD.CreateMesh(geom)
649 ## Returns true if the hypotheses are defined well
650 # @param theSubObject a subshape of a mesh shape
651 # @return True or False
652 # @ingroup l2_construct
653 def IsReadyToCompute(self, theSubObject):
654 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
656 ## Returns errors of hypotheses definition.
657 # The list of errors is empty if everything is OK.
658 # @param theSubObject a subshape of a mesh shape
659 # @return a list of errors
660 # @ingroup l2_construct
661 def GetAlgoState(self, theSubObject):
662 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
664 ## Returns a geometrical object on which the given element was built.
665 # The returned geometrical object, if not nil, is either found in the
666 # study or published by this method with the given name
667 # @param theElementID the id of the mesh element
668 # @param theGeomName the user-defined name of the geometrical object
669 # @return GEOM::GEOM_Object instance
670 # @ingroup l2_construct
671 def GetGeometryByMeshElement(self, theElementID, theGeomName):
672 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
674 ## Returns the mesh dimension depending on the dimension of the underlying shape
675 # @return mesh dimension as an integer value [0,3]
676 # @ingroup l1_auxiliary
677 def MeshDimension(self):
678 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
679 if len( shells ) > 0 :
681 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
683 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
689 ## Creates a segment discretization 1D algorithm.
690 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
691 # \n If the optional \a geom parameter is not set, this algorithm is global.
692 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
693 # @param algo the type of the required algorithm. Possible values are:
695 # - smesh.PYTHON for discretization via a python function,
696 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
697 # @param geom If defined is the subshape to be meshed
698 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
699 # @ingroup l3_algos_basic
700 def Segment(self, algo=REGULAR, geom=0):
701 ## if Segment(geom) is called by mistake
702 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
703 algo, geom = geom, algo
704 if not algo: algo = REGULAR
707 return Mesh_Segment(self, geom)
709 return Mesh_Segment_Python(self, geom)
710 elif algo == COMPOSITE:
711 return Mesh_CompositeSegment(self, geom)
713 return Mesh_Segment(self, geom)
715 ## Enables creation of nodes and segments usable by 2D algoritms.
716 # The added nodes and segments must be bound to edges and vertices by
717 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
718 # If the optional \a geom parameter is not set, this algorithm is global.
719 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
720 # @param geom the subshape to be manually meshed
721 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
722 # @ingroup l3_algos_basic
723 def UseExistingSegments(self, geom=0):
724 algo = Mesh_UseExisting(1,self,geom)
725 return algo.GetAlgorithm()
727 ## Enables creation of nodes and faces usable by 3D algoritms.
728 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
729 # and SetMeshElementOnShape()
730 # If the optional \a geom parameter is not set, this algorithm is global.
731 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
732 # @param geom the subshape to be manually meshed
733 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
734 # @ingroup l3_algos_basic
735 def UseExistingFaces(self, geom=0):
736 algo = Mesh_UseExisting(2,self,geom)
737 return algo.GetAlgorithm()
739 ## Creates a triangle 2D algorithm for faces.
740 # If the optional \a geom parameter is not set, this algorithm is global.
741 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
742 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
743 # @param geom If defined, the subshape to be meshed (GEOM_Object)
744 # @return an instance of Mesh_Triangle algorithm
745 # @ingroup l3_algos_basic
746 def Triangle(self, algo=MEFISTO, geom=0):
747 ## if Triangle(geom) is called by mistake
748 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
752 return Mesh_Triangle(self, algo, geom)
754 ## Creates a quadrangle 2D algorithm for faces.
755 # If the optional \a geom parameter is not set, this algorithm is global.
756 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
757 # @param geom If defined, the subshape to be meshed (GEOM_Object)
758 # @return an instance of Mesh_Quadrangle algorithm
759 # @ingroup l3_algos_basic
760 def Quadrangle(self, geom=0):
761 return Mesh_Quadrangle(self, geom)
763 ## Creates a tetrahedron 3D algorithm for solids.
764 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
765 # If the optional \a geom parameter is not set, this algorithm is global.
766 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
767 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
768 # @param geom If defined, the subshape to be meshed (GEOM_Object)
769 # @return an instance of Mesh_Tetrahedron algorithm
770 # @ingroup l3_algos_basic
771 def Tetrahedron(self, algo=NETGEN, geom=0):
772 ## if Tetrahedron(geom) is called by mistake
773 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
774 algo, geom = geom, algo
775 if not algo: algo = NETGEN
777 return Mesh_Tetrahedron(self, algo, geom)
779 ## Creates a hexahedron 3D algorithm for solids.
780 # If the optional \a geom parameter is not set, this algorithm is global.
781 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
782 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
783 # @param geom If defined, the subshape to be meshed (GEOM_Object)
784 # @return an instance of Mesh_Hexahedron algorithm
785 # @ingroup l3_algos_basic
786 def Hexahedron(self, algo=Hexa, geom=0):
787 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
788 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
789 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
790 elif geom == 0: algo, geom = Hexa, algo
791 return Mesh_Hexahedron(self, algo, geom)
793 ## Deprecated, used only for compatibility!
794 # @return an instance of Mesh_Netgen algorithm
795 # @ingroup l3_algos_basic
796 def Netgen(self, is3D, geom=0):
797 return Mesh_Netgen(self, is3D, geom)
799 ## Creates a projection 1D algorithm for edges.
800 # If the optional \a geom parameter is not set, this algorithm is global.
801 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
802 # @param geom If defined, the subshape to be meshed
803 # @return an instance of Mesh_Projection1D algorithm
804 # @ingroup l3_algos_proj
805 def Projection1D(self, geom=0):
806 return Mesh_Projection1D(self, geom)
808 ## Creates a projection 2D algorithm for faces.
809 # If the optional \a geom parameter is not set, this algorithm is global.
810 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
811 # @param geom If defined, the subshape to be meshed
812 # @return an instance of Mesh_Projection2D algorithm
813 # @ingroup l3_algos_proj
814 def Projection2D(self, geom=0):
815 return Mesh_Projection2D(self, geom)
817 ## Creates a projection 3D algorithm for solids.
818 # If the optional \a geom parameter is not set, this algorithm is global.
819 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
820 # @param geom If defined, the subshape to be meshed
821 # @return an instance of Mesh_Projection3D algorithm
822 # @ingroup l3_algos_proj
823 def Projection3D(self, geom=0):
824 return Mesh_Projection3D(self, geom)
826 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
827 # If the optional \a geom parameter is not set, this algorithm is global.
828 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
829 # @param geom If defined, the subshape to be meshed
830 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
831 # @ingroup l3_algos_radialp l3_algos_3dextr
832 def Prism(self, geom=0):
836 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
837 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
838 if nbSolids == 0 or nbSolids == nbShells:
839 return Mesh_Prism3D(self, geom)
840 return Mesh_RadialPrism3D(self, geom)
842 ## Computes the mesh and returns the status of the computation
843 # @return True or False
844 # @ingroup l2_construct
845 def Compute(self, geom=0):
846 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
848 geom = self.mesh.GetShapeToMesh()
853 ok = self.smeshpyD.Compute(self.mesh, geom)
854 except SALOME.SALOME_Exception, ex:
855 print "Mesh computation failed, exception caught:"
856 print " ", ex.details.text
859 print "Mesh computation failed, exception caught:"
860 traceback.print_exc()
862 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
873 reason = '%s %sD algorithm is missing' % (glob, dim)
874 elif err.state == HYP_MISSING:
875 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
876 % (glob, dim, name, dim))
877 elif err.state == HYP_NOTCONFORM:
878 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
879 elif err.state == HYP_BAD_PARAMETER:
880 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
881 % ( glob, dim, name ))
882 elif err.state == HYP_BAD_GEOMETRY:
883 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
884 'geometry' % ( glob, dim, name ))
886 reason = "For unknown reason."+\
887 " Revise Mesh.Compute() implementation in smeshDC.py!"
895 print '"' + GetName(self.mesh) + '"',"has not been computed:"
899 print '"' + GetName(self.mesh) + '"',"has not been computed."
902 if salome.sg.hasDesktop():
903 smeshgui = salome.ImportComponentGUI("SMESH")
904 smeshgui.Init(salome.myStudyId)
905 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
906 salome.sg.updateObjBrowser(1)
910 ## Removes all nodes and elements
911 # @ingroup l2_construct
914 if salome.sg.hasDesktop():
915 smeshgui = salome.ImportComponentGUI("SMESH")
916 smeshgui.Init(salome.myStudyId)
917 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
918 salome.sg.updateObjBrowser(1)
920 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
921 # @param fineness [0,-1] defines mesh fineness
922 # @return True or False
923 # @ingroup l3_algos_basic
924 def AutomaticTetrahedralization(self, fineness=0):
925 dim = self.MeshDimension()
927 self.RemoveGlobalHypotheses()
928 self.Segment().AutomaticLength(fineness)
930 self.Triangle().LengthFromEdges()
933 self.Tetrahedron(NETGEN)
935 return self.Compute()
937 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
938 # @param fineness [0,-1] defines mesh fineness
939 # @return True or False
940 # @ingroup l3_algos_basic
941 def AutomaticHexahedralization(self, fineness=0):
942 dim = self.MeshDimension()
943 # assign the hypotheses
944 self.RemoveGlobalHypotheses()
945 self.Segment().AutomaticLength(fineness)
952 return self.Compute()
954 ## Assigns a hypothesis
955 # @param hyp a hypothesis to assign
956 # @param geom a subhape of mesh geometry
957 # @return SMESH.Hypothesis_Status
958 # @ingroup l2_hypotheses
959 def AddHypothesis(self, hyp, geom=0):
960 if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
961 hyp = hyp.GetAlgorithm()
966 geom = self.mesh.GetShapeToMesh()
968 status = self.mesh.AddHypothesis(geom, hyp)
969 isAlgo = hyp._narrow( SMESH_Algo )
970 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
973 ## Unassigns a hypothesis
974 # @param hyp a hypothesis to unassign
975 # @param geom a subshape of mesh geometry
976 # @return SMESH.Hypothesis_Status
977 # @ingroup l2_hypotheses
978 def RemoveHypothesis(self, hyp, geom=0):
979 if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
980 hyp = hyp.GetAlgorithm()
985 status = self.mesh.RemoveHypothesis(geom, hyp)
988 ## Gets the list of hypotheses added on a geometry
989 # @param geom a subshape of mesh geometry
990 # @return the sequence of SMESH_Hypothesis
991 # @ingroup l2_hypotheses
992 def GetHypothesisList(self, geom):
993 return self.mesh.GetHypothesisList( geom )
995 ## Removes all global hypotheses
996 # @ingroup l2_hypotheses
997 def RemoveGlobalHypotheses(self):
998 current_hyps = self.mesh.GetHypothesisList( self.geom )
999 for hyp in current_hyps:
1000 self.mesh.RemoveHypothesis( self.geom, hyp )
1004 ## Creates a mesh group based on the geometric object \a grp
1005 # and gives a \a name, \n if this parameter is not defined
1006 # the name is the same as the geometric group name \n
1007 # Note: Works like GroupOnGeom().
1008 # @param grp a geometric group, a vertex, an edge, a face or a solid
1009 # @param name the name of the mesh group
1010 # @return SMESH_GroupOnGeom
1011 # @ingroup l2_grps_create
1012 def Group(self, grp, name=""):
1013 return self.GroupOnGeom(grp, name)
1015 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1016 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1017 # @param f the file name
1018 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1019 # @ingroup l2_impexp
1020 def ExportToMED(self, f, version, opt=0):
1021 self.mesh.ExportToMED(f, opt, version)
1023 ## Exports the mesh in a file in MED format
1024 # @param f is the file name
1025 # @param auto_groups boolean parameter for creating/not creating
1026 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1027 # the typical use is auto_groups=false.
1028 # @param version MED format version(MED_V2_1 or MED_V2_2)
1029 # @ingroup l2_impexp
1030 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1031 self.mesh.ExportToMED(f, auto_groups, version)
1033 ## Exports the mesh in a file in DAT format
1034 # @param f the file name
1035 # @ingroup l2_impexp
1036 def ExportDAT(self, f):
1037 self.mesh.ExportDAT(f)
1039 ## Exports the mesh in a file in UNV format
1040 # @param f the file name
1041 # @ingroup l2_impexp
1042 def ExportUNV(self, f):
1043 self.mesh.ExportUNV(f)
1045 ## Export the mesh in a file in STL format
1046 # @param f the file name
1047 # @param ascii defines the file encoding
1048 # @ingroup l2_impexp
1049 def ExportSTL(self, f, ascii=1):
1050 self.mesh.ExportSTL(f, ascii)
1053 # Operations with groups:
1054 # ----------------------
1056 ## Creates an empty mesh group
1057 # @param elementType the type of elements in the group
1058 # @param name the name of the mesh group
1059 # @return SMESH_Group
1060 # @ingroup l2_grps_create
1061 def CreateEmptyGroup(self, elementType, name):
1062 return self.mesh.CreateGroup(elementType, name)
1064 ## Creates a mesh group based on the geometrical object \a grp
1065 # and gives a \a name, \n if this parameter is not defined
1066 # the name is the same as the geometrical group name
1067 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1068 # @param name the name of the mesh group
1069 # @param typ the type of elements in the group. If not set, it is
1070 # automatically detected by the type of the geometry
1071 # @return SMESH_GroupOnGeom
1072 # @ingroup l2_grps_create
1073 def GroupOnGeom(self, grp, name="", typ=None):
1075 name = grp.GetName()
1078 tgeo = str(grp.GetShapeType())
1079 if tgeo == "VERTEX":
1081 elif tgeo == "EDGE":
1083 elif tgeo == "FACE":
1085 elif tgeo == "SOLID":
1087 elif tgeo == "SHELL":
1089 elif tgeo == "COMPOUND":
1090 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1091 print "Mesh.Group: empty geometric group", GetName( grp )
1093 tgeo = self.geompyD.GetType(grp)
1094 if tgeo == geompyDC.ShapeType["VERTEX"]:
1096 elif tgeo == geompyDC.ShapeType["EDGE"]:
1098 elif tgeo == geompyDC.ShapeType["FACE"]:
1100 elif tgeo == geompyDC.ShapeType["SOLID"]:
1104 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1107 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1109 ## Creates a mesh group by the given ids of elements
1110 # @param groupName the name of the mesh group
1111 # @param elementType the type of elements in the group
1112 # @param elemIDs the list of ids
1113 # @return SMESH_Group
1114 # @ingroup l2_grps_create
1115 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1116 group = self.mesh.CreateGroup(elementType, groupName)
1120 ## Creates a mesh group by the given conditions
1121 # @param groupName the name of the mesh group
1122 # @param elementType the type of elements in the group
1123 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1124 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1125 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1126 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1127 # @return SMESH_Group
1128 # @ingroup l2_grps_create
1132 CritType=FT_Undefined,
1135 UnaryOp=FT_Undefined):
1136 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1137 group = self.MakeGroupByCriterion(groupName, aCriterion)
1140 ## Creates a mesh group by the given criterion
1141 # @param groupName the name of the mesh group
1142 # @param Criterion the instance of Criterion class
1143 # @return SMESH_Group
1144 # @ingroup l2_grps_create
1145 def MakeGroupByCriterion(self, groupName, Criterion):
1146 aFilterMgr = self.smeshpyD.CreateFilterManager()
1147 aFilter = aFilterMgr.CreateFilter()
1149 aCriteria.append(Criterion)
1150 aFilter.SetCriteria(aCriteria)
1151 group = self.MakeGroupByFilter(groupName, aFilter)
1154 ## Creates a mesh group by the given criteria (list of criteria)
1155 # @param groupName the name of the mesh group
1156 # @param theCriteria the list of criteria
1157 # @return SMESH_Group
1158 # @ingroup l2_grps_create
1159 def MakeGroupByCriteria(self, groupName, theCriteria):
1160 aFilterMgr = self.smeshpyD.CreateFilterManager()
1161 aFilter = aFilterMgr.CreateFilter()
1162 aFilter.SetCriteria(theCriteria)
1163 group = self.MakeGroupByFilter(groupName, aFilter)
1166 ## Creates a mesh group by the given filter
1167 # @param groupName the name of the mesh group
1168 # @param theFilter the instance of Filter class
1169 # @return SMESH_Group
1170 # @ingroup l2_grps_create
1171 def MakeGroupByFilter(self, groupName, theFilter):
1172 anIds = theFilter.GetElementsId(self.mesh)
1173 anElemType = theFilter.GetElementType()
1174 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1177 ## Passes mesh elements through the given filter and return IDs of fitting elements
1178 # @param theFilter SMESH_Filter
1179 # @return a list of ids
1180 # @ingroup l1_controls
1181 def GetIdsFromFilter(self, theFilter):
1182 return theFilter.GetElementsId(self.mesh)
1184 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1185 # Returns a list of special structures (borders).
1186 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1187 # @ingroup l1_controls
1188 def GetFreeBorders(self):
1189 aFilterMgr = self.smeshpyD.CreateFilterManager()
1190 aPredicate = aFilterMgr.CreateFreeEdges()
1191 aPredicate.SetMesh(self.mesh)
1192 aBorders = aPredicate.GetBorders()
1196 # @ingroup l2_grps_delete
1197 def RemoveGroup(self, group):
1198 self.mesh.RemoveGroup(group)
1200 ## Removes a group with its contents
1201 # @ingroup l2_grps_delete
1202 def RemoveGroupWithContents(self, group):
1203 self.mesh.RemoveGroupWithContents(group)
1205 ## Gets the list of groups existing in the mesh
1206 # @return a sequence of SMESH_GroupBase
1207 # @ingroup l2_grps_create
1208 def GetGroups(self):
1209 return self.mesh.GetGroups()
1211 ## Gets the number of groups existing in the mesh
1212 # @return the quantity of groups as an integer value
1213 # @ingroup l2_grps_create
1215 return self.mesh.NbGroups()
1217 ## Gets the list of names of groups existing in the mesh
1218 # @return list of strings
1219 # @ingroup l2_grps_create
1220 def GetGroupNames(self):
1221 groups = self.GetGroups()
1223 for group in groups:
1224 names.append(group.GetName())
1227 ## Produces a union of two groups
1228 # A new group is created. All mesh elements that are
1229 # present in the initial groups are added to the new one
1230 # @return an instance of SMESH_Group
1231 # @ingroup l2_grps_operon
1232 def UnionGroups(self, group1, group2, name):
1233 return self.mesh.UnionGroups(group1, group2, name)
1235 ## Prodices an intersection of two groups
1236 # A new group is created. All mesh elements that are common
1237 # for the two initial groups are added to the new one.
1238 # @return an instance of SMESH_Group
1239 # @ingroup l2_grps_operon
1240 def IntersectGroups(self, group1, group2, name):
1241 return self.mesh.IntersectGroups(group1, group2, name)
1243 ## Produces a cut of two groups
1244 # A new group is created. All mesh elements that are present in
1245 # the main group but are not present in the tool group are added to the new one
1246 # @return an instance of SMESH_Group
1247 # @ingroup l2_grps_operon
1248 def CutGroups(self, mainGroup, toolGroup, name):
1249 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1252 # Get some info about mesh:
1253 # ------------------------
1255 ## Returns the log of nodes and elements added or removed
1256 # since the previous clear of the log.
1257 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1258 # @return list of log_block structures:
1263 # @ingroup l1_auxiliary
1264 def GetLog(self, clearAfterGet):
1265 return self.mesh.GetLog(clearAfterGet)
1267 ## Clears the log of nodes and elements added or removed since the previous
1268 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1269 # @ingroup l1_auxiliary
1271 self.mesh.ClearLog()
1273 ## Toggles auto color mode on the object.
1274 # @param theAutoColor the flag which toggles auto color mode.
1275 # @ingroup l1_auxiliary
1276 def SetAutoColor(self, theAutoColor):
1277 self.mesh.SetAutoColor(theAutoColor)
1279 ## Gets flag of object auto color mode.
1280 # @return True or False
1281 # @ingroup l1_auxiliary
1282 def GetAutoColor(self):
1283 return self.mesh.GetAutoColor()
1285 ## Gets the internal ID
1286 # @return integer value, which is the internal Id of the mesh
1287 # @ingroup l1_auxiliary
1289 return self.mesh.GetId()
1292 # @return integer value, which is the study Id of the mesh
1293 # @ingroup l1_auxiliary
1294 def GetStudyId(self):
1295 return self.mesh.GetStudyId()
1297 ## Checks the group names for duplications.
1298 # Consider the maximum group name length stored in MED file.
1299 # @return True or False
1300 # @ingroup l1_auxiliary
1301 def HasDuplicatedGroupNamesMED(self):
1302 return self.mesh.HasDuplicatedGroupNamesMED()
1304 ## Obtains the mesh editor tool
1305 # @return an instance of SMESH_MeshEditor
1306 # @ingroup l1_modifying
1307 def GetMeshEditor(self):
1308 return self.mesh.GetMeshEditor()
1311 # @return an instance of SALOME_MED::MESH
1312 # @ingroup l1_auxiliary
1313 def GetMEDMesh(self):
1314 return self.mesh.GetMEDMesh()
1317 # Get informations about mesh contents:
1318 # ------------------------------------
1320 ## Returns the number of nodes in the mesh
1321 # @return an integer value
1322 # @ingroup l1_meshinfo
1324 return self.mesh.NbNodes()
1326 ## Returns the number of elements in the mesh
1327 # @return an integer value
1328 # @ingroup l1_meshinfo
1329 def NbElements(self):
1330 return self.mesh.NbElements()
1332 ## Returns the number of edges in the mesh
1333 # @return an integer value
1334 # @ingroup l1_meshinfo
1336 return self.mesh.NbEdges()
1338 ## Returns the number of edges with the given order in the mesh
1339 # @param elementOrder the order of elements:
1340 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1341 # @return an integer value
1342 # @ingroup l1_meshinfo
1343 def NbEdgesOfOrder(self, elementOrder):
1344 return self.mesh.NbEdgesOfOrder(elementOrder)
1346 ## Returns the number of faces in the mesh
1347 # @return an integer value
1348 # @ingroup l1_meshinfo
1350 return self.mesh.NbFaces()
1352 ## Returns the number of faces with the given order in the mesh
1353 # @param elementOrder the order of elements:
1354 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1355 # @return an integer value
1356 # @ingroup l1_meshinfo
1357 def NbFacesOfOrder(self, elementOrder):
1358 return self.mesh.NbFacesOfOrder(elementOrder)
1360 ## Returns the number of triangles in the mesh
1361 # @return an integer value
1362 # @ingroup l1_meshinfo
1363 def NbTriangles(self):
1364 return self.mesh.NbTriangles()
1366 ## Returns the number of triangles with the given order in the mesh
1367 # @param elementOrder is the order of elements:
1368 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1369 # @return an integer value
1370 # @ingroup l1_meshinfo
1371 def NbTrianglesOfOrder(self, elementOrder):
1372 return self.mesh.NbTrianglesOfOrder(elementOrder)
1374 ## Returns the number of quadrangles in the mesh
1375 # @return an integer value
1376 # @ingroup l1_meshinfo
1377 def NbQuadrangles(self):
1378 return self.mesh.NbQuadrangles()
1380 ## Returns the number of quadrangles with the given order in the mesh
1381 # @param elementOrder the order of elements:
1382 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1383 # @return an integer value
1384 # @ingroup l1_meshinfo
1385 def NbQuadranglesOfOrder(self, elementOrder):
1386 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1388 ## Returns the number of polygons in the mesh
1389 # @return an integer value
1390 # @ingroup l1_meshinfo
1391 def NbPolygons(self):
1392 return self.mesh.NbPolygons()
1394 ## Returns the number of volumes in the mesh
1395 # @return an integer value
1396 # @ingroup l1_meshinfo
1397 def NbVolumes(self):
1398 return self.mesh.NbVolumes()
1400 ## Returns the number of volumes with the given order in the mesh
1401 # @param elementOrder the order of elements:
1402 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1403 # @return an integer value
1404 # @ingroup l1_meshinfo
1405 def NbVolumesOfOrder(self, elementOrder):
1406 return self.mesh.NbVolumesOfOrder(elementOrder)
1408 ## Returns the number of tetrahedrons in the mesh
1409 # @return an integer value
1410 # @ingroup l1_meshinfo
1412 return self.mesh.NbTetras()
1414 ## Returns the number of tetrahedrons with the given order in the mesh
1415 # @param elementOrder the order of elements:
1416 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1417 # @return an integer value
1418 # @ingroup l1_meshinfo
1419 def NbTetrasOfOrder(self, elementOrder):
1420 return self.mesh.NbTetrasOfOrder(elementOrder)
1422 ## Returns the number of hexahedrons in the mesh
1423 # @return an integer value
1424 # @ingroup l1_meshinfo
1426 return self.mesh.NbHexas()
1428 ## Returns the number of hexahedrons with the given order in the mesh
1429 # @param elementOrder the order of elements:
1430 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1431 # @return an integer value
1432 # @ingroup l1_meshinfo
1433 def NbHexasOfOrder(self, elementOrder):
1434 return self.mesh.NbHexasOfOrder(elementOrder)
1436 ## Returns the number of pyramids in the mesh
1437 # @return an integer value
1438 # @ingroup l1_meshinfo
1439 def NbPyramids(self):
1440 return self.mesh.NbPyramids()
1442 ## Returns the number of pyramids with the given order in the mesh
1443 # @param elementOrder the order of elements:
1444 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1445 # @return an integer value
1446 # @ingroup l1_meshinfo
1447 def NbPyramidsOfOrder(self, elementOrder):
1448 return self.mesh.NbPyramidsOfOrder(elementOrder)
1450 ## Returns the number of prisms in the mesh
1451 # @return an integer value
1452 # @ingroup l1_meshinfo
1454 return self.mesh.NbPrisms()
1456 ## Returns the number of prisms with the given order in the mesh
1457 # @param elementOrder the order of elements:
1458 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1459 # @return an integer value
1460 # @ingroup l1_meshinfo
1461 def NbPrismsOfOrder(self, elementOrder):
1462 return self.mesh.NbPrismsOfOrder(elementOrder)
1464 ## Returns the number of polyhedrons in the mesh
1465 # @return an integer value
1466 # @ingroup l1_meshinfo
1467 def NbPolyhedrons(self):
1468 return self.mesh.NbPolyhedrons()
1470 ## Returns the number of submeshes in the mesh
1471 # @return an integer value
1472 # @ingroup l1_meshinfo
1473 def NbSubMesh(self):
1474 return self.mesh.NbSubMesh()
1476 ## Returns the list of mesh elements IDs
1477 # @return the list of integer values
1478 # @ingroup l1_meshinfo
1479 def GetElementsId(self):
1480 return self.mesh.GetElementsId()
1482 ## Returns the list of IDs of mesh elements with the given type
1483 # @param elementType the required type of elements
1484 # @return list of integer values
1485 # @ingroup l1_meshinfo
1486 def GetElementsByType(self, elementType):
1487 return self.mesh.GetElementsByType(elementType)
1489 ## Returns the list of mesh nodes IDs
1490 # @return the list of integer values
1491 # @ingroup l1_meshinfo
1492 def GetNodesId(self):
1493 return self.mesh.GetNodesId()
1495 # Get the information about mesh elements:
1496 # ------------------------------------
1498 ## Returns the type of mesh element
1499 # @return the value from SMESH::ElementType enumeration
1500 # @ingroup l1_meshinfo
1501 def GetElementType(self, id, iselem):
1502 return self.mesh.GetElementType(id, iselem)
1504 ## Returns the list of submesh elements IDs
1505 # @param Shape a geom object(subshape) IOR
1506 # Shape must be the subshape of a ShapeToMesh()
1507 # @return the list of integer values
1508 # @ingroup l1_meshinfo
1509 def GetSubMeshElementsId(self, Shape):
1510 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1511 ShapeID = Shape.GetSubShapeIndices()[0]
1514 return self.mesh.GetSubMeshElementsId(ShapeID)
1516 ## Returns the list of submesh nodes IDs
1517 # @param Shape a geom object(subshape) IOR
1518 # Shape must be the subshape of a ShapeToMesh()
1519 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1520 # @return the list of integer values
1521 # @ingroup l1_meshinfo
1522 def GetSubMeshNodesId(self, Shape, all):
1523 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1524 ShapeID = Shape.GetSubShapeIndices()[0]
1527 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1529 ## Returns the list of IDs of submesh elements with the given type
1530 # @param Shape a geom object(subshape) IOR
1531 # Shape must be a subshape of a ShapeToMesh()
1532 # @return the list of integer values
1533 # @ingroup l1_meshinfo
1534 def GetSubMeshElementType(self, Shape):
1535 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1536 ShapeID = Shape.GetSubShapeIndices()[0]
1539 return self.mesh.GetSubMeshElementType(ShapeID)
1541 ## Gets the mesh description
1542 # @return string value
1543 # @ingroup l1_meshinfo
1545 return self.mesh.Dump()
1548 # Get the information about nodes and elements of a mesh by its IDs:
1549 # -----------------------------------------------------------
1551 ## Gets XYZ coordinates of a node
1552 # \n If there is no nodes for the given ID - returns an empty list
1553 # @return a list of double precision values
1554 # @ingroup l1_meshinfo
1555 def GetNodeXYZ(self, id):
1556 return self.mesh.GetNodeXYZ(id)
1558 ## Returns list of IDs of inverse elements for the given node
1559 # \n If there is no node for the given ID - returns an empty list
1560 # @return a list of integer values
1561 # @ingroup l1_meshinfo
1562 def GetNodeInverseElements(self, id):
1563 return self.mesh.GetNodeInverseElements(id)
1565 ## @brief Returns the position of a node on the shape
1566 # @return SMESH::NodePosition
1567 # @ingroup l1_meshinfo
1568 def GetNodePosition(self,NodeID):
1569 return self.mesh.GetNodePosition(NodeID)
1571 ## If the given element is a node, returns the ID of shape
1572 # \n If there is no node for the given ID - returns -1
1573 # @return an integer value
1574 # @ingroup l1_meshinfo
1575 def GetShapeID(self, id):
1576 return self.mesh.GetShapeID(id)
1578 ## Returns the ID of the result shape after
1579 # FindShape() from SMESH_MeshEditor for the given element
1580 # \n If there is no element for the given ID - returns -1
1581 # @return an integer value
1582 # @ingroup l1_meshinfo
1583 def GetShapeIDForElem(self,id):
1584 return self.mesh.GetShapeIDForElem(id)
1586 ## Returns the number of nodes for the given element
1587 # \n If there is no element for the given ID - returns -1
1588 # @return an integer value
1589 # @ingroup l1_meshinfo
1590 def GetElemNbNodes(self, id):
1591 return self.mesh.GetElemNbNodes(id)
1593 ## Returns the node ID the given index for the given element
1594 # \n If there is no element for the given ID - returns -1
1595 # \n If there is no node for the given index - returns -2
1596 # @return an integer value
1597 # @ingroup l1_meshinfo
1598 def GetElemNode(self, id, index):
1599 return self.mesh.GetElemNode(id, index)
1601 ## Returns the IDs of nodes of the given element
1602 # @return a list of integer values
1603 # @ingroup l1_meshinfo
1604 def GetElemNodes(self, id):
1605 return self.mesh.GetElemNodes(id)
1607 ## Returns true if the given node is the medium node in the given quadratic element
1608 # @ingroup l1_meshinfo
1609 def IsMediumNode(self, elementID, nodeID):
1610 return self.mesh.IsMediumNode(elementID, nodeID)
1612 ## Returns true if the given node is the medium node in one of quadratic elements
1613 # @ingroup l1_meshinfo
1614 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1615 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1617 ## Returns the number of edges for the given element
1618 # @ingroup l1_meshinfo
1619 def ElemNbEdges(self, id):
1620 return self.mesh.ElemNbEdges(id)
1622 ## Returns the number of faces for the given element
1623 # @ingroup l1_meshinfo
1624 def ElemNbFaces(self, id):
1625 return self.mesh.ElemNbFaces(id)
1627 ## Returns true if the given element is a polygon
1628 # @ingroup l1_meshinfo
1629 def IsPoly(self, id):
1630 return self.mesh.IsPoly(id)
1632 ## Returns true if the given element is quadratic
1633 # @ingroup l1_meshinfo
1634 def IsQuadratic(self, id):
1635 return self.mesh.IsQuadratic(id)
1637 ## Returns XYZ coordinates of the barycenter of the given element
1638 # \n If there is no element for the given ID - returns an empty list
1639 # @return a list of three double values
1640 # @ingroup l1_meshinfo
1641 def BaryCenter(self, id):
1642 return self.mesh.BaryCenter(id)
1645 # Mesh edition (SMESH_MeshEditor functionality):
1646 # ---------------------------------------------
1648 ## Removes the elements from the mesh by ids
1649 # @param IDsOfElements is a list of ids of elements to remove
1650 # @return True or False
1651 # @ingroup l2_modif_del
1652 def RemoveElements(self, IDsOfElements):
1653 return self.editor.RemoveElements(IDsOfElements)
1655 ## Removes nodes from mesh by ids
1656 # @param IDsOfNodes is a list of ids of nodes to remove
1657 # @return True or False
1658 # @ingroup l2_modif_del
1659 def RemoveNodes(self, IDsOfNodes):
1660 return self.editor.RemoveNodes(IDsOfNodes)
1662 ## Add a node to the mesh by coordinates
1663 # @return Id of the new node
1664 # @ingroup l2_modif_add
1665 def AddNode(self, x, y, z):
1666 return self.editor.AddNode( x, y, z)
1668 ## Creates a linear or quadratic edge (this is determined
1669 # by the number of given nodes).
1670 # @param IDsOfNodes the list of node IDs for creation of the element.
1671 # The order of nodes in this list should correspond to the description
1672 # of MED. \n This description is located by the following link:
1673 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1674 # @return the Id of the new edge
1675 # @ingroup l2_modif_add
1676 def AddEdge(self, IDsOfNodes):
1677 return self.editor.AddEdge(IDsOfNodes)
1679 ## Creates a linear or quadratic face (this is determined
1680 # by the number of given nodes).
1681 # @param IDsOfNodes the list of node IDs for creation of the element.
1682 # The order of nodes in this list should correspond to the description
1683 # of MED. \n This description is located by the following link:
1684 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1685 # @return the Id of the new face
1686 # @ingroup l2_modif_add
1687 def AddFace(self, IDsOfNodes):
1688 return self.editor.AddFace(IDsOfNodes)
1690 ## Adds a polygonal face to the mesh by the list of node IDs
1691 # @param IdsOfNodes the list of node IDs for creation of the element.
1692 # @return the Id of the new face
1693 # @ingroup l2_modif_add
1694 def AddPolygonalFace(self, IdsOfNodes):
1695 return self.editor.AddPolygonalFace(IdsOfNodes)
1697 ## Creates both simple and quadratic volume (this is determined
1698 # by the number of given nodes).
1699 # @param IDsOfNodes the list of node IDs for creation of the element.
1700 # The order of nodes in this list should correspond to the description
1701 # of MED. \n This description is located by the following link:
1702 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1703 # @return the Id of the new volumic element
1704 # @ingroup l2_modif_add
1705 def AddVolume(self, IDsOfNodes):
1706 return self.editor.AddVolume(IDsOfNodes)
1708 ## Creates a volume of many faces, giving nodes for each face.
1709 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1710 # @param Quantities the list of integer values, Quantities[i]
1711 # gives the quantity of nodes in face number i.
1712 # @return the Id of the new volumic element
1713 # @ingroup l2_modif_add
1714 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1715 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1717 ## Creates a volume of many faces, giving the IDs of the existing faces.
1718 # @param IdsOfFaces the list of face IDs for volume creation.
1720 # Note: The created volume will refer only to the nodes
1721 # of the given faces, not to the faces themselves.
1722 # @return the Id of the new volumic element
1723 # @ingroup l2_modif_add
1724 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1725 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1728 ## @brief Binds a node to a vertex
1729 # @param NodeID a node ID
1730 # @param Vertex a vertex or vertex ID
1731 # @return True if succeed else raises an exception
1732 # @ingroup l2_modif_add
1733 def SetNodeOnVertex(self, NodeID, Vertex):
1734 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1735 VertexID = Vertex.GetSubShapeIndices()[0]
1739 self.editor.SetNodeOnVertex(NodeID, VertexID)
1740 except SALOME.SALOME_Exception, inst:
1741 raise ValueError, inst.details.text
1745 ## @brief Stores the node position on an edge
1746 # @param NodeID a node ID
1747 # @param Edge an edge or edge ID
1748 # @param paramOnEdge a parameter on the edge where the node is located
1749 # @return True if succeed else raises an exception
1750 # @ingroup l2_modif_add
1751 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1752 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1753 EdgeID = Edge.GetSubShapeIndices()[0]
1757 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1758 except SALOME.SALOME_Exception, inst:
1759 raise ValueError, inst.details.text
1762 ## @brief Stores node position on a face
1763 # @param NodeID a node ID
1764 # @param Face a face or face ID
1765 # @param u U parameter on the face where the node is located
1766 # @param v V parameter on the face where the node is located
1767 # @return True if succeed else raises an exception
1768 # @ingroup l2_modif_add
1769 def SetNodeOnFace(self, NodeID, Face, u, v):
1770 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1771 FaceID = Face.GetSubShapeIndices()[0]
1775 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1776 except SALOME.SALOME_Exception, inst:
1777 raise ValueError, inst.details.text
1780 ## @brief Binds a node to a solid
1781 # @param NodeID a node ID
1782 # @param Solid a solid or solid ID
1783 # @return True if succeed else raises an exception
1784 # @ingroup l2_modif_add
1785 def SetNodeInVolume(self, NodeID, Solid):
1786 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1787 SolidID = Solid.GetSubShapeIndices()[0]
1791 self.editor.SetNodeInVolume(NodeID, SolidID)
1792 except SALOME.SALOME_Exception, inst:
1793 raise ValueError, inst.details.text
1796 ## @brief Bind an element to a shape
1797 # @param ElementID an element ID
1798 # @param Shape a shape or shape ID
1799 # @return True if succeed else raises an exception
1800 # @ingroup l2_modif_add
1801 def SetMeshElementOnShape(self, ElementID, Shape):
1802 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1803 ShapeID = Shape.GetSubShapeIndices()[0]
1807 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1808 except SALOME.SALOME_Exception, inst:
1809 raise ValueError, inst.details.text
1813 ## Moves the node with the given id
1814 # @param NodeID the id of the node
1815 # @param x a new X coordinate
1816 # @param y a new Y coordinate
1817 # @param z a new Z coordinate
1818 # @return True if succeed else False
1819 # @ingroup l2_modif_movenode
1820 def MoveNode(self, NodeID, x, y, z):
1821 return self.editor.MoveNode(NodeID, x, y, z)
1823 ## Finds the node closest to a point
1824 # @param x the X coordinate of a point
1825 # @param y the Y coordinate of a point
1826 # @param z the Z coordinate of a point
1827 # @return the ID of a node
1828 # @ingroup l2_modif_throughp
1829 def FindNodeClosestTo(self, x, y, z):
1830 preview = self.mesh.GetMeshEditPreviewer()
1831 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1833 ## Finds the node closest to a point and moves it to a point location
1834 # @param x the X coordinate of a point
1835 # @param y the Y coordinate of a point
1836 # @param z the Z coordinate of a point
1837 # @return the ID of a moved node
1838 # @ingroup l2_modif_throughp
1839 def MeshToPassThroughAPoint(self, x, y, z):
1840 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1842 ## Replaces two neighbour triangles sharing Node1-Node2 link
1843 # with the triangles built on the same 4 nodes but having other common link.
1844 # @param NodeID1 the ID of the first node
1845 # @param NodeID2 the ID of the second node
1846 # @return false if proper faces were not found
1847 # @ingroup l2_modif_invdiag
1848 def InverseDiag(self, NodeID1, NodeID2):
1849 return self.editor.InverseDiag(NodeID1, NodeID2)
1851 ## Replaces two neighbour triangles sharing Node1-Node2 link
1852 # with a quadrangle built on the same 4 nodes.
1853 # @param NodeID1 the ID of the first node
1854 # @param NodeID2 the ID of the second node
1855 # @return false if proper faces were not found
1856 # @ingroup l2_modif_unitetri
1857 def DeleteDiag(self, NodeID1, NodeID2):
1858 return self.editor.DeleteDiag(NodeID1, NodeID2)
1860 ## Reorients elements by ids
1861 # @param IDsOfElements if undefined reorients all mesh elements
1862 # @return True if succeed else False
1863 # @ingroup l2_modif_changori
1864 def Reorient(self, IDsOfElements=None):
1865 if IDsOfElements == None:
1866 IDsOfElements = self.GetElementsId()
1867 return self.editor.Reorient(IDsOfElements)
1869 ## Reorients all elements of the object
1870 # @param theObject mesh, submesh or group
1871 # @return True if succeed else False
1872 # @ingroup l2_modif_changori
1873 def ReorientObject(self, theObject):
1874 if ( isinstance( theObject, Mesh )):
1875 theObject = theObject.GetMesh()
1876 return self.editor.ReorientObject(theObject)
1878 ## Fuses the neighbouring triangles into quadrangles.
1879 # @param IDsOfElements The triangles to be fused,
1880 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1881 # @param MaxAngle is the maximum angle between element normals at which the fusion
1882 # is still performed; theMaxAngle is mesured in radians.
1883 # @return TRUE in case of success, FALSE otherwise.
1884 # @ingroup l2_modif_unitetri
1885 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1886 if IDsOfElements == []:
1887 IDsOfElements = self.GetElementsId()
1888 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1890 ## Fuses the neighbouring triangles of the object into quadrangles
1891 # @param theObject is mesh, submesh or group
1892 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1893 # @param MaxAngle a max angle between element normals at which the fusion
1894 # is still performed; theMaxAngle is mesured in radians.
1895 # @return TRUE in case of success, FALSE otherwise.
1896 # @ingroup l2_modif_unitetri
1897 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1898 if ( isinstance( theObject, Mesh )):
1899 theObject = theObject.GetMesh()
1900 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1902 ## Splits quadrangles into triangles.
1903 # @param IDsOfElements the faces to be splitted.
1904 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1905 # @return TRUE in case of success, FALSE otherwise.
1906 # @ingroup l2_modif_cutquadr
1907 def QuadToTri (self, IDsOfElements, theCriterion):
1908 if IDsOfElements == []:
1909 IDsOfElements = self.GetElementsId()
1910 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1912 ## Splits quadrangles into triangles.
1913 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1914 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1915 # @return TRUE in case of success, FALSE otherwise.
1916 # @ingroup l2_modif_cutquadr
1917 def QuadToTriObject (self, theObject, theCriterion):
1918 if ( isinstance( theObject, Mesh )):
1919 theObject = theObject.GetMesh()
1920 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1922 ## Splits quadrangles into triangles.
1923 # @param IDsOfElements the faces to be splitted
1924 # @param Diag13 is used to choose a diagonal for splitting.
1925 # @return TRUE in case of success, FALSE otherwise.
1926 # @ingroup l2_modif_cutquadr
1927 def SplitQuad (self, IDsOfElements, Diag13):
1928 if IDsOfElements == []:
1929 IDsOfElements = self.GetElementsId()
1930 return self.editor.SplitQuad(IDsOfElements, Diag13)
1932 ## Splits quadrangles into triangles.
1933 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1934 # @param Diag13 is used to choose a diagonal for splitting.
1935 # @return TRUE in case of success, FALSE otherwise.
1936 # @ingroup l2_modif_cutquadr
1937 def SplitQuadObject (self, theObject, Diag13):
1938 if ( isinstance( theObject, Mesh )):
1939 theObject = theObject.GetMesh()
1940 return self.editor.SplitQuadObject(theObject, Diag13)
1942 ## Finds a better splitting of the given quadrangle.
1943 # @param IDOfQuad the ID of the quadrangle to be splitted.
1944 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1945 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1946 # diagonal is better, 0 if error occurs.
1947 # @ingroup l2_modif_cutquadr
1948 def BestSplit (self, IDOfQuad, theCriterion):
1949 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1951 ## Splits quadrangle faces near triangular facets of volumes
1953 # @ingroup l1_auxiliary
1954 def SplitQuadsNearTriangularFacets(self):
1955 faces_array = self.GetElementsByType(SMESH.FACE)
1956 for face_id in faces_array:
1957 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1958 quad_nodes = self.mesh.GetElemNodes(face_id)
1959 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1960 isVolumeFound = False
1961 for node1_elem in node1_elems:
1962 if not isVolumeFound:
1963 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1964 nb_nodes = self.GetElemNbNodes(node1_elem)
1965 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1966 volume_elem = node1_elem
1967 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1968 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1969 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1970 isVolumeFound = True
1971 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1972 self.SplitQuad([face_id], False) # diagonal 2-4
1973 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1974 isVolumeFound = True
1975 self.SplitQuad([face_id], True) # diagonal 1-3
1976 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1977 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1978 isVolumeFound = True
1979 self.SplitQuad([face_id], True) # diagonal 1-3
1981 ## @brief Splits hexahedrons into tetrahedrons.
1983 # This operation uses pattern mapping functionality for splitting.
1984 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1985 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1986 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1987 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1988 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
1989 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1990 # @return TRUE in case of success, FALSE otherwise.
1991 # @ingroup l1_auxiliary
1992 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1993 # Pattern: 5.---------.6
1998 # (0,0,1) 4.---------.7 * |
2005 # (0,0,0) 0.---------.3
2006 pattern_tetra = "!!! Nb of points: \n 8 \n\
2016 !!! Indices of points of 6 tetras: \n\
2024 pattern = self.smeshpyD.GetPattern()
2025 isDone = pattern.LoadFromFile(pattern_tetra)
2027 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2030 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2031 isDone = pattern.MakeMesh(self.mesh, False, False)
2032 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2034 # split quafrangle faces near triangular facets of volumes
2035 self.SplitQuadsNearTriangularFacets()
2039 ## @brief Split hexahedrons into prisms.
2041 # Uses the pattern mapping functionality for splitting.
2042 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2043 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2044 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2045 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2046 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2047 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2048 # @return TRUE in case of success, FALSE otherwise.
2049 # @ingroup l1_auxiliary
2050 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2051 # Pattern: 5.---------.6
2056 # (0,0,1) 4.---------.7 |
2063 # (0,0,0) 0.---------.3
2064 pattern_prism = "!!! Nb of points: \n 8 \n\
2074 !!! Indices of points of 2 prisms: \n\
2078 pattern = self.smeshpyD.GetPattern()
2079 isDone = pattern.LoadFromFile(pattern_prism)
2081 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2084 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2085 isDone = pattern.MakeMesh(self.mesh, False, False)
2086 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2088 # Splits quafrangle faces near triangular facets of volumes
2089 self.SplitQuadsNearTriangularFacets()
2093 ## Smoothes elements
2094 # @param IDsOfElements the list if ids of elements to smooth
2095 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2096 # Note that nodes built on edges and boundary nodes are always fixed.
2097 # @param MaxNbOfIterations the maximum number of iterations
2098 # @param MaxAspectRatio varies in range [1.0, inf]
2099 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2100 # @return TRUE in case of success, FALSE otherwise.
2101 # @ingroup l2_modif_smooth
2102 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2103 MaxNbOfIterations, MaxAspectRatio, Method):
2104 if IDsOfElements == []:
2105 IDsOfElements = self.GetElementsId()
2106 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2107 MaxNbOfIterations, MaxAspectRatio, Method)
2109 ## Smoothes elements which belong to the given object
2110 # @param theObject the object to smooth
2111 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2112 # Note that nodes built on edges and boundary nodes are always fixed.
2113 # @param MaxNbOfIterations the maximum number of iterations
2114 # @param MaxAspectRatio varies in range [1.0, inf]
2115 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2116 # @return TRUE in case of success, FALSE otherwise.
2117 # @ingroup l2_modif_smooth
2118 def SmoothObject(self, theObject, IDsOfFixedNodes,
2119 MaxNbOfIterations, MaxAspectRatio, Method):
2120 if ( isinstance( theObject, Mesh )):
2121 theObject = theObject.GetMesh()
2122 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2123 MaxNbOfIterations, MaxAspectRatio, Method)
2125 ## Parametrically smoothes the given elements
2126 # @param IDsOfElements the list if ids of elements to smooth
2127 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2128 # Note that nodes built on edges and boundary nodes are always fixed.
2129 # @param MaxNbOfIterations the maximum number of iterations
2130 # @param MaxAspectRatio varies in range [1.0, inf]
2131 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2132 # @return TRUE in case of success, FALSE otherwise.
2133 # @ingroup l2_modif_smooth
2134 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2135 MaxNbOfIterations, MaxAspectRatio, Method):
2136 if IDsOfElements == []:
2137 IDsOfElements = self.GetElementsId()
2138 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2139 MaxNbOfIterations, MaxAspectRatio, Method)
2141 ## Parametrically smoothes the elements which belong to the given object
2142 # @param theObject the object to smooth
2143 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2144 # Note that nodes built on edges and boundary nodes are always fixed.
2145 # @param MaxNbOfIterations the maximum number of iterations
2146 # @param MaxAspectRatio varies in range [1.0, inf]
2147 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2148 # @return TRUE in case of success, FALSE otherwise.
2149 # @ingroup l2_modif_smooth
2150 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2151 MaxNbOfIterations, MaxAspectRatio, Method):
2152 if ( isinstance( theObject, Mesh )):
2153 theObject = theObject.GetMesh()
2154 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2155 MaxNbOfIterations, MaxAspectRatio, Method)
2157 ## Converts the mesh to quadratic, deletes old elements, replacing
2158 # them with quadratic with the same id.
2159 # @ingroup l2_modif_tofromqu
2160 def ConvertToQuadratic(self, theForce3d):
2161 self.editor.ConvertToQuadratic(theForce3d)
2163 ## Converts the mesh from quadratic to ordinary,
2164 # deletes old quadratic elements, \n replacing
2165 # them with ordinary mesh elements with the same id.
2166 # @return TRUE in case of success, FALSE otherwise.
2167 # @ingroup l2_modif_tofromqu
2168 def ConvertFromQuadratic(self):
2169 return self.editor.ConvertFromQuadratic()
2171 ## Renumber mesh nodes
2172 # @ingroup l2_modif_renumber
2173 def RenumberNodes(self):
2174 self.editor.RenumberNodes()
2176 ## Renumber mesh elements
2177 # @ingroup l2_modif_renumber
2178 def RenumberElements(self):
2179 self.editor.RenumberElements()
2181 ## Generates new elements by rotation of the elements around the axis
2182 # @param IDsOfElements the list of ids of elements to sweep
2183 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2184 # @param AngleInRadians the angle of Rotation
2185 # @param NbOfSteps the number of steps
2186 # @param Tolerance tolerance
2187 # @param MakeGroups forces the generation of new groups from existing ones
2188 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2189 # of all steps, else - size of each step
2190 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2191 # @ingroup l2_modif_extrurev
2192 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2193 MakeGroups=False, TotalAngle=False):
2194 if IDsOfElements == []:
2195 IDsOfElements = self.GetElementsId()
2196 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2197 Axis = self.smeshpyD.GetAxisStruct(Axis)
2198 if TotalAngle and NbOfSteps:
2199 AngleInRadians /= NbOfSteps
2201 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2202 AngleInRadians, NbOfSteps, Tolerance)
2203 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2206 ## Generates new elements by rotation of the elements of object around the axis
2207 # @param theObject object which elements should be sweeped
2208 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2209 # @param AngleInRadians the angle of Rotation
2210 # @param NbOfSteps number of steps
2211 # @param Tolerance tolerance
2212 # @param MakeGroups forces the generation of new groups from existing ones
2213 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2214 # of all steps, else - size of each step
2215 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2216 # @ingroup l2_modif_extrurev
2217 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2218 MakeGroups=False, TotalAngle=False):
2219 if ( isinstance( theObject, Mesh )):
2220 theObject = theObject.GetMesh()
2221 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2222 Axis = self.smeshpyD.GetAxisStruct(Axis)
2223 if TotalAngle and NbOfSteps:
2224 AngleInRadians /= NbOfSteps
2226 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2227 NbOfSteps, Tolerance)
2228 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2231 ## Generates new elements by extrusion of the elements with given ids
2232 # @param IDsOfElements the list of elements ids for extrusion
2233 # @param StepVector vector, defining the direction and value of extrusion
2234 # @param NbOfSteps the number of steps
2235 # @param MakeGroups forces the generation of new groups from existing ones
2236 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2237 # @ingroup l2_modif_extrurev
2238 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2239 if IDsOfElements == []:
2240 IDsOfElements = self.GetElementsId()
2241 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2242 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2244 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2245 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2248 ## Generates new elements by extrusion of the elements with given ids
2249 # @param IDsOfElements is ids of elements
2250 # @param StepVector vector, defining the direction and value of extrusion
2251 # @param NbOfSteps the number of steps
2252 # @param ExtrFlags sets flags for extrusion
2253 # @param SewTolerance uses for comparing locations of nodes if flag
2254 # EXTRUSION_FLAG_SEW is set
2255 # @param MakeGroups forces the generation of new groups from existing ones
2256 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2257 # @ingroup l2_modif_extrurev
2258 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2259 ExtrFlags, SewTolerance, MakeGroups=False):
2260 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2261 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2263 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2264 ExtrFlags, SewTolerance)
2265 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2266 ExtrFlags, SewTolerance)
2269 ## Generates new elements by extrusion of the elements which belong to the object
2270 # @param theObject the object which elements should be processed
2271 # @param StepVector vector, defining the direction and value of extrusion
2272 # @param NbOfSteps the number of steps
2273 # @param MakeGroups forces the generation of new groups from existing ones
2274 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2275 # @ingroup l2_modif_extrurev
2276 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2277 if ( isinstance( theObject, Mesh )):
2278 theObject = theObject.GetMesh()
2279 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2280 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2282 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2283 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2286 ## Generates new elements by extrusion of the elements which belong to the object
2287 # @param theObject object which elements should be processed
2288 # @param StepVector vector, defining the direction and value of extrusion
2289 # @param NbOfSteps the number of steps
2290 # @param MakeGroups to generate new groups from existing ones
2291 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2292 # @ingroup l2_modif_extrurev
2293 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2294 if ( isinstance( theObject, Mesh )):
2295 theObject = theObject.GetMesh()
2296 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2297 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2299 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2300 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2303 ## Generates new elements by extrusion of the elements which belong to the object
2304 # @param theObject object which elements should be processed
2305 # @param StepVector vector, defining the direction and value of extrusion
2306 # @param NbOfSteps the number of steps
2307 # @param MakeGroups forces the generation of new groups from existing ones
2308 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2309 # @ingroup l2_modif_extrurev
2310 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2311 if ( isinstance( theObject, Mesh )):
2312 theObject = theObject.GetMesh()
2313 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2314 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2316 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2317 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2320 ## Generates new elements by extrusion of the given elements
2321 # The path of extrusion must be a meshed edge.
2322 # @param IDsOfElements ids of elements
2323 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2324 # @param PathShape shape(edge) defines the sub-mesh for the path
2325 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2326 # @param HasAngles allows the shape to be rotated around the path
2327 # to get the resulting mesh in a helical fashion
2328 # @param Angles list of angles
2329 # @param HasRefPoint allows using the reference point
2330 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2331 # The User can specify any point as the Reference Point.
2332 # @param MakeGroups forces the generation of new groups from existing ones
2333 # @param LinearVariation forces the computation of rotation angles as linear
2334 # variation of the given Angles along path steps
2335 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2336 # only SMESH::Extrusion_Error otherwise
2337 # @ingroup l2_modif_extrurev
2338 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2339 HasAngles, Angles, HasRefPoint, RefPoint,
2340 MakeGroups=False, LinearVariation=False):
2341 if IDsOfElements == []:
2342 IDsOfElements = self.GetElementsId()
2343 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2344 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2346 if ( isinstance( PathMesh, Mesh )):
2347 PathMesh = PathMesh.GetMesh()
2348 if HasAngles and Angles and LinearVariation:
2349 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2352 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2353 PathShape, NodeStart, HasAngles,
2354 Angles, HasRefPoint, RefPoint)
2355 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2356 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2358 ## Generates new elements by extrusion of the elements which belong to the object
2359 # The path of extrusion must be a meshed edge.
2360 # @param theObject the object which elements should be processed
2361 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2362 # @param PathShape shape(edge) defines the sub-mesh for the path
2363 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2364 # @param HasAngles allows the shape to be rotated around the path
2365 # to get the resulting mesh in a helical fashion
2366 # @param Angles list of angles
2367 # @param HasRefPoint allows using the reference point
2368 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2369 # The User can specify any point as the Reference Point.
2370 # @param MakeGroups forces the generation of new groups from existing ones
2371 # @param LinearVariation forces the computation of rotation angles as linear
2372 # variation of the given Angles along path steps
2373 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2374 # only SMESH::Extrusion_Error otherwise
2375 # @ingroup l2_modif_extrurev
2376 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2377 HasAngles, Angles, HasRefPoint, RefPoint,
2378 MakeGroups=False, LinearVariation=False):
2379 if ( isinstance( theObject, Mesh )):
2380 theObject = theObject.GetMesh()
2381 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2382 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2383 if ( isinstance( PathMesh, Mesh )):
2384 PathMesh = PathMesh.GetMesh()
2385 if HasAngles and Angles and LinearVariation:
2386 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2389 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2390 PathShape, NodeStart, HasAngles,
2391 Angles, HasRefPoint, RefPoint)
2392 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2393 NodeStart, HasAngles, Angles, HasRefPoint,
2396 ## Creates a symmetrical copy of mesh elements
2397 # @param IDsOfElements list of elements ids
2398 # @param Mirror is AxisStruct or geom object(point, line, plane)
2399 # @param theMirrorType is POINT, AXIS or PLANE
2400 # If the Mirror is a geom object this parameter is unnecessary
2401 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2402 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2403 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2404 # @ingroup l2_modif_trsf
2405 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2406 if IDsOfElements == []:
2407 IDsOfElements = self.GetElementsId()
2408 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2409 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2410 if Copy and MakeGroups:
2411 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2412 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2415 ## Creates a new mesh by a symmetrical copy of mesh elements
2416 # @param IDsOfElements the list of elements ids
2417 # @param Mirror is AxisStruct or geom object (point, line, plane)
2418 # @param theMirrorType is POINT, AXIS or PLANE
2419 # If the Mirror is a geom object this parameter is unnecessary
2420 # @param MakeGroups to generate new groups from existing ones
2421 # @param NewMeshName a name of the new mesh to create
2422 # @return instance of Mesh class
2423 # @ingroup l2_modif_trsf
2424 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2425 if IDsOfElements == []:
2426 IDsOfElements = self.GetElementsId()
2427 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2428 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2429 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2430 MakeGroups, NewMeshName)
2431 return Mesh(self.smeshpyD,self.geompyD,mesh)
2433 ## Creates a symmetrical copy of the object
2434 # @param theObject mesh, submesh or group
2435 # @param Mirror AxisStruct or geom object (point, line, plane)
2436 # @param theMirrorType is POINT, AXIS or PLANE
2437 # If the Mirror is a geom object this parameter is unnecessary
2438 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2439 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2440 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2441 # @ingroup l2_modif_trsf
2442 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2443 if ( isinstance( theObject, Mesh )):
2444 theObject = theObject.GetMesh()
2445 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2446 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2447 if Copy and MakeGroups:
2448 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2449 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2452 ## Creates a new mesh by a symmetrical copy of the object
2453 # @param theObject mesh, submesh or group
2454 # @param Mirror AxisStruct or geom object (point, line, plane)
2455 # @param theMirrorType POINT, AXIS or PLANE
2456 # If the Mirror is a geom object this parameter is unnecessary
2457 # @param MakeGroups forces the generation of new groups from existing ones
2458 # @param NewMeshName the name of the new mesh to create
2459 # @return instance of Mesh class
2460 # @ingroup l2_modif_trsf
2461 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2462 if ( isinstance( theObject, Mesh )):
2463 theObject = theObject.GetMesh()
2464 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2465 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2466 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2467 MakeGroups, NewMeshName)
2468 return Mesh( self.smeshpyD,self.geompyD,mesh )
2470 ## Translates the elements
2471 # @param IDsOfElements list of elements ids
2472 # @param Vector the direction of translation (DirStruct or vector)
2473 # @param Copy allows copying the translated elements
2474 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2476 # @ingroup l2_modif_trsf
2477 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2478 if IDsOfElements == []:
2479 IDsOfElements = self.GetElementsId()
2480 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2481 Vector = self.smeshpyD.GetDirStruct(Vector)
2482 if Copy and MakeGroups:
2483 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2484 self.editor.Translate(IDsOfElements, Vector, Copy)
2487 ## Creates a new mesh of translated elements
2488 # @param IDsOfElements list of elements ids
2489 # @param Vector the direction of translation (DirStruct or vector)
2490 # @param MakeGroups forces the generation of new groups from existing ones
2491 # @param NewMeshName the name of the newly created mesh
2492 # @return instance of Mesh class
2493 # @ingroup l2_modif_trsf
2494 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2495 if IDsOfElements == []:
2496 IDsOfElements = self.GetElementsId()
2497 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2498 Vector = self.smeshpyD.GetDirStruct(Vector)
2499 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2500 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2502 ## Translates the object
2503 # @param theObject the object to translate (mesh, submesh, or group)
2504 # @param Vector direction of translation (DirStruct or geom vector)
2505 # @param Copy allows copying the translated elements
2506 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2507 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2508 # @ingroup l2_modif_trsf
2509 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2510 if ( isinstance( theObject, Mesh )):
2511 theObject = theObject.GetMesh()
2512 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2513 Vector = self.smeshpyD.GetDirStruct(Vector)
2514 if Copy and MakeGroups:
2515 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2516 self.editor.TranslateObject(theObject, Vector, Copy)
2519 ## Creates a new mesh from the translated object
2520 # @param theObject the object to translate (mesh, submesh, or group)
2521 # @param Vector the direction of translation (DirStruct or geom vector)
2522 # @param MakeGroups forces the generation of new groups from existing ones
2523 # @param NewMeshName the name of the newly created mesh
2524 # @return instance of Mesh class
2525 # @ingroup l2_modif_trsf
2526 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2527 if (isinstance(theObject, Mesh)):
2528 theObject = theObject.GetMesh()
2529 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2530 Vector = self.smeshpyD.GetDirStruct(Vector)
2531 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2532 return Mesh( self.smeshpyD, self.geompyD, mesh )
2534 ## Rotates the elements
2535 # @param IDsOfElements list of elements ids
2536 # @param Axis the axis of rotation (AxisStruct or geom line)
2537 # @param AngleInRadians the angle of rotation (in radians)
2538 # @param Copy allows copying the rotated elements
2539 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2540 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2541 # @ingroup l2_modif_trsf
2542 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2543 if IDsOfElements == []:
2544 IDsOfElements = self.GetElementsId()
2545 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2546 Axis = self.smeshpyD.GetAxisStruct(Axis)
2547 if Copy and MakeGroups:
2548 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2549 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2552 ## Creates a new mesh of rotated elements
2553 # @param IDsOfElements list of element ids
2554 # @param Axis the axis of rotation (AxisStruct or geom line)
2555 # @param AngleInRadians the angle of rotation (in radians)
2556 # @param MakeGroups forces the generation of new groups from existing ones
2557 # @param NewMeshName the name of the newly created mesh
2558 # @return instance of Mesh class
2559 # @ingroup l2_modif_trsf
2560 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2561 if IDsOfElements == []:
2562 IDsOfElements = self.GetElementsId()
2563 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2564 Axis = self.smeshpyD.GetAxisStruct(Axis)
2565 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2566 MakeGroups, NewMeshName)
2567 return Mesh( self.smeshpyD, self.geompyD, mesh )
2569 ## Rotates the object
2570 # @param theObject the object to rotate( mesh, submesh, or group)
2571 # @param Axis the axis of rotation (AxisStruct or geom line)
2572 # @param AngleInRadians the angle of rotation (in radians)
2573 # @param Copy allows copying the rotated elements
2574 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2575 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2576 # @ingroup l2_modif_trsf
2577 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2578 if (isinstance(theObject, Mesh)):
2579 theObject = theObject.GetMesh()
2580 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2581 Axis = self.smeshpyD.GetAxisStruct(Axis)
2582 if Copy and MakeGroups:
2583 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2584 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2587 ## Creates a new mesh from the rotated object
2588 # @param theObject the object to rotate (mesh, submesh, or group)
2589 # @param Axis the axis of rotation (AxisStruct or geom line)
2590 # @param AngleInRadians the angle of rotation (in radians)
2591 # @param MakeGroups forces the generation of new groups from existing ones
2592 # @param NewMeshName the name of the newly created mesh
2593 # @return instance of Mesh class
2594 # @ingroup l2_modif_trsf
2595 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2596 if (isinstance( theObject, Mesh )):
2597 theObject = theObject.GetMesh()
2598 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2599 Axis = self.smeshpyD.GetAxisStruct(Axis)
2600 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2601 MakeGroups, NewMeshName)
2602 return Mesh( self.smeshpyD, self.geompyD, mesh )
2604 ## Finds groups of ajacent nodes within Tolerance.
2605 # @param Tolerance the value of tolerance
2606 # @return the list of groups of nodes
2607 # @ingroup l2_modif_trsf
2608 def FindCoincidentNodes (self, Tolerance):
2609 return self.editor.FindCoincidentNodes(Tolerance)
2611 ## Finds groups of ajacent nodes within Tolerance.
2612 # @param Tolerance the value of tolerance
2613 # @param SubMeshOrGroup SubMesh or Group
2614 # @return the list of groups of nodes
2615 # @ingroup l2_modif_trsf
2616 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2617 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2620 # @param GroupsOfNodes the list of groups of nodes
2621 # @ingroup l2_modif_trsf
2622 def MergeNodes (self, GroupsOfNodes):
2623 self.editor.MergeNodes(GroupsOfNodes)
2625 ## Finds the elements built on the same nodes.
2626 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2627 # @return a list of groups of equal elements
2628 # @ingroup l2_modif_trsf
2629 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2630 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2632 ## Merges elements in each given group.
2633 # @param GroupsOfElementsID groups of elements for merging
2634 # @ingroup l2_modif_trsf
2635 def MergeElements(self, GroupsOfElementsID):
2636 self.editor.MergeElements(GroupsOfElementsID)
2638 ## Leaves one element and removes all other elements built on the same nodes.
2639 # @ingroup l2_modif_trsf
2640 def MergeEqualElements(self):
2641 self.editor.MergeEqualElements()
2643 ## Sews free borders
2644 # @return SMESH::Sew_Error
2645 # @ingroup l2_modif_trsf
2646 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2647 FirstNodeID2, SecondNodeID2, LastNodeID2,
2648 CreatePolygons, CreatePolyedrs):
2649 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2650 FirstNodeID2, SecondNodeID2, LastNodeID2,
2651 CreatePolygons, CreatePolyedrs)
2653 ## Sews conform free borders
2654 # @return SMESH::Sew_Error
2655 # @ingroup l2_modif_trsf
2656 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2657 FirstNodeID2, SecondNodeID2):
2658 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2659 FirstNodeID2, SecondNodeID2)
2661 ## Sews border to side
2662 # @return SMESH::Sew_Error
2663 # @ingroup l2_modif_trsf
2664 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2665 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2666 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2667 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2669 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2670 # merged with the nodes of elements of Side2.
2671 # The number of elements in theSide1 and in theSide2 must be
2672 # equal and they should have similar nodal connectivity.
2673 # The nodes to merge should belong to side borders and
2674 # the first node should be linked to the second.
2675 # @return SMESH::Sew_Error
2676 # @ingroup l2_modif_trsf
2677 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2678 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2679 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2680 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2681 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2682 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2684 ## Sets new nodes for the given element.
2685 # @param ide the element id
2686 # @param newIDs nodes ids
2687 # @return If the number of nodes does not correspond to the type of element - returns false
2688 # @ingroup l2_modif_edit
2689 def ChangeElemNodes(self, ide, newIDs):
2690 return self.editor.ChangeElemNodes(ide, newIDs)
2692 ## If during the last operation of MeshEditor some nodes were
2693 # created, this method returns the list of their IDs, \n
2694 # if new nodes were not created - returns empty list
2695 # @return the list of integer values (can be empty)
2696 # @ingroup l1_auxiliary
2697 def GetLastCreatedNodes(self):
2698 return self.editor.GetLastCreatedNodes()
2700 ## If during the last operation of MeshEditor some elements were
2701 # created this method returns the list of their IDs, \n
2702 # if new elements were not created - returns empty list
2703 # @return the list of integer values (can be empty)
2704 # @ingroup l1_auxiliary
2705 def GetLastCreatedElems(self):
2706 return self.editor.GetLastCreatedElems()
2708 ## The mother class to define algorithm, it is not recommended to use it directly.
2711 # @ingroup l2_algorithms
2712 class Mesh_Algorithm:
2713 # @class Mesh_Algorithm
2714 # @brief Class Mesh_Algorithm
2716 #def __init__(self,smesh):
2724 ## Finds a hypothesis in the study by its type name and parameters.
2725 # Finds only the hypotheses created in smeshpyD engine.
2726 # @return SMESH.SMESH_Hypothesis
2727 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2728 study = smeshpyD.GetCurrentStudy()
2729 #to do: find component by smeshpyD object, not by its data type
2730 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2731 if scomp is not None:
2732 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2733 # Check if the root label of the hypotheses exists
2734 if res and hypRoot is not None:
2735 iter = study.NewChildIterator(hypRoot)
2736 # Check all published hypotheses
2738 hypo_so_i = iter.Value()
2739 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2740 if attr is not None:
2741 anIOR = attr.Value()
2742 hypo_o_i = salome.orb.string_to_object(anIOR)
2743 if hypo_o_i is not None:
2744 # Check if this is a hypothesis
2745 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2746 if hypo_i is not None:
2747 # Check if the hypothesis belongs to current engine
2748 if smeshpyD.GetObjectId(hypo_i) > 0:
2749 # Check if this is the required hypothesis
2750 if hypo_i.GetName() == hypname:
2752 if CompareMethod(hypo_i, args):
2766 ## Finds the algorithm in the study by its type name.
2767 # Finds only the algorithms, which have been created in smeshpyD engine.
2768 # @return SMESH.SMESH_Algo
2769 def FindAlgorithm (self, algoname, smeshpyD):
2770 study = smeshpyD.GetCurrentStudy()
2771 #to do: find component by smeshpyD object, not by its data type
2772 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2773 if scomp is not None:
2774 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2775 # Check if the root label of the algorithms exists
2776 if res and hypRoot is not None:
2777 iter = study.NewChildIterator(hypRoot)
2778 # Check all published algorithms
2780 algo_so_i = iter.Value()
2781 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2782 if attr is not None:
2783 anIOR = attr.Value()
2784 algo_o_i = salome.orb.string_to_object(anIOR)
2785 if algo_o_i is not None:
2786 # Check if this is an algorithm
2787 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2788 if algo_i is not None:
2789 # Checks if the algorithm belongs to the current engine
2790 if smeshpyD.GetObjectId(algo_i) > 0:
2791 # Check if this is the required algorithm
2792 if algo_i.GetName() == algoname:
2805 ## If the algorithm is global, returns 0; \n
2806 # else returns the submesh associated to this algorithm.
2807 def GetSubMesh(self):
2810 ## Returns the wrapped mesher.
2811 def GetAlgorithm(self):
2814 ## Gets the list of hypothesis that can be used with this algorithm
2815 def GetCompatibleHypothesis(self):
2818 mylist = self.algo.GetCompatibleHypothesis()
2821 ## Gets the name of the algorithm
2825 ## Sets the name to the algorithm
2826 def SetName(self, name):
2827 SetName(self.algo, name)
2829 ## Gets the id of the algorithm
2831 return self.algo.GetId()
2834 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2836 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2837 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2839 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2841 self.Assign(algo, mesh, geom)
2845 def Assign(self, algo, mesh, geom):
2847 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2854 name = GetName(geom)
2856 name = mesh.geompyD.SubShapeName(geom, piece)
2857 mesh.geompyD.addToStudyInFather(piece, geom, name)
2858 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2861 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2862 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2864 def CompareHyp (self, hyp, args):
2865 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2868 def CompareEqualHyp (self, hyp, args):
2872 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2873 UseExisting=0, CompareMethod=""):
2876 if CompareMethod == "": CompareMethod = self.CompareHyp
2877 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2880 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2886 a = a + s + str(args[i])
2890 SetName(hypo, hyp + a)
2893 if isinstance(hypo,BaseWrapper):
2894 bhypo = hypo.GetAlgorithm()
2897 status = self.mesh.mesh.AddHypothesis(self.geom, bhypo)
2898 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2902 # Public class: Mesh_Segment
2903 # --------------------------
2905 ## Class to define a segment 1D algorithm for discretization
2908 # @ingroup l3_algos_basic
2909 class Mesh_Segment(Mesh_Algorithm):
2911 ## Private constructor.
2912 def __init__(self, mesh, geom=0):
2913 Mesh_Algorithm.__init__(self)
2914 self.Create(mesh, geom, "Regular_1D")
2916 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2917 # @param l for the length of segments that cut an edge
2918 # @param UseExisting if ==true - searches for an existing hypothesis created with
2919 # the same parameters, else (default) - creates a new one
2920 # @param p precision, used for calculation of the number of segments.
2921 # The precision should be a positive, meaningful value within the range [0,1].
2922 # In general, the number of segments is calculated with the formula:
2923 # nb = ceil((edge_length / l) - p)
2924 # Function ceil rounds its argument to the higher integer.
2925 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2926 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2927 # p=1 means rounding of (edge_length / l) to the lower integer.
2928 # Default value is 1e-07.
2929 # @return an instance of StdMeshers_LocalLength hypothesis
2930 # @ingroup l3_hypos_1dhyps
2931 def LocalLength(self, l, UseExisting=0, p=1e-07):
2932 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2933 CompareMethod=self.CompareLocalLength)
2939 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2940 def CompareLocalLength(self, hyp, args):
2941 if IsEqual(hyp.GetLength(), args[0]):
2942 return IsEqual(hyp.GetPrecision(), args[1])
2945 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2946 # @param n for the number of segments that cut an edge
2947 # @param s for the scale factor (optional)
2948 # @param UseExisting if ==true - searches for an existing hypothesis created with
2949 # the same parameters, else (default) - create a new one
2950 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2951 # @ingroup l3_hypos_1dhyps
2952 def NumberOfSegments(self, n, s=[], UseExisting=0):
2954 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2955 CompareMethod=self.CompareNumberOfSegments)
2957 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2958 CompareMethod=self.CompareNumberOfSegments)
2959 hyp.SetDistrType( 1 )
2960 hyp.SetScaleFactor(s)
2961 hyp.SetNumberOfSegments(n)
2965 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2966 def CompareNumberOfSegments(self, hyp, args):
2967 if hyp.GetNumberOfSegments() == args[0]:
2971 if hyp.GetDistrType() == 1:
2972 if IsEqual(hyp.GetScaleFactor(), args[1]):
2976 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2977 # @param start defines the length of the first segment
2978 # @param end defines the length of the last segment
2979 # @param UseExisting if ==true - searches for an existing hypothesis created with
2980 # the same parameters, else (default) - creates a new one
2981 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2982 # @ingroup l3_hypos_1dhyps
2983 def Arithmetic1D(self, start, end, UseExisting=0):
2984 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2985 CompareMethod=self.CompareArithmetic1D)
2986 hyp.SetLength(start, 1)
2987 hyp.SetLength(end , 0)
2991 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2992 def CompareArithmetic1D(self, hyp, args):
2993 if IsEqual(hyp.GetLength(1), args[0]):
2994 if IsEqual(hyp.GetLength(0), args[1]):
2998 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2999 # @param start defines the length of the first segment
3000 # @param end defines the length of the last segment
3001 # @param UseExisting if ==true - searches for an existing hypothesis created with
3002 # the same parameters, else (default) - creates a new one
3003 # @return an instance of StdMeshers_StartEndLength hypothesis
3004 # @ingroup l3_hypos_1dhyps
3005 def StartEndLength(self, start, end, UseExisting=0):
3006 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3007 CompareMethod=self.CompareStartEndLength)
3008 hyp.SetLength(start, 1)
3009 hyp.SetLength(end , 0)
3012 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3013 def CompareStartEndLength(self, hyp, args):
3014 if IsEqual(hyp.GetLength(1), args[0]):
3015 if IsEqual(hyp.GetLength(0), args[1]):
3019 ## Defines "Deflection1D" hypothesis
3020 # @param d for the deflection
3021 # @param UseExisting if ==true - searches for an existing hypothesis created with
3022 # the same parameters, else (default) - create a new one
3023 # @ingroup l3_hypos_1dhyps
3024 def Deflection1D(self, d, UseExisting=0):
3025 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3026 CompareMethod=self.CompareDeflection1D)
3027 hyp.SetDeflection(d)
3030 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3031 def CompareDeflection1D(self, hyp, args):
3032 return IsEqual(hyp.GetDeflection(), args[0])
3034 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3035 # the opposite side in case of quadrangular faces
3036 # @ingroup l3_hypos_additi
3037 def Propagation(self):
3038 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3040 ## Defines "AutomaticLength" hypothesis
3041 # @param fineness for the fineness [0-1]
3042 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3043 # same parameters, else (default) - create a new one
3044 # @ingroup l3_hypos_1dhyps
3045 def AutomaticLength(self, fineness=0, UseExisting=0):
3046 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3047 CompareMethod=self.CompareAutomaticLength)
3048 hyp.SetFineness( fineness )
3051 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3052 def CompareAutomaticLength(self, hyp, args):
3053 return IsEqual(hyp.GetFineness(), args[0])
3055 ## Defines "SegmentLengthAroundVertex" hypothesis
3056 # @param length for the segment length
3057 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3058 # Any other integer value means that the hypothesis will be set on the
3059 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3060 # @param UseExisting if ==true - searches for an existing hypothesis created with
3061 # the same parameters, else (default) - creates a new one
3062 # @ingroup l3_algos_segmarv
3063 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3065 store_geom = self.geom
3066 if type(vertex) is types.IntType:
3067 if vertex == 0 or vertex == 1:
3068 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3076 if self.geom is None:
3077 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3078 name = GetName(self.geom)
3080 piece = self.mesh.geom
3081 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3082 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3083 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3085 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3087 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3088 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3090 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3091 CompareMethod=self.CompareLengthNearVertex)
3092 self.geom = store_geom
3093 hyp.SetLength( length )
3096 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3097 # @ingroup l3_algos_segmarv
3098 def CompareLengthNearVertex(self, hyp, args):
3099 return IsEqual(hyp.GetLength(), args[0])
3101 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3102 # If the 2D mesher sees that all boundary edges are quadratic,
3103 # it generates quadratic faces, else it generates linear faces using
3104 # medium nodes as if they are vertices.
3105 # The 3D mesher generates quadratic volumes only if all boundary faces
3106 # are quadratic, else it fails.
3108 # @ingroup l3_hypos_additi
3109 def QuadraticMesh(self):
3110 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3113 # Public class: Mesh_CompositeSegment
3114 # --------------------------
3116 ## Defines a segment 1D algorithm for discretization
3118 # @ingroup l3_algos_basic
3119 class Mesh_CompositeSegment(Mesh_Segment):
3121 ## Private constructor.
3122 def __init__(self, mesh, geom=0):
3123 self.Create(mesh, geom, "CompositeSegment_1D")
3126 # Public class: Mesh_Segment_Python
3127 # ---------------------------------
3129 ## Defines a segment 1D algorithm for discretization with python function
3131 # @ingroup l3_algos_basic
3132 class Mesh_Segment_Python(Mesh_Segment):
3134 ## Private constructor.
3135 def __init__(self, mesh, geom=0):
3136 import Python1dPlugin
3137 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3139 ## Defines "PythonSplit1D" hypothesis
3140 # @param n for the number of segments that cut an edge
3141 # @param func for the python function that calculates the length of all segments
3142 # @param UseExisting if ==true - searches for the existing hypothesis created with
3143 # the same parameters, else (default) - creates a new one
3144 # @ingroup l3_hypos_1dhyps
3145 def PythonSplit1D(self, n, func, UseExisting=0):
3146 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3147 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3148 hyp.SetNumberOfSegments(n)
3149 hyp.SetPythonLog10RatioFunction(func)
3152 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3153 def ComparePythonSplit1D(self, hyp, args):
3154 #if hyp.GetNumberOfSegments() == args[0]:
3155 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3159 # Public class: Mesh_Triangle
3160 # ---------------------------
3162 ## Defines a triangle 2D algorithm
3164 # @ingroup l3_algos_basic
3165 class Mesh_Triangle(Mesh_Algorithm):
3174 ## Private constructor.
3175 def __init__(self, mesh, algoType, geom=0):
3176 Mesh_Algorithm.__init__(self)
3178 self.algoType = algoType
3179 if algoType == MEFISTO:
3180 self.Create(mesh, geom, "MEFISTO_2D")
3182 elif algoType == BLSURF:
3184 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3185 #self.SetPhysicalMesh() - PAL19680
3186 elif algoType == NETGEN:
3188 print "Warning: NETGENPlugin module unavailable"
3190 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3192 elif algoType == NETGEN_2D:
3194 print "Warning: NETGENPlugin module unavailable"
3196 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3199 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3200 # @param area for the maximum area of each triangle
3201 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3202 # same parameters, else (default) - creates a new one
3204 # Only for algoType == MEFISTO || NETGEN_2D
3205 # @ingroup l3_hypos_2dhyps
3206 def MaxElementArea(self, area, UseExisting=0):
3207 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3208 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3209 CompareMethod=self.CompareMaxElementArea)
3210 elif self.algoType == NETGEN:
3211 hyp = self.Parameters(SIMPLE)
3212 hyp.SetMaxElementArea(area)
3215 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3216 def CompareMaxElementArea(self, hyp, args):
3217 return IsEqual(hyp.GetMaxElementArea(), args[0])
3219 ## Defines "LengthFromEdges" hypothesis to build triangles
3220 # based on the length of the edges taken from the wire
3222 # Only for algoType == MEFISTO || NETGEN_2D
3223 # @ingroup l3_hypos_2dhyps
3224 def LengthFromEdges(self):
3225 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3226 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3228 elif self.algoType == NETGEN:
3229 hyp = self.Parameters(SIMPLE)
3230 hyp.LengthFromEdges()
3233 ## Sets a way to define size of mesh elements to generate.
3234 # @param thePhysicalMesh is: DefaultSize or Custom.
3235 # @ingroup l3_hypos_blsurf
3236 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3237 # Parameter of BLSURF algo
3238 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3240 ## Sets size of mesh elements to generate.
3241 # @ingroup l3_hypos_blsurf
3242 def SetPhySize(self, theVal):
3243 # Parameter of BLSURF algo
3244 self.Parameters().SetPhySize(theVal)
3246 ## Sets lower boundary of mesh element size (PhySize).
3247 # @ingroup l3_hypos_blsurf
3248 def SetPhyMin(self, theVal=-1):
3249 # Parameter of BLSURF algo
3250 self.Parameters().SetPhyMin(theVal)
3252 ## Sets upper boundary of mesh element size (PhySize).
3253 # @ingroup l3_hypos_blsurf
3254 def SetPhyMax(self, theVal=-1):
3255 # Parameter of BLSURF algo
3256 self.Parameters().SetPhyMax(theVal)
3258 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3259 # @param theGeometricMesh is: DefaultGeom or Custom
3260 # @ingroup l3_hypos_blsurf
3261 def SetGeometricMesh(self, theGeometricMesh=0):
3262 # Parameter of BLSURF algo
3263 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3264 self.params.SetGeometricMesh(theGeometricMesh)
3266 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3267 # @ingroup l3_hypos_blsurf
3268 def SetAngleMeshS(self, theVal=_angleMeshS):
3269 # Parameter of BLSURF algo
3270 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3271 self.params.SetAngleMeshS(theVal)
3273 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3274 # @ingroup l3_hypos_blsurf
3275 def SetAngleMeshC(self, theVal=_angleMeshS):
3276 # Parameter of BLSURF algo
3277 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3278 self.params.SetAngleMeshC(theVal)
3280 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3281 # @ingroup l3_hypos_blsurf
3282 def SetGeoMin(self, theVal=-1):
3283 # Parameter of BLSURF algo
3284 self.Parameters().SetGeoMin(theVal)
3286 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3287 # @ingroup l3_hypos_blsurf
3288 def SetGeoMax(self, theVal=-1):
3289 # Parameter of BLSURF algo
3290 self.Parameters().SetGeoMax(theVal)
3292 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3293 # @ingroup l3_hypos_blsurf
3294 def SetGradation(self, theVal=_gradation):
3295 # Parameter of BLSURF algo
3296 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3297 self.params.SetGradation(theVal)
3299 ## Sets topology usage way.
3300 # @param way defines how mesh conformity is assured <ul>
3301 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3302 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3303 # @ingroup l3_hypos_blsurf
3304 def SetTopology(self, way):
3305 # Parameter of BLSURF algo
3306 self.Parameters().SetTopology(way)
3308 ## To respect geometrical edges or not.
3309 # @ingroup l3_hypos_blsurf
3310 def SetDecimesh(self, toIgnoreEdges=False):
3311 # Parameter of BLSURF algo
3312 self.Parameters().SetDecimesh(toIgnoreEdges)
3314 ## Sets verbosity level in the range 0 to 100.
3315 # @ingroup l3_hypos_blsurf
3316 def SetVerbosity(self, level):
3317 # Parameter of BLSURF algo
3318 self.Parameters().SetVerbosity(level)
3320 ## Sets advanced option value.
3321 # @ingroup l3_hypos_blsurf
3322 def SetOptionValue(self, optionName, level):
3323 # Parameter of BLSURF algo
3324 self.Parameters().SetOptionValue(optionName,level)
3326 ## Sets QuadAllowed flag.
3327 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3328 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3329 def SetQuadAllowed(self, toAllow=True):
3330 if self.algoType == NETGEN_2D:
3331 if toAllow: # add QuadranglePreference
3332 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3333 else: # remove QuadranglePreference
3334 for hyp in self.mesh.GetHypothesisList( self.geom ):
3335 if hyp.GetName() == "QuadranglePreference":
3336 self.mesh.RemoveHypothesis( self.geom, hyp )
3341 if self.Parameters():
3342 self.params.SetQuadAllowed(toAllow)
3345 ## Defines hypothesis having several parameters
3347 # @ingroup l3_hypos_netgen
3348 def Parameters(self, which=SOLE):
3351 if self.algoType == NETGEN:
3353 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3354 "libNETGENEngine.so", UseExisting=0)
3356 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3357 "libNETGENEngine.so", UseExisting=0)
3359 elif self.algoType == MEFISTO:
3360 print "Mefisto algo support no multi-parameter hypothesis"
3362 elif self.algoType == NETGEN_2D:
3363 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3364 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3366 elif self.algoType == BLSURF:
3367 self.params = self.Hypothesis("BLSURF_Parameters", [],
3368 "libBLSURFEngine.so", UseExisting=0)
3371 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3376 # Only for algoType == NETGEN
3377 # @ingroup l3_hypos_netgen
3378 def SetMaxSize(self, theSize):
3379 if self.Parameters():
3380 self.params.SetMaxSize(theSize)
3382 ## Sets SecondOrder flag
3384 # Only for algoType == NETGEN
3385 # @ingroup l3_hypos_netgen
3386 def SetSecondOrder(self, theVal):
3387 if self.Parameters():
3388 self.params.SetSecondOrder(theVal)
3390 ## Sets Optimize flag
3392 # Only for algoType == NETGEN
3393 # @ingroup l3_hypos_netgen
3394 def SetOptimize(self, theVal):
3395 if self.Parameters():
3396 self.params.SetOptimize(theVal)
3399 # @param theFineness is:
3400 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3402 # Only for algoType == NETGEN
3403 # @ingroup l3_hypos_netgen
3404 def SetFineness(self, theFineness):
3405 if self.Parameters():
3406 self.params.SetFineness(theFineness)
3410 # Only for algoType == NETGEN
3411 # @ingroup l3_hypos_netgen
3412 def SetGrowthRate(self, theRate):
3413 if self.Parameters():
3414 self.params.SetGrowthRate(theRate)
3416 ## Sets NbSegPerEdge
3418 # Only for algoType == NETGEN
3419 # @ingroup l3_hypos_netgen
3420 def SetNbSegPerEdge(self, theVal):
3421 if self.Parameters():
3422 self.params.SetNbSegPerEdge(theVal)
3424 ## Sets NbSegPerRadius
3426 # Only for algoType == NETGEN
3427 # @ingroup l3_hypos_netgen
3428 def SetNbSegPerRadius(self, theVal):
3429 if self.Parameters():
3430 self.params.SetNbSegPerRadius(theVal)
3432 ## Sets number of segments overriding value set by SetLocalLength()
3434 # Only for algoType == NETGEN
3435 # @ingroup l3_hypos_netgen
3436 def SetNumberOfSegments(self, theVal):
3437 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3439 ## Sets number of segments overriding value set by SetNumberOfSegments()
3441 # Only for algoType == NETGEN
3442 # @ingroup l3_hypos_netgen
3443 def SetLocalLength(self, theVal):
3444 self.Parameters(SIMPLE).SetLocalLength(theVal)
3449 # Public class: Mesh_Quadrangle
3450 # -----------------------------
3452 ## Defines a quadrangle 2D algorithm
3454 # @ingroup l3_algos_basic
3455 class Mesh_Quadrangle(Mesh_Algorithm):
3457 ## Private constructor.
3458 def __init__(self, mesh, geom=0):
3459 Mesh_Algorithm.__init__(self)
3460 self.Create(mesh, geom, "Quadrangle_2D")
3462 ## Defines "QuadranglePreference" hypothesis, forcing construction
3463 # of quadrangles if the number of nodes on the opposite edges is not the same
3464 # while the total number of nodes on edges is even
3466 # @ingroup l3_hypos_additi
3467 def QuadranglePreference(self):
3468 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3469 CompareMethod=self.CompareEqualHyp)
3472 ## Defines "TrianglePreference" hypothesis, forcing construction
3473 # of triangles in the refinement area if the number of nodes
3474 # on the opposite edges is not the same
3476 # @ingroup l3_hypos_additi
3477 def TrianglePreference(self):
3478 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3479 CompareMethod=self.CompareEqualHyp)
3482 # Public class: Mesh_Tetrahedron
3483 # ------------------------------
3485 ## Defines a tetrahedron 3D algorithm
3487 # @ingroup l3_algos_basic
3488 class Mesh_Tetrahedron(Mesh_Algorithm):
3493 ## Private constructor.
3494 def __init__(self, mesh, algoType, geom=0):
3495 Mesh_Algorithm.__init__(self)
3497 if algoType == NETGEN:
3498 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3501 elif algoType == FULL_NETGEN:
3503 print "Warning: NETGENPlugin module has not been imported."
3504 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3507 elif algoType == GHS3D:
3509 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3512 self.algoType = algoType
3514 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3515 # @param vol for the maximum volume of each tetrahedron
3516 # @param UseExisting if ==true - searches for the existing hypothesis created with
3517 # the same parameters, else (default) - creates a new one
3518 # @ingroup l3_hypos_maxvol
3519 def MaxElementVolume(self, vol, UseExisting=0):
3520 if self.algoType == NETGEN:
3521 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3522 CompareMethod=self.CompareMaxElementVolume)
3523 hyp.SetMaxElementVolume(vol)
3525 elif self.algoType == FULL_NETGEN:
3526 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3529 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3530 def CompareMaxElementVolume(self, hyp, args):
3531 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3533 ## Defines hypothesis having several parameters
3535 # @ingroup l3_hypos_netgen
3536 def Parameters(self, which=SOLE):
3539 if self.algoType == FULL_NETGEN:
3541 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3542 "libNETGENEngine.so", UseExisting=0)
3544 self.params = self.Hypothesis("NETGEN_Parameters", [],
3545 "libNETGENEngine.so", UseExisting=0)
3547 if self.algoType == GHS3D:
3548 self.params = self.Hypothesis("GHS3D_Parameters", [],
3549 "libGHS3DEngine.so", UseExisting=0)
3552 print "Algo supports no multi-parameter hypothesis"
3556 # Parameter of FULL_NETGEN
3557 # @ingroup l3_hypos_netgen
3558 def SetMaxSize(self, theSize):
3559 self.Parameters().SetMaxSize(theSize)
3561 ## Sets SecondOrder flag
3562 # Parameter of FULL_NETGEN
3563 # @ingroup l3_hypos_netgen
3564 def SetSecondOrder(self, theVal):
3565 self.Parameters().SetSecondOrder(theVal)
3567 ## Sets Optimize flag
3568 # Parameter of FULL_NETGEN
3569 # @ingroup l3_hypos_netgen
3570 def SetOptimize(self, theVal):
3571 self.Parameters().SetOptimize(theVal)
3574 # @param theFineness is:
3575 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3576 # Parameter of FULL_NETGEN
3577 # @ingroup l3_hypos_netgen
3578 def SetFineness(self, theFineness):
3579 self.Parameters().SetFineness(theFineness)
3582 # Parameter of FULL_NETGEN
3583 # @ingroup l3_hypos_netgen
3584 def SetGrowthRate(self, theRate):
3585 self.Parameters().SetGrowthRate(theRate)
3587 ## Sets NbSegPerEdge
3588 # Parameter of FULL_NETGEN
3589 # @ingroup l3_hypos_netgen
3590 def SetNbSegPerEdge(self, theVal):
3591 self.Parameters().SetNbSegPerEdge(theVal)
3593 ## Sets NbSegPerRadius
3594 # Parameter of FULL_NETGEN
3595 # @ingroup l3_hypos_netgen
3596 def SetNbSegPerRadius(self, theVal):
3597 self.Parameters().SetNbSegPerRadius(theVal)
3599 ## Sets number of segments overriding value set by SetLocalLength()
3600 # Only for algoType == NETGEN_FULL
3601 # @ingroup l3_hypos_netgen
3602 def SetNumberOfSegments(self, theVal):
3603 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3605 ## Sets number of segments overriding value set by SetNumberOfSegments()
3606 # Only for algoType == NETGEN_FULL
3607 # @ingroup l3_hypos_netgen
3608 def SetLocalLength(self, theVal):
3609 self.Parameters(SIMPLE).SetLocalLength(theVal)
3611 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3612 # Overrides value set by LengthFromEdges()
3613 # Only for algoType == NETGEN_FULL
3614 # @ingroup l3_hypos_netgen
3615 def MaxElementArea(self, area):
3616 self.Parameters(SIMPLE).SetMaxElementArea(area)
3618 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3619 # Overrides value set by MaxElementArea()
3620 # Only for algoType == NETGEN_FULL
3621 # @ingroup l3_hypos_netgen
3622 def LengthFromEdges(self):
3623 self.Parameters(SIMPLE).LengthFromEdges()
3625 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3626 # Overrides value set by MaxElementVolume()
3627 # Only for algoType == NETGEN_FULL
3628 # @ingroup l3_hypos_netgen
3629 def LengthFromFaces(self):
3630 self.Parameters(SIMPLE).LengthFromFaces()
3632 ## To mesh "holes" in a solid or not. Default is to mesh.
3633 # @ingroup l3_hypos_ghs3dh
3634 def SetToMeshHoles(self, toMesh):
3635 # Parameter of GHS3D
3636 self.Parameters().SetToMeshHoles(toMesh)
3638 ## Set Optimization level:
3639 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3640 # Default is Medium_Optimization
3641 # @ingroup l3_hypos_ghs3dh
3642 def SetOptimizationLevel(self, level):
3643 # Parameter of GHS3D
3644 self.Parameters().SetOptimizationLevel(level)
3646 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3647 # @ingroup l3_hypos_ghs3dh
3648 def SetMaximumMemory(self, MB):
3649 # Advanced parameter of GHS3D
3650 self.Parameters().SetMaximumMemory(MB)
3652 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3653 # automatic memory adjustment mode.
3654 # @ingroup l3_hypos_ghs3dh
3655 def SetInitialMemory(self, MB):
3656 # Advanced parameter of GHS3D
3657 self.Parameters().SetInitialMemory(MB)
3659 ## Path to working directory.
3660 # @ingroup l3_hypos_ghs3dh
3661 def SetWorkingDirectory(self, path):
3662 # Advanced parameter of GHS3D
3663 self.Parameters().SetWorkingDirectory(path)
3665 ## To keep working files or remove them. Log file remains in case of errors anyway.
3666 # @ingroup l3_hypos_ghs3dh
3667 def SetKeepFiles(self, toKeep):
3668 # Advanced parameter of GHS3D
3669 self.Parameters().SetKeepFiles(toKeep)
3671 ## To set verbose level [0-10]. <ul>
3672 #<li> 0 - no standard output,
3673 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3674 # indicates when the final mesh is being saved. In addition the software
3675 # gives indication regarding the CPU time.
3676 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3677 # histogram of the skin mesh, quality statistics histogram together with
3678 # the characteristics of the final mesh.</ul>
3679 # @ingroup l3_hypos_ghs3dh
3680 def SetVerboseLevel(self, level):
3681 # Advanced parameter of GHS3D
3682 self.Parameters().SetVerboseLevel(level)
3684 ## To create new nodes.
3685 # @ingroup l3_hypos_ghs3dh
3686 def SetToCreateNewNodes(self, toCreate):
3687 # Advanced parameter of GHS3D
3688 self.Parameters().SetToCreateNewNodes(toCreate)
3690 ## To use boundary recovery version which tries to create mesh on a very poor
3691 # quality surface mesh.
3692 # @ingroup l3_hypos_ghs3dh
3693 def SetToUseBoundaryRecoveryVersion(self, toUse):
3694 # Advanced parameter of GHS3D
3695 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3697 ## Sets command line option as text.
3698 # @ingroup l3_hypos_ghs3dh
3699 def SetTextOption(self, option):
3700 # Advanced parameter of GHS3D
3701 self.Parameters().SetTextOption(option)
3703 # Public class: Mesh_Hexahedron
3704 # ------------------------------
3706 ## Defines a hexahedron 3D algorithm
3708 # @ingroup l3_algos_basic
3709 class Mesh_Hexahedron(Mesh_Algorithm):
3714 ## Private constructor.
3715 def __init__(self, mesh, algoType=Hexa, geom=0):
3716 Mesh_Algorithm.__init__(self)
3718 self.algoType = algoType
3720 if algoType == Hexa:
3721 self.Create(mesh, geom, "Hexa_3D")
3724 elif algoType == Hexotic:
3725 import HexoticPlugin
3726 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3729 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3730 # @ingroup l3_hypos_hexotic
3731 def MinMaxQuad(self, min=3, max=8, quad=True):
3732 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3734 self.params.SetHexesMinLevel(min)
3735 self.params.SetHexesMaxLevel(max)
3736 self.params.SetHexoticQuadrangles(quad)
3739 # Deprecated, only for compatibility!
3740 # Public class: Mesh_Netgen
3741 # ------------------------------
3743 ## Defines a NETGEN-based 2D or 3D algorithm
3744 # that needs no discrete boundary (i.e. independent)
3746 # This class is deprecated, only for compatibility!
3749 # @ingroup l3_algos_basic
3750 class Mesh_Netgen(Mesh_Algorithm):
3754 ## Private constructor.
3755 def __init__(self, mesh, is3D, geom=0):
3756 Mesh_Algorithm.__init__(self)
3759 print "Warning: NETGENPlugin module has not been imported."
3763 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3767 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3770 ## Defines the hypothesis containing parameters of the algorithm
3771 def Parameters(self):
3773 hyp = self.Hypothesis("NETGEN_Parameters", [],
3774 "libNETGENEngine.so", UseExisting=0)
3776 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3777 "libNETGENEngine.so", UseExisting=0)
3780 # Public class: Mesh_Projection1D
3781 # ------------------------------
3783 ## Defines a projection 1D algorithm
3784 # @ingroup l3_algos_proj
3786 class Mesh_Projection1D(Mesh_Algorithm):
3788 ## Private constructor.
3789 def __init__(self, mesh, geom=0):
3790 Mesh_Algorithm.__init__(self)
3791 self.Create(mesh, geom, "Projection_1D")
3793 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3794 # a mesh pattern is taken, and, optionally, the association of vertices
3795 # between the source edge and a target edge (to which a hypothesis is assigned)
3796 # @param edge from which nodes distribution is taken
3797 # @param mesh from which nodes distribution is taken (optional)
3798 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3799 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3800 # to associate with \a srcV (optional)
3801 # @param UseExisting if ==true - searches for the existing hypothesis created with
3802 # the same parameters, else (default) - creates a new one
3803 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3804 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3806 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3807 hyp.SetSourceEdge( edge )
3808 if not mesh is None and isinstance(mesh, Mesh):
3809 mesh = mesh.GetMesh()
3810 hyp.SetSourceMesh( mesh )
3811 hyp.SetVertexAssociation( srcV, tgtV )
3814 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3815 #def CompareSourceEdge(self, hyp, args):
3816 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3820 # Public class: Mesh_Projection2D
3821 # ------------------------------
3823 ## Defines a projection 2D algorithm
3824 # @ingroup l3_algos_proj
3826 class Mesh_Projection2D(Mesh_Algorithm):
3828 ## Private constructor.
3829 def __init__(self, mesh, geom=0):
3830 Mesh_Algorithm.__init__(self)
3831 self.Create(mesh, geom, "Projection_2D")
3833 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3834 # a mesh pattern is taken, and, optionally, the association of vertices
3835 # between the source face and the target face (to which a hypothesis is assigned)
3836 # @param face from which the mesh pattern is taken
3837 # @param mesh from which the mesh pattern is taken (optional)
3838 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3839 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3840 # to associate with \a srcV1 (optional)
3841 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3842 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3843 # to associate with \a srcV2 (optional)
3844 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3845 # the same parameters, else (default) - forces the creation a new one
3847 # Note: all association vertices must belong to one edge of a face
3848 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3849 srcV2=None, tgtV2=None, UseExisting=0):
3850 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3852 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3853 hyp.SetSourceFace( face )
3854 if not mesh is None and isinstance(mesh, Mesh):
3855 mesh = mesh.GetMesh()
3856 hyp.SetSourceMesh( mesh )
3857 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3860 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3861 #def CompareSourceFace(self, hyp, args):
3862 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3865 # Public class: Mesh_Projection3D
3866 # ------------------------------
3868 ## Defines a projection 3D algorithm
3869 # @ingroup l3_algos_proj
3871 class Mesh_Projection3D(Mesh_Algorithm):
3873 ## Private constructor.
3874 def __init__(self, mesh, geom=0):
3875 Mesh_Algorithm.__init__(self)
3876 self.Create(mesh, geom, "Projection_3D")
3878 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3879 # the mesh pattern is taken, and, optionally, the association of vertices
3880 # between the source and the target solid (to which a hipothesis is assigned)
3881 # @param solid from where the mesh pattern is taken
3882 # @param mesh from where the mesh pattern is taken (optional)
3883 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3884 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3885 # to associate with \a srcV1 (optional)
3886 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3887 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3888 # to associate with \a srcV2 (optional)
3889 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3890 # the same parameters, else (default) - creates a new one
3892 # Note: association vertices must belong to one edge of a solid
3893 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3894 srcV2=0, tgtV2=0, UseExisting=0):
3895 hyp = self.Hypothesis("ProjectionSource3D",
3896 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3898 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3899 hyp.SetSource3DShape( solid )
3900 if not mesh is None and isinstance(mesh, Mesh):
3901 mesh = mesh.GetMesh()
3902 hyp.SetSourceMesh( mesh )
3903 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3906 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3907 #def CompareSourceShape3D(self, hyp, args):
3908 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3912 # Public class: Mesh_Prism
3913 # ------------------------
3915 ## Defines a 3D extrusion algorithm
3916 # @ingroup l3_algos_3dextr
3918 class Mesh_Prism3D(Mesh_Algorithm):
3920 ## Private constructor.
3921 def __init__(self, mesh, geom=0):
3922 Mesh_Algorithm.__init__(self)
3923 self.Create(mesh, geom, "Prism_3D")
3925 # Public class: Mesh_RadialPrism
3926 # -------------------------------
3928 ## Defines a Radial Prism 3D algorithm
3929 # @ingroup l3_algos_radialp
3931 class Mesh_RadialPrism3D(Mesh_Algorithm):
3933 ## Private constructor.
3934 def __init__(self, mesh, geom=0):
3935 Mesh_Algorithm.__init__(self)
3936 self.Create(mesh, geom, "RadialPrism_3D")
3938 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3939 self.nbLayers = None
3941 ## Return 3D hypothesis holding the 1D one
3942 def Get3DHypothesis(self):
3943 return self.distribHyp
3945 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3946 # hypothesis. Returns the created hypothesis
3947 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3948 #print "OwnHypothesis",hypType
3949 if not self.nbLayers is None:
3950 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3951 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3952 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3953 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3954 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3955 self.distribHyp.SetLayerDistribution( hyp )
3958 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3959 # prisms to build between the inner and outer shells
3960 # @param n number of layers
3961 # @param UseExisting if ==true - searches for the existing hypothesis created with
3962 # the same parameters, else (default) - creates a new one
3963 def NumberOfLayers(self, n, UseExisting=0):
3964 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3965 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3966 CompareMethod=self.CompareNumberOfLayers)
3967 self.nbLayers.SetNumberOfLayers( n )
3968 return self.nbLayers
3970 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3971 def CompareNumberOfLayers(self, hyp, args):
3972 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3974 ## Defines "LocalLength" hypothesis, specifying the segment length
3975 # to build between the inner and the outer shells
3976 # @param l the length of segments
3977 # @param p the precision of rounding
3978 def LocalLength(self, l, p=1e-07):
3979 hyp = self.OwnHypothesis("LocalLength", [l,p])
3984 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3985 # prisms to build between the inner and the outer shells.
3986 # @param n the number of layers
3987 # @param s the scale factor (optional)
3988 def NumberOfSegments(self, n, s=[]):
3990 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3992 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3993 hyp.SetDistrType( 1 )
3994 hyp.SetScaleFactor(s)
3995 hyp.SetNumberOfSegments(n)
3998 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3999 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4000 # @param start the length of the first segment
4001 # @param end the length of the last segment
4002 def Arithmetic1D(self, start, end ):
4003 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4004 hyp.SetLength(start, 1)
4005 hyp.SetLength(end , 0)
4008 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4009 # to build between the inner and the outer shells as geometric length increasing
4010 # @param start for the length of the first segment
4011 # @param end for the length of the last segment
4012 def StartEndLength(self, start, end):
4013 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4014 hyp.SetLength(start, 1)
4015 hyp.SetLength(end , 0)
4018 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4019 # to build between the inner and outer shells
4020 # @param fineness defines the quality of the mesh within the range [0-1]
4021 def AutomaticLength(self, fineness=0):
4022 hyp = self.OwnHypothesis("AutomaticLength")
4023 hyp.SetFineness( fineness )
4026 # Private class: Mesh_UseExisting
4027 # -------------------------------
4028 class Mesh_UseExisting(Mesh_Algorithm):
4030 def __init__(self, dim, mesh, geom=0):
4032 self.Create(mesh, geom, "UseExisting_1D")
4034 self.Create(mesh, geom, "UseExisting_2D")
4039 from salome_notebook import *
4041 ##Base class for wrap all StdMeshers interfaces
4044 ##Return instance of a _objref_StdMeshers hypothesis
4045 def GetAlgorithm(self):
4048 ##Return values of the notebook variables
4049 def ParseParameters(self, params ,nbParams, nbParam, arg):
4053 if isinstance(arg, str):
4054 if notebook.isVariable(arg):
4055 result = notebook.get(arg)
4063 paramsList = params.split(":")
4066 for n in range(1,nbParams+1):
4067 if n != nbParam and not isEmpty and len(paramsList[n-1])> 0:
4068 strResult = paramsList[n-1] + ":"
4070 if isVar and n == nbParam:
4071 if len(strResult) == 0 and nbParam != 1:
4072 strResult = strResult + ":"
4074 strResult = strResult+arg
4076 strResult = strResult + ":"
4078 return result, strResult
4081 #Wrapper class for StdMeshers_LocalLength hypothesis
4082 class LocalLength(BaseWrapper):
4083 def __init__(self, hypo):
4086 def SetLength(self, length):
4087 length,parameters = self.ParseParameters(self.hypo.GetParameters(),2,1,length)
4088 self.hypo.SetParameters(parameters)
4089 self.hypo.SetLength(length)
4091 def SetPrecision(self, precision):
4092 precision,parameters = self.ParseParameters(self.hypo.GetParameters(),2,2,precision)
4093 self.hypo.SetParameters(parameters)
4094 self.hypo.SetPrecision(precision)
4096 def GetLength(self):
4097 return self.hypo.GetLength()
4099 def GetPrecision(self):
4100 return self.hypo.GetLength()