Developer Documentation
PolyLineNodeT.hh
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // CLASS PolyLineNodeT
56 //
57 // Author: David Bommes <bommes@cs.rwth-aachen.de>
58 //
59 //=============================================================================
60 
61 
62 #ifndef ACG_POLYLINENODET_HH
63 #define ACG_POLYLINENODET_HH
64 
65 
66 //== INCLUDES =================================================================
67 
68 #include <ACG/Scenegraph/BaseNode.hh>
69 #include <ACG/Scenegraph/DrawModes.hh>
70 #include <ACG/GL/VertexDeclaration.hh>
71 #include <ACG/GL/IRenderer.hh>
72 #include <ACG/GL/GLPrimitives.hh>
73 
74 //== FORWARDDECLARATIONS ======================================================
75 
76 //== NAMESPACES ===============================================================
77 
78 namespace ACG {
79 namespace SceneGraph {
80 
81 //== CLASS DEFINITION =========================================================
82 
83 
84 
85 
93 template <class PolyLine>
94 class PolyLineNodeT : public BaseNode
95 {
96 public:
97 
98  // typedefs for easy access
99  typedef typename PolyLine::Point Point;
100 
102  PolyLineNodeT(PolyLine& _pl, BaseNode* _parent = 0, std::string _name = "<PolyLineNode>");
103 
105  ~PolyLineNodeT();
106 
107  PolyLine& polyline() { return polyline_; }
108 
111 
114 
116  void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
117 
119  void draw(GLState& /*_state*/,const DrawModes::DrawMode& _drawMode);
120 
122  void pick(GLState& _state, PickTarget _target);
123 
131  void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
132 
134  void update() { updateVBO_ = true; };
135 
136 
169  int addCustomBuffer(const ACG::VertexElement& _desc, const void* _buffer);
170 
171 
177  void setCustomBuffer(int _id, const void* _buffer);
178 
179 private:
180 
181  void pick_vertices ( GLState& _state );
182  void pick_spheres ( GLState& _state );
183  void pick_spheres_screen ( GLState& _state );
184  void pick_edges ( GLState& _state, unsigned int _offset);
185 
187  PolyLineNodeT(const PolyLineNodeT& _rhs);
188 
190  PolyLineNodeT& operator=(const PolyLineNodeT& _rhs);
191 
194 
197 
200 
202  std::vector< std::pair<ACG::VertexElement, const void*> > customBuffers_;
203 
205  std::map< typename PolyLine::CustomPropertyHandle, int> polylinePropMap_;
206 
212  void updateVBO();
213 
222  void setupVertexDeclaration(VertexDeclaration* _dst, int _colorSource) const;
223 
229  void writeVertex(unsigned int _vertex, void* _dst);
230 
237  void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void* _dst) const;
238 
239 private:
240 
243 
245  unsigned int vbo_;
246 
248  std::vector<unsigned int> selectedVertexIndexBuffer_;
249 
251  std::vector<unsigned int> selectedEdgeIndexBuffer_;
252 
255 
258 
261 
264 };
265 
266 
267 //=============================================================================
268 } // namespace SceneGraph
269 } // namespace ACG
270 //=============================================================================
271 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINENODET_C)
272 #define ACG_POLYLINENODET_TEMPLATES
273 #include "PolyLineNodeT.cc"
274 #endif
275 //=============================================================================
276 #endif // ACG_POLYLINENODET_HH defined
277 //=============================================================================
278 
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Class to define the vertex input layout.
Definition: MeshNode2T.cc:266
void getRenderObjects(ACG::IRenderer *_renderer, ACG::GLState &_state, const ACG::SceneGraph::DrawModes::DrawMode &_drawMode, const ACG::SceneGraph::Material *_mat)
Add the objects to the given renderer.
void draw(GLState &, const DrawModes::DrawMode &_drawMode)
draw lines and normals
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
std::vector< std::pair< ACG::VertexElement, const void * > > customBuffers_
Custom vertex data for shader based rendering.
void setCustomBuffer(int _id, const void *_buffer)
bool updateVBO_
Flag to trigger update of vbo.
PolyLine & polyline_
The associated poly line.
ACG::VertexDeclaration vertexDeclVCol_
Vertex layout with vertex colors.
Class to define the vertex input layout.
unsigned int vbo_
VBO used to render the poly line.
void writeVertex(unsigned int _vertex, void *_dst)
Write vertex data for rendering to a buffer.
DrawModes::DrawMode POINTS_SPHERES_SCREEN
This defines a local point spheres draw mode for all polyLine nodes with constant screen size...
void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void *_dst) const
Write color for rendering to a buffer.
std::map< typename PolyLine::CustomPropertyHandle, int > polylinePropMap_
Map from custom properties in PolyLine to id in customBuffers_.
ACG::VertexDeclaration vertexDecl_
Vertex layout without vertex colors.
PolyLineNodeT & operator=(const PolyLineNodeT &_rhs)
Assignment operator (not used)
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
ACG_CLASSNAME(PolyLineNodeT)
static name of this class
ACG::VertexDeclaration vertexDeclECol_
Vertex layout with edge colors.
int addCustomBuffer(const ACG::VertexElement &_desc, const void *_buffer)
Description of one vertex element.
Definition: MeshNode2T.cc:84
void updateVBO()
Trigger an update of the vbo.
GLSphere * sphere_
Sphere for VertexSphere DrawMode.
void pick(GLState &_state, PickTarget _target)
picking
void setupVertexDeclaration(VertexDeclaration *_dst, int _colorSource) const
Create the vertex declaration.
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
std::vector< unsigned int > selectedEdgeIndexBuffer_
Index buffer for selected edges.
DrawModes::DrawMode POINTS_SPHERES
This defines a local point spheres draw mode for all polyLine nodes.
std::vector< unsigned int > selectedVertexIndexBuffer_
Index buffer for selected vertices.
PolyLineNodeT(PolyLine &_pl, BaseNode *_parent=0, std::string _name="<PolyLineNode>")
Constructor.
void update()
Trigger an update of the vbo.