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
60 # MirrorType enumeration
61 POINT = SMESH_MeshEditor.POINT
62 AXIS = SMESH_MeshEditor.AXIS
63 PLANE = SMESH_MeshEditor.PLANE
65 # Smooth_Method enumeration
66 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
67 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
69 # Fineness enumeration(for NETGEN)
81 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
82 smesh.SetCurrentStudy(salome.myStudy)
88 ior = salome.orb.object_to_string(obj)
89 sobj = salome.myStudy.FindObjectIOR(ior)
93 attr = sobj.FindAttribute("AttributeName")[1]
96 ## Sets name to object
97 def SetName(obj, name):
98 ior = salome.orb.object_to_string(obj)
99 sobj = salome.myStudy.FindObjectIOR(ior)
101 attr = sobj.FindAttribute("AttributeName")[1]
104 ## Returns long value from enumeration
105 # Uses for SMESH.FunctorType enumeration
106 def EnumToLong(theItem):
109 ## Get PointStruct from vertex
110 # @param theVertex is GEOM object(vertex)
111 # @return SMESH.PointStruct
112 def GetPointStruct(theVertex):
113 [x, y, z] = geompy.PointCoordinates(theVertex)
114 return PointStruct(x,y,z)
116 ## Get DirStruct from vector
117 # @param theVector is GEOM object(vector)
118 # @return SMESH.DirStruct
119 def GetDirStruct(theVector):
120 vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] )
121 if(len(vertices) != 2):
122 print "Error: vector object is incorrect."
124 p1 = geompy.PointCoordinates(vertices[0])
125 p2 = geompy.PointCoordinates(vertices[1])
126 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
130 ## Get AxisStruct from object
131 # @param theObj is GEOM object(line or plane)
132 # @return SMESH.AxisStruct
133 def GetAxisStruct(theObj):
134 edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] )
136 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
137 vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] )
138 vertex1 = geompy.PointCoordinates(vertex1)
139 vertex2 = geompy.PointCoordinates(vertex2)
140 vertex3 = geompy.PointCoordinates(vertex3)
141 vertex4 = geompy.PointCoordinates(vertex4)
142 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
143 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
144 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] ]
145 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
147 elif len(edges) == 1:
148 vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
149 p1 = geompy.PointCoordinates( vertex1 )
150 p2 = geompy.PointCoordinates( vertex2 )
151 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
155 # From SMESH_Gen interface:
156 # ------------------------
158 ## Set the current mode
159 def SetEmbeddedMode( theMode ):
160 smesh.SetEmbeddedMode(theMode)
162 ## Get the current mode
163 def IsEmbeddedMode():
164 return smesh.IsEmbeddedMode()
166 ## Set the current study
167 def SetCurrentStudy( theStudy ):
168 smesh.SetCurrentStudy(theStudy)
170 ## Get the current study
171 def GetCurrentStudy():
172 return smesh.GetCurrentStudy()
174 ## Create Mesh object importing data from given UNV file
175 # @return an instance of Mesh class
176 def CreateMeshesFromUNV( theFileName ):
177 aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName)
178 aMesh = Mesh(aSmeshMesh)
181 ## Create Mesh object(s) importing data from given MED file
182 # @return a list of Mesh class instances
183 def CreateMeshesFromMED( theFileName ):
184 aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName)
186 for iMesh in range(len(aSmeshMeshes)) :
187 aMesh = Mesh(aSmeshMeshes[iMesh])
188 aMeshes.append(aMesh)
189 return aMeshes, aStatus
191 ## Create Mesh object importing data from given STL file
192 # @return an instance of Mesh class
193 def CreateMeshesFromSTL( theFileName ):
194 aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName)
195 aMesh = Mesh(aSmeshMesh)
198 ## From SMESH_Gen interface
199 def GetSubShapesId( theMainObject, theListOfSubObjects ):
200 return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
202 ## From SMESH_Gen interface. Creates pattern
204 return smesh.GetPattern()
208 # Filtering. Auxiliary functions:
209 # ------------------------------
211 ## Creates an empty criterion
212 # @return SMESH.Filter.Criterion
213 def GetEmptyCriterion():
214 Type = EnumToLong(FT_Undefined)
215 Compare = EnumToLong(FT_Undefined)
219 UnaryOp = EnumToLong(FT_Undefined)
220 BinaryOp = EnumToLong(FT_Undefined)
223 Precision = -1 ##@1e-07
224 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
225 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
227 ## Creates a criterion by given parameters
228 # @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
229 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
230 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
231 # @param Treshold is threshold value (range of ids as string, shape, numeric)
232 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
233 # @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
234 # FT_Undefined(must be for the last criterion in criteria)
235 # @return SMESH.Filter.Criterion
236 def GetCriterion(elementType,
238 Compare = FT_EqualTo,
240 UnaryOp=FT_Undefined,
241 BinaryOp=FT_Undefined):
242 aCriterion = GetEmptyCriterion()
243 aCriterion.TypeOfElement = elementType
244 aCriterion.Type = EnumToLong(CritType)
248 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
249 aCriterion.Compare = EnumToLong(Compare)
250 elif Compare == "=" or Compare == "==":
251 aCriterion.Compare = EnumToLong(FT_EqualTo)
253 aCriterion.Compare = EnumToLong(FT_LessThan)
255 aCriterion.Compare = EnumToLong(FT_MoreThan)
257 aCriterion.Compare = EnumToLong(FT_EqualTo)
260 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
261 FT_BelongToCylinder, FT_LyingOnGeom]:
263 if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object):
264 aCriterion.ThresholdStr = GetName(aTreshold)
265 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
267 print "Error: Treshold should be a shape."
269 elif CritType == FT_RangeOfIds:
271 if isinstance(aTreshold, str):
272 aCriterion.ThresholdStr = aTreshold
274 print "Error: Treshold should be a string."
276 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
277 # Here we don't need treshold
278 if aTreshold == FT_LogicalNOT:
279 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
280 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
281 aCriterion.BinaryOp = aTreshold
285 aTreshold = float(aTreshold)
286 aCriterion.Threshold = aTreshold
288 print "Error: Treshold should be a number."
291 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
292 aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
294 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
295 aCriterion.BinaryOp = EnumToLong(Treshold)
297 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
298 aCriterion.BinaryOp = EnumToLong(UnaryOp)
300 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
301 aCriterion.BinaryOp = EnumToLong(BinaryOp)
305 ## Creates filter by given parameters of criterion
306 # @param elementType is the type of elements in the group
307 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
308 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
309 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
310 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
311 # @return SMESH_Filter
312 def GetFilter(elementType,
313 CritType=FT_Undefined,
316 UnaryOp=FT_Undefined):
317 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
318 aFilterMgr = smesh.CreateFilterManager()
319 aFilter = aFilterMgr.CreateFilter()
321 aCriteria.append(aCriterion)
322 aFilter.SetCriteria(aCriteria)
325 ## Creates numerical functor by its type
326 # @param theCrierion is FT_...; functor type
327 # @return SMESH_NumericalFunctor
328 def GetFunctor(theCriterion):
329 aFilterMgr = smesh.CreateFilterManager()
330 if theCriterion == FT_AspectRatio:
331 return aFilterMgr.CreateAspectRatio()
332 elif theCriterion == FT_AspectRatio3D:
333 return aFilterMgr.CreateAspectRatio3D()
334 elif theCriterion == FT_Warping:
335 return aFilterMgr.CreateWarping()
336 elif theCriterion == FT_MinimumAngle:
337 return aFilterMgr.CreateMinimumAngle()
338 elif theCriterion == FT_Taper:
339 return aFilterMgr.CreateTaper()
340 elif theCriterion == FT_Skew:
341 return aFilterMgr.CreateSkew()
342 elif theCriterion == FT_Area:
343 return aFilterMgr.CreateArea()
344 elif theCriterion == FT_Volume3D:
345 return aFilterMgr.CreateVolume3D()
346 elif theCriterion == FT_MultiConnection:
347 return aFilterMgr.CreateMultiConnection()
348 elif theCriterion == FT_MultiConnection2D:
349 return aFilterMgr.CreateMultiConnection2D()
350 elif theCriterion == FT_Length:
351 return aFilterMgr.CreateLength()
352 elif theCriterion == FT_Length2D:
353 return aFilterMgr.CreateLength2D()
355 print "Error: given parameter is not numerucal functor type."
358 ## Print error message if a hypothesis was not assigned.
359 def TreatHypoStatus(status, hypName, geomName, isAlgo):
361 hypType = "algorithm"
363 hypType = "hypothesis"
365 if status == HYP_UNKNOWN_FATAL :
366 reason = "for unknown reason"
367 elif status == HYP_INCOMPATIBLE :
368 reason = "this hypothesis mismatches algorithm"
369 elif status == HYP_NOTCONFORM :
370 reason = "not conform mesh would be built"
371 elif status == HYP_ALREADY_EXIST :
372 reason = hypType + " of the same dimension already assigned to this shape"
373 elif status == HYP_BAD_DIM :
374 reason = hypType + " mismatches shape"
375 elif status == HYP_CONCURENT :
376 reason = "there are concurrent hypotheses on sub-shapes"
377 elif status == HYP_BAD_SUBSHAPE :
378 reason = "shape is neither the main one, nor its subshape, nor a valid group"
379 elif status == HYP_BAD_GEOMETRY:
380 reason = "geometry mismatches algorithm's expectation"
381 elif status == HYP_HIDDEN_ALGO:
382 reason = "it is hidden by an algorithm of upper dimension generating all-dimensions elements"
383 elif status == HYP_HIDING_ALGO:
384 reason = "it hides algorithm(s) of lower dimension by generating all-dimensions elements"
387 hypName = '"' + hypName + '"'
388 geomName= '"' + geomName+ '"'
389 if status < HYP_UNKNOWN_FATAL:
390 print hypName, "was assigned to", geomName,"but", reason
392 print hypName, "was not assigned to",geomName,":", reason
397 ## Mother class to define algorithm, recommended to don't use directly.
400 class Mesh_Algorithm:
401 # @class Mesh_Algorithm
402 # @brief Class Mesh_Algorithm
409 ## If the algorithm is global, return 0; \n
410 # else return the submesh associated to this algorithm.
411 def GetSubMesh(self):
414 ## Return the wrapped mesher.
415 def GetAlgorithm(self):
418 ## Get list of hypothesis that can be used with this algorithm
419 def GetCompatibleHypothesis(self):
422 list = self.algo.GetCompatibleHypothesis()
430 def SetName(self, name):
431 SetName(self.algo, name)
435 return self.algo.GetId()
438 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
440 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
445 name = GetName(piece)
450 name = geompy.SubShapeName(geom, piece)
451 geompy.addToStudyInFather(piece, geom, name)
452 self.subm = mesh.mesh.GetSubMesh(geom, hypo)
454 self.algo = smesh.CreateHypothesis(hypo, so)
455 SetName(self.algo, name + "/" + hypo)
456 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
457 TreatHypoStatus( status, hypo, name, 1 )
460 def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
461 hypo = smesh.CreateHypothesis(hyp, so)
467 a = a + s + str(args[i])
470 name = GetName(self.geom)
471 SetName(hypo, name + "/" + hyp + a)
472 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
473 TreatHypoStatus( status, hyp, name, 0 )
477 # Public class: Mesh_Segment
478 # --------------------------
480 ## Class to define a segment 1D algorithm for discretization
483 class Mesh_Segment(Mesh_Algorithm):
485 ## Private constructor.
486 def __init__(self, mesh, geom=0):
487 self.Create(mesh, geom, "Regular_1D")
489 ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
490 # @param l for the length of segments that cut an edge
491 def LocalLength(self, l):
492 hyp = self.Hypothesis("LocalLength", [l])
496 ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
497 # @param n for the number of segments that cut an edge
498 # @param s for the scale factor (optional)
499 def NumberOfSegments(self, n, s=[]):
501 hyp = self.Hypothesis("NumberOfSegments", [n])
503 hyp = self.Hypothesis("NumberOfSegments", [n,s])
504 hyp.SetDistrType( 1 )
505 hyp.SetScaleFactor(s)
506 hyp.SetNumberOfSegments(n)
509 ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
510 # @param start for the length of the first segment
511 # @param end for the length of the last segment
512 def Arithmetic1D(self, start, end):
513 hyp = self.Hypothesis("Arithmetic1D", [start, end])
514 hyp.SetLength(start, 1)
515 hyp.SetLength(end , 0)
518 ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
519 # @param start for the length of the first segment
520 # @param end for the length of the last segment
521 def StartEndLength(self, start, end):
522 hyp = self.Hypothesis("StartEndLength", [start, end])
523 hyp.SetLength(start, 1)
524 hyp.SetLength(end , 0)
527 ## Define "Deflection1D" hypothesis
528 # @param d for the deflection
529 def Deflection1D(self, d):
530 hyp = self.Hypothesis("Deflection1D", [d])
534 ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
535 # the opposite side in the case of quadrangular faces
536 def Propagation(self):
537 return self.Hypothesis("Propagation")
539 ## Define "AutomaticLength" hypothesis
540 # @param fineness for the fineness [0-1]
541 def AutomaticLength(self, fineness=0):
542 hyp = self.Hypothesis("AutomaticLength")
543 hyp.SetFineness( fineness )
546 ## Define "SegmentLengthAroundVertex" hypothesis
547 # @param length for the segment length
548 # @param vertex for the length localization: vertex index [0,1] | verext object
549 def LengthNearVertex(self, length, vertex=0):
551 store_geom = self.geom
553 if type(vertex) is types.IntType:
554 vertex = geompy.SubShapeAllSorted(self.geom,geompy.ShapeType["VERTEX"])[vertex]
558 hyp = self.Hypothesis("SegmentAroundVertex_0D")
559 hyp = self.Hypothesis("SegmentLengthAroundVertex")
560 self.geom = store_geom
561 hyp.SetLength( length )
564 ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
565 # If the 2D mesher sees that all boundary edges are quadratic ones,
566 # it generates quadratic faces, else it generates linear faces using
567 # medium nodes as if they were vertex ones.
568 # The 3D mesher generates quadratic volumes only if all boundary faces
569 # are quadratic ones, else it fails.
570 def QuadraticMesh(self):
571 hyp = self.Hypothesis("QuadraticMesh")
574 # Public class: Mesh_CompositeSegment
575 # --------------------------
577 ## Class to define a segment 1D algorithm for discretization
580 class Mesh_CompositeSegment(Mesh_Segment):
582 ## Private constructor.
583 def __init__(self, mesh, geom=0):
584 self.Create(mesh, geom, "CompositeSegment_1D")
587 # Public class: Mesh_Segment_Python
588 # ---------------------------------
590 ## Class to define a segment 1D algorithm for discretization with python function
593 class Mesh_Segment_Python(Mesh_Segment):
595 ## Private constructor.
596 def __init__(self, mesh, geom=0):
597 import Python1dPlugin
598 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
600 ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
601 # @param n for the number of segments that cut an edge
602 # @param func for the python function that calculate the length of all segments
603 def PythonSplit1D(self, n, func):
604 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so")
605 hyp.SetNumberOfSegments(n)
606 hyp.SetPythonLog10RatioFunction(func)
609 # Public class: Mesh_Triangle
610 # ---------------------------
612 ## Class to define a triangle 2D algorithm
615 class Mesh_Triangle(Mesh_Algorithm):
622 ## Private constructor.
623 def __init__(self, mesh, algoType, geom=0):
624 self.algoType = algoType
625 if algoType == MEFISTO:
626 self.Create(mesh, geom, "MEFISTO_2D")
627 elif algoType == BLSURF:
629 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
630 self.SetPhysicalMesh()
631 elif algoType == NETGEN:
633 print "Warning: NETGENPlugin module has not been imported."
634 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
636 ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
637 # @param area for the maximum area of each triangles
638 def MaxElementArea(self, area):
639 if self.algoType == MEFISTO:
640 hyp = self.Hypothesis("MaxElementArea", [area])
641 hyp.SetMaxElementArea(area)
643 elif self.algoType == NETGEN:
644 print "Netgen 1D-2D algo doesn't support this hypothesis"
647 ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
648 def LengthFromEdges(self):
649 if self.algoType == MEFISTO:
650 hyp = self.Hypothesis("LengthFromEdges")
652 elif self.algoType == NETGEN:
653 print "Netgen 1D-2D algo doesn't support this hypothesis"
656 ## Define "Netgen 2D Parameters" hypothesis
657 def Parameters(self):
658 if self.algoType == NETGEN:
659 self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
661 elif self.algoType == MEFISTO:
662 print "Mefisto algo doesn't support this hypothesis"
664 elif self.algoType == BLSURF:
665 self.params = self.Hypothesis("BLSURF_Parameters", [], "libBLSURFEngine.so")
669 def SetMaxSize(self, theSize):
672 self.params.SetMaxSize(theSize)
674 ## Set SecondOrder flag
675 def SetSecondOrder(seld, theVal):
678 self.params.SetSecondOrder(theVal)
681 def SetOptimize(self, theVal):
684 self.params.SetOptimize(theVal)
687 # @param theFineness is:
688 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
689 def SetFineness(self, theFineness):
692 self.params.SetFineness(theFineness)
695 def SetGrowthRate(self, theRate):
698 self.params.SetGrowthRate(theRate)
701 def SetNbSegPerEdge(self, theVal):
704 self.params.SetNbSegPerEdge(theVal)
706 ## Set NbSegPerRadius
707 def SetNbSegPerRadius(self, theVal):
710 self.params.SetNbSegPerRadius(theVal)
713 # @param thePhysicalMesh is:
714 # DefaultSize or Custom
715 def SetPhysicalMesh(self, thePhysicalMesh=1):
718 self.params.SetPhysicalMesh(thePhysicalMesh)
721 def SetPhySize(self, theVal):
724 self.params.SetPhySize(theVal)
727 # @param theGeometricMesh is:
728 # DefaultGeom or Custom
729 def SetGeometricMesh(self, theGeometricMesh=0):
732 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
733 self.params.SetGeometricMesh(theGeometricMesh)
735 ## Set AngleMeshS flag
736 def SetAngleMeshS(self, theVal=_angleMeshS):
739 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
740 self.params.SetAngleMeshS(theVal)
742 ## Set Gradation flag
743 def SetGradation(self, theVal=_gradation):
746 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
747 self.params.SetGradation(theVal)
749 ## Set QuadAllowed flag
750 def SetQuadAllowed(self, toAllow=False):
753 self.params.SetQuadAllowed(toAllow)
756 def SetDecimesh(self, toAllow=False):
759 self.params.SetDecimesh(toAllow)
761 # Public class: Mesh_Quadrangle
762 # -----------------------------
764 ## Class to define a quadrangle 2D algorithm
767 class Mesh_Quadrangle(Mesh_Algorithm):
769 ## Private constructor.
770 def __init__(self, mesh, geom=0):
771 self.Create(mesh, geom, "Quadrangle_2D")
773 ## Define "QuadranglePreference" hypothesis, forcing construction
774 # of quadrangles if the number of nodes on opposite edges is not the same
775 # in the case where the global number of nodes on edges is even
776 def QuadranglePreference(self):
777 hyp = self.Hypothesis("QuadranglePreference")
780 # Public class: Mesh_Tetrahedron
781 # ------------------------------
783 ## Class to define a tetrahedron 3D algorithm
786 class Mesh_Tetrahedron(Mesh_Algorithm):
791 ## Private constructor.
792 def __init__(self, mesh, algoType, geom=0):
793 if algoType == NETGEN:
794 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
795 elif algoType == GHS3D:
797 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
798 elif algoType == FULL_NETGEN:
800 print "Warning: NETGENPlugin module has not been imported."
801 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
802 self.algoType = algoType
804 ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
805 # @param vol for the maximum volume of each tetrahedral
806 def MaxElementVolume(self, vol):
807 hyp = self.Hypothesis("MaxElementVolume", [vol])
808 hyp.SetMaxElementVolume(vol)
811 ## Define "Netgen 3D Parameters" hypothesis
812 def Parameters(self):
813 if (self.algoType == FULL_NETGEN):
814 self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
817 print "Algo doesn't support this hypothesis"
821 def SetMaxSize(self, theSize):
824 self.params.SetMaxSize(theSize)
826 ## Set SecondOrder flag
827 def SetSecondOrder(self, theVal):
830 self.params.SetSecondOrder(theVal)
833 def SetOptimize(self, theVal):
836 self.params.SetOptimize(theVal)
839 # @param theFineness is:
840 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
841 def SetFineness(self, theFineness):
844 self.params.SetFineness(theFineness)
847 def SetGrowthRate(self, theRate):
850 self.params.SetGrowthRate(theRate)
853 def SetNbSegPerEdge(self, theVal):
856 self.params.SetNbSegPerEdge(theVal)
858 ## Set NbSegPerRadius
859 def SetNbSegPerRadius(self, theVal):
862 self.params.SetNbSegPerRadius(theVal)
864 # Public class: Mesh_Hexahedron
865 # ------------------------------
867 ## Class to define a hexahedron 3D algorithm
870 class Mesh_Hexahedron(Mesh_Algorithm):
872 ## Private constructor.
873 ## def __init__(self, mesh, geom=0):
874 ## self.Create(mesh, geom, "Hexa_3D")
875 def __init__(self, mesh, algo, geom):
877 self.Create(mesh, geom, "Hexa_3D")
878 elif algo == Hexotic:
880 self.Create(mesh, geom, "Hexotic_3D" , "libHexoticEngine.so")
882 ## Define "MinMaxQuad" hypothesis to give the three hexotic parameters
883 def MinMaxQuad(self, min=3, max=8, quad=True):
884 hyp = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so")
885 hyp.SetHexesMinLevel(min)
886 hyp.SetHexesMaxLevel(max)
887 hyp.SetHexoticQuadrangles(quad)
890 # Deprecated, only for compatibility!
891 # Public class: Mesh_Netgen
892 # ------------------------------
894 ## Class to define a NETGEN-based 2D or 3D algorithm
895 # that need no discrete boundary (i.e. independent)
897 # This class is deprecated, only for compatibility!
900 class Mesh_Netgen(Mesh_Algorithm):
904 ## Private constructor.
905 def __init__(self, mesh, is3D, geom=0):
907 print "Warning: NETGENPlugin module has not been imported."
911 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
913 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
915 ## Define hypothesis containing parameters of the algorithm
916 def Parameters(self):
918 hyp = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
920 hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
923 # Public class: Mesh_Projection1D
924 # ------------------------------
926 ## Class to define a projection 1D algorithm
929 class Mesh_Projection1D(Mesh_Algorithm):
931 ## Private constructor.
932 def __init__(self, mesh, geom=0):
933 self.Create(mesh, geom, "Projection_1D")
935 ## Define "Source Edge" hypothesis, specifying a meshed edge to
936 # take a mesh pattern from, and optionally association of vertices
937 # between the source edge and a target one (where a hipothesis is assigned to)
938 # @param edge to take nodes distribution from
939 # @param mesh to take nodes distribution from (optional)
940 # @param srcV is vertex of \a edge to associate with \a tgtV (optional)
941 # @param tgtV is vertex of \a the edge where the algorithm is assigned,
942 # to associate with \a srcV (optional)
943 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None):
944 hyp = self.Hypothesis("ProjectionSource1D")
945 hyp.SetSourceEdge( edge )
946 if not mesh is None and isinstance(mesh, Mesh):
947 mesh = mesh.GetMesh()
948 hyp.SetSourceMesh( mesh )
949 hyp.SetVertexAssociation( srcV, tgtV )
953 # Public class: Mesh_Projection2D
954 # ------------------------------
956 ## Class to define a projection 2D algorithm
959 class Mesh_Projection2D(Mesh_Algorithm):
961 ## Private constructor.
962 def __init__(self, mesh, geom=0):
963 self.Create(mesh, geom, "Projection_2D")
965 ## Define "Source Face" hypothesis, specifying a meshed face to
966 # take a mesh pattern from, and optionally association of vertices
967 # between the source face and a target one (where a hipothesis is assigned to)
968 # @param face to take mesh pattern from
969 # @param mesh to take mesh pattern from (optional)
970 # @param srcV1 is vertex of \a face to associate with \a tgtV1 (optional)
971 # @param tgtV1 is vertex of \a the face where the algorithm is assigned,
972 # to associate with \a srcV1 (optional)
973 # @param srcV2 is vertex of \a face to associate with \a tgtV1 (optional)
974 # @param tgtV2 is vertex of \a the face where the algorithm is assigned,
975 # to associate with \a srcV2 (optional)
977 # Note: association vertices must belong to one edge of a face
978 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None, srcV2=None, tgtV2=None):
979 hyp = self.Hypothesis("ProjectionSource2D")
980 hyp.SetSourceFace( face )
981 if not mesh is None and isinstance(mesh, Mesh):
982 mesh = mesh.GetMesh()
983 hyp.SetSourceMesh( mesh )
984 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
987 # Public class: Mesh_Projection3D
988 # ------------------------------
990 ## Class to define a projection 3D algorithm
993 class Mesh_Projection3D(Mesh_Algorithm):
995 ## Private constructor.
996 def __init__(self, mesh, geom=0):
997 self.Create(mesh, geom, "Projection_3D")
999 ## Define "Source Shape 3D" hypothesis, specifying a meshed solid to
1000 # take a mesh pattern from, and optionally association of vertices
1001 # between the source solid and a target one (where a hipothesis is assigned to)
1002 # @param solid to take mesh pattern from
1003 # @param mesh to take mesh pattern from (optional)
1004 # @param srcV1 is vertex of \a solid to associate with \a tgtV1 (optional)
1005 # @param tgtV1 is vertex of \a the solid where the algorithm is assigned,
1006 # to associate with \a srcV1 (optional)
1007 # @param srcV2 is vertex of \a solid to associate with \a tgtV1 (optional)
1008 # @param tgtV2 is vertex of \a the solid where the algorithm is assigned,
1009 # to associate with \a srcV2 (optional)
1011 # Note: association vertices must belong to one edge of a solid
1012 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0, srcV2=0, tgtV2=0):
1013 hyp = self.Hypothesis("ProjectionSource3D")
1014 hyp.SetSource3DShape( solid )
1015 if not mesh is None and isinstance(mesh, Mesh):
1016 mesh = mesh.GetMesh()
1017 hyp.SetSourceMesh( mesh )
1018 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1022 # Public class: Mesh_Prism
1023 # ------------------------
1025 ## Class to define a 3D extrusion algorithm
1028 class Mesh_Prism3D(Mesh_Algorithm):
1030 ## Private constructor.
1031 def __init__(self, mesh, geom=0):
1032 self.Create(mesh, geom, "Prism_3D")
1034 # Public class: Mesh_RadialPrism
1035 # -------------------------------
1037 ## Class to define a Radial Prism 3D algorithm
1040 class Mesh_RadialPrism3D(Mesh_Algorithm):
1042 ## Private constructor.
1043 def __init__(self, mesh, geom=0):
1044 self.Create(mesh, geom, "RadialPrism_3D")
1045 self.distribHyp = self.Hypothesis( "LayerDistribution" )
1046 self.nbLayers = None
1048 ## Return 3D hypothesis holding the 1D one
1049 def Get3DHypothesis(self):
1050 return self.distribHyp
1052 ## Private method creating 1D hypothes and storing it in the LayerDistribution
1053 # hypothes. Returns the created hypothes
1054 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1055 if not self.nbLayers is None:
1056 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1057 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1058 study = GetCurrentStudy() # prevent publishing of own 1D hypothesis
1059 hyp = smesh.CreateHypothesis(hypType, so)
1060 SetCurrentStudy( study ) # anable publishing
1061 self.distribHyp.SetLayerDistribution( hyp )
1064 ## Define "NumberOfLayers" hypothesis, specifying a number of layers of
1065 # prisms to build between the inner and outer shells
1066 def NumberOfLayers(self, n ):
1067 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1068 self.nbLayers = self.Hypothesis("NumberOfLayers")
1069 self.nbLayers.SetNumberOfLayers( n )
1070 return self.nbLayers
1072 ## Define "LocalLength" hypothesis, specifying segment length
1073 # to build between the inner and outer shells
1074 # @param l for the length of segments
1075 def LocalLength(self, l):
1076 hyp = self.OwnHypothesis("LocalLength", [l])
1080 ## Define "NumberOfSegments" hypothesis, specifying a number of layers of
1081 # prisms to build between the inner and outer shells
1082 # @param n for the number of segments
1083 # @param s for the scale factor (optional)
1084 def NumberOfSegments(self, n, s=[]):
1086 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1088 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1089 hyp.SetDistrType( 1 )
1090 hyp.SetScaleFactor(s)
1091 hyp.SetNumberOfSegments(n)
1094 ## Define "Arithmetic1D" hypothesis, specifying distribution of segments
1095 # to build between the inner and outer shells as arithmetic length increasing
1096 # @param start for the length of the first segment
1097 # @param end for the length of the last segment
1098 def Arithmetic1D(self, start, end):
1099 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1100 hyp.SetLength(start, 1)
1101 hyp.SetLength(end , 0)
1104 ## Define "StartEndLength" hypothesis, specifying distribution of segments
1105 # to build between the inner and outer shells as geometric length increasing
1106 # @param start for the length of the first segment
1107 # @param end for the length of the last segment
1108 def StartEndLength(self, start, end):
1109 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1110 hyp.SetLength(start, 1)
1111 hyp.SetLength(end , 0)
1114 ## Define "AutomaticLength" hypothesis, specifying number of segments
1115 # to build between the inner and outer shells
1116 # @param fineness for the fineness [0-1]
1117 def AutomaticLength(self, fineness=0):
1118 hyp = self.OwnHypothesis("AutomaticLength")
1119 hyp.SetFineness( fineness )
1123 # Public class: Mesh
1124 # ==================
1126 ## Class to define a mesh
1128 # The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
1138 # Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
1139 # sets GUI name of this mesh to \a name.
1140 # @param obj Shape to be meshed or SMESH_Mesh object
1141 # @param name Study name of the mesh
1142 def __init__(self, obj=0, name=0):
1146 if isinstance(obj, geompy.GEOM._objref_GEOM_Object):
1148 self.mesh = smesh.CreateMesh(self.geom)
1149 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1152 self.mesh = smesh.CreateEmptyMesh()
1154 SetName(self.mesh, name)
1156 SetName(self.mesh, GetName(obj))
1158 self.editor = self.mesh.GetMeshEditor()
1160 ## Method that inits the Mesh object from SMESH_Mesh interface
1161 # @param theMesh is SMESH_Mesh object
1162 def SetMesh(self, theMesh):
1164 self.geom = self.mesh.GetShapeToMesh()
1166 ## Method that returns the mesh
1167 # @return SMESH_Mesh object
1173 name = GetName(self.GetMesh())
1177 def SetName(self, name):
1178 SetName(self.GetMesh(), name)
1180 ## Get the subMesh object associated to a subShape. The subMesh object
1181 # gives access to nodes and elements IDs.
1182 # \n SubMesh will be used instead of SubShape in a next idl version to
1183 # adress a specific subMesh...
1184 def GetSubMesh(self, theSubObject, name):
1185 submesh = self.mesh.GetSubMesh(theSubObject, name)
1188 ## Method that returns the shape associated to the mesh
1189 # @return GEOM_Object
1193 ## Method that associates given shape to the mesh(entails the mesh recreation)
1194 # @param geom shape to be meshed(GEOM_Object)
1195 def SetShape(self, geom):
1196 self.mesh = smesh.CreateMesh(geom)
1198 ## Return true if hypotheses are defined well
1199 # @param theMesh is an instance of Mesh class
1200 # @param theSubObject subshape of a mesh shape
1201 def IsReadyToCompute(self, theSubObject):
1202 return smesh.IsReadyToCompute(self.mesh, theSubObject)
1204 ## Return errors of hypotheses definintion
1205 # error list is empty if everything is OK
1206 # @param theMesh is an instance of Mesh class
1207 # @param theSubObject subshape of a mesh shape
1208 # @return a list of errors
1209 def GetAlgoState(self, theSubObject):
1210 return smesh.GetAlgoState(self.mesh, theSubObject)
1212 ## Return geometrical object the given element is built on.
1213 # The returned geometrical object, if not nil, is either found in the
1214 # study or is published by this method with the given name
1215 # @param theMesh is an instance of Mesh class
1216 # @param theElementID an id of the mesh element
1217 # @param theGeomName user defined name of geometrical object
1218 # @return GEOM::GEOM_Object instance
1219 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1220 return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1222 ## Returns mesh dimension depending on shape one
1223 def MeshDimension(self):
1224 shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
1225 if len( shells ) > 0 :
1227 elif geompy.NumberOfFaces( self.geom ) > 0 :
1229 elif geompy.NumberOfEdges( self.geom ) > 0 :
1235 ## Creates a segment discretization 1D algorithm.
1236 # If the optional \a algo parameter is not sets, this algorithm is REGULAR.
1237 # If the optional \a geom parameter is not sets, this algorithm is global.
1238 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1239 # @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
1240 # @param geom If defined, subshape to be meshed
1241 def Segment(self, algo=REGULAR, geom=0):
1242 ## if Segment(geom) is called by mistake
1243 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1244 algo, geom = geom, algo
1247 return Mesh_Segment(self, geom)
1248 elif algo == PYTHON:
1249 return Mesh_Segment_Python(self, geom)
1250 elif algo == COMPOSITE:
1251 return Mesh_CompositeSegment(self, geom)
1253 return Mesh_Segment(self, geom)
1255 ## Creates a triangle 2D algorithm for faces.
1256 # If the optional \a geom parameter is not sets, this algorithm is global.
1257 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1258 # @param algo values are: smesh.MEFISTO or smesh.NETGEN
1259 # @param geom If defined, subshape to be meshed
1260 def Triangle(self, algo=MEFISTO, geom=0):
1261 ## if Triangle(geom) is called by mistake
1262 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1266 return Mesh_Triangle(self, algo, geom)
1268 ## Creates a quadrangle 2D algorithm for faces.
1269 # If the optional \a geom parameter is not sets, this algorithm is global.
1270 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1271 # @param geom If defined, subshape to be meshed
1272 def Quadrangle(self, geom=0):
1273 return Mesh_Quadrangle(self, geom)
1275 ## Creates a tetrahedron 3D algorithm for solids.
1276 # The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
1277 # If the optional \a geom parameter is not sets, this algorithm is global.
1278 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1279 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
1280 # @param geom If defined, subshape to be meshed
1281 def Tetrahedron(self, algo=NETGEN, geom=0):
1282 ## if Tetrahedron(geom) is called by mistake
1283 if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1284 algo, geom = geom, algo
1286 return Mesh_Tetrahedron(self, algo, geom)
1288 ## Creates a hexahedron 3D algorithm for solids.
1289 # If the optional \a geom parameter is not sets, this algorithm is global.
1290 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1291 # @param geom If defined, subshape to be meshed
1292 ## def Hexahedron(self, geom=0):
1293 ## return Mesh_Hexahedron(self, geom)
1294 def Hexahedron(self, algo=Hexa, geom=0):
1295 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1296 if ( isinstance(algo, geompy.GEOM._objref_GEOM_Object) ):
1297 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1298 elif geom == 0: algo, geom = Hexa, algo
1299 return Mesh_Hexahedron(self, algo, geom)
1301 ## Deprecated, only for compatibility!
1302 def Netgen(self, is3D, geom=0):
1303 return Mesh_Netgen(self, is3D, geom)
1305 ## Creates a projection 1D algorithm for edges.
1306 # If the optional \a geom parameter is not sets, this algorithm is global.
1307 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1308 # @param geom If defined, subshape to be meshed
1309 def Projection1D(self, geom=0):
1310 return Mesh_Projection1D(self, geom)
1312 ## Creates a projection 2D algorithm for faces.
1313 # If the optional \a geom parameter is not sets, this algorithm is global.
1314 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1315 # @param geom If defined, subshape to be meshed
1316 def Projection2D(self, geom=0):
1317 return Mesh_Projection2D(self, geom)
1319 ## Creates a projection 3D algorithm for solids.
1320 # If the optional \a geom parameter is not sets, this algorithm is global.
1321 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1322 # @param geom If defined, subshape to be meshed
1323 def Projection3D(self, geom=0):
1324 return Mesh_Projection3D(self, geom)
1326 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1327 # If the optional \a geom parameter is not sets, this algorithm is global.
1328 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1329 # @param geom If defined, subshape to be meshed
1330 def Prism(self, geom=0):
1334 nbSolids = len( geompy.SubShapeAll( shape, geompy.ShapeType["SOLID"] ))
1335 nbShells = len( geompy.SubShapeAll( shape, geompy.ShapeType["SHELL"] ))
1336 if nbSolids == 0 or nbSolids == nbShells:
1337 return Mesh_Prism3D(self, geom)
1338 return Mesh_RadialPrism3D(self, geom)
1340 ## Compute the mesh and return the status of the computation
1341 def Compute(self, geom=0):
1342 if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object):
1344 print "Compute impossible: mesh is not constructed on geom shape."
1350 ok = smesh.Compute(self.mesh, geom)
1351 except SALOME.SALOME_Exception, ex:
1352 print "Mesh computation failed, exception cought:"
1353 print " ", ex.details.text
1356 print "Mesh computation failed, exception cought:"
1357 traceback.print_exc()
1359 errors = smesh.GetAlgoState( self.mesh, geom )
1362 if err.isGlobalAlgo:
1367 dim = str(err.algoDim)
1368 if err.name == MISSING_ALGO:
1369 reason = glob + dim + "D algorithm is missing"
1370 elif err.name == MISSING_HYPO:
1371 name = '"' + err.algoName + '"'
1372 reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
1373 elif err.name == NOT_CONFORM_MESH:
1374 reason = "Global \"Not Conform mesh allowed\" hypothesis is missing"
1375 elif err.name == BAD_PARAM_VALUE:
1376 name = '"' + err.algoName + '"'
1377 reason = "Hypothesis of" + glob + dim + "D algorithm " + name +\
1378 " has a bad parameter value"
1380 reason = "For unknown reason."+\
1381 " Revise Mesh.Compute() implementation in smesh.py!"
1383 if allReasons != "":
1386 allReasons += reason
1388 if allReasons != "":
1389 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1392 print '"' + GetName(self.mesh) + '"',"has not been computed."
1395 if salome.sg.hasDesktop():
1396 smeshgui = salome.ImportComponentGUI("SMESH")
1397 smeshgui.Init(salome.myStudyId)
1398 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1399 salome.sg.updateObjBrowser(1)
1403 ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1404 # The parameter \a fineness [0,-1] defines mesh fineness
1405 def AutomaticTetrahedralization(self, fineness=0):
1406 dim = self.MeshDimension()
1408 self.RemoveGlobalHypotheses()
1409 self.Segment().AutomaticLength(fineness)
1411 self.Triangle().LengthFromEdges()
1414 self.Tetrahedron(NETGEN)
1416 return self.Compute()
1418 ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1419 # The parameter \a fineness [0,-1] defines mesh fineness
1420 def AutomaticHexahedralization(self, fineness=0):
1421 dim = self.MeshDimension()
1423 self.RemoveGlobalHypotheses()
1424 self.Segment().AutomaticLength(fineness)
1431 return self.Compute()
1433 ## Assign hypothesis
1434 # @param hyp is a hypothesis to assign
1435 # @param geom is subhape of mesh geometry
1436 def AddHypothesis(self, hyp, geom=0 ):
1437 if isinstance( hyp, Mesh_Algorithm ):
1438 hyp = hyp.GetAlgorithm()
1443 status = self.mesh.AddHypothesis(geom, hyp)
1444 isAlgo = ( hyp._narrow( SMESH.SMESH_Algo ) is not None )
1445 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1448 ## Get the list of hypothesis added on a geom
1449 # @param geom is subhape of mesh geometry
1450 def GetHypothesisList(self, geom):
1451 return self.mesh.GetHypothesisList( geom )
1453 ## Removes all global hypotheses
1454 def RemoveGlobalHypotheses(self):
1455 current_hyps = self.mesh.GetHypothesisList( self.geom )
1456 for hyp in current_hyps:
1457 self.mesh.RemoveHypothesis( self.geom, hyp )
1461 ## Create a mesh group based on geometric object \a grp
1462 # and give a \a name, \n if this parameter is not defined
1463 # the name is the same as the geometric group name \n
1464 # Note: Works like GroupOnGeom().
1465 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1466 # @param name is the name of the mesh group
1467 # @return SMESH_GroupOnGeom
1468 def Group(self, grp, name=""):
1469 return self.GroupOnGeom(grp, name)
1471 ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1472 # Export the mesh in a file with the MED format and choice the \a version of MED format
1473 # @param f is the file name
1474 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1475 def ExportToMED(self, f, version, opt=0):
1476 self.mesh.ExportToMED(f, opt, version)
1478 ## Export the mesh in a file with the MED format
1479 # @param f is the file name
1480 # @param auto_groups boolean parameter for creating/not creating
1481 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1482 # the typical use is auto_groups=false.
1483 # @param version MED format version(MED_V2_1 or MED_V2_2)
1484 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1485 self.mesh.ExportToMED(f, auto_groups, version)
1487 ## Export the mesh in a file with the DAT format
1488 # @param f is the file name
1489 def ExportDAT(self, f):
1490 self.mesh.ExportDAT(f)
1492 ## Export the mesh in a file with the UNV format
1493 # @param f is the file name
1494 def ExportUNV(self, f):
1495 self.mesh.ExportUNV(f)
1497 ## Export the mesh in a file with the STL format
1498 # @param f is the file name
1499 # @param ascii defined the kind of file contents
1500 def ExportSTL(self, f, ascii=1):
1501 self.mesh.ExportSTL(f, ascii)
1504 # Operations with groups:
1505 # ----------------------
1507 ## Creates an empty mesh group
1508 # @param elementType is the type of elements in the group
1509 # @param name is the name of the mesh group
1510 # @return SMESH_Group
1511 def CreateEmptyGroup(self, elementType, name):
1512 return self.mesh.CreateGroup(elementType, name)
1514 ## Creates a mesh group based on geometric object \a grp
1515 # and give a \a name, \n if this parameter is not defined
1516 # the name is the same as the geometric group name
1517 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1518 # @param name is the name of the mesh group
1519 # @return SMESH_GroupOnGeom
1520 def GroupOnGeom(self, grp, name="", type=None):
1522 name = grp.GetName()
1525 tgeo = str(grp.GetShapeType())
1526 if tgeo == "VERTEX":
1528 elif tgeo == "EDGE":
1530 elif tgeo == "FACE":
1532 elif tgeo == "SOLID":
1534 elif tgeo == "SHELL":
1536 elif tgeo == "COMPOUND":
1537 if len( geompy.GetObjectIDs( grp )) == 0:
1538 print "Mesh.Group: empty geometric group", GetName( grp )
1540 tgeo = geompy.GetType(grp)
1541 if tgeo == geompy.ShapeType["VERTEX"]:
1543 elif tgeo == geompy.ShapeType["EDGE"]:
1545 elif tgeo == geompy.ShapeType["FACE"]:
1547 elif tgeo == geompy.ShapeType["SOLID"]:
1551 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1554 return self.mesh.CreateGroupFromGEOM(type, name, grp)
1556 ## Create a mesh group by the given ids of elements
1557 # @param groupName is the name of the mesh group
1558 # @param elementType is the type of elements in the group
1559 # @param elemIDs is the list of ids
1560 # @return SMESH_Group
1561 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1562 group = self.mesh.CreateGroup(elementType, groupName)
1566 ## Create a mesh group by the given conditions
1567 # @param groupName is the name of the mesh group
1568 # @param elementType is the type of elements in the group
1569 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1570 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1571 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
1572 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
1573 # @return SMESH_Group
1577 CritType=FT_Undefined,
1580 UnaryOp=FT_Undefined):
1581 aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1582 group = self.MakeGroupByCriterion(groupName, aCriterion)
1585 ## Create a mesh group by the given criterion
1586 # @param groupName is the name of the mesh group
1587 # @param Criterion is the instance of Criterion class
1588 # @return SMESH_Group
1589 def MakeGroupByCriterion(self, groupName, Criterion):
1590 aFilterMgr = smesh.CreateFilterManager()
1591 aFilter = aFilterMgr.CreateFilter()
1593 aCriteria.append(Criterion)
1594 aFilter.SetCriteria(aCriteria)
1595 group = self.MakeGroupByFilter(groupName, aFilter)
1598 ## Create a mesh group by the given criteria(list of criterions)
1599 # @param groupName is the name of the mesh group
1600 # @param Criteria is the list of criterions
1601 # @return SMESH_Group
1602 def MakeGroupByCriteria(self, groupName, theCriteria):
1603 aFilterMgr = smesh.CreateFilterManager()
1604 aFilter = aFilterMgr.CreateFilter()
1605 aFilter.SetCriteria(theCriteria)
1606 group = self.MakeGroupByFilter(groupName, aFilter)
1609 ## Create a mesh group by the given filter
1610 # @param groupName is the name of the mesh group
1611 # @param Criterion is the instance of Filter class
1612 # @return SMESH_Group
1613 def MakeGroupByFilter(self, groupName, theFilter):
1614 anIds = theFilter.GetElementsId(self.mesh)
1615 anElemType = theFilter.GetElementType()
1616 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1619 ## Pass mesh elements through the given filter and return ids
1620 # @param theFilter is SMESH_Filter
1621 # @return list of ids
1622 def GetIdsFromFilter(self, theFilter):
1623 return theFilter.GetElementsId(self.mesh)
1625 ## Verify whether 2D mesh element has free edges(edges connected to one face only)\n
1626 # Returns list of special structures(borders).
1627 # @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
1628 def GetFreeBorders(self):
1629 aFilterMgr = smesh.CreateFilterManager()
1630 aPredicate = aFilterMgr.CreateFreeEdges()
1631 aPredicate.SetMesh(self.mesh)
1632 aBorders = aPredicate.GetBorders()
1636 def RemoveGroup(self, group):
1637 self.mesh.RemoveGroup(group)
1639 ## Remove group with its contents
1640 def RemoveGroupWithContents(self, group):
1641 self.mesh.RemoveGroupWithContents(group)
1643 ## Get the list of groups existing in the mesh
1644 def GetGroups(self):
1645 return self.mesh.GetGroups()
1647 ## Get the list of names of groups existing in the mesh
1648 def GetGroupNames(self):
1649 groups = self.GetGroups()
1651 for group in groups:
1652 names.append(group.GetName())
1655 ## Union of two groups
1656 # New group is created. All mesh elements that are
1657 # present in initial groups are added to the new one
1658 def UnionGroups(self, group1, group2, name):
1659 return self.mesh.UnionGroups(group1, group2, name)
1661 ## Intersection of two groups
1662 # New group is created. All mesh elements that are
1663 # present in both initial groups are added to the new one.
1664 def IntersectGroups(self, group1, group2, name):
1665 return self.mesh.IntersectGroups(group1, group2, name)
1667 ## Cut of two groups
1668 # New group is created. All mesh elements that are present in
1669 # main group but do not present in tool group are added to the new one
1670 def CutGroups(self, mainGroup, toolGroup, name):
1671 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1674 # Get some info about mesh:
1675 # ------------------------
1677 ## Get the log of nodes and elements added or removed since previous
1679 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1680 # @return list of log_block structures:
1685 def GetLog(self, clearAfterGet):
1686 return self.mesh.GetLog(clearAfterGet)
1688 ## Clear the log of nodes and elements added or removed since previous
1689 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1691 self.mesh.ClearLog()
1693 ## Get the internal Id
1695 return self.mesh.GetId()
1698 def GetStudyId(self):
1699 return self.mesh.GetStudyId()
1701 ## Check group names for duplications.
1702 # Consider maximum group name length stored in MED file.
1703 def HasDuplicatedGroupNamesMED(self):
1704 return self.mesh.GetStudyId()
1706 ## Obtain instance of SMESH_MeshEditor
1707 def GetMeshEditor(self):
1708 return self.mesh.GetMeshEditor()
1711 def GetMEDMesh(self):
1712 return self.mesh.GetMEDMesh()
1715 # Get informations about mesh contents:
1716 # ------------------------------------
1718 ## Returns number of nodes in mesh
1720 return self.mesh.NbNodes()
1722 ## Returns number of elements in mesh
1723 def NbElements(self):
1724 return self.mesh.NbElements()
1726 ## Returns number of edges in mesh
1728 return self.mesh.NbEdges()
1730 ## Returns number of edges with given order in mesh
1731 # @param elementOrder is order of elements:
1732 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1733 def NbEdgesOfOrder(self, elementOrder):
1734 return self.mesh.NbEdgesOfOrder(elementOrder)
1736 ## Returns number of faces in mesh
1738 return self.mesh.NbFaces()
1740 ## Returns number of faces with given order in mesh
1741 # @param elementOrder is order of elements:
1742 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1743 def NbFacesOfOrder(self, elementOrder):
1744 return self.mesh.NbFacesOfOrder(elementOrder)
1746 ## Returns number of triangles in mesh
1747 def NbTriangles(self):
1748 return self.mesh.NbTriangles()
1750 ## Returns number of triangles with given order in mesh
1751 # @param elementOrder is order of elements:
1752 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1753 def NbTrianglesOfOrder(self, elementOrder):
1754 return self.mesh.NbTrianglesOfOrder(elementOrder)
1756 ## Returns number of quadrangles in mesh
1757 def NbQuadrangles(self):
1758 return self.mesh.NbQuadrangles()
1760 ## Returns number of quadrangles with given order in mesh
1761 # @param elementOrder is order of elements:
1762 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1763 def NbQuadranglesOfOrder(self, elementOrder):
1764 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1766 ## Returns number of polygons in mesh
1767 def NbPolygons(self):
1768 return self.mesh.NbPolygons()
1770 ## Returns number of volumes in mesh
1771 def NbVolumes(self):
1772 return self.mesh.NbVolumes()
1774 ## Returns number of volumes with given order in mesh
1775 # @param elementOrder is order of elements:
1776 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1777 def NbVolumesOfOrder(self, elementOrder):
1778 return self.mesh.NbVolumesOfOrder(elementOrder)
1780 ## Returns number of tetrahedrons in mesh
1782 return self.mesh.NbTetras()
1784 ## Returns number of tetrahedrons with given order in mesh
1785 # @param elementOrder is order of elements:
1786 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1787 def NbTetrasOfOrder(self, elementOrder):
1788 return self.mesh.NbTetrasOfOrder(elementOrder)
1790 ## Returns number of hexahedrons in mesh
1792 return self.mesh.NbHexas()
1794 ## Returns number of hexahedrons with given order in mesh
1795 # @param elementOrder is order of elements:
1796 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1797 def NbHexasOfOrder(self, elementOrder):
1798 return self.mesh.NbHexasOfOrder(elementOrder)
1800 ## Returns number of pyramids in mesh
1801 def NbPyramids(self):
1802 return self.mesh.NbPyramids()
1804 ## Returns number of pyramids with given order in mesh
1805 # @param elementOrder is order of elements:
1806 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1807 def NbPyramidsOfOrder(self, elementOrder):
1808 return self.mesh.NbPyramidsOfOrder(elementOrder)
1810 ## Returns number of prisms in mesh
1812 return self.mesh.NbPrisms()
1814 ## Returns number of prisms with given order in mesh
1815 # @param elementOrder is order of elements:
1816 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1817 def NbPrismsOfOrder(self, elementOrder):
1818 return self.mesh.NbPrismsOfOrder(elementOrder)
1820 ## Returns number of polyhedrons in mesh
1821 def NbPolyhedrons(self):
1822 return self.mesh.NbPolyhedrons()
1824 ## Returns number of submeshes in mesh
1825 def NbSubMesh(self):
1826 return self.mesh.NbSubMesh()
1828 ## Returns list of mesh elements ids
1829 def GetElementsId(self):
1830 return self.mesh.GetElementsId()
1832 ## Returns list of ids of mesh elements with given type
1833 # @param elementType is required type of elements
1834 def GetElementsByType(self, elementType):
1835 return self.mesh.GetElementsByType(elementType)
1837 ## Returns list of mesh nodes ids
1838 def GetNodesId(self):
1839 return self.mesh.GetNodesId()
1841 # Get informations about mesh elements:
1842 # ------------------------------------
1844 ## Returns type of mesh element
1845 def GetElementType(self, id, iselem):
1846 return self.mesh.GetElementType(id, iselem)
1848 ## Returns list of submesh elements ids
1849 # @param shapeID is geom object(subshape) IOR
1850 def GetSubMeshElementsId(self, shapeID):
1851 return self.mesh.GetSubMeshElementsId(shapeID)
1853 ## Returns list of submesh nodes ids
1854 # @param shapeID is geom object(subshape) IOR
1855 def GetSubMeshNodesId(self, shapeID, all):
1856 return self.mesh.GetSubMeshNodesId(shapeID, all)
1858 ## Returns list of ids of submesh elements with given type
1859 # @param shapeID is geom object(subshape) IOR
1860 def GetSubMeshElementType(self, shapeID):
1861 return self.mesh.GetSubMeshElementType(shapeID)
1863 ## Get mesh description
1865 return self.mesh.Dump()
1868 # Get information about nodes and elements of mesh by its ids:
1869 # -----------------------------------------------------------
1871 ## Get XYZ coordinates of node as list of double
1872 # \n If there is not node for given ID - returns empty list
1873 def GetNodeXYZ(self, id):
1874 return self.mesh.GetNodeXYZ(id)
1876 ## For given node returns list of IDs of inverse elements
1877 # \n If there is not node for given ID - returns empty list
1878 def GetNodeInverseElements(self, id):
1879 return self.mesh.GetNodeInverseElements(id)
1881 ## If given element is node returns IDs of shape from position
1882 # \n If there is not node for given ID - returns -1
1883 def GetShapeID(self, id):
1884 return self.mesh.GetShapeID(id)
1886 ## For given element returns ID of result shape after
1887 # FindShape() from SMESH_MeshEditor
1888 # \n If there is not element for given ID - returns -1
1889 def GetShapeIDForElem(id):
1890 return self.mesh.GetShapeIDForElem(id)
1892 ## Returns number of nodes for given element
1893 # \n If there is not element for given ID - returns -1
1894 def GetElemNbNodes(self, id):
1895 return self.mesh.GetElemNbNodes(id)
1897 ## Returns ID of node by given index for given element
1898 # \n If there is not element for given ID - returns -1
1899 # \n If there is not node for given index - returns -2
1900 def GetElemNode(self, id, index):
1901 return self.mesh.GetElemNode(id, index)
1903 ## Returns true if given node is medium node
1904 # in given quadratic element
1905 def IsMediumNode(self, elementID, nodeID):
1906 return self.mesh.IsMediumNode(elementID, nodeID)
1908 ## Returns true if given node is medium node
1909 # in one of quadratic elements
1910 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1911 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1913 ## Returns number of edges for given element
1914 def ElemNbEdges(self, id):
1915 return self.mesh.ElemNbEdges(id)
1917 ## Returns number of faces for given element
1918 def ElemNbFaces(self, id):
1919 return self.mesh.ElemNbFaces(id)
1921 ## Returns true if given element is polygon
1922 def IsPoly(self, id):
1923 return self.mesh.IsPoly(id)
1925 ## Returns true if given element is quadratic
1926 def IsQuadratic(self, id):
1927 return self.mesh.IsQuadratic(id)
1929 ## Returns XYZ coordinates of bary center for given element
1931 # \n If there is not element for given ID - returns empty list
1932 def BaryCenter(self, id):
1933 return self.mesh.BaryCenter(id)
1936 # Mesh edition (SMESH_MeshEditor functionality):
1937 # ---------------------------------------------
1939 ## Removes elements from mesh by ids
1940 # @param IDsOfElements is list of ids of elements to remove
1941 def RemoveElements(self, IDsOfElements):
1942 return self.editor.RemoveElements(IDsOfElements)
1944 ## Removes nodes from mesh by ids
1945 # @param IDsOfNodes is list of ids of nodes to remove
1946 def RemoveNodes(self, IDsOfNodes):
1947 return self.editor.RemoveNodes(IDsOfNodes)
1949 ## Add node to mesh by coordinates
1950 def AddNode(self, x, y, z):
1951 return self.editor.AddNode( x, y, z)
1954 ## Create edge both similar and quadratic (this is determed
1955 # by number of given nodes).
1956 # @param IdsOfNodes List of node IDs for creation of element.
1957 # Needed order of nodes in this list corresponds to description
1958 # of MED. \n This description is located by the following link:
1959 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1960 def AddEdge(self, IDsOfNodes):
1961 return self.editor.AddEdge(IDsOfNodes)
1963 ## Create face both similar and quadratic (this is determed
1964 # by number of given nodes).
1965 # @param IdsOfNodes List of node IDs for creation of element.
1966 # Needed order of nodes in this list corresponds to description
1967 # of MED. \n This description is located by the following link:
1968 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1969 def AddFace(self, IDsOfNodes):
1970 return self.editor.AddFace(IDsOfNodes)
1972 ## Add polygonal face to mesh by list of nodes ids
1973 def AddPolygonalFace(self, IdsOfNodes):
1974 return self.editor.AddPolygonalFace(IdsOfNodes)
1976 ## Create volume both similar and quadratic (this is determed
1977 # by number of given nodes).
1978 # @param IdsOfNodes List of node IDs for creation of element.
1979 # Needed order of nodes in this list corresponds to description
1980 # of MED. \n This description is located by the following link:
1981 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1982 def AddVolume(self, IDsOfNodes):
1983 return self.editor.AddVolume(IDsOfNodes)
1985 ## Create volume of many faces, giving nodes for each face.
1986 # @param IdsOfNodes List of node IDs for volume creation face by face.
1987 # @param Quantities List of integer values, Quantities[i]
1988 # gives quantity of nodes in face number i.
1989 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1990 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1992 ## Create volume of many faces, giving IDs of existing faces.
1993 # @param IdsOfFaces List of face IDs for volume creation.
1995 # Note: The created volume will refer only to nodes
1996 # of the given faces, not to the faces itself.
1997 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1998 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2000 ## Move node with given id
2001 # @param NodeID id of the node
2002 # @param x new X coordinate
2003 # @param y new Y coordinate
2004 # @param z new Z coordinate
2005 def MoveNode(self, NodeID, x, y, z):
2006 return self.editor.MoveNode(NodeID, x, y, z)
2008 ## Find a node closest to a point
2009 # @param x X coordinate of a point
2010 # @param y Y coordinate of a point
2011 # @param z Z coordinate of a point
2012 # @return id of a node
2013 def FindNodeClosestTo(self, x, y, z):
2014 preview = self.mesh.GetMeshEditPreviewer()
2015 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2017 ## Find a node closest to a point and move it to a point location
2018 # @param x X coordinate of a point
2019 # @param y Y coordinate of a point
2020 # @param z Z coordinate of a point
2021 # @return id of a moved node
2022 def MeshToPassThroughAPoint(self, x, y, z):
2023 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2025 ## Replace two neighbour triangles sharing Node1-Node2 link
2026 # with ones built on the same 4 nodes but having other common link.
2027 # @param NodeID1 first node id
2028 # @param NodeID2 second node id
2029 # @return false if proper faces not found
2030 def InverseDiag(self, NodeID1, NodeID2):
2031 return self.editor.InverseDiag(NodeID1, NodeID2)
2033 ## Replace two neighbour triangles sharing Node1-Node2 link
2034 # with a quadrangle built on the same 4 nodes.
2035 # @param NodeID1 first node id
2036 # @param NodeID2 second node id
2037 # @return false if proper faces not found
2038 def DeleteDiag(self, NodeID1, NodeID2):
2039 return self.editor.DeleteDiag(NodeID1, NodeID2)
2041 ## Reorient elements by ids
2042 # @param IDsOfElements if undefined reorient all mesh elements
2043 def Reorient(self, IDsOfElements=None):
2044 if IDsOfElements == None:
2045 IDsOfElements = self.GetElementsId()
2046 return self.editor.Reorient(IDsOfElements)
2048 ## Reorient all elements of the object
2049 # @param theObject is mesh, submesh or group
2050 def ReorientObject(self, theObject):
2051 return self.editor.ReorientObject(theObject)
2053 ## Fuse neighbour triangles into quadrangles.
2054 # @param IDsOfElements The triangles to be fused,
2055 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2056 # @param MaxAngle is a max angle between element normals at which fusion
2057 # is still performed; theMaxAngle is mesured in radians.
2058 # @return TRUE in case of success, FALSE otherwise.
2059 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2060 if IDsOfElements == []:
2061 IDsOfElements = self.GetElementsId()
2062 return self.editor.TriToQuad(IDsOfElements, GetFunctor(theCriterion), MaxAngle)
2064 ## Fuse neighbour triangles of the object into quadrangles
2065 # @param theObject is mesh, submesh or group
2066 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2067 # @param MaxAngle is a max angle between element normals at which fusion
2068 # is still performed; theMaxAngle is mesured in radians.
2069 # @return TRUE in case of success, FALSE otherwise.
2070 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2071 return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
2073 ## Split quadrangles into triangles.
2074 # @param IDsOfElements the faces to be splitted.
2075 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2076 # @param @return TRUE in case of success, FALSE otherwise.
2077 def QuadToTri (self, IDsOfElements, theCriterion):
2078 if IDsOfElements == []:
2079 IDsOfElements = self.GetElementsId()
2080 return self.editor.QuadToTri(IDsOfElements, GetFunctor(theCriterion))
2082 ## Split quadrangles into triangles.
2083 # @param theObject object to taking list of elements from, is mesh, submesh or group
2084 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2085 def QuadToTriObject (self, theObject, theCriterion):
2086 return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
2088 ## Split quadrangles into triangles.
2089 # @param theElems The faces to be splitted
2090 # @param the13Diag is used to choose a diagonal for splitting.
2091 # @return TRUE in case of success, FALSE otherwise.
2092 def SplitQuad (self, IDsOfElements, Diag13):
2093 if IDsOfElements == []:
2094 IDsOfElements = self.GetElementsId()
2095 return self.editor.SplitQuad(IDsOfElements, Diag13)
2097 ## Split quadrangles into triangles.
2098 # @param theObject is object to taking list of elements from, is mesh, submesh or group
2099 def SplitQuadObject (self, theObject, Diag13):
2100 return self.editor.SplitQuadObject(theObject, Diag13)
2102 ## Find better splitting of the given quadrangle.
2103 # @param IDOfQuad ID of the quadrangle to be splitted.
2104 # @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
2105 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2106 # diagonal is better, 0 if error occurs.
2107 def BestSplit (self, IDOfQuad, theCriterion):
2108 return self.editor.BestSplit(IDOfQuad, GetFunctor(theCriterion))
2110 ## Split quafrangle faces near triangular facets of volumes
2112 def SplitQuadsNearTriangularFacets(self):
2113 faces_array = self.GetElementsByType(SMESH.FACE)
2114 for face_id in faces_array:
2115 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2116 quad_nodes = self.mesh.GetElemNodes(face_id)
2117 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2118 isVolumeFound = False
2119 for node1_elem in node1_elems:
2120 if not isVolumeFound:
2121 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2122 nb_nodes = self.GetElemNbNodes(node1_elem)
2123 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2124 volume_elem = node1_elem
2125 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2126 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2127 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2128 isVolumeFound = True
2129 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2130 self.SplitQuad([face_id], False) # diagonal 2-4
2131 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2132 isVolumeFound = True
2133 self.SplitQuad([face_id], True) # diagonal 1-3
2134 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2135 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2136 isVolumeFound = True
2137 self.SplitQuad([face_id], True) # diagonal 1-3
2139 ## @brief Split hexahedrons into tetrahedrons.
2141 # Use pattern mapping functionality for splitting.
2142 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2143 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2144 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2145 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2146 # key-point will be mapped into <theNode001>-th node of each volume.
2147 # The (0,0,0) key-point of used pattern corresponds to not split corner.
2148 # @return TRUE in case of success, FALSE otherwise.
2149 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2150 # Pattern: 5.---------.6
2155 # (0,0,1) 4.---------.7 * |
2162 # (0,0,0) 0.---------.3
2163 pattern_tetra = "!!! Nb of points: \n 8 \n\
2173 !!! Indices of points of 6 tetras: \n\
2181 pattern = GetPattern()
2182 isDone = pattern.LoadFromFile(pattern_tetra)
2184 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2187 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2188 isDone = pattern.MakeMesh(self.mesh, False, False)
2189 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2191 # split quafrangle faces near triangular facets of volumes
2192 self.SplitQuadsNearTriangularFacets()
2196 ## @brief Split hexahedrons into prisms.
2198 # Use pattern mapping functionality for splitting.
2199 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2200 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2201 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2202 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2203 # key-point will be mapped into <theNode001>-th node of each volume.
2204 # The edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2205 # @param @return TRUE in case of success, FALSE otherwise.
2206 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2207 # Pattern: 5.---------.6
2212 # (0,0,1) 4.---------.7 |
2219 # (0,0,0) 0.---------.3
2220 pattern_prism = "!!! Nb of points: \n 8 \n\
2230 !!! Indices of points of 2 prisms: \n\
2234 pattern = GetPattern()
2235 isDone = pattern.LoadFromFile(pattern_prism)
2237 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2240 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2241 isDone = pattern.MakeMesh(self.mesh, False, False)
2242 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2244 # split quafrangle faces near triangular facets of volumes
2245 self.SplitQuadsNearTriangularFacets()
2250 # @param IDsOfElements list if ids of elements to smooth
2251 # @param IDsOfFixedNodes list of ids of fixed nodes.
2252 # Note that nodes built on edges and boundary nodes are always fixed.
2253 # @param MaxNbOfIterations maximum number of iterations
2254 # @param MaxAspectRatio varies in range [1.0, inf]
2255 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2256 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2257 MaxNbOfIterations, MaxAspectRatio, Method):
2258 if IDsOfElements == []:
2259 IDsOfElements = self.GetElementsId()
2260 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2261 MaxNbOfIterations, MaxAspectRatio, Method)
2263 ## Smooth elements belong to given object
2264 # @param theObject object to smooth
2265 # @param IDsOfFixedNodes list of ids of fixed nodes.
2266 # Note that nodes built on edges and boundary nodes are always fixed.
2267 # @param MaxNbOfIterations maximum number of iterations
2268 # @param MaxAspectRatio varies in range [1.0, inf]
2269 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2270 def SmoothObject(self, theObject, IDsOfFixedNodes,
2271 MaxNbOfIterations, MaxxAspectRatio, Method):
2272 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2273 MaxNbOfIterations, MaxxAspectRatio, Method)
2275 ## Parametric smooth the given elements
2276 # @param IDsOfElements list if ids of elements to smooth
2277 # @param IDsOfFixedNodes list of ids of fixed nodes.
2278 # Note that nodes built on edges and boundary nodes are always fixed.
2279 # @param MaxNbOfIterations maximum number of iterations
2280 # @param MaxAspectRatio varies in range [1.0, inf]
2281 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2282 def SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2283 MaxNbOfIterations, MaxAspectRatio, Method):
2284 if IDsOfElements == []:
2285 IDsOfElements = self.GetElementsId()
2286 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2287 MaxNbOfIterations, MaxAspectRatio, Method)
2289 ## Parametric smooth elements belong to given object
2290 # @param theObject object to smooth
2291 # @param IDsOfFixedNodes list of ids of fixed nodes.
2292 # Note that nodes built on edges and boundary nodes are always fixed.
2293 # @param MaxNbOfIterations maximum number of iterations
2294 # @param MaxAspectRatio varies in range [1.0, inf]
2295 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2296 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2297 MaxNbOfIterations, MaxAspectRatio, Method):
2298 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2299 MaxNbOfIterations, MaxAspectRatio, Method)
2301 ## Converts all mesh to quadratic one, deletes old elements, replacing
2302 # them with quadratic ones with the same id.
2303 def ConvertToQuadratic(self, theForce3d):
2304 self.editor.ConvertToQuadratic(theForce3d)
2306 ## Converts all mesh from quadratic to ordinary ones,
2307 # deletes old quadratic elements, \n replacing
2308 # them with ordinary mesh elements with the same id.
2309 def ConvertFromQuadratic(self):
2310 return self.editor.ConvertFromQuadratic()
2312 ## Renumber mesh nodes
2313 def RenumberNodes(self):
2314 self.editor.RenumberNodes()
2316 ## Renumber mesh elements
2317 def RenumberElements(self):
2318 self.editor.RenumberElements()
2320 ## Generate new elements by rotation of the elements around the axis
2321 # @param IDsOfElements list of ids of elements to sweep
2322 # @param Axix axis of rotation, AxisStruct or line(geom object)
2323 # @param AngleInRadians angle of Rotation
2324 # @param NbOfSteps number of steps
2325 # @param Tolerance tolerance
2326 def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
2327 if IDsOfElements == []:
2328 IDsOfElements = self.GetElementsId()
2329 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2330 Axix = GetAxisStruct(Axix)
2331 self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
2333 ## Generate new elements by rotation of the elements of object around the axis
2334 # @param theObject object wich elements should be sweeped
2335 # @param Axix axis of rotation, AxisStruct or line(geom object)
2336 # @param AngleInRadians angle of Rotation
2337 # @param NbOfSteps number of steps
2338 # @param Tolerance tolerance
2339 def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
2340 if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2341 Axix = GetAxisStruct(Axix)
2342 self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
2344 ## Generate new elements by extrusion of the elements with given ids
2345 # @param IDsOfElements list of elements ids for extrusion
2346 # @param StepVector vector, defining the direction and value of extrusion
2347 # @param NbOfSteps the number of steps
2348 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
2349 if IDsOfElements == []:
2350 IDsOfElements = self.GetElementsId()
2351 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2352 StepVector = GetDirStruct(StepVector)
2353 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2355 ## Generate new elements by extrusion of the elements with given ids
2356 # @param IDsOfElements is ids of elements
2357 # @param StepVector vector, defining the direction and value of extrusion
2358 # @param NbOfSteps the number of steps
2359 # @param ExtrFlags set flags for performing extrusion
2360 # @param SewTolerance uses for comparing locations of nodes if flag
2361 # EXTRUSION_FLAG_SEW is set
2362 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
2363 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2364 StepVector = GetDirStruct(StepVector)
2365 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
2367 ## Generate new elements by extrusion of the elements belong to object
2368 # @param theObject object wich elements should be processed
2369 # @param StepVector vector, defining the direction and value of extrusion
2370 # @param NbOfSteps the number of steps
2371 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
2372 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2373 StepVector = GetDirStruct(StepVector)
2374 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2376 ## Generate new elements by extrusion of the elements belong to object
2377 # @param theObject object wich elements should be processed
2378 # @param StepVector vector, defining the direction and value of extrusion
2379 # @param NbOfSteps the number of steps
2380 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
2381 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2382 StepVector = GetDirStruct(StepVector)
2383 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2385 ## Generate new elements by extrusion of the elements belong to object
2386 # @param theObject object wich elements should be processed
2387 # @param StepVector vector, defining the direction and value of extrusion
2388 # @param NbOfSteps the number of steps
2389 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
2390 if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2391 StepVector = GetDirStruct(StepVector)
2392 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2394 ## Generate new elements by extrusion of the given elements
2395 # A path of extrusion must be a meshed edge.
2396 # @param IDsOfElements is ids of elements
2397 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2398 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2399 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2400 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2401 # @param Angles list of angles
2402 # @param HasRefPoint allows to use base point
2403 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2404 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2405 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2406 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2407 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
2408 if IDsOfElements == []:
2409 IDsOfElements = self.GetElementsId()
2410 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2411 RefPoint = GetPointStruct(RefPoint)
2413 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
2414 HasAngles, Angles, HasRefPoint, RefPoint)
2416 ## Generate new elements by extrusion of the elements belong to object
2417 # A path of extrusion must be a meshed edge.
2418 # @param IDsOfElements is ids of elements
2419 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2420 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2421 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2422 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2423 # @param Angles list of angles
2424 # @param HasRefPoint allows to use base point
2425 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2426 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2427 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2428 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2429 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
2430 if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2431 RefPoint = GetPointStruct(RefPoint)
2432 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
2433 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation)
2435 ## Symmetrical copy of mesh elements
2436 # @param IDsOfElements list of elements ids
2437 # @param Mirror is AxisStruct or geom object(point, line, plane)
2438 # @param theMirrorType is POINT, AXIS or PLANE
2439 # If the Mirror is geom object this parameter is unnecessary
2440 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2441 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
2442 if IDsOfElements == []:
2443 IDsOfElements = self.GetElementsId()
2444 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2445 Mirror = GetAxisStruct(Mirror)
2446 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2448 ## Symmetrical copy of object
2449 # @param theObject mesh, submesh or group
2450 # @param Mirror is AxisStruct or geom object(point, line, plane)
2451 # @param theMirrorType is POINT, AXIS or PLANE
2452 # If the Mirror is geom object this parameter is unnecessary
2453 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2454 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
2455 if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2456 Mirror = GetAxisStruct(Mirror)
2457 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2459 ## Translates the elements
2460 # @param IDsOfElements list of elements ids
2461 # @param Vector direction of translation(DirStruct or vector)
2462 # @param Copy allows to copy the translated elements
2463 def Translate(self, IDsOfElements, Vector, Copy):
2464 if IDsOfElements == []:
2465 IDsOfElements = self.GetElementsId()
2466 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2467 Vector = GetDirStruct(Vector)
2468 self.editor.Translate(IDsOfElements, Vector, Copy)
2470 ## Translates the object
2471 # @param theObject object to translate(mesh, submesh, or group)
2472 # @param Vector direction of translation(DirStruct or geom vector)
2473 # @param Copy allows to copy the translated elements
2474 def TranslateObject(self, theObject, Vector, Copy):
2475 if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2476 Vector = GetDirStruct(Vector)
2477 self.editor.TranslateObject(theObject, Vector, Copy)
2479 ## Rotates the elements
2480 # @param IDsOfElements list of elements ids
2481 # @param Axis axis of rotation(AxisStruct or geom line)
2482 # @param AngleInRadians angle of rotation(in radians)
2483 # @param Copy allows to copy the rotated elements
2484 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
2485 if IDsOfElements == []:
2486 IDsOfElements = self.GetElementsId()
2487 if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
2488 Axis = GetAxisStruct(Axis)
2489 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2491 ## Rotates the object
2492 # @param theObject object to rotate(mesh, submesh, or group)
2493 # @param Axis axis of rotation(AxisStruct or geom line)
2494 # @param AngleInRadians angle of rotation(in radians)
2495 # @param Copy allows to copy the rotated elements
2496 def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
2497 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2499 ## Find group of nodes close to each other within Tolerance.
2500 # @param Tolerance tolerance value
2501 # @param list of group of nodes
2502 def FindCoincidentNodes (self, Tolerance):
2503 return self.editor.FindCoincidentNodes(Tolerance)
2505 ## Find group of nodes close to each other within Tolerance.
2506 # @param Tolerance tolerance value
2507 # @param SubMeshOrGroup SubMesh or Group
2508 # @param list of group of nodes
2509 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2510 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2513 # @param list of group of nodes
2514 def MergeNodes (self, GroupsOfNodes):
2515 self.editor.MergeNodes(GroupsOfNodes)
2517 ## Find elements built on the same nodes.
2518 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2519 # @return a list of groups of equal elements
2520 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2521 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2523 ## Merge elements in each given group.
2524 # @param GroupsOfElementsID groups of elements for merging
2525 def MergeElements(self, GroupsOfElementsID):
2526 self.editor.MergeElements(GroupsOfElementsID)
2528 ## Remove all but one of elements built on the same nodes.
2529 def MergeEqualElements(self):
2530 self.editor.MergeEqualElements()
2533 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2534 FirstNodeID2, SecondNodeID2, LastNodeID2,
2535 CreatePolygons, CreatePolyedrs):
2536 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2537 FirstNodeID2, SecondNodeID2, LastNodeID2,
2538 CreatePolygons, CreatePolyedrs)
2540 ## Sew conform free borders
2541 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2542 FirstNodeID2, SecondNodeID2):
2543 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2544 FirstNodeID2, SecondNodeID2)
2546 ## Sew border to side
2547 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2548 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2549 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2550 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2552 ## Sew two sides of a mesh. Nodes belonging to Side1 are
2553 # merged with nodes of elements of Side2.
2554 # Number of elements in theSide1 and in theSide2 must be
2555 # equal and they should have similar node connectivity.
2556 # The nodes to merge should belong to sides borders and
2557 # the first node should be linked to the second.
2558 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2559 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2560 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2561 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2562 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2563 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2565 ## Set new nodes for given element.
2566 # @param ide the element id
2567 # @param newIDs nodes ids
2568 # @return If number of nodes is not corresponded to type of element - returns false
2569 def ChangeElemNodes(self, ide, newIDs):
2570 return self.editor.ChangeElemNodes(ide, newIDs)
2572 ## If during last operation of MeshEditor some nodes were
2573 # created this method returns list of it's IDs, \n
2574 # if new nodes not created - returns empty list
2575 def GetLastCreatedNodes(self):
2576 return self.editor.GetLastCreatedNodes()
2578 ## If during last operation of MeshEditor some elements were
2579 # created this method returns list of it's IDs, \n
2580 # if new elements not creared - returns empty list
2581 def GetLastCreatedElems(self):
2582 return self.editor.GetLastCreatedElems()