Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PolyLineCollectionNodeT.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 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef POLYLINE_COLLECTION_NODE_T_HH
51 #define POLYLINE_COLLECTION_NODE_T_HH
52 
53 
54 //== INCLUDES =================================================================
55 
56 #include <ACG/Scenegraph/BaseNode.hh>
57 #include <ACG/Scenegraph/DrawModes.hh>
58 #include <ACG/GL/VertexDeclaration.hh>
59 #include <ACG/GL/IRenderer.hh>
60 #include <ACG/GL/GLPrimitives.hh>
61 
62 //== FORWARDDECLARATIONS ======================================================
63 
64 //== NAMESPACES ===============================================================
65 
66 namespace ACG {
67 namespace SceneGraph {
68 
69 //== CLASS DEFINITION =========================================================
70 
71 
72 
73 
79 template <class PolyLineCollection>
81 {
82 public:
83 
84  // typedefs for easy access
85  typedef typename PolyLineCollection::PolyLine::Point Point;
86 
88  PolyLineCollectionNodeT(PolyLineCollection& _pl, BaseNode* _parent = 0, std::string _name = "<PolyLineCollectionNode>");
89 
92 
93  PolyLineCollection& polyline_collection() { return polyline_collection_; }
94 
97 
99  DrawModes::DrawMode availableDrawModes() const;
100 
102  void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
103 
105  void draw(GLState& /*_state*/,const DrawModes::DrawMode& _drawMode);
106 
108  void pick(GLState& _state, PickTarget _target);
109 
117  void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
118 
120  void update() { updateVBO_ = true; };
121  void resetVBO() {offsets_.clear();}
122 
123 private:
124 
127 
130 
133 
139  void updateVBO();
140 
146  void writeVertex(typename PolyLineCollection::PolyLine* _polyline, unsigned int _vertex, void* _dst);
147 
148 private:
149 
152 
154  unsigned int vbo_;
155 
158 
161 
162  std::vector<std::pair<size_t, size_t> > offsets_;
163 
164  size_t total_vertex_count_;
165 };
166 
167 
168 //=============================================================================
169 } // namespace SceneGraph
170 } // namespace ACG
171 //=============================================================================
172 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINECOLLECTIONNODET_C)
173 #define ACG_POLYLINECOLLECTIONNODET_TEMPLATES
174 #include "PolyLineCollectionNodeT.cc"
175 #endif
176 
177 
178 #endif // POLYLINE_COLLECTION_NODE_T_HH
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 pick(GLState &_state, PickTarget _target)
picking
void draw(GLState &, const DrawModes::DrawMode &_drawMode)
draw lines and normals
unsigned int vbo_
VBO used to render the poly line.
void update()
Trigger an update of the vbo.
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
Class to define the vertex input layout.
Definition: MeshNode2T.cc:266
bool updateVBO_
Flag to trigger update of vbo.
void writeVertex(typename PolyLineCollection::PolyLine *_polyline, unsigned int _vertex, void *_dst)
Write vertex data for rendering to a buffer.
ACG::VertexDeclaration vertexDecl_
Buffer organization.
GLSphere * sphere_
Sphere for VertexSphere DrawMode.
void updateVBO()
Trigger an update of the vbo.
PolyLineCollectionNodeT(PolyLineCollection &_pl, BaseNode *_parent=0, std::string _name="<PolyLineCollectionNode>")
Constructor.
DrawModes::DrawMode availableDrawModes() const
return available draw modes
PolyLineCollectionNodeT & operator=(const PolyLineCollectionNodeT &_rhs)
Assignment operator (not used)
PolyLineCollection & polyline_collection_
The associated poly line collection.
ACG_CLASSNAME(PolyLineCollectionNodeT)
static name of this class
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box