![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/Tensor.h>
Data class for strongly typed dense tensors of fixed rank and data type. More...
Data class for strongly typed dense tensors of fixed rank and data type.
Unlike most Data classes, this one notices content changes and notifies listeners. Any method in this class that changes the allocation of the underlying buffer may throw an exception on failure.
Classes | |
class | Access |
Helper class for read/write access to the data content of a Tensor. More... | |
class | ConstAccess |
Helper class for read-only access to the data content of a Tensor. More... | |
Public Member Functions | |
Tensor () | |
Default constructor, initializes size to 0 on all dimensions. | |
template<typename... sizeT, typename = typename std::enable_if<TensorBase::are_all_convertible<size_t, sizeT...>::value>::type> | |
Tensor (size_t s0, sizeT... s) | |
Creates a tensor of the given size and allocates the required storage space. Does not initialize content. | |
Tensor (const Tensor< Order > &other) | |
Deep copy constructor. | |
~Tensor () override | |
Deletes the tensor. This triggers an appropriate signal via the Data base destructor. | |
Tensor< Order > & | operator= (const Tensor< Order > &other) |
Deep copy. | |
template<int U = Order> | |
std::enable_if<(U==1), Tensor< Order > & >::type | operator= (const std::vector< double > &vec) |
Convenience assignment operator from std::vector for 1st order tensors. | |
template<int U = Order, typename = typename std::enable_if<U == 1>::type> | |
Tensor (const std::vector< double > &vec) | |
Convenience constructor from a vector. | |
template<int U = Order> | |
std::enable_if<(U==2), Tensor< Order > & >::type | operator= (const std::initializer_list< std::vector< double > > &vec) |
Convenience assignment from a list of row vectors. | |
template<int U = Order, typename = typename std::enable_if<U == 2>::type> | |
Tensor (const std::initializer_list< std::vector< double > > &vec) | |
Convenience constructor from a list of row vectors. | |
int | order () const override |
Returns the rank of the tensor. | |
std::vector< size_t > | size () const override |
Returns the size of the tensor. | |
size_t | bufferLength () const override |
Returns the number of elements in this tensor's storage buffer. | |
size_t | bufferSize () const override |
Returns the number of bytes in this tensor's storage buffer. | |
template<typename... sizeT, typename = typename std::enable_if<TensorBase::are_all_convertible<size_t, sizeT...>::value>::type> | |
void | resize (sizeT... s) |
Resizes the tensor and reallocates the storage if necessary. | |
void | resize (const std::array< size_t, Order > &size) |
Resizes the tensor and reallocates the storage if necessary. | |
bool | serialize (std::ostream &out) const override |
Stores the tensor size and content (but not type and rank) in a stream. | |
bool | deserialize (std::istream &in) override |
Restores the tensor size and content (but not type and rank) from a stream. | |
Access | access () |
Provides scoped read&write access to the tensor data. Notifies listeners that content has changed when the returned object is deleted. | |
ConstAccess | constAccess () const |
Provides scoped read-only access to the tensor data. | |
std::string | describe () const override |
Human readable description of the data for showing in the info bar. | |
template<typename... idxT, typename = typename std::enable_if<TensorBase::are_all_convertible<size_t, idxT...>::value>::type> | |
const double & | operator() (idxT... idx) const |
const double * | data () const |
template<int U = Order, typename = typename std::enable_if<U == 1>::type> | |
operator double () const | |
Convenience conversion to double for cases where a more generalized method is known to return only 1 value. | |
![]() | |
Kind | kind () const override |
Return the kind of this data. | |
Pose::TransformationConvention | matrixConvention () const override |
Defines whether the internally stored matrices in derived classes map from or to the world coordinate system. | |
Geometry::AlignedBox | bounds () const override |
Returns the axis-aligned bounding box of this data in world space. | |
std::string | filename () const |
void | setFilename (const std::string &name) |
void | requestPostProcessing (bool val) |
Controls whether adding this object to the data model should trigger an automatic plot. Has no effect afterwards. | |
bool | needsPostProcessing () const |
![]() | |
Data (const std::string &name="") | |
Data (const Data &other) | |
Data & | operator= (const Data &other) |
virtual | ~Data () |
Mandatory virtual destructor. | |
virtual Modality | modality () const |
Return the modality of this data. | |
const std::string & | name () const |
Return the name of this data. | |
void | setName (const std::string &name) |
Sets the name of this data. | |
virtual bool | isAnnotationType () const |
Return whether this data type is visualized through an annotation (e.g. mesh) | |
const DataComponentList & | components () const |
Returns the list of DataComponents for this data. | |
DataComponentList & | components () |
virtual void | setMatrixFromWorld (const mat4 &m) |
Set matrix mapping from the world coordinate system to the data coordinate system. | |
virtual void | setMatrixToWorld (const mat4 &m) |
Set matrix mapping from the data coordinate system to the world coordinate system. | |
virtual mat4 | matrixFromWorld () const |
Get matrix mapping from the world coordinate system to the data coordinate system. | |
virtual mat4 | matrixToWorld () const |
Get matrix mapping from the data coordinate system to the world coordinate system. | |
virtual mat4 | matrix () const |
Return the transformation matrix. | |
virtual void | setMatrix (const mat4 &m) |
Set the transformation matrix. | |
Additional Inherited Members | |
![]() | |
template<bool... bs> | |
using | all_true = std::is_same<bool_pack<bs..., true>, bool_pack<true, bs...>> |
template<class R, class... Ts> | |
using | are_all_convertible = all_true<std::is_convertible<Ts, R>::value...> |
![]() | |
enum | Kind { UNKNOWN = 0 , IMAGE = 1 , VOLUME = 2 , IMAGESET = 3 , VOLUMESET = 4 , IMAGESTREAM = 5 , VOLUMESTREAM = 6 , POINTSET = 7 , SURFACE = 8 , TRACKINGSTREAM = 9 , LIVETRACKINGSTREAM = TRACKINGSTREAM , TRACKINGDATA = 10 , TREE = 11 , TENSOR = 12 , POLYDATASTREAM = 13 , STEREOIMAGESET = 14 , STEREOIMAGESTREAM = 15 , VOLUMETRICMESH = 16 } |
Kind of data. More... | |
enum | Modality { NA = 0 , XRAY = 1 , CT = 2 , MRI = 3 , ULTRASOUND = 4 , VIDEO = 5 , NM = 6 , OCT = 7 , LABEL = 8 , DISTANCE = 9 } |
Image modality of the data. More... | |
![]() | |
static std::string | modalityString (Data::Modality m) |
Return the name of an image modality. | |
static Data::Modality | stringToModality (const std::string &s) |
Returns the modality corresponding to a modality string or NA if nothing matches. | |
![]() | |
Signal< const Data * > | signalContentChanged |
![]() | |
Signal< const Data * > | signalDeleted |
Signal emitted when this instance is deleted. | |
Signal< const Data * > | signalMatrixChanged |
Signal emitted when the transformation of this Data has changed. | |
Signal< std::string > | signalNameChanged |
Signal emitted when the name changed. | |
![]() | |
TensorBase & | operator= (const TensorBase &other) |
![]() | |
void | swapWith (Data &other) |
Swaps the data and emits a matrix and name changed signal for both. | |
![]() | |
mat4 | m_matrix |
Transformation matrix. | |
std::recursive_mutex * | m_matrixMutex |
Used to internally synchronize access to the matrix of data. | |
DataComponentList | m_dataComponentList |
The list of DataComponents for this data. | |
|
inlineoverridevirtual |
Returns the rank of the tensor.
Implements TensorBase.
|
inlineoverridevirtual |
Returns the size of the tensor.
Implements TensorBase.
|
overridevirtual |
Returns the number of elements in this tensor's storage buffer.
Implements TensorBase.
|
overridevirtual |
Returns the number of bytes in this tensor's storage buffer.
Implements TensorBase.
void resize | ( | sizeT... | s | ) |
Resizes the tensor and reallocates the storage if necessary.
If the storage size does not change, this just reshapes the tensor while keeping the data.
void resize | ( | const std::array< size_t, Order > & | size | ) |
Resizes the tensor and reallocates the storage if necessary.
If the storage size does not change, this just reshapes the tensor while keeping the data.
|
overridevirtual |
Stores the tensor size and content (but not type and rank) in a stream.
Implements TensorBase.
|
overridevirtual |
Restores the tensor size and content (but not type and rank) from a stream.
Implements TensorBase.
|
overridevirtual |
Human readable description of the data for showing in the info bar.
Reimplemented from Data.