# group is updated at modification of the filter
filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
filtIDs3 = filtGroup.GetIDs()
- print "After filter modification, group on filter contains %s elemens" % filtGroup.Size()
+ print("After filter modification, group on filter contains %s elemens" % filtGroup.Size())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
j = 1
for i in range(len(aGroupElemIDs)):
- if j > 20: j = 1; print ""
- print aGroupElemIDs[i],
+ if j > 20: j = 1; print("")
+ print(aGroupElemIDs[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# create union group : area >= 20 and area < 20
aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
- print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
+ print("Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID()))
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# create an intersection of groups : 20 < area < 60
aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
- print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
+ print("Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID()))
# Please note that also there is IntersectGroups() method which works with two groups only
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# create a cut of groups : area >= 60
aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
- print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
+ print("Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID()))
# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# inverse the diagonal bb[1] - tt[2]
- print "\nDiagonal inversion ... ",
+ print("\nDiagonal inversion ... ", end=' ')
res = mesh.InverseDiag(bb[1], tt[2])
- if not res: print "failed!"
- else: print "done."
+ if not res: print("failed!")
+ else: print("done.")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# delete the diagonal bb[1] - tt[2]
- print "\nUnite two triangles ... ",
+ print("\nUnite two triangles ... ", end=' ')
res = mesh.DeleteDiag(bb[1], tt[2])
- if not res: print "failed!"
- else: print "done."
+ if not res: print("failed!")
+ else: print("done.")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# unite a set of triangles
- print "\nUnite a set of triangles ... ",
+ print("\nUnite a set of triangles ... ", end=' ')
res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.)
- if not res: print "failed!"
- else: print "done."
+ if not res: print("failed!")
+ else: print("done.")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)
res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH)
- print "\nSmoothing ... ",
- if not res: print "failed!"
- else: print "done."
+ print("\nSmoothing ... ", end=' ')
+ if not res: print("failed!")
+ else: print("done.")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
+ print("Criterion: Edges length > ", length_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
+ aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + repr(length_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
aGroup.Add(anNodeIds)
# print the result
- print "Criterion: Free nodes Nb = ", len(anNodeIds)
+ print("Criterion: Free nodes Nb = ", len(anNodeIds))
j = 1
for i in range(len(anNodeIds)):
- if j > 20: j = 1; print ""
- print anNodeIds[i],
+ if j > 20: j = 1; print("")
+ print(anNodeIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
+ print("Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + `length_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + repr(length_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
+ print("Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + repr(nb_conn))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
+ print("Criterion: Area > ", area_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + `area_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + repr(area_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
+ print("Criterion: Taper > ", taper_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + `taper_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + repr(taper_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
+ print("Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + `ar_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + repr(ar_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
+ print("Criterion: Skew > ", skew_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + `skew_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + repr(skew_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds)
+ print("Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + `mel_2d_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + repr(mel_2d_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
- print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds)
+ print("Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
+ if j > 20: j = 1; print("")
+ print(anIds[i], end=' ')
j = j + 1
pass
- print ""
+ print("")
# create a group
- aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + `mel_3d_margin`)
+ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + repr(mel_3d_margin))
aGroup.Add(anIds)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# merge elements
trias.MergeEqualElements()
- print "Number of elements after MergeEqualElements:"
- print "Edges : ", trias.NbEdges()
- print "Triangles : ", trias.NbTriangles()
- print "Quadrangles: ", trias.NbQuadrangles()
- print "Volumes : ", trias.NbVolumes()
+ print("Number of elements after MergeEqualElements:")
+ print("Edges : ", trias.NbEdges())
+ print("Triangles : ", trias.NbTriangles())
+ print("Quadrangles: ", trias.NbQuadrangles())
+ print("Volumes : ", trias.NbVolumes())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile )
- aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( aStudy->URL() ).c_str() );
- aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(myCurrentStudy->URL()) ).c_str() );
++ aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(aStudy->URL()) ).c_str() );
// Set names of temporary files
TCollection_AsciiString filename =
( char* )( isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir().c_str() );
// Convert the stream into sequence of files to process
- SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
- tmpDir.ToCString(),
- isMultiFile );
+ SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
+ tmpDir.ToCString(),
+ isMultiFile );
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile ) {
- CORBA::String_var url = aStudy->URL();
- aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( url.in() ).c_str();
- CORBA::WString_var url = myCurrentStudy->URL();
++ CORBA::WString_var url = aStudy->URL();
+ aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(url.in()) ).c_str();
}
// Set names of temporary files
TCollection_AsciiString filename = tmpDir + aStudyName + "_SMESH.hdf";
smesh.SetName(hypArea200, "Max. Element Area")
- print "---------------------Compute the mesh"
+ print("---------------------Compute the mesh")
ret = mesh.Compute()
- print ret
+ print(ret)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE)
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE)
- print "Create aGroupOnShell - a group linked to a shell"
+ print("Create aGroupOnShell - a group linked to a shell")
aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", SMESH.EDGE)
- print "aGroupOnShell type =", aGroupOnShell.GetType()
- print "aGroupOnShell size =", aGroupOnShell.Size()
- print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
+ print("aGroupOnShell type =", aGroupOnShell.GetType())
+ print("aGroupOnShell size =", aGroupOnShell.Size())
+ print("aGroupOnShell ids :", aGroupOnShell.GetListOfID())
- print " "
+ print(" ")
- print "Modify <LocalLength> hypothesis: 100 -> 50"
+ print("Modify <LocalLength> hypothesis: 100 -> 50")
hypLen1.SetLength(50)
- print "Contents of aGroupOnShell changes:"
- print "aGroupOnShell size =", aGroupOnShell.Size()
- print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
+ print("Contents of aGroupOnShell changes:")
+ print("aGroupOnShell size =", aGroupOnShell.Size())
+ print("aGroupOnShell ids :", aGroupOnShell.GetListOfID())
- print " "
+ print(" ")
- print "Re-compute mesh, contents of aGroupOnShell changes again:"
+ print("Re-compute mesh, contents of aGroupOnShell changes again:")
mesh.Compute()
- print "aGroupOnShell size =", aGroupOnShell.Size()
- print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
+ print("aGroupOnShell size =", aGroupOnShell.Size())
+ print("aGroupOnShell ids :", aGroupOnShell.GetListOfID())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume))
- print "-------------------------- compute the mesh of the mechanic piece"
+ print("-------------------------- compute the mesh of the mechanic piece")
mesh.Compute()
- print "Information about the Nut:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of quadrangles : ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print("Information about the Nut:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of quadrangles : ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
if ret != 0:
log=mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the Mesh_mechanic:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print(linelog)
+ print("Information about the Mesh_mechanic:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
else:
- print "problem when computing the mesh"
+ print("problem when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the MeshBox2:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print(linelog)
+ print("Information about the MeshBox2:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
else:
- print "probleme when computing the mesh"
+ print("probleme when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the MeshBox3:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print(linelog)
+ print("Information about the MeshBox3:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
else:
- print "probleme when computing the mesh"
+ print("probleme when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the MeshBox:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print(linelog)
+ print("Information about the MeshBox:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
else:
- print "probleme when computing the mesh"
+ print("probleme when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
- print "-------------------------- compute the mesh of the volume"
+ print("-------------------------- compute the mesh of the volume")
ret=mesh.Compute()
## log=mesh.GetLog(0) # no erase trace
## for linelog in log:
## print linelog
- print "Information about the MeshBox :"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print("Information about the MeshBox :")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
else:
- print "problem when Computing the mesh"
+ print("problem when Computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
- print "number of Shells in compshell : ", len(subShellList)
- print "number of Faces in compshell : ", len(subFaceList)
- print "number of Edges in compshell : ", len(subEdgeList)
+ print("number of Shells in compshell : ", len(subShellList))
+ print("number of Faces in compshell : ", len(subFaceList))
+ print("number of Edges in compshell : ", len(subEdgeList))
status = geompy.CheckShape(compshell)
- print " check status ", status
+ print(" check status ", status)
### ---------------------------- SMESH --------------------------------------
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
# ---- init a Mesh with the compshell
shape_mesh = salome.IDToObject( idcomp )
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the MeshcompShel:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of quadrangles : ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of hexahedrons : ", mesh.NbHexas()
+ print(linelog)
+ print("Information about the MeshcompShel:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of quadrangles : ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of hexahedrons : ", mesh.NbHexas())
else:
- print "problem when Computing the mesh"
+ print("problem when Computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
- print "number of Shells in compshell : ", len(subShellList)
- print "number of Faces in compshell : ", len(subFaceList)
- print "number of Edges in compshell : ", len(subEdgeList)
+ print("number of Shells in compshell : ", len(subShellList))
+ print("number of Faces in compshell : ", len(subFaceList))
+ print("number of Edges in compshell : ", len(subEdgeList))
status = geompy.CheckShape(compshell)
- print " check status ", status
+ print(" check status ", status)
### ---------------------------- SMESH --------------------------------------
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
- print "-------------------------- create Mesh, algorithm, hypothesis"
+ print("-------------------------- create Mesh, algorithm, hypothesis")
mesh = smesh.Mesh(compshell, "MeshcompShel");
netgen = mesh.Tetrahedron(smeshBuilder.FULL_NETGEN)
netgen.SetFineness( smeshBuilder.Fine )
#netgen.SetOptimize( 1 )
- print "-------------------------- compute mesh"
+ print("-------------------------- compute mesh")
ret = mesh.Compute()
- print ret
+ print(ret)
if ret != 0:
- print "Information about the MeshcompShel:"
- print "Number of nodes : ", mesh.GetMesh().NbNodes()
- print "Number of edges : ", mesh.GetMesh().NbEdges()
- print "Number of faces : ", mesh.GetMesh().NbFaces()
- print "Number of triangles : ", mesh.GetMesh().NbTriangles()
- print "Number of volumes : ", mesh.GetMesh().NbVolumes()
- print "Number of tetrahedrons : ", mesh.GetMesh().NbTetras()
+ print("Information about the MeshcompShel:")
+ print("Number of nodes : ", mesh.GetMesh().NbNodes())
+ print("Number of edges : ", mesh.GetMesh().NbEdges())
+ print("Number of faces : ", mesh.GetMesh().NbFaces())
+ print("Number of triangles : ", mesh.GetMesh().NbTriangles())
+ print("Number of volumes : ", mesh.GetMesh().NbVolumes())
+ print("Number of tetrahedrons : ", mesh.GetMesh().NbTetras())
else:
- print "problem when computing the mesh"
+ print("problem when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
- print "number of Shells in compshell : ", len(subShellList)
- print "number of Faces in compshell : ", len(subFaceList)
- print "number of Edges in compshell : ", len(subEdgeList)
+ print("number of Shells in compshell : ", len(subShellList))
+ print("number of Faces in compshell : ", len(subFaceList))
+ print("number of Edges in compshell : ", len(subEdgeList))
status = geompy.CheckShape(compshell)
- print " check status ", status
+ print(" check status ", status)
### ---------------------------- SMESH --------------------------------------
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
# ---- init a Mesh with the compshell
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the MeshcompShel:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons : ", mesh.NbTetras()
+ print(linelog)
+ print("Information about the MeshcompShel:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons : ", mesh.NbTetras())
else:
- print "problem when computing the mesh"
+ print("problem when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
if ret != 0:
log = mesh.GetLog(0) # no erase trace
for linelog in log:
- print linelog
- print "Information about the Mesh_mechanic_tetra:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of volumes : ", mesh.NbVolumes()
+ print(linelog)
+ print("Information about the Mesh_mechanic_tetra:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
else:
- print "probleme when computing the mesh"
+ print("probleme when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
anIds = aGroup.GetIDs()
# print result
- print "Criterion: Free edges Nb = ", len( anIds )
+ print("Criterion: Free edges Nb = ", len( anIds ))
for i in range( len( anIds ) ):
- print anIds[ i ]
+ print(anIds[ i ])
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# -----------------------------------------------------------------------------
- print "-------------------------- mesh"
+ print("-------------------------- mesh")
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
# ---- define a mesh on the geom shape 'blob'
mesh=smesh.Mesh(blob, "MeshBlob")
pass
# ---- compute mesh
- print "-------------------------- compute mesh"
+ print("-------------------------- compute mesh")
ok = mesh.Compute()
if ok:
- print "Information about the Mesh:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of quadrangles : ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of hexahedrons : ", mesh.NbHexas()
+ print("Information about the Mesh:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of quadrangles : ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of hexahedrons : ", mesh.NbHexas())
else:
- print "problem when Computing the mesh"
+ print("problem when Computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
mesh.Compute()
- print "Information about the Mesh_mechanic:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of quadrangles : ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print("Information about the Mesh_mechanic:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of quadrangles : ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
netgen.SetQuadAllowed( 1 )
#netgen.SetOptimize( 1 )
- print "-------------------------- compute mesh"
+ print("-------------------------- compute mesh")
ret = mesh.Compute()
- print ret
+ print(ret)
if ret != 0:
- print "Information about the MeshcompShel:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of quadrangles : ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons : ", mesh.NbTetras()
+ print("Information about the MeshcompShel:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of quadrangles : ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons : ", mesh.NbTetras())
else:
- print "problem when computing the mesh"
+ print("problem when computing the mesh")
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
smesh.SetName(hypVolume, "maxElementVolume_" + str(maxElementVolume))
- print "-------------------------- compute the mesh of the mechanic piece"
+ print("-------------------------- compute the mesh of the mechanic piece")
mesh.Compute()
- print "Information about the Mesh_mechanic_tetra:"
- print "Number of nodes : ", mesh.NbNodes()
- print "Number of edges : ", mesh.NbEdges()
- print "Number of faces : ", mesh.NbFaces()
- print "Number of triangles : ", mesh.NbTriangles()
- print "Number of quadrangles: ", mesh.NbQuadrangles()
- print "Number of volumes : ", mesh.NbVolumes()
- print "Number of tetrahedrons: ", mesh.NbTetras()
+ print("Information about the Mesh_mechanic_tetra:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of quadrangles: ", mesh.NbQuadrangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
for f in subShapeList:
name = geompy.SubShapeName(f, box)
- print name
+ print(name)
idedge.append( geompy.addToStudyInFather(box, f, name) )
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# ---- launch SMESH
smeshgui = salome.ImportComponentGUI("SMESH")
i1 = a.indexes[ii]
ii = ii+1
i2 = a.indexes[ii]
- print i2
+ print(i2)
ii = ii+1
- print "ii", ii
+ print("ii", ii)
i3 = a.indexes[ii]
- print i3
+ print(i3)
#ii = ii+1
ii = ii+1
- print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
+ print("AddTriangle %i - %i %i %i" % (ind, i1, i2, i3))
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
edge = edgeList[0]
name = geompy.SubShapeName(edge, face)
- print name
+ print(name)
idedge = geompy.addToStudyInFather(face, edge, name)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
mesh.Compute()
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
sg = salome.ImportComponentGUI('SMESH')
- if type(sg) != type(salome.salome_ComponentGUI):
+ if not isinstance(sg, type(salome.salome_ComponentGUI)):
sg.CreateAndDisplayActor('0:1:2:3')
# ---- compute box
- print "-------------------------- compute box"
+ print("-------------------------- compute box")
ret = mesh.Compute()
- print ret
+ print(ret)
log = mesh.GetLog(0); # no erase trace
for linelog in log:
- print linelog
+ print(linelog)
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# Values
# ------
- print "Output directory:", tmpDir
+tmpDir = os.getenv('SALOME_TMP_DIR', '/tmp')
++print("Output directory:", tmpDir)
+
# Path for ".med" files
-path = "/tmp/ex29_%s_" % os.getenv('USER','unknown')
+path = os.path.join( tmpDir, "ex29_%s_" % os.getenv('USER','unknown'))
# Name of the shape and the mesh
name = "Carre"
try:
# get instance of class smeshBuilder
engineSmesh = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
- smesh = smeshBuilder.New(salome.myStudy, engineSmesh)
+ smesh = smeshBuilder.New(True,engineSmesh)
except:
- print "exception in smesh.py: instance creation failed"
+ print("exception in smesh.py: instance creation failed")
smesh = None
pass
# Check that Threshold is a group
if isinstance(aThreshold, SMESH._objref_SMESH_GroupBase):
if aThreshold.GetType() != elementType:
- raise ValueError, "Group type mismatches Element type"
+ raise ValueError("Group type mismatches Element type")
aCriterion.ThresholdStr = aThreshold.GetName()
aCriterion.ThresholdID = salome.orb.object_to_string( aThreshold )
- study = self.GetCurrentStudy()
+ study = salome.myStudy
if study:
so = study.FindObjectIOR( aCriterion.ThresholdID )
if so:
global doLcc
engine = instance
if engine is None:
- doLcc = True
+ doLcc = True
smeshInst = smeshBuilder()
assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__
- smeshInst.init_smesh(study)
+ smeshInst.init_smesh(isPublished)
return smeshInst
else: msg += " has not been computed"
if allReasons != "": msg += ":"
else: msg += "."
- print msg
- print allReasons
+ print(msg)
+ print(allReasons)
pass
- if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
+ if salome.sg.hasDesktop():
if not isinstance( refresh, list): # not a call from subMesh.Compute()
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
return ok
# Create an instance of algorithm
def __call__(self,algo="",geom=0,*args):
- algoType = self.defaultAlgoType
- for arg in args + (algo,geom):
- if isinstance( arg, geomBuilder.GEOM._objref_GEOM_Object ):
- geom = arg
- if isinstance( arg, str ) and arg:
+ algoType = ""
+ shape = 0
+ if isinstance( algo, str ):
+ algoType = algo
+ elif ( isinstance( algo, geomBuilder.GEOM._objref_GEOM_Object ) and \
+ not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object )):
+ shape = algo
+ elif algo:
+ args += (algo,)
+
+ if isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ):
+ shape = geom
+ elif not algoType and isinstance( geom, str ):
+ algoType = geom
+ elif geom:
+ args += (geom,)
+ for arg in args:
+ if isinstance( arg, geomBuilder.GEOM._objref_GEOM_Object ) and not shape:
+ shape = arg
+ elif isinstance( arg, str ) and not algoType:
algoType = arg
+ else:
+ import traceback, sys
+ msg = "Warning. Unexpected argument in mesh.%s() ---> %s" % ( self.method, arg )
+ sys.stderr.write( msg + '\n' )
+ tb = traceback.extract_stack(None,2)
+ traceback.print_list( [tb[0]] )
+ if not algoType:
+ algoType = self.defaultAlgoType
if not algoType and self.algoTypeToClass:
- algoType = self.algoTypeToClass.keys()[0]
- if self.algoTypeToClass.has_key( algoType ):
+ algoType = list(self.algoTypeToClass.keys())[0]
+ if algoType in self.algoTypeToClass:
#print "Create algo",algoType
- return self.algoTypeToClass[ algoType ]( self.mesh, geom )
- raise RuntimeError("No class found for algo type %s" % algoType)
++
+ return self.algoTypeToClass[ algoType ]( self.mesh, shape )
- raise RuntimeError, "No class found for algo type %s" % algoType
++ raise RuntimeError( "No class found for algo type %s" % algoType)
return None
## Private class used to substitute and store variable parameters of hypotheses.
if k[0] == '_': continue
algo = getattr( plugin, k )
#print " algo:", str(algo)
- if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod" ):
+ if inspect.isclass(algo) and hasattr(algo, "meshMethod"):
#print " meshMethod:" , str(algo.meshMethod)
if not hasattr( Mesh, algo.meshMethod ):
- setattr( Mesh, algo.meshMethod, algoCreator() )
+ setattr( Mesh, algo.meshMethod, algoCreator( algo.meshMethod ))
pass
getattr( Mesh, algo.meshMethod ).add( algo )
pass
ACmt = myBuilder.FindOrCreateAttribute(myObject, "AttributeComment")
ACmt.SetValue(datai)
- if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(False)
+ if salome.sg.hasDesktop(): salome.sg.updateObjBrowser()
self.num += 1
- if verbose: print("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai))
+ if verbose: print(("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai)))
return True
def PBSaveHypPressed(self):
notebook.set("MGCleaner_%i" % self.num, data)
"""
- if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(False)
+ if salome.sg.hasDesktop(): salome.sg.updateObjBrowser()
self.num += 1
- if verbose: print("save %s in Object Browser done:\n%s" % (name, data))
+ if verbose: print(("save %s in Object Browser done:\n%s" % (name, data)))
return True
def SP_toStr(self, widget):
import sys,os
import salome
- from getStats import getGroupesRef
- from Type_Maille import dicoDimENtite
+ from .getStats import getGroupesRef
+ from .Type_Maille import dicoDimENtite
-def getCritere(dim,NomMesh,acritere,theStudy):
+def getCritere(dim,NomMesh,acritere):
import SMESH
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(theStudy)
+ smesh = smeshBuilder.New()
import numpy
# print dim,NomMesh,acritere
if dim == 2 :
ACmt = myBuilder.FindOrCreateAttribute(myObject, "AttributeComment")
ACmt.SetValue(datai)
- if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(False)
+ if salome.sg.hasDesktop(): salome.sg.updateObjBrowser()
self.num += 1
- if verbose: print("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai))
+ if verbose: print(("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai)))
return True
def PBSaveHypPressed(self):
data = self.getResumeData(separator=" ; ")
self.editor.setAttributeValue(newStudyIter, "AttributeComment", data)
- if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(False)
+ if salome.sg.hasDesktop(): salome.sg.updateObjBrowser()
self.num += 1
- if verbose: print("save %s in Object Browser done:\n%s" % (name, data))
+ if verbose: print(("save %s in Object Browser done:\n%s" % (name, data)))
return True
def SP_toStr(self, widget):
# if you already have plugins defined in a salome_plugins.py file, add this file at the end.
# if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py
- import sys, traceback
import math
+ import sys
+ import traceback
+
from blocFissure import gmu
+
def fissureCoudeDlg(context):
- # get context study, studyId, salomeGui
+ # get context study, salomeGui
study = context.study
- studyId = context.studyId
sg = context.sg
import os
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
filename="/home/gboulant/development/projets/salome/SPADDER/spadder/resources/padderexe/REF_spheres.dat.xyz"
- file=open(filename,'rb')
- import csv
- datalines = csv.reader(file, delimiter=' ')
+ with open(filename,'rb') as f:
+ datalines = csv.reader(file, delimiter=' ')
i=0
for row in datalines:
x=float(row[0])
# Test of usage of SMESH engine from the test component
# WARN: the SMESH engine must be loaded first
- print "Test of usage of SMESH engine from the test component"
+ print("Test of usage of SMESH engine from the test component")
import SMESH
salome.lcc.FindOrLoadComponent("FactoryServer","SMESH")
-c.testsmesh(salome.myStudyId)
+c.testsmesh()
- print "Test completed : OK"
+ print("Test completed : OK")