![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/SharedImageSet.h>
Set of images independent of their storage location. More...
Inheritance diagram for SharedImageSet:Set of images independent of their storage location.
This class is the main high-level container for image data consisting of one or multiple images or volumes, and should be used both in algorithms and visualization classes. Both a single focus and multiple selection is featured, as well as providing transformation matrices and timestamps for each image.
SharedImageSet uses shared_ptr internally to store the SharedImages. This enables you to easily create a container SharedImageSet that temporarily wraps existing images (e.g. to pass them to a separate Algorithm) without taking exclusive ownership.
Public Types | |
| enum | CloneOptions { Everything = 0 , NoImageData = 1 << 0 , NoDataComponents = 1 << 1 , ShallowImageCopy = 1 << 2 , NoSelection = 1 << 3 , NoTracking = 1 << 4 } |
| Bitset enumeration to configure which aspects of a SharedImageSet to copy. More... | |
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 | |
| SharedImageSet (std::shared_ptr< Image > img) | |
| Construct from a single Image. | |
| SharedImageSet (std::shared_ptr< SharedImage > img) | |
| Construct from a single SharedImage. | |
| SharedImageSet () | |
| Construct an empty SharedImageSet. | |
| SharedImageSet & | operator= (const SharedImageSet &)=delete |
| std::unique_ptr< SharedImageSet > | clone (Flags< CloneOptions > cloneOptions=Everything) const |
| Create a copy of this SharedImageSet instance. | |
| void | add (std::shared_ptr< Image > img) |
| Add a single image to the data set. | |
| void | add (std::shared_ptr< Image > img, const mat4 &m) |
| Add a single image with its transformation matrix. | |
| virtual void | add (std::shared_ptr< SharedImage > img) |
| Add a shared image to the data set. | |
| void | add (const std::vector< std::shared_ptr< SharedImage > > &images) |
| Add a list of shared images. | |
| bool | replace (int pos, std::shared_ptr< SharedImage > img) |
| Replace a particular shared image entry, will not do anything if no image of that index exist yet. | |
| virtual void | remove (int pos, int count=1) |
| Removes images at the specified locations and deletes them if owned. | |
| void | remove (const SharedImage *img) |
| Removes a specific image and deletes it if owned. | |
| virtual void | clear () |
| Clear all data and delete it if owned. | |
| std::string | describe () const override |
| Short description of the image set. | |
| void | setModalityOverride (std::optional< Data::Modality > modalityOverride) |
| Set a modalityOverride. | |
| virtual void | setModality (Modality m) |
| Set image modality for all frames. | |
| Modality | modality () const override |
| Return the modality of this data. | |
| virtual bool | isMultiModal () const |
| Return true if set contains images of different modalities, false otherwise. | |
| virtual void | prepare (bool shiftOnly=false) |
| Prepare the image in memory for most common scenarios Integral types are converted to unsigned representation if applicable, double-precision will be converted to single-precision float. | |
| void | uploadGl () const |
| Upload all images as OpenGL textures. | |
| bool | hasMem (int which=-1) const |
| Query whether an up-to-date memory image is present. If not, a sync is required. | |
| bool | hasGl (int which=-1) const |
| Query whether an up-to-date OpenGL image is present. If not, a sync is required. | |
| const DataComponentList & | components () const |
| Returns the list of DataComponents for this data. | |
| DataComponentList & | components () |
| const DataComponentList & | components (int i) const |
| Returns the DataComponents associated to the element with that index. | |
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. | |
| 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 () |
Public Member Functions inherited from SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Public Member Functions inherited from ElementwiseDataComponentData | |
| ElementwiseDataComponentList & | elementwiseComponents () |
| Returns elementwise data component list. | |
| const ElementwiseDataComponentList & | elementwiseComponents () const |
| Returns elementwise data component list. | |
| DataComponentList & | mutableComponents (int i) |
| Returns the DataComponents associated to the element with that index, creating it if necessary. | |
| const DataComponentList & | components (int i) const |
| Returns the DataComponents associated to the element with that index. | |
Public Member Functions inherited from Selectable | |
| Selectable (const Selectable &) | |
| Selectable (Selectable &&) | |
| Selectable & | operator= (const Selectable &) |
| Selectable & | operator= (Selectable &&) |
| virtual Selection | selection () const |
| virtual int | focus () const |
| virtual void | setSelection (const Selection &sel) |
| Set the underlying selection. | |
| virtual void | setFocus (int index) |
| Set focus of the selection. | |
Protected Member Functions | |
| virtual SharedImageSet * | createCloneContainer () const |
| Internal method for creating the container object holding the clone. | |
| virtual void | cloneInternal (SharedImageSet &other, Flags< CloneOptions > cloneOptions) const |
| Internal method for cloning which should be called from derived container classes. | |
| virtual void | swapWith (SharedImageSet &other) |
Internal method for swapping the contents of this container with other. | |
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 SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
Protected Attributes | |
| std::vector< std::shared_ptr< SharedImage > > | m_images |
| Vector of shared image pointers. | |
| std::vector< double > | m_timestamps |
| Optional timestamps of the image frames. | |
| Properties | m_properties |
| Auxiliary information properties. | |
| Geometry::AlignedBox | m_bounds |
| Axis-aligned bounding box of all images in world space. | |
| bool | m_updateBounds = true |
| Flag specifying whether the bounds should be re-computed. | |
| std::optional< Data::Modality > | m_modalityOverride |
| Overrides the modality of the containing SharedImages. This is used e.g. for the ConeBeamData concept in CT. | |
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. | |
Protected Attributes inherited from ElementwiseDataComponentData | |
| ElementwiseDataComponentList | m_elementwiseComponents |
| Encodes elementwise data components. | |
Protected Attributes inherited from Selectable | |
| std::mutex | m_selectionMutex |
| Mutex protecting the selection. | |
| Selection | m_sel |
Image access | |
| virtual SharedImage * | get (int which=-1) |
| Get specific or selected shared image. | |
| std::shared_ptr< SharedImage > | getShared (int which=-1) |
| Get specific or selected shared image. | |
| MemImage * | mem (int which=-1) |
| Get specific or selected image in memory If required image will be synchronized. | |
| GlImage * | gl (int which=-1) |
| Get specific or selected OpenGL image If required image will be synchronized. | |
| const std::vector< std::shared_ptr< SharedImage > > & | images () |
| Return entire vector of images. | |
| std::vector< std::shared_ptr< SharedImage > > | selectedImages (Selection::NonePolicy noneSelectionHandling) |
| Return vector of all selected images. | |
Const image access | |
| virtual const SharedImage * | get (int which=-1) const |
| Get specific or selected shared image. | |
| std::shared_ptr< const SharedImage > | getShared (int which=-1) const |
| Get specific or selected shared image. | |
| const Image * | img (int which=-1) const |
| Get specific or selected image descriptor. | |
| const MemImage * | mem (int which=-1) const |
| Get specific or selected image in memory If required image will be synchronized. | |
| const GlImage * | gl (int which=-1) const |
| Get specific or selected OpenGL image If required image will be synchronized. | |
| std::vector< std::shared_ptr< const SharedImage > > | images () const |
| Return entire vector of images. | |
| std::vector< std::shared_ptr< const SharedImage > > | selectedImages (Selection::NonePolicy noneSelectionHandling) const |
| Return vector of all selected images. | |
Image matrix access | |
| Pose::TransformationConvention | matrixConvention () const override |
| Matrices of images map from the world coordinate system. | |
| virtual void | setMatrix (const mat4 &m, int which, bool updateAll=false) |
Set specific (which >=0) or focused (which ==-1) image matrix. | |
| virtual mat4 | matrix (int which) const |
Get specific (which >=0) or focused (which ==-1) image matrix. | |
| void | setMatrix (const mat4 &m) override |
| Set focused image matrix. | |
| mat4 | matrix () const override |
| Get focused image matrix. | |
| virtual void | setMatrixFromWorld (const mat4 &m, int which, bool updateAll=false) |
Set specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system. | |
| virtual void | setMatrixToWorld (const mat4 &m, int which, bool updateAll=false) |
Set specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system. | |
| virtual mat4 | matrixFromWorld (int which) const |
Get specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system. | |
| virtual mat4 | matrixToWorld (int which) const |
Get specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system. | |
| virtual bool | hasTransformations () const |
| Return true if at least one image in the set has a matrix transformation unequal identity. | |
| virtual void | setDeformation (std::shared_ptr< Deformation > def, int which=-1) |
| Sets a deformation for specified or focus image. | |
| virtual std::shared_ptr< Deformation > | deformation (int which=-1) const |
| Returns the deformation for the specified or focused image, or 0 if not deformation is set. | |
| virtual void | setMask (std::shared_ptr< Mask > mask, int which=-1) |
| Sets a mask for specified or focus image. | |
| virtual std::shared_ptr< Mask > | mask (int which=-1) const |
| Returns the mask for the specified or focused image, or 0 if not mask is set. | |
| 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 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. | |
Timestamp access | |
| virtual void | setTimestamp (double time, int which=-1) |
| Set specific or focused timestamp in seconds. | |
| double | timestamp (int which=-1) const |
| Get specific or focused timestamp in seconds. | |
| const std::vector< double > | timestamps () const |
| Get the timestamps sequence. | |
| bool | hasTimestamps () const |
| Return if all image frames have timestamps. | |
Miscellaneous const access methods | |
| int | size () const override |
| Return the size of the image set. | |
| bool | allEqual () const |
| Return if all image descriptors are the same. | |
| Kind | kind () const override |
| Return the kind of data contained here. | |
| Geometry::AlignedBox | bounds () const override |
| Returns the axis-aligned bounding box of all images in world space. | |
| Properties * | properties () |
| Return auxiliary data structures stored in Properties. | |
| const Properties * | properties () const |
| Return auxiliary data structures stored in Properties. | |
Additional Inherited Members | |
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. | |
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 Selectable | |
| ProtectedSignal | signalSelectionChanged |
| Signals that the selection or size might have changed. | |
| enum CloneOptions |
Bitset enumeration to configure which aspects of a SharedImageSet to copy.
| Enumerator | |
|---|---|
| Everything | Perform a deep copy of all data contained by the SharedImageSet. |
| NoImageData | Do not clone any image data. |
| NoDataComponents | Do not clone any DataComponents. |
| ShallowImageCopy | Clone SharedImages with SharedImage::ShallowImageCopy flag (do not deep copy the underlying Images) |
| NoSelection | Do not copy over the Selection. |
| NoTracking | Do not copy over any TrackingSequences (only relevant for TrackedSharedImageSet derived classes) |
|
explicit |
Construct from a single Image.
Note that any std::unique_ptr implicitly converts to a std::shared_ptr of same type.
|
explicit |
Construct from a single SharedImage.
Note that any std::unique_ptr implicitly converts to a std::shared_ptr of same type.
|
virtual |
Add a shared image to the data set.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Removes images at the specified locations and deletes them if owned.
Reimplemented in TrackedSharedImageSet.
| void remove | ( | const SharedImage * | img | ) |
Removes a specific image and deletes it if owned.
|
virtual |
Clear all data and delete it if owned.
Reimplemented in TrackedSharedImageSet.
|
overridevirtual |
Short description of the image set.
Reimplemented from Data.
| void setModalityOverride | ( | std::optional< Data::Modality > | modalityOverride | ) |
Set a modalityOverride.
See SharedImageSet::modality() for more details on how the modality of the SharedImageSet is determined in case of an active modalityOverride.
| modalityOverride | Pass a Data::Modality to set a modalityOverride. In order to remove an override you can pass std::nullopt as argument. |
|
overridevirtual |
Return the modality of this data.
The modality will be determined like this:
Reimplemented from Data.
Reimplemented in UltrasoundSweep.
|
virtual |
Prepare the image in memory for most common scenarios Integral types are converted to unsigned representation if applicable, double-precision will be converted to single-precision float.
Furthermore, if shiftOnly is false it will rescale the present intensity range to [0..1] for floating point types or to the entire available value range for integral types. For image sets that contain more than one image shiftOnly will always be forced to true. Derived classes may do more modality specific processing here.
| void uploadGl | ( | ) | const |
Upload all images as OpenGL textures.
This method throws an exception if the OpenGL texture creation fails.
| MemImage * mem | ( | int | which = -1 | ) |
Get specific or selected image in memory If required image will be synchronized.
Use hasMem() to check if synchronization is required.
| GlImage * gl | ( | int | which = -1 | ) |
Get specific or selected OpenGL image If required image will be synchronized.
Use hasGl() to check if synchronization is required.
|
inline |
Return entire vector of images.
This method is non-const since the images themselves may be manipulated.
| const MemImage * mem | ( | int | which = -1 | ) | const |
Get specific or selected image in memory If required image will be synchronized.
Use hasMem() to check if synchronization is required.
| const GlImage * gl | ( | int | which = -1 | ) | const |
Get specific or selected OpenGL image If required image will be synchronized.
Use hasGl() to check if synchronization is required.
|
inlineoverridevirtual |
Matrices of images map from the world coordinate system.
Implements Data.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Set specific (which >=0) or focused (which ==-1) image matrix.
If updateAll is set, the matrices of all images are updated relative to which.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Get specific (which >=0) or focused (which ==-1) image matrix.
Reimplemented in TrackedSharedImageSet.
|
overridevirtual |
|
overridevirtual |
|
virtual |
Set specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.
If updateAll is set, the matrices of all images are updated relative to which.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Set specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.
If updateAll is set, the matrices of all images are updated relative to which.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Get specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Get specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Return true if at least one image in the set has a matrix transformation unequal identity.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Set specific or focused timestamp in seconds.
Reimplemented in TrackedSharedImageSet.
|
overridevirtual |
Return the size of the image set.
Implements Selectable.
|
overridevirtual |
Returns the axis-aligned bounding box of all images in world space.
Implements Data.
Reimplemented in TrackedSharedImageSet, and UltrasoundSweep.
| Properties * properties | ( | ) |
Return auxiliary data structures stored in Properties.
| const Properties * properties | ( | ) | const |
Return auxiliary data structures stored in Properties.
|
protectedvirtual |
Internal method for creating the container object holding the clone.
Reimplemented in TrackedSharedImageSet, and UltrasoundSweep.
|
protectedvirtual |
Internal method for cloning which should be called from derived container classes.
Reimplemented in TrackedSharedImageSet.
|
virtual |
Get matrix mapping from the world coordinate system to the data coordinate system.
Inverse of matrixToWorld.
Reimplemented from Data.
|
virtual |
Get matrix mapping from the data coordinate system to the world coordinate system.
Inverse of matrixFromWorld.
Reimplemented from Data.
|
virtual |
Set matrix mapping from the world coordinate system to the data coordinate system.
m might be inverted before it is saved. The default implementation checks matrixConvention and accordingly calls setMatrix with either m or its inverse. Reimplemented from Data.
|
virtual |
Set matrix mapping from the data coordinate system to the world coordinate system.
m might be inverted before it is saved. The default implementation checks matrixConvention and accordingly calls setMatrix with either m or its inverse. Reimplemented from Data.