Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
110 ACG_CLASSNAME(PolyLineNodeT);
111
113 DrawModes::DrawMode availableDrawModes() const;
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
193 ACG::VertexDeclaration vertexDecl_;
194
196 ACG::VertexDeclaration vertexDeclVCol_;
197
199 ACG::VertexDeclaration vertexDeclECol_;
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
242 PolyLine& polyline_;
243
245 unsigned int vbo_;
246
248 std::vector<unsigned int> selectedVertexIndexBuffer_;
249
251 std::vector<unsigned int> selectedEdgeIndexBuffer_;
252
254 bool updateVBO_;
255
257 GLSphere* sphere_;
258
260 DrawModes::DrawMode POINTS_SPHERES;
261
263 DrawModes::DrawMode POINTS_SPHERES_SCREEN;
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
ACG::SceneGraph::ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: MeshNode2T.cc:294
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
ACG::SceneGraph::PolyLineNodeT::availableDrawModes
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Definition: PolyLineNodeT.cc:131
ACG::SceneGraph::PolyLineNodeT::updateVBO_
bool updateVBO_
Flag to trigger update of vbo.
Definition: PolyLineNodeT.hh:254
ACG::SceneGraph::PolyLineNodeT::vertexDecl_
ACG::VertexDeclaration vertexDecl_
Vertex layout without vertex colors.
Definition: PolyLineNodeT.hh:193
ACG::SceneGraph::ACG::GLState
Definition: MeshNode2T.cc:220
ACG::PolyLineT
Definition: PolyLineT.hh:90
ACG::SceneGraph::PolyLineNodeT::setCustomBuffer
void setCustomBuffer(int _id, const void *_buffer)
Definition: PolyLineNodeT.cc:1118
ACG::SceneGraph::PolyLineNodeT::updateVBO
void updateVBO()
Trigger an update of the vbo.
Definition: PolyLineNodeT.cc:684
ACG::SceneGraph::PolyLineNodeT::sphere_
GLSphere * sphere_
Sphere for VertexSphere DrawMode.
Definition: PolyLineNodeT.hh:257
ACG::SceneGraph::PolyLineNodeT::polyline_
PolyLine & polyline_
The associated poly line.
Definition: PolyLineNodeT.hh:242
ACG::SceneGraph::PolyLineNodeT::vertexDeclVCol_
ACG::VertexDeclaration vertexDeclVCol_
Vertex layout with vertex colors.
Definition: PolyLineNodeT.hh:196
ACG::SceneGraph::PolyLineNodeT::addCustomBuffer
int addCustomBuffer(const ACG::VertexElement &_desc, const void *_buffer)
Definition: PolyLineNodeT.cc:1098
ACG::SceneGraph::PolyLineNodeT::operator=
PolyLineNodeT & operator=(const PolyLineNodeT &_rhs)
Assignment operator (not used)
ACG::GLState
Definition: GLState.hh:220
ACG::SceneGraph::PolyLineNodeT::~PolyLineNodeT
~PolyLineNodeT()
Destructor.
Definition: PolyLineNodeT.cc:105
ACG::GLSphere
Definition: GLPrimitives.hh:137
ACG::SceneGraph::PolyLineNodeT::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
Definition: PolyLineNodeT.cc:115
ACG::SceneGraph::PolyLineNodeT::writeVertex
void writeVertex(unsigned int _vertex, void *_dst)
Write vertex data for rendering to a buffer.
Definition: PolyLineNodeT.cc:810
ACG::SceneGraph::PolyLineNodeT::PolyLineNodeT
PolyLineNodeT(PolyLine &_pl, BaseNode *_parent=0, std::string _name="<PolyLineNode>")
Constructor.
Definition: PolyLineNodeT.cc:78
ACG::SceneGraph::PolyLineNodeT::selectedEdgeIndexBuffer_
std::vector< unsigned int > selectedEdgeIndexBuffer_
Index buffer for selected edges.
Definition: PolyLineNodeT.hh:251
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
ACG::SceneGraph::PolyLineNodeT::selectedVertexIndexBuffer_
std::vector< unsigned int > selectedVertexIndexBuffer_
Index buffer for selected vertices.
Definition: PolyLineNodeT.hh:248
ACG::SceneGraph::ACG::SceneGraph::Material
Definition: MeshNode2T.cc:85
ACG::SceneGraph::ACG::VertexDeclaration
Class to define the vertex input layout.
Definition: MeshNode2T.cc:266
ACG::SceneGraph::PolyLineNodeT::writeVertexColor
void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void *_dst) const
Write color for rendering to a buffer.
Definition: PolyLineNodeT.cc:776
ACG::SceneGraph::PolyLineNodeT::polylinePropMap_
std::map< typename PolyLine::CustomPropertyHandle, int > polylinePropMap_
Map from custom properties in PolyLine to id in customBuffers_.
Definition: PolyLineNodeT.hh:205
ACG::SceneGraph::PolyLineNodeT::vbo_
unsigned int vbo_
VBO used to render the poly line.
Definition: PolyLineNodeT.hh:245
ACG::SceneGraph::PolyLineNodeT::pick
void pick(GLState &_state, PickTarget _target)
picking
Definition: PolyLineNodeT.cc:371
ACG::SceneGraph::PolyLineNodeT
Definition: PolyLineNodeT.hh:94
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::ACG::IRenderer
Definition: MeshNode2T.cc:84
ACG::VertexDeclaration
Class to define the vertex input layout.
Definition: VertexDeclaration.hh:266
ACG::SceneGraph::PolyLineNodeT::getRenderObjects
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.
Definition: PolyLineNodeT.cc:860
ACG::SceneGraph::PolyLineNodeT::POINTS_SPHERES
DrawModes::DrawMode POINTS_SPHERES
This defines a local point spheres draw mode for all polyLine nodes.
Definition: PolyLineNodeT.hh:260
ACG::SceneGraph::ACG::VertexElement
Description of one vertex element.
Definition: MeshNode2T.cc:84
ACG::SceneGraph::PolyLineNodeT::setupVertexDeclaration
void setupVertexDeclaration(VertexDeclaration *_dst, int _colorSource) const
Create the vertex declaration.
Definition: PolyLineNodeT.cc:631
ACG::SceneGraph::PolyLineNodeT::ACG_CLASSNAME
ACG_CLASSNAME(PolyLineNodeT)
static name of this class
ACG::SceneGraph::PolyLineNodeT::update
void update()
Trigger an update of the vbo.
Definition: PolyLineNodeT.hh:134
ACG::SceneGraph::PolyLineNodeT::vertexDeclECol_
ACG::VertexDeclaration vertexDeclECol_
Vertex layout with edge colors.
Definition: PolyLineNodeT.hh:199
ACG::SceneGraph::PolyLineNodeT::customBuffers_
std::vector< std::pair< ACG::VertexElement, const void * > > customBuffers_
Custom vertex data for shader based rendering.
Definition: PolyLineNodeT.hh:202
ACG::SceneGraph::PolyLineNodeT::POINTS_SPHERES_SCREEN
DrawModes::DrawMode POINTS_SPHERES_SCREEN
This defines a local point spheres draw mode for all polyLine nodes with constant screen size...
Definition: PolyLineNodeT.hh:263
ACG::SceneGraph::PolyLineNodeT::draw
void draw(GLState &, const DrawModes::DrawMode &_drawMode)
draw lines and normals
Definition: PolyLineNodeT.cc:143