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 
45 
46 
47 //=============================================================================
48 //
49 // CLASS PointNode
50 //
51 //=============================================================================
52 
53 
54 #ifndef ACG_POINTNODE_HH
55 #define ACG_POINTNODE_HH
56 
57 
58 //== INCLUDES =================================================================
59 
60 #include "BaseNode.hh"
61 #include "DrawModes.hh"
62 #include <ACG/GL/VertexDeclaration.hh>
63 #include <vector>
64 
65 //== NAMESPACES ===============================================================
66 
67 namespace ACG {
68 namespace SceneGraph {
69 
70 //== CLASS DEFINITION =========================================================
71 
72 
73 
82 class ACGDLLEXPORT PointNode : public BaseNode
83 {
84 public:
85 
86  // typedefs
87  typedef std::vector<ACG::Vec3d> PointVector;
88  typedef PointVector::iterator PointIter;
89  typedef PointVector::const_iterator ConstPointIter;
90  typedef std::vector<ACG::Vec4f> ColorVector;
91  typedef ColorVector::iterator ColorIter;
92  typedef ColorVector::const_iterator ConstColorIter;
93 
94 
96  PointNode( BaseNode* _parent=0,
97  const std::string & _name="<PointNode>" )
98  : BaseNode(_parent, _name)
99  {}
100 
103 
105  ACG_CLASSNAME(PointNode);
106 
108  DrawModes::DrawMode availableDrawModes() const override;
109 
111  void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) override;
112 
114  void draw(GLState& _state, const DrawModes::DrawMode& _drawMode) override;
115 
117  void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat) override;
118 
120  void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc) {
121  points_.reserve(_np); normals_.reserve(_nn); colors_.reserve(_nc);
122  }
123 
125  void add_point(const ACG::Vec3d& _p) { points_.push_back(_p); }
127  void add_normal(const ACG::Vec3d& _n) { normals_.push_back(_n); }
129  void add_color(const ACG::Vec4f& _c) { colors_.push_back(_c); }
130 
132  size_t n_points() const { return points_.size(); }
133 
135  void clear_points() { points_.clear(); }
137  void clear_normals() { normals_.clear(); }
139  void clear_colors() { colors_.clear(); }
141  void clear() { clear_points(); clear_normals(); clear_colors(); }
142 
144  PointVector& points() { return points_; }
146  PointVector& normals() { return normals_; }
148  ColorVector& colors() { return colors_; }
149 
150 
151 private:
152 
153  PointVector points_, normals_;
154  ColorVector colors_;
155 
156  VertexDeclaration vertexDecl_;
157 };
158 
159 
160 //=============================================================================
161 } // namespace SceneGraph
162 } // namespace ACG
163 //=============================================================================
164 #endif // ACG_POINTNODE_HH defined
165 //=============================================================================
size_t n_points() const
how many points?
Definition: PointNode.hh:132
PointNode(BaseNode *_parent=0, const std::string &_name="<PointNode>")
default constructor
Definition: PointNode.hh:96
void add_color(const ACG::Vec4f &_c)
add color
Definition: PointNode.hh:129
void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc)
reserve mem for _np points and _nn normals
Definition: PointNode.hh:120
Namespace providing different geometric functions concerning angles.
Class to define the vertex input layout.
void clear_normals()
clear normals
Definition: PointNode.hh:137
PointVector & normals()
get normal container
Definition: PointNode.hh:146
void clear()
clear points and normals and colors
Definition: PointNode.hh:141
void add_point(const ACG::Vec3d &_p)
add point
Definition: PointNode.hh:125
PointVector & points()
get point container
Definition: PointNode.hh:144
void clear_colors()
clear colors
Definition: PointNode.hh:139
ColorVector & colors()
get color container
Definition: PointNode.hh:148
void clear_points()
clear points
Definition: PointNode.hh:135
void add_normal(const ACG::Vec3d &_n)
add normal
Definition: PointNode.hh:127