StatusNodesT.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_STATUS_NODES_HH
00054 #define ACG_STATUS_NODES_HH
00055
00056
00057
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
00069
00070
00071 namespace ACG {
00072 namespace SceneGraph {
00073
00074
00075
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& , PickTarget ) {}
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
00131 Vec3d bbMin_;
00132 Vec3d bbMax_;
00133 };
00134
00135
00136
00137
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
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
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 }
00222 }
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