00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef freecloth_geom_geMesh_h
00020 #define freecloth_geom_geMesh_h
00021
00022 #ifndef freecloth_geom_package_h
00023 #include <freecloth/geom/package.h>
00024 #endif
00025
00026 #ifndef freecloth_base_vector
00027 #include <freecloth/base/vector>
00028 #endif
00029
00030 #ifndef freecloth_resmgt_rcBase_h
00031 #include <freecloth/resmgt/rcBase.h>
00032 #endif
00033
00034 #ifndef freecloth_geom_gePoint_h
00035 #include <freecloth/geom/gePoint.h>
00036 #endif
00037
00038 #ifndef freecloth_geom_geMeshTypes_h
00039 #include <freecloth/geom/geMeshTypes.h>
00040 #endif
00041
00042 FREECLOTH_NAMESPACE_START
00043
00044
00045
00046
00047
00048 class GeMeshBuilder;
00049 class GeVector;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 class GeMesh : public RCBase, public GeMeshTypes {
00080
00081 public:
00082
00083
00084
00085
00086 class FaceConstIterator;
00087
00088 class FaceWrapper;
00089
00090
00091
00092
00093 typedef FaceWrapper FaceType;
00094
00095
00096
00097
00098
00099
00100 UInt32 getNbFaces() const;
00101 FaceType getFace( FaceId ) const;
00102 FaceConstIterator beginFace() const;
00103 FaceConstIterator endFace() const;
00104
00105 UInt32 getNbVertices() const;
00106 const VertexType& getVertex( VertexId ) const;
00107 VertexType& getVertex( VertexId );
00108 const VertexType* getVertexArray() const;
00109 VertexIterator beginVertex();
00110 VertexIterator endVertex();
00111 VertexConstIterator beginVertex() const;
00112 VertexConstIterator endVertex() const;
00113
00114 bool hasTexture() const;
00115 UInt32 getNbTextureVertices() const;
00116 const TextureVertexType& getTextureVertex( TextureVertexId ) const;
00117 TextureVertexType& getTextureVertex( TextureVertexId );
00118 const TextureVertexType* getTextureVertexArray() const;
00119 TextureVertexIterator beginTextureVertex();
00120 TextureVertexIterator endTextureVertex();
00121 TextureVertexConstIterator beginTextureVertex() const;
00122 TextureVertexConstIterator endTextureVertex() const;
00123
00124
00125 private:
00126
00127
00128
00129 friend class FaceWrapper;
00130 friend class GeMeshBuilder;
00131
00132
00133
00134 class Face;
00135
00136
00137
00138 typedef std::vector<Face> FaceContainer;
00139
00140
00141 GeMesh();
00142
00143
00144
00145 FaceContainer _faces;
00146 VertexContainer _vertices;
00147 TextureVertexContainer _textureVertices;
00148 };
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 class GeMesh::Face : public GeMeshTypes {
00164
00165 public:
00166
00167 enum {
00168
00169 NB_VERTICES = 3
00170 };
00171
00172
00173 Face(
00174 VertexId, VertexId, VertexId,
00175 TextureVertexId, TextureVertexId, TextureVertexId
00176 );
00177
00178
00179 UInt32 getNbVertices() const;
00180 VertexId getVertexId( FaceVertexId ) const;
00181 TextureVertexId getTextureVertexId( FaceVertexId ) const;
00182
00183 private:
00184
00185
00186
00187 friend class GeMesh;
00188
00189
00190
00191 VertexId _vertexIds[ NB_VERTICES ];
00192 TextureVertexId _textureVertexIds[ NB_VERTICES ];
00193 };
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 class GeMesh::FaceWrapper : public GeMeshTypes {
00210
00211 public:
00212
00213
00214 enum {
00215
00216 NB_VERTICES = 3
00217 };
00218
00219
00220
00221
00222 FaceWrapper();
00223 FaceWrapper( const GeMesh&, FaceId );
00224
00225
00226
00227 FaceId getFaceId() const;
00228 UInt32 getNbVertices() const;
00229 VertexId getVertexId( FaceVertexId ) const;
00230 const VertexType& getVertex( FaceVertexId ) const;
00231 TextureVertexId getTextureVertexId( FaceVertexId ) const;
00232 const TextureVertexType& getTextureVertex( FaceVertexId ) const;
00233
00234
00235 Float calcArea() const;
00236
00237 GeVector calcNormal() const;
00238
00239
00240
00241
00242 GePoint calcBarycentric( const GePoint& p ) const;
00243
00244 private:
00245
00246 friend class GeMesh::FaceConstIterator;
00247 friend class GeMeshBuilder;
00248
00249
00250
00251 static GePoint calcBarycentric(
00252 const GePoint& p,
00253 const GePoint& v1,
00254 const GePoint& v2,
00255 const GePoint& v3
00256 );
00257
00258
00259
00260 FaceWrapper( const GeMesh*, FaceId );
00261 bool isValid() const;
00262
00263
00264 const GeMesh* _mesh;
00265 FaceId _faceId;
00266 };
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 class GeMesh::FaceConstIterator : public GeMeshTypes {
00281
00282 public:
00283
00284
00285 static FaceConstIterator begin( const GeMesh& );
00286 static FaceConstIterator end( const GeMesh& );
00287
00288
00289 FaceConstIterator();
00290 FaceConstIterator( const GeMesh&, FaceId );
00291
00292
00293 FaceConstIterator& operator++();
00294 FaceConstIterator operator++( int );
00295 FaceConstIterator& operator--();
00296 FaceConstIterator operator--( int );
00297
00298 bool operator == ( const FaceConstIterator& ) const;
00299 bool operator != ( const FaceConstIterator& ) const;
00300
00301 const FaceWrapper& operator*() const;
00302 const FaceWrapper* operator->() const;
00303
00304 private:
00305
00306 friend class GeMesh;
00307 friend class GeMeshBuilder;
00308
00309
00310
00311
00312 explicit FaceConstIterator( const FaceWrapper& );
00313
00314
00315
00316
00317 GeMesh::FaceWrapper _wrapper;
00318 };
00319
00320
00321
00322
00323 std::ostream& operator<<( std::ostream&, const GeMesh& );
00324 std::ostream& operator<<( std::ostream&, const GeMesh::FaceWrapper& );
00325
00326
00327 FREECLOTH_NAMESPACE_END
00328
00329 #include <freecloth/geom/geMesh.inline.h>
00330
00331 #endif