StatusNodesT.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 //  Status Nodes
00049 //
00050 //=============================================================================
00051 
00052 
00053 #ifndef ACG_STATUS_NODES_HH
00054 #define ACG_STATUS_NODES_HH
00055 
00056 
00057 //== INCLUDES =================================================================
00058 
00059 
00060 #include <OpenMesh/Core/Mesh/Attributes.hh>
00061 
00062 #include "MaterialNode.hh"
00063 #include "DrawModes.hh"
00064 
00065 #include <vector>
00066 
00067 
00068 //== NAMESPACES ===============================================================
00069 
00070 
00071 namespace ACG {
00072 namespace SceneGraph {
00073 
00074 
00075 //== CLASS DEFINITION =========================================================
00076 
00077 
00083 template <class Mesh, class Mod>
00084 class StatusNodeT : public MaterialNode
00085 {
00086 public:
00087 
00089   StatusNodeT( const Mesh&         _mesh,
00090                BaseNode*           _parent = 0,
00091                const std::string&  _name   = "<StatusNode>" );
00092 
00094   ~StatusNodeT() {}
00095 
00096   ACG_CLASSNAME(StatusNode);
00097 
00098 
00102   void update_cache();
00103 
00104 
00105   DrawModes::DrawMode  availableDrawModes() const;
00106   void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
00107   void draw(GLState& _state, DrawModes::DrawMode _drawMode);
00108   void pick(GLState& /* _state */ , PickTarget /* _target */ ) {}
00109 
00110 
00111 private:
00112 
00113   typedef typename Mesh::Face        Face;
00114   typedef typename Mesh::Vertex      Vertex;
00115   typedef typename Mesh::Halfedge    Halfedge;
00116   typedef typename Mesh::Edge        Edge;
00117   typedef typename Mesh::FaceHandle  FaceHandle;
00118 
00119   void draw_points();
00120   void draw_edges();
00121   void draw_faces(bool _per_vertex);
00122 
00123 
00124 private:
00125 
00126   const Mesh&                mesh_;
00127   std::vector<unsigned int>  v_cache_, e_cache_, f_cache_;
00128   std::vector<FaceHandle>    fh_cache_;
00129 
00130   // bounding box
00131   Vec3d bbMin_;
00132   Vec3d bbMax_;
00133 };
00134 
00135 
00136 
00137 //== CLASS DEFINITION =========================================================
00138 
00139 
00140 template <class Mesh, unsigned int Bit>
00141 struct StatusModT
00142 {
00143   static bool is_vertex_selected(const Mesh& _mesh,
00144                                  typename Mesh::VertexHandle _vh)
00145   {
00146     return _mesh.status(_vh).is_bit_set(Bit);
00147   }
00148 
00149   static bool is_edge_selected(const Mesh& _mesh,
00150                                typename Mesh::EdgeHandle _eh)
00151   {
00152     return _mesh.status(_eh).is_bit_set(Bit);
00153   }
00154 
00155   static bool is_face_selected(const Mesh& _mesh,
00156                                typename Mesh::FaceHandle _fh)
00157   {
00158     return _mesh.status(_fh).is_bit_set(Bit);
00159   }
00160 };
00161 
00162 
00163 
00164 //== CLASS DEFINITION =========================================================
00165 
00166 
00167 template <class Mesh>
00168 struct SelectionModT
00169   : public StatusModT<Mesh, OpenMesh::Attributes::SELECTED>
00170 {};
00171 
00172 
00173 
00179 template <class Mesh>
00180 class SelectionNodeT
00181   : virtual public StatusNodeT<Mesh, SelectionModT<Mesh> >
00182 {
00183 public:
00184 
00190   SelectionNodeT( const Mesh&         _mesh,
00191                   BaseNode*           _parent = 0,
00192                   const std::string&  _name   = "<SelectionNode>" )
00193     : StatusNodeT<Mesh, SelectionModT<Mesh> > (_mesh, _parent, _name)
00194   {}
00195 };
00196 
00197 
00198 //== CLASS DEFINITION =========================================================
00199 
00200 
00201 template <class Mesh>
00202 struct LockModT
00203   : public StatusModT<Mesh, OpenMesh::Attributes::LOCKED>
00204 {};
00205 
00206 
00207 template <class Mesh>
00208 class LockNodeT : public StatusNodeT<Mesh, LockModT<Mesh> >
00209 {
00210 public:
00211 
00212   LockNodeT( const Mesh&         _mesh,
00213              BaseNode*           _parent = 0,
00214              const std::string&  _name   = "<LockNode>" )
00215     : StatusNodeT<Mesh, LockModT<Mesh> > (_mesh, _parent, _name)
00216   {}
00217 };
00218 
00219 
00220 //=============================================================================
00221 } // namespace SceneGraph
00222 } // namespace ACG
00223 //=============================================================================
00224 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_STATUS_NODES_C)
00225 #define ACG_STATUS_NODES_TEMPLATES
00226 #include "StatusNodesT.cc"
00227 #endif
00228 //=============================================================================
00229 #endif // ACG_STATUS_NODES_HH defined
00230 //=============================================================================
00231 

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