00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef SEGMENTATIONCLUSTER_H
00013 #define SEGMENTATIONCLUSTER_H
00014
00015 #include <vector>
00016 #include <boost/shared_ptr.hpp>
00017 #ifdef USE_QT4
00018 #include <QtCore>
00019 #endif
00020
00021 #include "../mesh/mesh_sequence.h"
00022
00023
00024 namespace SegmentationNS {
00025
00026 class Cluster {
00027 friend class Segmentation;
00028 public:
00029 enum ClusterType {
00030 VertexClustering,
00031 FaceClustering,
00032 FrameClustering,
00033 UnspecifiedClustering
00034 };
00035
00036
00037 Cluster();
00038 Cluster(MeshNS::MeshSequencePtr dm, ClusterType type);
00039 Cluster(MeshNS::MeshSequencePtr dm, std::vector<int> fv, ClusterType type);
00040 Cluster(MeshNS::MeshSequencePtr dm, std::vector<int> fv, std::vector<float> color, ClusterType type);
00041
00042 inline void add(int fv) {
00043 _indices.push_back(fv);
00044 }
00045
00046 inline void push_back(int fv) {
00047 _indices.push_back(fv);
00048 }
00049
00050 void close();
00051
00052 inline void setColor(std::vector<float> color) {
00053 _color= color;
00054 }
00055
00056 inline void setType(const ClusterType& type) {
00057 _type= type;
00058 }
00059 inline void setMesh(MeshNS::MeshSequencePtr dm) {
00060 _dm= dm;
00061 }
00062 void draw(const MeshNS::RenderMode& mode, int frame) const;
00063
00064 private:
00065 MeshNS::MeshSequencePtr _dm;
00066 ClusterType _type;
00067
00068 inline float myRand() { return ((float) rand()) / ((float) RAND_MAX); }
00069 inline void initColor() {
00070 _color.push_back(myRand());
00071 _color.push_back(myRand());
00072 _color.push_back(myRand());
00073 }
00074
00075 public:
00076
00077 std::vector<int> _indices;
00078 private:
00079 std::vector<float> _color;
00080 };
00081 }
00082
00083 #ifdef USE_QT4
00084 Q_DECLARE_METATYPE(SegmentationNS::Cluster)
00085 Q_DECLARE_METATYPE(SegmentationNS::Cluster*)
00086 #endif
00087
00088
00089 #endif