MeshInspector / MeshLib

Mesh processing library
https://meshinspector.com
Other
498 stars 56 forks source link

VectorFloatByVert to numpy #2751

Closed drperpen closed 2 months ago

drperpen commented 4 months ago

Hi, I am trying to get geodesic approx distances on my mesh. My problem is that the returned distances is a meshlib.mrmeshpy.VectorFloatByVert and I cannot seem to be able to convert it to a numpy array. I tried with ctypes as well with no luck because the iterator does not have a data() or similar. Is there a way to convert it to numpy that I am missing? Thanks!

source_points = update_mesh(mesh_current_frame, mask)
meshlib_mesh = meshlib.mrmeshnumpy.meshFromFacesVerts(mesh_current_frame.face_indices.reshape(-1,3), mesh_current_frame.positions)
meshlib_source_points  = meshlib.mrmeshnumpy.pointCloudFromPoints(seed_points.positions)
meshlib_targets = meshlib.mrmeshnumpy.pointCloudFromPoints(mesh_current_frame.positions)
distances = meshlib.mrmeshpy.computeSurfaceDistances(meshlib_mesh, meshlib_seeds.validPoints, meshlib_targets.validPoints)
Grantim commented 4 months ago

Hello!

You can operate with distances.vec like as list()


source_points = update_mesh(mesh_current_frame, mask)
meshlib_mesh = meshlib.mrmeshnumpy.meshFromFacesVerts(mesh_current_frame.face_indices.reshape(-1,3), mesh_current_frame.positions)
meshlib_source_points  = meshlib.mrmeshnumpy.pointCloudFromPoints(seed_points.positions)
meshlib_targets = meshlib.mrmeshnumpy.pointCloudFromPoints(mesh_current_frame.positions)
distances = meshlib.mrmeshpy.computeSurfaceDistances(meshlib_mesh, meshlib_seeds.validPoints, meshlib_targets.validPoints)

npArrayDistances = numpy.array(distances.vec)