Subversion Repositories gelsvn

Rev

Rev 33 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <iostream>

#include "CGLA/Vec3f.h"
#include "HMeshUtil/quadric_simplify.h"
#include "HMeshUtil/x3d_save.h"
#include "HMeshUtil/x3d_load.h"
#include "HMeshUtil/caps_and_needles.h"

using namespace std;
using namespace CGLA;
using namespace HMeshUtil;
using namespace HMesh;

int main(int argc, char** argv)
{
        Manifold m;
        x3d_load(argv[1], m);

        Vec3f p0, p7;
        m.get_bbox(p0, p7);
        Vec3f d = p7-p0;
        float s = 1.0/d.max_coord();
        cout << p0 << p7 << d << s << endl;
        
        for(VertexIter vi = m.vertices_begin(); vi != m.vertices_end(); ++vi)
                {
                        vi->set_pos((vi->get_pos() - p0) * s);
                }

        cout << "Perform quadric based simplification ... " << endl;
        quadric_simplify(m,atoi(argv[2]));

        cout << "Removing caps and needles ... " << endl;
        remove_caps_from_trimesh(m, M_PI * 0.85);
        remove_needles_from_trimesh(m, 1e-4);

        cout << "Validity: " << m.is_valid() << endl;
        cout << "Now saving ... " << endl;
        x3d_save("decimated.x3d", m);
}