00001 #ifndef X3DTK_MESH_MESHDATA_H
00002 #define X3DTK_MESH_MESHDATA_H
00003
00004 #include "X3DTypes.h"
00005 #include "TypeList.h"
00006 #include "MESH_SFFace.h"
00007
00008 #include <map>
00009
00010 namespace X3DTK {
00011 namespace MESH {
00012
00018 class VertexPointData
00019 {
00020 public:
00022 void setPoint(const SFPoint3f &point) {_point = point;};
00024 inline const SFPoint3f &getPoint() const {return _point;};
00025
00026 private:
00027 SFPoint3f _point;
00028 };
00029
00035 class VertexNormalData
00036 {
00037 public:
00039 void setNormalOfFace(const SFVec3f &normal, BaseSFFace *face);
00041 const SFVec3f &getNormalOfFace(BaseSFFace *face) const;
00042
00044 const std::map<BaseSFFace *, unsigned short> &getMap() const {return _normalMap;};
00046 const MFVec3f &getNormalArray() const {return _normalArray;};
00047
00048 private:
00049 MFVec3f _normalArray;
00050 std::map<BaseSFFace *, unsigned short> _normalMap;
00051 };
00052
00058 class VertexColorData
00059 {
00060 public:
00062 void setColorOfFace(const SFColorRGBA &color, BaseSFFace *face);
00064 const SFColorRGBA &getColorOfFace(BaseSFFace *face) const;
00065
00067 const std::map<BaseSFFace *, unsigned short> &getMap() const {return _colorMap;};
00069 const MFColorRGBA &getColorArray() const {return _colorArray;};
00070
00071 private:
00072 MFColorRGBA _colorArray;
00073 std::map<BaseSFFace *, unsigned short> _colorMap;
00074 };
00075
00081 class VertexTexCoordData
00082 {
00083 public:
00085 void setTexCoordOfFace(const SFPoint2f &texCoord, BaseSFFace *face);
00087 const SFPoint2f &getTexCoordOfFace(BaseSFFace *face) const;
00088
00090 const std::map<BaseSFFace *, unsigned short> &getMap() const {return _texCoordMap;};
00092 const MFPoint2f &getTexCoordArray() const {return _texCoordArray;};
00093
00094 private:
00095 MFPoint2f _texCoordArray;
00096 std::map<BaseSFFace *, unsigned short> _texCoordMap;
00097 };
00098
00104 class FaceNormalData
00105 {
00106 public:
00108 void setNormal(const SFVec3f &normal) {_normal = normal;};
00110 inline const SFVec3f &getNormal() const {return _normal;};
00111
00112 private:
00113 SFVec3f _normal;
00114 };
00115
00121 class FaceColorData
00122 {
00123 public:
00125 void setColor(const SFColorRGBA &color) {_color = color;};
00127 inline const SFColorRGBA &getColor() const {return _color;};
00128
00129 private:
00130 SFColorRGBA _color;
00131 };
00132
00138 class MeshNormalData
00139 {
00140 public:
00142 void setNormal(bool value) {_normal = value;};
00144 void setNormalPerVertex(bool value) {_normalPerVertex = value;};
00146 void setCreaseAngle(float value) {_creaseAngle = value;};
00147
00149 inline bool hasNormal() const {return _normal;};
00151 inline bool getNormalPerVertex() const {return _normalPerVertex;};
00153 inline float getCreaseAngle() const {return _creaseAngle;};
00154
00155 private:
00156 bool _normal;
00157 bool _normalPerVertex;
00158 float _creaseAngle;
00159 };
00160
00166 class MeshColorData
00167 {
00168 public:
00170 void setColor(bool value) {_color = value;};
00172 void setColorPerVertex(bool value) {_colorPerVertex = value;};
00174 void setRGBA(bool value) {_rgba = value;};
00175
00177 inline bool hasColor() const {return _color;};
00179 inline bool getColorPerVertex() const {return _colorPerVertex;};
00181 inline bool getRGBA() const {return _rgba;};
00182
00183 private:
00184 bool _color;
00185 bool _colorPerVertex;
00186 bool _rgba;
00187 };
00188
00194 class MeshTexCoordData
00195 {
00196 public:
00198 void setTexCoord(bool value) {_texCoord = value;};
00200 inline bool hasTexCoord() const {return _texCoord;};
00201
00202 private:
00203 bool _texCoord;
00204 };
00205
00211 class MeshSolidData
00212 {
00213 public:
00215 void setSolid(bool value) {_solid = value;};
00217 inline bool isSolid() const {return _solid;};
00218
00219 private:
00220 bool _solid;
00221 };
00222
00223
00224 #ifdef TEMPLATE_SPECIALIZATION_SUPPORTED
00225
00231 typedef clist<tlist<VertexPointData, tlist<VertexNormalData, tlist<VertexColorData, tlist<VertexTexCoordData> > > > > VertexData;
00232
00238 typedef nil EdgeData;
00239
00245 typedef clist<tlist<FaceNormalData, tlist<FaceColorData> > > FaceData;
00246
00252 typedef clist<tlist<MeshNormalData, tlist<MeshColorData, tlist<MeshTexCoordData, tlist<MeshSolidData> > > > > MeshData;
00253
00254 #else
00255
00256 class VertexData : public VertexPointData, public VertexNormalData, public VertexColorData, public VertexTexCoordData
00257 {};
00258
00259 class EdgeData
00260 {};
00261
00262 class FaceData : public FaceNormalData, public FaceColorData
00263 {};
00264
00265 class MeshData : public MeshNormalData, public MeshColorData, public MeshTexCoordData, public MeshSolidData
00266 {};
00267
00268 #endif
00269
00270 }
00271 }
00272
00273 #endif