Avogadro
1.1.0
|
00001 /********************************************************************** 00002 Mesh - Primitive class to encapsulate triangular meshes/ 00003 00004 Copyright (C) 2008 Marcus D. Hanwell 00005 00006 This file is part of the Avogadro molecular editor project. 00007 For more information, see <http://avogadro.openmolecules.net/> 00008 00009 Avogadro is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 Avogadro is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00022 02110-1301, USA. 00023 **********************************************************************/ 00024 00025 #ifndef MESH_H 00026 #define MESH_H 00027 00028 #include <avogadro/primitive.h> 00029 #include <Eigen/Core> 00030 00031 #include <vector> 00032 00033 // Forward declarations 00034 class QReadWriteLock; 00035 00036 namespace Avogadro { 00037 00038 class Molecule; 00039 class Color3f; 00050 class MeshPrivate; 00051 class A_EXPORT Mesh : public Primitive 00052 { 00053 Q_OBJECT 00054 00055 public: 00059 Mesh(QObject *parent=0); 00060 00064 ~Mesh(); 00065 00074 bool reserve(unsigned int size, bool colors = false); 00075 00081 void setStable(bool stable); 00082 00088 bool stable(); 00089 00093 void setIsoValue(float value) { m_isoValue = value; } 00094 00098 float isoValue() const { return m_isoValue; } 00099 00103 void setOtherMesh(unsigned int other) { m_other = other; } 00104 00108 unsigned int otherMesh() const { return m_other; } 00109 00113 void setCube(unsigned int cube) { m_cube = cube; } 00114 00118 unsigned int cube() const { return m_cube; } 00119 00123 const std::vector<Eigen::Vector3f> & vertices() const; 00124 00128 unsigned int numVertices() const { return m_vertices.size(); } 00129 00133 const Eigen::Vector3f * vertex(int n) const; 00134 00138 bool setVertices(const std::vector<Eigen::Vector3f> &values); 00139 00144 bool addVertices(const std::vector<Eigen::Vector3f> &values); 00145 00149 const std::vector<Eigen::Vector3f> & normals() const; 00150 00154 unsigned int numNormals() const { return m_normals.size(); } 00155 00156 00160 const Eigen::Vector3f * normal(int n) const; 00161 00165 bool setNormals(const std::vector<Eigen::Vector3f> &values); 00166 00171 bool addNormals(const std::vector<Eigen::Vector3f> &values); 00172 00176 const std::vector<Color3f> & colors() const; 00177 00181 const Color3f * color(int n) const; 00182 00186 bool setColors(const std::vector<Color3f> &values); 00187 00192 bool addColors(const std::vector<Color3f> &values); 00193 00199 bool valid() const; 00200 00205 bool clear(); 00206 00210 Mesh& operator=(const Mesh& other); 00211 00215 void setName(QString name) { m_name = name; } 00216 00220 QString name() { return m_name; } 00221 00225 QReadWriteLock *lock() const; 00226 00227 friend class Molecule; 00228 00229 protected: 00230 std::vector<Eigen::Vector3f> m_vertices; 00231 std::vector<Eigen::Vector3f> m_normals; 00232 std::vector<Color3f> m_colors; 00233 QString m_name; 00234 bool m_stable; 00235 float m_isoValue; 00236 unsigned int m_other; // Unique id of the other mesh if this is part of a pair 00237 unsigned int m_cube; // Unique id of the cube this mesh was generated from 00238 QReadWriteLock *m_lock; 00239 Q_DECLARE_PRIVATE(Mesh) 00240 }; 00241 } // End namespace Avogadro 00242 00243 #endif