zhulianhua / Voxelizer

A C++ tool for converting 3D .stl file to voxels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolution?

robbiebarrat opened this issue · comments

How to specify resolution?

Like how many voxels compose the long end of the model?

If i need a 32x32x32 array, what would i have to change?

You can refer to the example in the main.cpp, line 17 and 21. You should specify the gridNum when you create the GridBox object. And by setting the gridNum you can specify the resolution.

Would changing line 21 to
int3 gridNum = 32;
change the resolution to 32x32x32? I only know python so sorry if i'm totally wrong.

I've pushed new commits, and now the main.cpp illustrate a complete example:
Generate a grid of voxels in a bounding box with corners (-2,-2,-2) to (2,2,2), and voxelizing a sphere object locates at (0,0,0) with a radius 1. You can see the comments in the main.cpp and how to run in the example.sh

thank you so much!!

One more thing - when i try to run example.sh, i get an error dealing with there not being a file just called "voxelizer"

The command i ran to build was
cmake .
and the error im getting after building, when trying to run example.sh is
./example.sh: 9: ./example.sh: ./voxelizer: not found

The content of the example.sh is

#!/bin/sh

# An example to build & run an example

rm -rf build
mkdir build && cd build
cmake ..
make
./voxelizer ../sphere.stl

The cmake command generates the Makefile and the make should build the executable file voxelizer.
Note we create the build directory and cd to it before compiling the code and run the example.

You should see the following output if you have successfully made and run the executable:

......
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lhzhu/Desktop/Voxelizer/build
Scanning dependencies of target test
[ 14%] Building CXX object CMakeFiles/test.dir/test/test.cpp.o
[ 28%] Linking CXX executable test
[ 28%] Built target test
Scanning dependencies of target voxelizer
[ 42%] Building CXX object CMakeFiles/voxelizer.dir/Voxelizer.cpp.o
[ 57%] Building CXX object CMakeFiles/voxelizer.dir/V3.cpp.o
[ 71%] Building CXX object CMakeFiles/voxelizer.dir/main.cpp.o
[ 85%] Building CXX object CMakeFiles/voxelizer.dir/Triangle.cpp.o
[100%] Linking CXX executable voxelizer
[100%] Built target voxelizer
Reading geometry ...
STL file comment Exported from Blender-2.76 (sub 0)
Num of triangle 960
Generating voxilzer ...
GEO bound = Bbox(
minCorner: 	(-1, -1, -1)
maxCorner: 	(1, 1, 1)
Extend: 	(2, 2, 2)
)

nx = 33, ny = 33, nz = 33
count of flag == 1 : 2112
Writing vtk image ...
Deleting the flag memory!

Other wise, you need to check if the build goes wrong.