Shapely polygon from trimesh.path.path.Path2D
See original GitHub issueI have sliced a 3d mesh with yz planes into several 2d sections (i.e. Path2D objects). Now, I’d like to create Shapely polygons from these 2d sections. For doing so, I need a list of points as XY coords. However, if I use Path2D.vertices
, I get a weird polygon because the vertices are un-ordered. Is there any way to get an ordered list of the vertices composing a Path2D object?
Obviously I cannot use the python .sort()
method.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
trimesh.path — trimesh 3.17.1 documentation
A list of shapely.geometry.Polygon objects with interiors created by checking which closed polygons enclose which other polygons. Returns. full – Polygons ...
Read more >Find Properties of Polygons from Path2D, derived from the ...
The property "polygons_closed" returns an array of shapely polygons. So to get ie. the area, use: for polygon in slice_2D.polygons_closed: ...
Read more >Part — pyslm 0.5.0 documentation - Read the Docs
Returns the list of paths and coordinates from a cross-section (i.e.. regenerate () ... A Shapely Polygon representing the projected area of the...
Read more >python/8446/trimesh/trimesh/path/path.py - Program Talk
path.py. A library designed to work with vector paths. ... from shapely.geometry import Polygon ... If the current Path2D consists of n 'root'...
Read more >PySLM - lukeparry.uk
The paths are then translated into Shapely.Polygon objects. """ Extract the outline of the overhang mesh region""" poly ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, so what part isn’t working? The polygon is probably displaced if you are using the to_planar method without specifying the matrix.
I updated the section example: https://github.com/mikedh/trimesh/blob/master/examples/section.ipynb check out In[12] to show how to pass the matrix. Also I added In[10] which shows a linestring-polygon intersection.
Best, Mike
No worries, glad it was a version issue in this case! Though for future people looking at this I actually have another suspect that could possibly touch this too: vertex merging behavior. After a bunch of asks for “no merging by default” my compromise solution was to to consider vertex normals if populated, and only merge vertices that had the same position, vertex normal (if loaded), and UV (if loaded).
For 3D printing-ish stuff, I now load every mesh using
loaded = trimesh.load(file_name, merge_norm=True, merge_tex=True)
. Behavior on STL files (which have no vertex normals) wouldn’t change, but OBJ could.