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
39 # import NETGENPlugin module if possible
57 # MirrorType enumeration
58 POINT = SMESH_MeshEditor.POINT
59 AXIS = SMESH_MeshEditor.AXIS
60 PLANE = SMESH_MeshEditor.PLANE
62 # Smooth_Method enumeration
63 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
64 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
66 # Fineness enumeration(for NETGEN)
78 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
79 smesh.SetCurrentStudy(salome.myStudy)
85 ior = salome.orb.object_to_string(obj)
86 sobj = salome.myStudy.FindObjectIOR(ior)
90 attr = sobj.FindAttribute("AttributeName")[1]
93 ## Sets name to object
94 def SetName(obj, name):
95 ior = salome.orb.object_to_string(obj)
96 sobj = salome.myStudy.FindObjectIOR(ior)
98 attr = sobj.FindAttribute("AttributeName")[1]
101 ## Returns long value from enumeration
102 # Uses for SMESH.FunctorType enumeration
103 def EnumToLong(theItem):
106 ## Get PointStruct from vertex
107 # @param theVertex is GEOM object(vertex)
108 # @return SMESH.PointStruct
109 def GetPointStruct(theVertex):
110 [x, y, z] = geompy.PointCoordinates(theVertex)
111 return PointStruct(x,y,z)
113 ## Get DirStruct from vector
114 # @param theVector is GEOM object(vector)
115 # @return SMESH.DirStruct
116 def GetDirStruct(theVector):
117 vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] )
118 if(len(vertices) != 2):
119 print "Error: vector object is incorrect."
121 p1 = geompy.PointCoordinates(vertices[0])
122 p2 = geompy.PointCoordinates(vertices[1])
123 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
127 ## Get AxisStruct from object
128 # @param theObj is GEOM object(line or plane)
129 # @return SMESH.AxisStruct
130 def GetAxisStruct(theObj):
131 edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] )
133 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
134 vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] )
135 vertex1 = geompy.PointCoordinates(vertex1)
136 vertex2 = geompy.PointCoordinates(vertex2)
137 vertex3 = geompy.PointCoordinates(vertex3)
138 vertex4 = geompy.PointCoordinates(vertex4)
139 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
140 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
141 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] ]
142 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
144 elif len(edges) == 1:
145 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
146 p1 = geompy.PointCoordinates( vertex1 )
147 p2 = geompy.PointCoordinates( vertex2 )
148 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
152 # From SMESH_Gen interface:
153 # ------------------------
155 ## Set the current mode
156 def SetEmbeddedMode( theMode ):
157 smesh.SetEmbeddedMode(theMode)
159 ## Get the current mode
160 def IsEmbeddedMode():
161 return smesh.IsEmbeddedMode()
163 ## Set the current study
164 def SetCurrentStudy( theStudy ):
165 smesh.SetCurrentStudy(theStudy)
167 ## Get the current study
168 def GetCurrentStudy():
169 return smesh.GetCurrentStudy()
171 ## Create Mesh object importing data from given UNV file
172 # @return an instance of Mesh class
173 def CreateMeshesFromUNV( theFileName ):
174 aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName)
175 aMesh = Mesh(aSmeshMesh)
178 ## Create Mesh object(s) importing data from given MED file
179 # @return a list of Mesh class instances
180 def CreateMeshesFromMED( theFileName ):
181 aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName)
183 for iMesh in range(len(aSmeshMeshes)) :
184 aMesh = Mesh(aSmeshMeshes[iMesh])
185 aMeshes.append(aMesh)
186 return aMeshes, aStatus
188 ## Create Mesh object importing data from given STL file
189 # @return an instance of Mesh class
190 def CreateMeshesFromSTL( theFileName ):
191 aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName)
192 aMesh = Mesh(aSmeshMesh)
195 ## From SMESH_Gen interface
196 def GetSubShapesId( theMainObject, theListOfSubObjects ):
197 return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
199 ## From SMESH_Gen interface. Creates pattern
201 return smesh.GetPattern()
205 # Filtering. Auxiliary functions:
206 # ------------------------------
208 ## Creates an empty criterion
209 # @return SMESH.Filter.Criterion
210 def GetEmptyCriterion():
211 Type = EnumToLong(FT_Undefined)
212 Compare = EnumToLong(FT_Undefined)
216 UnaryOp = EnumToLong(FT_Undefined)
217 BinaryOp = EnumToLong(FT_Undefined)
220 Precision = -1 ##@1e-07
221 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
222 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
224 ## Creates a criterion by given parameters
225 # @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
226 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
227 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
228 # @param Treshold is threshold value (range of ids as string, shape, numeric)
229 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
230 # @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
231 # FT_Undefined(must be for the last criterion in criteria)
232 # @return SMESH.Filter.Criterion
233 def GetCriterion(elementType,
235 Compare = FT_EqualTo,
237 UnaryOp=FT_Undefined,
238 BinaryOp=FT_Undefined):
239 aCriterion = GetEmptyCriterion()
240 aCriterion.TypeOfElement = elementType
241 aCriterion.Type = EnumToLong(CritType)
245 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
246 aCriterion.Compare = EnumToLong(Compare)
247 elif Compare == "=" or Compare == "==":
248 aCriterion.Compare = EnumToLong(FT_EqualTo)
250 aCriterion.Compare = EnumToLong(FT_LessThan)
252 aCriterion.Compare = EnumToLong(FT_MoreThan)
254 aCriterion.Compare = EnumToLong(FT_EqualTo)
257 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
258 FT_BelongToCylinder, FT_LyingOnGeom]:
260 if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object):
261 aCriterion.ThresholdStr = GetName(aTreshold)
262 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
264 print "Error: Treshold should be a shape."
266 elif CritType == FT_RangeOfIds:
268 if isinstance(aTreshold, str):
269 aCriterion.ThresholdStr = aTreshold
271 print "Error: Treshold should be a string."
273 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
274 # Here we don't need treshold
275 if aTreshold == FT_LogicalNOT:
276 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
277 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
278 aCriterion.BinaryOp = aTreshold
282 aTreshold = float(aTreshold)
283 aCriterion.Threshold = aTreshold
285 print "Error: Treshold should be a number."
288 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
289 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
291 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
292 aCriterion.BinaryOp = EnumToLong(Treshold)
294 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
295 aCriterion.BinaryOp = EnumToLong(UnaryOp)
297 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
298 aCriterion.BinaryOp = EnumToLong(BinaryOp)
302 ## Creates filter by given parameters of criterion
303 # @param elementType is the type of elements in the group
304 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
305 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
306 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
307 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
308 # @return SMESH_Filter
309 def GetFilter(elementType,
310 CritType=FT_Undefined,
313 UnaryOp=FT_Undefined):
314 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
315 aFilterMgr = smesh.CreateFilterManager()
316 aFilter = aFilterMgr.CreateFilter()
318 aCriteria.append(aCriterion)
319 aFilter.SetCriteria(aCriteria)
322 ## Creates numerical functor by its type
323 # @param theCrierion is FT_...; functor type
324 # @return SMESH_NumericalFunctor
325 def GetFunctor(theCriterion):
326 aFilterMgr = smesh.CreateFilterManager()
327 if theCriterion == FT_AspectRatio:
328 return aFilterMgr.CreateAspectRatio()
329 elif theCriterion == FT_AspectRatio3D:
330 return aFilterMgr.CreateAspectRatio3D()
331 elif theCriterion == FT_Warping:
332 return aFilterMgr.CreateWarping()
333 elif theCriterion == FT_MinimumAngle:
334 return aFilterMgr.CreateMinimumAngle()
335 elif theCriterion == FT_Taper:
336 return aFilterMgr.CreateTaper()
337 elif theCriterion == FT_Skew:
338 return aFilterMgr.CreateSkew()
339 elif theCriterion == FT_Area:
340 return aFilterMgr.CreateArea()
341 elif theCriterion == FT_Volume3D:
342 return aFilterMgr.CreateVolume3D()
343 elif theCriterion == FT_MultiConnection:
344 return aFilterMgr.CreateMultiConnection()
345 elif theCriterion == FT_MultiConnection2D:
346 return aFilterMgr.CreateMultiConnection2D()
347 elif theCriterion == FT_Length:
348 return aFilterMgr.CreateLength()
349 elif theCriterion == FT_Length2D:
350 return aFilterMgr.CreateLength2D()
352 print "Error: given parameter is not numerucal functor type."
355 ## Print error message if a hypothesis was not assigned.
356 def TreatHypoStatus(status, hypName, geomName, isAlgo):
358 hypType = "algorithm"
360 hypType = "hypothesis"
362 if status == HYP_UNKNOWN_FATAL :
363 reason = "for unknown reason"
364 elif status == HYP_INCOMPATIBLE :
365 reason = "this hypothesis mismatches algorithm"
366 elif status == HYP_NOTCONFORM :
367 reason = "not conform mesh would be built"
368 elif status == HYP_ALREADY_EXIST :
369 reason = hypType + " of the same dimension already assigned to this shape"
370 elif status == HYP_BAD_DIM :
371 reason = hypType + " mismatches shape"
372 elif status == HYP_CONCURENT :
373 reason = "there are concurrent hypotheses on sub-shapes"
374 elif status == HYP_BAD_SUBSHAPE :
375 reason = "shape is neither the main one, nor its subshape, nor a valid group"
376 elif status == HYP_BAD_GEOMETRY:
377 reason = "geometry mismatches algorithm's expectation"
378 elif status == HYP_HIDDEN_ALGO:
379 reason = "it is hidden by an algorithm of upper dimension generating all-dimensions elements"
380 elif status == HYP_HIDING_ALGO:
381 reason = "it hides algorithm(s) of lower dimension by generating all-dimensions elements"
384 hypName = '"' + hypName + '"'
385 geomName= '"' + geomName+ '"'
386 if status < HYP_UNKNOWN_FATAL:
387 print hypName, "was assigned to", geomName,"but", reason
389 print hypName, "was not assigned to",geomName,":", reason
394 ## Mother class to define algorithm, recommended to don't use directly.
397 class Mesh_Algorithm:
398 # @class Mesh_Algorithm
399 # @brief Class Mesh_Algorithm
406 ## If the algorithm is global, return 0; \n
407 # else return the submesh associated to this algorithm.
408 def GetSubMesh(self):
411 ## Return the wrapped mesher.
412 def GetAlgorithm(self):
415 ## Get list of hypothesis that can be used with this algorithm
416 def GetCompatibleHypothesis(self):
419 list = self.algo.GetCompatibleHypothesis()
427 def SetName(self, name):
428 SetName(self.algo, name)
432 return self.algo.GetId()
435 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
437 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
442 name = GetName(piece)
447 name = geompy.SubShapeName(geom, piece)
448 geompy.addToStudyInFather(piece, geom, name)
449 self.subm = mesh.mesh.GetSubMesh(geom, hypo)
451 self.algo = smesh.CreateHypothesis(hypo, so)
452 SetName(self.algo, name + "/" + hypo)
453 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
454 TreatHypoStatus( status, hypo, name, 1 )
457 def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
458 hypo = smesh.CreateHypothesis(hyp, so)
464 a = a + s + str(args[i])
467 name = GetName(self.geom)
468 SetName(hypo, name + "/" + hyp + a)
469 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
470 TreatHypoStatus( status, hyp, name, 0 )
474 # Public class: Mesh_Segment
475 # --------------------------
477 ## Class to define a segment 1D algorithm for discretization
480 class Mesh_Segment(Mesh_Algorithm):
482 ## Private constructor.
483 def __init__(self, mesh, geom=0):
484 self.Create(mesh, geom, "Regular_1D")
486 ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
487 # @param l for the length of segments that cut an edge
488 def LocalLength(self, l):
489 hyp = self.Hypothesis("LocalLength", [l])
493 ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
494 # @param n for the number of segments that cut an edge
495 # @param s for the scale factor (optional)
496 def NumberOfSegments(self, n, s=[]):
498 hyp = self.Hypothesis("NumberOfSegments", [n])
500 hyp = self.Hypothesis("NumberOfSegments", [n,s])
501 hyp.SetDistrType( 1 )
502 hyp.SetScaleFactor(s)
503 hyp.SetNumberOfSegments(n)
506 ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
507 # @param start for the length of the first segment
508 # @param end for the length of the last segment
509 def Arithmetic1D(self, start, end):
510 hyp = self.Hypothesis("Arithmetic1D", [start, end])
511 hyp.SetLength(start, 1)
512 hyp.SetLength(end , 0)
515 ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
516 # @param start for the length of the first segment
517 # @param end for the length of the last segment
518 def StartEndLength(self, start, end):
519 hyp = self.Hypothesis("StartEndLength", [start, end])
520 hyp.SetLength(start, 1)
521 hyp.SetLength(end , 0)
524 ## Define "Deflection1D" hypothesis
525 # @param d for the deflection
526 def Deflection1D(self, d):
527 hyp = self.Hypothesis("Deflection1D", [d])
531 ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
532 # the opposite side in the case of quadrangular faces
533 def Propagation(self):
534 return self.Hypothesis("Propagation")
536 ## Define "AutomaticLength" hypothesis
537 # @param fineness for the fineness [0-1]
538 def AutomaticLength(self, fineness=0):
539 hyp = self.Hypothesis("AutomaticLength")
540 hyp.SetFineness( fineness )
543 ## Define "SegmentLengthAroundVertex" hypothesis
544 # @param length for the segment length
545 # @param vertex for the length localization: vertex index [0,1] | verext object
546 def LengthNearVertex(self, length, vertex=0):
548 store_geom = self.geom
550 if type(vertex) is types.IntType:
551 vertex = geompy.SubShapeAllSorted(self.geom,geompy.ShapeType["VERTEX"])[vertex]
555 hyp = self.Hypothesis("SegmentAroundVertex_0D")
556 hyp = self.Hypothesis("SegmentLengthAroundVertex")
557 self.geom = store_geom
558 hyp.SetLength( length )
561 ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
562 # If the 2D mesher sees that all boundary edges are quadratic ones,
563 # it generates quadratic faces, else it generates linear faces using
564 # medium nodes as if they were vertex ones.
565 # The 3D mesher generates quadratic volumes only if all boundary faces
566 # are quadratic ones, else it fails.
567 def QuadraticMesh(self):
568 hyp = self.Hypothesis("QuadraticMesh")
571 # Public class: Mesh_CompositeSegment
572 # --------------------------
574 ## Class to define a segment 1D algorithm for discretization
577 class Mesh_CompositeSegment(Mesh_Segment):
579 ## Private constructor.
580 def __init__(self, mesh, geom=0):
581 self.Create(mesh, geom, "CompositeSegment_1D")
584 # Public class: Mesh_Segment_Python
585 # ---------------------------------
587 ## Class to define a segment 1D algorithm for discretization with python function
590 class Mesh_Segment_Python(Mesh_Segment):
592 ## Private constructor.
593 def __init__(self, mesh, geom=0):
594 import Python1dPlugin
595 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
597 ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
598 # @param n for the number of segments that cut an edge
599 # @param func for the python function that calculate the length of all segments
600 def PythonSplit1D(self, n, func):
601 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so")
602 hyp.SetNumberOfSegments(n)
603 hyp.SetPythonLog10RatioFunction(func)
606 # Public class: Mesh_Triangle
607 # ---------------------------
609 ## Class to define a triangle 2D algorithm
612 class Mesh_Triangle(Mesh_Algorithm):
617 ## Private constructor.
618 def __init__(self, mesh, algoType, geom=0):
619 if algoType == MEFISTO:
620 self.Create(mesh, geom, "MEFISTO_2D")
621 elif algoType == NETGEN:
623 print "Warning: NETGENPlugin module has not been imported."
624 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
625 self.algoType = algoType
627 ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
628 # @param area for the maximum area of each triangles
629 def MaxElementArea(self, area):
630 if self.algoType == MEFISTO:
631 hyp = self.Hypothesis("MaxElementArea", [area])
632 hyp.SetMaxElementArea(area)
634 elif self.algoType == NETGEN:
635 print "Netgen 1D-2D algo doesn't support this hypothesis"
638 ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
639 def LengthFromEdges(self):
640 if self.algoType == MEFISTO:
641 hyp = self.Hypothesis("LengthFromEdges")
643 elif self.algoType == NETGEN:
644 print "Netgen 1D-2D algo doesn't support this hypothesis"
647 ## Define "Netgen 2D Parameters" hypothesis
648 def Parameters(self):
649 if self.algoType == NETGEN:
650 self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
652 elif self.algoType == MEFISTO:
653 print "Mefisto algo doesn't support this hypothesis"
657 def SetMaxSize(self, theSize):
660 self.params.SetMaxSize(theSize)
662 ## Set SecondOrder flag
663 def SetSecondOrder(seld, theVal):
666 self.params.SetSecondOrder(theVal)
669 def SetOptimize(self, theVal):
672 self.params.SetOptimize(theVal)
675 # @param theFineness is:
676 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
677 def SetFineness(self, theFineness):
680 self.params.SetFineness(theFineness)
683 def SetGrowthRate(self, theRate):
686 self.params.SetGrowthRate(theRate)
689 def SetNbSegPerEdge(self, theVal):
692 self.params.SetNbSegPerEdge(theVal)
694 ## Set NbSegPerRadius
695 def SetNbSegPerRadius(self, theVal):
698 self.params.SetNbSegPerRadius(theVal)
700 ## Set QuadAllowed flag
701 def SetQuadAllowed(self, toAllow):
704 self.params.SetQuadAllowed(toAllow)
707 # Public class: Mesh_Quadrangle
708 # -----------------------------
710 ## Class to define a quadrangle 2D algorithm
713 class Mesh_Quadrangle(Mesh_Algorithm):
715 ## Private constructor.
716 def __init__(self, mesh, geom=0):
717 self.Create(mesh, geom, "Quadrangle_2D")
719 ## Define "QuadranglePreference" hypothesis, forcing construction
720 # of quadrangles if the number of nodes on opposite edges is not the same
721 # in the case where the global number of nodes on edges is even
722 def QuadranglePreference(self):
723 hyp = self.Hypothesis("QuadranglePreference")
726 # Public class: Mesh_Tetrahedron
727 # ------------------------------
729 ## Class to define a tetrahedron 3D algorithm
732 class Mesh_Tetrahedron(Mesh_Algorithm):
737 ## Private constructor.
738 def __init__(self, mesh, algoType, geom=0):
739 if algoType == NETGEN:
740 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
741 elif algoType == GHS3D:
743 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
744 elif algoType == FULL_NETGEN:
746 print "Warning: NETGENPlugin module has not been imported."
747 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
748 self.algoType = algoType
750 ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
751 # @param vol for the maximum volume of each tetrahedral
752 def MaxElementVolume(self, vol):
753 hyp = self.Hypothesis("MaxElementVolume", [vol])
754 hyp.SetMaxElementVolume(vol)
757 ## Define "Netgen 3D Parameters" hypothesis
758 def Parameters(self):
759 if (self.algoType == FULL_NETGEN):
760 self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
763 print "Algo doesn't support this hypothesis"
767 def SetMaxSize(self, theSize):
770 self.params.SetMaxSize(theSize)
772 ## Set SecondOrder flag
773 def SetSecondOrder(self, theVal):
776 self.params.SetSecondOrder(theVal)
779 def SetOptimize(self, theVal):
782 self.params.SetOptimize(theVal)
785 # @param theFineness is:
786 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
787 def SetFineness(self, theFineness):
790 self.params.SetFineness(theFineness)
793 def SetGrowthRate(self, theRate):
796 self.params.SetGrowthRate(theRate)
799 def SetNbSegPerEdge(self, theVal):
802 self.params.SetNbSegPerEdge(theVal)
804 ## Set NbSegPerRadius
805 def SetNbSegPerRadius(self, theVal):
808 self.params.SetNbSegPerRadius(theVal)
810 # Public class: Mesh_Hexahedron
811 # ------------------------------
813 ## Class to define a hexahedron 3D algorithm
816 class Mesh_Hexahedron(Mesh_Algorithm):
818 ## Private constructor.
819 def __init__(self, mesh, geom=0):
820 self.Create(mesh, geom, "Hexa_3D")
822 # Deprecated, only for compatibility!
823 # Public class: Mesh_Netgen
824 # ------------------------------
826 ## Class to define a NETGEN-based 2D or 3D algorithm
827 # that need no discrete boundary (i.e. independent)
829 # This class is deprecated, only for compatibility!
832 class Mesh_Netgen(Mesh_Algorithm):
836 ## Private constructor.
837 def __init__(self, mesh, is3D, geom=0):
839 print "Warning: NETGENPlugin module has not been imported."
843 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
845 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
847 ## Define hypothesis containing parameters of the algorithm
848 def Parameters(self):
850 hyp = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
852 hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
855 # Public class: Mesh_Projection1D
856 # ------------------------------
858 ## Class to define a projection 1D algorithm
861 class Mesh_Projection1D(Mesh_Algorithm):
863 ## Private constructor.
864 def __init__(self, mesh, geom=0):
865 self.Create(mesh, geom, "Projection_1D")
867 ## Define "Source Edge" hypothesis, specifying a meshed edge to
868 # take a mesh pattern from, and optionally association of vertices
869 # between the source edge and a target one (where a hipothesis is assigned to)
870 # @param edge to take nodes distribution from
871 # @param mesh to take nodes distribution from (optional)
872 # @param srcV is vertex of \a edge to associate with \a tgtV (optional)
873 # @param tgtV is vertex of \a the edge where the algorithm is assigned,
874 # to associate with \a srcV (optional)
875 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None):
876 hyp = self.Hypothesis("ProjectionSource1D")
877 hyp.SetSourceEdge( edge )
878 if not mesh is None and isinstance(mesh, Mesh):
879 mesh = mesh.GetMesh()
880 hyp.SetSourceMesh( mesh )
881 hyp.SetVertexAssociation( srcV, tgtV )
885 # Public class: Mesh_Projection2D
886 # ------------------------------
888 ## Class to define a projection 2D algorithm
891 class Mesh_Projection2D(Mesh_Algorithm):
893 ## Private constructor.
894 def __init__(self, mesh, geom=0):
895 self.Create(mesh, geom, "Projection_2D")
897 ## Define "Source Face" hypothesis, specifying a meshed face to
898 # take a mesh pattern from, and optionally association of vertices
899 # between the source face and a target one (where a hipothesis is assigned to)
900 # @param face to take mesh pattern from
901 # @param mesh to take mesh pattern from (optional)
902 # @param srcV1 is vertex of \a face to associate with \a tgtV1 (optional)
903 # @param tgtV1 is vertex of \a the face where the algorithm is assigned,
904 # to associate with \a srcV1 (optional)
905 # @param srcV2 is vertex of \a face to associate with \a tgtV1 (optional)
906 # @param tgtV2 is vertex of \a the face where the algorithm is assigned,
907 # to associate with \a srcV2 (optional)
909 # Note: association vertices must belong to one edge of a face
910 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None, srcV2=None, tgtV2=None):
911 hyp = self.Hypothesis("ProjectionSource2D")
912 hyp.SetSourceFace( face )
913 if not mesh is None and isinstance(mesh, Mesh):
914 mesh = mesh.GetMesh()
915 hyp.SetSourceMesh( mesh )
916 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
919 # Public class: Mesh_Projection3D
920 # ------------------------------
922 ## Class to define a projection 3D algorithm
925 class Mesh_Projection3D(Mesh_Algorithm):
927 ## Private constructor.
928 def __init__(self, mesh, geom=0):
929 self.Create(mesh, geom, "Projection_3D")
931 ## Define "Source Shape 3D" hypothesis, specifying a meshed solid to
932 # take a mesh pattern from, and optionally association of vertices
933 # between the source solid and a target one (where a hipothesis is assigned to)
934 # @param solid to take mesh pattern from
935 # @param mesh to take mesh pattern from (optional)
936 # @param srcV1 is vertex of \a solid to associate with \a tgtV1 (optional)
937 # @param tgtV1 is vertex of \a the solid where the algorithm is assigned,
938 # to associate with \a srcV1 (optional)
939 # @param srcV2 is vertex of \a solid to associate with \a tgtV1 (optional)
940 # @param tgtV2 is vertex of \a the solid where the algorithm is assigned,
941 # to associate with \a srcV2 (optional)
943 # Note: association vertices must belong to one edge of a solid
944 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0, srcV2=0, tgtV2=0):
945 hyp = self.Hypothesis("ProjectionSource3D")
946 hyp.SetSource3DShape( solid )
947 if not mesh is None and isinstance(mesh, Mesh):
948 mesh = mesh.GetMesh()
949 hyp.SetSourceMesh( mesh )
950 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
954 # Public class: Mesh_Prism
955 # ------------------------
957 ## Class to define a 3D extrusion algorithm
960 class Mesh_Prism3D(Mesh_Algorithm):
962 ## Private constructor.
963 def __init__(self, mesh, geom=0):
964 self.Create(mesh, geom, "Prism_3D")
966 # Public class: Mesh_RadialPrism
967 # -------------------------------
969 ## Class to define a Radial Prism 3D algorithm
972 class Mesh_RadialPrism3D(Mesh_Algorithm):
974 ## Private constructor.
975 def __init__(self, mesh, geom=0):
976 self.Create(mesh, geom, "RadialPrism_3D")
977 self.distribHyp = self.Hypothesis( "LayerDistribution" )
980 ## Return 3D hypothesis holding the 1D one
981 def Get3DHypothesis(self):
982 return self.distribHyp
984 ## Private method creating 1D hypothes and storing it in the LayerDistribution
985 # hypothes. Returns the created hypothes
986 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
987 if not self.nbLayers is None:
988 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
989 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
990 study = GetCurrentStudy() # prevent publishing of own 1D hypothesis
991 hyp = smesh.CreateHypothesis(hypType, so)
992 SetCurrentStudy( study ) # anable publishing
993 self.distribHyp.SetLayerDistribution( hyp )
996 ## Define "NumberOfLayers" hypothesis, specifying a number of layers of
997 # prisms to build between the inner and outer shells
998 def NumberOfLayers(self, n ):
999 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1000 self.nbLayers = self.Hypothesis("NumberOfLayers")
1001 self.nbLayers.SetNumberOfLayers( n )
1002 return self.nbLayers
1004 ## Define "LocalLength" hypothesis, specifying segment length
1005 # to build between the inner and outer shells
1006 # @param l for the length of segments
1007 def LocalLength(self, l):
1008 hyp = self.OwnHypothesis("LocalLength", [l])
1012 ## Define "NumberOfSegments" hypothesis, specifying a number of layers of
1013 # prisms to build between the inner and outer shells
1014 # @param n for the number of segments
1015 # @param s for the scale factor (optional)
1016 def NumberOfSegments(self, n, s=[]):
1018 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1020 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1021 hyp.SetDistrType( 1 )
1022 hyp.SetScaleFactor(s)
1023 hyp.SetNumberOfSegments(n)
1026 ## Define "Arithmetic1D" hypothesis, specifying distribution of segments
1027 # to build between the inner and outer shells as arithmetic length increasing
1028 # @param start for the length of the first segment
1029 # @param end for the length of the last segment
1030 def Arithmetic1D(self, start, end):
1031 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1032 hyp.SetLength(start, 1)
1033 hyp.SetLength(end , 0)
1036 ## Define "StartEndLength" hypothesis, specifying distribution of segments
1037 # to build between the inner and outer shells as geometric length increasing
1038 # @param start for the length of the first segment
1039 # @param end for the length of the last segment
1040 def StartEndLength(self, start, end):
1041 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1042 hyp.SetLength(start, 1)
1043 hyp.SetLength(end , 0)
1046 ## Define "AutomaticLength" hypothesis, specifying number of segments
1047 # to build between the inner and outer shells
1048 # @param fineness for the fineness [0-1]
1049 def AutomaticLength(self, fineness=0):
1050 hyp = self.OwnHypothesis("AutomaticLength")
1051 hyp.SetFineness( fineness )
1055 # Public class: Mesh
1056 # ==================
1058 ## Class to define a mesh
1060 # The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
1070 # Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
1071 # sets GUI name of this mesh to \a name.
1072 # @param obj Shape to be meshed or SMESH_Mesh object
1073 # @param name Study name of the mesh
1074 def __init__(self, obj=0, name=0):
1078 if isinstance(obj, geompy.GEOM._objref_GEOM_Object):
1080 self.mesh = smesh.CreateMesh(self.geom)
1081 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1084 self.mesh = smesh.CreateEmptyMesh()
1086 SetName(self.mesh, name)
1088 SetName(self.mesh, GetName(obj))
1090 self.editor = self.mesh.GetMeshEditor()
1092 ## Method that inits the Mesh object from SMESH_Mesh interface
1093 # @param theMesh is SMESH_Mesh object
1094 def SetMesh(self, theMesh):
1096 self.geom = self.mesh.GetShapeToMesh()
1098 ## Method that returns the mesh
1099 # @return SMESH_Mesh object
1105 name = GetName(self.GetMesh())
1109 def SetName(self, name):
1110 SetName(self.GetMesh(), name)
1112 ## Get the subMesh object associated to a subShape. The subMesh object
1113 # gives access to nodes and elements IDs.
1114 # \n SubMesh will be used instead of SubShape in a next idl version to
1115 # adress a specific subMesh...
1116 def GetSubMesh(self, theSubObject, name):
1117 submesh = self.mesh.GetSubMesh(theSubObject, name)
1120 ## Method that returns the shape associated to the mesh
1121 # @return GEOM_Object
1125 ## Method that associates given shape to the mesh(entails the mesh recreation)
1126 # @param geom shape to be meshed(GEOM_Object)
1127 def SetShape(self, geom):
1128 self.mesh = smesh.CreateMesh(geom)
1130 ## Return true if hypotheses are defined well
1131 # @param theMesh is an instance of Mesh class
1132 # @param theSubObject subshape of a mesh shape
1133 def IsReadyToCompute(self, theSubObject):
1134 return smesh.IsReadyToCompute(self.mesh, theSubObject)
1136 ## Return errors of hypotheses definintion
1137 # error list is empty if everything is OK
1138 # @param theMesh is an instance of Mesh class
1139 # @param theSubObject subshape of a mesh shape
1140 # @return a list of errors
1141 def GetAlgoState(self, theSubObject):
1142 return smesh.GetAlgoState(self.mesh, theSubObject)
1144 ## Return geometrical object the given element is built on.
1145 # The returned geometrical object, if not nil, is either found in the
1146 # study or is published by this method with the given name
1147 # @param theMesh is an instance of Mesh class
1148 # @param theElementID an id of the mesh element
1149 # @param theGeomName user defined name of geometrical object
1150 # @return GEOM::GEOM_Object instance
1151 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1152 return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1154 ## Returns mesh dimension depending on shape one
1155 def MeshDimension(self):
1156 shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
1157 if len( shells ) > 0 :
1159 elif geompy.NumberOfFaces( self.geom ) > 0 :
1161 elif geompy.NumberOfEdges( self.geom ) > 0 :
1167 ## Creates a segment discretization 1D algorithm.
1168 # If the optional \a algo parameter is not sets, this algorithm is REGULAR.
1169 # If the optional \a geom parameter is not sets, this algorithm is global.
1170 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1171 # @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
1172 # @param geom If defined, subshape to be meshed
1173 def Segment(self, algo=REGULAR, geom=0):
1174 ## if Segment(geom) is called by mistake
1175 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1176 algo, geom = geom, algo
1179 return Mesh_Segment(self, geom)
1180 elif algo == PYTHON:
1181 return Mesh_Segment_Python(self, geom)
1182 elif algo == COMPOSITE:
1183 return Mesh_CompositeSegment(self, geom)
1185 return Mesh_Segment(self, geom)
1187 ## Creates a triangle 2D algorithm for faces.
1188 # If the optional \a geom parameter is not sets, this algorithm is global.
1189 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1190 # @param algo values are: smesh.MEFISTO or smesh.NETGEN
1191 # @param geom If defined, subshape to be meshed
1192 def Triangle(self, algo=MEFISTO, geom=0):
1193 ## if Triangle(geom) is called by mistake
1194 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1198 return Mesh_Triangle(self, algo, geom)
1200 ## Creates a quadrangle 2D algorithm for faces.
1201 # If the optional \a geom parameter is not sets, this algorithm is global.
1202 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1203 # @param geom If defined, subshape to be meshed
1204 def Quadrangle(self, geom=0):
1205 return Mesh_Quadrangle(self, geom)
1207 ## Creates a tetrahedron 3D algorithm for solids.
1208 # The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
1209 # If the optional \a geom parameter is not sets, this algorithm is global.
1210 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1211 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
1212 # @param geom If defined, subshape to be meshed
1213 def Tetrahedron(self, algo=NETGEN, geom=0):
1214 ## if Tetrahedron(geom) is called by mistake
1215 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1216 algo, geom = geom, algo
1218 return Mesh_Tetrahedron(self, algo, geom)
1220 ## Creates a hexahedron 3D algorithm for solids.
1221 # If the optional \a geom parameter is not sets, this algorithm is global.
1222 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1223 # @param geom If defined, subshape to be meshed
1224 def Hexahedron(self, geom=0):
1225 return Mesh_Hexahedron(self, geom)
1227 ## Deprecated, only for compatibility!
1228 def Netgen(self, is3D, geom=0):
1229 return Mesh_Netgen(self, is3D, geom)
1231 ## Creates a projection 1D algorithm for edges.
1232 # If the optional \a geom parameter is not sets, this algorithm is global.
1233 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1234 # @param geom If defined, subshape to be meshed
1235 def Projection1D(self, geom=0):
1236 return Mesh_Projection1D(self, geom)
1238 ## Creates a projection 2D algorithm for faces.
1239 # If the optional \a geom parameter is not sets, this algorithm is global.
1240 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1241 # @param geom If defined, subshape to be meshed
1242 def Projection2D(self, geom=0):
1243 return Mesh_Projection2D(self, geom)
1245 ## Creates a projection 3D algorithm for solids.
1246 # If the optional \a geom parameter is not sets, this algorithm is global.
1247 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1248 # @param geom If defined, subshape to be meshed
1249 def Projection3D(self, geom=0):
1250 return Mesh_Projection3D(self, geom)
1252 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1253 # If the optional \a geom parameter is not sets, this algorithm is global.
1254 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1255 # @param geom If defined, subshape to be meshed
1256 def Prism(self, geom=0):
1260 nbSolids = len( geompy.SubShapeAll( shape, geompy.ShapeType["SOLID"] ))
1261 nbShells = len( geompy.SubShapeAll( shape, geompy.ShapeType["SHELL"] ))
1262 if nbSolids == 0 or nbSolids == nbShells:
1263 return Mesh_Prism3D(self, geom)
1264 return Mesh_RadialPrism3D(self, geom)
1266 ## Compute the mesh and return the status of the computation
1267 def Compute(self, geom=0):
1268 if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object):
1270 print "Compute impossible: mesh is not constructed on geom shape."
1276 ok = smesh.Compute(self.mesh, geom)
1277 except SALOME.SALOME_Exception, ex:
1278 print "Mesh computation failed, exception cought:"
1279 print " ", ex.details.text
1282 print "Mesh computation failed, exception cought:"
1283 traceback.print_exc()
1285 errors = smesh.GetAlgoState( self.mesh, geom )
1288 if err.isGlobalAlgo:
1293 dim = str(err.algoDim)
1294 if err.name == MISSING_ALGO:
1295 reason = glob + dim + "D algorithm is missing"
1296 elif err.name == MISSING_HYPO:
1297 name = '"' + err.algoName + '"'
1298 reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
1299 elif err.name == NOT_CONFORM_MESH:
1300 reason = "Global \"Not Conform mesh allowed\" hypothesis is missing"
1301 elif err.name == BAD_PARAM_VALUE:
1302 name = '"' + err.algoName + '"'
1303 reason = "Hypothesis of" + glob + dim + "D algorithm " + name +\
1304 " has a bad parameter value"
1306 reason = "For unknown reason."+\
1307 " Revise Mesh.Compute() implementation in smesh.py!"
1309 if allReasons != "":
1312 allReasons += reason
1314 if allReasons != "":
1315 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1318 print '"' + GetName(self.mesh) + '"',"has not been computed."
1321 if salome.sg.hasDesktop():
1322 smeshgui = salome.ImportComponentGUI("SMESH")
1323 smeshgui.Init(salome.myStudyId)
1324 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok )
1325 salome.sg.updateObjBrowser(1)
1329 ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1330 # The parameter \a fineness [0,-1] defines mesh fineness
1331 def AutomaticTetrahedralization(self, fineness=0):
1332 dim = self.MeshDimension()
1334 self.RemoveGlobalHypotheses()
1335 self.Segment().AutomaticLength(fineness)
1337 self.Triangle().LengthFromEdges()
1340 self.Tetrahedron(NETGEN)
1342 return self.Compute()
1344 ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1345 # The parameter \a fineness [0,-1] defines mesh fineness
1346 def AutomaticHexahedralization(self, fineness=0):
1347 dim = self.MeshDimension()
1349 self.RemoveGlobalHypotheses()
1350 self.Segment().AutomaticLength(fineness)
1357 return self.Compute()
1359 ## Assign hypothesis
1360 # @param hyp is a hypothesis to assign
1361 # @param geom is subhape of mesh geometry
1362 def AddHypothesis(self, hyp, geom=0 ):
1363 if isinstance( hyp, Mesh_Algorithm ):
1364 hyp = hyp.GetAlgorithm()
1369 status = self.mesh.AddHypothesis(geom, hyp)
1370 isAlgo = ( hyp._narrow( SMESH.SMESH_Algo ) is not None )
1371 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1374 ## Get the list of hypothesis added on a geom
1375 # @param geom is subhape of mesh geometry
1376 def GetHypothesisList(self, geom):
1377 return self.mesh.GetHypothesisList( geom )
1379 ## Removes all global hypotheses
1380 def RemoveGlobalHypotheses(self):
1381 current_hyps = self.mesh.GetHypothesisList( self.geom )
1382 for hyp in current_hyps:
1383 self.mesh.RemoveHypothesis( self.geom, hyp )
1387 ## Create a mesh group based on geometric object \a grp
1388 # and give a \a name, \n if this parameter is not defined
1389 # the name is the same as the geometric group name \n
1390 # Note: Works like GroupOnGeom().
1391 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1392 # @param name is the name of the mesh group
1393 # @return SMESH_GroupOnGeom
1394 def Group(self, grp, name=""):
1395 return self.GroupOnGeom(grp, name)
1397 ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1398 # Export the mesh in a file with the MED format and choice the \a version of MED format
1399 # @param f is the file name
1400 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1401 def ExportToMED(self, f, version, opt=0):
1402 self.mesh.ExportToMED(f, opt, version)
1404 ## Export the mesh in a file with the MED format
1405 # @param f is the file name
1406 # @param auto_groups boolean parameter for creating/not creating
1407 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1408 # the typical use is auto_groups=false.
1409 # @param version MED format version(MED_V2_1 or MED_V2_2)
1410 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1411 self.mesh.ExportToMED(f, auto_groups, version)
1413 ## Export the mesh in a file with the DAT format
1414 # @param f is the file name
1415 def ExportDAT(self, f):
1416 self.mesh.ExportDAT(f)
1418 ## Export the mesh in a file with the UNV format
1419 # @param f is the file name
1420 def ExportUNV(self, f):
1421 self.mesh.ExportUNV(f)
1423 ## Export the mesh in a file with the STL format
1424 # @param f is the file name
1425 # @param ascii defined the kind of file contents
1426 def ExportSTL(self, f, ascii=1):
1427 self.mesh.ExportSTL(f, ascii)
1430 # Operations with groups:
1431 # ----------------------
1433 ## Creates an empty mesh group
1434 # @param elementType is the type of elements in the group
1435 # @param name is the name of the mesh group
1436 # @return SMESH_Group
1437 def CreateEmptyGroup(self, elementType, name):
1438 return self.mesh.CreateGroup(elementType, name)
1440 ## Creates a mesh group based on geometric object \a grp
1441 # and give a \a name, \n if this parameter is not defined
1442 # the name is the same as the geometric group name
1443 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1444 # @param name is the name of the mesh group
1445 # @return SMESH_GroupOnGeom
1446 def GroupOnGeom(self, grp, name="", type=None):
1448 name = grp.GetName()
1451 tgeo = str(grp.GetShapeType())
1452 if tgeo == "VERTEX":
1454 elif tgeo == "EDGE":
1456 elif tgeo == "FACE":
1458 elif tgeo == "SOLID":
1460 elif tgeo == "SHELL":
1462 elif tgeo == "COMPOUND":
1463 if len( geompy.GetObjectIDs( grp )) == 0:
1464 print "Mesh.Group: empty geometric group", GetName( grp )
1466 tgeo = geompy.GetType(grp)
1467 if tgeo == geompy.ShapeType["VERTEX"]:
1469 elif tgeo == geompy.ShapeType["EDGE"]:
1471 elif tgeo == geompy.ShapeType["FACE"]:
1473 elif tgeo == geompy.ShapeType["SOLID"]:
1477 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1480 return self.mesh.CreateGroupFromGEOM(type, name, grp)
1482 ## Create a mesh group by the given ids of elements
1483 # @param groupName is the name of the mesh group
1484 # @param elementType is the type of elements in the group
1485 # @param elemIDs is the list of ids
1486 # @return SMESH_Group
1487 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1488 group = self.mesh.CreateGroup(elementType, groupName)
1492 ## Create a mesh group by the given conditions
1493 # @param groupName is the name of the mesh group
1494 # @param elementType is the type of elements in the group
1495 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1496 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1497 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
1498 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
1499 # @return SMESH_Group
1503 CritType=FT_Undefined,
1506 UnaryOp=FT_Undefined):
1507 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1508 group = self.MakeGroupByCriterion(groupName, aCriterion)
1511 ## Create a mesh group by the given criterion
1512 # @param groupName is the name of the mesh group
1513 # @param Criterion is the instance of Criterion class
1514 # @return SMESH_Group
1515 def MakeGroupByCriterion(self, groupName, Criterion):
1516 aFilterMgr = smesh.CreateFilterManager()
1517 aFilter = aFilterMgr.CreateFilter()
1519 aCriteria.append(Criterion)
1520 aFilter.SetCriteria(aCriteria)
1521 group = self.MakeGroupByFilter(groupName, aFilter)
1524 ## Create a mesh group by the given criteria(list of criterions)
1525 # @param groupName is the name of the mesh group
1526 # @param Criteria is the list of criterions
1527 # @return SMESH_Group
1528 def MakeGroupByCriteria(self, groupName, theCriteria):
1529 aFilterMgr = smesh.CreateFilterManager()
1530 aFilter = aFilterMgr.CreateFilter()
1531 aFilter.SetCriteria(theCriteria)
1532 group = self.MakeGroupByFilter(groupName, aFilter)
1535 ## Create a mesh group by the given filter
1536 # @param groupName is the name of the mesh group
1537 # @param Criterion is the instance of Filter class
1538 # @return SMESH_Group
1539 def MakeGroupByFilter(self, groupName, theFilter):
1540 anIds = theFilter.GetElementsId(self.mesh)
1541 anElemType = theFilter.GetElementType()
1542 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1545 ## Pass mesh elements through the given filter and return ids
1546 # @param theFilter is SMESH_Filter
1547 # @return list of ids
1548 def GetIdsFromFilter(self, theFilter):
1549 return theFilter.GetElementsId(self.mesh)
1551 ## Verify whether 2D mesh element has free edges(edges connected to one face only)\n
1552 # Returns list of special structures(borders).
1553 # @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
1554 def GetFreeBorders(self):
1555 aFilterMgr = smesh.CreateFilterManager()
1556 aPredicate = aFilterMgr.CreateFreeEdges()
1557 aPredicate.SetMesh(self.mesh)
1558 aBorders = aPredicate.GetBorders()
1562 def RemoveGroup(self, group):
1563 self.mesh.RemoveGroup(group)
1565 ## Remove group with its contents
1566 def RemoveGroupWithContents(self, group):
1567 self.mesh.RemoveGroupWithContents(group)
1569 ## Get the list of groups existing in the mesh
1570 def GetGroups(self):
1571 return self.mesh.GetGroups()
1573 ## Get the list of names of groups existing in the mesh
1574 def GetGroupNames(self):
1575 groups = self.GetGroups()
1577 for group in groups:
1578 names.append(group.GetName())
1581 ## Union of two groups
1582 # New group is created. All mesh elements that are
1583 # present in initial groups are added to the new one
1584 def UnionGroups(self, group1, group2, name):
1585 return self.mesh.UnionGroups(group1, group2, name)
1587 ## Intersection of two groups
1588 # New group is created. All mesh elements that are
1589 # present in both initial groups are added to the new one.
1590 def IntersectGroups(self, group1, group2, name):
1591 return self.mesh.IntersectGroups(group1, group2, name)
1593 ## Cut of two groups
1594 # New group is created. All mesh elements that are present in
1595 # main group but do not present in tool group are added to the new one
1596 def CutGroups(self, mainGroup, toolGroup, name):
1597 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1600 # Get some info about mesh:
1601 # ------------------------
1603 ## Get the log of nodes and elements added or removed since previous
1605 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1606 # @return list of log_block structures:
1611 def GetLog(self, clearAfterGet):
1612 return self.mesh.GetLog(clearAfterGet)
1614 ## Clear the log of nodes and elements added or removed since previous
1615 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1617 self.mesh.ClearLog()
1619 ## Get the internal Id
1621 return self.mesh.GetId()
1624 def GetStudyId(self):
1625 return self.mesh.GetStudyId()
1627 ## Check group names for duplications.
1628 # Consider maximum group name length stored in MED file.
1629 def HasDuplicatedGroupNamesMED(self):
1630 return self.mesh.GetStudyId()
1632 ## Obtain instance of SMESH_MeshEditor
1633 def GetMeshEditor(self):
1634 return self.mesh.GetMeshEditor()
1637 def GetMEDMesh(self):
1638 return self.mesh.GetMEDMesh()
1641 # Get informations about mesh contents:
1642 # ------------------------------------
1644 ## Returns number of nodes in mesh
1646 return self.mesh.NbNodes()
1648 ## Returns number of elements in mesh
1649 def NbElements(self):
1650 return self.mesh.NbElements()
1652 ## Returns number of edges in mesh
1654 return self.mesh.NbEdges()
1656 ## Returns number of edges with given order in mesh
1657 # @param elementOrder is order of elements:
1658 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1659 def NbEdgesOfOrder(self, elementOrder):
1660 return self.mesh.NbEdgesOfOrder(elementOrder)
1662 ## Returns number of faces in mesh
1664 return self.mesh.NbFaces()
1666 ## Returns number of faces with given order in mesh
1667 # @param elementOrder is order of elements:
1668 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1669 def NbFacesOfOrder(self, elementOrder):
1670 return self.mesh.NbFacesOfOrder(elementOrder)
1672 ## Returns number of triangles in mesh
1673 def NbTriangles(self):
1674 return self.mesh.NbTriangles()
1676 ## Returns number of triangles with given order in mesh
1677 # @param elementOrder is order of elements:
1678 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1679 def NbTrianglesOfOrder(self, elementOrder):
1680 return self.mesh.NbTrianglesOfOrder(elementOrder)
1682 ## Returns number of quadrangles in mesh
1683 def NbQuadrangles(self):
1684 return self.mesh.NbQuadrangles()
1686 ## Returns number of quadrangles with given order in mesh
1687 # @param elementOrder is order of elements:
1688 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1689 def NbQuadranglesOfOrder(self, elementOrder):
1690 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1692 ## Returns number of polygons in mesh
1693 def NbPolygons(self):
1694 return self.mesh.NbPolygons()
1696 ## Returns number of volumes in mesh
1697 def NbVolumes(self):
1698 return self.mesh.NbVolumes()
1700 ## Returns number of volumes with given order in mesh
1701 # @param elementOrder is order of elements:
1702 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1703 def NbVolumesOfOrder(self, elementOrder):
1704 return self.mesh.NbVolumesOfOrder(elementOrder)
1706 ## Returns number of tetrahedrons in mesh
1708 return self.mesh.NbTetras()
1710 ## Returns number of tetrahedrons with given order in mesh
1711 # @param elementOrder is order of elements:
1712 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1713 def NbTetrasOfOrder(self, elementOrder):
1714 return self.mesh.NbTetrasOfOrder(elementOrder)
1716 ## Returns number of hexahedrons in mesh
1718 return self.mesh.NbHexas()
1720 ## Returns number of hexahedrons with given order in mesh
1721 # @param elementOrder is order of elements:
1722 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1723 def NbHexasOfOrder(self, elementOrder):
1724 return self.mesh.NbHexasOfOrder(elementOrder)
1726 ## Returns number of pyramids in mesh
1727 def NbPyramids(self):
1728 return self.mesh.NbPyramids()
1730 ## Returns number of pyramids with given order in mesh
1731 # @param elementOrder is order of elements:
1732 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1733 def NbPyramidsOfOrder(self, elementOrder):
1734 return self.mesh.NbPyramidsOfOrder(elementOrder)
1736 ## Returns number of prisms in mesh
1738 return self.mesh.NbPrisms()
1740 ## Returns number of prisms with given order in mesh
1741 # @param elementOrder is order of elements:
1742 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1743 def NbPrismsOfOrder(self, elementOrder):
1744 return self.mesh.NbPrismsOfOrder(elementOrder)
1746 ## Returns number of polyhedrons in mesh
1747 def NbPolyhedrons(self):
1748 return self.mesh.NbPolyhedrons()
1750 ## Returns number of submeshes in mesh
1751 def NbSubMesh(self):
1752 return self.mesh.NbSubMesh()
1754 ## Returns list of mesh elements ids
1755 def GetElementsId(self):
1756 return self.mesh.GetElementsId()
1758 ## Returns list of ids of mesh elements with given type
1759 # @param elementType is required type of elements
1760 def GetElementsByType(self, elementType):
1761 return self.mesh.GetElementsByType(elementType)
1763 ## Returns list of mesh nodes ids
1764 def GetNodesId(self):
1765 return self.mesh.GetNodesId()
1767 # Get informations about mesh elements:
1768 # ------------------------------------
1770 ## Returns type of mesh element
1771 def GetElementType(self, id, iselem):
1772 return self.mesh.GetElementType(id, iselem)
1774 ## Returns list of submesh elements ids
1775 # @param shapeID is geom object(subshape) IOR
1776 def GetSubMeshElementsId(self, shapeID):
1777 return self.mesh.GetSubMeshElementsId(shapeID)
1779 ## Returns list of submesh nodes ids
1780 # @param shapeID is geom object(subshape) IOR
1781 def GetSubMeshNodesId(self, shapeID, all):
1782 return self.mesh.GetSubMeshNodesId(shapeID, all)
1784 ## Returns list of ids of submesh elements with given type
1785 # @param shapeID is geom object(subshape) IOR
1786 def GetSubMeshElementType(self, shapeID):
1787 return self.mesh.GetSubMeshElementType(shapeID)
1789 ## Get mesh description
1791 return self.mesh.Dump()
1794 # Get information about nodes and elements of mesh by its ids:
1795 # -----------------------------------------------------------
1797 ## Get XYZ coordinates of node as list of double
1798 # \n If there is not node for given ID - returns empty list
1799 def GetNodeXYZ(self, id):
1800 return self.mesh.GetNodeXYZ(id)
1802 ## For given node returns list of IDs of inverse elements
1803 # \n If there is not node for given ID - returns empty list
1804 def GetNodeInverseElements(self, id):
1805 return self.mesh.GetNodeInverseElements(id)
1807 ## If given element is node returns IDs of shape from position
1808 # \n If there is not node for given ID - returns -1
1809 def GetShapeID(self, id):
1810 return self.mesh.GetShapeID(id)
1812 ## For given element returns ID of result shape after
1813 # FindShape() from SMESH_MeshEditor
1814 # \n If there is not element for given ID - returns -1
1815 def GetShapeIDForElem(id):
1816 return self.mesh.GetShapeIDForElem(id)
1818 ## Returns number of nodes for given element
1819 # \n If there is not element for given ID - returns -1
1820 def GetElemNbNodes(self, id):
1821 return self.mesh.GetElemNbNodes(id)
1823 ## Returns ID of node by given index for given element
1824 # \n If there is not element for given ID - returns -1
1825 # \n If there is not node for given index - returns -2
1826 def GetElemNode(self, id, index):
1827 return self.mesh.GetElemNode(id, index)
1829 ## Returns true if given node is medium node
1830 # in given quadratic element
1831 def IsMediumNode(self, elementID, nodeID):
1832 return self.mesh.IsMediumNode(elementID, nodeID)
1834 ## Returns true if given node is medium node
1835 # in one of quadratic elements
1836 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1837 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1839 ## Returns number of edges for given element
1840 def ElemNbEdges(self, id):
1841 return self.mesh.ElemNbEdges(id)
1843 ## Returns number of faces for given element
1844 def ElemNbFaces(self, id):
1845 return self.mesh.ElemNbFaces(id)
1847 ## Returns true if given element is polygon
1848 def IsPoly(self, id):
1849 return self.mesh.IsPoly(id)
1851 ## Returns true if given element is quadratic
1852 def IsQuadratic(self, id):
1853 return self.mesh.IsQuadratic(id)
1855 ## Returns XYZ coordinates of bary center for given element
1857 # \n If there is not element for given ID - returns empty list
1858 def BaryCenter(self, id):
1859 return self.mesh.BaryCenter(id)
1862 # Mesh edition (SMESH_MeshEditor functionality):
1863 # ---------------------------------------------
1865 ## Removes elements from mesh by ids
1866 # @param IDsOfElements is list of ids of elements to remove
1867 def RemoveElements(self, IDsOfElements):
1868 return self.editor.RemoveElements(IDsOfElements)
1870 ## Removes nodes from mesh by ids
1871 # @param IDsOfNodes is list of ids of nodes to remove
1872 def RemoveNodes(self, IDsOfNodes):
1873 return self.editor.RemoveNodes(IDsOfNodes)
1875 ## Add node to mesh by coordinates
1876 def AddNode(self, x, y, z):
1877 return self.editor.AddNode( x, y, z)
1880 ## Create edge both similar and quadratic (this is determed
1881 # by number of given nodes).
1882 # @param IdsOfNodes List of node IDs for creation of element.
1883 # Needed order of nodes in this list corresponds to description
1884 # of MED. \n This description is located by the following link:
1885 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1886 def AddEdge(self, IDsOfNodes):
1887 return self.editor.AddEdge(IDsOfNodes)
1889 ## Create face both similar and quadratic (this is determed
1890 # by number of given nodes).
1891 # @param IdsOfNodes List of node IDs for creation of element.
1892 # Needed order of nodes in this list corresponds to description
1893 # of MED. \n This description is located by the following link:
1894 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1895 def AddFace(self, IDsOfNodes):
1896 return self.editor.AddFace(IDsOfNodes)
1898 ## Add polygonal face to mesh by list of nodes ids
1899 def AddPolygonalFace(self, IdsOfNodes):
1900 return self.editor.AddPolygonalFace(IdsOfNodes)
1902 ## Create volume both similar and quadratic (this is determed
1903 # by number of given nodes).
1904 # @param IdsOfNodes List of node IDs for creation of element.
1905 # Needed order of nodes in this list corresponds to description
1906 # of MED. \n This description is located by the following link:
1907 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1908 def AddVolume(self, IDsOfNodes):
1909 return self.editor.AddVolume(IDsOfNodes)
1911 ## Create volume of many faces, giving nodes for each face.
1912 # @param IdsOfNodes List of node IDs for volume creation face by face.
1913 # @param Quantities List of integer values, Quantities[i]
1914 # gives quantity of nodes in face number i.
1915 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1916 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1918 ## Create volume of many faces, giving IDs of existing faces.
1919 # @param IdsOfFaces List of face IDs for volume creation.
1921 # Note: The created volume will refer only to nodes
1922 # of the given faces, not to the faces itself.
1923 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1924 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1926 ## Move node with given id
1927 # @param NodeID id of the node
1928 # @param x new X coordinate
1929 # @param y new Y coordinate
1930 # @param z new Z coordinate
1931 def MoveNode(self, NodeID, x, y, z):
1932 return self.editor.MoveNode(NodeID, x, y, z)
1934 ## Find a node closest to a point
1935 # @param x X coordinate of a point
1936 # @param y Y coordinate of a point
1937 # @param z Z coordinate of a point
1938 # @return id of a node
1939 def FindNodeClosestTo(self, x, y, z):
1940 preview = self.mesh.GetMeshEditPreviewer()
1941 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1943 ## Find a node closest to a point and move it to a point location
1944 # @param x X coordinate of a point
1945 # @param y Y coordinate of a point
1946 # @param z Z coordinate of a point
1947 # @return id of a moved node
1948 def MeshToPassThroughAPoint(self, x, y, z):
1949 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1951 ## Replace two neighbour triangles sharing Node1-Node2 link
1952 # with ones built on the same 4 nodes but having other common link.
1953 # @param NodeID1 first node id
1954 # @param NodeID2 second node id
1955 # @return false if proper faces not found
1956 def InverseDiag(self, NodeID1, NodeID2):
1957 return self.editor.InverseDiag(NodeID1, NodeID2)
1959 ## Replace two neighbour triangles sharing Node1-Node2 link
1960 # with a quadrangle built on the same 4 nodes.
1961 # @param NodeID1 first node id
1962 # @param NodeID2 second node id
1963 # @return false if proper faces not found
1964 def DeleteDiag(self, NodeID1, NodeID2):
1965 return self.editor.DeleteDiag(NodeID1, NodeID2)
1967 ## Reorient elements by ids
1968 # @param IDsOfElements if undefined reorient all mesh elements
1969 def Reorient(self, IDsOfElements=None):
1970 if IDsOfElements == None:
1971 IDsOfElements = self.GetElementsId()
1972 return self.editor.Reorient(IDsOfElements)
1974 ## Reorient all elements of the object
1975 # @param theObject is mesh, submesh or group
1976 def ReorientObject(self, theObject):
1977 return self.editor.ReorientObject(theObject)
1979 ## Fuse neighbour triangles into quadrangles.
1980 # @param IDsOfElements The triangles to be fused,
1981 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1982 # @param MaxAngle is a max angle between element normals at which fusion
1983 # is still performed; theMaxAngle is mesured in radians.
1984 # @return TRUE in case of success, FALSE otherwise.
1985 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1986 if IDsOfElements == []:
1987 IDsOfElements = self.GetElementsId()
1988 return self.editor.TriToQuad(IDsOfElements, GetFunctor(theCriterion), MaxAngle)
1990 ## Fuse neighbour triangles of the object into quadrangles
1991 # @param theObject is mesh, submesh or group
1992 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1993 # @param MaxAngle is a max angle between element normals at which fusion
1994 # is still performed; theMaxAngle is mesured in radians.
1995 # @return TRUE in case of success, FALSE otherwise.
1996 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1997 return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
1999 ## Split quadrangles into triangles.
2000 # @param IDsOfElements the faces to be splitted.
2001 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2002 # @param @return TRUE in case of success, FALSE otherwise.
2003 def QuadToTri (self, IDsOfElements, theCriterion):
2004 if IDsOfElements == []:
2005 IDsOfElements = self.GetElementsId()
2006 return self.editor.QuadToTri(IDsOfElements, GetFunctor(theCriterion))
2008 ## Split quadrangles into triangles.
2009 # @param theObject object to taking list of elements from, is mesh, submesh or group
2010 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2011 def QuadToTriObject (self, theObject, theCriterion):
2012 return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
2014 ## Split quadrangles into triangles.
2015 # @param theElems The faces to be splitted
2016 # @param the13Diag is used to choose a diagonal for splitting.
2017 # @return TRUE in case of success, FALSE otherwise.
2018 def SplitQuad (self, IDsOfElements, Diag13):
2019 if IDsOfElements == []:
2020 IDsOfElements = self.GetElementsId()
2021 return self.editor.SplitQuad(IDsOfElements, Diag13)
2023 ## Split quadrangles into triangles.
2024 # @param theObject is object to taking list of elements from, is mesh, submesh or group
2025 def SplitQuadObject (self, theObject, Diag13):
2026 return self.editor.SplitQuadObject(theObject, Diag13)
2028 ## Find better splitting of the given quadrangle.
2029 # @param IDOfQuad ID of the quadrangle to be splitted.
2030 # @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
2031 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2032 # diagonal is better, 0 if error occurs.
2033 def BestSplit (self, IDOfQuad, theCriterion):
2034 return self.editor.BestSplit(IDOfQuad, GetFunctor(theCriterion))
2036 ## Split quafrangle faces near triangular facets of volumes
2038 def SplitQuadsNearTriangularFacets(self):
2039 faces_array = self.GetElementsByType(SMESH.FACE)
2040 for face_id in faces_array:
2041 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2042 quad_nodes = self.mesh.GetElemNodes(face_id)
2043 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2044 isVolumeFound = False
2045 for node1_elem in node1_elems:
2046 if not isVolumeFound:
2047 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2048 nb_nodes = self.GetElemNbNodes(node1_elem)
2049 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2050 volume_elem = node1_elem
2051 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2052 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2053 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2054 isVolumeFound = True
2055 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2056 self.SplitQuad([face_id], False) # diagonal 2-4
2057 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2058 isVolumeFound = True
2059 self.SplitQuad([face_id], True) # diagonal 1-3
2060 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2061 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2062 isVolumeFound = True
2063 self.SplitQuad([face_id], True) # diagonal 1-3
2065 ## @brief Split hexahedrons into tetrahedrons.
2067 # Use pattern mapping functionality for splitting.
2068 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2069 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2070 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2071 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2072 # key-point will be mapped into <theNode001>-th node of each volume.
2073 # The (0,0,0) key-point of used pattern corresponds to not split corner.
2074 # @param @return TRUE in case of success, FALSE otherwise.
2075 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2076 # Pattern: 5.---------.6
2081 # (0,0,1) 4.---------.7 * |
2088 # (0,0,0) 0.---------.3
2089 pattern_tetra = "!!! Nb of points: \n 8 \n\
2099 !!! Indices of points of 6 tetras: \n\
2107 pattern = GetPattern()
2108 isDone = pattern.LoadFromFile(pattern_tetra)
2110 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2113 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2114 isDone = pattern.MakeMesh(self.mesh, False, False)
2115 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2117 # split quafrangle faces near triangular facets of volumes
2118 self.SplitQuadsNearTriangularFacets()
2122 ## @brief Split hexahedrons into prisms.
2124 # Use pattern mapping functionality for splitting.
2125 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2126 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2127 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2128 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2129 # key-point will be mapped into <theNode001>-th node of each volume.
2130 # The edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2131 # @param @return TRUE in case of success, FALSE otherwise.
2132 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2133 # Pattern: 5.---------.6
2138 # (0,0,1) 4.---------.7 |
2145 # (0,0,0) 0.---------.3
2146 pattern_prism = "!!! Nb of points: \n 8 \n\
2156 !!! Indices of points of 2 prisms: \n\
2160 pattern = GetPattern()
2161 isDone = pattern.LoadFromFile(pattern_prism)
2163 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2166 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2167 isDone = pattern.MakeMesh(self.mesh, False, False)
2168 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2170 # split quafrangle faces near triangular facets of volumes
2171 self.SplitQuadsNearTriangularFacets()
2176 # @param IDsOfElements list if ids of elements to smooth
2177 # @param IDsOfFixedNodes list of ids of fixed nodes.
2178 # Note that nodes built on edges and boundary nodes are always fixed.
2179 # @param MaxNbOfIterations maximum number of iterations
2180 # @param MaxAspectRatio varies in range [1.0, inf]
2181 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2182 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2183 MaxNbOfIterations, MaxAspectRatio, Method):
2184 if IDsOfElements == []:
2185 IDsOfElements = self.GetElementsId()
2186 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2187 MaxNbOfIterations, MaxAspectRatio, Method)
2189 ## Smooth elements belong to given object
2190 # @param theObject object to smooth
2191 # @param IDsOfFixedNodes list of ids of fixed nodes.
2192 # Note that nodes built on edges and boundary nodes are always fixed.
2193 # @param MaxNbOfIterations maximum number of iterations
2194 # @param MaxAspectRatio varies in range [1.0, inf]
2195 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2196 def SmoothObject(self, theObject, IDsOfFixedNodes,
2197 MaxNbOfIterations, MaxxAspectRatio, Method):
2198 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2199 MaxNbOfIterations, MaxxAspectRatio, Method)
2201 ## Parametric smooth the given elements
2202 # @param IDsOfElements list if ids of elements to smooth
2203 # @param IDsOfFixedNodes list of ids of fixed nodes.
2204 # Note that nodes built on edges and boundary nodes are always fixed.
2205 # @param MaxNbOfIterations maximum number of iterations
2206 # @param MaxAspectRatio varies in range [1.0, inf]
2207 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2208 def SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2209 MaxNbOfIterations, MaxAspectRatio, Method):
2210 if IDsOfElements == []:
2211 IDsOfElements = self.GetElementsId()
2212 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2213 MaxNbOfIterations, MaxAspectRatio, Method)
2215 ## Parametric smooth elements belong to given object
2216 # @param theObject object to smooth
2217 # @param IDsOfFixedNodes list of ids of fixed nodes.
2218 # Note that nodes built on edges and boundary nodes are always fixed.
2219 # @param MaxNbOfIterations maximum number of iterations
2220 # @param MaxAspectRatio varies in range [1.0, inf]
2221 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2222 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2223 MaxNbOfIterations, MaxAspectRatio, Method):
2224 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2225 MaxNbOfIterations, MaxAspectRatio, Method)
2227 ## Converts all mesh to quadratic one, deletes old elements, replacing
2228 # them with quadratic ones with the same id.
2229 def ConvertToQuadratic(self, theForce3d):
2230 self.editor.ConvertToQuadratic(theForce3d)
2232 ## Converts all mesh from quadratic to ordinary ones,
2233 # deletes old quadratic elements, \n replacing
2234 # them with ordinary mesh elements with the same id.
2235 def ConvertFromQuadratic(self):
2236 return self.editor.ConvertFromQuadratic()
2238 ## Renumber mesh nodes
2239 def RenumberNodes(self):
2240 self.editor.RenumberNodes()
2242 ## Renumber mesh elements
2243 def RenumberElements(self):
2244 self.editor.RenumberElements()
2246 ## Generate new elements by rotation of the elements around the axis
2247 # @param IDsOfElements list of ids of elements to sweep
2248 # @param Axix axis of rotation, AxisStruct or line(geom object)
2249 # @param AngleInRadians angle of Rotation
2250 # @param NbOfSteps number of steps
2251 # @param Tolerance tolerance
2252 def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
2253 if IDsOfElements == []:
2254 IDsOfElements = self.GetElementsId()
2255 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2256 Axix = GetAxisStruct(Axix)
2257 self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
2259 ## Generate new elements by rotation of the elements of object around the axis
2260 # @param theObject object wich elements should be sweeped
2261 # @param Axix axis of rotation, AxisStruct or line(geom object)
2262 # @param AngleInRadians angle of Rotation
2263 # @param NbOfSteps number of steps
2264 # @param Tolerance tolerance
2265 def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
2266 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2267 Axix = GetAxisStruct(Axix)
2268 self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
2270 ## Generate new elements by extrusion of the elements with given ids
2271 # @param IDsOfElements list of elements ids for extrusion
2272 # @param StepVector vector, defining the direction and value of extrusion
2273 # @param NbOfSteps the number of steps
2274 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
2275 if IDsOfElements == []:
2276 IDsOfElements = self.GetElementsId()
2277 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2278 StepVector = GetDirStruct(StepVector)
2279 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2281 ## Generate new elements by extrusion of the elements with given ids
2282 # @param IDsOfElements is ids of elements
2283 # @param StepVector vector, defining the direction and value of extrusion
2284 # @param NbOfSteps the number of steps
2285 # @param ExtrFlags set flags for performing extrusion
2286 # @param SewTolerance uses for comparing locations of nodes if flag
2287 # EXTRUSION_FLAG_SEW is set
2288 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
2289 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2290 StepVector = GetDirStruct(StepVector)
2291 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
2293 ## Generate new elements by extrusion of the elements belong to object
2294 # @param theObject object wich elements should be processed
2295 # @param StepVector vector, defining the direction and value of extrusion
2296 # @param NbOfSteps the number of steps
2297 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
2298 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2299 StepVector = GetDirStruct(StepVector)
2300 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2302 ## Generate new elements by extrusion of the elements belong to object
2303 # @param theObject object wich elements should be processed
2304 # @param StepVector vector, defining the direction and value of extrusion
2305 # @param NbOfSteps the number of steps
2306 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
2307 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2308 StepVector = GetDirStruct(StepVector)
2309 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2311 ## Generate new elements by extrusion of the elements belong to object
2312 # @param theObject object wich elements should be processed
2313 # @param StepVector vector, defining the direction and value of extrusion
2314 # @param NbOfSteps the number of steps
2315 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
2316 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2317 StepVector = GetDirStruct(StepVector)
2318 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2320 ## Generate new elements by extrusion of the given elements
2321 # A path of extrusion must be a meshed edge.
2322 # @param IDsOfElements is ids of elements
2323 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2324 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2325 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2326 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2327 # @param Angles list of angles
2328 # @param HasRefPoint allows to use base point
2329 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2330 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2331 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2332 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2333 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
2334 if IDsOfElements == []:
2335 IDsOfElements = self.GetElementsId()
2336 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2337 RefPoint = GetPointStruct(RefPoint)
2339 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
2340 HasAngles, Angles, HasRefPoint, RefPoint)
2342 ## Generate new elements by extrusion of the elements belong to object
2343 # A path of extrusion must be a meshed edge.
2344 # @param IDsOfElements is ids of elements
2345 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2346 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2347 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2348 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2349 # @param Angles list of angles
2350 # @param HasRefPoint allows to use base point
2351 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2352 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2353 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2354 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2355 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
2356 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2357 RefPoint = GetPointStruct(RefPoint)
2358 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
2359 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation)
2361 ## Symmetrical copy of mesh elements
2362 # @param IDsOfElements list of elements ids
2363 # @param Mirror is AxisStruct or geom object(point, line, plane)
2364 # @param theMirrorType is POINT, AXIS or PLANE
2365 # If the Mirror is geom object this parameter is unnecessary
2366 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2367 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
2368 if IDsOfElements == []:
2369 IDsOfElements = self.GetElementsId()
2370 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2371 Mirror = GetAxisStruct(Mirror)
2372 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2374 ## Symmetrical copy of object
2375 # @param theObject mesh, submesh or group
2376 # @param Mirror is AxisStruct or geom object(point, line, plane)
2377 # @param theMirrorType is POINT, AXIS or PLANE
2378 # If the Mirror is geom object this parameter is unnecessary
2379 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2380 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
2381 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2382 Mirror = GetAxisStruct(Mirror)
2383 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2385 ## Translates the elements
2386 # @param IDsOfElements list of elements ids
2387 # @param Vector direction of translation(DirStruct or vector)
2388 # @param Copy allows to copy the translated elements
2389 def Translate(self, IDsOfElements, Vector, Copy):
2390 if IDsOfElements == []:
2391 IDsOfElements = self.GetElementsId()
2392 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2393 Vector = GetDirStruct(Vector)
2394 self.editor.Translate(IDsOfElements, Vector, Copy)
2396 ## Translates the object
2397 # @param theObject object to translate(mesh, submesh, or group)
2398 # @param Vector direction of translation(DirStruct or geom vector)
2399 # @param Copy allows to copy the translated elements
2400 def TranslateObject(self, theObject, Vector, Copy):
2401 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2402 Vector = GetDirStruct(Vector)
2403 self.editor.TranslateObject(theObject, Vector, Copy)
2405 ## Rotates the elements
2406 # @param IDsOfElements list of elements ids
2407 # @param Axis axis of rotation(AxisStruct or geom line)
2408 # @param AngleInRadians angle of rotation(in radians)
2409 # @param Copy allows to copy the rotated elements
2410 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
2411 if IDsOfElements == []:
2412 IDsOfElements = self.GetElementsId()
2413 if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
2414 Axis = GetAxisStruct(Axis)
2415 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2417 ## Rotates the object
2418 # @param theObject object to rotate(mesh, submesh, or group)
2419 # @param Axis axis of rotation(AxisStruct or geom line)
2420 # @param AngleInRadians angle of rotation(in radians)
2421 # @param Copy allows to copy the rotated elements
2422 def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
2423 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2425 ## Find group of nodes close to each other within Tolerance.
2426 # @param Tolerance tolerance value
2427 # @param list of group of nodes
2428 def FindCoincidentNodes (self, Tolerance):
2429 return self.editor.FindCoincidentNodes(Tolerance)
2431 ## Find group of nodes close to each other within Tolerance.
2432 # @param Tolerance tolerance value
2433 # @param SubMeshOrGroup SubMesh or Group
2434 # @param list of group of nodes
2435 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2436 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2439 # @param list of group of nodes
2440 def MergeNodes (self, GroupsOfNodes):
2441 self.editor.MergeNodes(GroupsOfNodes)
2443 ## Find elements built on the same nodes.
2444 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2445 # @return a list of groups of equal elements
2446 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2447 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2449 ## Merge elements in each given group.
2450 # @param GroupsOfElementsID groups of elements for merging
2451 def MergeElements(self, GroupsOfElementsID):
2452 self.editor.MergeElements(GroupsOfElementsID)
2454 ## Remove all but one of elements built on the same nodes.
2455 def MergeEqualElements(self):
2456 self.editor.MergeEqualElements()
2459 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2460 FirstNodeID2, SecondNodeID2, LastNodeID2,
2461 CreatePolygons, CreatePolyedrs):
2462 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2463 FirstNodeID2, SecondNodeID2, LastNodeID2,
2464 CreatePolygons, CreatePolyedrs)
2466 ## Sew conform free borders
2467 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2468 FirstNodeID2, SecondNodeID2):
2469 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2470 FirstNodeID2, SecondNodeID2)
2472 ## Sew border to side
2473 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2474 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2475 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2476 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2478 ## Sew two sides of a mesh. Nodes belonging to Side1 are
2479 # merged with nodes of elements of Side2.
2480 # Number of elements in theSide1 and in theSide2 must be
2481 # equal and they should have similar node connectivity.
2482 # The nodes to merge should belong to sides borders and
2483 # the first node should be linked to the second.
2484 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2485 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2486 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2487 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2488 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2489 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2491 ## Set new nodes for given element.
2492 # @param ide the element id
2493 # @param newIDs nodes ids
2494 # @return If number of nodes is not corresponded to type of element - returns false
2495 def ChangeElemNodes(self, ide, newIDs):
2496 return self.editor.ChangeElemNodes(ide, newIDs)
2498 ## If during last operation of MeshEditor some nodes were
2499 # created this method returns list of it's IDs, \n
2500 # if new nodes not created - returns empty list
2501 def GetLastCreatedNodes(self):
2502 return self.editor.GetLastCreatedNodes()
2504 ## If during last operation of MeshEditor some elements were
2505 # created this method returns list of it's IDs, \n
2506 # if new elements not creared - returns empty list
2507 def GetLastCreatedElems(self):
2508 return self.editor.GetLastCreatedElems()