Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for path3d export to ply format #2282

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

moberweger
Copy link

This PR adds support to export Path3D object into the PLY format. This can be used to visualize the Path3D objects in common 3D mesh viewers, such as MeshLab. These are shown as line stripes, as shown below.
This PR contains:

  • add export and import capabilities for PLY format that uses the edge property of the PLY format
  • add basic unittest that saves and loads a simple Path3D

Screenshot from 2024-09-06 16-01-43

@mikedh
Copy link
Owner

mikedh commented Sep 9, 2024

Awesome thanks for the PR!! It seems like we could probably merge this in with trimesh.exchange.ply and have the load function return either a Trimesh or Path3D? Do we need the separate trimesh.path.exchange.ply module? I guess since PLY is a container format the choice is between confusing return types or confusing function calls 😄.

My only other note is we could probably support any entity type pretty easily by using the entity.discrete(path.vertices) -> (n, 2) float64 which for a Line will do the same thing as the current code:

if isinstance(e, Line):
    for pp in range(len(e.points) - 1):
        entities.append((e.points[pp], e.points[pp + 1]))
else:
    raise NotImplementedError(f"type {type(e)} not supported as entities")

@moberweger
Copy link
Author

Thanks @mikedh for your feedback.
I was also thinking about the integration in the common trimesh.exchange.ply , but ended up with having a unique return value being the cleaner way of doing things 😅 But let me know if you think otherwise.
Thanks for the remark about the entity, I will update the PR 👍

@mikedh mikedh changed the base branch from main to release/revolve September 17, 2024 18:32
@mikedh mikedh merged commit 538f7b9 into mikedh:release/revolve Sep 17, 2024
9 checks passed
@mikedh
Copy link
Owner

mikedh commented Sep 17, 2024

Thanks for the PR and fixes!

@mikedh mikedh mentioned this pull request Sep 17, 2024
@mikedh
Copy link
Owner

mikedh commented Sep 29, 2024

Sorry for the slow release, I'll try to get this out next week. I was testing this and I was wondering are there any existing packages that output or load PLY paths in this format? 3JS maybe?

@moberweger
Copy link
Author

Thanks for looking into this so thoroughly. The almighty Open3D library can save the ply format, it is called LineSet over there. I used it before porting this stuff to trimesh, but Open3D was too heavy for my usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants