Skip to content

Commit

Permalink
* Reads ascii correctly. Time for a refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
phooky committed Aug 4, 2011
1 parent e6f1d41 commit d3ef208
Show file tree
Hide file tree
Showing 4 changed files with 477 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AsciiSTL.cc
Expand Up @@ -31,7 +31,7 @@ static Vertex readVertex(std::istream& in, const string expected) {
static Triangle readTriangle(std::istream& in, Mesh& mesh) {
Triangle t;
expect(in, "facet");
Vertex n = readVertex(in,"normal");
t.normal() = readVertex(in,"normal");

expect(in, "outer");
expect(in, "loop");
Expand Down
6 changes: 3 additions & 3 deletions BinarySTL.cc
Expand Up @@ -45,10 +45,10 @@ Mesh loadBinarySTL(std::istream& in) {
for (int f = 0; f < facets && !in.eof(); f++) {
// TODO: check that file is long enough! We can't have this
// block.
// Read normal and discard (for now)
Vertex normal = readVertex(in);
Vertex v[3];
// Read normal
Triangle t;
t.normal() = readVertex(in);
Vertex v[3];
for (int i =0; i < 3; i++) {
v[i] = readVertex(in);
t[i] = mesh.vertices.addVertex(v[i]);
Expand Down
2 changes: 2 additions & 0 deletions Mesh.hh
Expand Up @@ -52,10 +52,12 @@ public:
class Triangle {
private:
int v[3];
Vertex normalVect;
public:
Triangle() {}
int& operator[](int idx) { return v[idx]; }
const int& operator[](int idx) const { return v[idx]; }
Vertex& normal() { return normalVect; }
};

typedef std::pair<int,int> intpair;
Expand Down

0 comments on commit d3ef208

Please sign in to comment.