Skip to content
Snippets Groups Projects
Commit 6ff85f24 authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: Implement VirtualCouplingObject

Subclass of trackingcontroller and collidingobject
parent 82d0a998
No related branches found
No related tags found
No related merge requests found
......@@ -36,14 +36,14 @@ public:
{
Visual,
Static,
VirtualCoupled,
VirtualCoupling,
Rigid,
Deformable
};
SceneObject(std::string name) : m_name(name) {}
~SceneObject() = default;
virtual ~SceneObject() = default;
const Type& getType() const;
......
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include "imstkVirtualCouplingObject.h"
#include <memory>
#include "imstkGeometry.h"
#include "imstkGeometryMap.h"
#include <g3log/g3log.hpp>
namespace imstk {
void
VirtualCouplingObject::updateFromDevice()
{
Vec3d p;
Quatd r;
if (!this->computeTrackingData(p, r))
{
LOG(WARNING) << "VirtualCouplingObject::updateFromDevice warning: could not update tracking info.";
return;
}
// Update colliding geometry
m_collidingGeometry->setPosition(p);
m_collidingGeometry->setOrientation(r);
// Update visual geometry
if(m_collidingToVisualMap)
{
m_collidingToVisualMap->apply();
}
}
}
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#ifndef imstkVirtualCouplingObject_h
#define imstkVirtualCouplingObject_h
#include "imstkCollidingObject.h"
#include "imstkTrackingController.h"
namespace imstk {
class Geometry;
class GeometryMap;
class VirtualCouplingObject : public CollidingObject, public TrackingController
{
public:
VirtualCouplingObject(std::string name,
std::shared_ptr<DeviceClient> deviceClient = nullptr,
double scaling = 1.0) :
CollidingObject(name),
TrackingController(deviceClient, scaling)
{
m_type = Type::VirtualCoupling;
}
~VirtualCouplingObject() = default;
void updateFromDevice();
};
}
#endif // ifndef imstkVirtualCouplingObject_h
......@@ -22,6 +22,7 @@
#include "imstkSceneManager.h"
#include "imstkCameraController.h"
#include "imstkVirtualCouplingObject.h"
#include "g3log/g3log.hpp"
......@@ -45,6 +46,21 @@ SceneManager::initModule()
}
}
void
SceneManager::runModule()
{
LOG(DEBUG) << m_name << " manager : running";
for (auto obj : m_scene->getSceneObjects())
{
if (auto virtualCoupling = std::dynamic_pointer_cast<VirtualCouplingObject>(obj))
{
virtualCoupling->updateFromDevice();
}
}
}
void
SceneManager::cleanUpModule()
{
......@@ -56,13 +72,6 @@ SceneManager::cleanUpModule()
m_threadMap.at(camController->getName()).join();
}
}
void
SceneManager::runModule()
{
LOG(DEBUG) << m_name << " manager : running";
}
void
SceneManager::startModuleInNewThread(std::shared_ptr<Module> module)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment