Commit c717b6fb authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

BUG: Do not scale the cylinder based on radius

parent 57fb5e54
Pipeline #62490 running with stage
......@@ -81,10 +81,10 @@ protected:
void applyScaling(const double s) override;
void updatePostTransformData() override;
double m_radius = 0.7; ///> Radius of the cylinder
double m_length = 10.; ///> Length of the cylinder
double m_radiusPostTransform = 0.7; ///> Radius of the cylinder oncee transform applied
double m_lengthPostTransform = 10.; ///> Length of the cylinder onc transform applied
double m_radius = 1.; ///> Radius of the cylinder
double m_length = 1.; ///> Length of the cylinder
double m_radiusPostTransform = 1.; ///> Radius of the cylinder oncee transform applied
double m_lengthPostTransform = 1.; ///> Length of the cylinder onc transform applied
};
} // imstk
......
......@@ -21,8 +21,6 @@
#include "imstkVTKCylinderRenderDelegate.h"
#include "vtkCylinderSource.h"
namespace imstk
{
VTKCylinderRenderDelegate::VTKCylinderRenderDelegate(std::shared_ptr<Cylinder> cylinder) :
......@@ -30,10 +28,10 @@ VTKCylinderRenderDelegate::VTKCylinderRenderDelegate(std::shared_ptr<Cylinder> c
m_transformFilter(vtkSmartPointer<vtkTransformPolyDataFilter>::New())
{
Geometry::DataType type = Geometry::DataType::PreTransform;
auto cylinderSource = vtkSmartPointer<vtkCylinderSource>::New();
cylinderSource = vtkSmartPointer<vtkCylinderSource>::New();
cylinderSource->SetCenter(0., 0., 0.);
cylinderSource->SetRadius(cylinder->getRadius(type));
cylinderSource->SetHeight(cylinder->getLength(type));
cylinderSource->SetRadius(1.);
cylinderSource->SetHeight(m_geometry->getLength());
cylinderSource->SetResolution(100);
m_transformFilter->SetInputConnection(cylinderSource->GetOutputPort());
......@@ -53,10 +51,13 @@ VTKCylinderRenderDelegate::updateDataSource()
Geometry::DataType type = Geometry::DataType::PreTransform;
cylinderSource->SetRadius(m_geometry->getRadius());
cylinderSource->SetHeight(m_geometry->getLength());
AffineTransform3d T = AffineTransform3d::Identity();
T.translate(m_geometry->getPosition(type));
T.rotate(Quatd::FromTwoVectors(UP_VECTOR, m_geometry->getOrientationAxis(type)));
T.scale(m_geometry->getRadius(type));
T.scale(1.0);
T.matrix().transposeInPlace();
auto vtkT = vtkTransform::SafeDownCast(m_transformFilter->GetTransform());
......
......@@ -29,6 +29,7 @@
#include "vtkTransformPolyDataFilter.h"
#include "vtkCylinderSource.h"
namespace imstk
{
///
......@@ -60,6 +61,8 @@ public:
std::shared_ptr<Geometry> getGeometry() const override;
protected:
vtkSmartPointer<vtkCylinderSource> cylinderSource;
std::shared_ptr<Cylinder> m_geometry; ///> Geometry
vtkSmartPointer<vtkTransformPolyDataFilter> m_transformFilter; ///> Source
......
......@@ -2825,7 +2825,7 @@ void testVirtualCouplingCylinder()
#ifdef iMSTK_USE_OPENHAPTICS
// Device clients
auto client = std::make_shared<imstk::HDAPIDeviceClient>("PHANToM 1");
auto client = std::make_shared<imstk::HDAPIDeviceClient>("PHANToM 2");
// Device Server
auto server = std::make_shared<imstk::HDAPIDeviceServer>();
......@@ -2839,20 +2839,20 @@ void testVirtualCouplingCylinder()
auto visualGeom = std::make_shared<imstk::Sphere>();
visualGeom->setRadius(5.);
auto collidingGeom = std::make_shared<imstk::Sphere>();
collidingGeom->setRadius(5);
collidingGeom->setRadius(5.);
auto virtualCouplingSphereObj = std::make_shared<CollidingObject>("VirtualCouplingObject");
virtualCouplingSphereObj->setCollidingGeometry(collidingGeom);
virtualCouplingSphereObj->setVisualGeometry(visualGeom);
scene->addSceneObject(virtualCouplingSphereObj);
// Create colliding cylinder scene object
auto CylinderGeom = std::make_shared<Cylinder>();
//CylinderGeom->setRadius(20.);
//CylinderGeom->setLength(40.);
auto CylinderGeomVis = std::make_shared<Cylinder>();
CylinderGeomVis->setRadius(10.);
CylinderGeomVis->setLength(40.);
auto CylinderObj = std::make_shared<CollidingObject>("Cylinder");
CylinderObj->setVisualGeometry(CylinderGeom);
CylinderObj->setCollidingGeometry(CylinderGeom);
CylinderObj->setVisualGeometry(CylinderGeomVis);
CylinderObj->setCollidingGeometry(CylinderGeomVis);
scene->addSceneObject(CylinderObj);
// Create and add virtual coupling object controller in the scene
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment