iMSTK
Interactive Medical Simulation Toolkit
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
imstk::ImageData Class Reference

Class to represent 1, 2, or 3D image data (i.e. structured points) More...

#include <imstkImageData.h>

Inheritance diagram for imstk::ImageData:
Inheritance graph
[legend]
Collaboration diagram for imstk::ImageData:
Collaboration graph
[legend]

Public Member Functions

void print () const override
 Print the image data info.
 
double getVolume () override
 Returns the volume.
 
const Vec3i & getDimensions () const
 Returns the dimensions of the image.
 
int getNumComponents () const
 Returns the number of components of the image.
 
void * getVoidPointer ()
 Returns a pointer to the underlying storage of the image.
 
std::shared_ptr< ImageDatacast (ScalarTypeId type)
 
const Vec3d & getInvSpacing () const
 Returns inv spacing of the image.
 
const ScalarTypeId getScalarType () const
 Returns the scalar type of the image.
 
const Vec6d & getBounds ()
 Returns bounds of the image (voxel to voxel)
 
void computeBoundingBox (Vec3d &lowerCorner, Vec3d &upperCorner, const double imstkNotUsed(paddingPercent)) override
 
void allocate (const ScalarTypeId type, const int numComps, const Vec3i &dims, const Vec3d &spacing=Vec3d(1.0, 1.0, 1.0), const Vec3d &origin=Vec3d(0.0, 0.0, 0.0))
 Allocate image by type.
 
void computePoints ()
 Generates points in the geometry from the ImageData (center of each voxel)
 
void clear () override
 Clear the data.
 
std::unique_ptr< ImageDataclone ()
 Polymorphic clone, hides the declaration in superclass return own type.
 
size_t getScalarIndex (int x, int y, int z=0)
 Returns index of data in scalar array given structured image coordinate, does no bounds checking.
 
size_t getScalarIndex (const Vec3i &imgCoord)
 
std::shared_ptr< AbstractDataArraygetScalars () const
 Get/Set the scalars.
 
void setScalars (std::shared_ptr< AbstractDataArray > scalars, const int numComps, int *dim)
 
const Vec3d & getOrigin () const
 Get/Set the origin of the image.
 
void setOrigin (const Vec3d &origin)
 
const Vec3d & getSpacing () const
 Get/Set the spacing between pixels/voxels of the image.
 
void setSpacing (const Vec3d &spacing)
 
- Public Member Functions inherited from imstk::PointSet
void initialize (std::shared_ptr< VecDataArray< double, 3 >> positions)
 Initializes the data structure given vertex positions.
 
virtual void computeBoundingBox (Vec3d &lowerCorner, Vec3d &upperCorner, const double paddingPercent=0.0) override
 Compute the bounding box for the entire mesh.
 
void setInitialVertexPositions (std::shared_ptr< VecDataArray< double, 3 >> vertices)
 Sets initial positions from an array.
 
std::shared_ptr< VecDataArray< double, 3 > > getInitialVertexPositions () const
 Returns the vector of initial positions of the mesh vertices.
 
Vec3d & getInitialVertexPosition (const size_t vertNum)
 Returns the initial position of a vertex given its index.
 
void setVertexPositions (std::shared_ptr< VecDataArray< double, 3 >> positions)
 Sets current vertex positions of the mesh.
 
std::shared_ptr< VecDataArray< double, 3 > > getVertexPositions (DataType type=DataType::PostTransform) const
 Returns the vector of current positions of the mesh vertices.
 
void setVertexPosition (const size_t vertNum, const Vec3d &pos)
 Set the current position of a vertex given its index to certain position (this is not a thread-safe method)
 
int getNumVertices () const
 Returns the number of total vertices in the mesh.
 
void setVertexAttribute (const std::string &arrayName, std::shared_ptr< AbstractDataArray > arr)
 Set a data array holding some per vertex data.
 
std::shared_ptr< AbstractDataArraygetVertexAttribute (const std::string &arrayName) const
 Get a specific data array. If the array name cannot be found, nullptr is returned.
 
bool hasVertexAttribute (const std::string &arrayName) const
 Check if a specific data array exists.
 
void setVertexAttributes (std::unordered_map< std::string, std::shared_ptr< AbstractDataArray >> attributes)
 Set the vertex attributes map.
 
const std::unordered_map< std::string, std::shared_ptr< AbstractDataArray > > & getVertexAttributes () const
 Get the vertex attributes map.
 
void updatePostTransformData () const override
 Applies the geometries member transform to produce currPositions.
 
std::unique_ptr< PointSetclone ()
 Polymorphic clone, hides the declaration in superclass return own type.
 
const Vec3d & getVertexPosition (const size_t vertNum, DataType type=DataType::PostTransform) const
 Returns the position of a vertex given its index.
 
Vec3d & getVertexPosition (const size_t vertNum, DataType type=DataType::PostTransform)
 
void setVertexScalars (const std::string &arrayName, std::shared_ptr< AbstractDataArray > scalars)
 Get/Set the active scalars.
 
void setVertexScalars (const std::string &arrayName)
 
std::string getActiveVertexScalars () const
 
std::shared_ptr< AbstractDataArraygetVertexScalars () const
 
void setVertexNormals (const std::string &arrayName, std::shared_ptr< VecDataArray< double, 3 >> normals)
 Get/Set the active normals.
 
void setVertexNormals (const std::string &arrayName)
 
std::string getActiveVertexNormals () const
 
std::shared_ptr< VecDataArray< double, 3 > > getVertexNormals () const
 
void setVertexTangents (const std::string &arrayName, std::shared_ptr< VecDataArray< float, 3 >> tangents)
 Get/Set the active tangents.
 
void setVertexTangents (const std::string &arrayName)
 
std::string getActiveVertexTangents () const
 
std::shared_ptr< VecDataArray< float, 3 > > getVertexTangents () const
 
void setVertexTCoords (const std::string &arrayName, std::shared_ptr< VecDataArray< float, 2 >> tcoords)
 Get/Set the active tcoords.
 
void setVertexTCoords (const std::string &arrayName)
 
std::string getActiveVertexTCoords () const
 
std::shared_ptr< VecDataArray< float, 2 > > getVertexTCoords () const
 
- Public Member Functions inherited from imstk::Geometry
 Geometry (const Geometry &other)
 
void operator= (const Geometry &other)
 
virtual const std::string getTypeName () const =0
 Returns the string representing the type name of the geometry. More...
 
 SIGNAL (Geometry, modified)
 
virtual Vec3d getCenter ()
 Returns the bounding box center.
 
void transform (const Mat4d &T, TransformType type=TransformType::ConcatenateToTransform)
 Applies a rigid transform to the geometry.
 
std::unique_ptr< Geometryclone ()
 polymorphic clone function, utilize this to get a copy of the geometry without casting to the expected geometry type
 
const std::string & getName () const
 Get the name of the geometry.
 
void setName (const std::string &name)
 
size_t getGlobalId () const
 Get the global (unique) index of the geometry.
 
virtual bool isMesh () const
 Returns true if the geometry is a mesh, else returns false.
 
void postModified ()
 Post modified event.
 
void translate (const Vec3d &t, TransformType type=TransformType::ConcatenateToTransform)
 Translate the geometry in Cartesian space.
 
void translate (double x, double y, double z, TransformType type=TransformType::ConcatenateToTransform)
 
void rotate (const Quatd &q, TransformType type=TransformType::ConcatenateToTransform)
 Rotate the geometry in Cartesian space.
 
void rotate (const Mat3d &m, TransformType type=TransformType::ConcatenateToTransform)
 
void rotate (const Vec3d &axis, double radians, TransformType type=TransformType::ConcatenateToTransform)
 
void scale (const Vec3d &scaling, TransformType type=TransformType::ConcatenateToTransform)
 Scale in Cartesian directions.
 
void scale (const double scaling, TransformType type=TransformType::ConcatenateToTransform)
 
Vec3d getTranslation () const
 Get/Set translation.
 
void setTranslation (const Vec3d &t)
 
void setTranslation (const double x, const double y, const double z)
 
Mat3d getRotation () const
 Get/Set rotation.
 
void setRotation (const Mat3d &m)
 
void setRotation (const Quatd &q)
 
void setRotation (const Vec3d &axis, const double angle)
 
Vec3d getScaling () const
 Get/Set scaling.
 
void setScaling (const Vec3d &s)
 
void setScaling (const double s)
 
const Mat4d & getTransform () const
 Get/Set the transform.
 
void setTransform (const Mat4d &m)
 
- 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 Member Functions

static size_t getScalarIndex (int x, int y, int z, const Vec3i &dims, int numComps)
 Returns index of data in scalar array given structured image coordinate, dimensions, and number of components does no bounds checking.
 
- Static Public Member Functions inherited from imstk::Geometry
static size_t getNumGlobalIds ()
 Get number of ids/geometries.
 

Protected Attributes

std::shared_ptr< AbstractDataArraym_scalarArray = nullptr
 
Vec3i m_dims = Vec3i(0, 0, 0)
 
int m_numComps = 1
 
Vec3d m_origin = Vec3d(0.0, 0.0, 0.0)
 
Vec3d m_spacing = Vec3d(1.0, 1.0, 1.0)
 
Vec3d m_invSpacing = Vec3d(1.0, 1.0, 1.0)
 
Vec6d m_bounds = Vec6d::Zero()
 
- Protected Attributes inherited from imstk::PointSet
std::shared_ptr< VecDataArray< double, 3 > > m_initialVertexPositions
 
std::shared_ptr< VecDataArray< double, 3 > > m_vertexPositions
 
std::unordered_map< std::string, std::shared_ptr< AbstractDataArray > > m_vertexAttributes
 
std::string m_activeVertexNormals = ""
 
std::string m_activeVertexScalars = ""
 
std::string m_activeVertexTangents = ""
 
std::string m_activeVertexTCoords = ""
 
Vec3d m_lowerCorner
 
Vec3d m_upperCorner
 
- Protected Attributes inherited from imstk::Geometry
bool m_transformApplied = true
 
bool m_boundsDirty = true
 
Mat4d m_transform = Mat4d::Identity()
 Transformation matrix.
 
size_t m_globalId
 Unique ID assigned to each geometry upon construction.
 
std::string m_name = "unnamed"
 
- 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
 

Additional Inherited Members

- Public Types inherited from imstk::Geometry
enum  TransformType { ApplyToData, ConcatenateToTransform }
 Enumeration for the transformation to apply ApplyToTransform to apply the transformation to the data ConcatenateToTransform to apply the transformation to the transform matrix.
 
enum  DataType { PreTransform, PostTransform }
 Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied PostTransform for data where transform matrix is applied.
 
- Public Types inherited from imstk::EventObject
using Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> >
 
- Protected Member Functions inherited from imstk::PointSet
void applyTransform (const Mat4d &m) override
 Applies transformation m directly the initial and post transform data.
 
void setActiveVertexAttribute (std::string &activeAttributeName, const std::string attributeName, const int expectedNumComponents, const ScalarTypeId expectedScalarType)
 Sets the active vertex attribute name as long as the # components is satisfied. Throws message and casts if incorrect scalar type is provided.
 
- Static Protected Member Functions inherited from imstk::Geometry
static size_t getUniqueId ()
 Get a unique ID for the new generated geometry object.
 
- Static Protected Attributes inherited from imstk::Geometry
static std::atomic< size_t > s_numGlobalIds = { 0 }
 Total number of geometries that have been created in this program.
 

Detailed Description

Class to represent 1, 2, or 3D image data (i.e. structured points)

Definition at line 22 of file imstkImageData.h.


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