A demo for mesh-voxel conversion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
873 B

#include <iostream>
#include "STLReader.hpp"
#include "Voxel.hpp"
#include <chrono>
int main() {
Mesh mesh;
if (readSTL("../plate.stl", mesh)) {
std::cout << "Successfully read STL file." << std::endl;
std::cout << "Vertices count: " << mesh.vertices.size() << std::endl;
std::cout << "Faces count: " << mesh.faces.size() << std::endl;
} else {
std::cerr << "Failed to read STL file." << std::endl;
}
Vec3f cellSize = {0.1, 0.1, 0.1};
// Vec3 cellSize = {0.01, 0.01, 0.01};
// timer
auto begin = std::chrono::steady_clock::now();
auto voxelGrid = VoxelGrid::generateFromMesh(mesh, cellSize);
auto end = std::chrono::steady_clock::now();
std::cout << "Time elapsed: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << "ms"
<< std::endl;
return 0;
}