LineNode.hh
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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef ACG_LINENODE_HH
00054 #define ACG_LINENODE_HH
00055
00056
00057
00058
00059 #include "MaterialNode.hh"
00060 #include "DrawModes.hh"
00061 #include <vector>
00062
00063
00064
00065 namespace ACG {
00066 namespace SceneGraph {
00067
00068
00069
00070
00071
00081 class ACGDLLEXPORT LineNode : public MaterialNode
00082 {
00083 public:
00084
00085
00086 typedef std::vector<Vec3f> PointVector;
00087 typedef PointVector::iterator PointIter;
00088 typedef PointVector::const_iterator ConstPointIter;
00089 typedef std::vector<ACG::Vec3uc> ColorVector;
00090 typedef ColorVector::iterator ColorIter;
00091 typedef ColorVector::const_iterator ConstColorIter;
00092
00094 enum LineMode { LineSegmentsMode, PolygonMode };
00095
00096
00097
00099 LineNode( LineMode _mode,
00100 BaseNode* _parent=0,
00101 std::string _name="<LineNode>" ) :
00102 MaterialNode(_parent,
00103 _name,
00104 MaterialNode::BaseColor |
00105 MaterialNode::LineWidth),
00106 line_mode_(_mode)
00107 {
00108 drawMode(DrawModes::WIREFRAME);
00109 }
00110
00112 ~LineNode() {}
00113
00114
00116 void set_line_mode(LineMode _mode) { line_mode_ = _mode; }
00117
00118
00119
00121 ACG_CLASSNAME(LineNode);
00122
00124 DrawModes::DrawMode availableDrawModes() const;
00125
00127 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
00128
00130 void draw(GLState& _state, DrawModes::DrawMode _drawMode);
00131
00132
00133
00134
00136 void reserve_lines(unsigned int _n) { points_.reserve(2*_n); }
00137
00139 void reserve_points(unsigned int _n) { points_.reserve(_n); }
00140
00142 void clear() { clear_points(); clear_colors(); }
00144 void clear_points() { points_.clear(); }
00146 void clear_colors() { colors_.clear(); }
00147
00148
00150 void add_point(const Vec3f& _v) { points_.push_back(_v); }
00151
00153 void add_line(const Vec3f& _v0, const Vec3f& _v1) {
00154 add_point(_v0); add_point(_v1);
00155 }
00157 void add_color(const ACG::Vec3uc& _c) { colors_.push_back(_c); }
00158
00159
00161 unsigned int n_points() const { return points_.size(); }
00162
00164 const PointVector& points() const { return points_; }
00165
00167 ColorVector& colors() { return colors_; }
00168
00169
00171 void push_back(const Vec3f& _v) { points_.push_back(_v); }
00172 typedef Vec3f value_type;
00173 typedef Vec3f& reference;
00174 typedef const Vec3f& const_reference;
00175
00176
00177 protected:
00178
00179 PointVector points_;
00180 ColorVector colors_;
00181
00182 LineMode line_mode_;
00183 };
00184
00185
00186
00187 }
00188 }
00189
00190 #endif // ACG_LINENODE_HH defined
00191
00192