29 #include "../common/WAssert.h"
30 #include "../common/WColor.h"
31 #include "../common/exceptions/WOutOfBounds.h"
32 #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" );
61 m_vertices( vertices ),
65 WAssert( vertices->size() % 3 == 0,
"Number of floats in the vertex array must be a multiple of 3" );
68 size_t numPoints = vertices->size() / 3;
69 WAssert( ( colors->size() / 4 == numPoints ) ||
70 ( colors->size() / 3 == numPoints ) ||
71 ( colors->size() / 1 == numPoints )
72 ,
"Number of floats in the color array must be 1,3, or 4 per vertex" );
120 for(
size_t pointIdx = 3; pointIdx <
m_vertices->size(); pointIdx+=3 )
122 minX = std::min(
m_vertices->operator[]( pointIdx + 0 ), minX );
123 minY = std::min(
m_vertices->operator[]( pointIdx + 1 ), minY );
124 minZ = std::min(
m_vertices->operator[]( pointIdx + 2 ), minZ );
125 maxX = std::max(
m_vertices->operator[]( pointIdx + 0 ), maxX );
126 maxY = std::max(
m_vertices->operator[]( pointIdx + 1 ), maxY );
127 maxZ = std::max(
m_vertices->operator[]( pointIdx + 2 ), maxZ );
146 return "WDataSetPoints";
151 return "Dataset which contains points without any topological relation.";
188 throw WOutOfBounds(
"The specified index is invalid." );
205 throw WOutOfBounds(
"The specified index is invalid." );
211 return WColor(
m_colors->operator[]( pointIdx * 1 + 0 ),
212 m_colors->operator[]( pointIdx * 1 + 0 ),
213 m_colors->operator[]( pointIdx * 1 + 0 ),
216 return WColor(
m_colors->operator[]( pointIdx * 3 + 0 ),
217 m_colors->operator[]( pointIdx * 3 + 1 ),
218 m_colors->operator[]( pointIdx * 3 + 2 ),
221 return WColor(
m_colors->operator[]( pointIdx * 4 + 0 ),
222 m_colors->operator[]( pointIdx * 4 + 1 ),
223 m_colors->operator[]( pointIdx * 4 + 2 ),
224 m_colors->operator[]( pointIdx * 4 + 3 ) );
226 return WColor( 1.0, 1.0, 1.0, 1.0 );
232 return ( pointIdx < m_vertices->
size() / 3 );
virtual const std::string getName() const
Gets the name of this prototype.
VertexArray getVertices() const
Getter for the point vertices.
bool isValidPointIdx(const size_t pointIdx) const
Is this a valid point index?
WColor getColor(const size_t pointIdx) const
The color of a given point.
ColorArray getColors() const
Getter for the point colors.
WBoundingBox m_bb
Axis aligned bounding box for all point-vertices of this dataset.
ColorArray m_colors
An array of the colors per vertex.
std::any m_data
An optional vector for data per vertex.
size_t size() const
Get number of points in this data set.
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
VertexArray m_vertices
Point vector for all points.
ColorType m_colorType
Which colortype do we use in m_colors.
virtual const std::string getDescription() const
Gets the description for this prototype.
ColorType
The type of colors we have for each point.
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
void init(bool calcBB=false)
Initialize arrays and bbox if needed.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
WPosition getPosition(const size_t pointIdx) const
Query coordinates of a given point.
ColorType getColorType() const
Check the type of color.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
WPosition operator[](const size_t pointIdx) const
Query coordinates of a given point.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
std::any getData() const
Getter for the data set.
virtual ~WDataSetPoints()
Destructor.
WBoundingBox getBoundingBox() const
Get the bounding box.
WDataSetPoints()
Constructs a new set of points.
Indicates invalid element access of a container.
This only is a 3d double vector.