LineNode.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8548 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-12 14:40:13 +0100 (Fr, 12. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS LineNode
00049 //
00050 //=============================================================================
00051 
00052 
00053 #ifndef ACG_LINENODE_HH
00054 #define ACG_LINENODE_HH
00055 
00056 
00057 //== INCLUDES =================================================================
00058 
00059 #include "MaterialNode.hh"
00060 #include "DrawModes.hh"
00061 #include <vector>
00062 
00063 //== NAMESPACES ===============================================================
00064 
00065 namespace ACG {
00066 namespace SceneGraph {
00067 
00068 //== CLASS DEFINITION =========================================================
00069 
00070 
00071 
00081 class ACGDLLEXPORT LineNode : public MaterialNode
00082 {
00083 public:
00084 
00085   // typedefs
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 } // namespace SceneGraph
00188 } // namespace ACG
00189 //=============================================================================
00190 #endif // ACG_LINENODE_HH defined
00191 //=============================================================================
00192 

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .