32 #ifndef Array_INCLUDE_ONCE 33 #define Array_INCLUDE_ONCE 66 VL_DEBUG_SET_OBJECT_NAME()
77 VL_DEBUG_SET_OBJECT_NAME()
112 virtual size_t glSize()
const = 0;
115 virtual GLenum
glType()
const = 0;
118 virtual size_t size()
const = 0;
142 virtual int compare(
int a,
int b)
const = 0;
212 template <
typename T_VectorType,
typename T_Scalar,
size_t T_GL_Size, GLenum T_GL_Type>
220 static const size_t gl_size = T_GL_Size;
221 static const GLenum gl_type = T_GL_Type;
223 virtual size_t glSize()
const {
return T_GL_Size; }
225 virtual GLenum
glType()
const {
return T_GL_Type; }
245 const T_VectorType*
begin()
const {
return reinterpret_cast<const T_VectorType*
>(
ptr()); }
247 T_VectorType*
begin() {
return reinterpret_cast<T_VectorType*
>(
ptr()); }
249 const T_VectorType*
end()
const {
return (reinterpret_cast<const T_VectorType*>(
ptr()))+
size(); }
251 T_VectorType*
end() {
return (reinterpret_cast<T_VectorType*>(
ptr()))+
size(); }
255 T_VectorType&
at(
size_t i) {
VL_CHECK(i<
size());
return *(
reinterpret_cast<T_VectorType*
>(
ptr())+i); }
257 const T_VectorType&
at(
size_t i)
const {
VL_CHECK(i<
size());
return *(
reinterpret_cast<const T_VectorType*
>(
ptr())+i); }
261 const T_VectorType&
operator[](
size_t i)
const {
return at(i); }
283 const int count = T_GL_Size == 4 ? 3 : T_GL_Size;
284 for(
size_t i=0; i<
size(); ++i)
287 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(i));
288 for(
int j=0; j<count; ++j )
289 v.
ptr()[j] = (real)pv[j];
294 for(
size_t i=0; i<
size(); ++i)
297 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(i));
298 for(
int j=0; j<count; ++j )
299 v.
ptr()[j] = (real)pv[j];
300 real r = (v-center).lengthSquared();
310 const int count = T_GL_Size == 4 ? 3 : T_GL_Size;
311 for(
size_t i=0; i<
size(); ++i)
314 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(i));
315 for(
int j=0; j<count; ++j )
316 v.
ptr()[j] = (real)pv[j];
324 for(
size_t i=0; i<
size(); ++i)
327 T_Scalar* pv =
reinterpret_cast<T_Scalar*
>(&at(i));
329 for(
size_t j=0; j<T_GL_Size; ++j )
330 v.
ptr()[j] = (real)pv[j];
334 for(
size_t j=0; j<T_GL_Size; ++j )
335 pv[j] = (T_Scalar)v.
ptr()[j];
341 for(
size_t i=0; i<
size(); ++i)
344 T_Scalar* pv =
reinterpret_cast<T_Scalar*
>(&at(i));
346 for(
size_t j=0; j<T_GL_Size; ++j )
347 v.
ptr()[j] = (real)pv[j];
351 for(
unsigned j=0; j<T_GL_Size; ++j )
352 pv[j] = (T_Scalar)v.
ptr()[j];
359 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(vector_index));
360 for(
size_t j=0; j<T_GL_Size; ++j )
361 v.
ptr()[j] = (real)pv[j];
368 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(vector_index));
369 const int count = T_GL_Size <= 3 ? T_GL_Size : 3;
370 for(
int j=0; j<count; ++j )
371 v.
ptr()[j] = (real)pv[j];
378 const T_Scalar* pv =
reinterpret_cast<const T_Scalar*
>(&at(vector_index));
379 const int count = T_GL_Size <= 2 ? T_GL_Size : 2;
380 for(
int j=0; j<count; ++j )
381 v.
ptr()[j] = (real)pv[j];
387 const T_Scalar* pa =
reinterpret_cast<const T_Scalar*
>(&at(a));
388 const T_Scalar* pb =
reinterpret_cast<const T_Scalar*
>(&at(b));
389 for(
size_t i=0; i<T_GL_Size; ++i )
390 if ( pa[i] != pb[i] )
391 return pa[i] < pb[i] ? -1 : +1;
395 void initFrom(
const std::vector<T_VectorType>& vector)
397 resize(vector.size());
401 memcpy(
ptr(),&vector[0],
sizeof(vector[0])*vector.size());
An array of GL_INT_2_10_10_10_REV.
The ArrayAbstract class defines an abstract interface to conveniently manipulate data stored in a Buf...
const T_VectorType & at(size_t i) const
const T_VectorType * end() const
void deleteBufferObject()
An array 4d GL_FIXED vectors.
void normalize()
Normalizes the vectors contained in the buffer.
void setNormalize(bool normalize)
The 'normalized' parameter as used with glVertexAttribPointer()
A 3d array of GL_HALF_FLOAT vectors.
virtual ref< ArrayAbstract > clone() const =0
size_t scalarCountBufferObject() const
vec3 getAsVec3(size_t vector_index) const
Returns a vector from the buffer as a vec3 value.
ArrayAbstract(const ArrayAbstract &other)
Copies only the local data and not the BufferObject related fields.
void operator=(const ArrayAbstract &other)
Copies only the local data and not the BufferObject related fields.
void setInterpretation(EVertexAttribInterpretation behavior)
How the data is interpreted by the OpenGL, see EVertexAttribInterpretation.
BufferObject * bufferObject()
vec3 center() const
Returns the center of the AABB.
virtual size_t glSize() const =0
Returns the number of scalar components for the array, ie 3 for ArrayFloat3, 1 for ArrayUInt1 etc...
vec2 getAsVec2(size_t vector_index) const
Returns a vector from the buffer as a vec2 value.
EVertexAttribInterpretation interpretation() const
How the data is interpreted by the OpenGL, see EVertexAttribInterpretation.
virtual vec2 getAsVec2(size_t vector_index) const =0
Returns a vector from the buffer as a vec2 value.
virtual size_t bytesPerVector() const
vec4 getAsVec4(size_t vector_index) const
Returns a vector from the buffer as a vec4 value.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
virtual vec3 getAsVec3(size_t vector_index) const =0
Returns a vector from the buffer as a vec3 value.
const T_VectorType * begin() const
virtual Sphere computeBoundingSphere() const =0
Computes the bounding sphere enclosing the vectors contained in the buffer.
ref< BufferObject > mBufferObject
void transform(const mat4 &m)
Transforms the vectors contained in the buffer.
size_t scalarCount() const
size_t size() const
Returns the number of elements of an array.
Visualization Library main namespace.
int compare(int a, int b) const
Compares two vectors.
const BufferObject * bufferObject() const
const T_VectorType & operator[](size_t i) const
void setBufferObjectDirty(bool dirty=true)
Wether the BufferObject should be updated or not using the local storage.
virtual void normalize()=0
Normalizes the vectors contained in the buffer.
const unsigned char * ptr() const
Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() ...
Sphere computeBoundingSphere() const
Computes the bounding sphere enclosing the vectors contained in the buffer.
void setUsage(EBufferObjectUsage usage)
BU_STATIC_DRAW by default.
The AABB class implements an axis-aligned bounding box using vl::real precision.
unsigned char * ptr()
Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() ...
virtual size_t glSize() const
Returns the number of scalar components for the array, ie 3 for ArrayFloat3, 1 for ArrayUInt1 etc...
An array of GL_UNSIGNED_INT_2_10_10_10_REV.
void initFrom(const std::vector< T_VectorType > &vector)
A 3d array of GL_UNSIGNED_INT_2_10_10_10_REV vectors.
The base class for all the reference counted objects.
T_VectorType & operator[](size_t i)
virtual GLenum glType() const
Returns the OpenGL type for the array, ie GL_FLOAT for ArrayFloat3, GL_UNSIGNED_INT for ArrayUInt1 et...
virtual ref< ArrayAbstract > clone() const
void updateBufferObject(EBufferObjectUpdateMode mode=BUM_KeepRamBuffer)
Updates the BufferObject.
bool isBufferObjectDirty() const
Wether the BufferObject should be updated or not using the local storage.
bool normalize() const
The 'normalized' parameter as used with glVertexAttribPointer()
The Sphere class defines a sphere using a center and a radius using vl::real precision.
Data will be sent using glVertexAttribPointer(), that is, data will be converted to floating point pr...
Keeps the local buffer on RAM and updates the BufferObject only if it is marked as dirty...
A 2d array of GL_HALF_FLOAT vectors.
virtual AABB computeBoundingBox() const =0
Computes the axis aligned bounding box enclosing the vectors contained in the buffer.
T_VectorType & at(size_t i)
A 2d array of GL_UNSIGNED_INT_2_10_10_10_REV vectors.
size_t sizeBufferObject() const
virtual GLenum glType() const =0
Returns the OpenGL type for the array, ie GL_FLOAT for ArrayFloat3, GL_UNSIGNED_INT for ArrayUInt1 et...
The BufferObject class is a Buffer that can upload its data on the GPU memory.
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
A 4d array of GL_UNSIGNED_INT_2_10_10_10_REV vectors.
virtual size_t size() const =0
Returns the number of elements of an array.
const Vector4 & normalize(T_Scalar *len=NULL)
A 4d array of GL_INT_2_10_10_10_REV vectors.
virtual int compare(int a, int b) const =0
Compares two vectors.
The Array class is a template array used to conveniently manipulate data stored in a BufferObject...
A 2d array of GL_INT_2_10_10_10_REV vectors.
GLsizeiptr byteCountBufferObject() const
void setBufferData(EBufferObjectUsage usage, bool discard_local_storage=false)
virtual vec4 getAsVec4(size_t vector_index) const =0
Returns a vector from the buffer as a vec4 value.
The ref<> class is used to reference-count an Object.
void resize(size_t byte_count, size_t alignment=0)
virtual void transform(const mat4 &m)=0
Transforms the vectors contained in the buffer.
EBufferObjectUsage usage() const
BU_STATIC_DRAW by default.
Data is specified once and used many times as the source of drawing or image specification commands...
virtual size_t bytesUsed() const
Returns the amount of memory in bytes used by an array. Equivalent to bufferObject()->bytesUsed().
virtual ref< ArrayAbstract > createArray() const
An array of GL_HALF_FLOAT.
EVertexAttribInterpretation mInterpretation
EVertexAttribInterpretation
Specifies how the data of a VertexAttribInfo is sent to the OpenGL driver, see also http://www...
An array 3d GL_FIXED vectors.
AABB computeBoundingBox() const
Computes the axis aligned bounding box enclosing the vectors contained in the buffer.
A 3d array of GL_INT_2_10_10_10_REV vectors.
A 4d array of GL_HALF_FLOAT vectors.
EBufferObjectUsage mBufferObjectUsage
ArrayAbstract()
Default constructor.
An array 2d GL_FIXED vectors.