iMSTK
Interactive Medical Simulation Toolkit
imstkCylinder.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkAnalyticalGeometry.h"
10 #include "imstkMacros.h"
11 
12 namespace imstk
13 {
20 {
21 public:
22  Cylinder(const Vec3d& pos = Vec3d(0.0, 0.0, 0.0), const double radius = 1.0, const double length = 1.0,
23  const Quatd& orientation = Quatd::Identity()) :
25  {
26  setPosition(pos);
27  setOrientation(orientation);
28  setRadius(radius);
29  setLength(length);
31  }
32 
33  ~Cylinder() override = default;
34 
35  IMSTK_TYPE_NAME(Cylinder)
36 
37 
38  void print() const override;
41 
45  double getVolume() override { return PI * m_radius * m_radius * m_length; }
46 
50  double getRadius(DataType type = DataType::PostTransform);
51  void setRadius(const double r);
53 
57  double getLength(DataType type = DataType::PostTransform);
58  void setLength(const double r);
60 
64  void computeBoundingBox(Vec3d& min, Vec3d& max, const double paddingPercent);
65 
69  void updatePostTransformData() const override;
70 
75  std::unique_ptr<Cylinder> clone()
76  {
77  return std::unique_ptr<Cylinder>(cloneImplementation());
78  }
79 
80 protected:
81  // Hide these unimplemented functions
83 
84  void applyTransform(const Mat4d& m) override;
85 
86  double m_radius = 1.0;
87  double m_length = 1.0;
88  mutable double m_radiusPostTransform = 1.0;
89  mutable double m_lengthPostTransform = 1.0;
90 
91 private:
92  Cylinder* cloneImplementation() const
93  {
94  return new Cylinder(*this);
95  }
96 };
97 } // namespace imstk
double m_radiusPostTransform
Radius of the cylinder oncee transform applied.
Definition: imstkCylinder.h:88
Base class for any analytical geometrical representation.
void computeBoundingBox(Vec3d &min, Vec3d &max, const double paddingPercent)
Get the min, max of the AABB around the cylinder.
Cylinder geometry, default configuration is at origin with length running up the y axes...
Definition: imstkCylinder.h:19
double m_radius
Radius of the cylinder.
Definition: imstkCylinder.h:86
Compound Geometry.
void updatePostTransformData() const override
Update the Cylinder parameters applying the latest transform.
double m_length
Length of the cylinder.
Definition: imstkCylinder.h:87
void setPosition(const Vec3d p)
Set the local position.
void setOrientation(const Quatd r)
Set the local orientation.
double getLength(DataType type=DataType::PostTransform)
Get/Set the length of the cylinder.
double getRadius(DataType type=DataType::PostTransform)
Get/Set the radius of the cylinder.
double m_lengthPostTransform
Length of the cylinder onc transform applied.
Definition: imstkCylinder.h:89
void applyTransform(const Mat4d &m) override
Apply a user transform directly to (pre-transformed) parameters producing new parameters.
double getFunctionValue(const Vec3d &imstkNotUsed(pos)) const override
Returns the implicit function value, this could signed, unsigned distance, or some other scalar...
std::unique_ptr< Cylinder > clone()
Polymorphic clone, hides the declaration in superclass return own type.
Definition: imstkCylinder.h:75
void print() const override
Print the cylinder info.
DataType
Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied Po...
Definition: imstkGeometry.h:41
double getVolume() override
Returns the volume of the cylinder.
Definition: imstkCylinder.h:45