Auto-scale POV output

This commit is contained in:
Alessandro Ranellucci 2016-07-09 14:14:59 +02:00
parent 0b79b971e8
commit 7ddf2b4029

View File

@ -49,11 +49,18 @@ OBJ::write(TriangleMesh& mesh, std::string output_file)
bool
POV::write(TriangleMesh& mesh, std::string output_file)
{
TriangleMesh mesh2 = mesh;
{
Sizef3 size = mesh2.bounding_box().size();
coordf_t maxdim = fmax(size.x, fmax(size.y, size.y));
mesh2.scale(10.0/maxdim);
}
using namespace std;
ofstream pov;
pov.open(output_file.c_str(), ios::out | ios::trunc);
for (int i = 0; i < mesh.stl.stats.number_of_facets; ++i) {
const stl_facet &f = mesh.stl.facet_start[i];
for (int i = 0; i < mesh2.stl.stats.number_of_facets; ++i) {
const stl_facet &f = mesh2.stl.facet_start[i];
pov << "triangle { ";
pov << "<" << f.vertex[0].x << "," << f.vertex[0].y << "," << f.vertex[0].z << ">,";
pov << "<" << f.vertex[1].x << "," << f.vertex[1].y << "," << f.vertex[1].z << ">,";