cfdmsh - python module for meshing of airfoil

Download cfdmsh - Python module for meshing of airfoil

If you can't read please download the document

Upload: apoorvs75

Post on 08-Nov-2015

101 views

Category:

Documents


15 download

DESCRIPTION

Python module for meshing of airfoil in Salome

TRANSCRIPT

"""+++++++++++ CFDMSH +++++++++++Python Library for CFD Meshing with Salome Platformhttp://www.vzlu.cz/en/results-transfer/software-r/free-software-downloadAuthor: Tougeron W. ([email protected])Last Modification: 18.06.2013Licence: GNU General Public License"""version="2.2.33"import salome, salome.geom.geomtoolsimport geompy, GEOMimport smesh, SMESHimport time#### Here are internal functions ####def GetSubShapeNames(salomeObject,output='name',isRecursive=True):subShapeList=[]childIterator=salome.myStudy.NewChildIterator(salomeObject)childIterator.InitEx(isRecursive)while(childIterator.More()):subObject=childIterator.Value()if subObject.GetAllAttributes():if output=='name':subShape=subObject.GetName()elif output=='ID':subShape=salome.ObjectToID(subObject.GetObject())else:subShape=NonesubShapeList.append(subShape)childIterator.Next()return subShapeListdef CheckObjectExistence(name,moduleName='GEOM'):# Make this function recursiveif isinstance(name,list):objectList=[]for subObject in name:objectList.append(CheckObjectExistence(subObject,moduleName))return objectList#-else:# Get the componentgeometryComponent=salome.myStudy.FindComponent(moduleName)#-# Get the existing namesnameList=GetSubShapeNames(geometryComponent)#-# Check the object existenceif name==None:return Noneelif name in nameList:return Trueelse:return False#-def GetNextNameIndex(name,moduleName='GEOM'):# Get the componentgeometryComponent=salome.myStudy.FindComponent(moduleName)#-# Get the existing namesnameList=GetSubShapeNames(geometryComponent)#-# Get the existing indexesexistingIndexes=[]for existingName in nameList:if existingName.find(name)!=-1:nameEnding=existingName.split(name)[1]try:index=int(nameEnding)existingIndexes.append(index)except:pass#-# Sort the existing indexes listexistingIndexes=list(set(existingIndexes))existingIndexes.sort()#-# Get the next indexi=1for existingIndex in existingIndexes:if existingIndex!=i:breaki+=1nextIndex=str(i)#-# Return the indexreturn nextIndex#-def AddToStudy(object,name="Geometrical Object",father=None,display=True):if isinstance(object,list):for subObject in object:AddToStudy(subObject,name)else:name+='_'index=GetNextNameIndex(name)name+=indexif father==None:id=geompy.addToStudy(object,name)else:id=geompy.addToStudyInFather(father,object,name)if display==True:gg=salome.ImportComponentGUI("GEOM")gg.createAndDisplayGO(id)else:if salome.sg.hasDesktop():salome.sg.updateObjBrowser(1)def GetObject(object,componentName='GEOM'):if isinstance(object,list):objectList=[]for subObject in object:objectList.append(GetObject(subObject,componentName))return objectListelse:if isinstance(object,str):if CheckObjectExistence(object,componentName):objectName=objectobject=salome.myStudy.FindObjectByName(objectName,componentName)[0].GetObject()else:print "[X] The object",object,"doesn't exist in the study tree."return "error"return objectdef GetSubShapes(shape):if isinstance(shape,list):returnList=[]for subShape in shape:returnList.append(GetSubShapes(subShape))return returnListelse:shapeVertexes=geompy.SubShapeAll(shape,geompy.ShapeType["VERTEX"])shapeEdges=geompy.SubShapeAll(shape,geompy.ShapeType["EDGE"])shapeFaces=geompy.SubShapeAll(shape,geompy.ShapeType["FACE"])shapeSolids=geompy.SubShapeAll(shape,geompy.ShapeType["SOLID"])return [shapeVertexes,shapeEdges,shapeFaces,shapeSolids,shape]def PrintDefinedFunctions():print """Defined Functions:> Geometry Module: + Measurement: - GeometricalEquality() + Basic Geometry Tools: * 1D: - ExtendSpline() - FuseSplines() - MakeMiddleSpline() - RebuildSpline() - SplitEdge() * 2D: - FuseCoplanarFaces() - RebuildFace() - RemoveFaceExtraEdges() + Viscous Layer Generation: * 2D: - MakeEdgeOffset() - ExtendViscousLayer() - CloseViscousLayer() - PropagateViscousLayerIntersection() * 3D: - MakeTipViscousLayer() - ExtendTipViscousLayer() - CloseTipViscousLayer() - MakeLinkingSolids() - GetBoundaryFaces() + Group Management: - GetTriEdgeFaces() - CopyGeometricalGroups() - ExportGeometricalGroups() - ImportGeometricalGroups()> Mesh Module: + Viscous Layer Meshing: - ViscousLayerScaleFactor() + Mesh Export: - ExportAmshFile() + Mesh Management: - ExportMeshConfiguration() - ImportMeshConfiguration()> Multi-module Functions: - RotateFlapGenerateAndExportMeshInAmshFormat()"""def PrintVersion():print "Version:"print version#### - ######## Here are cfdmsh functions ####def GeometricalEquality(shape1,shape2,tol=1e-7):"""Compares the shapes of two geometrical objects.Argument(s):Name Description Type Default Valueshape1 First geometrical object. / Its name in the study tree. Any geometrical object / String -shape2 Second geometrical object. / Its name in the study tree. Any geometrical object / String -tol Maximum difference allowed between all the shape parameters. Float 1e-7Returned Value(s):dim Value Type Number Name- Boolean 1 - """isEqual=False# Get the input shape(s)shapes=GetObject([shape1,shape2],'GEOM')#-if "error" in [shape1,shape2]:returnelse:# Check the centers of masscentersOfMass=[geompy.MakeCDG(shapes[0]),geompy.MakeCDG(shapes[1])]distance=geompy.MinDistance(centersOfMass[1],centersOfMass[0])#-if distancetol:break#-if i==len(basicProperties[0])-1:# If they are equal...# Check the inertia matricesinertiaMatrices=[geompy.Inertia(shapes[0]),geompy.Inertia(shapes[1])]for i in range(len(inertiaMatrices[0])):difference=abs(inertiaMatrices[1][i]-inertiaMatrices[0][i])if difference>tol:break#-if i==len(inertiaMatrices[0])-1:# If they are equal...# Say the shapes are equalisEqual=True#-# Return the resultreturn isEqual#-def ExtendSpline(edge,vertex,pos="auto",np=10,add=True,infa=False,dim=1):"""Extends an Edge to a Vertex position.Argument(s):Name Description Type Default Valueedge Curve to extend. / Its name in the study tree. Edge / String -vertex Vertex to reach. / Its name in the study tree. Vertex / String -pos If equals "before" or "after", the edge is extended from it start or its end respectivly (according to its orientation). If equals "auto", the function decides itself. String "auto"np See the documentation. Integer 10add See the documentation. Boolean Trueinfa See the documentation. Boolean Falsedim See the documentation. Integer 1Returned Value(s):dim Value Type Number Name0 Compound of Vertexes 1 "ExtendedSpline (Vertexes)"1 Edge 1 "ExtendedSpline""""if dim>1:returnelse:# Get the input shape(s)[edge,vertex]=GetObject([edge,vertex],'GEOM')father=Noneif infa==True:father=edge#-# Check the input shape existenceif "error" in [edge,vertex]:return#-else:# Get the sub-shapes[edge,vertex]=GetSubShapes([edge,vertex])#-# Check the positionif pos not in ["auto","before","after"]:pos="auto"#-# Get the pos of the user vertexif pos=="auto":vertexDistances=[geompy.MinDistance(vertex[-1],edge[0][0]),geompy.MinDistance(vertex[-1],edge[0][1])]pos="after"if vertexDistances[0] < vertexDistances[1]:pos="before"#-# Create the spline vertexessplineVertexes=[]if pos=="before":splineVertexes=[vertex[-1]]for parameter in [n/float(np) for n in range(np+1)]:splineVertex=geompy.MakeVertexOnCurve(edge[-1],parameter)splineVertexes.append(splineVertex)if pos=="after":splineVertexes.append(vertex[-1])#-if dim==0:# If the output dimension is 0...# Create the vertex compoundsplineVertexCompound=geompy.MakeCompound(splineVertexes)#-# Add and return the resulting shape(s)if add==True:AddToStudy(splineVertexCompound,"ExtendedSpline (Vertexes)",father)return splineVertexCompound#-else:# Create the extended splineextendedSpline=geompy.MakeInterpol(splineVertexes,False,False)#-# Add and return the resulting shape(s)if add==True:AddToStudy(extendedSpline,"ExtendedSpline",father)return extendedSpline#-def FuseSplines(edge1,edge2,np=10,add=True,dim=1):"""Fuses two Edges.Argument(s):Name Description Type Default Valueedge1 First spline to fuse. / Its name in the study tree. Edge / String -edge2 Second spline to fuse. / Its name in the study tree. Edge / String -np See the documentation. Integer 10add See the documentation. Boolean Truedim See the documentation. Integer 1Returned Value(s):dim Value Type Number Name0 Compound of Vertexes 1 "FusedSpline (Vertexes)"1 Edge 1 "FusedSpline"Conditions of Use:For better results, if coincident, both splines has to be as tangential as possible."""if dim>1:returnelse:# Get the input shape(s)edges=GetObject([edge1,edge2],'GEOM')#-# Check the input shape existenceif "error" in [edge1,edge2]:return#-else:# Extract the edge vertexes#### Here the extremum vertexes are created on curve#### and not exploded to be sure the vertex order#### respects the edge orientationedgeVertexes=[geompy.MakeVertexOnCurve(edges[0],0),geompy.MakeVertexOnCurve(edges[0],1),geompy.MakeVertexOnCurve(edges[1],0),geompy.MakeVertexOnCurve(edges[1],1)]####-#-# Determine the edge directionsminDistances=[geompy.MinDistance(edgeVertexes[0],edges[1]),geompy.MinDistance(edgeVertexes[1],edges[1]),geompy.MinDistance(edges[0],edgeVertexes[2]),geompy.MinDistance(edges[0],edgeVertexes[3])]reverseEdges=[False,False]if minDistances[0] < minDistances[1]:reverseEdges[0]=Trueif minDistances[2] > minDistances[3]:reverseEdges[1]=True#-# Split edge1fusedSplineVertexes=[]for parameter in [n/float(np) for n in range(np)]:if reverseEdges[0] == True:parameter=1-parameteredge1Vertex=geompy.MakeVertexOnCurve(edges[0],parameter)fusedSplineVertexes.append(edge1Vertex)#-# Split edge2for parameter in [n/float(np) for n in range(np+1)]:if reverseEdges[1] == True:parameter=1-parameteredge2Vertex=geompy.MakeVertexOnCurve(edges[1],parameter)fusedSplineVertexes.append(edge2Vertex)#-if dim==0:# If the output dimension is 0...# Create the vertex compoundfusedSplineVertexCompound=geompy.MakeCompound(fusedSplineVertexes)#-# Add and return the resulting shape(s)if add==True:AddToStudy(fusedSplineVertexCompound,"FusedSpline (Vertexes)")return fusedSplineVertexCompound#-else:# Create the fused edgefusedSpline=geompy.MakeInterpol(fusedSplineVertexes,False,False)#-# Add and return the resulting shape(s)if add==True:AddToStudy(fusedSpline,"FusedSpline")return fusedSpline#-def MakeMiddleSpline(edge1,edge2,np=10,add=True,dim=1):"""Creates a middle spline of two Edges.Argument(s):Name Description Type Default Valueedge1 First of the two edges between which build the middle edge. / Its name in the study tree. Edge / String -edge2 Second of the two edges between which build the middle edge. / Its name in the study tree. Edge / String -np See the documentation. Integer 10add See the documentation. Boolean Truedim See the documentation. Integer 1Returned Value(s):dim Value Type Number Name0 Compound of Vertexes 1 "MiddleSpline (Vertexes)"1 Edge 1 "MiddleSpline""""if dim>1:returnelse:# Get the input shape(s)edges=GetObject([edge1,edge2],'GEOM')#-# Check the input shape existenceif "error" in [edge1,edge2]:return#-else:# Get the sub-shapesedges=GetSubShapes(edges)#-# Get the offset edge senselinkingEdges=[geompy.MakeEdge(edges[0][0][0],edges[1][0][0]),geompy.MakeEdge(edges[0][0][0],edges[1][0][1])]linkingEdgeLengths=[geompy.BasicProperties(linkingEdges[0])[0],geompy.BasicProperties(linkingEdges[1])[0]]reverseParameter=Falseif linkingEdgeLengths[0]>linkingEdgeLengths[1]:reverseParameter=True#-# Create the pointsedgeVertexes=[[],[]]for parameter in [float(i)/(np-1) for i in range(np)]:edgeVertexes[0].append(geompy.MakeVertexOnCurve(edges[0][-1],parameter))if reverseParameter==True:parameter=1.0-parameteredgeVertexes[1].append(geompy.MakeVertexOnCurve(edges[1][-1],parameter))#-# Get the middle spline vertexesnbVertexes=len(edgeVertexes[0])middleVertexes=[]for i in range(nbVertexes):spline=geompy.MakeEdge(edgeVertexes[0][i],edgeVertexes[1][i])middleVertexes.append(geompy.MakeVertexOnCurve(spline,0.5))#-if dim==0:# If the output dimension is 0...# Create the vertex compoundmiddleVertexCompound=geompy.MakeCompound(middleVertexes)#-# Add and return the resulting shape(s)if add==True:AddToStudy(middleVertexCompound,"MiddleSpline (Vertexes)")return middleSpline#-else:# Create the middle splinemiddleSpline=geompy.MakeInterpol(middleVertexes)#-# Add and return the resulting shape(s)if add==True:AddToStudy(middleSpline,"MiddleSpline")return middleSpline#-def RebuildSpline(edge,np=10,add=True,infa=False,dim=1):"""Rebuilds an Edge with a certain number of Vertexes.Argument(s): Name Description Type Default Valueedge The edge to rebuild. / Its name in the study tree. Edge / String -np See the documentation. Integer 10add See the documentation. Boolean Trueinfa See the documentation. Boolean Falsedim See the documentation. Integer 1Returned Value(s):dim Value Type Number Name0 Compound of Vertexes 1 "FusedSpline (Vertexes)"1 Edge 1 "FusedSpline""""if dim>1:returnelse:# Make this function recursiveif isinstance(edge,list):returnList=[]for subObject in edge:returnList.append(RebuildSpline(subObject,np,add,infa,dim))return returnList#-else:# Get the input shape(s)edge=GetObject(edge,'GEOM')father=Noneif infa==True:father=edge#-# Check the input shape existenceif "error" in [edge]:return#-else:# Create the pointspoints=[]for parameter in [float(i)/(np-1) for i in range(np)]:points.append(geompy.MakeVertexOnCurve(edge,parameter))#-if dim==0:# If the output dimension is 0...# Create the vertex compoundpointCompound=geompy.MakeCompound(points)#-# Add and return the resulting shape(s)if add==True:AddToStudy(pointCompound,"RebuiltSpline (Vertexes)",father)return pointCompound#-else:# Create the edgerebuiltSpline=geompy.MakeInterpol(points)#-# Add and return the resulting shape(s)if add==True:AddToStudy(rebuiltSpline,"RebuiltSpline",father)return rebuiltSpline#-def SplitEdge(edge,np=10,add=True,infa=False,dim=1):"""Splits an edge into a wirSplits an edge into a wire.Argument(s): Name Description Type Default Valueedge Edge to split. / Its name in the study tree. Edge / String -np See the documentation. Integer 10add See the documentation. Boolean Trueinfa See the documentation. Boolean Falsedim See the documentation. Integer 1Returned Value(s): dim Value Type Number Name0 Compound of Vertexes 1 "SplitEdge (Vertexes)"1 Edge 1 "SplitEdge""""if dim>1:returnelse:# Make this function recursiveif isinstance(edge,list):returnList=[]for subObject in edge:returnList.append(SplitEdge(subObject,np,add,infa,dim))return returnList#-else:# Get the input shape(s)edge=GetObject(edge,'GEOM')father=Noneif infa==True:father=edge#-# Check the input shape existenceif "error" in [edge]:return#-else:# Create the pointspoints=[]for parameter in [float(i)/(np-1) for i in range(np)]:points.append(geompy.MakeVertexOnCurve(edge,parameter))#-if dim==0:# If the output dimension is 0...# Create the vertex compoundpointCompound=geompy.MakeCompound(points)#-# Add and return the resulting shape(s)if add==True:AddToStudy(pointCompound,"SplitEdge (Vertexes)",father)return pointCompound#-else:# Partition the edgepartition=geompy.MakePartition([edge],points)#-# Explode the partition in edgesedges=geompy.SubShapeAll(partition,geompy.ShapeType["EDGE"])#-# Create the wirewire=geompy.MakeWire(edges)#-# Add and return the resulting shape(s)if add==True:AddToStudy(wire,"SplitEdge",father)return wire#-def FuseCoplanarFaces(face1,face2,add=True):"""Completely fuses two coplanar Faces.Argument(s):Name Description Type Default Valueface1 First face to fuse. / Its name in the study tree. Face / String -face2 Second face to fuse. / Its name in the study tree. Face / String -add See the documentation. Boolean TrueReturned Value(s):dim Value Type Number Name- Face 1 "FusedFace""""# Get the input shape(s)faces=GetObject([face1,face2],'GEOM')#-# Check the input shape existenceif "error" in [face1,face2]:return#-else:# Get the plane normalnormal=geompy.GetNormal(faces[0])#-# Extrude the facesextrusionDistance=1e3cuttingPlanePosition=extrusionDistance/2extrudedFaces=[geompy.MakePrismVecH(faces[0],normal,extrusionDistance),geompy.MakePrismVecH(faces[1],normal,extrusionDistance)]#-# Fuse the extruded facesfusedExtension=geompy.MakeFuse(extrudedFaces[0],extrudedFaces[1])#-# Get the length of the cutting planeboundingBox=geompy.BoundingBox(fusedExtension)dx=abs(boundingBox[1]-boundingBox[0])dy=abs(boundingBox[2]-boundingBox[1])dz=abs(boundingBox[3]-boundingBox[2])planeLength=2*dx+2*dy+2*dz#-# Create the cutting planecuttingPlane=geompy.MakePlaneFace(faces[0],planeLength)cuttingPlane=geompy.MakeTranslationVectorDistance(cuttingPlane,normal,cuttingPlanePosition)#-# Cut the fused extrusion with the planefusedFace=geompy.MakeCommon(fusedExtension,cuttingPlane)#-# Remove shells (optional)randomVertex=geompy.MakeVertex(0,0,0)# This vertex is only used to make the below partition possiblefusedFace=geompy.MakePartition([fusedFace],[randomVertex],Limit=geompy.ShapeType["FACE"])#-# Move the face to the original positionfusedFace=geompy.MakeTranslationVectorDistance(fusedFace,normal,-cuttingPlanePosition)#-# Add and return the resulting shape(s)if add==True:AddToStudy(fusedFace,"FusedFace")return fusedFace#-def RebuildFace(face,np=30,rel=False,switch=False,tol=1e-7,add=True,infa=False,dim=2):"""Rebuilds a Face using its extrapolated iso-lines.Argument(s):Name Description Type Default Valueface The face to rebuild. / Its name in the study tree. Face / String -np See here. Integer 20rel If equals True, the function try to relimit the rebuild face using the source face edges. Boolean Falseswitch If equals True, the iso-curves are switched from iso-u to iso-v. Boolean Falsetol See here. Float 1e-7add See here. Boolean Trueinfa See here. Boolean Falsedim See here. Integer 2Returned Value(s):dim Value Type Number Name1 Compound of Edges 1 "RebuiltFace (Edges)"2 Edge 1 "RebuiltFace""""if dim==0 or dim==3:returnelse:# Make this function recursiveif isinstance(face,list):returnList=[]for subObject in face:returnList.append(RebuildFace(subObject,np,switch,add,infa,dim))return returnList#-else:# Get the input shape(s)face=GetObject(face,'GEOM')father=Noneif infa==True:father=face#-# Check the input shape existenceif "error" in [face]:return#-else:# Get the sub-shapesface=GetSubShapes(face)#-# Create the iso curvesisoCurves=[]for i in [n/float(np) for n in range(np+1)]:isoCurveVertexes=[]for j in [n/float(np) for n in range(np+1)]:if switch==True:newIsoCurveVertex=geompy.MakeVertexOnSurface(face[-1],j,i)else:newIsoCurveVertex=geompy.MakeVertexOnSurface(face[-1],i,j)isoCurveVertexes.append(newIsoCurveVertex)newIsoCurve=geompy.MakeInterpol(isoCurveVertexes)isoCurves.append(newIsoCurve)#-# Put them into a compoundisoCurveCompound=geompy.MakeCompound(isoCurves)#-if dim==1:# If the output dimension is 1...# Add and return the resulting shape(s)if add==True:AddToStudy(isoCurveCompound,"RebuiltFace (Edges)",father)return isoCurveCompound#-else:# Create the filling from this compoundfilling=geompy.MakeFilling(isoCurveCompound,theMinDeg = 10,theMaxDeg = 20,theTol2D=1e-5,theTol3D=1e-5)#-# Relimitate the fillingrebuildFace=fillingif rel==True:projectedEdges=[]for edge in face[1]:try:projectedEdge=geompy.MakeProjection(edge,filling)projectedEdges.append(projectedEdge)except:passif len(projectedEdges)>0:fillingPartition=geompy.MakePartition([filling],projectedEdges)fillingPartitionFaces=geompy.SubShapeAll(fillingPartition,geompy.ShapeType["FACE"])for fillingPartitionFace in fillingPartitionFaces:fillingPartitionFaceVertexes=geompy.SubShapeAll(fillingPartitionFace,geompy.ShapeType["VERTEX"])match=Truefor fillingPartitionFaceVertex in fillingPartitionFaceVertexes:projectedEdgeCompound=geompy.MakeCompound(projectedEdges)minDistance=geompy.MinDistance(fillingPartitionFaceVertex,projectedEdgeCompound)if minDistance>tol:match=Falseif match==True:rebuildFace=fillingPartitionFacebreak#-# Add and return the resulting shape(s)if add==True:AddToStudy(rebuildFace,"RebuiltFace",father)return filling#-def RemoveFaceExtraEdges(face,tol=1e-7,add=True,infa=False):"""Does the same as the geompy.RemoveExtraEdges function of Salome (Repair > Remove Extra Edges) but applies on a Face instead of on a Solid.Argument(s): Name Description Type Default Valueface Face from which remove extra edges. / Its name in the study tree. Face / String -tol See the documentation. Float 1e-7add See the documentation. Boolean Trueinfa See the documentation. Boolean FalseReturned Value(s):dim Value Type Number Name- Face 1 "FaceWithoutExtraEdges""""# Make this function recursiveif isinstance(face,list):returnList=[]for subObject in face:returnList.append(RemoveFaceExtraEdges(subObject,add,infa))return returnList#-else:# Get the input shape(s)face=GetObject(face,'GEOM')father=Noneif infa==True:father=face#-# Check the input shape existenceif "error" in [face]:return#-else:# Get the face normalnormal=geompy.GetNormal(face)#-# Etrude the faceNameextrudedFace=geompy.MakePrismVecH(face,normal,1000)#-# Remove the extra edgesfixedSolid=geompy.RemoveExtraEdges(extrudedFace)#-# Get the facesexplodedFaces=geompy.SubShapeAll(fixedSolid,geompy.ShapeType["FACE"])#-# Get the fixed facefor explodedFace in explodedFaces:vertexes=geompy.SubShapeAll(explodedFace,geompy.ShapeType["VERTEX"])match=Truefor vertex in vertexes:minDistance=geompy.MinDistance(vertex,face)if minDistance>tol:match=Falseif match==True:fixedFace=explodedFacebreak#-# Add and return the resulting shape(s)if add==True:AddToStudy(fixedFace,"FaceWithoutExtraEdges",father)return fixedFace#-def MakeEdgeOffset(edge,dist,pos=[0,1],face=None,plane=None,np=50,tol=1e-7,rev=False,add=True,infa=False,dim=1):"""Creates an offset of an Edge.Argument(s):Name Description Type Default Valueedge Source curve. / Its name in the study tree. Edge / String -dist Offset distance. Must be an array to create a variable offset. Float / Array of Floats -pos Positions on the source edge (0 < pos < 1). Only necessary if the dist argument is an array. Array of Floats [0,1]face See the documentation. Face / String Noneplane See the documentation. If the input edge is straight, the default plane is the OXY plane. Face / String Nonenp See the documentation. Integer 50tol See the documentation. Float 1e-7rev See the documentation. Boolean Falseadd See the documentation. Boolean Trueinfa See the documentation. Boolean Falsedim See the documentation. Integer 1Returned Value(s):dim Value Type Number Name0 Compound of Vertexes 1 "Offset (Vertexes)"1 Compound of Edges 1 "Offset"Conditions of Use:The input edge has to be open.In addition, if the input edge is straight, it is also necessary to set the face or the plane argument so as the function knows the offset direction"""if dim>1:returnelse:# Make this function recursiveif isinstance(edge,list):returnList=[]for subObject in edge:returnList.append(MakeEdgeOffset(subObject,dist,pos,face,plane,np,rev,add,infa,dim))return returnList#-else:# Get the input shape(s)[edge,face,plane]=GetObject([edge,face,plane],'GEOM')father=Noneif infa==True:father=edge#-# Check the input shape existenceif "error" in [edge,face,plane]:return#-else:# Get the sub-shapesedge=GetSubShapes(edge)#-offsetEdges=[]if face==None:# If no face is given by the user...if plane==None:# And if no plane is given by the user...# Close the input edgeclosingEdge=geompy.MakeEdge(edge[0][0],edge[0][1])closedContour=geompy.MakeWire([edge[-1],closingEdge])#-if abs(geompy.BasicProperties(closingEdge)[0]-geompy.BasicProperties(edge[-1])[0])=pos[i] and parameter 0:# If so...# Write the shape flaghypothesisFile.write("SHAPE:\n")#-for shapeHypothesis in shapeHypotheses:# For each shape hypothesis...# Get the hypothesis nameshapeHypothesisName=smesh.GetName(shapeHypothesis)#-# Write the hypothesishypothesisFile.write("%s\n"%(shapeHypothesisName))#-# Get the shape groupsmeshShapeGroups=geompy.GetGroups(meshShape)#-for group in meshShapeGroups:# For each group...# Get the group namegroupName=group.GetName()#-# Get the hypothesis listgroupHypotheses=mesh.GetHypothesisList(group)#-# Check if hypotheses are associated to the groupnbGroupHypotheses=len(groupHypotheses)#-if nbGroupHypotheses > 0:# If so...# Write the group namehypothesisFile.write("SUBMESH:%s\n"%(groupName))#-for groupHypothesis in groupHypotheses:# For each hypothesis...# Get the hypothesis namegroupHypothesisName=smesh.GetName(groupHypothesis)#-# Write the hypothesishypothesisFile.write("%s\n"%(groupHypothesisName))#-# Get the mesh groupsmeshGroups=mesh.GetGroups()#-# Check if there are mesh groupsnbMeshGroups=len(meshGroups)#-if nbMeshGroups > 0:# If so...# Write the group flaghypothesisFile.write("GROUPS:")#-for meshGroup in meshGroups:# For each mesh group...# Get the mesh group namemeshGroupName=meshGroup.GetName()#-# Write the mesh group namehypothesisFile.write("%s\t"%(meshGroupName))#-# Close hypothesis filehypothesisFile.close()#-def ImportMeshConfiguration(mesh='Mesh_1',file='mesh'):"""Imports into a mesh algorithms, hypotheses and group names rom a file created with the ExportMeshConfiguration function.Argument(s):Name Description Type Default Valuemesh The target mesh. / Its name in the study tree. Mesh / String "Mesh_1"file Name of the file to read. String "mesh"Conditions of Use:All the hypotheses and algorithms present in the file has to be also present in the study. Also, there must be, in the geometrical object associated to the target mesh, groups having the same name as the groups present in the file. """# Get the input meshmesh=GetObject(mesh,'SMESH')#-# Check the input shape existenceif "error" in [mesh]:return#-else:if "