Closed HollowHeartNet closed 3 years ago
As 3D alpha shapes are returned as a trimesh
object, you can use its API to export to a mesh file. If the format you are looking for is not supported, you will need to look to 3rd party libraries to help with the conversion.
https://trimsh.org/trimesh.html#trimesh.Trimesh.export
Export the current mesh to a file object. If file_obj is a filename, file will be written there.
Supported formats are stl, off, ply, collada, json, dict, glb, dict64, msgpack.
Tested Example:
alpha_shape.export('save.stl')
Dear @bellockk
Thank you for responding. I've already tried to export a 2D / 3D alpha shape with the trimesh API, but it does not work. Here is a small example (2D points):
import os
import sys
import pandas as pd
import numpy as np
import trimesh
from descartes import PolygonPatch
import matplotlib.pyplot as plt
sys.path.insert(0, os.path.dirname(os.getcwd()))
import alphashape
points_2d = [(0., 0.), (0., 1.), (1., 1.), (1., 0.),
(0.5, 0.25), (0.5, 0.75), (0.25, 0.5), (0.75, 0.5)]
alpha_shape = alphashape.alphashape(points_2d, 0)
alpha_shape.export('save.stl')
When I run the script I get the following error:
Traceback (most recent call last):
File ".\alphashape_mesh.py", line 29, in <module>
alpha_shape.export('save.stl')
AttributeError: 'Polygon' object has no attribute 'export'
Can you please help?
Try it with 3D points and it will work. For 2D input, a Shapely Polygon object is returned.
Dear community,
I would like to know how to save the created / computed concave hull with alpha shape as mesh file (e.g. OBJ format)?
I would appreciate any help.
Best,