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
45
46
47 //=============================================================================
48 //
49 // CLASS PolyLineNodeT
50 //
51 // Author: David Bommes <bommes@cs.rwth-aachen.de>
52 //
53 //=============================================================================
54
55
56 #ifndef ACG_POLYLINENODET_HH
57 #define ACG_POLYLINENODET_HH
58
59
60 //== INCLUDES =================================================================
61
62 #include <ACG/Scenegraph/BaseNode.hh>
63 #include <ACG/Scenegraph/DrawModes.hh>
64 #include <ACG/GL/VertexDeclaration.hh>
65 #include <ACG/GL/IRenderer.hh>
66 #include <ACG/GL/GLPrimitives.hh>
67 #include <ACG/GL/globjects.hh>
68
69 //== FORWARDDECLARATIONS ======================================================
70
71 //== NAMESPACES ===============================================================
72
73 namespace ACG {
74 namespace SceneGraph {
75
76 //== CLASS DEFINITION =========================================================
77
78
79
80
88 template <class PolyLine>
89 class PolyLineNodeT : public BaseNode
90 {
91 public:
92
93 // typedefs for easy access
94 typedef typename PolyLine::Point Point;
95
97 PolyLineNodeT(PolyLine& _pl, BaseNode* _parent = 0, std::string _name = "<PolyLineNode>");
98
100 ~PolyLineNodeT();
101
102 PolyLine& polyline() { return polyline_; }
103
105 ACG_CLASSNAME(PolyLineNodeT);
106
108 DrawModes::DrawMode availableDrawModes() const;
109
111 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
112
114 void draw(GLState& /*_state*/,const DrawModes::DrawMode& _drawMode);
115
117 void pick(GLState& _state, PickTarget _target);
118
126 void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
127
129 void update() { updateVBO_ = true; };
130
131
164 int addCustomBuffer(const ACG::VertexElement& _desc, const void* _buffer);
165
166
172 void setCustomBuffer(int _id, const void* _buffer);
173
174
175
184 void setupVertexDeclaration(VertexDeclaration* _dst, int _colorSource) const;
185
186
199 size_t fillVertexBuffer(void* _buf, size_t _bufSize, bool _addLineStripEndVertex);
200
201 private:
202
203 void pick_vertices ( GLState& _state );
204 void pick_spheres ( GLState& _state );
205 void pick_spheres_screen ( GLState& _state );
206 void pick_edges ( GLState& _state, unsigned int _offset);
207
209 PolyLineNodeT(const PolyLineNodeT& _rhs);
210
212 PolyLineNodeT& operator=(const PolyLineNodeT& _rhs);
213
215 ACG::VertexDeclaration vertexDecl_;
216
218 ACG::VertexDeclaration vertexDeclVCol_;
219
221 ACG::VertexDeclaration vertexDeclECol_;
222
224 std::vector< std::pair<ACG::VertexElement, const void*> > customBuffers_;
225
227 std::map< typename PolyLine::CustomPropertyHandle, int> polylinePropMap_;
228
234 void updateVBO();
235
241 void writeVertex(unsigned int _vertex, void* _dst);
242
249 void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void* _dst) const;
250
251 private:
252
254 PolyLine& polyline_;
255
257 GeometryBuffer vbo_;
258
260 std::vector<unsigned int> selectedVertexIndexBuffer_;
261
263 std::vector<unsigned int> selectedEdgeIndexBuffer_;
264
266 bool updateVBO_;
267
269 GLSphere* sphere_;
270
272 DrawModes::DrawMode POINTS_SPHERES;
273
275 DrawModes::DrawMode POINTS_SPHERES_SCREEN;
276 };
277
278
279 //=============================================================================
280 } // namespace SceneGraph
281 } // namespace ACG
282 //=============================================================================
283 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINENODET_C)
284 #define ACG_POLYLINENODET_TEMPLATES
285 #include "PolyLineNodeT_impl.hh"
286 #endif
287 //=============================================================================
288 #endif // ACG_POLYLINENODET_HH defined
289 //=============================================================================
290
ACG::SceneGraph::PolyLineNodeT::update
void update()
Trigger an update of the vbo.
Definition: PolyLineNodeT.hh:129
ACG::SceneGraph::PolyLineNodeT
Definition: PolyLineNodeT.hh:89
ACG::SceneGraph::PolyLineNodeT::selectedVertexIndexBuffer_
std::vector< unsigned int > selectedVertexIndexBuffer_
Index buffer for selected vertices.
Definition: PolyLineNodeT.hh:260
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::VertexDeclaration
Class to define the vertex input layout.
Definition: VertexDeclaration.hh:268
ACG::SceneGraph::ACG::GLState
Definition: MeshNode2T_impl.hh:213
ACG::SceneGraph::PolyLineNodeT::updateVBO
void updateVBO()
Trigger an update of the vbo.
Definition: PolyLineNodeT_impl.hh:757
ACG::SceneGraph::PolyLineNodeT::writeVertexColor
void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void *_dst) const
Write color for rendering to a buffer.
Definition: PolyLineNodeT_impl.hh:809
ACG::SceneGraph::PolyLineNodeT::vbo_
GeometryBuffer vbo_
VBO used to render the poly line.
Definition: PolyLineNodeT.hh:257
ACG::SceneGraph::PolyLineNodeT::addCustomBuffer
int addCustomBuffer(const ACG::VertexElement &_desc, const void *_buffer)
Definition: PolyLineNodeT_impl.hh:1131
ACG::SceneGraph::PolyLineNodeT::availableDrawModes
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Definition: PolyLineNodeT_impl.hh:124
ACG::SceneGraph::PolyLineNodeT::polyline_
PolyLine & polyline_
The associated poly line.
Definition: PolyLineNodeT.hh:254
ACG::GLState
Definition: GLState.hh:213
ACG::SceneGraph::PolyLineNodeT::writeVertex
void writeVertex(unsigned int _vertex, void *_dst)
Write vertex data for rendering to a buffer.
Definition: PolyLineNodeT_impl.hh:843
ACG::SceneGraph::PolyLineNodeT::setCustomBuffer
void setCustomBuffer(int _id, const void *_buffer)
Definition: PolyLineNodeT_impl.hh:1151
ACG::SceneGraph::PolyLineNodeT::polylinePropMap_
std::map< typename PolyLine::CustomPropertyHandle, int > polylinePropMap_
Map from custom properties in PolyLine to id in customBuffers_.
Definition: PolyLineNodeT.hh:227
ACG::PolyLineT
Definition: PolyLineT.hh:84
ACG::SceneGraph::PolyLineNodeT::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
Definition: PolyLineNodeT_impl.hh:108
ACG::SceneGraph::PolyLineNodeT::pick
void pick(GLState &_state, PickTarget _target)
picking
Definition: PolyLineNodeT_impl.hh:364
ACG::SceneGraph::PolyLineNodeT::draw
void draw(GLState &, const DrawModes::DrawMode &_drawMode)
draw lines and normals
Definition: PolyLineNodeT_impl.hh:136
ACG::SceneGraph::PolyLineNodeT::setupVertexDeclaration
void setupVertexDeclaration(VertexDeclaration *_dst, int _colorSource) const
Create the vertex declaration.
Definition: PolyLineNodeT_impl.hh:638
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_impl.hh:893
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:275
ACG::SceneGraph::PolyLineNodeT::sphere_
GLSphere * sphere_
Sphere for VertexSphere DrawMode.
Definition: PolyLineNodeT.hh:269
ACG::GLSphere
Definition: GLPrimitives.hh:139
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::VertexElement
Description of one vertex element.
Definition: VertexDeclaration.hh:78
ACG::SceneGraph::Material
Definition: MaterialNode.hh:79
ACG::SceneGraph::PolyLineNodeT::customBuffers_
std::vector< std::pair< ACG::VertexElement, const void * > > customBuffers_
Custom vertex data for shader based rendering.
Definition: PolyLineNodeT.hh:224
ACG::SceneGraph::PolyLineNodeT::~PolyLineNodeT
~PolyLineNodeT()
Destructor.
Definition: PolyLineNodeT_impl.hh:98
ACG::SceneGraph::PolyLineNodeT::selectedEdgeIndexBuffer_
std::vector< unsigned int > selectedEdgeIndexBuffer_
Index buffer for selected edges.
Definition: PolyLineNodeT.hh:263
SceneGraph
Definition: QtPrincipalAxisDialog.hh:67
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: PickTarget.hh:73
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::PolyLineNodeT::fillVertexBuffer
size_t fillVertexBuffer(void *_buf, size_t _bufSize, bool _addLineStripEndVertex)
Fill a buffer with vertex data.
Definition: PolyLineNodeT_impl.hh:691
ACG::SceneGraph::PolyLineNodeT::updateVBO_
bool updateVBO_
Flag to trigger update of vbo.
Definition: PolyLineNodeT.hh:266
ACG::SceneGraph::PolyLineNodeT::vertexDecl_
ACG::VertexDeclaration vertexDecl_
Vertex layout without vertex colors.
Definition: PolyLineNodeT.hh:215
ACG::IRenderer
Definition: IRenderer.hh:78
ACG::SceneGraph::PolyLineNodeT::PolyLineNodeT
PolyLineNodeT(PolyLine &_pl, BaseNode *_parent=0, std::string _name="<PolyLineNode>")
Constructor.
Definition: PolyLineNodeT_impl.hh:72
ACG::SceneGraph::PolyLineNodeT::operator=
PolyLineNodeT & operator=(const PolyLineNodeT &_rhs)
Assignment operator (not used)
ACG::SceneGraph::PolyLineNodeT::ACG_CLASSNAME
ACG_CLASSNAME(PolyLineNodeT)
static name of this class
ACG::SceneGraph::PolyLineNodeT::POINTS_SPHERES
DrawModes::DrawMode POINTS_SPHERES
This defines a local point spheres draw mode for all polyLine nodes.
Definition: PolyLineNodeT.hh:272
ACG::SceneGraph::PolyLineNodeT::vertexDeclECol_
ACG::VertexDeclaration vertexDeclECol_
Vertex layout with edge colors.
Definition: PolyLineNodeT.hh:221
ACG::SceneGraph::PolyLineNodeT::vertexDeclVCol_
ACG::VertexDeclaration vertexDeclVCol_
Vertex layout with vertex colors.
Definition: PolyLineNodeT.hh:218