21 ## MirrorType enumeration
22 POINT = SMESH_MeshEditor.POINT
23 AXIS = SMESH_MeshEditor.AXIS
24 PLANE = SMESH_MeshEditor.PLANE
26 ## Smooth_Method enumeration
27 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
28 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
30 ## Fineness enumeration(for NETGEN)
42 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
43 smesh.SetCurrentStudy(salome.myStudy)
49 ior = salome.orb.object_to_string(obj)
50 sobj = salome.myStudy.FindObjectIOR(ior)
54 attr = sobj.FindAttribute("AttributeName")[1]
57 ## Sets name to object
58 def SetName(obj, name):
59 ior = salome.orb.object_to_string(obj)
60 sobj = salome.myStudy.FindObjectIOR(ior)
62 attr = sobj.FindAttribute("AttributeName")[1]
65 ## Returns long value from enumeration
66 # Uses for FT_... enumeration
67 def EnumToLong(theItem):
70 ## Get PointStruct from vertex
71 # @param theVertex is GEOM object(vertex)
72 # @return SMESH.PointStruct
73 def GetPointStruct(theVertex):
74 [x, y, z] = geompy.PointCoordinates(theVertex)
75 return PointStruct(x,y,z)
77 ## Get DirStruct from vector
78 # @param theVector is GEOM object(vector)
79 # @return SMESH.DirStruct
80 def GetDirStruct(theVector):
81 vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] )
82 if(len(vertices) != 2):
83 print "Error: vector object is incorrect."
85 p1 = geompy.PointCoordinates(vertices[0])
86 p2 = geompy.PointCoordinates(vertices[1])
87 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
91 ## Get AxisStruct from object
92 # @param theObj is GEOM object(line or plane)
93 # @return SMESH.AxisStruct
94 def GetAxisStruct(theObj):
95 edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] )
97 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
98 vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] )
99 vertex1 = geompy.PointCoordinates(vertex1)
100 vertex2 = geompy.PointCoordinates(vertex2)
101 vertex3 = geompy.PointCoordinates(vertex3)
102 vertex4 = geompy.PointCoordinates(vertex4)
103 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
104 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
105 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] ]
106 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
108 elif len(edges) == 1:
109 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
110 p1 = geompy.PointCoordinates( vertex1 )
111 p2 = geompy.PointCoordinates( vertex2 )
112 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
116 ## From SMESH_Gen interface:
117 # ------------------------
119 ## Set the current mode
120 def SetEmbeddedMode( theMode ):
121 smesh.SetEmbeddedMode(theMode)
123 ## Get the current mode
124 def IsEmbeddedMode():
125 return smesh.IsEmbeddedMode()
127 ## Set the current study
128 def SetCurrentStudy( theStudy ):
129 smesh.SetCurrentStudy(theStudy)
131 ## Get the current study
132 def GetCurrentStudy():
133 return smesh.GetCurrentStudy()
135 ## Create Mesh object importing data from given UNV file
136 # @return an instance of Mesh class
137 def CreateMeshesFromUNV( theFileName ):
138 aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName)
139 aMesh = Mesh(aSmeshMesh)
142 ## Create Mesh object(s) importing data from given MED file
143 # @return a list of Mesh class instances
144 def CreateMeshesFromMED( theFileName ):
145 aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName)
147 for iMesh in range(len(aSmeshMeshes)) :
148 aMesh = Mesh(aSmeshMeshes[iMesh])
149 aMeshes.append(aMesh)
150 return aMeshes, aStatus
152 ## Create Mesh object importing data from given STL file
153 # @return an instance of Mesh class
154 def CreateMeshesFromSTL( theFileName ):
155 aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName)
156 aMesh = Mesh(aSmeshMesh)
159 ## From SMESH_Gen interface
160 def GetSubShapesId( theMainObject, theListOfSubObjects ):
161 return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
163 ## From SMESH_Gen interface. Creates pattern
165 return smesh.GetPattern()
169 ## Filtering. Auxiliary functions:
170 # ------------------------------
172 ## Creates an empty criterion
173 # @return SMESH.Filter.Criterion
174 def GetEmptyCriterion():
175 Type = EnumToLong(FT_Undefined)
176 Compare = EnumToLong(FT_Undefined)
180 UnaryOp = EnumToLong(FT_Undefined)
181 BinaryOp = EnumToLong(FT_Undefined)
184 Precision = -1 ##@1e-07
185 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
186 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
188 ## Creates a criterion by given parameters
189 # @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
190 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
191 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
192 # @param Treshold is threshold value (range of ids as string, shape, numeric)
193 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
194 # @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
195 # FT_Undefined(must be for the last criterion in criteria)
196 # @return SMESH.Filter.Criterion
197 def GetCriterion(elementType,
199 Compare = FT_EqualTo,
201 UnaryOp=FT_Undefined,
202 BinaryOp=FT_Undefined):
203 aCriterion = GetEmptyCriterion()
204 aCriterion.TypeOfElement = elementType
205 aCriterion.Type = EnumToLong(CritType)
209 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
210 aCriterion.Compare = EnumToLong(Compare)
212 aCriterion.Compare = EnumToLong(FT_EqualTo)
215 if CritType in [FT_BelongToGeom, FT_BelongToPlane,
216 FT_BelongToCylinder, FT_LyingOnGeom]:
218 if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object):
219 aCriterion.ThresholdStr = GetName(aTreshold)
220 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
222 print "Error: Treshold should be a shape."
224 elif CritType == FT_RangeOfIds:
226 if isinstance(aTreshold, str):
227 aCriterion.ThresholdStr = aTreshold
229 print "Error: Treshold should be a string."
231 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
232 # Here we don't need treshold
233 if aTreshold == FT_LogicalNOT:
234 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
235 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
236 aCriterion.BinaryOp = aTreshold
240 aTreshold = float(aTreshold)
241 aCriterion.Threshold = aTreshold
243 print "Error: Treshold should be a number."
246 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
247 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
249 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
250 aCriterion.BinaryOp = EnumToLong(Treshold)
252 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
253 aCriterion.BinaryOp = EnumToLong(UnaryOp)
255 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
256 aCriterion.BinaryOp = EnumToLong(BinaryOp)
260 ## Creates filter by given parameters of criterion
261 # @param elementType is the type of elements in the group
262 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
263 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
264 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
265 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
266 # @return SMESH_Filter
267 def GetFilter(elementType,
268 CritType=FT_Undefined,
271 UnaryOp=FT_Undefined):
272 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
273 aFilterMgr = smesh.CreateFilterManager()
274 aFilter = aFilterMgr.CreateFilter()
276 aCriteria.append(aCriterion)
277 aFilter.SetCriteria(aCriteria)
280 ## Creates numerical functor by its type
281 # @param theCrierion is FT_...; functor type
282 # @return SMESH_NumericalFunctor
283 def GetFunctor(theCriterion):
284 aFilterMgr = smesh.CreateFilterManager()
285 if theCriterion == FT_AspectRatio:
286 return aFilterMgr.CreateAspectRatio()
287 elif theCriterion == FT_AspectRatio3D:
288 return aFilterMgr.CreateAspectRatio3D()
289 elif theCriterion == FT_Warping:
290 return aFilterMgr.CreateWarping()
291 elif theCriterion == FT_MinimumAngle:
292 return aFilterMgr.CreateMinimumAngle()
293 elif theCriterion == FT_Taper:
294 return aFilterMgr.CreateTaper()
295 elif theCriterion == FT_Skew:
296 return aFilterMgr.CreateSkew()
297 elif theCriterion == FT_Area:
298 return aFilterMgr.CreateArea()
299 elif theCriterion == FT_Volume3D:
300 return aFilterMgr.CreateVolume3D()
301 elif theCriterion == FT_MultiConnection:
302 return aFilterMgr.CreateMultiConnection()
303 elif theCriterion == FT_MultiConnection2D:
304 return aFilterMgr.CreateMultiConnection2D()
305 elif theCriterion == FT_Length:
306 return aFilterMgr.CreateLength()
307 elif theCriterion == FT_Length2D:
308 return aFilterMgr.CreateLength2D()
310 print "Error: given parameter is not numerucal functor type."
315 ## Mother class to define algorithm, recommended to don't use directly.
318 class Mesh_Algorithm:
319 # @class Mesh_Algorithm
320 # @brief Class Mesh_Algorithm
327 ## If the algorithm is global, return 0
328 # \fn else return the submesh associated to this algorithm.
331 def GetSubMesh(self):
334 ## Return the wrapped mesher.
335 def GetAlgorithm(self):
338 ## Get list of hypothesis that can be used with this algorithm
339 def GetCompatibleHypothesis(self):
342 list = self.algo.GetCompatibleHypothesis()
350 def SetName(self, name):
351 SetName(self.algo, name)
355 return self.algo.GetId()
357 ## Private method. Print error message if a hypothesis was not assigned.
358 def TreatHypoStatus(self, status, hypName, geomName, isAlgo):
360 hypType = "algorithm"
362 hypType = "hypothesis"
363 if status == HYP_UNKNOWN_FATAL :
364 reason = "for unknown reason"
365 elif status == HYP_INCOMPATIBLE :
366 reason = "this hypothesis mismatches algorithm"
367 elif status == HYP_NOTCONFORM :
368 reason = "not conform mesh would be built"
369 elif status == HYP_ALREADY_EXIST :
370 reason = hypType + " of the same dimension already assigned to this shape"
371 elif status == HYP_BAD_DIM :
372 reason = hypType + " mismatches shape"
373 elif status == HYP_CONCURENT :
374 reason = "there are concurrent hypotheses on sub-shapes"
375 elif status == HYP_BAD_SUBSHAPE :
376 reason = "shape is neither the main one, nor its subshape, nor a valid group"
379 hypName = '"' + hypName + '"'
380 geomName= '"' + geomName+ '"'
381 if status < HYP_UNKNOWN_FATAL:
382 print hypName, "was assigned to", geomName,"but", reason
384 print hypName, "was not assigned to",geomName,":", reason
388 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
390 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
395 name = GetName(piece)
400 name = geompy.SubShapeName(geom, piece)
401 geompy.addToStudyInFather(piece, geom, name)
402 self.subm = mesh.mesh.GetSubMesh(geom, hypo)
404 self.algo = smesh.CreateHypothesis(hypo, so)
405 SetName(self.algo, name + "/" + hypo)
406 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
407 self.TreatHypoStatus( status, hypo, name, 1 )
410 def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
411 hypo = smesh.CreateHypothesis(hyp, so)
417 a = a + s + str(args[i])
420 name = GetName(self.geom)
421 SetName(hypo, name + "/" + hyp + a)
422 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
423 self.TreatHypoStatus( status, hyp, name, 0 )
427 # Public class: Mesh_Segment
428 # --------------------------
430 ## Class to define a segment 1D algorithm for discretization
433 class Mesh_Segment(Mesh_Algorithm):
435 ## Private constructor.
436 def __init__(self, mesh, geom=0):
437 self.Create(mesh, geom, "Regular_1D")
439 ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
440 # @param l for the length of segments that cut an edge
441 def LocalLength(self, l):
442 hyp = self.Hypothesis("LocalLength", [l])
446 ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
447 # @param n for the number of segments that cut an edge
448 # @param s for the scale factor (optional)
449 def NumberOfSegments(self, n, s=[]):
451 hyp = self.Hypothesis("NumberOfSegments", [n])
453 hyp = self.Hypothesis("NumberOfSegments", [n,s])
454 hyp.SetDistrType( 1 )
455 hyp.SetScaleFactor(s)
456 hyp.SetNumberOfSegments(n)
459 ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
460 # @param start for the length of the first segment
461 # @param end for the length of the last segment
462 def Arithmetic1D(self, start, end):
463 hyp = self.Hypothesis("Arithmetic1D", [start, end])
464 hyp.SetLength(start, 1)
465 hyp.SetLength(end , 0)
468 ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
469 # @param start for the length of the first segment
470 # @param end for the length of the last segment
471 def StartEndLength(self, start, end):
472 hyp = self.Hypothesis("StartEndLength", [start, end])
473 hyp.SetLength(start, 1)
474 hyp.SetLength(end , 0)
477 ## Define "Deflection1D" hypothesis
478 # @param d for the deflection
479 def Deflection1D(self, d):
480 hyp = self.Hypothesis("Deflection1D", [d])
484 ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
485 # the opposite side in the case of quadrangular faces
486 def Propagation(self):
487 return self.Hypothesis("Propagation")
489 ## Define "AutomaticLength" hypothesis
490 # @param fineness for the fineness [0-1]
491 def AutomaticLength(self, fineness=0):
492 hyp = self.Hypothesis("AutomaticLength")
493 hyp.SetFineness( fineness )
496 ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
497 # If the 2D mesher sees that all boundary edges are quadratic ones,
498 # it generates quadratic faces, else it generates linear faces using
499 # medium nodes as if they were vertex ones.
500 # The 3D mesher generates quadratic volumes only if all boundary faces
501 # are quadratic ones, else it fails.
502 def QuadraticMesh(self):
503 hyp = self.Hypothesis("QuadraticMesh")
506 # Public class: Mesh_Segment_Python
507 # ---------------------------------
509 ## Class to define a segment 1D algorithm for discretization with python function
512 class Mesh_Segment_Python(Mesh_Segment):
514 ## Private constructor.
515 def __init__(self, mesh, geom=0):
516 import Python1dPlugin
517 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
519 ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
520 # @param n for the number of segments that cut an edge
521 # @param func for the python function that calculate the length of all segments
522 def PythonSplit1D(self, n, func):
523 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so")
524 hyp.SetNumberOfSegments(n)
525 hyp.SetPythonLog10RatioFunction(func)
528 # Public class: Mesh_Triangle
529 # ---------------------------
531 ## Class to define a triangle 2D algorithm
534 class Mesh_Triangle(Mesh_Algorithm):
539 ## Private constructor.
540 def __init__(self, mesh, algoType, geom=0):
541 if algoType == MEFISTO:
542 self.Create(mesh, geom, "MEFISTO_2D")
543 elif algoType == NETGEN:
544 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
545 self.algoType = algoType
547 ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
548 # @param area for the maximum area of each triangles
549 def MaxElementArea(self, area):
550 if self.algoType == MEFISTO:
551 hyp = self.Hypothesis("MaxElementArea", [area])
552 hyp.SetMaxElementArea(area)
554 elif self.algoType == NETGEN:
555 print "Netgen 1D-2D algo doesn't support this hypothesis"
558 ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
559 def LengthFromEdges(self):
560 if self.algoType == MEFISTO:
561 hyp = self.Hypothesis("LengthFromEdges")
563 elif self.algoType == NETGEN:
564 print "Netgen 1D-2D algo doesn't support this hypothesis"
567 ## Define "Netgen 2D Parameters" hypothesis
568 def Parameters(self):
569 if self.algoType == NETGEN:
570 self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
572 elif self.algoType == MEFISTO:
573 print "Mefisto algo doesn't support this hypothesis"
577 def SetMaxSize(self, theSize):
580 self.params.SetMaxSize(theSize)
582 ## Set SecondOrder flag
583 def SetSecondOrder(seld, theVal):
586 self.params.SetSecondOrder(theVal)
589 def SetOptimize(self, theVal):
592 self.params.SetOptimize(theVal)
595 # @param theFineness is:
596 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
597 def SetFineness(self, theFineness):
600 self.params.SetFineness(theFineness)
603 def SetGrowthRate(self, theRate):
606 self.params.SetGrowthRate(theRate)
609 def SetNbSegPerEdge(self, theVal):
612 self.params.SetNbSegPerEdge(theVal)
614 ## Set NbSegPerRadius
615 def SetNbSegPerRadius(self, theVal):
618 self.params.SetNbSegPerRadius(theVal)
620 ## Set QuadAllowed flag
621 def SetQuadAllowed(self, toAllow):
624 self.params.SetQuadAllowed(toAllow)
627 # Public class: Mesh_Quadrangle
628 # -----------------------------
630 ## Class to define a quadrangle 2D algorithm
633 class Mesh_Quadrangle(Mesh_Algorithm):
635 ## Private constructor.
636 def __init__(self, mesh, geom=0):
637 self.Create(mesh, geom, "Quadrangle_2D")
639 ## Define "QuadranglePreference" hypothesis, forcing construction
640 # of quadrangles if the number of nodes on opposite edges is not the same
641 # in the case where the global number of nodes on edges is even
642 def QuadranglePreference(self):
643 hyp = self.Hypothesis("QuadranglePreference")
646 # Public class: Mesh_Tetrahedron
647 # ------------------------------
649 ## Class to define a tetrahedron 3D algorithm
652 class Mesh_Tetrahedron(Mesh_Algorithm):
657 ## Private constructor.
658 def __init__(self, mesh, algoType, geom=0):
659 if algoType == NETGEN:
660 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
661 elif algoType == GHS3D:
663 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
664 elif algoType == FULL_NETGEN:
665 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
666 self.algoType = algoType
668 ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
669 # @param vol for the maximum volume of each tetrahedral
670 def MaxElementVolume(self, vol):
671 hyp = self.Hypothesis("MaxElementVolume", [vol])
672 hyp.SetMaxElementVolume(vol)
675 ## Define "Netgen 3D Parameters" hypothesis
676 def Parameters(self):
677 if (self.algoType == FULL_NETGEN):
678 self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
681 print "Algo doesn't support this hypothesis"
685 def SetMaxSize(self, theSize):
688 self.params.SetMaxSize(theSize)
690 ## Set SecondOrder flag
691 def SetSecondOrder(self, theVal):
694 self.params.SetSecondOrder(theVal)
697 def SetOptimize(self, theVal):
700 self.params.SetOptimize(theVal)
703 # @param theFineness is:
704 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
705 def SetFineness(self, theFineness):
708 self.params.SetFineness(theFineness)
711 def SetGrowthRate(self, theRate):
714 self.params.SetGrowthRate(theRate)
717 def SetNbSegPerEdge(self, theVal):
720 self.params.SetNbSegPerEdge(theVal)
722 ## Set NbSegPerRadius
723 def SetNbSegPerRadius(self, theVal):
726 self.params.SetNbSegPerRadius(theVal)
728 # Public class: Mesh_Hexahedron
729 # ------------------------------
731 ## Class to define a hexahedron 3D algorithm
734 class Mesh_Hexahedron(Mesh_Algorithm):
736 ## Private constructor.
737 def __init__(self, mesh, geom=0):
738 self.Create(mesh, geom, "Hexa_3D")
740 # Deprecated, only for compatibility!
741 # Public class: Mesh_Netgen
742 # ------------------------------
744 ## Class to define a NETGEN-based 2D or 3D algorithm
745 # that need no discrete boundary (i.e. independent)
748 class Mesh_Netgen(Mesh_Algorithm):
752 ## Private constructor.
753 def __init__(self, mesh, is3D, geom=0):
756 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
758 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
760 ## Define hypothesis containing parameters of the algorithm
761 def Parameters(self):
763 hyp = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
765 hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
771 ## Class to define a mesh
773 # The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
783 # Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
784 # sets GUI name of this mesh to \a name.
785 # @param obj Shape to be meshed or SMESH_Mesh object
786 # @param name Study name of the mesh
787 def __init__(self, obj=0, name=0):
789 if isinstance(obj, geompy.GEOM._objref_GEOM_Object):
791 self.mesh = smesh.CreateMesh(self.geom)
792 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
795 self.mesh = smesh.CreateEmptyMesh()
797 SetName(self.mesh, name)
799 SetName(self.mesh, GetName(obj))
801 self.editor = self.mesh.GetMeshEditor()
803 ## Method that inits the Mesh object from SMESH_Mesh interface
804 # @param theMesh is SMESH_Mesh object
805 def SetMesh(self, theMesh):
807 self.geom = self.mesh.GetShapeToMesh()
809 ## Method that returns the mesh
810 # @return SMESH_Mesh object
816 name = GetName(self.GetMesh())
820 def SetName(self, name):
821 SetName(self.GetMesh(), name)
823 ## Get the subMesh object associated to a subShape. The subMesh object
824 # gives access to nodes and elements IDs.
825 # SubMesh will be used instead of SubShape in a next idl version to
826 # adress a specific subMesh...
827 def GetSubMesh(self, theSubObject, name):
828 submesh = self.mesh.GetSubMesh(theSubObject, name)
831 ## Method that returns the shape associated to the mesh
832 # @return GEOM_Object
836 ## Method that associates given shape to the mesh(entails the mesh recreation)
837 # @param geom shape to be meshed(GEOM_Object)
838 def SetShape(self, geom):
839 self.mesh = smesh.CreateMesh(geom)
841 ## Return true if hypotheses are defined well
842 # @param theMesh is an instance of Mesh class
843 # @param theSubObject subshape of a mesh shape
844 def IsReadyToCompute(self, theSubObject):
845 return smesh.IsReadyToCompute(self.mesh, theSubObject)
847 ## Return errors of hypotheses definintion
848 # error list is empty if everything is OK
849 # @param theMesh is an instance of Mesh class
850 # @param theSubObject subshape of a mesh shape
851 # @return a list of errors
852 def GetAlgoState(self, theSubObject):
853 return smesh.GetAlgoState(self.mesh, theSubObject)
855 ## Return geometrical object the given element is built on.
856 # The returned geometrical object, if not nil, is either found in the
857 # study or is published by this method with the given name
858 # @param theMesh is an instance of Mesh class
859 # @param theElementID an id of the mesh element
860 # @param theGeomName user defined name of geometrical object
861 # @return GEOM::GEOM_Object instance
862 def GetGeometryByMeshElement(self, theElementID, theGeomName):
863 return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
865 ## Returns mesh dimension depending on shape one
866 def MeshDimension(self):
867 shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
868 if len( shells ) > 0 :
870 elif geompy.NumberOfFaces( self.geom ) > 0 :
872 elif geompy.NumberOfEdges( self.geom ) > 0 :
878 ## Creates a segment discretization 1D algorithm.
879 # If the optional \a algo parameter is not sets, this algorithm is REGULAR.
880 # If the optional \a geom parameter is not sets, this algorithm is global.
881 # Otherwise, this algorithm define a submesh based on \a geom subshape.
882 # @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
883 # @param geom If defined, subshape to be meshed
884 def Segment(self, algo=REGULAR, geom=0):
885 ## if Segment(geom) is called by mistake
886 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
887 algo, geom = geom, algo
890 return Mesh_Segment(self, geom)
892 return Mesh_Segment_Python(self, geom)
894 return Mesh_Segment(self, geom)
896 ## Creates a triangle 2D algorithm for faces.
897 # If the optional \a geom parameter is not sets, this algorithm is global.
898 # Otherwise, this algorithm define a submesh based on \a geom subshape.
899 # @param algo values are: smesh.MEFISTO or smesh.NETGEN
900 # @param geom If defined, subshape to be meshed
901 def Triangle(self, algo=MEFISTO, geom=0):
902 ## if Triangle(geom) is called by mistake
903 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
907 return Mesh_Triangle(self, algo, geom)
909 ## Creates a quadrangle 2D algorithm for faces.
910 # If the optional \a geom parameter is not sets, this algorithm is global.
911 # Otherwise, this algorithm define a submesh based on \a geom subshape.
912 # @param geom If defined, subshape to be meshed
913 def Quadrangle(self, geom=0):
914 return Mesh_Quadrangle(self, geom)
916 ## Creates a tetrahedron 3D algorithm for solids.
917 # The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
918 # If the optional \a geom parameter is not sets, this algorithm is global.
919 # Otherwise, this algorithm define a submesh based on \a geom subshape.
920 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
921 # @param geom If defined, subshape to be meshed
922 def Tetrahedron(self, algo=NETGEN, geom=0):
923 ## if Tetrahedron(geom) is called by mistake
924 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
925 algo, geom = geom, algo
927 return Mesh_Tetrahedron(self, algo, geom)
929 ## Creates a hexahedron 3D algorithm for solids.
930 # If the optional \a geom parameter is not sets, this algorithm is global.
931 # Otherwise, this algorithm define a submesh based on \a geom subshape.
932 # @param geom If defined, subshape to be meshed
933 def Hexahedron(self, geom=0):
934 return Mesh_Hexahedron(self, geom)
936 ## Deprecated, only for compatibility!
937 # Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no
938 # discrete boundary).
939 # If the optional \a geom parameter is not sets, this algorithm is global.
940 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
941 # @param is3D If 0 then algorithm is 2D, otherwise 3D
942 # @param geom If defined, subshape to be meshed
943 def Netgen(self, is3D, geom=0):
944 return Mesh_Netgen(self, is3D, geom)
946 ## Compute the mesh and return the status of the computation
947 def Compute(self, geom=0):
948 if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object):
950 print "Compute impossible: mesh is not constructed on geom shape."
954 ok = smesh.Compute(self.mesh, geom)
956 errors = smesh.GetAlgoState( self.mesh, geom )
964 dim = str(err.algoDim)
965 if err.name == MISSING_ALGO:
966 reason = glob + dim + "D algorithm is missing"
967 elif err.name == MISSING_HYPO:
968 name = '"' + err.algoName + '"'
969 reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
971 reason = "Global \"Not Conform mesh allowed\" hypothesis is missing"
979 print '"' + GetName(self.mesh) + '"',"not computed:"
983 if salome.sg.hasDesktop():
984 smeshgui = salome.ImportComponentGUI("SMESH")
985 smeshgui.Init(salome.myStudyId)
986 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok )
987 salome.sg.updateObjBrowser(1)
991 ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
992 # The parameter \a fineness [0.-1.] defines mesh fineness
993 def AutomaticTetrahedralization(self, fineness=0):
994 dim = self.MeshDimension()
996 self.RemoveGlobalHypotheses()
997 self.Segment().AutomaticLength(fineness)
999 self.Triangle().LengthFromEdges()
1002 self.Tetrahedron(NETGEN)
1004 return self.Compute()
1006 ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1007 # The parameter \a fineness [0.-1.] defines mesh fineness
1008 def AutomaticHexahedralization(self, fineness=0):
1009 dim = self.MeshDimension()
1011 self.RemoveGlobalHypotheses()
1012 self.Segment().AutomaticLength(fineness)
1019 return self.Compute()
1021 ## Get the list of hypothesis added on a geom
1022 # @param geom is subhape of mesh geometry
1023 def GetHypothesisList(self, geom):
1024 return self.mesh.GetHypothesisList( geom )
1026 ## Removes all global hypotheses
1027 def RemoveGlobalHypotheses(self):
1028 current_hyps = self.mesh.GetHypothesisList( self.geom )
1029 for hyp in current_hyps:
1030 self.mesh.RemoveHypothesis( self.geom, hyp )
1034 ## Create a mesh group based on geometric object \a grp
1035 # and give a \a name, if this parameter is not defined
1036 # the name is the same as the geometric group name
1037 # Note: this function is obsolete. Works like GroupOnGeom().
1038 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1039 # @param name is the name of the mesh group
1040 # @return SMESH_GroupOnGeom
1041 def Group(self, grp, name=""):
1042 return self.GroupOnGeom(grp, name)
1044 ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1045 # Export the mesh in a file with the MED format and choice the \a version of MED format
1046 # @param f is the file name
1047 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1048 def ExportToMED(self, f, version, opt=0):
1049 self.mesh.ExportToMED(f, opt, version)
1051 ## Export the mesh in a file with the MED format
1052 # @param f is the file name
1053 # @param auto_groups boolean parameter for creating/not creating
1054 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1055 # the typical use is auto_groups=false.
1056 # @param version MED format version(MED_V2_1 or MED_V2_2)
1057 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1058 self.mesh.ExportToMED(f, auto_groups, version)
1060 ## Export the mesh in a file with the DAT format
1061 # @param f is the file name
1062 def ExportDAT(self, f):
1063 self.mesh.ExportDAT(f)
1065 ## Export the mesh in a file with the UNV format
1066 # @param f is the file name
1067 def ExportUNV(self, f):
1068 self.mesh.ExportUNV(f)
1070 ## Export the mesh in a file with the STL format
1071 # @param f is the file name
1072 # @param ascii defined the kind of file contents
1073 def ExportSTL(self, f, ascii=1):
1074 self.mesh.ExportSTL(f, ascii)
1076 ###################################################################################
1078 ## Operations with groups
1079 # ----------------------
1081 ## Creates an empty mesh group
1082 # @param elementType is the type of elements in the group
1083 # @param name is the name of the mesh group
1084 # @return SMESH_Group
1085 def CreateEmptyGroup(self, elementType, name):
1086 return self.mesh.CreateGroup(elementType, name)
1088 ## Creates a mesh group based on geometric object \a grp
1089 # and give a \a name, if this parameter is not defined
1090 # the name is the same as the geometric group name
1091 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1092 # @param name is the name of the mesh group
1093 # @return SMESH_GroupOnGeom
1094 def GroupOnGeom(self, grp, name="", type=None):
1096 name = grp.GetName()
1099 tgeo = str(grp.GetShapeType())
1100 if tgeo == "VERTEX":
1102 elif tgeo == "EDGE":
1104 elif tgeo == "FACE":
1106 elif tgeo == "SOLID":
1108 elif tgeo == "SHELL":
1110 elif tgeo == "COMPOUND":
1111 if len( geompy.GetObjectIDs( grp )) == 0:
1112 print "Mesh.Group: empty geometric group", GetName( grp )
1114 tgeo = geompy.GetType(grp)
1115 if tgeo == geompy.ShapeType["VERTEX"]:
1117 elif tgeo == geompy.ShapeType["EDGE"]:
1119 elif tgeo == geompy.ShapeType["FACE"]:
1121 elif tgeo == geompy.ShapeType["SOLID"]:
1125 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1128 return self.mesh.CreateGroupFromGEOM(type, name, grp)
1130 ## Create a mesh group by the given ids of elements
1131 # @param groupName is the name of the mesh group
1132 # @param elementType is the type of elements in the group
1133 # @param elemIDs is the list of ids
1134 # @return SMESH_Group
1135 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1136 group = self.mesh.CreateGroup(elementType, groupName)
1140 ## Create a mesh group by the given conditions
1141 # @param groupName is the name of the mesh group
1142 # @param elementType is the type of elements in the group
1143 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1144 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1145 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
1146 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
1147 # @return SMESH_Group
1151 CritType=FT_Undefined,
1154 UnaryOp=FT_Undefined):
1155 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1156 group = self.MakeGroupByCriterion(groupName, aCriterion)
1159 ## Create a mesh group by the given criterion
1160 # @param groupName is the name of the mesh group
1161 # @param Criterion is the instance of Criterion class
1162 # @return SMESH_Group
1163 def MakeGroupByCriterion(self, groupName, Criterion):
1164 aFilterMgr = smesh.CreateFilterManager()
1165 aFilter = aFilterMgr.CreateFilter()
1167 aCriteria.append(Criterion)
1168 aFilter.SetCriteria(aCriteria)
1169 group = self.MakeGroupByFilter(groupName, aFilter)
1172 ## Create a mesh group by the given criteria(list of criterions)
1173 # @param groupName is the name of the mesh group
1174 # @param Criteria is the list of criterions
1175 # @return SMESH_Group
1176 def MakeGroupByCriteria(self, groupName, theCriteria):
1177 aFilterMgr = smesh.CreateFilterManager()
1178 aFilter = aFilterMgr.CreateFilter()
1179 aFilter.SetCriteria(theCriteria)
1180 group = self.MakeGroupByFilter(groupName, aFilter)
1183 ## Create a mesh group by the given filter
1184 # @param groupName is the name of the mesh group
1185 # @param Criterion is the instance of Filter class
1186 # @return SMESH_Group
1187 def MakeGroupByFilter(self, groupName, theFilter):
1188 anIds = theFilter.GetElementsId(self.mesh)
1189 anElemType = theFilter.GetElementType()
1190 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1193 ## Pass mesh elements through the given filter and return ids
1194 # @param theFilter is SMESH_Filter
1195 # @return list of ids
1196 def GetIdsFromFilter(self, theFilter):
1197 return theFilter.GetElementsId(self.mesh)
1199 ## Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
1200 # Returns list of special structures(borders).
1201 # @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
1202 def GetFreeBorders(self):
1203 aFilterMgr = smesh.CreateFilterManager()
1204 aPredicate = aFilterMgr.CreateFreeEdges()
1205 aPredicate.SetMesh(self.mesh)
1206 aBorders = aPredicate.GetBorders()
1210 def RemoveGroup(self, group):
1211 self.mesh.RemoveGroup(group)
1213 ## Remove group with its contents
1214 def RemoveGroupWithContents(self, group):
1215 self.mesh.RemoveGroupWithContents(group)
1217 ## Get the list of groups existing in the mesh
1218 def GetGroups(self):
1219 return self.mesh.GetGroups()
1221 ## Get the list of names of groups existing in the mesh
1222 def GetGroupNames(self):
1223 groups = self.GetGroups()
1225 for group in groups:
1226 names.append(group.GetName())
1229 ## Union of two groups
1230 # New group is created. All mesh elements that are
1231 # present in initial groups are added to the new one
1232 def UnionGroups(self, group1, group2, name):
1233 return self.mesh.UnionGroups(group1, group2, name)
1235 ## Intersection of two groups
1236 # New group is created. All mesh elements that are
1237 # present in both initial groups are added to the new one.
1238 def IntersectGroups(self, group1, group2, name):
1239 return self.mesh.IntersectGroups(group1, group2, name)
1241 ## Cut of two groups
1242 # New group is created. All mesh elements that are present in
1243 # main group but do not present in tool group are added to the new one
1244 def CutGroups(self, mainGroup, toolGroup, name):
1245 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1248 ## Get some info about mesh:
1249 # ------------------------
1251 ## Get the log of nodes and elements added or removed since previous
1253 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1254 # @return list of log_block structures:
1259 def GetLog(self, clearAfterGet):
1260 return self.mesh.GetLog(clearAfterGet)
1262 ## Clear the log of nodes and elements added or removed since previous
1263 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1265 self.mesh.ClearLog()
1267 ## Get the internal Id
1269 return self.mesh.GetId()
1272 def GetStudyId(self):
1273 return self.mesh.GetStudyId()
1275 ## Check group names for duplications.
1276 # Consider maximum group name length stored in MED file.
1277 def HasDuplicatedGroupNamesMED(self):
1278 return self.mesh.GetStudyId()
1280 ## Obtain instance of SMESH_MeshEditor
1281 def GetMeshEditor(self):
1282 return self.mesh.GetMeshEditor()
1285 def GetMEDMesh(self):
1286 return self.mesh.GetMEDMesh()
1289 ## Get informations about mesh contents:
1290 # ------------------------------------
1292 ## Returns number of nodes in mesh
1294 return self.mesh.NbNodes()
1296 ## Returns number of elements in mesh
1297 def NbElements(self):
1298 return self.mesh.NbElements()
1300 ## Returns number of edges in mesh
1302 return self.mesh.NbEdges()
1304 ## Returns number of edges with given order in mesh
1305 # @param elementOrder is order of elements:
1306 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1307 def NbEdgesOfOrder(self, elementOrder):
1308 return self.mesh.NbEdgesOfOrder(elementOrder)
1310 ## Returns number of faces in mesh
1312 return self.mesh.NbFaces()
1314 ## Returns number of faces with given order in mesh
1315 # @param elementOrder is order of elements:
1316 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1317 def NbFacesOfOrder(self, elementOrder):
1318 return self.mesh.NbFacesOfOrder(elementOrder)
1320 ## Returns number of triangles in mesh
1321 def NbTriangles(self):
1322 return self.mesh.NbTriangles()
1324 ## Returns number of triangles with given order in mesh
1325 # @param elementOrder is order of elements:
1326 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1327 def NbTrianglesOfOrder(self, elementOrder):
1328 return self.mesh.NbTrianglesOfOrder(elementOrder)
1330 ## Returns number of quadrangles in mesh
1331 def NbQuadrangles(self):
1332 return self.mesh.NbQuadrangles()
1334 ## Returns number of quadrangles with given order in mesh
1335 # @param elementOrder is order of elements:
1336 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1337 def NbQuadranglesOfOrder(self, elementOrder):
1338 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1340 ## Returns number of polygons in mesh
1341 def NbPolygons(self):
1342 return self.mesh.NbPolygons()
1344 ## Returns number of volumes in mesh
1345 def NbVolumes(self):
1346 return self.mesh.NbVolumes()
1348 ## Returns number of volumes with given order in mesh
1349 # @param elementOrder is order of elements:
1350 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1351 def NbVolumesOfOrder(self, elementOrder):
1352 return self.mesh.NbVolumesOfOrder(elementOrder)
1354 ## Returns number of tetrahedrons in mesh
1356 return self.mesh.NbTetras()
1358 ## Returns number of tetrahedrons with given order in mesh
1359 # @param elementOrder is order of elements:
1360 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1361 def NbTetrasOfOrder(self, elementOrder):
1362 return self.mesh.NbTetrasOfOrder(elementOrder)
1364 ## Returns number of hexahedrons in mesh
1366 return self.mesh.NbHexas()
1368 ## Returns number of hexahedrons with given order in mesh
1369 # @param elementOrder is order of elements:
1370 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1371 def NbHexasOfOrder(self, elementOrder):
1372 return self.mesh.NbHexasOfOrder(elementOrder)
1374 ## Returns number of pyramids in mesh
1375 def NbPyramids(self):
1376 return self.mesh.NbPyramids()
1378 ## Returns number of pyramids with given order in mesh
1379 # @param elementOrder is order of elements:
1380 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1381 def NbPyramidsOfOrder(self, elementOrder):
1382 return self.mesh.NbPyramidsOfOrder(elementOrder)
1384 ## Returns number of prisms in mesh
1386 return self.mesh.NbPrisms()
1388 ## Returns number of prisms with given order in mesh
1389 # @param elementOrder is order of elements:
1390 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1391 def NbPrismsOfOrder(self, elementOrder):
1392 return self.mesh.NbPrismsOfOrder(elementOrder)
1394 ## Returns number of polyhedrons in mesh
1395 def NbPolyhedrons(self):
1396 return self.mesh.NbPolyhedrons()
1398 ## Returns number of submeshes in mesh
1399 def NbSubMesh(self):
1400 return self.mesh.NbSubMesh()
1402 ## Returns list of mesh elements ids
1403 def GetElementsId(self):
1404 return self.mesh.GetElementsId()
1406 ## Returns list of ids of mesh elements with given type
1407 # @param elementType is required type of elements
1408 def GetElementsByType(self, elementType):
1409 return self.mesh.GetElementsByType(elementType)
1411 ## Returns list of mesh nodes ids
1412 def GetNodesId(self):
1413 return self.mesh.GetNodesId()
1415 ## Get informations about mesh elements:
1416 # ------------------------------------
1418 ## Returns type of mesh element
1419 def GetElementType(self, id, iselem):
1420 return self.mesh.GetElementType(id, iselem)
1422 ## Returns list of submesh elements ids
1423 # @param shapeID is geom object(subshape) IOR
1424 def GetSubMeshElementsId(self, shapeID):
1425 return self.mesh.GetSubMeshElementsId(shapeID)
1427 ## Returns list of submesh nodes ids
1428 # @param shapeID is geom object(subshape) IOR
1429 def GetSubMeshNodesId(self, shapeID, all):
1430 return self.mesh.GetSubMeshNodesId(shapeID, all)
1432 ## Returns list of ids of submesh elements with given type
1433 # @param shapeID is geom object(subshape) IOR
1434 def GetSubMeshElementType(self, shapeID):
1435 return self.mesh.GetSubMeshElementType(shapeID)
1437 ## Get mesh description
1439 return self.mesh.Dump()
1442 ## Get information about nodes and elements of mesh by its ids:
1443 # -----------------------------------------------------------
1445 ## Get XYZ coordinates of node as list of double
1446 # If there is not node for given ID - returns empty list
1447 def GetNodeXYZ(self, id):
1448 return self.mesh.GetNodeXYZ(id)
1450 ## For given node returns list of IDs of inverse elements
1451 # If there is not node for given ID - returns empty list
1452 def GetNodeInverseElements(self, id):
1453 return self.mesh.GetNodeInverseElements(id)
1455 ## If given element is node returns IDs of shape from position
1456 # If there is not node for given ID - returns -1
1457 def GetShapeID(self, id):
1458 return self.mesh.GetShapeID(id)
1460 ## For given element returns ID of result shape after
1461 # FindShape() from SMESH_MeshEditor
1462 # If there is not element for given ID - returns -1
1463 def GetShapeIDForElem(id):
1464 return self.mesh.GetShapeIDForElem(id)
1466 ## Returns number of nodes for given element
1467 # If there is not element for given ID - returns -1
1468 def GetElemNbNodes(self, id):
1469 return self.mesh.GetElemNbNodes(id)
1471 ## Returns ID of node by given index for given element
1472 # If there is not element for given ID - returns -1
1473 # If there is not node for given index - returns -2
1474 def GetElemNode(self, id, index):
1475 return self.mesh.GetElemNode(id, index)
1477 ## Returns true if given node is medium node
1478 # in given quadratic element
1479 def IsMediumNode(self, elementID, nodeID):
1480 return self.mesh.IsMediumNode(elementID, nodeID)
1482 ## Returns true if given node is medium node
1483 # in one of quadratic elements
1484 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1485 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1487 ## Returns number of edges for given element
1488 def ElemNbEdges(self, id):
1489 return self.mesh.ElemNbEdges(id)
1491 ## Returns number of faces for given element
1492 def ElemNbFaces(self, id):
1493 return self.mesh.ElemNbFaces(id)
1495 ## Returns true if given element is polygon
1496 def IsPoly(self, id):
1497 return self.mesh.IsPoly(id)
1499 ## Returns true if given element is quadratic
1500 def IsQuadratic(self, id):
1501 return self.mesh.IsQuadratic(id)
1503 ## Returns XYZ coordinates of bary center for given element
1505 # If there is not element for given ID - returns empty list
1506 def BaryCenter(self, id):
1507 return self.mesh.BaryCenter(id)
1510 ## Mesh edition (SMESH_MeshEditor functionality):
1511 # ---------------------------------------------
1513 ## Removes elements from mesh by ids
1514 # @param IDsOfElements is list of ids of elements to remove
1515 def RemoveElements(self, IDsOfElements):
1516 return self.editor.RemoveElements(IDsOfElements)
1518 ## Removes nodes from mesh by ids
1519 # @param IDsOfNodes is list of ids of nodes to remove
1520 def RemoveNodes(self, IDsOfNodes):
1521 return self.editor.RemoveNodes(IDsOfNodes)
1523 ## Add node to mesh by coordinates
1524 def AddNode(self, x, y, z):
1525 return self.editor.AddNode( x, y, z)
1528 ## Create edge both similar and quadratic (this is determed
1529 # by number of given nodes).
1530 # @param IdsOfNodes List of node IDs for creation of element.
1531 # Needed order of nodes in this list corresponds to description
1532 # of MED. This description is located by the following link:
1533 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1534 def AddEdge(self, IDsOfNodes):
1535 return self.editor.AddEdge(IDsOfNodes)
1537 ## Create face both similar and quadratic (this is determed
1538 # by number of given nodes).
1539 # @param IdsOfNodes List of node IDs for creation of element.
1540 # Needed order of nodes in this list corresponds to description
1541 # of MED. This description is located by the following link:
1542 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1543 def AddFace(self, IDsOfNodes):
1544 return self.editor.AddFace(IDsOfNodes)
1546 ## Add polygonal face to mesh by list of nodes ids
1547 def AddPolygonalFace(self, IdsOfNodes):
1548 return self.editor.AddPolygonalFace(IdsOfNodes)
1550 ## Create volume both similar and quadratic (this is determed
1551 # by number of given nodes).
1552 # @param IdsOfNodes List of node IDs for creation of element.
1553 # Needed order of nodes in this list corresponds to description
1554 # of MED. This description is located by the following link:
1555 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1556 def AddVolume(self, IDsOfNodes):
1557 return self.editor.AddVolume(IDsOfNodes)
1559 ## Create volume of many faces, giving nodes for each face.
1560 # @param IdsOfNodes List of node IDs for volume creation face by face.
1561 # @param Quantities List of integer values, Quantities[i]
1562 # gives quantity of nodes in face number i.
1563 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1564 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1566 ## Create volume of many faces, giving IDs of existing faces.
1567 # @param IdsOfFaces List of face IDs for volume creation.
1569 # Note: The created volume will refer only to nodes
1570 # of the given faces, not to the faces itself.
1571 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1572 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1574 ## Move node with given id
1575 # @param NodeID id of the node
1576 # @param x displacing along the X axis
1577 # @param y displacing along the Y axis
1578 # @param z displacing along the Z axis
1579 def MoveNode(self, NodeID, x, y, z):
1580 return self.editor.MoveNode(NodeID, x, y, z)
1582 ## Replace two neighbour triangles sharing Node1-Node2 link
1583 # with ones built on the same 4 nodes but having other common link.
1584 # @param NodeID1 first node id
1585 # @param NodeID2 second node id
1586 # @return false if proper faces not found
1587 def InverseDiag(self, NodeID1, NodeID2):
1588 return self.editor.InverseDiag(NodeID1, NodeID2)
1590 ## Replace two neighbour triangles sharing Node1-Node2 link
1591 # with a quadrangle built on the same 4 nodes.
1592 # @param NodeID1 first node id
1593 # @param NodeID2 second node id
1594 # @return false if proper faces not found
1595 def DeleteDiag(self, NodeID1, NodeID2):
1596 return self.editor.DeleteDiag(NodeID1, NodeID2)
1598 ## Reorient elements by ids
1599 # @param IDsOfElements if undefined reorient all mesh elements
1600 def Reorient(self, IDsOfElements=None):
1601 if IDsOfElements == None:
1602 IDsOfElements = self.GetElementsId()
1603 return self.editor.Reorient(IDsOfElements)
1605 ## Reorient all elements of the object
1606 # @param theObject is mesh, submesh or group
1607 def ReorientObject(self, theObject):
1608 return self.editor.ReorientObject(theObject)
1610 ## Fuse neighbour triangles into quadrangles.
1611 # @param IDsOfElements The triangles to be fused,
1612 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1613 # @param MaxAngle is a max angle between element normals at which fusion
1614 # is still performed; theMaxAngle is mesured in radians.
1615 # @return TRUE in case of success, FALSE otherwise.
1616 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1617 if IDsOfElements == []:
1618 IDsOfElements = self.GetElementsId()
1619 return self.editor.TriToQuad(IDsOfElements, GetFunctor(theCriterion), MaxAngle)
1621 ## Fuse neighbour triangles of the object into quadrangles
1622 # @param theObject is mesh, submesh or group
1623 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1624 # @param MaxAngle is a max angle between element normals at which fusion
1625 # is still performed; theMaxAngle is mesured in radians.
1626 # @return TRUE in case of success, FALSE otherwise.
1627 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1628 return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
1630 ## Split quadrangles into triangles.
1631 # @param IDsOfElements the faces to be splitted.
1632 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
1633 # @param @return TRUE in case of success, FALSE otherwise.
1634 def QuadToTri (self, IDsOfElements, theCriterion):
1635 if IDsOfElements == []:
1636 IDsOfElements = self.GetElementsId()
1637 return self.editor.QuadToTri(IDsOfElements, GetFunctor(theCriterion))
1639 ## Split quadrangles into triangles.
1640 # @param theObject object to taking list of elements from, is mesh, submesh or group
1641 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
1642 def QuadToTriObject (self, theObject, theCriterion):
1643 return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
1645 ## Split quadrangles into triangles.
1646 # @param theElems The faces to be splitted
1647 # @param the13Diag is used to choose a diagonal for splitting.
1648 # @return TRUE in case of success, FALSE otherwise.
1649 def SplitQuad (self, IDsOfElements, Diag13):
1650 if IDsOfElements == []:
1651 IDsOfElements = self.GetElementsId()
1652 return self.editor.SplitQuad(IDsOfElements, Diag13)
1654 ## Split quadrangles into triangles.
1655 # @param theObject is object to taking list of elements from, is mesh, submesh or group
1656 def SplitQuadObject (self, theObject, Diag13):
1657 return self.editor.SplitQuadObject(theObject, Diag13)
1659 ## Find better splitting of the given quadrangle.
1660 # @param IDOfQuad ID of the quadrangle to be splitted.
1661 # @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
1662 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1663 # diagonal is better, 0 if error occurs.
1664 def BestSplit (self, IDOfQuad, theCriterion):
1665 return self.editor.BestSplit(IDOfQuad, GetFunctor(theCriterion))
1668 # @param IDsOfElements list if ids of elements to smooth
1669 # @param IDsOfFixedNodes list of ids of fixed nodes.
1670 # Note that nodes built on edges and boundary nodes are always fixed.
1671 # @param MaxNbOfIterations maximum number of iterations
1672 # @param MaxAspectRatio varies in range [1.0, inf]
1673 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1674 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
1675 MaxNbOfIterations, MaxAspectRatio, Method):
1676 if IDsOfElements == []:
1677 IDsOfElements = self.GetElementsId()
1678 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
1679 MaxNbOfIterations, MaxAspectRatio, Method)
1681 ## Smooth elements belong to given object
1682 # @param theObject object to smooth
1683 # @param IDsOfFixedNodes list of ids of fixed nodes.
1684 # Note that nodes built on edges and boundary nodes are always fixed.
1685 # @param MaxNbOfIterations maximum number of iterations
1686 # @param MaxAspectRatio varies in range [1.0, inf]
1687 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1688 def SmoothObject(self, theObject, IDsOfFixedNodes,
1689 MaxNbOfIterations, MaxxAspectRatio, Method):
1690 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
1691 MaxNbOfIterations, MaxxAspectRatio, Method)
1693 ## Parametric smooth the given elements
1694 # @param IDsOfElements list if ids of elements to smooth
1695 # @param IDsOfFixedNodes list of ids of fixed nodes.
1696 # Note that nodes built on edges and boundary nodes are always fixed.
1697 # @param MaxNbOfIterations maximum number of iterations
1698 # @param MaxAspectRatio varies in range [1.0, inf]
1699 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1700 def SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1701 MaxNbOfIterations, MaxAspectRatio, Method):
1702 if IDsOfElements == []:
1703 IDsOfElements = self.GetElementsId()
1704 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1705 MaxNbOfIterations, MaxAspectRatio, Method)
1707 ## Parametric smooth elements belong to given object
1708 # @param theObject object to smooth
1709 # @param IDsOfFixedNodes list of ids of fixed nodes.
1710 # Note that nodes built on edges and boundary nodes are always fixed.
1711 # @param MaxNbOfIterations maximum number of iterations
1712 # @param MaxAspectRatio varies in range [1.0, inf]
1713 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1714 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
1715 MaxNbOfIterations, MaxAspectRatio, Method):
1716 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
1717 MaxNbOfIterations, MaxAspectRatio, Method)
1719 ## Converts all mesh to quadratic one, deletes old elements, replacing
1720 # them with quadratic ones with the same id.
1721 def ConvertToQuadratic(self, theForce3d):
1722 self.editor.ConvertToQuadratic(theForce3d)
1724 ## Converts all mesh from quadratic to ordinary ones,
1725 # deletes old quadratic elements, replacing
1726 # them with ordinary mesh elements with the same id.
1727 def ConvertFromQuadratic(self):
1728 return self.editor.ConvertFromQuadratic()
1730 ## Renumber mesh nodes
1731 def RenumberNodes(self):
1732 self.editor.RenumberNodes()
1734 ## Renumber mesh elements
1735 def RenumberElements(self):
1736 self.editor.RenumberElements()
1738 ## Generate new elements by rotation of the elements around the axis
1739 # @param IDsOfElements list of ids of elements to sweep
1740 # @param Axix axis of rotation, AxisStruct or line(geom object)
1741 # @param AngleInRadians angle of Rotation
1742 # @param NbOfSteps number of steps
1743 # @param Tolerance tolerance
1744 def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
1745 if IDsOfElements == []:
1746 IDsOfElements = self.GetElementsId()
1747 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
1748 Axix = GetAxisStruct(Axix)
1749 self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
1751 ## Generate new elements by rotation of the elements of object around the axis
1752 # @param theObject object wich elements should be sweeped
1753 # @param Axix axis of rotation, AxisStruct or line(geom object)
1754 # @param AngleInRadians angle of Rotation
1755 # @param NbOfSteps number of steps
1756 # @param Tolerance tolerance
1757 def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
1758 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
1759 Axix = GetAxisStruct(Axix)
1760 self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
1762 ## Generate new elements by extrusion of the elements with given ids
1763 # @param IDsOfElements list of elements ids for extrusion
1764 # @param StepVector vector, defining the direction and value of extrusion
1765 # @param NbOfSteps the number of steps
1766 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
1767 if IDsOfElements == []:
1768 IDsOfElements = self.GetElementsId()
1769 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1770 StepVector = GetDirStruct(StepVector)
1771 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
1773 ## Generate new elements by extrusion of the elements with given ids
1774 # @param IDsOfElements is ids of elements
1775 # @param StepVector vector, defining the direction and value of extrusion
1776 # @param NbOfSteps the number of steps
1777 # @param ExtrFlags set flags for performing extrusion
1778 # @param SewTolerance uses for comparing locations of nodes if flag
1779 # EXTRUSION_FLAG_SEW is set
1780 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
1781 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1782 StepVector = GetDirStruct(StepVector)
1783 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
1785 ## Generate new elements by extrusion of the elements belong to object
1786 # @param theObject object wich elements should be processed
1787 # @param StepVector vector, defining the direction and value of extrusion
1788 # @param NbOfSteps the number of steps
1789 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
1790 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1791 StepVector = GetDirStruct(StepVector)
1792 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
1794 ## Generate new elements by extrusion of the elements belong to object
1795 # @param theObject object wich elements should be processed
1796 # @param StepVector vector, defining the direction and value of extrusion
1797 # @param NbOfSteps the number of steps
1798 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
1799 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1800 StepVector = GetDirStruct(StepVector)
1801 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
1803 ## Generate new elements by extrusion of the elements belong to object
1804 # @param theObject object wich elements should be processed
1805 # @param StepVector vector, defining the direction and value of extrusion
1806 # @param NbOfSteps the number of steps
1807 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
1808 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1809 StepVector = GetDirStruct(StepVector)
1810 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
1812 ## Generate new elements by extrusion of the given elements
1813 # A path of extrusion must be a meshed edge.
1814 # @param IDsOfElements is ids of elements
1815 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
1816 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
1817 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
1818 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
1819 # @param Angles list of angles
1820 # @param HasRefPoint allows to use base point
1821 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
1822 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
1823 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
1824 HasAngles, Angles, HasRefPoint, RefPoint):
1825 if IDsOfElements == []:
1826 IDsOfElements = self.GetElementsId()
1827 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
1828 RefPoint = GetPointStruct(RefPoint)
1829 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
1830 HasAngles, Angles, HasRefPoint, RefPoint)
1832 ## Generate new elements by extrusion of the elements belong to object
1833 # A path of extrusion must be a meshed edge.
1834 # @param IDsOfElements is ids of elements
1835 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
1836 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
1837 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
1838 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
1839 # @param Angles list of angles
1840 # @param HasRefPoint allows to use base point
1841 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
1842 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
1843 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
1844 HasAngles, Angles, HasRefPoint, RefPoint):
1845 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
1846 RefPoint = GetPointStruct(RefPoint)
1847 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
1848 HasAngles, Angles, HasRefPoint, RefPoint)
1850 ## Symmetrical copy of mesh elements
1851 # @param IDsOfElements list of elements ids
1852 # @param Mirror is AxisStruct or geom object(point, line, plane)
1853 # @param theMirrorType is POINT, AXIS or PLANE
1854 # If the Mirror is geom object this parameter is unnecessary
1855 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
1856 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
1857 if IDsOfElements == []:
1858 IDsOfElements = self.GetElementsId()
1859 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
1860 Mirror = GetAxisStruct(Mirror)
1861 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
1863 ## Symmetrical copy of object
1864 # @param theObject mesh, submesh or group
1865 # @param Mirror is AxisStruct or geom object(point, line, plane)
1866 # @param theMirrorType is POINT, AXIS or PLANE
1867 # If the Mirror is geom object this parameter is unnecessary
1868 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
1869 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
1870 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
1871 Mirror = GetAxisStruct(Mirror)
1872 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
1874 ## Translates the elements
1875 # @param IDsOfElements list of elements ids
1876 # @param Vector direction of translation(DirStruct or vector)
1877 # @param Copy allows to copy the translated elements
1878 def Translate(self, IDsOfElements, Vector, Copy):
1879 if IDsOfElements == []:
1880 IDsOfElements = self.GetElementsId()
1881 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
1882 Vector = GetDirStruct(Vector)
1883 self.editor.Translate(IDsOfElements, Vector, Copy)
1885 ## Translates the object
1886 # @param theObject object to translate(mesh, submesh, or group)
1887 # @param Vector direction of translation(DirStruct or geom vector)
1888 # @param Copy allows to copy the translated elements
1889 def TranslateObject(self, theObject, Vector, Copy):
1890 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
1891 Vector = GetDirStruct(Vector)
1892 self.editor.TranslateObject(theObject, Vector, Copy)
1894 ## Rotates the elements
1895 # @param IDsOfElements list of elements ids
1896 # @param Axis axis of rotation(AxisStruct or geom line)
1897 # @param AngleInRadians angle of rotation(in radians)
1898 # @param Copy allows to copy the rotated elements
1899 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
1900 if IDsOfElements == []:
1901 IDsOfElements = self.GetElementsId()
1902 if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
1903 Axis = GetAxisStruct(Axis)
1904 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
1906 ## Rotates the object
1907 # @param theObject object to rotate(mesh, submesh, or group)
1908 # @param Axis axis of rotation(AxisStruct or geom line)
1909 # @param AngleInRadians angle of rotation(in radians)
1910 # @param Copy allows to copy the rotated elements
1911 def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
1912 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
1914 ## Find group of nodes close to each other within Tolerance.
1915 # @param Tolerance tolerance value
1916 # @param list of group of nodes
1917 def FindCoincidentNodes (self, Tolerance):
1918 return self.editor.FindCoincidentNodes(Tolerance)
1921 # @param list of group of nodes
1922 def MergeNodes (self, GroupsOfNodes):
1923 self.editor.MergeNodes(GroupsOfNodes)
1925 ## Remove all but one of elements built on the same nodes.
1926 def MergeEqualElements(self):
1927 self.editor.MergeEqualElements()
1930 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
1931 FirstNodeID2, SecondNodeID2, LastNodeID2,
1932 CreatePolygons, CreatePolyedrs):
1933 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
1934 FirstNodeID2, SecondNodeID2, LastNodeID2,
1935 CreatePolygons, CreatePolyedrs)
1937 ## Sew conform free borders
1938 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
1939 FirstNodeID2, SecondNodeID2):
1940 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
1941 FirstNodeID2, SecondNodeID2)
1943 ## Sew border to side
1944 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
1945 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
1946 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
1947 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
1949 ## Sew two sides of a mesh. Nodes belonging to Side1 are
1950 # merged with nodes of elements of Side2.
1951 # Number of elements in theSide1 and in theSide2 must be
1952 # equal and they should have similar node connectivity.
1953 # The nodes to merge should belong to sides borders and
1954 # the first node should be linked to the second.
1955 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
1956 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
1957 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
1958 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
1959 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
1960 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
1962 ## Set new nodes for given element.
1963 # @param ide the element id
1964 # @param newIDs nodes ids
1965 # @return If number of nodes is not corresponded to type of element - returns false
1966 def ChangeElemNodes(self, ide, newIDs):
1967 return self.editor.ChangeElemNodes(ide, newIDs)
1969 ## If during last operation of MeshEditor some nodes were
1970 # created this method returns list of it's IDs, if new nodes
1971 # not created - returns empty list
1972 def GetLastCreatedNodes(self):
1973 return self.editor.GetLastCreatedNodes()
1975 ## If during last operation of MeshEditor some elements were
1976 # created this method returns list of it's IDs, if new elements
1977 # not creared - returns empty list
1978 def GetLastCreatedElems(self):
1979 return self.editor.GetLastCreatedElems()