1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 def IsEqual(val1, val2, tol=PrecisionConfusion):
159 if abs(val1 - val2) < tol:
167 ior = salome.orb.object_to_string(obj)
168 sobj = salome.myStudy.FindObjectIOR(ior)
172 attr = sobj.FindAttribute("AttributeName")[1]
175 ## Prints error message if a hypothesis was not assigned.
176 def TreatHypoStatus(status, hypName, geomName, isAlgo):
178 hypType = "algorithm"
180 hypType = "hypothesis"
182 if status == HYP_UNKNOWN_FATAL :
183 reason = "for unknown reason"
184 elif status == HYP_INCOMPATIBLE :
185 reason = "this hypothesis mismatches the algorithm"
186 elif status == HYP_NOTCONFORM :
187 reason = "a non-conform mesh would be built"
188 elif status == HYP_ALREADY_EXIST :
189 reason = hypType + " of the same dimension is already assigned to this shape"
190 elif status == HYP_BAD_DIM :
191 reason = hypType + " mismatches the shape"
192 elif status == HYP_CONCURENT :
193 reason = "there are concurrent hypotheses on sub-shapes"
194 elif status == HYP_BAD_SUBSHAPE :
195 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
196 elif status == HYP_BAD_GEOMETRY:
197 reason = "geometry mismatches the expectation of the algorithm"
198 elif status == HYP_HIDDEN_ALGO:
199 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
200 elif status == HYP_HIDING_ALGO:
201 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
202 elif status == HYP_NEED_SHAPE:
203 reason = "Algorithm can't work without shape"
206 hypName = '"' + hypName + '"'
207 geomName= '"' + geomName+ '"'
208 if status < HYP_UNKNOWN_FATAL:
209 print hypName, "was assigned to", geomName,"but", reason
211 print hypName, "was not assigned to",geomName,":", reason
214 ## Converts an angle from degrees to radians
215 def DegreesToRadians(AngleInDegrees):
217 return AngleInDegrees * pi / 180.0
219 # end of l1_auxiliary
222 # All methods of this class are accessible directly from the smesh.py package.
223 class smeshDC(SMESH._objref_SMESH_Gen):
225 ## Sets the current study and Geometry component
226 # @ingroup l1_auxiliary
227 def init_smesh(self,theStudy,geompyD):
228 self.SetCurrentStudy(theStudy,geompyD)
230 ## Creates an empty Mesh. This mesh can have an underlying geometry.
231 # @param obj the Geometrical object on which the mesh is built. If not defined,
232 # the mesh will have no underlying geometry.
233 # @param name the name for the new mesh.
234 # @return an instance of Mesh class.
235 # @ingroup l2_construct
236 def Mesh(self, obj=0, name=0):
237 return Mesh(self,self.geompyD,obj,name)
239 ## Returns a long value from enumeration
240 # Should be used for SMESH.FunctorType enumeration
241 # @ingroup l1_controls
242 def EnumToLong(self,theItem):
245 ## Gets PointStruct from vertex
246 # @param theVertex a GEOM object(vertex)
247 # @return SMESH.PointStruct
248 # @ingroup l1_auxiliary
249 def GetPointStruct(self,theVertex):
250 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
251 return PointStruct(x,y,z)
253 ## Gets DirStruct from vector
254 # @param theVector a GEOM object(vector)
255 # @return SMESH.DirStruct
256 # @ingroup l1_auxiliary
257 def GetDirStruct(self,theVector):
258 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
259 if(len(vertices) != 2):
260 print "Error: vector object is incorrect."
262 p1 = self.geompyD.PointCoordinates(vertices[0])
263 p2 = self.geompyD.PointCoordinates(vertices[1])
264 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
265 dirst = DirStruct(pnt)
268 ## Makes DirStruct from a triplet
269 # @param x,y,z vector components
270 # @return SMESH.DirStruct
271 # @ingroup l1_auxiliary
272 def MakeDirStruct(self,x,y,z):
273 pnt = PointStruct(x,y,z)
274 return DirStruct(pnt)
276 ## Get AxisStruct from object
277 # @param theObj a GEOM object (line or plane)
278 # @return SMESH.AxisStruct
279 # @ingroup l1_auxiliary
280 def GetAxisStruct(self,theObj):
281 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
283 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
284 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
285 vertex1 = self.geompyD.PointCoordinates(vertex1)
286 vertex2 = self.geompyD.PointCoordinates(vertex2)
287 vertex3 = self.geompyD.PointCoordinates(vertex3)
288 vertex4 = self.geompyD.PointCoordinates(vertex4)
289 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
290 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
291 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] ]
292 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
294 elif len(edges) == 1:
295 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
296 p1 = self.geompyD.PointCoordinates( vertex1 )
297 p2 = self.geompyD.PointCoordinates( vertex2 )
298 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
302 # From SMESH_Gen interface:
303 # ------------------------
305 ## Sets the given name to the object
306 # @param obj the object to rename
307 # @param name a new object name
308 # @ingroup l1_auxiliary
309 def SetName(self, obj, name):
310 print "obj_name = ", name
311 if isinstance( obj, Mesh ):
313 elif isinstance( obj, Mesh_Algorithm ):
314 obj = obj.GetAlgorithm()
315 ior = salome.orb.object_to_string(obj)
316 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
318 ## Sets the current mode
319 # @ingroup l1_auxiliary
320 def SetEmbeddedMode( self,theMode ):
321 #self.SetEmbeddedMode(theMode)
322 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
324 ## Gets the current mode
325 # @ingroup l1_auxiliary
326 def IsEmbeddedMode(self):
327 #return self.IsEmbeddedMode()
328 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
330 ## Sets the current study
331 # @ingroup l1_auxiliary
332 def SetCurrentStudy( self, theStudy, geompyD = None ):
333 #self.SetCurrentStudy(theStudy)
336 geompyD = geompy.geom
339 self.SetGeomEngine(geompyD)
340 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
342 ## Gets the current study
343 # @ingroup l1_auxiliary
344 def GetCurrentStudy(self):
345 #return self.GetCurrentStudy()
346 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
348 ## Creates a Mesh object importing data from the given UNV file
349 # @return an instance of Mesh class
351 def CreateMeshesFromUNV( self,theFileName ):
352 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
353 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
356 ## Creates a Mesh object(s) importing data from the given MED file
357 # @return a list of Mesh class instances
359 def CreateMeshesFromMED( self,theFileName ):
360 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
362 for iMesh in range(len(aSmeshMeshes)) :
363 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
364 aMeshes.append(aMesh)
365 return aMeshes, aStatus
367 ## Creates a Mesh object importing data from the given STL file
368 # @return an instance of Mesh class
370 def CreateMeshesFromSTL( self, theFileName ):
371 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
372 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
375 ## Concatenate the given meshes into one mesh.
376 # @return an instance of Mesh class
377 # @param meshes the meshes to combine into one mesh
378 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
379 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
380 # @param mergeTolerance tolerance for merging nodes
381 # @param allGroups forces creation of groups of all elements
382 def Concatenate( self, meshes, uniteIdenticalGroups,
383 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
385 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
386 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
388 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
389 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
390 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
393 ## From SMESH_Gen interface
394 # @return the list of integer values
395 # @ingroup l1_auxiliary
396 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
397 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
399 ## From SMESH_Gen interface. Creates a pattern
400 # @return an instance of SMESH_Pattern
402 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
403 # @ingroup l2_modif_patterns
404 def GetPattern(self):
405 return SMESH._objref_SMESH_Gen.GetPattern(self)
407 ## Sets number of segments per diagonal of boundary box of geometry by which
408 # default segment length of appropriate 1D hypotheses is defined.
409 # Default value is 10
410 # @ingroup l1_auxiliary
411 def SetBoundaryBoxSegmentation(self, nbSegments):
412 #return self.GetCurrentStudy()
413 return SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
416 # Filtering. Auxiliary functions:
417 # ------------------------------
419 ## Creates an empty criterion
420 # @return SMESH.Filter.Criterion
421 # @ingroup l1_controls
422 def GetEmptyCriterion(self):
423 Type = self.EnumToLong(FT_Undefined)
424 Compare = self.EnumToLong(FT_Undefined)
428 UnaryOp = self.EnumToLong(FT_Undefined)
429 BinaryOp = self.EnumToLong(FT_Undefined)
432 Precision = -1 ##@1e-07
433 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
434 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
436 ## Creates a criterion by the given parameters
437 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
438 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
439 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
440 # @param Treshold the threshold value (range of ids as string, shape, numeric)
441 # @param UnaryOp FT_LogicalNOT or FT_Undefined
442 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
443 # FT_Undefined (must be for the last criterion of all criteria)
444 # @return SMESH.Filter.Criterion
445 # @ingroup l1_controls
446 def GetCriterion(self,elementType,
448 Compare = FT_EqualTo,
450 UnaryOp=FT_Undefined,
451 BinaryOp=FT_Undefined):
452 aCriterion = self.GetEmptyCriterion()
453 aCriterion.TypeOfElement = elementType
454 aCriterion.Type = self.EnumToLong(CritType)
458 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
459 aCriterion.Compare = self.EnumToLong(Compare)
460 elif Compare == "=" or Compare == "==":
461 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
463 aCriterion.Compare = self.EnumToLong(FT_LessThan)
465 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
467 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
470 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
471 FT_BelongToCylinder, FT_LyingOnGeom]:
472 # Checks the treshold
473 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
474 aCriterion.ThresholdStr = GetName(aTreshold)
475 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
477 print "Error: The treshold should be a shape."
479 elif CritType == FT_RangeOfIds:
480 # Checks the treshold
481 if isinstance(aTreshold, str):
482 aCriterion.ThresholdStr = aTreshold
484 print "Error: The treshold should be a string."
486 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
487 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
488 # At this point the treshold is unnecessary
489 if aTreshold == FT_LogicalNOT:
490 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
491 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
492 aCriterion.BinaryOp = aTreshold
496 aTreshold = float(aTreshold)
497 aCriterion.Threshold = aTreshold
499 print "Error: The treshold should be a number."
502 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
503 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
505 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
506 aCriterion.BinaryOp = self.EnumToLong(Treshold)
508 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
509 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
511 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
512 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
516 ## Creates a filter with the given parameters
517 # @param elementType the type of elements in the group
518 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
519 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
520 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
521 # @param UnaryOp FT_LogicalNOT or FT_Undefined
522 # @return SMESH_Filter
523 # @ingroup l1_controls
524 def GetFilter(self,elementType,
525 CritType=FT_Undefined,
528 UnaryOp=FT_Undefined):
529 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
530 aFilterMgr = self.CreateFilterManager()
531 aFilter = aFilterMgr.CreateFilter()
533 aCriteria.append(aCriterion)
534 aFilter.SetCriteria(aCriteria)
537 ## Creates a numerical functor by its type
538 # @param theCriterion FT_...; functor type
539 # @return SMESH_NumericalFunctor
540 # @ingroup l1_controls
541 def GetFunctor(self,theCriterion):
542 aFilterMgr = self.CreateFilterManager()
543 if theCriterion == FT_AspectRatio:
544 return aFilterMgr.CreateAspectRatio()
545 elif theCriterion == FT_AspectRatio3D:
546 return aFilterMgr.CreateAspectRatio3D()
547 elif theCriterion == FT_Warping:
548 return aFilterMgr.CreateWarping()
549 elif theCriterion == FT_MinimumAngle:
550 return aFilterMgr.CreateMinimumAngle()
551 elif theCriterion == FT_Taper:
552 return aFilterMgr.CreateTaper()
553 elif theCriterion == FT_Skew:
554 return aFilterMgr.CreateSkew()
555 elif theCriterion == FT_Area:
556 return aFilterMgr.CreateArea()
557 elif theCriterion == FT_Volume3D:
558 return aFilterMgr.CreateVolume3D()
559 elif theCriterion == FT_MultiConnection:
560 return aFilterMgr.CreateMultiConnection()
561 elif theCriterion == FT_MultiConnection2D:
562 return aFilterMgr.CreateMultiConnection2D()
563 elif theCriterion == FT_Length:
564 return aFilterMgr.CreateLength()
565 elif theCriterion == FT_Length2D:
566 return aFilterMgr.CreateLength2D()
568 print "Error: given parameter is not numerucal functor type."
570 ## Creates hypothesis
573 # @return created hypothesis instance
574 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
575 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
578 #Registering the new proxy for SMESH_Gen
579 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
585 ## This class allows defining and managing a mesh.
586 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
587 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
588 # new nodes and elements and by changing the existing entities), to get information
589 # about a mesh and to export a mesh into different formats.
598 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
599 # sets the GUI name of this mesh to \a name.
600 # @param smeshpyD an instance of smeshDC class
601 # @param geompyD an instance of geompyDC class
602 # @param obj Shape to be meshed or SMESH_Mesh object
603 # @param name Study name of the mesh
604 # @ingroup l2_construct
605 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
606 self.smeshpyD=smeshpyD
611 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
613 self.mesh = self.smeshpyD.CreateMesh(self.geom)
614 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
617 self.mesh = self.smeshpyD.CreateEmptyMesh()
619 self.smeshpyD.SetName(self.mesh, name)
621 self.smeshpyD.SetName(self.mesh, GetName(obj))
624 self.geom = self.mesh.GetShapeToMesh()
626 self.editor = self.mesh.GetMeshEditor()
628 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
629 # @param theMesh a SMESH_Mesh object
630 # @ingroup l2_construct
631 def SetMesh(self, theMesh):
633 self.geom = self.mesh.GetShapeToMesh()
635 ## Returns the mesh, that is an instance of SMESH_Mesh interface
636 # @return a SMESH_Mesh object
637 # @ingroup l2_construct
641 ## Gets the name of the mesh
642 # @return the name of the mesh as a string
643 # @ingroup l2_construct
645 name = GetName(self.GetMesh())
648 ## Sets a name to the mesh
649 # @param name a new name of the mesh
650 # @ingroup l2_construct
651 def SetName(self, name):
652 self.smeshpyD.SetName(self.GetMesh(), name)
654 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
655 # The subMesh object gives access to the IDs of nodes and elements.
656 # @param theSubObject a geometrical object (shape)
657 # @param theName a name for the submesh
658 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
659 # @ingroup l2_submeshes
660 def GetSubMesh(self, theSubObject, theName):
661 submesh = self.mesh.GetSubMesh(theSubObject, theName)
664 ## Returns the shape associated to the mesh
665 # @return a GEOM_Object
666 # @ingroup l2_construct
670 ## Associates the given shape to the mesh (entails the recreation of the mesh)
671 # @param geom the shape to be meshed (GEOM_Object)
672 # @ingroup l2_construct
673 def SetShape(self, geom):
674 self.mesh = self.smeshpyD.CreateMesh(geom)
676 ## Returns true if the hypotheses are defined well
677 # @param theSubObject a subshape of a mesh shape
678 # @return True or False
679 # @ingroup l2_construct
680 def IsReadyToCompute(self, theSubObject):
681 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
683 ## Returns errors of hypotheses definition.
684 # The list of errors is empty if everything is OK.
685 # @param theSubObject a subshape of a mesh shape
686 # @return a list of errors
687 # @ingroup l2_construct
688 def GetAlgoState(self, theSubObject):
689 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
691 ## Returns a geometrical object on which the given element was built.
692 # The returned geometrical object, if not nil, is either found in the
693 # study or published by this method with the given name
694 # @param theElementID the id of the mesh element
695 # @param theGeomName the user-defined name of the geometrical object
696 # @return GEOM::GEOM_Object instance
697 # @ingroup l2_construct
698 def GetGeometryByMeshElement(self, theElementID, theGeomName):
699 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
701 ## Returns the mesh dimension depending on the dimension of the underlying shape
702 # @return mesh dimension as an integer value [0,3]
703 # @ingroup l1_auxiliary
704 def MeshDimension(self):
705 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
706 if len( shells ) > 0 :
708 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
710 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
716 ## Creates a segment discretization 1D algorithm.
717 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
718 # \n If the optional \a geom parameter is not set, this algorithm is global.
719 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
720 # @param algo the type of the required algorithm. Possible values are:
722 # - smesh.PYTHON for discretization via a python function,
723 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
724 # @param geom If defined is the subshape to be meshed
725 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
726 # @ingroup l3_algos_basic
727 def Segment(self, algo=REGULAR, geom=0):
728 ## if Segment(geom) is called by mistake
729 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
730 algo, geom = geom, algo
731 if not algo: algo = REGULAR
734 return Mesh_Segment(self, geom)
736 return Mesh_Segment_Python(self, geom)
737 elif algo == COMPOSITE:
738 return Mesh_CompositeSegment(self, geom)
740 return Mesh_Segment(self, geom)
742 ## Enables creation of nodes and segments usable by 2D algoritms.
743 # The added nodes and segments must be bound to edges and vertices by
744 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
745 # If the optional \a geom parameter is not set, this algorithm is global.
746 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
747 # @param geom the subshape to be manually meshed
748 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
749 # @ingroup l3_algos_basic
750 def UseExistingSegments(self, geom=0):
751 algo = Mesh_UseExisting(1,self,geom)
752 return algo.GetAlgorithm()
754 ## Enables creation of nodes and faces usable by 3D algoritms.
755 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
756 # and SetMeshElementOnShape()
757 # If the optional \a geom parameter is not set, this algorithm is global.
758 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
759 # @param geom the subshape to be manually meshed
760 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
761 # @ingroup l3_algos_basic
762 def UseExistingFaces(self, geom=0):
763 algo = Mesh_UseExisting(2,self,geom)
764 return algo.GetAlgorithm()
766 ## Creates a triangle 2D algorithm for faces.
767 # If the optional \a geom parameter is not set, this algorithm is global.
768 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
769 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
770 # @param geom If defined, the subshape to be meshed (GEOM_Object)
771 # @return an instance of Mesh_Triangle algorithm
772 # @ingroup l3_algos_basic
773 def Triangle(self, algo=MEFISTO, geom=0):
774 ## if Triangle(geom) is called by mistake
775 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
779 return Mesh_Triangle(self, algo, geom)
781 ## Creates a quadrangle 2D algorithm for faces.
782 # If the optional \a geom parameter is not set, this algorithm is global.
783 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
784 # @param geom If defined, the subshape to be meshed (GEOM_Object)
785 # @return an instance of Mesh_Quadrangle algorithm
786 # @ingroup l3_algos_basic
787 def Quadrangle(self, geom=0):
788 return Mesh_Quadrangle(self, geom)
790 ## Creates a tetrahedron 3D algorithm for solids.
791 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
792 # If the optional \a geom parameter is not set, this algorithm is global.
793 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
794 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
795 # @param geom If defined, the subshape to be meshed (GEOM_Object)
796 # @return an instance of Mesh_Tetrahedron algorithm
797 # @ingroup l3_algos_basic
798 def Tetrahedron(self, algo=NETGEN, geom=0):
799 ## if Tetrahedron(geom) is called by mistake
800 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
801 algo, geom = geom, algo
802 if not algo: algo = NETGEN
804 return Mesh_Tetrahedron(self, algo, geom)
806 ## Creates a hexahedron 3D algorithm for solids.
807 # If the optional \a geom parameter is not set, this algorithm is global.
808 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
809 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
810 # @param geom If defined, the subshape to be meshed (GEOM_Object)
811 # @return an instance of Mesh_Hexahedron algorithm
812 # @ingroup l3_algos_basic
813 def Hexahedron(self, algo=Hexa, geom=0):
814 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
815 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
816 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
817 elif geom == 0: algo, geom = Hexa, algo
818 return Mesh_Hexahedron(self, algo, geom)
820 ## Deprecated, used only for compatibility!
821 # @return an instance of Mesh_Netgen algorithm
822 # @ingroup l3_algos_basic
823 def Netgen(self, is3D, geom=0):
824 return Mesh_Netgen(self, is3D, geom)
826 ## Creates a projection 1D algorithm for edges.
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_Projection1D algorithm
831 # @ingroup l3_algos_proj
832 def Projection1D(self, geom=0):
833 return Mesh_Projection1D(self, geom)
835 ## Creates a projection 2D algorithm for faces.
836 # If the optional \a geom parameter is not set, this algorithm is global.
837 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
838 # @param geom If defined, the subshape to be meshed
839 # @return an instance of Mesh_Projection2D algorithm
840 # @ingroup l3_algos_proj
841 def Projection2D(self, geom=0):
842 return Mesh_Projection2D(self, geom)
844 ## Creates a projection 3D algorithm for solids.
845 # If the optional \a geom parameter is not set, this algorithm is global.
846 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
847 # @param geom If defined, the subshape to be meshed
848 # @return an instance of Mesh_Projection3D algorithm
849 # @ingroup l3_algos_proj
850 def Projection3D(self, geom=0):
851 return Mesh_Projection3D(self, geom)
853 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
854 # If the optional \a geom parameter is not set, this algorithm is global.
855 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
856 # @param geom If defined, the subshape to be meshed
857 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
858 # @ingroup l3_algos_radialp l3_algos_3dextr
859 def Prism(self, geom=0):
863 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
864 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
865 if nbSolids == 0 or nbSolids == nbShells:
866 return Mesh_Prism3D(self, geom)
867 return Mesh_RadialPrism3D(self, geom)
869 ## Computes the mesh and returns the status of the computation
870 # @return True or False
871 # @ingroup l2_construct
872 def Compute(self, geom=0):
873 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
875 geom = self.mesh.GetShapeToMesh()
880 ok = self.smeshpyD.Compute(self.mesh, geom)
881 except SALOME.SALOME_Exception, ex:
882 print "Mesh computation failed, exception caught:"
883 print " ", ex.details.text
886 print "Mesh computation failed, exception caught:"
887 traceback.print_exc()
889 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
900 reason = '%s %sD algorithm is missing' % (glob, dim)
901 elif err.state == HYP_MISSING:
902 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
903 % (glob, dim, name, dim))
904 elif err.state == HYP_NOTCONFORM:
905 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
906 elif err.state == HYP_BAD_PARAMETER:
907 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
908 % ( glob, dim, name ))
909 elif err.state == HYP_BAD_GEOMETRY:
910 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
911 'geometry' % ( glob, dim, name ))
913 reason = "For unknown reason."+\
914 " Revise Mesh.Compute() implementation in smeshDC.py!"
922 print '"' + GetName(self.mesh) + '"',"has not been computed:"
926 print '"' + GetName(self.mesh) + '"',"has not been computed."
929 if salome.sg.hasDesktop():
930 smeshgui = salome.ImportComponentGUI("SMESH")
931 smeshgui.Init(salome.myStudyId)
932 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
933 salome.sg.updateObjBrowser(1)
937 ## Removes all nodes and elements
938 # @ingroup l2_construct
941 if salome.sg.hasDesktop():
942 smeshgui = salome.ImportComponentGUI("SMESH")
943 smeshgui.Init(salome.myStudyId)
944 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
945 salome.sg.updateObjBrowser(1)
947 ## Removes all nodes and elements of indicated shape
948 # @ingroup l2_construct
949 def ClearSubMesh(self, geomId):
950 self.mesh.ClearSubMesh(geomId)
951 if salome.sg.hasDesktop():
952 smeshgui = salome.ImportComponentGUI("SMESH")
953 smeshgui.Init(salome.myStudyId)
954 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
955 salome.sg.updateObjBrowser(1)
957 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
958 # @param fineness [0,-1] defines mesh fineness
959 # @return True or False
960 # @ingroup l3_algos_basic
961 def AutomaticTetrahedralization(self, fineness=0):
962 dim = self.MeshDimension()
964 self.RemoveGlobalHypotheses()
965 self.Segment().AutomaticLength(fineness)
967 self.Triangle().LengthFromEdges()
970 self.Tetrahedron(NETGEN)
972 return self.Compute()
974 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
975 # @param fineness [0,-1] defines mesh fineness
976 # @return True or False
977 # @ingroup l3_algos_basic
978 def AutomaticHexahedralization(self, fineness=0):
979 dim = self.MeshDimension()
980 # assign the hypotheses
981 self.RemoveGlobalHypotheses()
982 self.Segment().AutomaticLength(fineness)
989 return self.Compute()
991 ## Assigns a hypothesis
992 # @param hyp a hypothesis to assign
993 # @param geom a subhape of mesh geometry
994 # @return SMESH.Hypothesis_Status
995 # @ingroup l2_hypotheses
996 def AddHypothesis(self, hyp, geom=0):
997 if isinstance( hyp, Mesh_Algorithm ):
998 hyp = hyp.GetAlgorithm()
1003 geom = self.mesh.GetShapeToMesh()
1005 status = self.mesh.AddHypothesis(geom, hyp)
1006 isAlgo = hyp._narrow( SMESH_Algo )
1007 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1010 ## Unassigns a hypothesis
1011 # @param hyp a hypothesis to unassign
1012 # @param geom a subshape of mesh geometry
1013 # @return SMESH.Hypothesis_Status
1014 # @ingroup l2_hypotheses
1015 def RemoveHypothesis(self, hyp, geom=0):
1016 if isinstance( hyp, Mesh_Algorithm ):
1017 hyp = hyp.GetAlgorithm()
1022 status = self.mesh.RemoveHypothesis(geom, hyp)
1025 ## Gets the list of hypotheses added on a geometry
1026 # @param geom a subshape of mesh geometry
1027 # @return the sequence of SMESH_Hypothesis
1028 # @ingroup l2_hypotheses
1029 def GetHypothesisList(self, geom):
1030 return self.mesh.GetHypothesisList( geom )
1032 ## Removes all global hypotheses
1033 # @ingroup l2_hypotheses
1034 def RemoveGlobalHypotheses(self):
1035 current_hyps = self.mesh.GetHypothesisList( self.geom )
1036 for hyp in current_hyps:
1037 self.mesh.RemoveHypothesis( self.geom, hyp )
1041 ## Creates a mesh group based on the geometric object \a grp
1042 # and gives a \a name, \n if this parameter is not defined
1043 # the name is the same as the geometric group name \n
1044 # Note: Works like GroupOnGeom().
1045 # @param grp a geometric group, a vertex, an edge, a face or a solid
1046 # @param name the name of the mesh group
1047 # @return SMESH_GroupOnGeom
1048 # @ingroup l2_grps_create
1049 def Group(self, grp, name=""):
1050 return self.GroupOnGeom(grp, name)
1052 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1053 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1054 # @param f the file name
1055 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1056 # @ingroup l2_impexp
1057 def ExportToMED(self, f, version, opt=0):
1058 self.mesh.ExportToMED(f, opt, version)
1060 ## Exports the mesh in a file in MED format
1061 # @param f is the file name
1062 # @param auto_groups boolean parameter for creating/not creating
1063 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1064 # the typical use is auto_groups=false.
1065 # @param version MED format version(MED_V2_1 or MED_V2_2)
1066 # @ingroup l2_impexp
1067 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1068 self.mesh.ExportToMED(f, auto_groups, version)
1070 ## Exports the mesh in a file in DAT format
1071 # @param f the file name
1072 # @ingroup l2_impexp
1073 def ExportDAT(self, f):
1074 self.mesh.ExportDAT(f)
1076 ## Exports the mesh in a file in UNV format
1077 # @param f the file name
1078 # @ingroup l2_impexp
1079 def ExportUNV(self, f):
1080 self.mesh.ExportUNV(f)
1082 ## Export the mesh in a file in STL format
1083 # @param f the file name
1084 # @param ascii defines the file encoding
1085 # @ingroup l2_impexp
1086 def ExportSTL(self, f, ascii=1):
1087 self.mesh.ExportSTL(f, ascii)
1090 # Operations with groups:
1091 # ----------------------
1093 ## Creates an empty mesh group
1094 # @param elementType the type of elements in the group
1095 # @param name the name of the mesh group
1096 # @return SMESH_Group
1097 # @ingroup l2_grps_create
1098 def CreateEmptyGroup(self, elementType, name):
1099 return self.mesh.CreateGroup(elementType, name)
1101 ## Creates a mesh group based on the geometrical object \a grp
1102 # and gives a \a name, \n if this parameter is not defined
1103 # the name is the same as the geometrical group name
1104 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1105 # @param name the name of the mesh group
1106 # @param typ the type of elements in the group. If not set, it is
1107 # automatically detected by the type of the geometry
1108 # @return SMESH_GroupOnGeom
1109 # @ingroup l2_grps_create
1110 def GroupOnGeom(self, grp, name="", typ=None):
1112 name = grp.GetName()
1115 tgeo = str(grp.GetShapeType())
1116 if tgeo == "VERTEX":
1118 elif tgeo == "EDGE":
1120 elif tgeo == "FACE":
1122 elif tgeo == "SOLID":
1124 elif tgeo == "SHELL":
1126 elif tgeo == "COMPOUND":
1127 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1128 print "Mesh.Group: empty geometric group", GetName( grp )
1130 tgeo = self.geompyD.GetType(grp)
1131 if tgeo == geompyDC.ShapeType["VERTEX"]:
1133 elif tgeo == geompyDC.ShapeType["EDGE"]:
1135 elif tgeo == geompyDC.ShapeType["FACE"]:
1137 elif tgeo == geompyDC.ShapeType["SOLID"]:
1141 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1144 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1146 ## Creates a mesh group by the given ids of elements
1147 # @param groupName the name of the mesh group
1148 # @param elementType the type of elements in the group
1149 # @param elemIDs the list of ids
1150 # @return SMESH_Group
1151 # @ingroup l2_grps_create
1152 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1153 group = self.mesh.CreateGroup(elementType, groupName)
1157 ## Creates a mesh group by the given conditions
1158 # @param groupName the name of the mesh group
1159 # @param elementType the type of elements in the group
1160 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1161 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1162 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1163 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1164 # @return SMESH_Group
1165 # @ingroup l2_grps_create
1169 CritType=FT_Undefined,
1172 UnaryOp=FT_Undefined):
1173 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1174 group = self.MakeGroupByCriterion(groupName, aCriterion)
1177 ## Creates a mesh group by the given criterion
1178 # @param groupName the name of the mesh group
1179 # @param Criterion the instance of Criterion class
1180 # @return SMESH_Group
1181 # @ingroup l2_grps_create
1182 def MakeGroupByCriterion(self, groupName, Criterion):
1183 aFilterMgr = self.smeshpyD.CreateFilterManager()
1184 aFilter = aFilterMgr.CreateFilter()
1186 aCriteria.append(Criterion)
1187 aFilter.SetCriteria(aCriteria)
1188 group = self.MakeGroupByFilter(groupName, aFilter)
1191 ## Creates a mesh group by the given criteria (list of criteria)
1192 # @param groupName the name of the mesh group
1193 # @param theCriteria the list of criteria
1194 # @return SMESH_Group
1195 # @ingroup l2_grps_create
1196 def MakeGroupByCriteria(self, groupName, theCriteria):
1197 aFilterMgr = self.smeshpyD.CreateFilterManager()
1198 aFilter = aFilterMgr.CreateFilter()
1199 aFilter.SetCriteria(theCriteria)
1200 group = self.MakeGroupByFilter(groupName, aFilter)
1203 ## Creates a mesh group by the given filter
1204 # @param groupName the name of the mesh group
1205 # @param theFilter the instance of Filter class
1206 # @return SMESH_Group
1207 # @ingroup l2_grps_create
1208 def MakeGroupByFilter(self, groupName, theFilter):
1209 anIds = theFilter.GetElementsId(self.mesh)
1210 anElemType = theFilter.GetElementType()
1211 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1214 ## Passes mesh elements through the given filter and return IDs of fitting elements
1215 # @param theFilter SMESH_Filter
1216 # @return a list of ids
1217 # @ingroup l1_controls
1218 def GetIdsFromFilter(self, theFilter):
1219 return theFilter.GetElementsId(self.mesh)
1221 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1222 # Returns a list of special structures (borders).
1223 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1224 # @ingroup l1_controls
1225 def GetFreeBorders(self):
1226 aFilterMgr = self.smeshpyD.CreateFilterManager()
1227 aPredicate = aFilterMgr.CreateFreeEdges()
1228 aPredicate.SetMesh(self.mesh)
1229 aBorders = aPredicate.GetBorders()
1233 # @ingroup l2_grps_delete
1234 def RemoveGroup(self, group):
1235 self.mesh.RemoveGroup(group)
1237 ## Removes a group with its contents
1238 # @ingroup l2_grps_delete
1239 def RemoveGroupWithContents(self, group):
1240 self.mesh.RemoveGroupWithContents(group)
1242 ## Gets the list of groups existing in the mesh
1243 # @return a sequence of SMESH_GroupBase
1244 # @ingroup l2_grps_create
1245 def GetGroups(self):
1246 return self.mesh.GetGroups()
1248 ## Gets the number of groups existing in the mesh
1249 # @return the quantity of groups as an integer value
1250 # @ingroup l2_grps_create
1252 return self.mesh.NbGroups()
1254 ## Gets the list of names of groups existing in the mesh
1255 # @return list of strings
1256 # @ingroup l2_grps_create
1257 def GetGroupNames(self):
1258 groups = self.GetGroups()
1260 for group in groups:
1261 names.append(group.GetName())
1264 ## Produces a union of two groups
1265 # A new group is created. All mesh elements that are
1266 # present in the initial groups are added to the new one
1267 # @return an instance of SMESH_Group
1268 # @ingroup l2_grps_operon
1269 def UnionGroups(self, group1, group2, name):
1270 return self.mesh.UnionGroups(group1, group2, name)
1272 ## Produces a union list of groups
1273 # New group is created. All mesh elements that are present in
1274 # initial groups are added to the new one
1275 # @return an instance of SMESH_Group
1276 # @ingroup l2_grps_operon
1277 def UnionListOfGroups(self, groups, name):
1278 return self.mesh.UnionListOfGroups(groups, name)
1280 ## Prodices an intersection of two groups
1281 # A new group is created. All mesh elements that are common
1282 # for the two initial groups are added to the new one.
1283 # @return an instance of SMESH_Group
1284 # @ingroup l2_grps_operon
1285 def IntersectGroups(self, group1, group2, name):
1286 return self.mesh.IntersectGroups(group1, group2, name)
1288 ## Produces an intersection of groups
1289 # New group is created. All mesh elements that are present in all
1290 # initial groups simultaneously are added to the new one
1291 # @return an instance of SMESH_Group
1292 # @ingroup l2_grps_operon
1293 def IntersectListOfGroups(self, groups, name):
1294 return self.mesh.IntersectListOfGroups(groups, name)
1296 ## Produces a cut of two groups
1297 # A new group is created. All mesh elements that are present in
1298 # the main group but are not present in the tool group are added to the new one
1299 # @return an instance of SMESH_Group
1300 # @ingroup l2_grps_operon
1301 def CutGroups(self, main_group, tool_group, name):
1302 return self.mesh.CutGroups(main_group, tool_group, name)
1304 ## Produces a cut of groups
1305 # A new group is created. All mesh elements that are present in main groups
1306 # but do not present in tool groups are added to the new one
1307 # @return an instance of SMESH_Group
1308 # @ingroup l2_grps_operon
1309 def CutListOfGroups(self, main_groups, tool_groups, name):
1310 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1312 ## Produces a group of elements with specified element type using list of existing groups
1313 # A new group is created. System
1314 # 1) extract all nodes on which groups elements are built
1315 # 2) combine all elements of specified dimension laying on these nodes
1316 # @return an instance of SMESH_Group
1317 # @ingroup l2_grps_operon
1318 def CreateDimGroup(self, groups, elem_type, name):
1319 return self.mesh.CreateDimGroup(groups, elem_type, name)
1322 ## Convert group on geom into standalone group
1323 # @ingroup l2_grps_delete
1324 def ConvertToStandalone(self, group):
1325 return self.mesh.ConvertToStandalone(group)
1327 # Get some info about mesh:
1328 # ------------------------
1330 ## Returns the log of nodes and elements added or removed
1331 # since the previous clear of the log.
1332 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1333 # @return list of log_block structures:
1338 # @ingroup l1_auxiliary
1339 def GetLog(self, clearAfterGet):
1340 return self.mesh.GetLog(clearAfterGet)
1342 ## Clears the log of nodes and elements added or removed since the previous
1343 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1344 # @ingroup l1_auxiliary
1346 self.mesh.ClearLog()
1348 ## Toggles auto color mode on the object.
1349 # @param theAutoColor the flag which toggles auto color mode.
1350 # @ingroup l1_auxiliary
1351 def SetAutoColor(self, theAutoColor):
1352 self.mesh.SetAutoColor(theAutoColor)
1354 ## Gets flag of object auto color mode.
1355 # @return True or False
1356 # @ingroup l1_auxiliary
1357 def GetAutoColor(self):
1358 return self.mesh.GetAutoColor()
1360 ## Gets the internal ID
1361 # @return integer value, which is the internal Id of the mesh
1362 # @ingroup l1_auxiliary
1364 return self.mesh.GetId()
1367 # @return integer value, which is the study Id of the mesh
1368 # @ingroup l1_auxiliary
1369 def GetStudyId(self):
1370 return self.mesh.GetStudyId()
1372 ## Checks the group names for duplications.
1373 # Consider the maximum group name length stored in MED file.
1374 # @return True or False
1375 # @ingroup l1_auxiliary
1376 def HasDuplicatedGroupNamesMED(self):
1377 return self.mesh.HasDuplicatedGroupNamesMED()
1379 ## Obtains the mesh editor tool
1380 # @return an instance of SMESH_MeshEditor
1381 # @ingroup l1_modifying
1382 def GetMeshEditor(self):
1383 return self.mesh.GetMeshEditor()
1386 # @return an instance of SALOME_MED::MESH
1387 # @ingroup l1_auxiliary
1388 def GetMEDMesh(self):
1389 return self.mesh.GetMEDMesh()
1392 # Get informations about mesh contents:
1393 # ------------------------------------
1395 ## Returns the number of nodes in the mesh
1396 # @return an integer value
1397 # @ingroup l1_meshinfo
1399 return self.mesh.NbNodes()
1401 ## Returns the number of elements in the mesh
1402 # @return an integer value
1403 # @ingroup l1_meshinfo
1404 def NbElements(self):
1405 return self.mesh.NbElements()
1407 ## Returns the number of edges in the mesh
1408 # @return an integer value
1409 # @ingroup l1_meshinfo
1411 return self.mesh.NbEdges()
1413 ## Returns the number of edges with the given order in the mesh
1414 # @param elementOrder the order of elements:
1415 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1416 # @return an integer value
1417 # @ingroup l1_meshinfo
1418 def NbEdgesOfOrder(self, elementOrder):
1419 return self.mesh.NbEdgesOfOrder(elementOrder)
1421 ## Returns the number of faces in the mesh
1422 # @return an integer value
1423 # @ingroup l1_meshinfo
1425 return self.mesh.NbFaces()
1427 ## Returns the number of faces with the given order in the mesh
1428 # @param elementOrder the order of elements:
1429 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1430 # @return an integer value
1431 # @ingroup l1_meshinfo
1432 def NbFacesOfOrder(self, elementOrder):
1433 return self.mesh.NbFacesOfOrder(elementOrder)
1435 ## Returns the number of triangles in the mesh
1436 # @return an integer value
1437 # @ingroup l1_meshinfo
1438 def NbTriangles(self):
1439 return self.mesh.NbTriangles()
1441 ## Returns the number of triangles with the given order in the mesh
1442 # @param elementOrder is the order of elements:
1443 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1444 # @return an integer value
1445 # @ingroup l1_meshinfo
1446 def NbTrianglesOfOrder(self, elementOrder):
1447 return self.mesh.NbTrianglesOfOrder(elementOrder)
1449 ## Returns the number of quadrangles in the mesh
1450 # @return an integer value
1451 # @ingroup l1_meshinfo
1452 def NbQuadrangles(self):
1453 return self.mesh.NbQuadrangles()
1455 ## Returns the number of quadrangles with the given order in the mesh
1456 # @param elementOrder the order of elements:
1457 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1458 # @return an integer value
1459 # @ingroup l1_meshinfo
1460 def NbQuadranglesOfOrder(self, elementOrder):
1461 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1463 ## Returns the number of polygons in the mesh
1464 # @return an integer value
1465 # @ingroup l1_meshinfo
1466 def NbPolygons(self):
1467 return self.mesh.NbPolygons()
1469 ## Returns the number of volumes in the mesh
1470 # @return an integer value
1471 # @ingroup l1_meshinfo
1472 def NbVolumes(self):
1473 return self.mesh.NbVolumes()
1475 ## Returns the number of volumes with the given order in the mesh
1476 # @param elementOrder the order of elements:
1477 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1478 # @return an integer value
1479 # @ingroup l1_meshinfo
1480 def NbVolumesOfOrder(self, elementOrder):
1481 return self.mesh.NbVolumesOfOrder(elementOrder)
1483 ## Returns the number of tetrahedrons in the mesh
1484 # @return an integer value
1485 # @ingroup l1_meshinfo
1487 return self.mesh.NbTetras()
1489 ## Returns the number of tetrahedrons with the given order in the mesh
1490 # @param elementOrder the order of elements:
1491 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1492 # @return an integer value
1493 # @ingroup l1_meshinfo
1494 def NbTetrasOfOrder(self, elementOrder):
1495 return self.mesh.NbTetrasOfOrder(elementOrder)
1497 ## Returns the number of hexahedrons in the mesh
1498 # @return an integer value
1499 # @ingroup l1_meshinfo
1501 return self.mesh.NbHexas()
1503 ## Returns the number of hexahedrons with the given order in the mesh
1504 # @param elementOrder the order of elements:
1505 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1506 # @return an integer value
1507 # @ingroup l1_meshinfo
1508 def NbHexasOfOrder(self, elementOrder):
1509 return self.mesh.NbHexasOfOrder(elementOrder)
1511 ## Returns the number of pyramids in the mesh
1512 # @return an integer value
1513 # @ingroup l1_meshinfo
1514 def NbPyramids(self):
1515 return self.mesh.NbPyramids()
1517 ## Returns the number of pyramids with the given order in the mesh
1518 # @param elementOrder the order of elements:
1519 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1520 # @return an integer value
1521 # @ingroup l1_meshinfo
1522 def NbPyramidsOfOrder(self, elementOrder):
1523 return self.mesh.NbPyramidsOfOrder(elementOrder)
1525 ## Returns the number of prisms in the mesh
1526 # @return an integer value
1527 # @ingroup l1_meshinfo
1529 return self.mesh.NbPrisms()
1531 ## Returns the number of prisms with the given order in the mesh
1532 # @param elementOrder the order of elements:
1533 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1534 # @return an integer value
1535 # @ingroup l1_meshinfo
1536 def NbPrismsOfOrder(self, elementOrder):
1537 return self.mesh.NbPrismsOfOrder(elementOrder)
1539 ## Returns the number of polyhedrons in the mesh
1540 # @return an integer value
1541 # @ingroup l1_meshinfo
1542 def NbPolyhedrons(self):
1543 return self.mesh.NbPolyhedrons()
1545 ## Returns the number of submeshes in the mesh
1546 # @return an integer value
1547 # @ingroup l1_meshinfo
1548 def NbSubMesh(self):
1549 return self.mesh.NbSubMesh()
1551 ## Returns the list of mesh elements IDs
1552 # @return the list of integer values
1553 # @ingroup l1_meshinfo
1554 def GetElementsId(self):
1555 return self.mesh.GetElementsId()
1557 ## Returns the list of IDs of mesh elements with the given type
1558 # @param elementType the required type of elements
1559 # @return list of integer values
1560 # @ingroup l1_meshinfo
1561 def GetElementsByType(self, elementType):
1562 return self.mesh.GetElementsByType(elementType)
1564 ## Returns the list of mesh nodes IDs
1565 # @return the list of integer values
1566 # @ingroup l1_meshinfo
1567 def GetNodesId(self):
1568 return self.mesh.GetNodesId()
1570 # Get the information about mesh elements:
1571 # ------------------------------------
1573 ## Returns the type of mesh element
1574 # @return the value from SMESH::ElementType enumeration
1575 # @ingroup l1_meshinfo
1576 def GetElementType(self, id, iselem):
1577 return self.mesh.GetElementType(id, iselem)
1579 ## Returns the list of submesh elements IDs
1580 # @param Shape a geom object(subshape) IOR
1581 # Shape must be the subshape of a ShapeToMesh()
1582 # @return the list of integer values
1583 # @ingroup l1_meshinfo
1584 def GetSubMeshElementsId(self, Shape):
1585 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1586 ShapeID = Shape.GetSubShapeIndices()[0]
1589 return self.mesh.GetSubMeshElementsId(ShapeID)
1591 ## Returns the list of submesh nodes IDs
1592 # @param Shape a geom object(subshape) IOR
1593 # Shape must be the subshape of a ShapeToMesh()
1594 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1595 # @return the list of integer values
1596 # @ingroup l1_meshinfo
1597 def GetSubMeshNodesId(self, Shape, all):
1598 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1599 ShapeID = Shape.GetSubShapeIndices()[0]
1602 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1604 ## Returns the list of IDs of submesh elements with the given type
1605 # @param Shape a geom object(subshape) IOR
1606 # Shape must be a subshape of a ShapeToMesh()
1607 # @return the list of integer values
1608 # @ingroup l1_meshinfo
1609 def GetSubMeshElementType(self, Shape):
1610 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1611 ShapeID = Shape.GetSubShapeIndices()[0]
1614 return self.mesh.GetSubMeshElementType(ShapeID)
1616 ## Gets the mesh description
1617 # @return string value
1618 # @ingroup l1_meshinfo
1620 return self.mesh.Dump()
1623 # Get the information about nodes and elements of a mesh by its IDs:
1624 # -----------------------------------------------------------
1626 ## Gets XYZ coordinates of a node
1627 # \n If there is no nodes for the given ID - returns an empty list
1628 # @return a list of double precision values
1629 # @ingroup l1_meshinfo
1630 def GetNodeXYZ(self, id):
1631 return self.mesh.GetNodeXYZ(id)
1633 ## Returns list of IDs of inverse elements for the given node
1634 # \n If there is no node for the given ID - returns an empty list
1635 # @return a list of integer values
1636 # @ingroup l1_meshinfo
1637 def GetNodeInverseElements(self, id):
1638 return self.mesh.GetNodeInverseElements(id)
1640 ## @brief Returns the position of a node on the shape
1641 # @return SMESH::NodePosition
1642 # @ingroup l1_meshinfo
1643 def GetNodePosition(self,NodeID):
1644 return self.mesh.GetNodePosition(NodeID)
1646 ## If the given element is a node, returns the ID of shape
1647 # \n If there is no node for the given ID - returns -1
1648 # @return an integer value
1649 # @ingroup l1_meshinfo
1650 def GetShapeID(self, id):
1651 return self.mesh.GetShapeID(id)
1653 ## Returns the ID of the result shape after
1654 # FindShape() from SMESH_MeshEditor for the given element
1655 # \n If there is no element for the given ID - returns -1
1656 # @return an integer value
1657 # @ingroup l1_meshinfo
1658 def GetShapeIDForElem(self,id):
1659 return self.mesh.GetShapeIDForElem(id)
1661 ## Returns the number of nodes for the given element
1662 # \n If there is no element for the given ID - returns -1
1663 # @return an integer value
1664 # @ingroup l1_meshinfo
1665 def GetElemNbNodes(self, id):
1666 return self.mesh.GetElemNbNodes(id)
1668 ## Returns the node ID the given index for the given element
1669 # \n If there is no element for the given ID - returns -1
1670 # \n If there is no node for the given index - returns -2
1671 # @return an integer value
1672 # @ingroup l1_meshinfo
1673 def GetElemNode(self, id, index):
1674 return self.mesh.GetElemNode(id, index)
1676 ## Returns the IDs of nodes of the given element
1677 # @return a list of integer values
1678 # @ingroup l1_meshinfo
1679 def GetElemNodes(self, id):
1680 return self.mesh.GetElemNodes(id)
1682 ## Returns true if the given node is the medium node in the given quadratic element
1683 # @ingroup l1_meshinfo
1684 def IsMediumNode(self, elementID, nodeID):
1685 return self.mesh.IsMediumNode(elementID, nodeID)
1687 ## Returns true if the given node is the medium node in one of quadratic elements
1688 # @ingroup l1_meshinfo
1689 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1690 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1692 ## Returns the number of edges for the given element
1693 # @ingroup l1_meshinfo
1694 def ElemNbEdges(self, id):
1695 return self.mesh.ElemNbEdges(id)
1697 ## Returns the number of faces for the given element
1698 # @ingroup l1_meshinfo
1699 def ElemNbFaces(self, id):
1700 return self.mesh.ElemNbFaces(id)
1702 ## Returns true if the given element is a polygon
1703 # @ingroup l1_meshinfo
1704 def IsPoly(self, id):
1705 return self.mesh.IsPoly(id)
1707 ## Returns true if the given element is quadratic
1708 # @ingroup l1_meshinfo
1709 def IsQuadratic(self, id):
1710 return self.mesh.IsQuadratic(id)
1712 ## Returns XYZ coordinates of the barycenter of the given element
1713 # \n If there is no element for the given ID - returns an empty list
1714 # @return a list of three double values
1715 # @ingroup l1_meshinfo
1716 def BaryCenter(self, id):
1717 return self.mesh.BaryCenter(id)
1720 # Mesh edition (SMESH_MeshEditor functionality):
1721 # ---------------------------------------------
1723 ## Removes the elements from the mesh by ids
1724 # @param IDsOfElements is a list of ids of elements to remove
1725 # @return True or False
1726 # @ingroup l2_modif_del
1727 def RemoveElements(self, IDsOfElements):
1728 return self.editor.RemoveElements(IDsOfElements)
1730 ## Removes nodes from mesh by ids
1731 # @param IDsOfNodes is a list of ids of nodes to remove
1732 # @return True or False
1733 # @ingroup l2_modif_del
1734 def RemoveNodes(self, IDsOfNodes):
1735 return self.editor.RemoveNodes(IDsOfNodes)
1737 ## Add a node to the mesh by coordinates
1738 # @return Id of the new node
1739 # @ingroup l2_modif_add
1740 def AddNode(self, x, y, z):
1741 return self.editor.AddNode( x, y, z)
1743 ## Creates a linear or quadratic edge (this is determined
1744 # by the number of given nodes).
1745 # @param IDsOfNodes the list of node IDs for creation of the element.
1746 # The order of nodes in this list should correspond to the description
1747 # of MED. \n This description is located by the following link:
1748 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1749 # @return the Id of the new edge
1750 # @ingroup l2_modif_add
1751 def AddEdge(self, IDsOfNodes):
1752 return self.editor.AddEdge(IDsOfNodes)
1754 ## Creates a linear or quadratic face (this is determined
1755 # by the number of given nodes).
1756 # @param IDsOfNodes the list of node IDs for creation of the element.
1757 # The order of nodes in this list should correspond to the description
1758 # of MED. \n This description is located by the following link:
1759 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1760 # @return the Id of the new face
1761 # @ingroup l2_modif_add
1762 def AddFace(self, IDsOfNodes):
1763 return self.editor.AddFace(IDsOfNodes)
1765 ## Adds a polygonal face to the mesh by the list of node IDs
1766 # @param IdsOfNodes the list of node IDs for creation of the element.
1767 # @return the Id of the new face
1768 # @ingroup l2_modif_add
1769 def AddPolygonalFace(self, IdsOfNodes):
1770 return self.editor.AddPolygonalFace(IdsOfNodes)
1772 ## Creates both simple and quadratic volume (this is determined
1773 # by the number of given nodes).
1774 # @param IDsOfNodes the list of node IDs for creation of the element.
1775 # The order of nodes in this list should correspond to the description
1776 # of MED. \n This description is located by the following link:
1777 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1778 # @return the Id of the new volumic element
1779 # @ingroup l2_modif_add
1780 def AddVolume(self, IDsOfNodes):
1781 return self.editor.AddVolume(IDsOfNodes)
1783 ## Creates a volume of many faces, giving nodes for each face.
1784 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1785 # @param Quantities the list of integer values, Quantities[i]
1786 # gives the quantity of nodes in face number i.
1787 # @return the Id of the new volumic element
1788 # @ingroup l2_modif_add
1789 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1790 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1792 ## Creates a volume of many faces, giving the IDs of the existing faces.
1793 # @param IdsOfFaces the list of face IDs for volume creation.
1795 # Note: The created volume will refer only to the nodes
1796 # of the given faces, not to the faces themselves.
1797 # @return the Id of the new volumic element
1798 # @ingroup l2_modif_add
1799 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1800 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1803 ## @brief Binds a node to a vertex
1804 # @param NodeID a node ID
1805 # @param Vertex a vertex or vertex ID
1806 # @return True if succeed else raises an exception
1807 # @ingroup l2_modif_add
1808 def SetNodeOnVertex(self, NodeID, Vertex):
1809 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1810 VertexID = Vertex.GetSubShapeIndices()[0]
1814 self.editor.SetNodeOnVertex(NodeID, VertexID)
1815 except SALOME.SALOME_Exception, inst:
1816 raise ValueError, inst.details.text
1820 ## @brief Stores the node position on an edge
1821 # @param NodeID a node ID
1822 # @param Edge an edge or edge ID
1823 # @param paramOnEdge a parameter on the edge where the node is located
1824 # @return True if succeed else raises an exception
1825 # @ingroup l2_modif_add
1826 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1827 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1828 EdgeID = Edge.GetSubShapeIndices()[0]
1832 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1833 except SALOME.SALOME_Exception, inst:
1834 raise ValueError, inst.details.text
1837 ## @brief Stores node position on a face
1838 # @param NodeID a node ID
1839 # @param Face a face or face ID
1840 # @param u U parameter on the face where the node is located
1841 # @param v V parameter on the face where the node is located
1842 # @return True if succeed else raises an exception
1843 # @ingroup l2_modif_add
1844 def SetNodeOnFace(self, NodeID, Face, u, v):
1845 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1846 FaceID = Face.GetSubShapeIndices()[0]
1850 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1851 except SALOME.SALOME_Exception, inst:
1852 raise ValueError, inst.details.text
1855 ## @brief Binds a node to a solid
1856 # @param NodeID a node ID
1857 # @param Solid a solid or solid ID
1858 # @return True if succeed else raises an exception
1859 # @ingroup l2_modif_add
1860 def SetNodeInVolume(self, NodeID, Solid):
1861 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1862 SolidID = Solid.GetSubShapeIndices()[0]
1866 self.editor.SetNodeInVolume(NodeID, SolidID)
1867 except SALOME.SALOME_Exception, inst:
1868 raise ValueError, inst.details.text
1871 ## @brief Bind an element to a shape
1872 # @param ElementID an element ID
1873 # @param Shape a shape or shape ID
1874 # @return True if succeed else raises an exception
1875 # @ingroup l2_modif_add
1876 def SetMeshElementOnShape(self, ElementID, Shape):
1877 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1878 ShapeID = Shape.GetSubShapeIndices()[0]
1882 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1883 except SALOME.SALOME_Exception, inst:
1884 raise ValueError, inst.details.text
1888 ## Moves the node with the given id
1889 # @param NodeID the id of the node
1890 # @param x a new X coordinate
1891 # @param y a new Y coordinate
1892 # @param z a new Z coordinate
1893 # @return True if succeed else False
1894 # @ingroup l2_modif_movenode
1895 def MoveNode(self, NodeID, x, y, z):
1896 return self.editor.MoveNode(NodeID, x, y, z)
1898 ## Finds the node closest to a point
1899 # @param x the X coordinate of a point
1900 # @param y the Y coordinate of a point
1901 # @param z the Z coordinate of a point
1902 # @return the ID of a node
1903 # @ingroup l2_modif_throughp
1904 def FindNodeClosestTo(self, x, y, z):
1905 preview = self.mesh.GetMeshEditPreviewer()
1906 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1908 ## Finds the node closest to a point and moves it to a point location
1909 # @param x the X coordinate of a point
1910 # @param y the Y coordinate of a point
1911 # @param z the Z coordinate of a point
1912 # @return the ID of a moved node
1913 # @ingroup l2_modif_throughp
1914 def MeshToPassThroughAPoint(self, x, y, z):
1915 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1917 ## Replaces two neighbour triangles sharing Node1-Node2 link
1918 # with the triangles built on the same 4 nodes but having other common link.
1919 # @param NodeID1 the ID of the first node
1920 # @param NodeID2 the ID of the second node
1921 # @return false if proper faces were not found
1922 # @ingroup l2_modif_invdiag
1923 def InverseDiag(self, NodeID1, NodeID2):
1924 return self.editor.InverseDiag(NodeID1, NodeID2)
1926 ## Replaces two neighbour triangles sharing Node1-Node2 link
1927 # with a quadrangle built on the same 4 nodes.
1928 # @param NodeID1 the ID of the first node
1929 # @param NodeID2 the ID of the second node
1930 # @return false if proper faces were not found
1931 # @ingroup l2_modif_unitetri
1932 def DeleteDiag(self, NodeID1, NodeID2):
1933 return self.editor.DeleteDiag(NodeID1, NodeID2)
1935 ## Reorients elements by ids
1936 # @param IDsOfElements if undefined reorients all mesh elements
1937 # @return True if succeed else False
1938 # @ingroup l2_modif_changori
1939 def Reorient(self, IDsOfElements=None):
1940 if IDsOfElements == None:
1941 IDsOfElements = self.GetElementsId()
1942 return self.editor.Reorient(IDsOfElements)
1944 ## Reorients all elements of the object
1945 # @param theObject mesh, submesh or group
1946 # @return True if succeed else False
1947 # @ingroup l2_modif_changori
1948 def ReorientObject(self, theObject):
1949 if ( isinstance( theObject, Mesh )):
1950 theObject = theObject.GetMesh()
1951 return self.editor.ReorientObject(theObject)
1953 ## Fuses the neighbouring triangles into quadrangles.
1954 # @param IDsOfElements The triangles to be fused,
1955 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1956 # @param MaxAngle is the maximum angle between element normals at which the fusion
1957 # is still performed; theMaxAngle is mesured in radians.
1958 # @return TRUE in case of success, FALSE otherwise.
1959 # @ingroup l2_modif_unitetri
1960 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1961 if IDsOfElements == []:
1962 IDsOfElements = self.GetElementsId()
1963 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1965 ## Fuses the neighbouring triangles of the object into quadrangles
1966 # @param theObject is mesh, submesh or group
1967 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1968 # @param MaxAngle a max angle between element normals at which the fusion
1969 # is still performed; theMaxAngle is mesured in radians.
1970 # @return TRUE in case of success, FALSE otherwise.
1971 # @ingroup l2_modif_unitetri
1972 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1973 if ( isinstance( theObject, Mesh )):
1974 theObject = theObject.GetMesh()
1975 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1977 ## Splits quadrangles into triangles.
1978 # @param IDsOfElements the faces to be splitted.
1979 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1980 # @return TRUE in case of success, FALSE otherwise.
1981 # @ingroup l2_modif_cutquadr
1982 def QuadToTri (self, IDsOfElements, theCriterion):
1983 if IDsOfElements == []:
1984 IDsOfElements = self.GetElementsId()
1985 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1987 ## Splits quadrangles into triangles.
1988 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1989 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1990 # @return TRUE in case of success, FALSE otherwise.
1991 # @ingroup l2_modif_cutquadr
1992 def QuadToTriObject (self, theObject, theCriterion):
1993 if ( isinstance( theObject, Mesh )):
1994 theObject = theObject.GetMesh()
1995 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1997 ## Splits quadrangles into triangles.
1998 # @param IDsOfElements the faces to be splitted
1999 # @param Diag13 is used to choose a diagonal for splitting.
2000 # @return TRUE in case of success, FALSE otherwise.
2001 # @ingroup l2_modif_cutquadr
2002 def SplitQuad (self, IDsOfElements, Diag13):
2003 if IDsOfElements == []:
2004 IDsOfElements = self.GetElementsId()
2005 return self.editor.SplitQuad(IDsOfElements, Diag13)
2007 ## Splits quadrangles into triangles.
2008 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2009 # @param Diag13 is used to choose a diagonal for splitting.
2010 # @return TRUE in case of success, FALSE otherwise.
2011 # @ingroup l2_modif_cutquadr
2012 def SplitQuadObject (self, theObject, Diag13):
2013 if ( isinstance( theObject, Mesh )):
2014 theObject = theObject.GetMesh()
2015 return self.editor.SplitQuadObject(theObject, Diag13)
2017 ## Finds a better splitting of the given quadrangle.
2018 # @param IDOfQuad the ID of the quadrangle to be splitted.
2019 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2020 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2021 # diagonal is better, 0 if error occurs.
2022 # @ingroup l2_modif_cutquadr
2023 def BestSplit (self, IDOfQuad, theCriterion):
2024 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2026 ## Splits quadrangle faces near triangular facets of volumes
2028 # @ingroup l1_auxiliary
2029 def SplitQuadsNearTriangularFacets(self):
2030 faces_array = self.GetElementsByType(SMESH.FACE)
2031 for face_id in faces_array:
2032 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2033 quad_nodes = self.mesh.GetElemNodes(face_id)
2034 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2035 isVolumeFound = False
2036 for node1_elem in node1_elems:
2037 if not isVolumeFound:
2038 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2039 nb_nodes = self.GetElemNbNodes(node1_elem)
2040 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2041 volume_elem = node1_elem
2042 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2043 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2044 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2045 isVolumeFound = True
2046 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2047 self.SplitQuad([face_id], False) # diagonal 2-4
2048 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2049 isVolumeFound = True
2050 self.SplitQuad([face_id], True) # diagonal 1-3
2051 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2052 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2053 isVolumeFound = True
2054 self.SplitQuad([face_id], True) # diagonal 1-3
2056 ## @brief Splits hexahedrons into tetrahedrons.
2058 # This operation uses pattern mapping functionality for splitting.
2059 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2060 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2061 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2062 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2063 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2064 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2065 # @return TRUE in case of success, FALSE otherwise.
2066 # @ingroup l1_auxiliary
2067 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2068 # Pattern: 5.---------.6
2073 # (0,0,1) 4.---------.7 * |
2080 # (0,0,0) 0.---------.3
2081 pattern_tetra = "!!! Nb of points: \n 8 \n\
2091 !!! Indices of points of 6 tetras: \n\
2099 pattern = self.smeshpyD.GetPattern()
2100 isDone = pattern.LoadFromFile(pattern_tetra)
2102 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2105 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2106 isDone = pattern.MakeMesh(self.mesh, False, False)
2107 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2109 # split quafrangle faces near triangular facets of volumes
2110 self.SplitQuadsNearTriangularFacets()
2114 ## @brief Split hexahedrons into prisms.
2116 # Uses the pattern mapping functionality for splitting.
2117 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2118 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2119 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2120 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2121 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2122 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2123 # @return TRUE in case of success, FALSE otherwise.
2124 # @ingroup l1_auxiliary
2125 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2126 # Pattern: 5.---------.6
2131 # (0,0,1) 4.---------.7 |
2138 # (0,0,0) 0.---------.3
2139 pattern_prism = "!!! Nb of points: \n 8 \n\
2149 !!! Indices of points of 2 prisms: \n\
2153 pattern = self.smeshpyD.GetPattern()
2154 isDone = pattern.LoadFromFile(pattern_prism)
2156 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2159 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2160 isDone = pattern.MakeMesh(self.mesh, False, False)
2161 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2163 # Splits quafrangle faces near triangular facets of volumes
2164 self.SplitQuadsNearTriangularFacets()
2168 ## Smoothes elements
2169 # @param IDsOfElements the list if ids of elements to smooth
2170 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2171 # Note that nodes built on edges and boundary nodes are always fixed.
2172 # @param MaxNbOfIterations the maximum number of iterations
2173 # @param MaxAspectRatio varies in range [1.0, inf]
2174 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2175 # @return TRUE in case of success, FALSE otherwise.
2176 # @ingroup l2_modif_smooth
2177 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2178 MaxNbOfIterations, MaxAspectRatio, Method):
2179 if IDsOfElements == []:
2180 IDsOfElements = self.GetElementsId()
2181 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2182 MaxNbOfIterations, MaxAspectRatio, Method)
2184 ## Smoothes elements which belong to the given object
2185 # @param theObject the object to smooth
2186 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2187 # Note that nodes built on edges and boundary nodes are always fixed.
2188 # @param MaxNbOfIterations the maximum number of iterations
2189 # @param MaxAspectRatio varies in range [1.0, inf]
2190 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2191 # @return TRUE in case of success, FALSE otherwise.
2192 # @ingroup l2_modif_smooth
2193 def SmoothObject(self, theObject, IDsOfFixedNodes,
2194 MaxNbOfIterations, MaxAspectRatio, Method):
2195 if ( isinstance( theObject, Mesh )):
2196 theObject = theObject.GetMesh()
2197 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2198 MaxNbOfIterations, MaxAspectRatio, Method)
2200 ## Parametrically smoothes the given elements
2201 # @param IDsOfElements the list if ids of elements to smooth
2202 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2203 # Note that nodes built on edges and boundary nodes are always fixed.
2204 # @param MaxNbOfIterations the maximum number of iterations
2205 # @param MaxAspectRatio varies in range [1.0, inf]
2206 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2207 # @return TRUE in case of success, FALSE otherwise.
2208 # @ingroup l2_modif_smooth
2209 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2210 MaxNbOfIterations, MaxAspectRatio, Method):
2211 if IDsOfElements == []:
2212 IDsOfElements = self.GetElementsId()
2213 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2214 MaxNbOfIterations, MaxAspectRatio, Method)
2216 ## Parametrically smoothes the elements which belong to the given object
2217 # @param theObject the object to smooth
2218 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2219 # Note that nodes built on edges and boundary nodes are always fixed.
2220 # @param MaxNbOfIterations the maximum number of iterations
2221 # @param MaxAspectRatio varies in range [1.0, inf]
2222 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2223 # @return TRUE in case of success, FALSE otherwise.
2224 # @ingroup l2_modif_smooth
2225 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2226 MaxNbOfIterations, MaxAspectRatio, Method):
2227 if ( isinstance( theObject, Mesh )):
2228 theObject = theObject.GetMesh()
2229 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2230 MaxNbOfIterations, MaxAspectRatio, Method)
2232 ## Converts the mesh to quadratic, deletes old elements, replacing
2233 # them with quadratic with the same id.
2234 # @ingroup l2_modif_tofromqu
2235 def ConvertToQuadratic(self, theForce3d):
2236 self.editor.ConvertToQuadratic(theForce3d)
2238 ## Converts the mesh from quadratic to ordinary,
2239 # deletes old quadratic elements, \n replacing
2240 # them with ordinary mesh elements with the same id.
2241 # @return TRUE in case of success, FALSE otherwise.
2242 # @ingroup l2_modif_tofromqu
2243 def ConvertFromQuadratic(self):
2244 return self.editor.ConvertFromQuadratic()
2246 ## Renumber mesh nodes
2247 # @ingroup l2_modif_renumber
2248 def RenumberNodes(self):
2249 self.editor.RenumberNodes()
2251 ## Renumber mesh elements
2252 # @ingroup l2_modif_renumber
2253 def RenumberElements(self):
2254 self.editor.RenumberElements()
2256 ## Generates new elements by rotation of the elements around the axis
2257 # @param IDsOfElements the list of ids of elements to sweep
2258 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2259 # @param AngleInRadians the angle of Rotation
2260 # @param NbOfSteps the number of steps
2261 # @param Tolerance tolerance
2262 # @param MakeGroups forces the generation of new groups from existing ones
2263 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2264 # of all steps, else - size of each step
2265 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2266 # @ingroup l2_modif_extrurev
2267 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2268 MakeGroups=False, TotalAngle=False):
2269 if IDsOfElements == []:
2270 IDsOfElements = self.GetElementsId()
2271 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2272 Axis = self.smeshpyD.GetAxisStruct(Axis)
2273 if TotalAngle and NbOfSteps:
2274 AngleInRadians /= NbOfSteps
2276 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2277 AngleInRadians, NbOfSteps, Tolerance)
2278 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2281 ## Generates new elements by rotation of the elements of object around the axis
2282 # @param theObject object which elements should be sweeped
2283 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2284 # @param AngleInRadians the angle of Rotation
2285 # @param NbOfSteps number of steps
2286 # @param Tolerance tolerance
2287 # @param MakeGroups forces the generation of new groups from existing ones
2288 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2289 # of all steps, else - size of each step
2290 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2291 # @ingroup l2_modif_extrurev
2292 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2293 MakeGroups=False, TotalAngle=False):
2294 if ( isinstance( theObject, Mesh )):
2295 theObject = theObject.GetMesh()
2296 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2297 Axis = self.smeshpyD.GetAxisStruct(Axis)
2298 if TotalAngle and NbOfSteps:
2299 AngleInRadians /= NbOfSteps
2301 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2302 NbOfSteps, Tolerance)
2303 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2306 ## Generates new elements by extrusion of the elements with given ids
2307 # @param IDsOfElements the list of elements ids for extrusion
2308 # @param StepVector vector, defining the direction and value of extrusion
2309 # @param NbOfSteps the number of steps
2310 # @param MakeGroups forces the generation of new groups from existing ones
2311 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2312 # @ingroup l2_modif_extrurev
2313 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2314 if IDsOfElements == []:
2315 IDsOfElements = self.GetElementsId()
2316 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2317 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2319 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2320 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2323 ## Generates new elements by extrusion of the elements with given ids
2324 # @param IDsOfElements is ids of elements
2325 # @param StepVector vector, defining the direction and value of extrusion
2326 # @param NbOfSteps the number of steps
2327 # @param ExtrFlags sets flags for extrusion
2328 # @param SewTolerance uses for comparing locations of nodes if flag
2329 # EXTRUSION_FLAG_SEW is set
2330 # @param MakeGroups forces the generation of new groups from existing ones
2331 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2332 # @ingroup l2_modif_extrurev
2333 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2334 ExtrFlags, SewTolerance, MakeGroups=False):
2335 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2336 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2338 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2339 ExtrFlags, SewTolerance)
2340 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2341 ExtrFlags, SewTolerance)
2344 ## Generates new elements by extrusion of the elements which belong to the object
2345 # @param theObject the object which elements should be processed
2346 # @param StepVector vector, defining the direction and value of extrusion
2347 # @param NbOfSteps the number of steps
2348 # @param MakeGroups forces the generation of new groups from existing ones
2349 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2350 # @ingroup l2_modif_extrurev
2351 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2352 if ( isinstance( theObject, Mesh )):
2353 theObject = theObject.GetMesh()
2354 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2355 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2357 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2358 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2361 ## Generates new elements by extrusion of the elements which belong to the object
2362 # @param theObject object which elements should be processed
2363 # @param StepVector vector, defining the direction and value of extrusion
2364 # @param NbOfSteps the number of steps
2365 # @param MakeGroups to generate new groups from existing ones
2366 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2367 # @ingroup l2_modif_extrurev
2368 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2369 if ( isinstance( theObject, Mesh )):
2370 theObject = theObject.GetMesh()
2371 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2372 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2374 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2375 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2378 ## Generates new elements by extrusion of the elements which belong to the object
2379 # @param theObject object which elements should be processed
2380 # @param StepVector vector, defining the direction and value of extrusion
2381 # @param NbOfSteps the number of steps
2382 # @param MakeGroups forces the generation of new groups from existing ones
2383 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2384 # @ingroup l2_modif_extrurev
2385 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2386 if ( isinstance( theObject, Mesh )):
2387 theObject = theObject.GetMesh()
2388 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2389 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2391 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2392 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2395 ## Generates new elements by extrusion of the given elements
2396 # The path of extrusion must be a meshed edge.
2397 # @param IDsOfElements ids of elements
2398 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2399 # @param PathShape shape(edge) defines the sub-mesh for the path
2400 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2401 # @param HasAngles allows the shape to be rotated around the path
2402 # to get the resulting mesh in a helical fashion
2403 # @param Angles list of angles
2404 # @param HasRefPoint allows using the reference point
2405 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2406 # The User can specify any point as the Reference Point.
2407 # @param MakeGroups forces the generation of new groups from existing ones
2408 # @param LinearVariation forces the computation of rotation angles as linear
2409 # variation of the given Angles along path steps
2410 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2411 # only SMESH::Extrusion_Error otherwise
2412 # @ingroup l2_modif_extrurev
2413 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2414 HasAngles, Angles, HasRefPoint, RefPoint,
2415 MakeGroups=False, LinearVariation=False):
2416 if IDsOfElements == []:
2417 IDsOfElements = self.GetElementsId()
2418 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2419 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2421 if ( isinstance( PathMesh, Mesh )):
2422 PathMesh = PathMesh.GetMesh()
2423 if HasAngles and Angles and LinearVariation:
2424 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2427 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2428 PathShape, NodeStart, HasAngles,
2429 Angles, HasRefPoint, RefPoint)
2430 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2431 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2433 ## Generates new elements by extrusion of the elements which belong to the object
2434 # The path of extrusion must be a meshed edge.
2435 # @param theObject the object which elements should be processed
2436 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2437 # @param PathShape shape(edge) defines the sub-mesh for the path
2438 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2439 # @param HasAngles allows the shape to be rotated around the path
2440 # to get the resulting mesh in a helical fashion
2441 # @param Angles list of angles
2442 # @param HasRefPoint allows using the reference point
2443 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2444 # The User can specify any point as the Reference Point.
2445 # @param MakeGroups forces the generation of new groups from existing ones
2446 # @param LinearVariation forces the computation of rotation angles as linear
2447 # variation of the given Angles along path steps
2448 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2449 # only SMESH::Extrusion_Error otherwise
2450 # @ingroup l2_modif_extrurev
2451 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2452 HasAngles, Angles, HasRefPoint, RefPoint,
2453 MakeGroups=False, LinearVariation=False):
2454 if ( isinstance( theObject, Mesh )):
2455 theObject = theObject.GetMesh()
2456 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2457 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2458 if ( isinstance( PathMesh, Mesh )):
2459 PathMesh = PathMesh.GetMesh()
2460 if HasAngles and Angles and LinearVariation:
2461 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2464 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2465 PathShape, NodeStart, HasAngles,
2466 Angles, HasRefPoint, RefPoint)
2467 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2468 NodeStart, HasAngles, Angles, HasRefPoint,
2471 ## Creates a symmetrical copy of mesh elements
2472 # @param IDsOfElements list of elements ids
2473 # @param Mirror is AxisStruct or geom object(point, line, plane)
2474 # @param theMirrorType is POINT, AXIS or PLANE
2475 # If the Mirror is a geom object this parameter is unnecessary
2476 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2477 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2478 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2479 # @ingroup l2_modif_trsf
2480 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2481 if IDsOfElements == []:
2482 IDsOfElements = self.GetElementsId()
2483 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2484 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2485 if Copy and MakeGroups:
2486 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2487 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2490 ## Creates a new mesh by a symmetrical copy of mesh elements
2491 # @param IDsOfElements the list of elements ids
2492 # @param Mirror is AxisStruct or geom object (point, line, plane)
2493 # @param theMirrorType is POINT, AXIS or PLANE
2494 # If the Mirror is a geom object this parameter is unnecessary
2495 # @param MakeGroups to generate new groups from existing ones
2496 # @param NewMeshName a name of the new mesh to create
2497 # @return instance of Mesh class
2498 # @ingroup l2_modif_trsf
2499 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2500 if IDsOfElements == []:
2501 IDsOfElements = self.GetElementsId()
2502 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2503 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2504 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2505 MakeGroups, NewMeshName)
2506 return Mesh(self.smeshpyD,self.geompyD,mesh)
2508 ## Creates a symmetrical copy of the object
2509 # @param theObject mesh, submesh or group
2510 # @param Mirror AxisStruct or geom object (point, line, plane)
2511 # @param theMirrorType is POINT, AXIS or PLANE
2512 # If the Mirror is a geom object this parameter is unnecessary
2513 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2514 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2515 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2516 # @ingroup l2_modif_trsf
2517 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2518 if ( isinstance( theObject, Mesh )):
2519 theObject = theObject.GetMesh()
2520 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2521 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2522 if Copy and MakeGroups:
2523 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2524 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2527 ## Creates a new mesh by a symmetrical copy of the object
2528 # @param theObject mesh, submesh or group
2529 # @param Mirror AxisStruct or geom object (point, line, plane)
2530 # @param theMirrorType POINT, AXIS or PLANE
2531 # If the Mirror is a geom object this parameter is unnecessary
2532 # @param MakeGroups forces the generation of new groups from existing ones
2533 # @param NewMeshName the name of the new mesh to create
2534 # @return instance of Mesh class
2535 # @ingroup l2_modif_trsf
2536 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2537 if ( isinstance( theObject, Mesh )):
2538 theObject = theObject.GetMesh()
2539 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2540 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2541 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2542 MakeGroups, NewMeshName)
2543 return Mesh( self.smeshpyD,self.geompyD,mesh )
2545 ## Translates the elements
2546 # @param IDsOfElements list of elements ids
2547 # @param Vector the direction of translation (DirStruct or vector)
2548 # @param Copy allows copying the translated elements
2549 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2550 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2551 # @ingroup l2_modif_trsf
2552 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2553 if IDsOfElements == []:
2554 IDsOfElements = self.GetElementsId()
2555 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2556 Vector = self.smeshpyD.GetDirStruct(Vector)
2557 if Copy and MakeGroups:
2558 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2559 self.editor.Translate(IDsOfElements, Vector, Copy)
2562 ## Creates a new mesh of translated elements
2563 # @param IDsOfElements list of elements ids
2564 # @param Vector the direction of translation (DirStruct or vector)
2565 # @param MakeGroups forces the generation of new groups from existing ones
2566 # @param NewMeshName the name of the newly created mesh
2567 # @return instance of Mesh class
2568 # @ingroup l2_modif_trsf
2569 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2570 if IDsOfElements == []:
2571 IDsOfElements = self.GetElementsId()
2572 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2573 Vector = self.smeshpyD.GetDirStruct(Vector)
2574 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2575 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2577 ## Translates the object
2578 # @param theObject the object to translate (mesh, submesh, or group)
2579 # @param Vector direction of translation (DirStruct or geom vector)
2580 # @param Copy allows copying the translated elements
2581 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2582 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2583 # @ingroup l2_modif_trsf
2584 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2585 if ( isinstance( theObject, Mesh )):
2586 theObject = theObject.GetMesh()
2587 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2588 Vector = self.smeshpyD.GetDirStruct(Vector)
2589 if Copy and MakeGroups:
2590 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2591 self.editor.TranslateObject(theObject, Vector, Copy)
2594 ## Creates a new mesh from the translated object
2595 # @param theObject the object to translate (mesh, submesh, or group)
2596 # @param Vector the direction of translation (DirStruct or geom vector)
2597 # @param MakeGroups forces the generation of new groups from existing ones
2598 # @param NewMeshName the name of the newly created mesh
2599 # @return instance of Mesh class
2600 # @ingroup l2_modif_trsf
2601 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2602 if (isinstance(theObject, Mesh)):
2603 theObject = theObject.GetMesh()
2604 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2605 Vector = self.smeshpyD.GetDirStruct(Vector)
2606 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2607 return Mesh( self.smeshpyD, self.geompyD, mesh )
2609 ## Rotates the elements
2610 # @param IDsOfElements list of elements ids
2611 # @param Axis the axis of rotation (AxisStruct or geom line)
2612 # @param AngleInRadians the angle of rotation (in radians)
2613 # @param Copy allows copying the rotated elements
2614 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2615 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2616 # @ingroup l2_modif_trsf
2617 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2618 if IDsOfElements == []:
2619 IDsOfElements = self.GetElementsId()
2620 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2621 Axis = self.smeshpyD.GetAxisStruct(Axis)
2622 if Copy and MakeGroups:
2623 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2624 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2627 ## Creates a new mesh of rotated elements
2628 # @param IDsOfElements list of element ids
2629 # @param Axis the axis of rotation (AxisStruct or geom line)
2630 # @param AngleInRadians the angle of rotation (in radians)
2631 # @param MakeGroups forces the generation of new groups from existing ones
2632 # @param NewMeshName the name of the newly created mesh
2633 # @return instance of Mesh class
2634 # @ingroup l2_modif_trsf
2635 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2636 if IDsOfElements == []:
2637 IDsOfElements = self.GetElementsId()
2638 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2639 Axis = self.smeshpyD.GetAxisStruct(Axis)
2640 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2641 MakeGroups, NewMeshName)
2642 return Mesh( self.smeshpyD, self.geompyD, mesh )
2644 ## Rotates the object
2645 # @param theObject the object to rotate( mesh, submesh, or group)
2646 # @param Axis the axis of rotation (AxisStruct or geom line)
2647 # @param AngleInRadians the angle of rotation (in radians)
2648 # @param Copy allows copying the rotated elements
2649 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2650 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2651 # @ingroup l2_modif_trsf
2652 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2653 if (isinstance(theObject, Mesh)):
2654 theObject = theObject.GetMesh()
2655 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2656 Axis = self.smeshpyD.GetAxisStruct(Axis)
2657 if Copy and MakeGroups:
2658 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2659 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2662 ## Creates a new mesh from the rotated object
2663 # @param theObject the object to rotate (mesh, submesh, or group)
2664 # @param Axis the axis of rotation (AxisStruct or geom line)
2665 # @param AngleInRadians the angle of rotation (in radians)
2666 # @param MakeGroups forces the generation of new groups from existing ones
2667 # @param NewMeshName the name of the newly created mesh
2668 # @return instance of Mesh class
2669 # @ingroup l2_modif_trsf
2670 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2671 if (isinstance( theObject, Mesh )):
2672 theObject = theObject.GetMesh()
2673 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2674 Axis = self.smeshpyD.GetAxisStruct(Axis)
2675 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2676 MakeGroups, NewMeshName)
2677 return Mesh( self.smeshpyD, self.geompyD, mesh )
2679 ## Finds groups of ajacent nodes within Tolerance.
2680 # @param Tolerance the value of tolerance
2681 # @return the list of groups of nodes
2682 # @ingroup l2_modif_trsf
2683 def FindCoincidentNodes (self, Tolerance):
2684 return self.editor.FindCoincidentNodes(Tolerance)
2686 ## Finds groups of ajacent nodes within Tolerance.
2687 # @param Tolerance the value of tolerance
2688 # @param SubMeshOrGroup SubMesh or Group
2689 # @return the list of groups of nodes
2690 # @ingroup l2_modif_trsf
2691 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2692 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2695 # @param GroupsOfNodes the list of groups of nodes
2696 # @ingroup l2_modif_trsf
2697 def MergeNodes (self, GroupsOfNodes):
2698 self.editor.MergeNodes(GroupsOfNodes)
2700 ## Finds the elements built on the same nodes.
2701 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2702 # @return a list of groups of equal elements
2703 # @ingroup l2_modif_trsf
2704 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2705 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2707 ## Merges elements in each given group.
2708 # @param GroupsOfElementsID groups of elements for merging
2709 # @ingroup l2_modif_trsf
2710 def MergeElements(self, GroupsOfElementsID):
2711 self.editor.MergeElements(GroupsOfElementsID)
2713 ## Leaves one element and removes all other elements built on the same nodes.
2714 # @ingroup l2_modif_trsf
2715 def MergeEqualElements(self):
2716 self.editor.MergeEqualElements()
2718 ## Sews free borders
2719 # @return SMESH::Sew_Error
2720 # @ingroup l2_modif_trsf
2721 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2722 FirstNodeID2, SecondNodeID2, LastNodeID2,
2723 CreatePolygons, CreatePolyedrs):
2724 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2725 FirstNodeID2, SecondNodeID2, LastNodeID2,
2726 CreatePolygons, CreatePolyedrs)
2728 ## Sews conform free borders
2729 # @return SMESH::Sew_Error
2730 # @ingroup l2_modif_trsf
2731 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2732 FirstNodeID2, SecondNodeID2):
2733 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2734 FirstNodeID2, SecondNodeID2)
2736 ## Sews border to side
2737 # @return SMESH::Sew_Error
2738 # @ingroup l2_modif_trsf
2739 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2740 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2741 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2742 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2744 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2745 # merged with the nodes of elements of Side2.
2746 # The number of elements in theSide1 and in theSide2 must be
2747 # equal and they should have similar nodal connectivity.
2748 # The nodes to merge should belong to side borders and
2749 # the first node should be linked to the second.
2750 # @return SMESH::Sew_Error
2751 # @ingroup l2_modif_trsf
2752 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2753 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2754 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2755 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2756 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2757 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2759 ## Sets new nodes for the given element.
2760 # @param ide the element id
2761 # @param newIDs nodes ids
2762 # @return If the number of nodes does not correspond to the type of element - returns false
2763 # @ingroup l2_modif_edit
2764 def ChangeElemNodes(self, ide, newIDs):
2765 return self.editor.ChangeElemNodes(ide, newIDs)
2767 ## If during the last operation of MeshEditor some nodes were
2768 # created, this method returns the list of their IDs, \n
2769 # if new nodes were not created - returns empty list
2770 # @return the list of integer values (can be empty)
2771 # @ingroup l1_auxiliary
2772 def GetLastCreatedNodes(self):
2773 return self.editor.GetLastCreatedNodes()
2775 ## If during the last operation of MeshEditor some elements were
2776 # created this method returns the list of their IDs, \n
2777 # if new elements were not created - returns empty list
2778 # @return the list of integer values (can be empty)
2779 # @ingroup l1_auxiliary
2780 def GetLastCreatedElems(self):
2781 return self.editor.GetLastCreatedElems()
2783 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2784 # @param theNodes identifiers of nodes to be doubled
2785 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
2786 # nodes. If list of element identifiers is empty then nodes are doubled but
2787 # they not assigned to elements
2788 # @return TRUE if operation has been completed successfully, FALSE otherwise
2789 # @ingroup l2_modif_edit
2790 def DoubleNodes(self, theNodes, theModifiedElems):
2791 return self.editor.DoubleNodes(theNodes, theModifiedElems)
2793 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2794 # This method provided for convenience works as DoubleNodes() described above.
2795 # @param theNodes identifiers of node to be doubled
2796 # @param theModifiedElems identifiers of elements to be updated
2797 # @return TRUE if operation has been completed successfully, FALSE otherwise
2798 # @ingroup l2_modif_edit
2799 def DoubleNode(self, theNodeId, theModifiedElems):
2800 return self.editor.DoubleNode(theNodeId, theModifiedElems)
2802 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2803 # This method provided for convenience works as DoubleNodes() described above.
2804 # @param theNodes group of nodes to be doubled
2805 # @param theModifiedElems group of elements to be updated.
2806 # @return TRUE if operation has been completed successfully, FALSE otherwise
2807 # @ingroup l2_modif_edit
2808 def DoubleNodeGroup(self, theNodes, theModifiedElems):
2809 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
2811 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2812 # This method provided for convenience works as DoubleNodes() described above.
2813 # @param theNodes list of groups of nodes to be doubled
2814 # @param theModifiedElems list of groups of elements to be updated.
2815 # @return TRUE if operation has been completed successfully, FALSE otherwise
2816 # @ingroup l2_modif_edit
2817 def DoubleNodeGroups(self, theNodes, theModifiedElems):
2818 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
2820 ## The mother class to define algorithm, it is not recommended to use it directly.
2823 # @ingroup l2_algorithms
2824 class Mesh_Algorithm:
2825 # @class Mesh_Algorithm
2826 # @brief Class Mesh_Algorithm
2828 #def __init__(self,smesh):
2836 ## Finds a hypothesis in the study by its type name and parameters.
2837 # Finds only the hypotheses created in smeshpyD engine.
2838 # @return SMESH.SMESH_Hypothesis
2839 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2840 study = smeshpyD.GetCurrentStudy()
2841 #to do: find component by smeshpyD object, not by its data type
2842 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2843 if scomp is not None:
2844 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2845 # Check if the root label of the hypotheses exists
2846 if res and hypRoot is not None:
2847 iter = study.NewChildIterator(hypRoot)
2848 # Check all published hypotheses
2850 hypo_so_i = iter.Value()
2851 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2852 if attr is not None:
2853 anIOR = attr.Value()
2854 hypo_o_i = salome.orb.string_to_object(anIOR)
2855 if hypo_o_i is not None:
2856 # Check if this is a hypothesis
2857 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2858 if hypo_i is not None:
2859 # Check if the hypothesis belongs to current engine
2860 if smeshpyD.GetObjectId(hypo_i) > 0:
2861 # Check if this is the required hypothesis
2862 if hypo_i.GetName() == hypname:
2864 if CompareMethod(hypo_i, args):
2878 ## Finds the algorithm in the study by its type name.
2879 # Finds only the algorithms, which have been created in smeshpyD engine.
2880 # @return SMESH.SMESH_Algo
2881 def FindAlgorithm (self, algoname, smeshpyD):
2882 study = smeshpyD.GetCurrentStudy()
2883 #to do: find component by smeshpyD object, not by its data type
2884 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2885 if scomp is not None:
2886 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2887 # Check if the root label of the algorithms exists
2888 if res and hypRoot is not None:
2889 iter = study.NewChildIterator(hypRoot)
2890 # Check all published algorithms
2892 algo_so_i = iter.Value()
2893 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2894 if attr is not None:
2895 anIOR = attr.Value()
2896 algo_o_i = salome.orb.string_to_object(anIOR)
2897 if algo_o_i is not None:
2898 # Check if this is an algorithm
2899 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2900 if algo_i is not None:
2901 # Checks if the algorithm belongs to the current engine
2902 if smeshpyD.GetObjectId(algo_i) > 0:
2903 # Check if this is the required algorithm
2904 if algo_i.GetName() == algoname:
2917 ## If the algorithm is global, returns 0; \n
2918 # else returns the submesh associated to this algorithm.
2919 def GetSubMesh(self):
2922 ## Returns the wrapped mesher.
2923 def GetAlgorithm(self):
2926 ## Gets the list of hypothesis that can be used with this algorithm
2927 def GetCompatibleHypothesis(self):
2930 mylist = self.algo.GetCompatibleHypothesis()
2933 ## Gets the name of the algorithm
2937 ## Sets the name to the algorithm
2938 def SetName(self, name):
2939 self.mesh.smeshpyD.SetName(self.algo, name)
2941 ## Gets the id of the algorithm
2943 return self.algo.GetId()
2946 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2948 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2949 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2951 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2953 self.Assign(algo, mesh, geom)
2957 def Assign(self, algo, mesh, geom):
2959 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2966 name = GetName(geom)
2968 name = mesh.geompyD.SubShapeName(geom, piece)
2969 mesh.geompyD.addToStudyInFather(piece, geom, name)
2970 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2973 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2974 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2976 def CompareHyp (self, hyp, args):
2977 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2980 def CompareEqualHyp (self, hyp, args):
2984 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2985 UseExisting=0, CompareMethod=""):
2988 if CompareMethod == "": CompareMethod = self.CompareHyp
2989 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2992 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2998 a = a + s + str(args[i])
3002 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3004 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3005 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3009 # Public class: Mesh_Segment
3010 # --------------------------
3012 ## Class to define a segment 1D algorithm for discretization
3015 # @ingroup l3_algos_basic
3016 class Mesh_Segment(Mesh_Algorithm):
3018 ## Private constructor.
3019 def __init__(self, mesh, geom=0):
3020 Mesh_Algorithm.__init__(self)
3021 self.Create(mesh, geom, "Regular_1D")
3023 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3024 # @param l for the length of segments that cut an edge
3025 # @param UseExisting if ==true - searches for an existing hypothesis created with
3026 # the same parameters, else (default) - creates a new one
3027 # @param p precision, used for calculation of the number of segments.
3028 # The precision should be a positive, meaningful value within the range [0,1].
3029 # In general, the number of segments is calculated with the formula:
3030 # nb = ceil((edge_length / l) - p)
3031 # Function ceil rounds its argument to the higher integer.
3032 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3033 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3034 # p=1 means rounding of (edge_length / l) to the lower integer.
3035 # Default value is 1e-07.
3036 # @return an instance of StdMeshers_LocalLength hypothesis
3037 # @ingroup l3_hypos_1dhyps
3038 def LocalLength(self, l, UseExisting=0, p=1e-07):
3039 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3040 CompareMethod=self.CompareLocalLength)
3046 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3047 def CompareLocalLength(self, hyp, args):
3048 if IsEqual(hyp.GetLength(), args[0]):
3049 return IsEqual(hyp.GetPrecision(), args[1])
3052 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3053 # @param length is optional maximal allowed length of segment, if it is omitted
3054 # the preestimated length is used that depends on geometry size
3055 # @param UseExisting if ==true - searches for an existing hypothesis created with
3056 # the same parameters, else (default) - create a new one
3057 # @return an instance of StdMeshers_MaxLength hypothesis
3058 # @ingroup l3_hypos_1dhyps
3059 def MaxSize(self, length=0.0, UseExisting=0):
3060 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3063 hyp.SetLength(length)
3065 # set preestimated length
3066 gen = self.mesh.smeshpyD
3067 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3068 self.mesh.GetMesh(), self.mesh.GetShape(),
3070 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3072 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3075 hyp.SetUsePreestimatedLength( length == 0.0 )
3078 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3079 # @param n for the number of segments that cut an edge
3080 # @param s for the scale factor (optional)
3081 # @param UseExisting if ==true - searches for an existing hypothesis created with
3082 # the same parameters, else (default) - create a new one
3083 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3084 # @ingroup l3_hypos_1dhyps
3085 def NumberOfSegments(self, n, s=[], UseExisting=0):
3087 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3088 CompareMethod=self.CompareNumberOfSegments)
3090 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3091 CompareMethod=self.CompareNumberOfSegments)
3092 hyp.SetDistrType( 1 )
3093 hyp.SetScaleFactor(s)
3094 hyp.SetNumberOfSegments(n)
3098 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3099 def CompareNumberOfSegments(self, hyp, args):
3100 if hyp.GetNumberOfSegments() == args[0]:
3104 if hyp.GetDistrType() == 1:
3105 if IsEqual(hyp.GetScaleFactor(), args[1]):
3109 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3110 # @param start defines the length of the first segment
3111 # @param end defines the length of the last segment
3112 # @param UseExisting if ==true - searches for an existing hypothesis created with
3113 # the same parameters, else (default) - creates a new one
3114 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3115 # @ingroup l3_hypos_1dhyps
3116 def Arithmetic1D(self, start, end, UseExisting=0):
3117 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3118 CompareMethod=self.CompareArithmetic1D)
3119 hyp.SetLength(start, 1)
3120 hyp.SetLength(end , 0)
3124 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3125 def CompareArithmetic1D(self, hyp, args):
3126 if IsEqual(hyp.GetLength(1), args[0]):
3127 if IsEqual(hyp.GetLength(0), args[1]):
3131 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3132 # @param start defines the length of the first segment
3133 # @param end defines the length of the last segment
3134 # @param UseExisting if ==true - searches for an existing hypothesis created with
3135 # the same parameters, else (default) - creates a new one
3136 # @return an instance of StdMeshers_StartEndLength hypothesis
3137 # @ingroup l3_hypos_1dhyps
3138 def StartEndLength(self, start, end, UseExisting=0):
3139 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3140 CompareMethod=self.CompareStartEndLength)
3141 hyp.SetLength(start, 1)
3142 hyp.SetLength(end , 0)
3145 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3146 def CompareStartEndLength(self, hyp, args):
3147 if IsEqual(hyp.GetLength(1), args[0]):
3148 if IsEqual(hyp.GetLength(0), args[1]):
3152 ## Defines "Deflection1D" hypothesis
3153 # @param d for the deflection
3154 # @param UseExisting if ==true - searches for an existing hypothesis created with
3155 # the same parameters, else (default) - create a new one
3156 # @ingroup l3_hypos_1dhyps
3157 def Deflection1D(self, d, UseExisting=0):
3158 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3159 CompareMethod=self.CompareDeflection1D)
3160 hyp.SetDeflection(d)
3163 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3164 def CompareDeflection1D(self, hyp, args):
3165 return IsEqual(hyp.GetDeflection(), args[0])
3167 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3168 # the opposite side in case of quadrangular faces
3169 # @ingroup l3_hypos_additi
3170 def Propagation(self):
3171 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3173 ## Defines "AutomaticLength" hypothesis
3174 # @param fineness for the fineness [0-1]
3175 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3176 # same parameters, else (default) - create a new one
3177 # @ingroup l3_hypos_1dhyps
3178 def AutomaticLength(self, fineness=0, UseExisting=0):
3179 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3180 CompareMethod=self.CompareAutomaticLength)
3181 hyp.SetFineness( fineness )
3184 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3185 def CompareAutomaticLength(self, hyp, args):
3186 return IsEqual(hyp.GetFineness(), args[0])
3188 ## Defines "SegmentLengthAroundVertex" hypothesis
3189 # @param length for the segment length
3190 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3191 # Any other integer value means that the hypothesis will be set on the
3192 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3193 # @param UseExisting if ==true - searches for an existing hypothesis created with
3194 # the same parameters, else (default) - creates a new one
3195 # @ingroup l3_algos_segmarv
3196 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3198 store_geom = self.geom
3199 if type(vertex) is types.IntType:
3200 if vertex == 0 or vertex == 1:
3201 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3209 if self.geom is None:
3210 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3211 name = GetName(self.geom)
3213 piece = self.mesh.geom
3214 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3215 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3216 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3218 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3220 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3221 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3223 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3224 CompareMethod=self.CompareLengthNearVertex)
3225 self.geom = store_geom
3226 hyp.SetLength( length )
3229 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3230 # @ingroup l3_algos_segmarv
3231 def CompareLengthNearVertex(self, hyp, args):
3232 return IsEqual(hyp.GetLength(), args[0])
3234 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3235 # If the 2D mesher sees that all boundary edges are quadratic,
3236 # it generates quadratic faces, else it generates linear faces using
3237 # medium nodes as if they are vertices.
3238 # The 3D mesher generates quadratic volumes only if all boundary faces
3239 # are quadratic, else it fails.
3241 # @ingroup l3_hypos_additi
3242 def QuadraticMesh(self):
3243 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3246 # Public class: Mesh_CompositeSegment
3247 # --------------------------
3249 ## Defines a segment 1D algorithm for discretization
3251 # @ingroup l3_algos_basic
3252 class Mesh_CompositeSegment(Mesh_Segment):
3254 ## Private constructor.
3255 def __init__(self, mesh, geom=0):
3256 self.Create(mesh, geom, "CompositeSegment_1D")
3259 # Public class: Mesh_Segment_Python
3260 # ---------------------------------
3262 ## Defines a segment 1D algorithm for discretization with python function
3264 # @ingroup l3_algos_basic
3265 class Mesh_Segment_Python(Mesh_Segment):
3267 ## Private constructor.
3268 def __init__(self, mesh, geom=0):
3269 import Python1dPlugin
3270 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3272 ## Defines "PythonSplit1D" hypothesis
3273 # @param n for the number of segments that cut an edge
3274 # @param func for the python function that calculates the length of all segments
3275 # @param UseExisting if ==true - searches for the existing hypothesis created with
3276 # the same parameters, else (default) - creates a new one
3277 # @ingroup l3_hypos_1dhyps
3278 def PythonSplit1D(self, n, func, UseExisting=0):
3279 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3280 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3281 hyp.SetNumberOfSegments(n)
3282 hyp.SetPythonLog10RatioFunction(func)
3285 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3286 def ComparePythonSplit1D(self, hyp, args):
3287 #if hyp.GetNumberOfSegments() == args[0]:
3288 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3292 # Public class: Mesh_Triangle
3293 # ---------------------------
3295 ## Defines a triangle 2D algorithm
3297 # @ingroup l3_algos_basic
3298 class Mesh_Triangle(Mesh_Algorithm):
3307 ## Private constructor.
3308 def __init__(self, mesh, algoType, geom=0):
3309 Mesh_Algorithm.__init__(self)
3311 self.algoType = algoType
3312 if algoType == MEFISTO:
3313 self.Create(mesh, geom, "MEFISTO_2D")
3315 elif algoType == BLSURF:
3317 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3318 #self.SetPhysicalMesh() - PAL19680
3319 elif algoType == NETGEN:
3321 print "Warning: NETGENPlugin module unavailable"
3323 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3325 elif algoType == NETGEN_2D:
3327 print "Warning: NETGENPlugin module unavailable"
3329 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3332 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3333 # @param area for the maximum area of each triangle
3334 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3335 # same parameters, else (default) - creates a new one
3337 # Only for algoType == MEFISTO || NETGEN_2D
3338 # @ingroup l3_hypos_2dhyps
3339 def MaxElementArea(self, area, UseExisting=0):
3340 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3341 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3342 CompareMethod=self.CompareMaxElementArea)
3343 elif self.algoType == NETGEN:
3344 hyp = self.Parameters(SIMPLE)
3345 hyp.SetMaxElementArea(area)
3348 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3349 def CompareMaxElementArea(self, hyp, args):
3350 return IsEqual(hyp.GetMaxElementArea(), args[0])
3352 ## Defines "LengthFromEdges" hypothesis to build triangles
3353 # based on the length of the edges taken from the wire
3355 # Only for algoType == MEFISTO || NETGEN_2D
3356 # @ingroup l3_hypos_2dhyps
3357 def LengthFromEdges(self):
3358 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3359 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3361 elif self.algoType == NETGEN:
3362 hyp = self.Parameters(SIMPLE)
3363 hyp.LengthFromEdges()
3366 ## Sets a way to define size of mesh elements to generate.
3367 # @param thePhysicalMesh is: DefaultSize or Custom.
3368 # @ingroup l3_hypos_blsurf
3369 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3370 # Parameter of BLSURF algo
3371 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3373 ## Sets size of mesh elements to generate.
3374 # @ingroup l3_hypos_blsurf
3375 def SetPhySize(self, theVal):
3376 # Parameter of BLSURF algo
3377 self.Parameters().SetPhySize(theVal)
3379 ## Sets lower boundary of mesh element size (PhySize).
3380 # @ingroup l3_hypos_blsurf
3381 def SetPhyMin(self, theVal=-1):
3382 # Parameter of BLSURF algo
3383 self.Parameters().SetPhyMin(theVal)
3385 ## Sets upper boundary of mesh element size (PhySize).
3386 # @ingroup l3_hypos_blsurf
3387 def SetPhyMax(self, theVal=-1):
3388 # Parameter of BLSURF algo
3389 self.Parameters().SetPhyMax(theVal)
3391 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3392 # @param theGeometricMesh is: DefaultGeom or Custom
3393 # @ingroup l3_hypos_blsurf
3394 def SetGeometricMesh(self, theGeometricMesh=0):
3395 # Parameter of BLSURF algo
3396 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3397 self.params.SetGeometricMesh(theGeometricMesh)
3399 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3400 # @ingroup l3_hypos_blsurf
3401 def SetAngleMeshS(self, theVal=_angleMeshS):
3402 # Parameter of BLSURF algo
3403 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3404 self.params.SetAngleMeshS(theVal)
3406 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3407 # @ingroup l3_hypos_blsurf
3408 def SetAngleMeshC(self, theVal=_angleMeshS):
3409 # Parameter of BLSURF algo
3410 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3411 self.params.SetAngleMeshC(theVal)
3413 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3414 # @ingroup l3_hypos_blsurf
3415 def SetGeoMin(self, theVal=-1):
3416 # Parameter of BLSURF algo
3417 self.Parameters().SetGeoMin(theVal)
3419 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3420 # @ingroup l3_hypos_blsurf
3421 def SetGeoMax(self, theVal=-1):
3422 # Parameter of BLSURF algo
3423 self.Parameters().SetGeoMax(theVal)
3425 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3426 # @ingroup l3_hypos_blsurf
3427 def SetGradation(self, theVal=_gradation):
3428 # Parameter of BLSURF algo
3429 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3430 self.params.SetGradation(theVal)
3432 ## Sets topology usage way.
3433 # @param way defines how mesh conformity is assured <ul>
3434 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3435 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3436 # @ingroup l3_hypos_blsurf
3437 def SetTopology(self, way):
3438 # Parameter of BLSURF algo
3439 self.Parameters().SetTopology(way)
3441 ## To respect geometrical edges or not.
3442 # @ingroup l3_hypos_blsurf
3443 def SetDecimesh(self, toIgnoreEdges=False):
3444 # Parameter of BLSURF algo
3445 self.Parameters().SetDecimesh(toIgnoreEdges)
3447 ## Sets verbosity level in the range 0 to 100.
3448 # @ingroup l3_hypos_blsurf
3449 def SetVerbosity(self, level):
3450 # Parameter of BLSURF algo
3451 self.Parameters().SetVerbosity(level)
3453 ## Sets advanced option value.
3454 # @ingroup l3_hypos_blsurf
3455 def SetOptionValue(self, optionName, level):
3456 # Parameter of BLSURF algo
3457 self.Parameters().SetOptionValue(optionName,level)
3459 ## Sets QuadAllowed flag.
3460 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3461 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3462 def SetQuadAllowed(self, toAllow=True):
3463 if self.algoType == NETGEN_2D:
3464 if toAllow: # add QuadranglePreference
3465 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3466 else: # remove QuadranglePreference
3467 for hyp in self.mesh.GetHypothesisList( self.geom ):
3468 if hyp.GetName() == "QuadranglePreference":
3469 self.mesh.RemoveHypothesis( self.geom, hyp )
3474 if self.Parameters():
3475 self.params.SetQuadAllowed(toAllow)
3478 ## Defines hypothesis having several parameters
3480 # @ingroup l3_hypos_netgen
3481 def Parameters(self, which=SOLE):
3484 if self.algoType == NETGEN:
3486 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3487 "libNETGENEngine.so", UseExisting=0)
3489 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3490 "libNETGENEngine.so", UseExisting=0)
3492 elif self.algoType == MEFISTO:
3493 print "Mefisto algo support no multi-parameter hypothesis"
3495 elif self.algoType == NETGEN_2D:
3496 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3497 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3499 elif self.algoType == BLSURF:
3500 self.params = self.Hypothesis("BLSURF_Parameters", [],
3501 "libBLSURFEngine.so", UseExisting=0)
3504 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3509 # Only for algoType == NETGEN
3510 # @ingroup l3_hypos_netgen
3511 def SetMaxSize(self, theSize):
3512 if self.Parameters():
3513 self.params.SetMaxSize(theSize)
3515 ## Sets SecondOrder flag
3517 # Only for algoType == NETGEN
3518 # @ingroup l3_hypos_netgen
3519 def SetSecondOrder(self, theVal):
3520 if self.Parameters():
3521 self.params.SetSecondOrder(theVal)
3523 ## Sets Optimize flag
3525 # Only for algoType == NETGEN
3526 # @ingroup l3_hypos_netgen
3527 def SetOptimize(self, theVal):
3528 if self.Parameters():
3529 self.params.SetOptimize(theVal)
3532 # @param theFineness is:
3533 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3535 # Only for algoType == NETGEN
3536 # @ingroup l3_hypos_netgen
3537 def SetFineness(self, theFineness):
3538 if self.Parameters():
3539 self.params.SetFineness(theFineness)
3543 # Only for algoType == NETGEN
3544 # @ingroup l3_hypos_netgen
3545 def SetGrowthRate(self, theRate):
3546 if self.Parameters():
3547 self.params.SetGrowthRate(theRate)
3549 ## Sets NbSegPerEdge
3551 # Only for algoType == NETGEN
3552 # @ingroup l3_hypos_netgen
3553 def SetNbSegPerEdge(self, theVal):
3554 if self.Parameters():
3555 self.params.SetNbSegPerEdge(theVal)
3557 ## Sets NbSegPerRadius
3559 # Only for algoType == NETGEN
3560 # @ingroup l3_hypos_netgen
3561 def SetNbSegPerRadius(self, theVal):
3562 if self.Parameters():
3563 self.params.SetNbSegPerRadius(theVal)
3565 ## Sets number of segments overriding value set by SetLocalLength()
3567 # Only for algoType == NETGEN
3568 # @ingroup l3_hypos_netgen
3569 def SetNumberOfSegments(self, theVal):
3570 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3572 ## Sets number of segments overriding value set by SetNumberOfSegments()
3574 # Only for algoType == NETGEN
3575 # @ingroup l3_hypos_netgen
3576 def SetLocalLength(self, theVal):
3577 self.Parameters(SIMPLE).SetLocalLength(theVal)
3582 # Public class: Mesh_Quadrangle
3583 # -----------------------------
3585 ## Defines a quadrangle 2D algorithm
3587 # @ingroup l3_algos_basic
3588 class Mesh_Quadrangle(Mesh_Algorithm):
3590 ## Private constructor.
3591 def __init__(self, mesh, geom=0):
3592 Mesh_Algorithm.__init__(self)
3593 self.Create(mesh, geom, "Quadrangle_2D")
3595 ## Defines "QuadranglePreference" hypothesis, forcing construction
3596 # of quadrangles if the number of nodes on the opposite edges is not the same
3597 # while the total number of nodes on edges is even
3599 # @ingroup l3_hypos_additi
3600 def QuadranglePreference(self):
3601 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3602 CompareMethod=self.CompareEqualHyp)
3605 ## Defines "TrianglePreference" hypothesis, forcing construction
3606 # of triangles in the refinement area if the number of nodes
3607 # on the opposite edges is not the same
3609 # @ingroup l3_hypos_additi
3610 def TrianglePreference(self):
3611 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3612 CompareMethod=self.CompareEqualHyp)
3615 # Public class: Mesh_Tetrahedron
3616 # ------------------------------
3618 ## Defines a tetrahedron 3D algorithm
3620 # @ingroup l3_algos_basic
3621 class Mesh_Tetrahedron(Mesh_Algorithm):
3626 ## Private constructor.
3627 def __init__(self, mesh, algoType, geom=0):
3628 Mesh_Algorithm.__init__(self)
3630 if algoType == NETGEN:
3631 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3634 elif algoType == FULL_NETGEN:
3636 print "Warning: NETGENPlugin module has not been imported."
3637 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3640 elif algoType == GHS3D:
3642 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3645 self.algoType = algoType
3647 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3648 # @param vol for the maximum volume of each tetrahedron
3649 # @param UseExisting if ==true - searches for the existing hypothesis created with
3650 # the same parameters, else (default) - creates a new one
3651 # @ingroup l3_hypos_maxvol
3652 def MaxElementVolume(self, vol, UseExisting=0):
3653 if self.algoType == NETGEN:
3654 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3655 CompareMethod=self.CompareMaxElementVolume)
3656 hyp.SetMaxElementVolume(vol)
3658 elif self.algoType == FULL_NETGEN:
3659 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3662 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3663 def CompareMaxElementVolume(self, hyp, args):
3664 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3666 ## Defines hypothesis having several parameters
3668 # @ingroup l3_hypos_netgen
3669 def Parameters(self, which=SOLE):
3672 if self.algoType == FULL_NETGEN:
3674 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3675 "libNETGENEngine.so", UseExisting=0)
3677 self.params = self.Hypothesis("NETGEN_Parameters", [],
3678 "libNETGENEngine.so", UseExisting=0)
3680 if self.algoType == GHS3D:
3681 self.params = self.Hypothesis("GHS3D_Parameters", [],
3682 "libGHS3DEngine.so", UseExisting=0)
3685 print "Algo supports no multi-parameter hypothesis"
3689 # Parameter of FULL_NETGEN
3690 # @ingroup l3_hypos_netgen
3691 def SetMaxSize(self, theSize):
3692 self.Parameters().SetMaxSize(theSize)
3694 ## Sets SecondOrder flag
3695 # Parameter of FULL_NETGEN
3696 # @ingroup l3_hypos_netgen
3697 def SetSecondOrder(self, theVal):
3698 self.Parameters().SetSecondOrder(theVal)
3700 ## Sets Optimize flag
3701 # Parameter of FULL_NETGEN
3702 # @ingroup l3_hypos_netgen
3703 def SetOptimize(self, theVal):
3704 self.Parameters().SetOptimize(theVal)
3707 # @param theFineness is:
3708 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3709 # Parameter of FULL_NETGEN
3710 # @ingroup l3_hypos_netgen
3711 def SetFineness(self, theFineness):
3712 self.Parameters().SetFineness(theFineness)
3715 # Parameter of FULL_NETGEN
3716 # @ingroup l3_hypos_netgen
3717 def SetGrowthRate(self, theRate):
3718 self.Parameters().SetGrowthRate(theRate)
3720 ## Sets NbSegPerEdge
3721 # Parameter of FULL_NETGEN
3722 # @ingroup l3_hypos_netgen
3723 def SetNbSegPerEdge(self, theVal):
3724 self.Parameters().SetNbSegPerEdge(theVal)
3726 ## Sets NbSegPerRadius
3727 # Parameter of FULL_NETGEN
3728 # @ingroup l3_hypos_netgen
3729 def SetNbSegPerRadius(self, theVal):
3730 self.Parameters().SetNbSegPerRadius(theVal)
3732 ## Sets number of segments overriding value set by SetLocalLength()
3733 # Only for algoType == NETGEN_FULL
3734 # @ingroup l3_hypos_netgen
3735 def SetNumberOfSegments(self, theVal):
3736 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3738 ## Sets number of segments overriding value set by SetNumberOfSegments()
3739 # Only for algoType == NETGEN_FULL
3740 # @ingroup l3_hypos_netgen
3741 def SetLocalLength(self, theVal):
3742 self.Parameters(SIMPLE).SetLocalLength(theVal)
3744 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3745 # Overrides value set by LengthFromEdges()
3746 # Only for algoType == NETGEN_FULL
3747 # @ingroup l3_hypos_netgen
3748 def MaxElementArea(self, area):
3749 self.Parameters(SIMPLE).SetMaxElementArea(area)
3751 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3752 # Overrides value set by MaxElementArea()
3753 # Only for algoType == NETGEN_FULL
3754 # @ingroup l3_hypos_netgen
3755 def LengthFromEdges(self):
3756 self.Parameters(SIMPLE).LengthFromEdges()
3758 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3759 # Overrides value set by MaxElementVolume()
3760 # Only for algoType == NETGEN_FULL
3761 # @ingroup l3_hypos_netgen
3762 def LengthFromFaces(self):
3763 self.Parameters(SIMPLE).LengthFromFaces()
3765 ## To mesh "holes" in a solid or not. Default is to mesh.
3766 # @ingroup l3_hypos_ghs3dh
3767 def SetToMeshHoles(self, toMesh):
3768 # Parameter of GHS3D
3769 self.Parameters().SetToMeshHoles(toMesh)
3771 ## Set Optimization level:
3772 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3773 # Default is Medium_Optimization
3774 # @ingroup l3_hypos_ghs3dh
3775 def SetOptimizationLevel(self, level):
3776 # Parameter of GHS3D
3777 self.Parameters().SetOptimizationLevel(level)
3779 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3780 # @ingroup l3_hypos_ghs3dh
3781 def SetMaximumMemory(self, MB):
3782 # Advanced parameter of GHS3D
3783 self.Parameters().SetMaximumMemory(MB)
3785 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3786 # automatic memory adjustment mode.
3787 # @ingroup l3_hypos_ghs3dh
3788 def SetInitialMemory(self, MB):
3789 # Advanced parameter of GHS3D
3790 self.Parameters().SetInitialMemory(MB)
3792 ## Path to working directory.
3793 # @ingroup l3_hypos_ghs3dh
3794 def SetWorkingDirectory(self, path):
3795 # Advanced parameter of GHS3D
3796 self.Parameters().SetWorkingDirectory(path)
3798 ## To keep working files or remove them. Log file remains in case of errors anyway.
3799 # @ingroup l3_hypos_ghs3dh
3800 def SetKeepFiles(self, toKeep):
3801 # Advanced parameter of GHS3D
3802 self.Parameters().SetKeepFiles(toKeep)
3804 ## To set verbose level [0-10]. <ul>
3805 #<li> 0 - no standard output,
3806 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3807 # indicates when the final mesh is being saved. In addition the software
3808 # gives indication regarding the CPU time.
3809 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3810 # histogram of the skin mesh, quality statistics histogram together with
3811 # the characteristics of the final mesh.</ul>
3812 # @ingroup l3_hypos_ghs3dh
3813 def SetVerboseLevel(self, level):
3814 # Advanced parameter of GHS3D
3815 self.Parameters().SetVerboseLevel(level)
3817 ## To create new nodes.
3818 # @ingroup l3_hypos_ghs3dh
3819 def SetToCreateNewNodes(self, toCreate):
3820 # Advanced parameter of GHS3D
3821 self.Parameters().SetToCreateNewNodes(toCreate)
3823 ## To use boundary recovery version which tries to create mesh on a very poor
3824 # quality surface mesh.
3825 # @ingroup l3_hypos_ghs3dh
3826 def SetToUseBoundaryRecoveryVersion(self, toUse):
3827 # Advanced parameter of GHS3D
3828 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3830 ## Sets command line option as text.
3831 # @ingroup l3_hypos_ghs3dh
3832 def SetTextOption(self, option):
3833 # Advanced parameter of GHS3D
3834 self.Parameters().SetTextOption(option)
3836 # Public class: Mesh_Hexahedron
3837 # ------------------------------
3839 ## Defines a hexahedron 3D algorithm
3841 # @ingroup l3_algos_basic
3842 class Mesh_Hexahedron(Mesh_Algorithm):
3847 ## Private constructor.
3848 def __init__(self, mesh, algoType=Hexa, geom=0):
3849 Mesh_Algorithm.__init__(self)
3851 self.algoType = algoType
3853 if algoType == Hexa:
3854 self.Create(mesh, geom, "Hexa_3D")
3857 elif algoType == Hexotic:
3858 import HexoticPlugin
3859 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3862 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3863 # @ingroup l3_hypos_hexotic
3864 def MinMaxQuad(self, min=3, max=8, quad=True):
3865 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3867 self.params.SetHexesMinLevel(min)
3868 self.params.SetHexesMaxLevel(max)
3869 self.params.SetHexoticQuadrangles(quad)
3872 # Deprecated, only for compatibility!
3873 # Public class: Mesh_Netgen
3874 # ------------------------------
3876 ## Defines a NETGEN-based 2D or 3D algorithm
3877 # that needs no discrete boundary (i.e. independent)
3879 # This class is deprecated, only for compatibility!
3882 # @ingroup l3_algos_basic
3883 class Mesh_Netgen(Mesh_Algorithm):
3887 ## Private constructor.
3888 def __init__(self, mesh, is3D, geom=0):
3889 Mesh_Algorithm.__init__(self)
3892 print "Warning: NETGENPlugin module has not been imported."
3896 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3900 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3903 ## Defines the hypothesis containing parameters of the algorithm
3904 def Parameters(self):
3906 hyp = self.Hypothesis("NETGEN_Parameters", [],
3907 "libNETGENEngine.so", UseExisting=0)
3909 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3910 "libNETGENEngine.so", UseExisting=0)
3913 # Public class: Mesh_Projection1D
3914 # ------------------------------
3916 ## Defines a projection 1D algorithm
3917 # @ingroup l3_algos_proj
3919 class Mesh_Projection1D(Mesh_Algorithm):
3921 ## Private constructor.
3922 def __init__(self, mesh, geom=0):
3923 Mesh_Algorithm.__init__(self)
3924 self.Create(mesh, geom, "Projection_1D")
3926 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3927 # a mesh pattern is taken, and, optionally, the association of vertices
3928 # between the source edge and a target edge (to which a hypothesis is assigned)
3929 # @param edge from which nodes distribution is taken
3930 # @param mesh from which nodes distribution is taken (optional)
3931 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3932 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3933 # to associate with \a srcV (optional)
3934 # @param UseExisting if ==true - searches for the existing hypothesis created with
3935 # the same parameters, else (default) - creates a new one
3936 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3937 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3939 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3940 hyp.SetSourceEdge( edge )
3941 if not mesh is None and isinstance(mesh, Mesh):
3942 mesh = mesh.GetMesh()
3943 hyp.SetSourceMesh( mesh )
3944 hyp.SetVertexAssociation( srcV, tgtV )
3947 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3948 #def CompareSourceEdge(self, hyp, args):
3949 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3953 # Public class: Mesh_Projection2D
3954 # ------------------------------
3956 ## Defines a projection 2D algorithm
3957 # @ingroup l3_algos_proj
3959 class Mesh_Projection2D(Mesh_Algorithm):
3961 ## Private constructor.
3962 def __init__(self, mesh, geom=0):
3963 Mesh_Algorithm.__init__(self)
3964 self.Create(mesh, geom, "Projection_2D")
3966 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3967 # a mesh pattern is taken, and, optionally, the association of vertices
3968 # between the source face and the target face (to which a hypothesis is assigned)
3969 # @param face from which the mesh pattern is taken
3970 # @param mesh from which the mesh pattern is taken (optional)
3971 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3972 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3973 # to associate with \a srcV1 (optional)
3974 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3975 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3976 # to associate with \a srcV2 (optional)
3977 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3978 # the same parameters, else (default) - forces the creation a new one
3980 # Note: all association vertices must belong to one edge of a face
3981 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3982 srcV2=None, tgtV2=None, UseExisting=0):
3983 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3985 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3986 hyp.SetSourceFace( face )
3987 if not mesh is None and isinstance(mesh, Mesh):
3988 mesh = mesh.GetMesh()
3989 hyp.SetSourceMesh( mesh )
3990 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3993 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3994 #def CompareSourceFace(self, hyp, args):
3995 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3998 # Public class: Mesh_Projection3D
3999 # ------------------------------
4001 ## Defines a projection 3D algorithm
4002 # @ingroup l3_algos_proj
4004 class Mesh_Projection3D(Mesh_Algorithm):
4006 ## Private constructor.
4007 def __init__(self, mesh, geom=0):
4008 Mesh_Algorithm.__init__(self)
4009 self.Create(mesh, geom, "Projection_3D")
4011 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4012 # the mesh pattern is taken, and, optionally, the association of vertices
4013 # between the source and the target solid (to which a hipothesis is assigned)
4014 # @param solid from where the mesh pattern is taken
4015 # @param mesh from where the mesh pattern is taken (optional)
4016 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4017 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4018 # to associate with \a srcV1 (optional)
4019 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4020 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4021 # to associate with \a srcV2 (optional)
4022 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4023 # the same parameters, else (default) - creates a new one
4025 # Note: association vertices must belong to one edge of a solid
4026 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4027 srcV2=0, tgtV2=0, UseExisting=0):
4028 hyp = self.Hypothesis("ProjectionSource3D",
4029 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4031 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4032 hyp.SetSource3DShape( solid )
4033 if not mesh is None and isinstance(mesh, Mesh):
4034 mesh = mesh.GetMesh()
4035 hyp.SetSourceMesh( mesh )
4036 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4039 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4040 #def CompareSourceShape3D(self, hyp, args):
4041 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4045 # Public class: Mesh_Prism
4046 # ------------------------
4048 ## Defines a 3D extrusion algorithm
4049 # @ingroup l3_algos_3dextr
4051 class Mesh_Prism3D(Mesh_Algorithm):
4053 ## Private constructor.
4054 def __init__(self, mesh, geom=0):
4055 Mesh_Algorithm.__init__(self)
4056 self.Create(mesh, geom, "Prism_3D")
4058 # Public class: Mesh_RadialPrism
4059 # -------------------------------
4061 ## Defines a Radial Prism 3D algorithm
4062 # @ingroup l3_algos_radialp
4064 class Mesh_RadialPrism3D(Mesh_Algorithm):
4066 ## Private constructor.
4067 def __init__(self, mesh, geom=0):
4068 Mesh_Algorithm.__init__(self)
4069 self.Create(mesh, geom, "RadialPrism_3D")
4071 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4072 self.nbLayers = None
4074 ## Return 3D hypothesis holding the 1D one
4075 def Get3DHypothesis(self):
4076 return self.distribHyp
4078 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4079 # hypothesis. Returns the created hypothesis
4080 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4081 #print "OwnHypothesis",hypType
4082 if not self.nbLayers is None:
4083 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4084 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4085 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4086 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4087 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4088 self.distribHyp.SetLayerDistribution( hyp )
4091 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4092 # prisms to build between the inner and outer shells
4093 # @param n number of layers
4094 # @param UseExisting if ==true - searches for the existing hypothesis created with
4095 # the same parameters, else (default) - creates a new one
4096 def NumberOfLayers(self, n, UseExisting=0):
4097 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4098 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4099 CompareMethod=self.CompareNumberOfLayers)
4100 self.nbLayers.SetNumberOfLayers( n )
4101 return self.nbLayers
4103 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4104 def CompareNumberOfLayers(self, hyp, args):
4105 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4107 ## Defines "LocalLength" hypothesis, specifying the segment length
4108 # to build between the inner and the outer shells
4109 # @param l the length of segments
4110 # @param p the precision of rounding
4111 def LocalLength(self, l, p=1e-07):
4112 hyp = self.OwnHypothesis("LocalLength", [l,p])
4117 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4118 # prisms to build between the inner and the outer shells.
4119 # @param n the number of layers
4120 # @param s the scale factor (optional)
4121 def NumberOfSegments(self, n, s=[]):
4123 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4125 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4126 hyp.SetDistrType( 1 )
4127 hyp.SetScaleFactor(s)
4128 hyp.SetNumberOfSegments(n)
4131 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4132 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4133 # @param start the length of the first segment
4134 # @param end the length of the last segment
4135 def Arithmetic1D(self, start, end ):
4136 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4137 hyp.SetLength(start, 1)
4138 hyp.SetLength(end , 0)
4141 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4142 # to build between the inner and the outer shells as geometric length increasing
4143 # @param start for the length of the first segment
4144 # @param end for the length of the last segment
4145 def StartEndLength(self, start, end):
4146 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4147 hyp.SetLength(start, 1)
4148 hyp.SetLength(end , 0)
4151 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4152 # to build between the inner and outer shells
4153 # @param fineness defines the quality of the mesh within the range [0-1]
4154 def AutomaticLength(self, fineness=0):
4155 hyp = self.OwnHypothesis("AutomaticLength")
4156 hyp.SetFineness( fineness )
4159 # Private class: Mesh_UseExisting
4160 # -------------------------------
4161 class Mesh_UseExisting(Mesh_Algorithm):
4163 def __init__(self, dim, mesh, geom=0):
4165 self.Create(mesh, geom, "UseExisting_1D")
4167 self.Create(mesh, geom, "UseExisting_2D")