ObjIO.h

00001 /*************************************************************************************************
00002  *
00003  * Modeling and animation (TNM079) 2007
00004  * Code base for lab assignments. Copyright:
00005  *   Gunnar Johansson (gunnar.johansson@itn.liu.se)
00006  *   Ken Museth (ken.museth@itn.liu.se)
00007  *   Michael Bang Nielsen (bang@daimi.au.dk)
00008  *   Ola Nilsson (ola.nilsson@itn.liu.se)
00009  *   Andreas Sderstrm (andreas.soderstrom@itn.liu.se)
00010  *
00011  *************************************************************************************************/
00012 #ifndef __obj_io_h__
00013 #define __obj_io_h__
00014 
00015 #include "Mesh.h"
00016 #include "Vector3.h"
00017 #include <string>
00018 #include <iostream>
00019 #include <fstream>
00020 #include <algorithm>
00021 
00022 class ObjIO 
00023 {
00024 public:
00025   ObjIO() {}
00026     
00027   bool load(Mesh *, std::istream & is); // NULL return on error
00028   bool save(Mesh *, std::ostream & os); // false return indicates error
00029     
00030 protected:
00031   bool readHeader(std::istream &is);
00032   bool readData(std::istream &is);
00033 
00034   static Vector3<unsigned int> readTri(std::istream &is);
00035   
00036   static void splitQuad(std::istream &is, Vector3<unsigned int>& tri1, Vector3<unsigned int>& tri2);
00037 
00038   struct LoadData
00039   {
00040     LoadData() : hasNormals(false){}
00041          
00042          //set  the boolean value stating if the normal is found 
00043          //in the model
00044          bool hasNormals;
00045 
00046     //STL vector for 
00047          //vertices, normals and
00048          //triangles
00049          std::vector<Vector3<float> > verts;
00050     std::vector<Vector3<float> > normals;
00051     std::vector<Vector3<unsigned int> > tris;
00052   } loadData;
00053 };
00054 
00055 #endif

Generated on Fri Jul 20 23:57:42 2007 for HalfEdge by  doxygen 1.5.1