7 #include "imstkGeometry.h" 8 #include "imstkLogger.h" 9 #include "imstkParallelUtils.h" 25 LOG(WARNING) <<
"computeBoundingBox() must be called from an instance of a specific geometry class";
31 if (t.isApprox(Vec3d::Zero()))
36 transform(AffineTransform3d(Eigen::Translation3d(t)).matrix(), type);
48 if (r.isApprox(Mat3d::Identity()))
53 Mat4d m = Mat4d::Identity();
54 m.block<3, 3>(0, 0) = r;
61 this->
rotate(q.toRotationMatrix(), type);
67 this->
rotate(Rotd(radians, axis.normalized()).toRotationMatrix(), type);
73 Mat4d m = Mat4d::Identity();
83 Mat4d m = Mat4d::Identity();
93 if (type == TransformType::ConcatenateToTransform)
102 m_transformApplied =
false;
112 Geometry::setTranslation(
const Vec3d& t)
115 m_transformApplied =
false;
119 Geometry::setTranslation(
const double x,
const double y,
const double z)
121 this->setTranslation(Vec3d(x, y, z));
125 Geometry::setRotation(
const Mat3d& m)
136 m_transformApplied =
false;
140 Geometry::setRotation(
const Quatd& q)
142 this->setRotation(q.toRotationMatrix());
146 Geometry::setRotation(
const Vec3d& axis,
const double angle)
148 this->setRotation(Rotd(angle, axis).toRotationMatrix());
152 Geometry::setScaling(
const Vec3d& s)
155 if (s == Vec3d::Zero())
157 LOG(WARNING) <<
"Cannot apply 0 scales";
163 m_transformApplied =
false;
167 Geometry::setScaling(
const double s)
169 setScaling(Vec3d(s, s, s));
181 r.block<3, 1>(0, 0) = x.normalized();
182 r.block<3, 1>(0, 1) = y.normalized();
183 r.block<3, 1>(0, 2) = z.normalized();
Mat4d m_transform
Transformation matrix.
static std::atomic< size_t > s_numGlobalIds
Total number of geometries that have been created in this program.
virtual void print() const
Print.
Vec3d getTranslation() const
Get/Set translation.
void rotate(const Quatd &q, TransformType type=TransformType::ConcatenateToTransform)
Rotate the geometry in Cartesian space.
virtual const std::string getTypeName() const =0
Returns the string representing the type name of the geometry.
virtual void computeBoundingBox(Vec3d &lowerCorner, Vec3d &upperCorner, const double paddingPercent=0.0)
Compute the bounding box for the geometry.
Vec3d getScaling() const
Get/Set scaling.
void transform(const Mat4d &T, TransformType type=TransformType::ConcatenateToTransform)
Applies a rigid transform to the geometry.
void postModified()
Post modified event.
Mat3d getRotation() const
Get/Set rotation.
void scale(const Vec3d &scaling, TransformType type=TransformType::ConcatenateToTransform)
Scale in Cartesian directions.
void translate(const Vec3d &t, TransformType type=TransformType::ConcatenateToTransform)
Translate the geometry in Cartesian space.
TransformType
Enumeration for the transformation to apply ApplyToTransform to apply the transformation to the data...
virtual void applyTransform(const Mat4d &)
Directly apply transform to data.