iMSTK
Interactive Medical Simulation Toolkit
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
imstk::VecDataArray< T, N > Class Template Reference

Simple dynamic array implementation that also supports event posting and viewing/facade. More...

#include <imstkVecDataArray.h>

Inheritance diagram for imstk::VecDataArray< T, N >:
Inheritance graph
[legend]
Collaboration diagram for imstk::VecDataArray< T, N >:
Collaboration graph
[legend]

Classes

class  const_iterator
 
class  iterator
 

Public Types

using ScalarType = T
 
using ValueType = Eigen::Matrix< T, N, 1 >
 
- Public Types inherited from imstk::DataArray< T >
using ScalarType = T
 
using ValueType = T
 
- Public Types inherited from imstk::EventObject
using Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> >
 

Public Member Functions

 VecDataArray ()
 Constructs an empty data array.
 
 VecDataArray (const int size)
 Constructs a data array of size.
 
 VecDataArray (std::initializer_list< Eigen::Matrix< T, N, 1 >> list)
 Constructs from intializer list.
 
 VecDataArray (const VecDataArray &other)
 
 VecDataArray (VecDataArray &&other)
 
template<typename U >
VecDataArray< U, N > cast ()
 Templated copy the current array with a new internal data type, does not change the number of components, pass in the new type as a template argument.
 
std::shared_ptr< AbstractDataArraycast (ScalarTypeId type) override
 Cast array to the IMSTK type on the abstract interface.
 
void resize (const int size) override
 Resize data array to hold exactly size number of values.
 
void fill (const ValueType &val)
 
int size () const
 
void squeeze () override
 Resize to current size.
 
void push_back (const ValueType &val)
 Append the data array to hold the new value, resizes if neccesary.
 
void push_back (const ValueType &&val)
 
void reserve (const int size) override
 Allocates extra capacity, for the number of values, conservative reallocate.
 
ValueType * getPointer ()
 
ValueType & operator[] (const size_t pos)
 
const ValueType & operator[] (const size_t pos) const
 
ValueType & at (const size_t pos)
 
const ValueType & at (const size_t pos) const
 
void erase (const int vecPos)
 
template<typename U , int M>
VecDataArray< T, N > & operator= (std::initializer_list< Eigen::Matrix< U, M, 1 >> list)
 Allow initialization from initializer list, ie: DataArray<int> arr = { 1, 2 }.
 
VecDataArrayoperator= (const VecDataArray &other)
 
void setData (ValueType *ptr, const int size)
 Computes the range of a component of the vectors elements. More...
 
int getNumberOfComponents () const override
 Returns the number of components.
 
std::unique_ptr< VecDataArray< T, N > > clone ()
 Polymorphic clone, shadows the declaration in the superclasss but returns own type.
 
iterator begin ()
 begin(), end() to mirror std::vector
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
- Public Member Functions inherited from imstk::DataArray< T >
 DataArray ()
 Constructs an empty data array DataArray will never have capacity < 1.
 
 DataArray (const int size)
 Constructs a data array.
 
template<typename U >
 DataArray (std::initializer_list< U > list)
 Constructs from intializer list.
 
 DataArray (const DataArray &other)
 Copy Constructor. More...
 
 DataArray (DataArray &&other)
 
void fill (const T &val)
 Fill the array with the specified value.
 
void push_back (const T &val)
 Append the data array to hold the new value, resizes if neccesary.
 
void push_back (const T &&val)
 
T * getPointer ()
 
void * getVoidPointer () override
 Returns void pointer to data.
 
T & operator[] (const size_t pos)
 
const T & operator[] (const size_t pos) const
 
T & at (const size_t pos)
 
const T & at (const size_t pos) const
 
template<typename U >
DataArray< T > & operator= (std::initializer_list< U > list)
 Allow initialization from initializer list, ie: DataArray<int> arr = { 1, 2 }.
 
DataArrayoperator= (const DataArray &other)
 
void setData (T *ptr, const int size)
 Computes the range of a component of the vectors elements. More...
 
template<typename N >
DataArray< N > cast ()
 Cast array to specific c++ type.
 
std::unique_ptr< DataArray< T > > clone ()
 Polymorphic clone, shadows the declaration in the superclasss but returns own type.
 
iterator begin ()
 begin(), end() to mirror std::vector
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
- Public Member Functions inherited from imstk::AbstractDataArray
 AbstractDataArray (const int size)
 
virtual ~AbstractDataArray ()
 Ensure all observers are disconnected.
 
 SIGNAL (AbstractDataArray, modified)
 
void clear ()
 Resizes to 0.
 
int size () const
 Get number of values/tuples.
 
ScalarTypeId getScalarType () const
 Returns the scalar type of this array.
 
int getCapacity () const
 Return the capacity of the array.
 
void postModified ()
 emits signal to all observers, informing them on the current address in memory and size of array
 
std::unique_ptr< AbstractDataArrayclone ()
 polymorphic clone() function, utilize this to get a copy of the array without casting to the expected array type
 
- Public Member Functions inherited from imstk::EventObject
template<typename T >
void postEvent (const T &e)
 Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent.
 
template<typename T >
void queueEvent (const T &e)
 Queues event directly to this.
 
void doEvent ()
 Do an event, if none exists return.
 
void doAllEvents ()
 Do all the events in the event queue.
 
void foreachEvent (std::function< void(Command cmd)> func)
 Thread safe loop over all event commands, one can implement a custom handler.
 
void rforeachEvent (std::function< void(Command cmd)> func)
 thread safe reverse loop over all event commands, one can implement a custom handler
 
void clearEvents ()
 Removes all events from queue cleans up copies of the event.
 

Static Public Attributes

static constexpr int NumComponents = N
 
- Static Public Attributes inherited from imstk::DataArray< T >
static constexpr int NumComponents = 1
 

Additional Inherited Members

- Protected Member Functions inherited from imstk::AbstractDataArray
void setType (const ScalarTypeId type)
 
- Protected Attributes inherited from imstk::DataArray< T >
bool m_mapped
 
T * m_data
 
- Protected Attributes inherited from imstk::AbstractDataArray
ScalarTypeId m_scalarType
 
int m_size
 
int m_capacity
 
- Protected Attributes inherited from imstk::EventObject
ParallelUtils::SpinLock eventQueueLock
 
std::deque< CommandeventQueue
 
std::vector< std::pair< std::string, std::vector< Observer > > > queuedObservers
 
std::vector< std::pair< std::string, std::vector< Observer > > > directObservers
 

Detailed Description

template<typename T, int N>
class imstk::VecDataArray< T, N >

Simple dynamic array implementation that also supports event posting and viewing/facade.

Definition at line 15 of file imstkImplicitGeometryToPointSetCCD.h.

Member Function Documentation

◆ at() [1/2]

template<typename T, int N>
ValueType& imstk::VecDataArray< T, N >::at ( const size_t  pos)
inline
Returns
the item at the given position
Note
as opposed to the std::vector bounds checking is only done when IMSTK_CHECK_ARRAY_RANGE is set

Definition at line 350 of file imstkVecDataArray.h.

◆ at() [2/2]

template<typename T, int N>
const ValueType& imstk::VecDataArray< T, N >::at ( const size_t  pos) const
inline
Returns
the item at the given position
Note
as opposed to the std::vector bounds checking is only done when IMSTK_CHECK_ARRAY_RANGE is set

Definition at line 362 of file imstkVecDataArray.h.

◆ setData()

template<typename T, int N>
void imstk::VecDataArray< T, N >::setData ( ValueType *  ptr,
const int  size 
)
inline

Computes the range of a component of the vectors elements.

: Use the array as a facade to anothers memory

Parameters

Definition at line 469 of file imstkVecDataArray.h.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: