9 #include "imstkEventObject.h" 10 #include "imstkMacros.h" 11 #include "imstkMath.h" 13 #include <unordered_map> 33 ConcatenateToTransform
53 m_transformApplied = other.m_transformApplied;
60 void operator=(
const Geometry& other)
62 m_transformApplied = other.m_transformApplied;
80 virtual void print()
const;
91 virtual void computeBoundingBox(Vec3d& lowerCorner, Vec3d& upperCorner,
const double paddingPercent = 0.0);
100 return (min + max) * 0.5;
115 void rotate(
const Vec3d& axis,
double radians,
TransformType type = TransformType::ConcatenateToTransform);
121 void scale(
const Vec3d& scaling,
TransformType type = TransformType::ConcatenateToTransform);
122 void scale(
const double scaling,
TransformType type = TransformType::ConcatenateToTransform);
134 void setTranslation(
const Vec3d& t);
135 void setTranslation(
const double x,
const double y,
const double z);
142 void setRotation(
const Mat3d& m);
143 void setRotation(
const Quatd& q);
144 void setRotation(
const Vec3d& axis,
const double angle);
151 void setScaling(
const Vec3d& s);
152 void setScaling(
const double s);
159 void setTransform(
const Mat4d& m)
162 m_transformApplied =
false;
173 return std::unique_ptr<Geometry>(cloneImplementation());
179 const std::string&
getName()
const {
return m_name; }
180 void setName(
const std::string& name) { m_name = name; }
195 virtual bool isMesh()
const {
return false; }
202 m_boundsDirty =
true;
206 virtual void updatePostTransformData()
const { }
225 mutable bool m_transformApplied =
true;
226 mutable bool m_boundsDirty =
true;
231 std::string m_name =
"unnamed";
237 virtual Geometry* cloneImplementation()
const = 0;
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.
std::unique_ptr< Geometry > clone()
polymorphic clone function, utilize this to get a copy of the geometry without casting to the expecte...
virtual bool isMesh() const
Returns true if the geometry is a mesh, else returns false.
static size_t getUniqueId()
Get a unique ID for the new generated geometry object.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
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.
const Mat4d & getTransform() const
Get/Set the transform.
Vec3d getScaling() const
Get/Set scaling.
void transform(const Mat4d &T, TransformType type=TransformType::ConcatenateToTransform)
Applies a rigid transform to the geometry.
static size_t getNumGlobalIds()
Get number of ids/geometries.
size_t m_globalId
Unique ID assigned to each geometry upon construction.
void postModified()
Post modified event.
Mat3d getRotation() const
Get/Set rotation.
void scale(const Vec3d &scaling, TransformType type=TransformType::ConcatenateToTransform)
Scale in Cartesian directions.
virtual Vec3d getCenter()
Returns the bounding box center.
virtual double getVolume()
Returns the volume of the geometry (if valid)
Base class for any geometrical representation.
const std::string & getName() const
Get the name of the geometry.
EventObject is the base class for all objects in iMSTK that can receive and emit events. It supports direct and queued observer functions. Direct observers receive events immediately on the same thread This can either be posted on an object or be a function pointer Queued observers receive events within their queue which they can process whenever they like. These can be connected with the connect/queuedConnect/disconnect functions Lambda recievers cannot be disconnected unless all receivers to a signal are removed.
void translate(const Vec3d &t, TransformType type=TransformType::ConcatenateToTransform)
Translate the geometry in Cartesian space.
size_t getGlobalId() const
Get the global (unique) index of the geometry.
void postEvent(const T &e)
Emits the event Direct observers will be immediately called, in sync Queued observers will receive th...
TransformType
Enumeration for the transformation to apply ApplyToTransform to apply the transformation to the data...
DataType
Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied Po...
virtual void applyTransform(const Mat4d &)
Directly apply transform to data.