28 #include "../common/exceptions/WOutOfBounds.h"
29 #include "../common/WAssert.h"
30 #include "../common/WColor.h"
31 #include "../common/math/linearAlgebra/WPosition.h"
33 #include "WDataSetPoints.h"
41 m_vertices( vertices ),
45 WAssert( vertices->size() % 3 == 0,
"Number of floats in the vertex array must be a multiple of 3" );
48 size_t numPoints = vertices->size() / 3;
49 WAssert( ( colors->size() / 4 == numPoints ) ||
50 ( colors->size() / 3 == numPoints ) ||
51 ( colors->size() / 1 == numPoints )
52 ,
"Number of floats in the color array must be 1,3, or 4 per vertex" );
60 m_vertices( vertices ),
63 WAssert( vertices->size() % 3 == 0,
"Number of floats in the vertex array must be a multiple of 3" );
66 size_t numPoints = vertices->size() / 3;
67 WAssert( ( colors->size() / 4 == numPoints ) ||
68 ( colors->size() / 3 == numPoints ) ||
69 ( colors->size() / 1 == numPoints )
70 ,
"Number of floats in the color array must be 1,3, or 4 per vertex" );
106 for(
size_t pointIdx = 3; pointIdx <
m_vertices->size(); pointIdx+=3 )
108 minX = std::min(
m_vertices->operator[]( pointIdx + 0 ), minX );
109 minY = std::min(
m_vertices->operator[]( pointIdx + 1 ), minY );
110 minZ = std::min(
m_vertices->operator[]( pointIdx + 2 ), minZ );
111 maxX = std::max(
m_vertices->operator[]( pointIdx + 0 ), maxX );
112 maxY = std::max(
m_vertices->operator[]( pointIdx + 1 ), maxY );
113 maxZ = std::max(
m_vertices->operator[]( pointIdx + 2 ), maxZ );
135 return "WDataSetPoints";
140 return "Dataset which contains points without any topological relation.";
172 throw WOutOfBounds(
"The specified index is invalid." );
189 throw WOutOfBounds(
"The specified index is invalid." );
195 return WColor(
m_colors->operator[]( pointIdx * 1 + 0 ),
196 m_colors->operator[]( pointIdx * 1 + 0 ),
197 m_colors->operator[]( pointIdx * 1 + 0 ),
200 return WColor(
m_colors->operator[]( pointIdx * 3 + 0 ),
201 m_colors->operator[]( pointIdx * 3 + 1 ),
202 m_colors->operator[]( pointIdx * 3 + 2 ),
205 return WColor(
m_colors->operator[]( pointIdx * 4 + 0 ),
206 m_colors->operator[]( pointIdx * 4 + 1 ),
207 m_colors->operator[]( pointIdx * 4 + 2 ),
208 m_colors->operator[]( pointIdx * 4 + 3 ) );
210 return WColor( 1.0, 1.0, 1.0, 1.0 );
216 return ( pointIdx < m_vertices->
size() / 3 );
ColorArray getColors() const
Getter for the point colors.
WPosition getPosition(const size_t pointIdx) const
Query coordinates of a given point.
WPosition operator[](const size_t pointIdx) const
Query coordinates of a given point.
WBoundingBox getBoundingBox() const
Get the bounding box.
virtual const std::string getDescription() const
Gets the description for this prototype.
Indicates invalid element access of a container.
WColor getColor(const size_t pointIdx) const
The color of a given point.
This only is a 3d double vector.
VertexArray m_vertices
Point vector for all points.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
ColorArray m_colors
An array of the colors per vertex.
bool isValidPointIdx(const size_t pointIdx) const
Is this a valid point index?
WDataSetPoints()
Constructs a new set of points.
VertexArray getVertices() const
Getter for the point vertices.
void init(bool calcBB=false)
Initialize arrays and bbox if needed.
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
virtual ~WDataSetPoints()
Destructor.
ColorType getColorType() const
Check the type of color.
virtual const std::string getName() const
Gets the name of this prototype.
WBoundingBox m_bb
Axis aligned bounding box for all point-vertices of this dataset.
ColorType m_colorType
Which colortype do we use in m_colors.
boost::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
size_t size() const
Get number of points in this data set.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
ColorType
The type of colors we have for each point.
boost::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.