9 #include "imstkMacros.h" 10 #include "imstkPointSet.h" 11 #include "imstkTypes.h" 15 class AbstractDataArray;
31 void print()
const override;
59 inline size_t getScalarIndex(
const Vec3i& imgCoord) {
return getScalarIndex(imgCoord[0], imgCoord[1], imgCoord[2], m_dims, m_numComps); }
66 inline static size_t getScalarIndex(
int x,
int y,
int z,
const Vec3i& dims,
int numComps) {
return (x + dims[0] * (y + z * dims[1])) * numComps; }
68 std::shared_ptr<ImageData> cast(ScalarTypeId type);
85 const Vec3d size = Vec3d(
86 m_spacing.x() * m_dims[0],
87 m_spacing.y() * m_dims[1],
88 m_spacing.z() * m_dims[2]);
90 m_bounds[0] = m_origin.x();
91 m_bounds[1] = m_origin.x() + size.x();
92 m_bounds[2] = m_origin.y();
93 m_bounds[3] = m_origin.y() + size.y();
94 m_bounds[4] = m_origin.z();
95 m_bounds[5] = m_origin.z() + size.z();
100 void computeBoundingBox(Vec3d& lowerCorner, Vec3d& upperCorner,
const double imstkNotUsed(paddingPercent))
override 103 lowerCorner = Vec3d(bounds[0], bounds[2], bounds[4]);
104 upperCorner = Vec3d(bounds[1], bounds[3], bounds[5]);
110 std::shared_ptr<AbstractDataArray>
getScalars()
const {
return m_scalarArray; }
111 void setScalars(std::shared_ptr<AbstractDataArray> scalars,
const int numComps,
int* dim);
118 void setOrigin(
const Vec3d& origin) { m_origin = origin; }
125 void setSpacing(
const Vec3d& spacing)
128 m_invSpacing = Vec3d(1.0 / spacing[0], 1.0 / spacing[1], 1.0 / spacing[2]);
136 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));
146 void clear()
override;
154 return std::unique_ptr<ImageData>(cloneImplementation());
163 using Geometry::setRotation;
164 using Geometry::setScaling;
165 using Geometry::setTranslation;
166 using Geometry::setTransform;
169 std::shared_ptr<AbstractDataArray> m_scalarArray =
nullptr;
170 Vec3i m_dims = Vec3i(0, 0, 0);
172 Vec3d m_origin = Vec3d(0.0, 0.0, 0.0);
173 Vec3d m_spacing = Vec3d(1.0, 1.0, 1.0);
174 Vec3d m_invSpacing = Vec3d(1.0, 1.0, 1.0);
175 Vec6d m_bounds = Vec6d::Zero();
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
std::unique_ptr< ImageData > clone()
Polymorphic clone, hides the declaration in superclass return own type.
void rotate(const Quatd &q, TransformType type=TransformType::ConcatenateToTransform)
Rotate the geometry in Cartesian space.
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...
const Vec3i & getDimensions() const
Returns the dimensions of the image.
const ScalarTypeId getScalarType() const
Returns the scalar type of the image.
void transform(const Mat4d &T, TransformType type=TransformType::ConcatenateToTransform)
Applies a rigid transform to the geometry.
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.
const Vec3d & getInvSpacing() const
Returns inv spacing of the image.
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.
double getVolume() override
Returns the volume.
void computePoints()
Generates points in the geometry from the ImageData (center of each voxel)
void scale(const Vec3d &scaling, TransformType type=TransformType::ConcatenateToTransform)
Scale in Cartesian directions.
std::shared_ptr< AbstractDataArray > getScalars() const
Get/Set the scalars.
const Vec3d & getSpacing() const
Get/Set the spacing between pixels/voxels of the image.
const Vec6d & getBounds()
Returns bounds of the image (voxel to voxel)
void clear() override
Clear the data.
void translate(const Vec3d &t, TransformType type=TransformType::ConcatenateToTransform)
Translate the geometry in Cartesian space.
int getNumComponents() const
Returns the number of components of the image.
const Vec3d & getOrigin() const
Get/Set the origin of the image.
void print() const override
Print the image data info.
Class to represent 1, 2, or 3D image data (i.e. structured points)
void * getVoidPointer()
Returns a pointer to the underlying storage of the image.