00001 #ifndef LINE_3D_H_IS_INCLUDED
00002 #define LINE_3D_H_IS_INCLUDED
00003
00004 #include "disp/gel.H"
00005
00006
00007
00008
00009
00010
00011 #define CLINE3D const LINE3D
00012 #define CLINE3Dptr const LINE3Dptr
00013
00014 MAKE_PTR_SUBC(LINE3D,GEL);
00015 class LINE3D : public GEL {
00016 public:
00017
00018
00019
00020 LINE3D();
00021 LINE3D(mlib::CWpt_list& pts);
00022
00023 virtual ~LINE3D();
00024
00025
00026
00027 DEFINE_RTTI_METHODS3("LINE3D", LINE3D*, GEL, CDATA_ITEM*);
00028
00029
00030
00031
00032 void add(mlib::CWpt &p);
00033
00034
00035 void add(mlib::CWpt_list &p);
00036
00037
00038 void clear() { _pts.clear(); }
00039
00040
00041 void set(mlib::CWpt_list& p) {
00042 clear();
00043 add(p);
00044 }
00045
00046
00047 void set(int i, mlib::CWpt& p);
00048
00049
00050
00051
00052 int num() const { return _pts.num(); }
00053
00054
00055 bool empty() const { return _pts.empty(); }
00056
00057
00058 mlib::CWpt_list& pts() const { return _pts; }
00059
00060
00061 mlib::CWpt& operator[](int i) const { return _pts[i]; }
00062 mlib::CWpt& point(int i) const { return _pts[i]; }
00063
00064
00065
00066 mlib::Wpt point(double s) const { return _pts.interpolate(s);}
00067
00068
00069 mlib::Wvec tangent(int i) const { return _pts.tan(i); }
00070 mlib::Wvec normal (int i) const { return tangent(i).perpend();}
00071
00072
00073 double length() const { return _pts.length();}
00074
00075
00076 bool loop() const { return (num() > 1 && (_pts[0] == _pts.last())); }
00077
00078
00079
00080
00081 double width() const { return _width; }
00082 void set_width(double w) { _width = w; }
00083
00084 CCOLOR& color() const { return _color; }
00085 void set_color(CCOLOR& c) { _color = c; }
00086
00087 double alpha() const { return _alpha; }
00088 void set_alpha(double a) { _alpha = a; }
00089
00090 void set_do_stipple(bool b=true) { _do_stipple = b; }
00091
00092 bool no_depth() const { return _no_depth; }
00093 void set_no_depth(bool d) { _no_depth = d; }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void draw_start(CCOLOR& col, double a, double w, bool do_stipple);
00104 void draw_pts();
00105 void draw_end();
00106
00107
00108
00109 virtual RAYhit& intersect(RAYhit &r, mlib::CWtransf& = mlib::Identity, int=0) const;
00110
00111
00112
00113 virtual int draw(CVIEWptr&);
00114 virtual int draw_vis_ref();
00115
00116
00117
00118 virtual DATA_ITEM* dup() const { return new LINE3D(); }
00119
00120 protected:
00121
00122
00123
00124 mlib::Wpt_list _pts;
00125 double _width;
00126 COLOR _color;
00127 double _alpha;
00128 bool _do_stipple;
00129 bool _no_depth;
00130
00131
00132
00133 int _draw (CCOLOR& col, double a, double w, bool do_stipple);
00134 };
00135
00136
00137
00138
00139 class LINE3D_list : public GEL_list<LINE3Dptr> {
00140 public:
00141
00142
00143
00144 void set_alpha(double a) const {
00145 for (int k = 0; k < _num; k++)
00146 _array[k]->set_alpha(a);
00147 }
00148 void set_color(CCOLOR& c) const {
00149 for (int k = 0; k < _num; k++)
00150 _array[k]->set_color(c);
00151 }
00152 void set_width(double w) const {
00153 for (int k = 0; k < _num; k++)
00154 _array[k]->set_width(w);
00155 }
00156 void set_do_stipple(bool b=1) const {
00157 for (int k = 0; k < _num; k++)
00158 _array[k]->set_do_stipple(b);
00159 }
00160 void draw_pts() const {
00161 for (int k = 0; k < _num; k++)
00162 _array[k]->draw_pts();
00163 }
00164 int draw(CVIEWptr &v) const {
00165 int ret = 0;
00166 for (int k = 0; k < _num; k++)
00167 ret += _array[k]->draw(v);
00168 return ret;
00169 }
00170 };
00171
00172 #endif // LINE_3D_H_IS_INCLUDED
00173
00174