Developer Documentation
PointNode.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 PointNode
56 //
57 //=============================================================================
58 
59 
60 #ifndef ACG_POINTNODE_HH
61 #define ACG_POINTNODE_HH
62 
63 
64 //== INCLUDES =================================================================
65 
66 #include "BaseNode.hh"
67 #include "DrawModes.hh"
68 #include <ACG/GL/VertexDeclaration.hh>
69 #include <vector>
70 
71 //== NAMESPACES ===============================================================
72 
73 namespace ACG {
74 namespace SceneGraph {
75 
76 //== CLASS DEFINITION =========================================================
77 
78 
79 
88 class ACGDLLEXPORT PointNode : public BaseNode
89 {
90 public:
91 
92  // typedefs
93  typedef std::vector<ACG::Vec3d> PointVector;
94  typedef PointVector::iterator PointIter;
95  typedef PointVector::const_iterator ConstPointIter;
96  typedef std::vector<ACG::Vec4f> ColorVector;
97  typedef ColorVector::iterator ColorIter;
98  typedef ColorVector::const_iterator ConstColorIter;
99 
100 
102  PointNode( BaseNode* _parent=0,
103  std::string _name="<PointNode>" )
104  : BaseNode(_parent, _name)
105  {}
106 
109 
111  ACG_CLASSNAME(PointNode);
112 
114  DrawModes::DrawMode availableDrawModes() const;
115 
117  void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
118 
120  void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
121 
123  void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat);
124 
126  void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc) {
127  points_.reserve(_np); normals_.reserve(_nn); colors_.reserve(_nc);
128  }
129 
131  void add_point(const ACG::Vec3d& _p) { points_.push_back(_p); }
133  void add_normal(const ACG::Vec3d& _n) { normals_.push_back(_n); }
135  void add_color(const ACG::Vec4f& _c) { colors_.push_back(_c); }
136 
138  size_t n_points() const { return points_.size(); }
139 
141  void clear_points() { points_.clear(); }
143  void clear_normals() { normals_.clear(); }
145  void clear_colors() { colors_.clear(); }
147  void clear() { clear_points(); clear_normals(); clear_colors(); }
148 
150  PointVector& points() { return points_; }
152  PointVector& normals() { return normals_; }
154  ColorVector& colors() { return colors_; }
155 
156 
157 private:
158 
159  PointVector points_, normals_;
160  ColorVector colors_;
161 
162  VertexDeclaration vertexDecl_;
163 };
164 
165 
166 //=============================================================================
167 } // namespace SceneGraph
168 } // namespace ACG
169 //=============================================================================
170 #endif // ACG_POINTNODE_HH defined
171 //=============================================================================
PointVector & points()
get point container
Definition: PointNode.hh:150
void clear_colors()
clear colors
Definition: PointNode.hh:145
size_t n_points() const
how many points?
Definition: PointNode.hh:138
void clear()
clear points and normals and colors
Definition: PointNode.hh:147
Class to define the vertex input layout.
void clear_points()
clear points
Definition: PointNode.hh:141
void add_normal(const ACG::Vec3d &_n)
add normal
Definition: PointNode.hh:133
void add_point(const ACG::Vec3d &_p)
add point
Definition: PointNode.hh:131
void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc)
reserve mem for _np points and _nn normals
Definition: PointNode.hh:126
PointVector & normals()
get normal container
Definition: PointNode.hh:152
ColorVector & colors()
get color container
Definition: PointNode.hh:154
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
PointNode(BaseNode *_parent=0, std::string _name="<PointNode>")
default constructor
Definition: PointNode.hh:102
void clear_normals()
clear normals
Definition: PointNode.hh:143
void add_color(const ACG::Vec4f &_c)
add color
Definition: PointNode.hh:135