Rev 207 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "CGLA/Mat4x4f.h"
#include "Util/ArgExtracter.h"
#include "Geometry/RGrid.h"
#include "Geometry/load_raw.h"
#include "Geometry/save_raw.h"
#include "HMesh/obj_save.h"
#include "HMesh/x3d_save.h"
#include "HMesh/caps_and_needles.h"
#include "HMesh/volume_polygonize.h"
#include "HMesh/triangulate.h"
using namespace CGLA;
using namespace Util;
using namespace HMesh;
using namespace std;
using namespace Geometry;
bool cuberille;
float iso = 40;
string file;
string ofile;
template<class T>
void do_everything(RGrid<T> grid)
{
cout << "loading <" << file << ">" << endl;
load_raw(file,grid);
cout << "Polygonizing, iso = " << iso << endl;
Manifold mani;
if(cuberille)
cuberille_polygonize(grid, mani, iso, true);
else
mc_polygonize(grid, mani, iso);
cout << "Triangulating" << endl;
shortest_edge_triangulate(mani);
cout << "Saving" << endl;
obj_save(ofile, mani);
}
int main(int argc, char**argv)
{
ArgExtracter ae(argc, argv);
if(ae.no_remaining_args() == 1 || ae.extract("-h"))
{
cout << "Usage: volpoly [-C] [-i <iso>] [-x <X>] [-y <Y>] [-z <Z>] "
<< "[-S|-f|-U|-b] raw-volume-file" << endl;
cout << "where -C implies that the cuberille method rather than\n"
<< "marching cubes should be used. -S -f -U -b indicate that\n"
<< "the volume is in short, float, unsigned short or unsigned\n"
<< "byte format" << endl;
exit(0);
}
cuberille = ae.extract("-C");
ae.extract("-i", iso);
int X = 128;
ae.extract("-x", X);
int Y = 128;
ae.extract("-y", Y);
int Z = 62;
ae.extract("-z", Z);
ofile = "isosurf.obj";
ae.extract("-o", ofile);
file = ae.get_last_arg();
if(ae.extract("-S"))
{
cout << "Data type = short" << endl;
RGrid<short> grid(Vec3i(X,Y,Z));
do_everything(grid);
}
else if(ae.extract("-f"))
{
cout << "Data type = float" << endl;
RGrid<float> grid(Vec3i(X,Y,Z));
do_everything(grid);
}
else if(ae.extract("-U"))
{
cout << "Data type = unsigned short" << endl;
RGrid<unsigned short> grid(Vec3i(X,Y,Z));
do_everything(grid);
}
else
{
cout << "Data type = unsigned char" << endl;
RGrid<unsigned char> grid(Vec3i(X,Y,Z));
do_everything(grid);
}
}