00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef VRN_SEGMENTLISTGEOMETRY_H
00029 #define VRN_SEGMENTLISTGEOMETRY_H
00030
00031 #include "voreen/core/datastructures/geometry/geometry.h"
00032 #include "tgt/glmath.h"
00033 #include <vector>
00034
00035 namespace voreen {
00036
00037 template<class T>
00038 class PointSegmentListGeometry : public Geometry {
00039
00040 public:
00041
00042 PointSegmentListGeometry() :
00043 Geometry(),
00044 numPoints_(0)
00045 { }
00046
00047 virtual ~PointSegmentListGeometry() { }
00048
00049 virtual void render() {
00050 glBegin(GL_POINTS);
00051 for (size_t i=0; i < segmentList_.size(); ++i){
00052 for (size_t j=0; j < segmentList_[i].size(); ++j){
00053
00054
00055 tgt::vertex(segmentList_[i][j]);
00056 }
00057 }
00058 glEnd();
00059 }
00060
00061 void setData(std::vector< std::vector<T> > segmentList) {
00062
00063 segmentList_ = segmentList;
00064 pointList_.clear();
00065 numPoints_ = 0;
00066 for (size_t i=0; i<segmentList_.size(); ++i) {
00067 numPoints_ += static_cast<int>(segmentList_[i].size());
00068 }
00069
00070 setHasChanged(true);
00071 }
00072
00073 void addSegment(std::vector<T> segment) {
00074 segmentList_.push_back(segment);
00075 pointList_.clear();
00076 numPoints_ += static_cast<int>(segment.size());
00077 setHasChanged(true);
00078 }
00079
00080 const std::vector< std::vector<T> >& getData() const { return segmentList_; }
00081
00082 const std::vector<T>& getPoints() {
00083
00084
00085 if (pointList_.empty() && numPoints_ > 0) {
00086 for (size_t i=0; i<segmentList_.size(); ++i) {
00087 pointList_.insert(pointList_.end(), segmentList_[i].begin(), segmentList_[i].end());
00088 }
00089 }
00090
00091 return pointList_;
00092 }
00093
00094 int getNumSegments() const { return static_cast<int>(segmentList_.size()); }
00095
00096 int getNumPoints() const { return numPoints_; }
00097
00098 protected:
00099
00100
00101 std::vector< std::vector<T> > segmentList_;
00102
00103
00104
00105 std::vector<T> pointList_;
00106
00107 int numPoints_;
00108
00109 };
00110
00111 typedef PointSegmentListGeometry<tgt::vec3> PointSegmentListGeometryVec3;
00112
00113 }
00114
00115 #endif // VRN_SEGMENTLISTGEOMETRY_H