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 struct VertexPointData 00019 { 00021 void setPoint(const SFPoint3f &point) {_point = point;}; 00023 inline const SFPoint3f &getPoint() const {return _point;}; 00024 00025 private: 00026 SFPoint3f _point; 00027 }; 00028 00034 struct VertexNormalData 00035 { 00037 template<class FData, class VData, class EData, bool readOnly> 00038 void setNormalOfFace(const SFVec3f &normal, SFFace<FData, VData, EData, readOnly> *face); 00040 template<class FData, class VData, class EData, bool readOnly> 00041 const SFVec3f &getNormalOfFace(SFFace<FData, VData, EData, readOnly> *face) const; 00042 00044 const std::map<void *, unsigned short> &getMap() const {return _normalMap;}; 00046 const MFVec3f &getNormalArray() const {return _normalArray;}; 00047 00048 private: 00049 MFVec3f _normalArray; 00050 std::map<void *, unsigned short> _normalMap; 00051 }; 00052 00058 struct VertexColorData 00059 { 00061 template<class FData, class VData, class EData, bool readOnly> 00062 void setColorOfFace(const SFColorRGBA &color, SFFace<FData, VData, EData, readOnly> *face); 00064 template<class FData, class VData, class EData, bool readOnly> 00065 const SFColorRGBA &getColorOfFace(SFFace<FData, VData, EData, readOnly> *face) const; 00066 00067 private: 00068 MFColorRGBA _colorArray; 00069 std::map<void *, unsigned short> _colorMap; 00070 }; 00071 00077 struct VertexTexCoordData 00078 { 00080 template<class FData, class VData, class EData, bool readOnly> 00081 void setTexCoordOfFace(const SFVec2f &texCoord, SFFace<FData, VData, EData, readOnly> *face); 00083 template<class FData, class VData, class EData, bool readOnly> 00084 const SFVec2f &getTexCoordOfFace(SFFace<FData, VData, EData, readOnly> *face) const; 00085 00086 private: 00087 MFVec2f _texCoordArray; 00088 std::map<void *, unsigned short> _texCoordMap; 00089 }; 00090 00096 struct FaceNormalData 00097 { 00099 void setNormal(const SFVec3f &normal) {_normal = normal;}; 00101 inline const SFVec3f &getNormal() const {return _normal;}; 00102 00103 private: 00104 SFVec3f _normal; 00105 }; 00106 00112 struct FaceColorData 00113 { 00115 void setColor(const SFColorRGBA &color) {_color = color;}; 00117 inline const SFColorRGBA &getColor() const {return _color;}; 00118 00119 private: 00120 SFColorRGBA _color; 00121 }; 00122 00128 struct MeshNormalData 00129 { 00131 void setNormal(bool value) {_normal = value;}; 00133 void setNormalPerVertex(bool value) {_normalPerVertex = value;}; 00134 00136 inline bool hasNormal() const {return _normal;}; 00138 inline bool getNormalPerVertex() const {return _normalPerVertex;}; 00139 00140 private: 00141 bool _normal; 00142 bool _normalPerVertex; 00143 }; 00144 00150 struct MeshColorData 00151 { 00153 void setColor(bool value) {_color = value;}; 00155 void setColorPerVertex(bool value) {_colorPerVertex = value;}; 00157 void setRGBA(bool value) {_rgba = value;}; 00158 00160 inline bool hasColor() const {return _color;}; 00162 inline bool getColorPerVertex() const {return _colorPerVertex;}; 00164 inline bool getRGBA() const {return _rgba;}; 00165 00166 private: 00167 bool _color; 00168 bool _colorPerVertex; 00169 bool _rgba; 00170 }; 00171 00177 struct MeshTexCoordData 00178 { 00180 void setTexCoord(bool value) {_texCoord = value;}; 00182 inline bool hasTexCoord() const {return _texCoord;}; 00183 00184 private: 00185 bool _texCoord; 00186 }; 00187 00193 typedef clist<tlist<VertexPointData, tlist<VertexNormalData, tlist<VertexColorData, tlist<VertexTexCoordData> > > > > VertexData; 00194 00200 typedef nil EdgeData; 00201 00207 typedef clist<tlist<FaceNormalData, tlist<FaceColorData> > > FaceData; 00208 00214 typedef clist<tlist<MeshNormalData, tlist<MeshColorData, tlist<MeshTexCoordData> > > > MeshData; 00215 00216 } 00217 } 00218 00219 #include "MESH_MeshData.inl" 00220 00221 #endif