1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
25
#ifndef WDATASETPOINTS_H
26
#define WDATASETPOINTS_H
32
#include <boost/shared_ptr.hpp>
34
#include "../common/WBoundingBox.h"
38
* Dataset to store a bunch of points without order or topology.
40
class WDataSetPoints : public WDataSet // NOLINT
43
// some type alias for the used arrays.
47
typedef boost::shared_ptr< WDataSetPoints > SPtr;
50
* Pointer to const dataset.
52
typedef boost::shared_ptr< const WDataSetPoints > ConstSPtr;
55
* List of vertex coordinates in term of components of vertices.
57
typedef boost::shared_ptr< std::vector< float > > VertexArray;
60
* Colors for each vertex in VertexArray.
62
typedef boost::shared_ptr< std::vector< float > > ColorArray;
65
* Constructs a new set of points. If no color is specified, white is used for all points.
67
* \note the number of floats in vertices must be a multiple of 3
68
* \note the number of floats in colors (if not NULL) must be vertices->size() / 3 times one of 1,3, or 4
70
* \param vertices the vertices of the points, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
71
* \param colors the colors of each vertex. Can be NULL.. Stored as R1,G1,B1,A1, ... Rn,Gn,Bn,An
72
* \param boundingBox The bounding box of the points (first minimum, second maximum).
74
WDataSetPoints( VertexArray vertices, ColorArray colors,
75
WBoundingBox boundingBox );
78
* Constructs a new set of points. The bounding box is calculated during construction. If no color is specified, white is used for all
81
* \note the number of floats in vertices must be a multiple of 3
82
* \note the number of floats in colors (if not NULL) must be vertices->size() / 3 times one of 1,3, or 4
84
* \param vertices the vertices of the points, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
85
* \param colors the colors of each vertex. Can be NULL.. Stored as R1,[G1,B1,[A1,]] ... Rn,[Gn,Bn,[An]]
87
WDataSetPoints( VertexArray vertices, ColorArray colors );
90
* Constructs a new set of points. The constructed instance is empty..
97
virtual ~WDataSetPoints();
100
* Get number of points in this data set.
102
* \return number of points
107
* Determines whether this dataset can be used as a texture.
109
* \return true if usable as texture.
111
virtual bool isTexture() const;
114
* Gets the name of this prototype.
118
virtual const std::string getName() const;
121
* Gets the description for this prototype.
123
* \return the description
125
virtual const std::string getDescription() const;
128
* Returns a prototype instantiated with the true type of the deriving class.
130
* \return the prototype.
132
static boost::shared_ptr< WPrototyped > getPrototype();
135
* Getter for the point vertices
136
* \return The vertices
138
VertexArray getVertices() const;
141
* Getter for the point colors
144
ColorArray getColors() const;
147
* Get the bounding box.
148
* \return The bounding box of all points.
150
WBoundingBox getBoundingBox() const;
153
* Query coordinates of a given point.
155
* \throw WOutOfBounds if invalid index is used.
156
* \param pointIdx the point index.
158
* \return the coordinates
160
WPosition operator[]( const size_t pointIdx ) const;
163
* Query coordinates of a given point.
165
* \throw WOutOfBounds if invalid index is used.
166
* \param pointIdx the point index.
168
* \return the coordinates
170
WPosition getPosition( const size_t pointIdx ) const;
173
* The color of a given point.
175
* \throw WOutOfBounds if invalid index is used.
176
* \param pointIdx the point index.
180
WColor getColor( const size_t pointIdx ) const;
183
* Is this a valid point index?
185
* \param pointIdx the index to check
187
* \return true if yes.
189
bool isValidPointIdx( const size_t pointIdx ) const;
192
* The type of colors we have for each point.
202
* Check the type of color.
206
ColorType getColorType() const;
209
* The prototype as singleton.
211
static boost::shared_ptr< WPrototyped > m_prototype;
215
* Point vector for all points
217
VertexArray m_vertices;
220
* An array of the colors per vertex.
225
* Which colortype do we use in m_colors.
227
ColorType m_colorType;
230
* Axis aligned bounding box for all point-vertices of this dataset.
235
* Initialize arrays and bbox if needed. Used during construction.
237
* \param calcBB if true, the bounding box is calculated
239
void init( bool calcBB = false );
242
#endif // WDATASETPOINTS_H