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
32 import SMESH # necessary for back compatibility
39 # import NETGENPlugin module if possible
58 NETGEN_1D2D3D = FULL_NETGEN
59 NETGEN_FULL = FULL_NETGEN
61 # MirrorType enumeration
62 POINT = SMESH_MeshEditor.POINT
63 AXIS = SMESH_MeshEditor.AXIS
64 PLANE = SMESH_MeshEditor.PLANE
66 # Smooth_Method enumeration
67 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
68 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
70 # Fineness enumeration(for NETGEN)
83 ior = salome.orb.object_to_string(obj)
84 sobj = salome.myStudy.FindObjectIOR(ior)
88 attr = sobj.FindAttribute("AttributeName")[1]
91 ## Sets name to object
92 def SetName(obj, name):
93 ior = salome.orb.object_to_string(obj)
94 sobj = salome.myStudy.FindObjectIOR(ior)
96 attr = sobj.FindAttribute("AttributeName")[1]
99 ## Print error message if a hypothesis was not assigned.
100 def TreatHypoStatus(status, hypName, geomName, isAlgo):
102 hypType = "algorithm"
104 hypType = "hypothesis"
106 if status == HYP_UNKNOWN_FATAL :
107 reason = "for unknown reason"
108 elif status == HYP_INCOMPATIBLE :
109 reason = "this hypothesis mismatches algorithm"
110 elif status == HYP_NOTCONFORM :
111 reason = "not conform mesh would be built"
112 elif status == HYP_ALREADY_EXIST :
113 reason = hypType + " of the same dimension already assigned to this shape"
114 elif status == HYP_BAD_DIM :
115 reason = hypType + " mismatches shape"
116 elif status == HYP_CONCURENT :
117 reason = "there are concurrent hypotheses on sub-shapes"
118 elif status == HYP_BAD_SUBSHAPE :
119 reason = "shape is neither the main one, nor its subshape, nor a valid group"
120 elif status == HYP_BAD_GEOMETRY:
121 reason = "geometry mismatches algorithm's expectation"
122 elif status == HYP_HIDDEN_ALGO:
123 reason = "it is hidden by an algorithm of upper dimension generating all-dimensions elements"
124 elif status == HYP_HIDING_ALGO:
125 reason = "it hides algorithm(s) of lower dimension by generating all-dimensions elements"
128 hypName = '"' + hypName + '"'
129 geomName= '"' + geomName+ '"'
130 if status < HYP_UNKNOWN_FATAL:
131 print hypName, "was assigned to", geomName,"but", reason
133 print hypName, "was not assigned to",geomName,":", reason
136 class smeshDC(SMESH._objref_SMESH_Gen):
138 def init_smesh(self,theStudy,geompyD):
140 self.SetGeomEngine(geompyD)
141 self.SetCurrentStudy(theStudy)
143 def Mesh(self, obj=0, name=0):
144 return Mesh(self,self.geompyD,obj,name)
146 ## Returns long value from enumeration
147 # Uses for SMESH.FunctorType enumeration
148 def EnumToLong(self,theItem):
151 ## Get PointStruct from vertex
152 # @param theVertex is GEOM object(vertex)
153 # @return SMESH.PointStruct
154 def GetPointStruct(self,theVertex):
155 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
156 return PointStruct(x,y,z)
158 ## Get DirStruct from vector
159 # @param theVector is GEOM object(vector)
160 # @return SMESH.DirStruct
161 def GetDirStruct(self,theVector):
162 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
163 if(len(vertices) != 2):
164 print "Error: vector object is incorrect."
166 p1 = self.geompyD.PointCoordinates(vertices[0])
167 p2 = self.geompyD.PointCoordinates(vertices[1])
168 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
169 dirst = DirStruct(pnt)
172 ## Make DirStruct from a triplet
173 # @param x,y,z are vector components
174 # @return SMESH.DirStruct
175 def MakeDirStruct(x,y,z):
176 pnt = PointStruct(x,y,z)
177 return DirStruct(pnt)
179 ## Get AxisStruct from object
180 # @param theObj is GEOM object(line or plane)
181 # @return SMESH.AxisStruct
182 def GetAxisStruct(self,theObj):
183 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
185 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
186 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
187 vertex1 = self.geompyD.PointCoordinates(vertex1)
188 vertex2 = self.geompyD.PointCoordinates(vertex2)
189 vertex3 = self.geompyD.PointCoordinates(vertex3)
190 vertex4 = self.geompyD.PointCoordinates(vertex4)
191 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
192 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
193 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] ]
194 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
196 elif len(edges) == 1:
197 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
198 p1 = self.geompyD.PointCoordinates( vertex1 )
199 p2 = self.geompyD.PointCoordinates( vertex2 )
200 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
204 # From SMESH_Gen interface:
205 # ------------------------
207 ## Set the current mode
208 def SetEmbeddedMode( self,theMode ):
209 #self.SetEmbeddedMode(theMode)
210 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
212 ## Get the current mode
213 def IsEmbeddedMode(self):
214 #return self.IsEmbeddedMode()
215 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
217 ## Set the current study
218 def SetCurrentStudy( self, theStudy ):
219 #self.SetCurrentStudy(theStudy)
220 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
222 ## Get the current study
223 def GetCurrentStudy(self):
224 #return self.GetCurrentStudy()
225 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
227 ## Create Mesh object importing data from given UNV file
228 # @return an instance of Mesh class
229 def CreateMeshesFromUNV( self,theFileName ):
230 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
231 aMesh = Mesh(self,self.geompyD,aSmeshMesh)
234 ## Create Mesh object(s) importing data from given MED file
235 # @return a list of Mesh class instances
236 def CreateMeshesFromMED( self,theFileName ):
237 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
239 for iMesh in range(len(aSmeshMeshes)) :
240 aMesh = Mesh(self,self.geompyD,aSmeshMeshes[iMesh])
241 aMeshes.append(aMesh)
242 return aMeshes, aStatus
244 ## Create Mesh object importing data from given STL file
245 # @return an instance of Mesh class
246 def CreateMeshesFromSTL( self, theFileName ):
247 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
248 aMesh = Mesh(self,self.geompyD,aSmeshMesh)
251 ## From SMESH_Gen interface
252 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
253 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
255 ## From SMESH_Gen interface. Creates pattern
256 def GetPattern(self):
257 return SMESH._objref_SMESH_Gen.GetPattern(self)
261 # Filtering. Auxiliary functions:
262 # ------------------------------
264 ## Creates an empty criterion
265 # @return SMESH.Filter.Criterion
266 def GetEmptyCriterion(self):
267 Type = self.EnumToLong(FT_Undefined)
268 Compare = self.EnumToLong(FT_Undefined)
272 UnaryOp = self.EnumToLong(FT_Undefined)
273 BinaryOp = self.EnumToLong(FT_Undefined)
276 Precision = -1 ##@1e-07
277 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
278 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
280 ## Creates a criterion by given parameters
281 # @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
282 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
283 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
284 # @param Treshold is threshold value (range of ids as string, shape, numeric)
285 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
286 # @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
287 # FT_Undefined(must be for the last criterion in criteria)
288 # @return SMESH.Filter.Criterion
289 def GetCriterion(self,elementType,
291 Compare = FT_EqualTo,
293 UnaryOp=FT_Undefined,
294 BinaryOp=FT_Undefined):
295 aCriterion = self.GetEmptyCriterion()
296 aCriterion.TypeOfElement = elementType
297 aCriterion.Type = self.EnumToLong(CritType)
301 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
302 aCriterion.Compare = self.EnumToLong(Compare)
303 elif Compare == "=" or Compare == "==":
304 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
306 aCriterion.Compare = self.EnumToLong(FT_LessThan)
308 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
310 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
313 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
314 FT_BelongToCylinder, FT_LyingOnGeom]:
316 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
317 aCriterion.ThresholdStr = GetName(aTreshold)
318 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
320 print "Error: Treshold should be a shape."
322 elif CritType == FT_RangeOfIds:
324 if isinstance(aTreshold, str):
325 aCriterion.ThresholdStr = aTreshold
327 print "Error: Treshold should be a string."
329 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
330 # Here we do not need treshold
331 if aTreshold == FT_LogicalNOT:
332 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
333 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
334 aCriterion.BinaryOp = aTreshold
338 aTreshold = float(aTreshold)
339 aCriterion.Threshold = aTreshold
341 print "Error: Treshold should be a number."
344 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
345 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
347 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
348 aCriterion.BinaryOp = self.EnumToLong(Treshold)
350 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
351 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
353 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
354 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
358 ## Creates filter by given parameters of criterion
359 # @param elementType is the type of elements in the group
360 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
361 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
362 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
363 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
364 # @return SMESH_Filter
365 def GetFilter(self,elementType,
366 CritType=FT_Undefined,
369 UnaryOp=FT_Undefined):
370 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
371 aFilterMgr = self.CreateFilterManager()
372 aFilter = aFilterMgr.CreateFilter()
374 aCriteria.append(aCriterion)
375 aFilter.SetCriteria(aCriteria)
378 ## Creates numerical functor by its type
379 # @param theCrierion is FT_...; functor type
380 # @return SMESH_NumericalFunctor
381 def GetFunctor(self,theCriterion):
382 aFilterMgr = self.CreateFilterManager()
383 if theCriterion == FT_AspectRatio:
384 return aFilterMgr.CreateAspectRatio()
385 elif theCriterion == FT_AspectRatio3D:
386 return aFilterMgr.CreateAspectRatio3D()
387 elif theCriterion == FT_Warping:
388 return aFilterMgr.CreateWarping()
389 elif theCriterion == FT_MinimumAngle:
390 return aFilterMgr.CreateMinimumAngle()
391 elif theCriterion == FT_Taper:
392 return aFilterMgr.CreateTaper()
393 elif theCriterion == FT_Skew:
394 return aFilterMgr.CreateSkew()
395 elif theCriterion == FT_Area:
396 return aFilterMgr.CreateArea()
397 elif theCriterion == FT_Volume3D:
398 return aFilterMgr.CreateVolume3D()
399 elif theCriterion == FT_MultiConnection:
400 return aFilterMgr.CreateMultiConnection()
401 elif theCriterion == FT_MultiConnection2D:
402 return aFilterMgr.CreateMultiConnection2D()
403 elif theCriterion == FT_Length:
404 return aFilterMgr.CreateLength()
405 elif theCriterion == FT_Length2D:
406 return aFilterMgr.CreateLength2D()
408 print "Error: given parameter is not numerucal functor type."
411 #Register the new proxy for SMESH_Gen
412 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
415 ## Mother class to define algorithm, recommended to do not use directly.
418 class Mesh_Algorithm:
419 # @class Mesh_Algorithm
420 # @brief Class Mesh_Algorithm
424 #def __init__(self,smesh):
432 #17908#def FindHypothesis(self,hypname, args):
433 #17908# key = "%s %s %s" % (self.__class__.__name__, hypname, args)
434 #17908# if Mesh_Algorithm.hypos.has_key( key ):
435 #17908# return Mesh_Algorithm.hypos[ key ]
438 ## If the algorithm is global, return 0; \n
439 # else return the submesh associated to this algorithm.
440 def GetSubMesh(self):
443 ## Return the wrapped mesher.
444 def GetAlgorithm(self):
447 ## Get list of hypothesis that can be used with this algorithm
448 def GetCompatibleHypothesis(self):
451 mylist = self.algo.GetCompatibleHypothesis()
459 def SetName(self, name):
460 SetName(self.algo, name)
464 return self.algo.GetId()
467 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
469 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
470 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
471 self.Assign(algo, mesh, geom)
475 def Assign(self, algo, mesh, geom):
477 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
486 name = mesh.geompyD.SubShapeName(geom, piece)
487 mesh.geompyD.addToStudyInFather(piece, geom, name)
488 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
491 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
492 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
495 def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so", UseExisting=0):
497 #17908#if UseExisting:
498 #17908# hypo = self.FindHypothesis(hyp, args)
499 #17908# if hypo: CreateNew = 0
502 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
503 key = "%s %s %s" % (self.__class__.__name__, hyp, args)
504 #17908#Mesh_Algorithm.hypos[key] = hypo
510 a = a + s + str(args[i])
513 name = GetName(self.geom)
514 #SetName(hypo, name + "/" + hyp + a) - NPAL16198
515 SetName(hypo, hyp + a)
517 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
518 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
522 # Public class: Mesh_Segment
523 # --------------------------
525 ## Class to define a segment 1D algorithm for discretization
528 class Mesh_Segment(Mesh_Algorithm):
530 #17908#algo = 0 # algorithm object common for all Mesh_Segments
532 ## Private constructor.
533 def __init__(self, mesh, geom=0):
534 Mesh_Algorithm.__init__(self)
536 #17908#if not Mesh_Segment.algo:
537 #17908# Mesh_Segment.algo = self.Create(mesh, geom, "Regular_1D")
539 #17908# self.Assign( Mesh_Segment.algo, mesh, geom)
541 self.Create(mesh, geom, "Regular_1D")
543 ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
544 # @param l for the length of segments that cut an edge
545 # @param UseExisting if ==true - search existing hypothesis created with
546 # same parameters, else (default) - create new
547 def LocalLength(self, l, UseExisting=0):
548 hyp = self.Hypothesis("LocalLength", [l], UseExisting=UseExisting)
552 ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
553 # @param n for the number of segments that cut an edge
554 # @param s for the scale factor (optional)
555 # @param UseExisting if ==true - search existing hypothesis created with
556 # same parameters, else (default) - create new
557 def NumberOfSegments(self, n, s=[], UseExisting=0):
559 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting)
561 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting)
562 hyp.SetDistrType( 1 )
563 hyp.SetScaleFactor(s)
564 hyp.SetNumberOfSegments(n)
567 ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
568 # @param start for the length of the first segment
569 # @param end for the length of the last segment
570 # @param UseExisting if ==true - search existing hypothesis created with
571 # same parameters, else (default) - create new
572 def Arithmetic1D(self, start, end, UseExisting=0):
573 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting)
574 hyp.SetLength(start, 1)
575 hyp.SetLength(end , 0)
578 ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
579 # @param start for the length of the first segment
580 # @param end for the length of the last segment
581 # @param UseExisting if ==true - search existing hypothesis created with
582 # same parameters, else (default) - create new
583 def StartEndLength(self, start, end, UseExisting=0):
584 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting)
585 hyp.SetLength(start, 1)
586 hyp.SetLength(end , 0)
589 ## Define "Deflection1D" hypothesis
590 # @param d for the deflection
591 # @param UseExisting if ==true - search existing hypothesis created with
592 # same parameters, else (default) - create new
593 def Deflection1D(self, d, UseExisting=0):
594 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting)
598 ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
599 # the opposite side in the case of quadrangular faces
600 def Propagation(self):
601 return self.Hypothesis("Propagation", UseExisting=1)
603 ## Define "AutomaticLength" hypothesis
604 # @param fineness for the fineness [0-1]
605 # @param UseExisting if ==true - search existing hypothesis created with
606 # same parameters, else (default) - create new
607 def AutomaticLength(self, fineness=0, UseExisting=0):
608 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting)
609 hyp.SetFineness( fineness )
612 ## Define "SegmentLengthAroundVertex" hypothesis
613 # @param length for the segment length
614 # @param vertex for the length localization: vertex index [0,1] | verext object
615 # @param UseExisting if ==true - search existing hypothesis created with
616 # same parameters, else (default) - create new
617 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
619 store_geom = self.geom
621 if type(vertex) is types.IntType:
622 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
626 hyp = self.Hypothesis("SegmentAroundVertex_0D",[length],UseExisting=UseExisting)
627 hyp = self.Hypothesis("SegmentLengthAroundVertex",[length],UseExisting=UseExisting)
628 self.geom = store_geom
629 hyp.SetLength( length )
632 ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
633 # If the 2D mesher sees that all boundary edges are quadratic ones,
634 # it generates quadratic faces, else it generates linear faces using
635 # medium nodes as if they were vertex ones.
636 # The 3D mesher generates quadratic volumes only if all boundary faces
637 # are quadratic ones, else it fails.
638 def QuadraticMesh(self):
639 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1)
642 # Public class: Mesh_CompositeSegment
643 # --------------------------
645 ## Class to define a segment 1D algorithm for discretization
648 class Mesh_CompositeSegment(Mesh_Segment):
650 #17908#algo = 0 # algorithm object common for all Mesh_CompositeSegments
652 ## Private constructor.
653 def __init__(self, mesh, geom=0):
654 #17908#if not Mesh_CompositeSegment.algo:
655 #17908# Mesh_CompositeSegment.algo = self.Create(mesh, geom, "CompositeSegment_1D")
657 #17908# self.Assign( Mesh_CompositeSegment.algo, mesh, geom)
659 self.Create(mesh, geom, "CompositeSegment_1D")
662 # Public class: Mesh_Segment_Python
663 # ---------------------------------
665 ## Class to define a segment 1D algorithm for discretization with python function
668 class Mesh_Segment_Python(Mesh_Segment):
670 #17908#algo = 0 # algorithm object common for all Mesh_Segment_Pythons
672 ## Private constructor.
673 def __init__(self, mesh, geom=0):
674 import Python1dPlugin
675 #17908#if not Mesh_Segment_Python.algo:
676 #17908# Mesh_Segment_Python.algo = self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
678 #17908# self.Assign( Mesh_Segment_Python.algo, mesh, geom)
680 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
682 ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
683 # @param n for the number of segments that cut an edge
684 # @param func for the python function that calculate the length of all segments
685 # @param UseExisting if ==true - search existing hypothesis created with
686 # same parameters, else (default) - create new
687 def PythonSplit1D(self, n, func, UseExisting=0):
688 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so", UseExisting=UseExisting)
689 hyp.SetNumberOfSegments(n)
690 hyp.SetPythonLog10RatioFunction(func)
693 # Public class: Mesh_Triangle
694 # ---------------------------
696 ## Class to define a triangle 2D algorithm
699 class Mesh_Triangle(Mesh_Algorithm):
705 # algorithm objects common for all instances of Mesh_Triangle
708 #17908#algoNET_2D = 0
710 ## Private constructor.
711 def __init__(self, mesh, algoType, geom=0):
712 Mesh_Algorithm.__init__(self)
714 if algoType == MEFISTO:
715 #17908#if not Mesh_Triangle.algoMEF:
716 #17908# Mesh_Triangle.algoMEF = self.Create(mesh, geom, "MEFISTO_2D")
718 #17908# self.Assign( Mesh_Triangle.algoMEF, mesh, geom)
720 self.Create(mesh, geom, "MEFISTO_2D")
722 elif algoType == NETGEN:
724 print "Warning: NETGENPlugin module unavailable"
726 #17908#if not Mesh_Triangle.algoNET:
727 #17908# Mesh_Triangle.algoNET = self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
729 #17908# self.Assign( Mesh_Triangle.algoNET, mesh, geom)
731 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
733 elif algoType == NETGEN_2D:
735 print "Warning: NETGENPlugin module unavailable"
737 #17908#if not Mesh_Triangle.algoNET_2D:
738 #17908# Mesh_Triangle.algoNET_2D = self.Create(mesh, geom,
739 #17908# "NETGEN_2D_ONLY", "libNETGENEngine.so")
741 #17908# self.Assign( Mesh_Triangle.algoNET_2D, mesh, geom)
743 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
746 self.algoType = algoType
748 ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
749 # @param area for the maximum area of each triangles
750 # @param UseExisting if ==true - search existing hypothesis created with
751 # same parameters, else (default) - create new
753 # Only for algoType == MEFISTO || NETGEN_2D
754 def MaxElementArea(self, area, UseExisting=0):
755 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
756 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting)
757 hyp.SetMaxElementArea(area)
759 elif self.algoType == NETGEN:
760 print "Netgen 1D-2D algo doesn't support this hypothesis"
763 ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
765 # Only for algoType == MEFISTO || NETGEN_2D
766 def LengthFromEdges(self):
767 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
768 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1)
770 elif self.algoType == NETGEN:
771 print "Netgen 1D-2D algo doesn't support this hypothesis"
774 ## Set QuadAllowed flag
776 # Only for algoType == NETGEN || NETGEN_2D
777 def SetQuadAllowed(self, toAllow=True):
778 if self.algoType == NETGEN_2D:
779 if toAllow: # add QuadranglePreference
780 self.Hypothesis("QuadranglePreference", UseExisting=1)
781 else: # remove QuadranglePreference
782 for hyp in self.mesh.GetHypothesisList( self.geom ):
783 if hyp.GetName() == "QuadranglePreference":
784 self.mesh.RemoveHypothesis( self.geom, hyp )
789 if self.params == 0 and self.Parameters():
790 self.params.SetQuadAllowed(toAllow)
793 ## Define "Netgen 2D Parameters" hypothesis
795 # Only for algoType == NETGEN
796 def Parameters(self):
797 if self.algoType == NETGEN:
798 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
799 "libNETGENEngine.so", UseExisting=0)
801 elif self.algoType == MEFISTO:
802 print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
804 elif self.algoType == NETGEN_2D:
805 print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
806 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
812 # Only for algoType == NETGEN
813 def SetMaxSize(self, theSize):
816 if self.params is not None:
817 self.params.SetMaxSize(theSize)
819 ## Set SecondOrder flag
821 # Only for algoType == NETGEN
822 def SetSecondOrder(self, theVal):
825 if self.params is not None:
826 self.params.SetSecondOrder(theVal)
830 # Only for algoType == NETGEN
831 def SetOptimize(self, theVal):
834 if self.params is not None:
835 self.params.SetOptimize(theVal)
838 # @param theFineness is:
839 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
841 # Only for algoType == NETGEN
842 def SetFineness(self, theFineness):
845 if self.params is not None:
846 self.params.SetFineness(theFineness)
850 # Only for algoType == NETGEN
851 def SetGrowthRate(self, theRate):
854 if self.params is not None:
855 self.params.SetGrowthRate(theRate)
859 # Only for algoType == NETGEN
860 def SetNbSegPerEdge(self, theVal):
863 if self.params is not None:
864 self.params.SetNbSegPerEdge(theVal)
866 ## Set NbSegPerRadius
868 # Only for algoType == NETGEN
869 def SetNbSegPerRadius(self, theVal):
872 if self.params is not None:
873 self.params.SetNbSegPerRadius(theVal)
878 # Public class: Mesh_Quadrangle
879 # -----------------------------
881 ## Class to define a quadrangle 2D algorithm
884 class Mesh_Quadrangle(Mesh_Algorithm):
886 #17908#algo = 0 # algorithm object common for all Mesh_Quadrangles
888 ## Private constructor.
889 def __init__(self, mesh, geom=0):
890 Mesh_Algorithm.__init__(self)
892 #17908#if not Mesh_Quadrangle.algo:
893 #17908# Mesh_Quadrangle.algo = self.Create(mesh, geom, "Quadrangle_2D")
895 #17908# self.Assign( Mesh_Quadrangle.algo, mesh, geom)
897 self.Create(mesh, geom, "Quadrangle_2D")
899 ## Define "QuadranglePreference" hypothesis, forcing construction
900 # of quadrangles if the number of nodes on opposite edges is not the same
901 # in the case where the global number of nodes on edges is even
902 def QuadranglePreference(self):
903 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1)
906 # Public class: Mesh_Tetrahedron
907 # ------------------------------
909 ## Class to define a tetrahedron 3D algorithm
912 class Mesh_Tetrahedron(Mesh_Algorithm):
917 #17908#algoNET = 0 # algorithm object common for all Mesh_Tetrahedrons
918 #17908#algoGHS = 0 # algorithm object common for all Mesh_Tetrahedrons
919 #17908#algoFNET = 0 # algorithm object common for all Mesh_Tetrahedrons
921 ## Private constructor.
922 def __init__(self, mesh, algoType, geom=0):
923 Mesh_Algorithm.__init__(self)
925 if algoType == NETGEN:
926 #17908#if not Mesh_Tetrahedron.algoNET:
927 #17908# Mesh_Tetrahedron.algoNET = self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
929 #17908# self.Assign( Mesh_Tetrahedron.algoNET, mesh, geom)
931 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
934 elif algoType == GHS3D:
935 #17908#if not Mesh_Tetrahedron.algoGHS:
936 #17908# import GHS3DPlugin
937 #17908# Mesh_Tetrahedron.algoGHS = self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
939 #17908# self.Assign( Mesh_Tetrahedron.algoGHS, mesh, geom)
942 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
945 elif algoType == FULL_NETGEN:
947 print "Warning: NETGENPlugin module has not been imported."
948 #17908#if not Mesh_Tetrahedron.algoFNET:
949 #17908# Mesh_Tetrahedron.algoFNET = self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
951 #17908# self.Assign( Mesh_Tetrahedron.algoFNET, mesh, geom)
953 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
956 self.algoType = algoType
958 ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
959 # @param vol for the maximum volume of each tetrahedral
960 # @param UseExisting if ==true - search existing hypothesis created with
961 # same parameters, else (default) - create new
962 def MaxElementVolume(self, vol, UseExisting=0):
963 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting)
964 hyp.SetMaxElementVolume(vol)
967 ## Define "Netgen 3D Parameters" hypothesis
968 def Parameters(self):
969 if (self.algoType == FULL_NETGEN):
970 self.params = self.Hypothesis("NETGEN_Parameters", [],
971 "libNETGENEngine.so", UseExisting=0)
974 print "Algo doesn't support this hypothesis"
978 def SetMaxSize(self, theSize):
981 self.params.SetMaxSize(theSize)
983 ## Set SecondOrder flag
984 def SetSecondOrder(self, theVal):
987 self.params.SetSecondOrder(theVal)
990 def SetOptimize(self, theVal):
993 self.params.SetOptimize(theVal)
996 # @param theFineness is:
997 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
998 def SetFineness(self, theFineness):
1001 self.params.SetFineness(theFineness)
1004 def SetGrowthRate(self, theRate):
1005 if self.params == 0:
1007 self.params.SetGrowthRate(theRate)
1010 def SetNbSegPerEdge(self, theVal):
1011 if self.params == 0:
1013 self.params.SetNbSegPerEdge(theVal)
1015 ## Set NbSegPerRadius
1016 def SetNbSegPerRadius(self, theVal):
1017 if self.params == 0:
1019 self.params.SetNbSegPerRadius(theVal)
1021 # Public class: Mesh_Hexahedron
1022 # ------------------------------
1024 ## Class to define a hexahedron 3D algorithm
1027 class Mesh_Hexahedron(Mesh_Algorithm):
1029 #17908#algo = 0 # algorithm object common for all Mesh_Hexahedrons
1031 ## Private constructor.
1032 def __init__(self, mesh, geom=0):
1033 Mesh_Algorithm.__init__(self)
1035 #17908#if not Mesh_Hexahedron.algo:
1036 #17908# Mesh_Hexahedron.algo = self.Create(mesh, geom, "Hexa_3D")
1038 #17908# self.Assign( Mesh_Hexahedron.algo, mesh, geom)
1040 self.Create(mesh, geom, "Hexa_3D")
1042 # Deprecated, only for compatibility!
1043 # Public class: Mesh_Netgen
1044 # ------------------------------
1046 ## Class to define a NETGEN-based 2D or 3D algorithm
1047 # that need no discrete boundary (i.e. independent)
1049 # This class is deprecated, only for compatibility!
1052 class Mesh_Netgen(Mesh_Algorithm):
1056 #17908#algoNET23 = 0 # algorithm object common for all Mesh_Netgens
1057 #17908#algoNET2 = 0 # algorithm object common for all Mesh_Netgens
1059 ## Private constructor.
1060 def __init__(self, mesh, is3D, geom=0):
1061 Mesh_Algorithm.__init__(self)
1064 print "Warning: NETGENPlugin module has not been imported."
1068 #17908#if not Mesh_Netgen.algoNET23:
1069 #17908# Mesh_Netgen.algoNET23 = self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
1071 #17908# self.Assign( Mesh_Netgen.algoNET23, mesh, geom)
1073 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
1077 #17908#if not Mesh_Netgen.algoNET2:
1078 #17908# Mesh_Netgen.algoNET2 = self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
1080 #17908# self.Assign( Mesh_Netgen.algoNET2, mesh, geom)
1082 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
1085 ## Define hypothesis containing parameters of the algorithm
1086 def Parameters(self):
1088 hyp = self.Hypothesis("NETGEN_Parameters", [],
1089 "libNETGENEngine.so", UseExisting=0)
1091 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
1092 "libNETGENEngine.so", UseExisting=0)
1095 # Public class: Mesh_Projection1D
1096 # ------------------------------
1098 ## Class to define a projection 1D algorithm
1101 class Mesh_Projection1D(Mesh_Algorithm):
1103 #17908#algo = 0 # algorithm object common for all Mesh_Projection1Ds
1105 ## Private constructor.
1106 def __init__(self, mesh, geom=0):
1107 Mesh_Algorithm.__init__(self)
1109 #17908#if not Mesh_Projection1D.algo:
1110 #17908# Mesh_Projection1D.algo = self.Create(mesh, geom, "Projection_1D")
1112 #17908# self.Assign( Mesh_Projection1D.algo, mesh, geom)
1114 self.Create(mesh, geom, "Projection_1D")
1116 ## Define "Source Edge" hypothesis, specifying a meshed edge to
1117 # take a mesh pattern from, and optionally association of vertices
1118 # between the source edge and a target one (where a hipothesis is assigned to)
1119 # @param edge to take nodes distribution from
1120 # @param mesh to take nodes distribution from (optional)
1121 # @param srcV is vertex of \a edge to associate with \a tgtV (optional)
1122 # @param tgtV is vertex of \a the edge where the algorithm is assigned,
1123 # to associate with \a srcV (optional)
1124 # @param UseExisting if ==true - search existing hypothesis created with
1125 # same parameters, else (default) - create new
1126 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
1127 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV], UseExisting=UseExisting)
1128 hyp.SetSourceEdge( edge )
1129 if not mesh is None and isinstance(mesh, Mesh):
1130 mesh = mesh.GetMesh()
1131 hyp.SetSourceMesh( mesh )
1132 hyp.SetVertexAssociation( srcV, tgtV )
1136 # Public class: Mesh_Projection2D
1137 # ------------------------------
1139 ## Class to define a projection 2D algorithm
1142 class Mesh_Projection2D(Mesh_Algorithm):
1144 #17908#algo = 0 # algorithm object common for all Mesh_Projection2Ds
1146 ## Private constructor.
1147 def __init__(self, mesh, geom=0):
1148 Mesh_Algorithm.__init__(self)
1150 #17908#if not Mesh_Projection2D.algo:
1151 #17908# Mesh_Projection2D.algo = self.Create(mesh, geom, "Projection_2D")
1153 #17908# self.Assign( Mesh_Projection2D.algo, mesh, geom)
1155 self.Create(mesh, geom, "Projection_2D")
1157 ## Define "Source Face" hypothesis, specifying a meshed face to
1158 # take a mesh pattern from, and optionally association of vertices
1159 # between the source face and a target one (where a hipothesis is assigned to)
1160 # @param face to take mesh pattern from
1161 # @param mesh to take mesh pattern from (optional)
1162 # @param srcV1 is vertex of \a face to associate with \a tgtV1 (optional)
1163 # @param tgtV1 is vertex of \a the face where the algorithm is assigned,
1164 # to associate with \a srcV1 (optional)
1165 # @param srcV2 is vertex of \a face to associate with \a tgtV1 (optional)
1166 # @param tgtV2 is vertex of \a the face where the algorithm is assigned,
1167 # to associate with \a srcV2 (optional)
1168 # @param UseExisting if ==true - search existing hypothesis created with
1169 # same parameters, else (default) - create new
1171 # Note: association vertices must belong to one edge of a face
1172 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
1173 srcV2=None, tgtV2=None, UseExisting=0):
1174 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
1175 UseExisting=UseExisting)
1176 hyp.SetSourceFace( face )
1177 if not mesh is None and isinstance(mesh, Mesh):
1178 mesh = mesh.GetMesh()
1179 hyp.SetSourceMesh( mesh )
1180 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1183 # Public class: Mesh_Projection3D
1184 # ------------------------------
1186 ## Class to define a projection 3D algorithm
1189 class Mesh_Projection3D(Mesh_Algorithm):
1191 #17908#algo = 0 # algorithm object common for all Mesh_Projection3Ds
1193 ## Private constructor.
1194 def __init__(self, mesh, geom=0):
1195 Mesh_Algorithm.__init__(self)
1197 #17908#if not Mesh_Projection3D.algo:
1198 #17908# Mesh_Projection3D.algo = self.Create(mesh, geom, "Projection_3D")
1200 #17908# self.Assign( Mesh_Projection3D.algo, mesh, geom)
1202 self.Create(mesh, geom, "Projection_3D")
1204 ## Define "Source Shape 3D" hypothesis, specifying a meshed solid to
1205 # take a mesh pattern from, and optionally association of vertices
1206 # between the source solid and a target one (where a hipothesis is assigned to)
1207 # @param solid to take mesh pattern from
1208 # @param mesh to take mesh pattern from (optional)
1209 # @param srcV1 is vertex of \a solid to associate with \a tgtV1 (optional)
1210 # @param tgtV1 is vertex of \a the solid where the algorithm is assigned,
1211 # to associate with \a srcV1 (optional)
1212 # @param srcV2 is vertex of \a solid to associate with \a tgtV1 (optional)
1213 # @param tgtV2 is vertex of \a the solid where the algorithm is assigned,
1214 # to associate with \a srcV2 (optional)
1215 # @param UseExisting - if ==true - search existing hypothesis created with
1216 # same parameters, else (default) - create new
1218 # Note: association vertices must belong to one edge of a solid
1219 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
1220 srcV2=0, tgtV2=0, UseExisting=0):
1221 hyp = self.Hypothesis("ProjectionSource3D",
1222 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
1223 UseExisting=UseExisting)
1224 hyp.SetSource3DShape( solid )
1225 if not mesh is None and isinstance(mesh, Mesh):
1226 mesh = mesh.GetMesh()
1227 hyp.SetSourceMesh( mesh )
1228 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1232 # Public class: Mesh_Prism
1233 # ------------------------
1235 ## Class to define a 3D extrusion algorithm
1238 class Mesh_Prism3D(Mesh_Algorithm):
1240 #17908#algo = 0 # algorithm object common for all Mesh_Prism3Ds
1242 ## Private constructor.
1243 def __init__(self, mesh, geom=0):
1244 Mesh_Algorithm.__init__(self)
1246 #17908#if not Mesh_Prism3D.algo:
1247 #17908# Mesh_Prism3D.algo = self.Create(mesh, geom, "Prism_3D")
1249 #17908# self.Assign( Mesh_Prism3D.algo, mesh, geom)
1251 self.Create(mesh, geom, "Prism_3D")
1253 # Public class: Mesh_RadialPrism
1254 # -------------------------------
1256 ## Class to define a Radial Prism 3D algorithm
1259 class Mesh_RadialPrism3D(Mesh_Algorithm):
1261 #17908#algo = 0 # algorithm object common for all Mesh_RadialPrism3Ds
1263 ## Private constructor.
1264 def __init__(self, mesh, geom=0):
1265 Mesh_Algorithm.__init__(self)
1267 #17908#if not Mesh_RadialPrism3D.algo:
1268 #17908# Mesh_RadialPrism3D.algo = self.Create(mesh, geom, "RadialPrism_3D")
1270 #17908# self.Assign( Mesh_RadialPrism3D.algo, mesh, geom)
1272 self.Create(mesh, geom, "RadialPrism_3D")
1274 self.distribHyp = self.Hypothesis( "LayerDistribution", UseExisting=0)
1275 self.nbLayers = None
1277 ## Return 3D hypothesis holding the 1D one
1278 def Get3DHypothesis(self):
1279 return self.distribHyp
1281 ## Private method creating 1D hypothes and storing it in the LayerDistribution
1282 # hypothes. Returns the created hypothes
1283 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1284 print "OwnHypothesis",hypType
1285 if not self.nbLayers is None:
1286 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1287 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1288 study = self.mesh.smeshpyD.GetCurrentStudy() # prevent publishing of own 1D hypothesis
1289 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1290 self.mesh.smeshpyD.SetCurrentStudy( study ) # anable publishing
1291 self.distribHyp.SetLayerDistribution( hyp )
1294 ## Define "NumberOfLayers" hypothesis, specifying a number of layers of
1295 # prisms to build between the inner and outer shells
1296 # @param UseExisting if ==true - search existing hypothesis created with
1297 # same parameters, else (default) - create new
1298 def NumberOfLayers(self, n, UseExisting=0):
1299 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1300 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting)
1301 self.nbLayers.SetNumberOfLayers( n )
1302 return self.nbLayers
1304 ## Define "LocalLength" hypothesis, specifying segment length
1305 # to build between the inner and outer shells
1306 # @param l for the length of segments
1307 def LocalLength(self, l):
1308 hyp = self.OwnHypothesis("LocalLength", [l] )
1312 ## Define "NumberOfSegments" hypothesis, specifying a number of layers of
1313 # prisms to build between the inner and outer shells
1314 # @param n for the number of segments
1315 # @param s for the scale factor (optional)
1316 def NumberOfSegments(self, n, s=[]):
1318 hyp = self.OwnHypothesis("NumberOfSegments", [n] )
1320 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1321 hyp.SetDistrType( 1 )
1322 hyp.SetScaleFactor(s)
1323 hyp.SetNumberOfSegments(n)
1326 ## Define "Arithmetic1D" hypothesis, specifying distribution of segments
1327 # to build between the inner and outer shells as arithmetic length increasing
1328 # @param start for the length of the first segment
1329 # @param end for the length of the last segment
1330 def Arithmetic1D(self, start, end ):
1331 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1332 hyp.SetLength(start, 1)
1333 hyp.SetLength(end , 0)
1336 ## Define "StartEndLength" hypothesis, specifying distribution of segments
1337 # to build between the inner and outer shells as geometric length increasing
1338 # @param start for the length of the first segment
1339 # @param end for the length of the last segment
1340 def StartEndLength(self, start, end):
1341 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1342 hyp.SetLength(start, 1)
1343 hyp.SetLength(end , 0)
1346 ## Define "AutomaticLength" hypothesis, specifying number of segments
1347 # to build between the inner and outer shells
1348 # @param fineness for the fineness [0-1]
1349 def AutomaticLength(self, fineness=0):
1350 hyp = self.OwnHypothesis("AutomaticLength")
1351 hyp.SetFineness( fineness )
1354 # Private class: Mesh_UseExisting
1355 # -------------------------------
1356 class Mesh_UseExisting(Mesh_Algorithm):
1358 #17908#algo1D = 0 # StdMeshers_UseExisting_1D object common for all Mesh_UseExisting
1359 #17908#algo2D = 0 # StdMeshers_UseExisting_2D object common for all Mesh_UseExisting
1361 def __init__(self, dim, mesh, geom=0):
1363 #17908#if not Mesh_UseExisting.algo1D:
1364 #17908# Mesh_UseExisting.algo1D= self.Create(mesh, geom, "UseExisting_1D")
1366 #17908# self.Assign( Mesh_UseExisting.algo1D, mesh, geom)
1368 self.Create(mesh, geom, "UseExisting_1D")
1370 #17908#if not Mesh_UseExisting.algo2D:
1371 #17908# Mesh_UseExisting.algo2D= self.Create(mesh, geom, "UseExisting_2D")
1373 #17908# self.Assign( Mesh_UseExisting.algo2D, mesh, geom)
1375 self.Create(mesh, geom, "UseExisting_2D")
1377 # Public class: Mesh
1378 # ==================
1380 ## Class to define a mesh
1382 # The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
1392 # Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
1393 # sets GUI name of this mesh to \a name.
1394 # @param obj Shape to be meshed or SMESH_Mesh object
1395 # @param name Study name of the mesh
1396 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1397 self.smeshpyD=smeshpyD
1398 self.geompyD=geompyD
1402 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1404 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1405 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1408 self.mesh = self.smeshpyD.CreateEmptyMesh()
1410 SetName(self.mesh, name)
1412 SetName(self.mesh, GetName(obj))
1414 self.editor = self.mesh.GetMeshEditor()
1416 ## Method that inits the Mesh object from SMESH_Mesh interface
1417 # @param theMesh is SMESH_Mesh object
1418 def SetMesh(self, theMesh):
1420 self.geom = self.mesh.GetShapeToMesh()
1422 ## Method that returns the mesh
1423 # @return SMESH_Mesh object
1429 name = GetName(self.GetMesh())
1433 def SetName(self, name):
1434 SetName(self.GetMesh(), name)
1436 ## Get the subMesh object associated to a subShape. The subMesh object
1437 # gives access to nodes and elements IDs.
1438 # \n SubMesh will be used instead of SubShape in a next idl version to
1439 # adress a specific subMesh...
1440 def GetSubMesh(self, theSubObject, name):
1441 submesh = self.mesh.GetSubMesh(theSubObject, name)
1444 ## Method that returns the shape associated to the mesh
1445 # @return GEOM_Object
1449 ## Method that associates given shape to the mesh(entails the mesh recreation)
1450 # @param geom shape to be meshed(GEOM_Object)
1451 def SetShape(self, geom):
1452 self.mesh = self.smeshpyD.CreateMesh(geom)
1454 ## Return true if hypotheses are defined well
1455 # @param theMesh is an instance of Mesh class
1456 # @param theSubObject subshape of a mesh shape
1457 def IsReadyToCompute(self, theSubObject):
1458 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1460 ## Return errors of hypotheses definintion
1461 # error list is empty if everything is OK
1462 # @param theMesh is an instance of Mesh class
1463 # @param theSubObject subshape of a mesh shape
1464 # @return a list of errors
1465 def GetAlgoState(self, theSubObject):
1466 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1468 ## Return geometrical object the given element is built on.
1469 # The returned geometrical object, if not nil, is either found in the
1470 # study or is published by this method with the given name
1471 # @param theMesh is an instance of Mesh class
1472 # @param theElementID an id of the mesh element
1473 # @param theGeomName user defined name of geometrical object
1474 # @return GEOM::GEOM_Object instance
1475 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1476 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1478 ## Returns mesh dimension depending on shape one
1479 def MeshDimension(self):
1480 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1481 if len( shells ) > 0 :
1483 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1485 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1491 ## Creates a segment discretization 1D algorithm.
1492 # If the optional \a algo parameter is not sets, this algorithm is REGULAR.
1493 # If the optional \a geom parameter is not sets, this algorithm is global.
1494 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1495 # @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
1496 # @param geom If defined, subshape to be meshed
1497 def Segment(self, algo=REGULAR, geom=0):
1498 ## if Segment(geom) is called by mistake
1499 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1500 algo, geom = geom, algo
1501 if not algo: algo = REGULAR
1504 return Mesh_Segment(self, geom)
1505 elif algo == PYTHON:
1506 return Mesh_Segment_Python(self, geom)
1507 elif algo == COMPOSITE:
1508 return Mesh_CompositeSegment(self, geom)
1510 return Mesh_Segment(self, geom)
1512 ## Enable creation of nodes and segments usable by 2D algoritms.
1513 # Added nodes and segments must be bound to edges and vertices by
1514 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1515 # If the optional \a geom parameter is not sets, this algorithm is global.
1516 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1517 # @param geom subshape to be manually meshed
1518 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1519 def UseExistingSegments(self, geom=0):
1520 algo = Mesh_UseExisting(1,self,geom)
1521 return algo.GetAlgorithm()
1523 ## Enable creation of nodes and faces usable by 3D algoritms.
1524 # Added nodes and faces must be bound to geom faces by SetNodeOnFace()
1525 # and SetMeshElementOnShape()
1526 # If the optional \a geom parameter is not sets, this algorithm is global.
1527 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1528 # @param geom subshape to be manually meshed
1529 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1530 def UseExistingFaces(self, geom=0):
1531 algo = Mesh_UseExisting(2,self,geom)
1532 return algo.GetAlgorithm()
1534 ## Creates a triangle 2D algorithm for faces.
1535 # If the optional \a geom parameter is not sets, this algorithm is global.
1536 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1537 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D
1538 # @param geom If defined, subshape to be meshed
1539 def Triangle(self, algo=MEFISTO, geom=0):
1540 ## if Triangle(geom) is called by mistake
1541 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1545 return Mesh_Triangle(self, algo, geom)
1547 ## Creates a quadrangle 2D algorithm for faces.
1548 # If the optional \a geom parameter is not sets, this algorithm is global.
1549 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1550 # @param geom If defined, subshape to be meshed
1551 def Quadrangle(self, geom=0):
1552 return Mesh_Quadrangle(self, geom)
1554 ## Creates a tetrahedron 3D algorithm for solids.
1555 # The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
1556 # If the optional \a geom parameter is not sets, this algorithm is global.
1557 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1558 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
1559 # @param geom If defined, subshape to be meshed
1560 def Tetrahedron(self, algo=NETGEN, geom=0):
1561 ## if Tetrahedron(geom) is called by mistake
1562 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1563 algo, geom = geom, algo
1564 if not algo: algo = NETGEN
1566 return Mesh_Tetrahedron(self, algo, geom)
1568 ## Creates a hexahedron 3D algorithm for solids.
1569 # If the optional \a geom parameter is not sets, this algorithm is global.
1570 # \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1571 # @param geom If defined, subshape to be meshed
1572 def Hexahedron(self, geom=0):
1573 return Mesh_Hexahedron(self, geom)
1575 ## Deprecated, only for compatibility!
1576 def Netgen(self, is3D, geom=0):
1577 return Mesh_Netgen(self, is3D, geom)
1579 ## Creates a projection 1D algorithm for edges.
1580 # If the optional \a geom parameter is not sets, this algorithm is global.
1581 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1582 # @param geom If defined, subshape to be meshed
1583 def Projection1D(self, geom=0):
1584 return Mesh_Projection1D(self, geom)
1586 ## Creates a projection 2D algorithm for faces.
1587 # If the optional \a geom parameter is not sets, this algorithm is global.
1588 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1589 # @param geom If defined, subshape to be meshed
1590 def Projection2D(self, geom=0):
1591 return Mesh_Projection2D(self, geom)
1593 ## Creates a projection 3D algorithm for solids.
1594 # If the optional \a geom parameter is not sets, this algorithm is global.
1595 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1596 # @param geom If defined, subshape to be meshed
1597 def Projection3D(self, geom=0):
1598 return Mesh_Projection3D(self, geom)
1600 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1601 # If the optional \a geom parameter is not sets, this algorithm is global.
1602 # Otherwise, this algorithm define a submesh based on \a geom subshape.
1603 # @param geom If defined, subshape to be meshed
1604 def Prism(self, geom=0):
1608 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1609 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1610 if nbSolids == 0 or nbSolids == nbShells:
1611 return Mesh_Prism3D(self, geom)
1612 return Mesh_RadialPrism3D(self, geom)
1614 ## Compute the mesh and return the status of the computation
1615 def Compute(self, geom=0):
1616 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1618 print "Compute impossible: mesh is not constructed on geom shape."
1624 ok = self.smeshpyD.Compute(self.mesh, geom)
1625 except SALOME.SALOME_Exception, ex:
1626 print "Mesh computation failed, exception caught:"
1627 print " ", ex.details.text
1630 print "Mesh computation failed, exception caught:"
1631 traceback.print_exc()
1633 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1636 if err.isGlobalAlgo:
1644 reason = '%s %sD algorithm is missing' % (glob, dim)
1645 elif err.state == HYP_MISSING:
1646 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1647 % (glob, dim, name, dim))
1648 elif err.state == HYP_NOTCONFORM:
1649 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1650 elif err.state == HYP_BAD_PARAMETER:
1651 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1652 % ( glob, dim, name ))
1653 elif err.state == HYP_BAD_GEOMETRY:
1654 reason = ('%s %sD algorithm "%s" is assigned to geometry mismatching'
1655 'its expectation' % ( glob, dim, name ))
1657 reason = "For unknown reason."+\
1658 " Revise Mesh.Compute() implementation in smesh.py!"
1660 if allReasons != "":
1663 allReasons += reason
1665 if allReasons != "":
1666 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1669 print '"' + GetName(self.mesh) + '"',"has not been computed."
1672 if salome.sg.hasDesktop():
1673 smeshgui = salome.ImportComponentGUI("SMESH")
1674 smeshgui.Init(salome.myStudyId)
1675 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1676 salome.sg.updateObjBrowser(1)
1680 ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1681 # The parameter \a fineness [0,-1] defines mesh fineness
1682 def AutomaticTetrahedralization(self, fineness=0):
1683 dim = self.MeshDimension()
1685 self.RemoveGlobalHypotheses()
1686 self.Segment().AutomaticLength(fineness)
1688 self.Triangle().LengthFromEdges()
1691 self.Tetrahedron(NETGEN)
1693 return self.Compute()
1695 ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1696 # The parameter \a fineness [0,-1] defines mesh fineness
1697 def AutomaticHexahedralization(self, fineness=0):
1698 dim = self.MeshDimension()
1700 self.RemoveGlobalHypotheses()
1701 self.Segment().AutomaticLength(fineness)
1708 return self.Compute()
1710 ## Assign hypothesis
1711 # @param hyp is a hypothesis to assign
1712 # @param geom is subhape of mesh geometry
1713 def AddHypothesis(self, hyp, geom=0 ):
1714 if isinstance( hyp, Mesh_Algorithm ):
1715 hyp = hyp.GetAlgorithm()
1720 status = self.mesh.AddHypothesis(geom, hyp)
1721 isAlgo = hyp._narrow( SMESH_Algo )
1722 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1725 ## Unassign hypothesis
1726 # @param hyp is a hypothesis to unassign
1727 # @param geom is subhape of mesh geometry
1728 def RemoveHypothesis(self, hyp, geom=0 ):
1729 if isinstance( hyp, Mesh_Algorithm ):
1730 hyp = hyp.GetAlgorithm()
1735 status = self.mesh.RemoveHypothesis(geom, hyp)
1738 ## Get the list of hypothesis added on a geom
1739 # @param geom is subhape of mesh geometry
1740 def GetHypothesisList(self, geom):
1741 return self.mesh.GetHypothesisList( geom )
1743 ## Removes all global hypotheses
1744 def RemoveGlobalHypotheses(self):
1745 current_hyps = self.mesh.GetHypothesisList( self.geom )
1746 for hyp in current_hyps:
1747 self.mesh.RemoveHypothesis( self.geom, hyp )
1751 ## Create a mesh group based on geometric object \a grp
1752 # and give a \a name, \n if this parameter is not defined
1753 # the name is the same as the geometric group name \n
1754 # Note: Works like GroupOnGeom().
1755 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1756 # @param name is the name of the mesh group
1757 # @return SMESH_GroupOnGeom
1758 def Group(self, grp, name=""):
1759 return self.GroupOnGeom(grp, name)
1761 ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1762 # Export the mesh in a file with the MED format and choice the \a version of MED format
1763 # @param f is the file name
1764 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1765 def ExportToMED(self, f, version, opt=0):
1766 self.mesh.ExportToMED(f, opt, version)
1768 ## Export the mesh in a file with the MED format
1769 # @param f is the file name
1770 # @param auto_groups boolean parameter for creating/not creating
1771 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1772 # the typical use is auto_groups=false.
1773 # @param version MED format version(MED_V2_1 or MED_V2_2)
1774 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1775 self.mesh.ExportToMED(f, auto_groups, version)
1777 ## Export the mesh in a file with the DAT format
1778 # @param f is the file name
1779 def ExportDAT(self, f):
1780 self.mesh.ExportDAT(f)
1782 ## Export the mesh in a file with the UNV format
1783 # @param f is the file name
1784 def ExportUNV(self, f):
1785 self.mesh.ExportUNV(f)
1787 ## Export the mesh in a file with the STL format
1788 # @param f is the file name
1789 # @param ascii defined the kind of file contents
1790 def ExportSTL(self, f, ascii=1):
1791 self.mesh.ExportSTL(f, ascii)
1794 # Operations with groups:
1795 # ----------------------
1797 ## Creates an empty mesh group
1798 # @param elementType is the type of elements in the group
1799 # @param name is the name of the mesh group
1800 # @return SMESH_Group
1801 def CreateEmptyGroup(self, elementType, name):
1802 return self.mesh.CreateGroup(elementType, name)
1804 ## Creates a mesh group based on geometric object \a grp
1805 # and give a \a name, \n if this parameter is not defined
1806 # the name is the same as the geometric group name
1807 # @param grp is a geometric group, a vertex, an edge, a face or a solid
1808 # @param name is the name of the mesh group
1809 # @return SMESH_GroupOnGeom
1810 def GroupOnGeom(self, grp, name="", typ=None):
1812 name = grp.GetName()
1815 tgeo = str(grp.GetShapeType())
1816 if tgeo == "VERTEX":
1818 elif tgeo == "EDGE":
1820 elif tgeo == "FACE":
1822 elif tgeo == "SOLID":
1824 elif tgeo == "SHELL":
1826 elif tgeo == "COMPOUND":
1827 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1828 print "Mesh.Group: empty geometric group", GetName( grp )
1830 tgeo = self.geompyD.GetType(grp)
1831 if tgeo == geompyDC.ShapeType["VERTEX"]:
1833 elif tgeo == geompyDC.ShapeType["EDGE"]:
1835 elif tgeo == geompyDC.ShapeType["FACE"]:
1837 elif tgeo == geompyDC.ShapeType["SOLID"]:
1841 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1844 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1846 ## Create a mesh group by the given ids of elements
1847 # @param groupName is the name of the mesh group
1848 # @param elementType is the type of elements in the group
1849 # @param elemIDs is the list of ids
1850 # @return SMESH_Group
1851 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1852 group = self.mesh.CreateGroup(elementType, groupName)
1856 ## Create a mesh group by the given conditions
1857 # @param groupName is the name of the mesh group
1858 # @param elementType is the type of elements in the group
1859 # @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1860 # @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1861 # @param Treshold is threshold value (range of id ids as string, shape, numeric)
1862 # @param UnaryOp is FT_LogicalNOT or FT_Undefined
1863 # @return SMESH_Group
1867 CritType=FT_Undefined,
1870 UnaryOp=FT_Undefined):
1871 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1872 group = self.MakeGroupByCriterion(groupName, aCriterion)
1875 ## Create a mesh group by the given criterion
1876 # @param groupName is the name of the mesh group
1877 # @param Criterion is the instance of Criterion class
1878 # @return SMESH_Group
1879 def MakeGroupByCriterion(self, groupName, Criterion):
1880 aFilterMgr = self.smeshpyD.CreateFilterManager()
1881 aFilter = aFilterMgr.CreateFilter()
1883 aCriteria.append(Criterion)
1884 aFilter.SetCriteria(aCriteria)
1885 group = self.MakeGroupByFilter(groupName, aFilter)
1888 ## Create a mesh group by the given criteria(list of criterions)
1889 # @param groupName is the name of the mesh group
1890 # @param Criteria is the list of criterions
1891 # @return SMESH_Group
1892 def MakeGroupByCriteria(self, groupName, theCriteria):
1893 aFilterMgr = self.smeshpyD.CreateFilterManager()
1894 aFilter = aFilterMgr.CreateFilter()
1895 aFilter.SetCriteria(theCriteria)
1896 group = self.MakeGroupByFilter(groupName, aFilter)
1899 ## Create a mesh group by the given filter
1900 # @param groupName is the name of the mesh group
1901 # @param Criterion is the instance of Filter class
1902 # @return SMESH_Group
1903 def MakeGroupByFilter(self, groupName, theFilter):
1904 anIds = theFilter.GetElementsId(self.mesh)
1905 anElemType = theFilter.GetElementType()
1906 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1909 ## Pass mesh elements through the given filter and return ids
1910 # @param theFilter is SMESH_Filter
1911 # @return list of ids
1912 def GetIdsFromFilter(self, theFilter):
1913 return theFilter.GetElementsId(self.mesh)
1915 ## Verify whether 2D mesh element has free edges(edges connected to one face only)\n
1916 # Returns list of special structures(borders).
1917 # @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
1918 def GetFreeBorders(self):
1919 aFilterMgr = self.smeshpyD.CreateFilterManager()
1920 aPredicate = aFilterMgr.CreateFreeEdges()
1921 aPredicate.SetMesh(self.mesh)
1922 aBorders = aPredicate.GetBorders()
1926 def RemoveGroup(self, group):
1927 self.mesh.RemoveGroup(group)
1929 ## Remove group with its contents
1930 def RemoveGroupWithContents(self, group):
1931 self.mesh.RemoveGroupWithContents(group)
1933 ## Get the list of groups existing in the mesh
1934 def GetGroups(self):
1935 return self.mesh.GetGroups()
1937 ## Get number of groups existing in the mesh
1939 return self.mesh.NbGroups()
1941 ## Get the list of names of groups existing in the mesh
1942 def GetGroupNames(self):
1943 groups = self.GetGroups()
1945 for group in groups:
1946 names.append(group.GetName())
1949 ## Union of two groups
1950 # New group is created. All mesh elements that are
1951 # present in initial groups are added to the new one
1952 def UnionGroups(self, group1, group2, name):
1953 return self.mesh.UnionGroups(group1, group2, name)
1955 ## Intersection of two groups
1956 # New group is created. All mesh elements that are
1957 # present in both initial groups are added to the new one.
1958 def IntersectGroups(self, group1, group2, name):
1959 return self.mesh.IntersectGroups(group1, group2, name)
1961 ## Cut of two groups
1962 # New group is created. All mesh elements that are present in
1963 # main group but do not present in tool group are added to the new one
1964 def CutGroups(self, mainGroup, toolGroup, name):
1965 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1968 # Get some info about mesh:
1969 # ------------------------
1971 ## Get the log of nodes and elements added or removed since previous
1973 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1974 # @return list of log_block structures:
1979 def GetLog(self, clearAfterGet):
1980 return self.mesh.GetLog(clearAfterGet)
1982 ## Clear the log of nodes and elements added or removed since previous
1983 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1985 self.mesh.ClearLog()
1987 def SetAutoColor(self, color):
1988 self.mesh.SetAutoColor(color)
1990 def GetAutoColor(self):
1991 return self.mesh.GetAutoColor()
1993 ## Get the internal Id
1995 return self.mesh.GetId()
1998 def GetStudyId(self):
1999 return self.mesh.GetStudyId()
2001 ## Check group names for duplications.
2002 # Consider maximum group name length stored in MED file.
2003 def HasDuplicatedGroupNamesMED(self):
2004 return self.mesh.HasDuplicatedGroupNamesMED()
2006 ## Obtain instance of SMESH_MeshEditor
2007 def GetMeshEditor(self):
2008 return self.mesh.GetMeshEditor()
2011 def GetMEDMesh(self):
2012 return self.mesh.GetMEDMesh()
2015 # Get informations about mesh contents:
2016 # ------------------------------------
2018 ## Returns number of nodes in mesh
2020 return self.mesh.NbNodes()
2022 ## Returns number of elements in mesh
2023 def NbElements(self):
2024 return self.mesh.NbElements()
2026 ## Returns number of edges in mesh
2028 return self.mesh.NbEdges()
2030 ## Returns number of edges with given order in mesh
2031 # @param elementOrder is order of elements:
2032 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2033 def NbEdgesOfOrder(self, elementOrder):
2034 return self.mesh.NbEdgesOfOrder(elementOrder)
2036 ## Returns number of faces in mesh
2038 return self.mesh.NbFaces()
2040 ## Returns number of faces with given order in mesh
2041 # @param elementOrder is order of elements:
2042 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2043 def NbFacesOfOrder(self, elementOrder):
2044 return self.mesh.NbFacesOfOrder(elementOrder)
2046 ## Returns number of triangles in mesh
2047 def NbTriangles(self):
2048 return self.mesh.NbTriangles()
2050 ## Returns number of triangles with given order in mesh
2051 # @param elementOrder is order of elements:
2052 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2053 def NbTrianglesOfOrder(self, elementOrder):
2054 return self.mesh.NbTrianglesOfOrder(elementOrder)
2056 ## Returns number of quadrangles in mesh
2057 def NbQuadrangles(self):
2058 return self.mesh.NbQuadrangles()
2060 ## Returns number of quadrangles with given order in mesh
2061 # @param elementOrder is order of elements:
2062 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2063 def NbQuadranglesOfOrder(self, elementOrder):
2064 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2066 ## Returns number of polygons in mesh
2067 def NbPolygons(self):
2068 return self.mesh.NbPolygons()
2070 ## Returns number of volumes in mesh
2071 def NbVolumes(self):
2072 return self.mesh.NbVolumes()
2074 ## Returns number of volumes with given order in mesh
2075 # @param elementOrder is order of elements:
2076 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2077 def NbVolumesOfOrder(self, elementOrder):
2078 return self.mesh.NbVolumesOfOrder(elementOrder)
2080 ## Returns number of tetrahedrons in mesh
2082 return self.mesh.NbTetras()
2084 ## Returns number of tetrahedrons with given order in mesh
2085 # @param elementOrder is order of elements:
2086 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2087 def NbTetrasOfOrder(self, elementOrder):
2088 return self.mesh.NbTetrasOfOrder(elementOrder)
2090 ## Returns number of hexahedrons in mesh
2092 return self.mesh.NbHexas()
2094 ## Returns number of hexahedrons with given order in mesh
2095 # @param elementOrder is order of elements:
2096 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2097 def NbHexasOfOrder(self, elementOrder):
2098 return self.mesh.NbHexasOfOrder(elementOrder)
2100 ## Returns number of pyramids in mesh
2101 def NbPyramids(self):
2102 return self.mesh.NbPyramids()
2104 ## Returns number of pyramids with given order in mesh
2105 # @param elementOrder is order of elements:
2106 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2107 def NbPyramidsOfOrder(self, elementOrder):
2108 return self.mesh.NbPyramidsOfOrder(elementOrder)
2110 ## Returns number of prisms in mesh
2112 return self.mesh.NbPrisms()
2114 ## Returns number of prisms with given order in mesh
2115 # @param elementOrder is order of elements:
2116 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2117 def NbPrismsOfOrder(self, elementOrder):
2118 return self.mesh.NbPrismsOfOrder(elementOrder)
2120 ## Returns number of polyhedrons in mesh
2121 def NbPolyhedrons(self):
2122 return self.mesh.NbPolyhedrons()
2124 ## Returns number of submeshes in mesh
2125 def NbSubMesh(self):
2126 return self.mesh.NbSubMesh()
2128 ## Returns list of mesh elements ids
2129 def GetElementsId(self):
2130 return self.mesh.GetElementsId()
2132 ## Returns list of ids of mesh elements with given type
2133 # @param elementType is required type of elements
2134 def GetElementsByType(self, elementType):
2135 return self.mesh.GetElementsByType(elementType)
2137 ## Returns list of mesh nodes ids
2138 def GetNodesId(self):
2139 return self.mesh.GetNodesId()
2141 # Get informations about mesh elements:
2142 # ------------------------------------
2144 ## Returns type of mesh element
2145 def GetElementType(self, id, iselem):
2146 return self.mesh.GetElementType(id, iselem)
2148 ## Returns list of submesh elements ids
2149 # @param Shape is geom object(subshape) IOR
2150 # Shape must be subshape of a ShapeToMesh()
2151 def GetSubMeshElementsId(self, Shape):
2152 if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
2153 ShapeID = Shape.GetSubShapeIndices()[0]
2156 return self.mesh.GetSubMeshElementsId(ShapeID)
2158 ## Returns list of submesh nodes ids
2159 # @param Shape is geom object(subshape) IOR
2160 # Shape must be subshape of a ShapeToMesh()
2161 def GetSubMeshNodesId(self, Shape, all):
2162 if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
2163 ShapeID = Shape.GetSubShapeIndices()[0]
2166 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2168 ## Returns list of ids of submesh elements with given type
2169 # @param Shape is geom object(subshape) IOR
2170 # Shape must be subshape of a ShapeToMesh()
2171 def GetSubMeshElementType(self, Shape):
2172 if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
2173 ShapeID = Shape.GetSubShapeIndices()[0]
2176 return self.mesh.GetSubMeshElementType(ShapeID)
2178 ## Get mesh description
2180 return self.mesh.Dump()
2183 # Get information about nodes and elements of mesh by its ids:
2184 # -----------------------------------------------------------
2186 ## Get XYZ coordinates of node as list of double
2187 # \n If there is not node for given ID - returns empty list
2188 def GetNodeXYZ(self, id):
2189 return self.mesh.GetNodeXYZ(id)
2191 ## For given node returns list of IDs of inverse elements
2192 # \n If there is not node for given ID - returns empty list
2193 def GetNodeInverseElements(self, id):
2194 return self.mesh.GetNodeInverseElements(id)
2196 ## @brief Return position of a node on shape
2197 # @return SMESH::NodePosition
2198 def GetNodePosition(self,NodeID):
2199 return self.mesh.GetNodePosition(NodeID)
2201 ## If given element is node returns IDs of shape from position
2202 # \n If there is not node for given ID - returns -1
2203 def GetShapeID(self, id):
2204 return self.mesh.GetShapeID(id)
2206 ## For given element returns ID of result shape after
2207 # FindShape() from SMESH_MeshEditor
2208 # \n If there is not element for given ID - returns -1
2209 def GetShapeIDForElem(self,id):
2210 return self.mesh.GetShapeIDForElem(id)
2212 ## Returns number of nodes for given element
2213 # \n If there is not element for given ID - returns -1
2214 def GetElemNbNodes(self, id):
2215 return self.mesh.GetElemNbNodes(id)
2217 ## Returns ID of node by given index for given element
2218 # \n If there is not element for given ID - returns -1
2219 # \n If there is not node for given index - returns -2
2220 def GetElemNode(self, id, index):
2221 return self.mesh.GetElemNode(id, index)
2223 ## Returns IDs of nodes of given element
2224 def GetElemNodes(self, id):
2225 return self.mesh.GetElemNodes(id)
2227 ## Returns true if given node is medium node
2228 # in given quadratic element
2229 def IsMediumNode(self, elementID, nodeID):
2230 return self.mesh.IsMediumNode(elementID, nodeID)
2232 ## Returns true if given node is medium node
2233 # in one of quadratic elements
2234 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2235 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2237 ## Returns number of edges for given element
2238 def ElemNbEdges(self, id):
2239 return self.mesh.ElemNbEdges(id)
2241 ## Returns number of faces for given element
2242 def ElemNbFaces(self, id):
2243 return self.mesh.ElemNbFaces(id)
2245 ## Returns true if given element is polygon
2246 def IsPoly(self, id):
2247 return self.mesh.IsPoly(id)
2249 ## Returns true if given element is quadratic
2250 def IsQuadratic(self, id):
2251 return self.mesh.IsQuadratic(id)
2253 ## Returns XYZ coordinates of bary center for given element
2255 # \n If there is not element for given ID - returns empty list
2256 def BaryCenter(self, id):
2257 return self.mesh.BaryCenter(id)
2260 # Mesh edition (SMESH_MeshEditor functionality):
2261 # ---------------------------------------------
2263 ## Removes elements from mesh by ids
2264 # @param IDsOfElements is list of ids of elements to remove
2265 def RemoveElements(self, IDsOfElements):
2266 return self.editor.RemoveElements(IDsOfElements)
2268 ## Removes nodes from mesh by ids
2269 # @param IDsOfNodes is list of ids of nodes to remove
2270 def RemoveNodes(self, IDsOfNodes):
2271 return self.editor.RemoveNodes(IDsOfNodes)
2273 ## Add node to mesh by coordinates
2274 def AddNode(self, x, y, z):
2275 return self.editor.AddNode( x, y, z)
2278 ## Create edge both similar and quadratic (this is determed
2279 # by number of given nodes).
2280 # @param IdsOfNodes List of node IDs for creation of element.
2281 # Needed order of nodes in this list corresponds to description
2282 # of MED. \n This description is located by the following link:
2283 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2284 def AddEdge(self, IDsOfNodes):
2285 return self.editor.AddEdge(IDsOfNodes)
2287 ## Create face both similar and quadratic (this is determed
2288 # by number of given nodes).
2289 # @param IdsOfNodes List of node IDs for creation of element.
2290 # Needed order of nodes in this list corresponds to description
2291 # of MED. \n This description is located by the following link:
2292 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2293 def AddFace(self, IDsOfNodes):
2294 return self.editor.AddFace(IDsOfNodes)
2296 ## Add polygonal face to mesh by list of nodes ids
2297 def AddPolygonalFace(self, IdsOfNodes):
2298 return self.editor.AddPolygonalFace(IdsOfNodes)
2300 ## Create volume both similar and quadratic (this is determed
2301 # by number of given nodes).
2302 # @param IdsOfNodes List of node IDs for creation of element.
2303 # Needed order of nodes in this list corresponds to description
2304 # of MED. \n This description is located by the following link:
2305 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2306 def AddVolume(self, IDsOfNodes):
2307 return self.editor.AddVolume(IDsOfNodes)
2309 ## Create volume of many faces, giving nodes for each face.
2310 # @param IdsOfNodes List of node IDs for volume creation face by face.
2311 # @param Quantities List of integer values, Quantities[i]
2312 # gives quantity of nodes in face number i.
2313 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2314 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2316 ## Create volume of many faces, giving IDs of existing faces.
2317 # @param IdsOfFaces List of face IDs for volume creation.
2319 # Note: The created volume will refer only to nodes
2320 # of the given faces, not to the faces itself.
2321 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2322 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2325 ## @brief Bind a node to a vertex
2326 # @param NodeID - node ID
2327 # @param Vertex - vertex or vertex ID
2328 # @return True if succeed else raise an exception
2329 def SetNodeOnVertex(self, NodeID, Vertex):
2330 if ( isinstance( Vertex, geompy.GEOM._objref_GEOM_Object)):
2331 VertexID = Vertex.GetSubShapeIndices()[0]
2335 self.editor.SetNodeOnVertex(NodeID, VertexID)
2336 except SALOME.SALOME_Exception, inst:
2337 raise ValueError, inst.details.text
2341 ## @brief Store node position on an edge
2342 # @param NodeID - node ID
2343 # @param Edge - edge or edge ID
2344 # @param paramOnEdge - parameter on edge where the node is located
2345 # @return True if succeed else raise an exception
2346 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2347 if ( isinstance( Edge, geompy.GEOM._objref_GEOM_Object)):
2348 EdgeID = Edge.GetSubShapeIndices()[0]
2352 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2353 except SALOME.SALOME_Exception, inst:
2354 raise ValueError, inst.details.text
2357 ## @brief Store node position on a face
2358 # @param NodeID - node ID
2359 # @param Face - face or face ID
2360 # @param u - U parameter on face where the node is located
2361 # @param v - V parameter on face where the node is located
2362 # @return True if succeed else raise an exception
2363 def SetNodeOnFace(self, NodeID, Face, u, v):
2364 if ( isinstance( Face, geompy.GEOM._objref_GEOM_Object)):
2365 FaceID = Face.GetSubShapeIndices()[0]
2369 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2370 except SALOME.SALOME_Exception, inst:
2371 raise ValueError, inst.details.text
2374 ## @brief Bind a node to a solid
2375 # @param NodeID - node ID
2376 # @param Solid - solid or solid ID
2377 # @return True if succeed else raise an exception
2378 def SetNodeInVolume(self, NodeID, Solid):
2379 if ( isinstance( Solid, geompy.GEOM._objref_GEOM_Object)):
2380 SolidID = Solid.GetSubShapeIndices()[0]
2384 self.editor.SetNodeInVolume(NodeID, SolidID)
2385 except SALOME.SALOME_Exception, inst:
2386 raise ValueError, inst.details.text
2389 ## @brief Bind an element to a shape
2390 # @param ElementID - element ID
2391 # @param Shape - shape or shape ID
2392 # @return True if succeed else raise an exception
2393 def SetMeshElementOnShape(self, ElementID, Shape):
2394 if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
2395 ShapeID = Shape.GetSubShapeIndices()[0]
2399 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2400 except SALOME.SALOME_Exception, inst:
2401 raise ValueError, inst.details.text
2405 ## Move node with given id
2406 # @param NodeID id of the node
2407 # @param x new X coordinate
2408 # @param y new Y coordinate
2409 # @param z new Z coordinate
2410 def MoveNode(self, NodeID, x, y, z):
2411 return self.editor.MoveNode(NodeID, x, y, z)
2413 ## Find a node closest to a point
2414 # @param x X coordinate of a point
2415 # @param y Y coordinate of a point
2416 # @param z Z coordinate of a point
2417 # @return id of a node
2418 def FindNodeClosestTo(self, x, y, z):
2419 preview = self.mesh.GetMeshEditPreviewer()
2420 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2422 ## Find a node closest to a point and move it to a point location
2423 # @param x X coordinate of a point
2424 # @param y Y coordinate of a point
2425 # @param z Z coordinate of a point
2426 # @return id of a moved node
2427 def MeshToPassThroughAPoint(self, x, y, z):
2428 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2430 ## Replace two neighbour triangles sharing Node1-Node2 link
2431 # with ones built on the same 4 nodes but having other common link.
2432 # @param NodeID1 first node id
2433 # @param NodeID2 second node id
2434 # @return false if proper faces not found
2435 def InverseDiag(self, NodeID1, NodeID2):
2436 return self.editor.InverseDiag(NodeID1, NodeID2)
2438 ## Replace two neighbour triangles sharing Node1-Node2 link
2439 # with a quadrangle built on the same 4 nodes.
2440 # @param NodeID1 first node id
2441 # @param NodeID2 second node id
2442 # @return false if proper faces not found
2443 def DeleteDiag(self, NodeID1, NodeID2):
2444 return self.editor.DeleteDiag(NodeID1, NodeID2)
2446 ## Reorient elements by ids
2447 # @param IDsOfElements if undefined reorient all mesh elements
2448 def Reorient(self, IDsOfElements=None):
2449 if IDsOfElements == None:
2450 IDsOfElements = self.GetElementsId()
2451 return self.editor.Reorient(IDsOfElements)
2453 ## Reorient all elements of the object
2454 # @param theObject is mesh, submesh or group
2455 def ReorientObject(self, theObject):
2456 return self.editor.ReorientObject(theObject)
2458 ## Fuse neighbour triangles into quadrangles.
2459 # @param IDsOfElements The triangles to be fused,
2460 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2461 # @param MaxAngle is a max angle between element normals at which fusion
2462 # is still performed; theMaxAngle is mesured in radians.
2463 # @return TRUE in case of success, FALSE otherwise.
2464 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2465 if IDsOfElements == []:
2466 IDsOfElements = self.GetElementsId()
2467 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2469 ## Fuse neighbour triangles of the object into quadrangles
2470 # @param theObject is mesh, submesh or group
2471 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2472 # @param MaxAngle is a max angle between element normals at which fusion
2473 # is still performed; theMaxAngle is mesured in radians.
2474 # @return TRUE in case of success, FALSE otherwise.
2475 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2476 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2478 ## Split quadrangles into triangles.
2479 # @param IDsOfElements the faces to be splitted.
2480 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2481 # @param @return TRUE in case of success, FALSE otherwise.
2482 def QuadToTri (self, IDsOfElements, theCriterion):
2483 if IDsOfElements == []:
2484 IDsOfElements = self.GetElementsId()
2485 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2487 ## Split quadrangles into triangles.
2488 # @param theObject object to taking list of elements from, is mesh, submesh or group
2489 # @param theCriterion is FT_...; used to choose a diagonal for splitting.
2490 def QuadToTriObject (self, theObject, theCriterion):
2491 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2493 ## Split quadrangles into triangles.
2494 # @param theElems The faces to be splitted
2495 # @param the13Diag is used to choose a diagonal for splitting.
2496 # @return TRUE in case of success, FALSE otherwise.
2497 def SplitQuad (self, IDsOfElements, Diag13):
2498 if IDsOfElements == []:
2499 IDsOfElements = self.GetElementsId()
2500 return self.editor.SplitQuad(IDsOfElements, Diag13)
2502 ## Split quadrangles into triangles.
2503 # @param theObject is object to taking list of elements from, is mesh, submesh or group
2504 def SplitQuadObject (self, theObject, Diag13):
2505 return self.editor.SplitQuadObject(theObject, Diag13)
2507 ## Find better splitting of the given quadrangle.
2508 # @param IDOfQuad ID of the quadrangle to be splitted.
2509 # @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
2510 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2511 # diagonal is better, 0 if error occurs.
2512 def BestSplit (self, IDOfQuad, theCriterion):
2513 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2515 ## Split quafrangle faces near triangular facets of volumes
2517 def SplitQuadsNearTriangularFacets(self):
2518 faces_array = self.GetElementsByType(SMESH.FACE)
2519 for face_id in faces_array:
2520 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2521 quad_nodes = self.mesh.GetElemNodes(face_id)
2522 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2523 isVolumeFound = False
2524 for node1_elem in node1_elems:
2525 if not isVolumeFound:
2526 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2527 nb_nodes = self.GetElemNbNodes(node1_elem)
2528 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2529 volume_elem = node1_elem
2530 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2531 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2532 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2533 isVolumeFound = True
2534 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2535 self.SplitQuad([face_id], False) # diagonal 2-4
2536 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2537 isVolumeFound = True
2538 self.SplitQuad([face_id], True) # diagonal 1-3
2539 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2540 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2541 isVolumeFound = True
2542 self.SplitQuad([face_id], True) # diagonal 1-3
2544 ## @brief Split hexahedrons into tetrahedrons.
2546 # Use pattern mapping functionality for splitting.
2547 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2548 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2549 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2550 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2551 # key-point will be mapped into <theNode001>-th node of each volume.
2552 # The (0,0,0) key-point of used pattern corresponds to not split corner.
2553 # @return TRUE in case of success, FALSE otherwise.
2554 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2555 # Pattern: 5.---------.6
2560 # (0,0,1) 4.---------.7 * |
2567 # (0,0,0) 0.---------.3
2568 pattern_tetra = "!!! Nb of points: \n 8 \n\
2578 !!! Indices of points of 6 tetras: \n\
2586 pattern = self.smeshpyD.GetPattern()
2587 isDone = pattern.LoadFromFile(pattern_tetra)
2589 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2592 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2593 isDone = pattern.MakeMesh(self.mesh, False, False)
2594 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2596 # split quafrangle faces near triangular facets of volumes
2597 self.SplitQuadsNearTriangularFacets()
2601 ## @brief Split hexahedrons into prisms.
2603 # Use pattern mapping functionality for splitting.
2604 # @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2605 # @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2606 # pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2607 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2608 # key-point will be mapped into <theNode001>-th node of each volume.
2609 # The edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2610 # @return TRUE in case of success, FALSE otherwise.
2611 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2612 # Pattern: 5.---------.6
2617 # (0,0,1) 4.---------.7 |
2624 # (0,0,0) 0.---------.3
2625 pattern_prism = "!!! Nb of points: \n 8 \n\
2635 !!! Indices of points of 2 prisms: \n\
2639 pattern = self.smeshpyD.GetPattern()
2640 isDone = pattern.LoadFromFile(pattern_prism)
2642 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2645 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2646 isDone = pattern.MakeMesh(self.mesh, False, False)
2647 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2649 # split quafrangle faces near triangular facets of volumes
2650 self.SplitQuadsNearTriangularFacets()
2655 # @param IDsOfElements list if ids of elements to smooth
2656 # @param IDsOfFixedNodes list of ids of fixed nodes.
2657 # Note that nodes built on edges and boundary nodes are always fixed.
2658 # @param MaxNbOfIterations maximum number of iterations
2659 # @param MaxAspectRatio varies in range [1.0, inf]
2660 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2661 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2662 MaxNbOfIterations, MaxAspectRatio, Method):
2663 if IDsOfElements == []:
2664 IDsOfElements = self.GetElementsId()
2665 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2666 MaxNbOfIterations, MaxAspectRatio, Method)
2668 ## Smooth elements belong to given object
2669 # @param theObject object to smooth
2670 # @param IDsOfFixedNodes list of ids of fixed nodes.
2671 # Note that nodes built on edges and boundary nodes are always fixed.
2672 # @param MaxNbOfIterations maximum number of iterations
2673 # @param MaxAspectRatio varies in range [1.0, inf]
2674 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2675 def SmoothObject(self, theObject, IDsOfFixedNodes,
2676 MaxNbOfIterations, MaxxAspectRatio, Method):
2677 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2678 MaxNbOfIterations, MaxxAspectRatio, Method)
2680 ## Parametric smooth the given elements
2681 # @param IDsOfElements list if ids of elements to smooth
2682 # @param IDsOfFixedNodes list of ids of fixed nodes.
2683 # Note that nodes built on edges and boundary nodes are always fixed.
2684 # @param MaxNbOfIterations maximum number of iterations
2685 # @param MaxAspectRatio varies in range [1.0, inf]
2686 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2687 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2688 MaxNbOfIterations, MaxAspectRatio, Method):
2689 if IDsOfElements == []:
2690 IDsOfElements = self.GetElementsId()
2691 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2692 MaxNbOfIterations, MaxAspectRatio, Method)
2694 ## Parametric smooth elements belong to given object
2695 # @param theObject object to smooth
2696 # @param IDsOfFixedNodes list of ids of fixed nodes.
2697 # Note that nodes built on edges and boundary nodes are always fixed.
2698 # @param MaxNbOfIterations maximum number of iterations
2699 # @param MaxAspectRatio varies in range [1.0, inf]
2700 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2701 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2702 MaxNbOfIterations, MaxAspectRatio, Method):
2703 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2704 MaxNbOfIterations, MaxAspectRatio, Method)
2706 ## Converts all mesh to quadratic one, deletes old elements, replacing
2707 # them with quadratic ones with the same id.
2708 def ConvertToQuadratic(self, theForce3d):
2709 self.editor.ConvertToQuadratic(theForce3d)
2711 ## Converts all mesh from quadratic to ordinary ones,
2712 # deletes old quadratic elements, \n replacing
2713 # them with ordinary mesh elements with the same id.
2714 def ConvertFromQuadratic(self):
2715 return self.editor.ConvertFromQuadratic()
2717 ## Renumber mesh nodes
2718 def RenumberNodes(self):
2719 self.editor.RenumberNodes()
2721 ## Renumber mesh elements
2722 def RenumberElements(self):
2723 self.editor.RenumberElements()
2725 ## Generate new elements by rotation of the elements around the axis
2726 # @param IDsOfElements list of ids of elements to sweep
2727 # @param Axix axis of rotation, AxisStruct or line(geom object)
2728 # @param AngleInRadians angle of Rotation
2729 # @param NbOfSteps number of steps
2730 # @param Tolerance tolerance
2731 # @param MakeGroups to generate new groups from existing ones
2732 def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
2733 if IDsOfElements == []:
2734 IDsOfElements = self.GetElementsId()
2735 if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
2736 Axix = self.smeshpyD.GetAxisStruct(Axix)
2738 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
2739 AngleInRadians, NbOfSteps, Tolerance)
2740 self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
2743 ## Generate new elements by rotation of the elements of object around the axis
2744 # @param theObject object wich elements should be sweeped
2745 # @param Axix axis of rotation, AxisStruct or line(geom object)
2746 # @param AngleInRadians angle of Rotation
2747 # @param NbOfSteps number of steps
2748 # @param Tolerance tolerance
2749 # @param MakeGroups to generate new groups from existing ones
2750 def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
2751 if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
2752 Axix = self.smeshpyD.GetAxisStruct(Axix)
2754 return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
2755 NbOfSteps, Tolerance)
2756 self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
2759 ## Generate new elements by extrusion of the elements with given ids
2760 # @param IDsOfElements list of elements ids for extrusion
2761 # @param StepVector vector, defining the direction and value of extrusion
2762 # @param NbOfSteps the number of steps
2763 # @param MakeGroups to generate new groups from existing ones
2764 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2765 if IDsOfElements == []:
2766 IDsOfElements = self.GetElementsId()
2767 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2768 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2770 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2771 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2774 ## Generate new elements by extrusion of the elements with given ids
2775 # @param IDsOfElements is ids of elements
2776 # @param StepVector vector, defining the direction and value of extrusion
2777 # @param NbOfSteps the number of steps
2778 # @param ExtrFlags set flags for performing extrusion
2779 # @param SewTolerance uses for comparing locations of nodes if flag
2780 # EXTRUSION_FLAG_SEW is set
2781 # @param MakeGroups to generate new groups from existing ones
2782 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance, MakeGroups=False):
2783 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2784 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2786 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2787 ExtrFlags, SewTolerance)
2788 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2789 ExtrFlags, SewTolerance)
2792 ## Generate new elements by extrusion of the elements belong to object
2793 # @param theObject object wich elements should be processed
2794 # @param StepVector vector, defining the direction and value of extrusion
2795 # @param NbOfSteps the number of steps
2796 # @param MakeGroups to generate new groups from existing ones
2797 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2798 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2799 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2801 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2802 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2805 ## Generate new elements by extrusion of the elements belong to object
2806 # @param theObject object wich elements should be processed
2807 # @param StepVector vector, defining the direction and value of extrusion
2808 # @param NbOfSteps the number of steps
2809 # @param MakeGroups to generate new groups from existing ones
2810 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2811 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2812 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2814 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2815 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2818 ## Generate new elements by extrusion of the elements belong to object
2819 # @param theObject object wich elements should be processed
2820 # @param StepVector vector, defining the direction and value of extrusion
2821 # @param NbOfSteps the number of steps
2822 # @param MakeGroups to generate new groups from existing ones
2823 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2824 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2825 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2827 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2828 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2831 ## Generate new elements by extrusion of the given elements
2832 # A path of extrusion must be a meshed edge.
2833 # @param IDsOfElements is ids of elements
2834 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2835 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2836 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2837 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2838 # @param Angles list of angles
2839 # @param HasRefPoint allows to use base point
2840 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2841 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2842 # @param MakeGroups to generate new groups from existing ones
2843 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2844 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2845 HasAngles, Angles, HasRefPoint, RefPoint,
2846 MakeGroups=False, LinearVariation=False):
2847 if IDsOfElements == []:
2848 IDsOfElements = self.GetElementsId()
2849 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2850 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2853 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(),
2854 PathShape, NodeStart, HasAngles,
2855 Angles, HasRefPoint, RefPoint)
2856 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape,
2857 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2859 ## Generate new elements by extrusion of the elements belong to object
2860 # A path of extrusion must be a meshed edge.
2861 # @param IDsOfElements is ids of elements
2862 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2863 # @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2864 # @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2865 # @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2866 # @param Angles list of angles
2867 # @param HasRefPoint allows to use base point
2868 # @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2869 # User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2870 # @param MakeGroups to generate new groups from existing ones
2871 # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
2872 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2873 HasAngles, Angles, HasRefPoint, RefPoint,
2874 MakeGroups=False, LinearVariation=False):
2875 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2876 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2878 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(),
2879 PathShape, NodeStart, HasAngles,
2880 Angles, HasRefPoint, RefPoint)
2881 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape,
2882 NodeStart, HasAngles, Angles, HasRefPoint,
2885 ## Symmetrical copy of mesh elements
2886 # @param IDsOfElements list of elements ids
2887 # @param Mirror is AxisStruct or geom object(point, line, plane)
2888 # @param theMirrorType is POINT, AXIS or PLANE
2889 # If the Mirror is geom object this parameter is unnecessary
2890 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2891 # @param MakeGroups to generate new groups from existing ones (if Copy)
2892 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2893 if IDsOfElements == []:
2894 IDsOfElements = self.GetElementsId()
2895 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2896 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2897 if Copy and MakeGroups:
2898 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2899 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2902 ## Symmetrical copy of object
2903 # @param theObject mesh, submesh or group
2904 # @param Mirror is AxisStruct or geom object(point, line, plane)
2905 # @param theMirrorType is POINT, AXIS or PLANE
2906 # If the Mirror is geom object this parameter is unnecessary
2907 # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2908 # @param MakeGroups to generate new groups from existing ones (if Copy)
2909 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2910 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2911 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2912 if Copy and MakeGroups:
2913 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2914 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2917 ## Translates the elements
2918 # @param IDsOfElements list of elements ids
2919 # @param Vector direction of translation(DirStruct or vector)
2920 # @param Copy allows to copy the translated elements
2921 # @param MakeGroups to generate new groups from existing ones (if Copy)
2922 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2923 if IDsOfElements == []:
2924 IDsOfElements = self.GetElementsId()
2925 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2926 Vector = self.smeshpyD.GetDirStruct(Vector)
2927 if Copy and MakeGroups:
2928 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2929 self.editor.Translate(IDsOfElements, Vector, Copy)
2932 ## Translates the object
2933 # @param theObject object to translate(mesh, submesh, or group)
2934 # @param Vector direction of translation(DirStruct or geom vector)
2935 # @param Copy allows to copy the translated elements
2936 # @param MakeGroups to generate new groups from existing ones (if Copy)
2937 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2938 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2939 Vector = self.smeshpyD.GetDirStruct(Vector)
2940 if Copy and MakeGroups:
2941 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2942 self.editor.TranslateObject(theObject, Vector, Copy)
2945 ## Rotates the elements
2946 # @param IDsOfElements list of elements ids
2947 # @param Axis axis of rotation(AxisStruct or geom line)
2948 # @param AngleInRadians angle of rotation(in radians)
2949 # @param Copy allows to copy the rotated elements
2950 # @param MakeGroups to generate new groups from existing ones (if Copy)
2951 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2952 if IDsOfElements == []:
2953 IDsOfElements = self.GetElementsId()
2954 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2955 Axis = self.smeshpyD.GetAxisStruct(Axis)
2956 if Copy and MakeGroups:
2957 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2958 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2961 ## Rotates the object
2962 # @param theObject object to rotate(mesh, submesh, or group)
2963 # @param Axis axis of rotation(AxisStruct or geom line)
2964 # @param AngleInRadians angle of rotation(in radians)
2965 # @param Copy allows to copy the rotated elements
2966 # @param MakeGroups to generate new groups from existing ones (if Copy)
2967 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2968 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2969 Axis = self.smeshpyD.GetAxisStruct(Axis)
2970 if Copy and MakeGroups:
2971 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2972 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2975 ## Find group of nodes close to each other within Tolerance.
2976 # @param Tolerance tolerance value
2977 # @param list of group of nodes
2978 def FindCoincidentNodes (self, Tolerance):
2979 return self.editor.FindCoincidentNodes(Tolerance)
2981 ## Find group of nodes close to each other within Tolerance.
2982 # @param Tolerance tolerance value
2983 # @param SubMeshOrGroup SubMesh or Group
2984 # @param list of group of nodes
2985 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2986 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2989 # @param list of group of nodes
2990 def MergeNodes (self, GroupsOfNodes):
2991 self.editor.MergeNodes(GroupsOfNodes)
2993 ## Find elements built on the same nodes.
2994 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2995 # @return a list of groups of equal elements
2996 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2997 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2999 ## Merge elements in each given group.
3000 # @param GroupsOfElementsID groups of elements for merging
3001 def MergeElements(self, GroupsOfElementsID):
3002 self.editor.MergeElements(GroupsOfElementsID)
3004 ## Remove all but one of elements built on the same nodes.
3005 def MergeEqualElements(self):
3006 self.editor.MergeEqualElements()
3009 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3010 FirstNodeID2, SecondNodeID2, LastNodeID2,
3011 CreatePolygons, CreatePolyedrs):
3012 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3013 FirstNodeID2, SecondNodeID2, LastNodeID2,
3014 CreatePolygons, CreatePolyedrs)
3016 ## Sew conform free borders
3017 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3018 FirstNodeID2, SecondNodeID2):
3019 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3020 FirstNodeID2, SecondNodeID2)
3022 ## Sew border to side
3023 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3024 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3025 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3026 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3028 ## Sew two sides of a mesh. Nodes belonging to Side1 are
3029 # merged with nodes of elements of Side2.
3030 # Number of elements in theSide1 and in theSide2 must be
3031 # equal and they should have similar node connectivity.
3032 # The nodes to merge should belong to sides borders and
3033 # the first node should be linked to the second.
3034 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3035 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3036 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3037 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3038 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3039 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3041 ## Set new nodes for given element.
3042 # @param ide the element id
3043 # @param newIDs nodes ids
3044 # @return If number of nodes is not corresponded to type of element - returns false
3045 def ChangeElemNodes(self, ide, newIDs):
3046 return self.editor.ChangeElemNodes(ide, newIDs)
3048 ## If during last operation of MeshEditor some nodes were
3049 # created this method returns list of its IDs, \n
3050 # if new nodes not created - returns empty list
3051 def GetLastCreatedNodes(self):
3052 return self.editor.GetLastCreatedNodes()
3054 ## If during last operation of MeshEditor some elements were
3055 # created this method returns list of its IDs, \n
3056 # if new elements not creared - returns empty list
3057 def GetLastCreatedElems(self):
3058 return self.editor.GetLastCreatedElems()