vertexData.h

00001 /*  
00002  *  Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch>
00003  *                2009, Stefan Eilemann <eile@equalizergraphics.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017   
00018     
00019     Header file of the VertexData class.
00020 */
00021 
00022 
00023 #ifndef MESH_VERTEXDATA_H
00024 #define MESH_VERTEXDATA_H
00025 
00026 
00027 #include "typedefs.h"
00028 #include <vector>
00029 
00030 
00031 // defined elsewhere
00032 class PlyFile;
00033 
00034 namespace mesh 
00035 {
00036     /*  Holds the flat data and offers routines to read, scale and sort it.  */
00037     class VertexData
00038     {
00039     public:
00040         VertexData();
00041 
00042         bool readPlyFile( const std::string& file );
00043         void sort( const Index start, const Index length, const Axis axis );
00044         void scale( const float baseSize = 2.0f );
00045         void calculateNormals( const bool vertexNormals = true );
00046         void calculateBoundingBox();
00047         const BoundingBox& getBoundingBox() const { return _boundingBox; }
00048         Axis getLongestAxis( const size_t start, const size_t elements ) const;
00049 
00050         void useInvertedFaces() { _invertFaces = true; }
00051 
00052         std::vector< Vertex >   vertices;
00053         std::vector< Color >    colors;
00054         std::vector< Normal >   normals;
00055         std::vector< Triangle > triangles;
00056 
00057     private:
00058         void readVertices( PlyFile* file, const int nVertices, 
00059                            const bool readColors );
00060         void readTriangles( PlyFile* file, const int nFaces );
00061 
00062         BoundingBox _boundingBox;
00063         bool        _invertFaces;
00064     };
00065 }
00066 
00067 
00068 #endif // MESH_VERTEXDATA_H
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8