Update: Pymeshlab developpers have already included the method m.edge_matrix()
in the current version of pymeshlab to expose edge data. Since then, this is the recommended way to solve your problem if you have a modern version of pymeshlab.
I have to bring bad news. At current day (October 2021) the edge information that you request is stored internally in the VCG meshes but it is not exposed to python API, so you can't read it using pymeshlab. You can only read the number of edges using the m.edge_number() method.
If you need to continue with your project, yours options are:
- Write one issue at https://github.com/cnr-isti-vclab/PyMeshLab/issues/ kindly asking the developers to expose the edge information to pymeshlab api.
- If your surfaces are convex, you can rebuild the edge data computing the convex hull of the vertex, or by sorting the vertex by angle around the centroid of the vertex.
- If your surfaces are complex, you can still store the mesh into a dxf file, and then parse the dxf to read the info back
The option 3 seems to be the most easy to achieve. The DXF files written by meshlab have a lot of sections
LINE
8
0
10
40.243473 -> this is coordinate X of point 1
20
-40.981182 -> this is coordinate Y of point 1
30
0.000000 -> this is coordinate Z of point 1
11
40.887867 -> this is coordinate X of point 2
21
-42.090389 -> this is coordinate Y of point 2
31
0.000000 -> this is coordinate Z of point 2
0
so you can parse the dxf file with this piece of python code
edges=[]
with open("contour.dxf") as f:
line = f.readline().strip()
while line:
if line == "LINE" :
f.readline()
f.readline()
f.readline()
x1 = float(f.readline())
f.readline()
y1 = float(f.readline())
f.readline()
z1 = float(f.readline())
f.readline()
x2 = float(f.readline())
f.readline()
y2 = float(f.readline())
f.readline()
z2 = float(f.readline())
print("edge from", (x1,y1,z1), "to", (x2,y2,z2))
edges.append( ( (x1,y1,z1), (x2,y2,z2) ) )
line = f.readline().strip()