Rev 467 | Rev 504 | 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 "off_load.h"
#include <fstream>
#include "HMesh.h"
#include "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;
}
uint NF, NV, NE;
ifs >> NV >> NF >> NE;
vector<Vec3f> vertices(NV);
for(uint i= 0; i < NV; ++i){
ifs >> vertices[i];
}
vector<uint> faces(NF);
vector<uint> indices;
for(uint i = 0; i < NF; ++i){
uint verts_in_face;
ifs >> verts_in_face;
faces[i] = verts_in_face;
for(uint j = 0; j < verts_in_face; ++j){
uint idx;
ifs >> idx;
indices.push_back(idx);
}
}
m.build(NV, reinterpret_cast<float*>(&vertices[0]), NF, &faces[0], &indices[0]);
return true;
}
}