//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00013 #ifndef _QUADMESH_H 00014 #define _QUADMESH_H 00015 00020 #include "GoTools/tesselator/GeneralMesh.h" 00021 #include <vector> 00022 00026 namespace Go 00027 { 00028 00029 class QuadMesh : public GeneralMesh 00030 { 00031 public: 00032 QuadMesh(int num_vert = 0, int num_quads = 0, 00033 bool use_normals = true, 00034 bool use_texcoords = false) 00035 : use_norm_(use_normals), 00036 use_texc_(use_texcoords) 00037 { 00038 resize(num_vert, num_quads); 00039 } 00040 00041 bool useNormals() 00042 { return use_norm_; } 00043 00044 bool useTexCoords() 00045 { return use_texc_; } 00046 00048 int numQuads() 00049 { return quads_.size()/4; } 00050 00051 virtual int numTriangles() 00052 { return quads_.size()/4; } 00053 00054 virtual int numVertices() 00055 { return vert_.size()/3; } 00056 00057 void resize(int num_vert, int num_quads) 00058 { 00059 vert_.resize(num_vert*3); 00060 if (use_norm_) 00061 norm_.resize(num_vert*3); 00062 if (use_texc_) 00063 texc_.resize(num_vert*2); 00064 quads_.resize(num_quads*4); 00065 } 00066 00067 virtual double* vertexArray() { return &vert_[0]; } 00068 double* normalArray() { return &norm_[0]; } 00069 double* texcoordArray() { return &texc_[0]; } 00070 unsigned int* quadIndexArray() { return &quads_[0]; } 00071 virtual unsigned int* triangleIndexArray() { return &quads_[0]; } 00072 virtual double* paramArray() {return 0;} 00073 virtual int atBoundary(int idx) {return 0;} 00074 00075 00076 private: 00077 bool use_norm_; 00078 bool use_texc_; 00079 00080 std::vector<double> vert_; 00081 std::vector<double> norm_; 00082 std::vector<double> texc_; 00083 std::vector<unsigned int> quads_; 00084 00085 }; 00086 00087 } // namespace Go 00088 00089 00090 00091 #endif // _GVQUADMESH_H 00092
Generated on Tue Sep 21 15:44:17 2010 for GoTools Core by  doxygen 1.6.3