zinsmatt / SpaceCarving

34 stars 4 forks source link

How to open the generated shape.vtr file in 3d format #3

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello Sir @zinsmatt . I wanted to know how can we visualize the generated .vtr file in 3d software's like blender,meshlab or how can we convert vtr into obj or stl for easy visualisation

zinsmatt commented 3 years ago

Hi @mohammedmudassirAS

You can visualize the .vtr file in Paraview. It is a very complete software for scientific visualization. The .vtr file contains the full grid with occupancy values, so that you can dynamically adjust the threshold of occupancy in Paraview.

Otherwise, you can directly threshold the occupancy in the code and save the result as OBJ pointcloud by adding the following lines:

OCC_THRESHOLD = 24
out_points = pts[occupancy > OCC_THRESHOLD, :]
with open("out.obj", "w") as fout:
        for p in out_points:
            fout.write("v " + " ".join(map(str, p)) + "\n")