Rev 595 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* off_load.cpp
* GEL
*
* Created by J. Andreas Bærentzen on 16/02/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <fstream>
#include "off_load.h"
#include "HMesh/Manifold.h"
#include "build_manifold.h"
using namespace std;
using namespace CGLA;
using namespace HMesh;
using namespace Geometry;
namespace HMesh
{
bool off_load(const std::string& filename, HMesh::Manifold& m)
{
ifstream ifs(filename.c_str());
string str;
if(ifs.good())
ifs >> str;
if(str != "OFF")
return false;
int NF, NV, NE;
ifs >> NV >> NF >> NE;
vector<Vec3f> vertices(NV);
for(int i=0;i<NV;++i)
ifs >> vertices[i];
vector<int> faces(NF);
vector<int> indices;
for(int i=0;i<NF;++i)
{
int verts_in_face;
ifs >> verts_in_face;
faces[i]=verts_in_face;
for(int j=0;j<verts_in_face;++j)
{
int idx;
ifs >> idx;
indices.push_back(idx);
}
}
build_manifold(m, NV, &vertices[0], NF, &faces[0], &indices[0]);
return true;
}
}