![]() |
ImFusion SDK 4.3
|
#include <ImFusion/ML/DataItem.h>
Class for holding a map of heterogeneous DataElements, see DataElement. More...
Inheritance diagram for DataItem:Class for holding a map of heterogeneous DataElements, see DataElement.
This class is used as a data container for applying Operations (see Operation) to a collection of heterogeneous elements in a consistent way. This class implements the concept of batch size for the contained elements. As such, a DataItem can be splitted or stacked along the batch axis like the contained DataElements, but only if all DataElements stored have consistent batch size.
Public Types | |
| using | Field = std::string |
| using | Element = std::shared_ptr<DataElement> |
| using | Elements = OrderedMap<Field, Element> |
Public Types inherited from Data | |
| 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... | |
Public Member Functions | |
| DataItem (Elements elements={}) | |
| Constructor from a map of elements. | |
| DataItem (DataItem &&that) noexcept | |
| DataItem & | operator= (DataItem &&that) noexcept |
| bool | operator== (const DataItem &other) const |
| bool | operator!= (const DataItem &other) const |
| std::unordered_set< Field > | fields () const |
| Returns the set of fields contained in this data item. | |
| Elements & | elements () |
| Exposes the underlying map. | |
| const Elements & | elements () const |
| bool | empty () const |
| void | clear () |
| void | set (Field field, std::shared_ptr< DataElement > element) |
| Set an element to the data item. | |
| void | set (Field field, std::shared_ptr< SharedImageSet > data) |
| Convenience function for directly adding a SharedImageSet as an Element Note: if the image dimension < 2 a VectorElement is created, otherwise an ImageElement. | |
| void | set (Field field, std::shared_ptr< KeypointSet > data) |
| Convenience functions for directly adding KeypointSet as a KeypointsElement. | |
| void | set (Field field, const KeypointSet &data) |
| void | set (Field field, KeypointSet &&data) |
| void | set (Field field, std::shared_ptr< BoundingBoxSet > data) |
| Convenience functions for directly adding BoundingBoxSet as a BoundingBoxesElement. | |
| void | set (Field field, const BoundingBoxSet &data) |
| void | set (Field field, BoundingBoxSet &&data) |
| void | set (Field field, std::shared_ptr< Tensor > data) |
| Convenience functions for directly adding Tensor or TensorSet as a TensorSetElement. | |
| void | set (Field field, const Tensor &data) |
| void | set (Field field, Tensor &&data) |
| void | set (Field field, std::shared_ptr< TensorSet > data) |
| void | set (Field field, const TensorSet &data) |
| void | set (Field field, TensorSet &&data) |
| DataItem | clone (DataElement::CloneOptions opt=DataElement::CloneOptions::Everything) const |
| Creates a clone of the current data item. | |
| int | dimension () const |
| Returns the dimensionality of the fields, or zero if no elements are present or if there are inconsistencies within them. | |
| size_t | numFields () const |
| Returns the number of the fields in the item. | |
| std::optional< size_t > | batchSize () const |
| Returns the batch size of the fields, 0 if elements are empty, or an empty optional if the batch size is inconsistent. | |
| bool | contains (const Field &name) const |
| Checks if the data item contains a field with the given name. | |
| std::shared_ptr< DataElement > | pop (const Field &name) |
| Removes an element from the item and returns it. | |
| const DataElement * | get (const Field &name) const |
| Returns a non-owning pointer to an element (or nullptr if it does not exist) | |
| DataElement * | get (const Field &name) |
| Returns a non-owning pointer to an element (or nullptr if it does not exist) | |
| template<typename T> | |
| T * | get (const Field &name) |
| Returns a non-owning pointer to a typed element (or nullptr if it does not exist or does not have the correct type) | |
| template<typename T> | |
| const T * | get (const Field &name) const |
| Returns a non-owning pointer to a typed element (or nullptr if it does not exist or does not have the correct type) | |
| template<typename T> | |
| std::unordered_set< T * > | getAll () |
| Returns a set of non-owning pointers to all elements of a certain type. | |
| template<typename T> | |
| std::unordered_set< const T * > | getAll () const |
| Returns a set of non-owning pointers to all elements of a certain type. | |
| template<typename T> | |
| T * | getIfOnly () |
| Returns non-owning pointer to element of a certain type, if it is the only element in the item of that type. | |
| template<typename T> | |
| const T * | getIfOnly () const |
| Returns non-owning pointer to element of a certain type, if it is the only element in the item of that type. | |
| bool | append (const DataItem &src) |
Append a frame at index frame from another DataItem to the current one. | |
| ML::Status | save (const std::string &location, bool compress=true) const |
Public Member Functions inherited from Data | |
| 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. | |
Static Public Member Functions | |
| static DataItem | stack (std::vector< DataItem > &&items) |
| Stack several data items along the batch dimension. | |
| static std::vector< DataItem > | split (DataItem &&item) |
| static DataItem | merge (std::vector< DataItem > &&items) |
| static ML::Status | save (const DataItem &item, const std::string &location, bool compress=true) |
| static DataItem | load (const std::string &location) |
Static Public Member Functions inherited from Data | |
| 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. | |
Implementation of CompoundData interface | |
| DataList | children () const override |
| Returns the list of direct children of this group. | |
| decltype(m_elements->cbegin()) | cbegin () const |
| decltype(m_elements->cend()) | cend () const |
| decltype(m_elements->begin()) | begin () |
| decltype(m_elements->end()) | end () |
Implementation of Data interface | |
| 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. | |
| void | setMatrix (const mat4 &m) override |
| Set the transformation matrix and updates all child matrices with the relative matrix between the old and new one. | |
| std::string | describe () const override |
| Return type description. | |
Additional Inherited Members | |
Public Attributes inherited from Data | |
| 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. | |
Public Attributes inherited from CompoundData | |
| Signal< Data * > | signalChildAdded |
| Signal emitted when a new Data instance has been added to children() | |
| Signal< Data * > | signalChildMoved |
| Signal emitted when a Data instance has changed its position in children() | |
| Signal< Data * > | signalChildAboutToBeRemoved |
| Signal emitted when a Data instance is about to be removed or taken from children() | |
Protected Member Functions inherited from Data | |
| void | swapWith (Data &other) |
| Swaps the data and emits a matrix and name changed signal for both. | |
Protected Member Functions inherited from NotCopyable | |
| NotCopyable (NotCopyable &&) noexcept=default | |
| NotCopyable & | operator= (NotCopyable &&) noexcept=default |
| NotCopyable (const NotCopyable &)=delete | |
| NotCopyable & | operator= (const NotCopyable &)=delete |
Protected Attributes inherited from Data | |
| 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. | |
|
inline |
Returns non-owning pointer to element of a certain type, if it is the only element in the item of that type.
Otherwise returns a nullptr
|
inline |
Returns non-owning pointer to element of a certain type, if it is the only element in the item of that type.
Otherwise returns a nullptr
| bool append | ( | const DataItem & | src | ) |
Append a frame at index frame from another DataItem to the current one.
/ Return false if any field in the data item is missing in the src DataItem. / If the function call is not successful, the item is left unchanged. bool appendFrame(const DataItem& src, int frame = 0);
/ Append all frames from another DataItem to the current one. / Return false if any field in the data item is missing in the src DataItem, / or if the src item has an inconsistent batch size. If the function call is not successful, the item is left unchanged.
|
static |
Stack several data items along the batch dimension.
| DataItemException | if DataItems have inconsistent batch size |
|
static |
| DataItemException | if DataItem has inconsistent batch size |
|
inlineoverridevirtual |
Defines whether the internally stored matrices in derived classes map from or to the world coordinate system.
Changes the behavior of the default implementations of matrixToWorld and matrixFromWorld.
Implements Data.
|
overridevirtual |
Returns the axis-aligned bounding box of this data in world space.
Implements Data.
|
overridevirtual |
Set the transformation matrix and updates all child matrices with the relative matrix between the old and new one.
Reimplemented from Data.
|
inlineoverridevirtual |
Return type description.
Reimplemented from Data.
|
overridevirtual |
Returns the list of direct children of this group.
Implements CompoundData.