Commit 2065d6a2 authored by Andrew Wilson's avatar Andrew Wilson Committed by Andrew Wilson
Browse files

compile fixes, builds on gcc

parent b618cb5d
......@@ -41,13 +41,10 @@
#include "imstkVTKViewer.h"
#ifdef iMSTK_USE_OPENHAPTICS
#define EXAMPLE_USE_HAPTICS
#define USE_PBR
#ifdef EXAMPLE_USE_HAPTICS
#include "imstkHapticDeviceManager.h"
#include "imstkHapticDeviceClient.h"
#endif
#else
#include "imstkKeyboardDeviceClient.h"
#endif
using namespace imstk;
......@@ -157,7 +154,6 @@ makeTissueObj(const std::string& name,
// Setup the VisualModel
imstkNew<RenderMaterial> material;
material->setBackFaceCulling(false);
#ifdef USE_PBR
material->setDisplayMode(RenderMaterial::DisplayMode::Surface);
material->setShadingModel(RenderMaterial::ShadingModel::PBR);
auto diffuseTex = MeshIO::read<ImageData>(iMSTK_DATA_ROOT "/textures/fleshDiffuse.jpg");
......@@ -166,9 +162,6 @@ makeTissueObj(const std::string& name,
material->addTexture(std::make_shared<Texture>(normalTex, Texture::Type::Normal));
auto ormTex = MeshIO::read<ImageData>(iMSTK_DATA_ROOT "/textures/fleshORM.jpg");
material->addTexture(std::make_shared<Texture>(ormTex, Texture::Type::ORM));
#else
material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
#endif
imstkNew<VisualModel> visualModel(clothMesh);
visualModel->setRenderMaterial(material);
......@@ -211,7 +204,7 @@ main()
imstkNew<VecDataArray<int, 2>> indicesPtr(1);
(*indicesPtr)[0] = Vec2i(0, 1);
toolGeometry->initialize(verticesPtr, indicesPtr);
#ifndef EXAMPLE_USE_HAPTICS
#ifndef iMSTK_USE_OPENHAPTICS
toolGeometry->translate(Vec3d(0.5, 2.0, 0.5));
#endif
......@@ -247,7 +240,7 @@ main()
sceneManager->setExecutionType(Module::ExecutionType::ADAPTIVE);
sceneManager->pause(); // Start simulation paused
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
imstkNew<HapticDeviceManager> hapticManager;
hapticManager->setSleepDelay(1.0); // Delay for 1ms (haptics thread is limited to max 1000hz)
std::shared_ptr<HapticDeviceClient> hapticDeviceClient = hapticManager->makeDeviceClient();
......@@ -256,7 +249,7 @@ main()
imstkNew<SimulationManager> driver;
driver->addModule(viewer);
driver->addModule(sceneManager);
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
driver->addModule(hapticManager);
#endif
driver->setDesiredDt(0.005);
......@@ -264,7 +257,7 @@ main()
Mat3d rotationalOffset = Mat3d::Identity();
connect<Event>(sceneManager, SceneManager::preUpdate, [&](Event*)
{
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
hapticDeviceClient->update();
const Quatd deviceOrientation = (Quatd(rotationalOffset) * hapticDeviceClient->getOrientation()).normalized();
const Vec3d devicePosition = (rotationalOffset * hapticDeviceClient->getPosition()) * 0.05 + Vec3d(0.0, 0.0, 0.0);
......
......@@ -44,25 +44,25 @@
#include "imstkVisualModel.h"
#include "imstkVTKViewer.h"
#ifdef iMSTK_USE_OPENHAPTICS
#define EXAMPLE_USE_HAPTICS
#define USE_FEM
// If two-way coupling is used haptic forces can be felt when the tool
// hits the tissue
#define TWOWAY_COUPLING
// Whether to use FEM or volume+distance constraints
#define USE_FEM
#ifdef TWOWAY_COUPLING
#include "imstkPbdRigidObjectCollision.h"
#else
#include "imstkPbdObjectCollision.h"
#endif
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
#include "imstkHapticDeviceManager.h"
#include "imstkHapticDeviceClient.h"
#include "imstkRigidObjectController.h"
#endif
#else
#include "imstkKeyboardDeviceClient.h"
#endif
using namespace imstk;
......@@ -382,7 +382,7 @@ main()
driver->addModule(sceneManager);
driver->setDesiredDt(0.002);
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
imstkNew<HapticDeviceManager> hapticManager;
hapticManager->setSleepDelay(1.0); // Delay for 1ms (haptics thread is limited to max 1000hz)
std::shared_ptr<HapticDeviceClient> hapticDeviceClient = hapticManager->makeDeviceClient();
......
......@@ -16,21 +16,23 @@
#
###########################################################################
project(Example-PBDTissueCut)
if(iMSTK_USE_OpenHaptics)
project(Example-PBDTissueCut)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
imstk_add_executable(${PROJECT_NAME}
PBDTissueCutExample.cpp
CutHelp.h)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
imstk_add_executable(${PROJECT_NAME}
PBDTissueCutExample.cpp
CutHelp.h)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
#-----------------------------------------------------------------------------
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
#-----------------------------------------------------------------------------
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD)
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
endif()
\ No newline at end of file
......@@ -46,16 +46,12 @@
#include "NeedleInteraction.h"
#ifdef iMSTK_USE_OPENHAPTICS
#define EXAMPLE_USE_HAPTICS
#ifdef EXAMPLE_USE_HAPTICS
#include "imstkHapticDeviceManager.h"
#include "imstkHapticDeviceClient.h"
#include "imstkRigidObjectController.h"
#else
#include "imstkKeyboardDeviceClient.h"
#endif
#endif
using namespace imstk;
......@@ -370,7 +366,7 @@ main()
driver->addModule(sceneManager);
driver->setDesiredDt(0.001);
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
imstkNew<HapticDeviceManager> hapticManager;
hapticManager->setSleepDelay(0.1); // Delay for 1ms (haptics thread is limited to max 1000hz)
std::shared_ptr<HapticDeviceClient> hapticDeviceClient = hapticManager->makeDeviceClient();
......@@ -423,6 +419,7 @@ main()
toolObj->getRigidBodyModel2()->getConfig()->m_dt = sceneManager->getDt();
//tissueObj->getPbdModel()->getParameters()->m_dt = sceneManager->getDt();
#ifdef iMSTK_USE_OPENHAPTICS
if (controller->getForce().norm() > 1.0)
{
ghostToolObj->getVisualModel(0)->setIsVisible(true);
......@@ -436,6 +433,7 @@ main()
toolGhostMesh->setRotation(controller->getRotation());
toolGhostMesh->updatePostTransformData();
toolGhostMesh->postModified();
#endif
});
// Add mouse and keyboard controls to the viewer
......
......@@ -44,17 +44,12 @@
#include "NeedleInteraction.h"
#ifdef iMSTK_USE_OPENHAPTICS
#define EXAMPLE_USE_HAPTICS
#define USE_FEM
#ifdef EXAMPLE_USE_HAPTICS
#include "imstkHapticDeviceManager.h"
#include "imstkHapticDeviceClient.h"
#include "imstkRigidObjectController.h"
#else
#include "imstkKeyboardDeviceClient.h"
#endif
#endif
using namespace imstk;
......@@ -358,7 +353,7 @@ main()
driver->addModule(sceneManager);
driver->setDesiredDt(0.001);
#ifdef EXAMPLE_USE_HAPTICS
#ifdef iMSTK_USE_OPENHAPTICS
imstkNew<HapticDeviceManager> hapticManager;
hapticManager->setSleepDelay(0.1); // Delay for 1ms (haptics thread is limited to max 1000hz)
std::shared_ptr<HapticDeviceClient> hapticDeviceClient = hapticManager->makeDeviceClient();
......
......@@ -173,20 +173,6 @@ struct PointIndexDirectionElement
double penetrationDepth;
};
#define ElementConstructorAssignment(ElementTypeName) \
CollisionElement(const ElementTypeName ## Element & element) : m_element { element }, m_type { CollisionElementType:: ## ElementTypeName } \
{ \
} \
void \
operator=(const ElementTypeName ## Element& element) \
{ \
m_element.m_ ## ElementTypeName ## Element = element; \
}
#define ElementUnionConstructor(ElementTypeName) \
ElementTypeName ## Element m_ ## ElementTypeName ## Element; \
Element(const ElementTypeName ## Element ## & ele) : m_ ## ElementTypeName ## Element(ele) { }
///
/// \brief Union of collision elements. We use a union to avoid polymorphism. There may be many
/// elements and accessing them needs to be quick. Additionally the union keeps them more compact
......@@ -196,11 +182,35 @@ struct CollisionElement
{
CollisionElement() : m_element{EmptyElement()}, m_type{CollisionElementType::Empty} { }
ElementConstructorAssignment(Empty);
ElementConstructorAssignment(CellVertex);
ElementConstructorAssignment(CellIndex);
ElementConstructorAssignment(PointDirection);
ElementConstructorAssignment(PointIndexDirection);
CollisionElement(const EmptyElement& element) : m_element{element}, m_type{CollisionElementType::Empty} { }
void operator=(const EmptyElement& element)
{
m_element.m_EmptyElement = element;
}
CollisionElement(const CellVertexElement& element) : m_element{element}, m_type{CollisionElementType::CellVertex} { }
void operator=(const CellVertexElement& element)
{
m_element.m_CellVertexElement = element;
}
CollisionElement(const CellIndexElement& element) : m_element{element}, m_type{CollisionElementType::CellIndex} { }
void operator=(const CellIndexElement& element)
{
m_element.m_CellIndexElement = element;
}
CollisionElement(const PointDirectionElement& element) : m_element{element}, m_type{CollisionElementType::PointDirection} { }
void operator=(const PointDirectionElement& element)
{
m_element.m_PointDirectionElement = element;
}
CollisionElement(const PointIndexDirectionElement& element) : m_element{element}, m_type{CollisionElementType::PointIndexDirection} { }
void operator=(const PointIndexDirectionElement& element)
{
m_element.m_PointIndexDirectionElement = element;
}
CollisionElement(const CollisionElement& other)
{
......@@ -226,14 +236,19 @@ struct CollisionElement
union Element
{
Element() : m_EmptyElement(EmptyElement()) { }
EmptyElement m_EmptyElement;
CellVertexElement m_CellVertexElement;
CellIndexElement m_CellIndexElement;
PointDirectionElement m_PointDirectionElement;
PointIndexDirectionElement m_PointIndexDirectionElement;
Element() : m_EmptyElement(EmptyElement()) { }
// Constructors needed here for implicit conversions+assignment between elements and parent struct
ElementUnionConstructor(Empty);
ElementUnionConstructor(CellVertex);
ElementUnionConstructor(CellIndex);
ElementUnionConstructor(PointDirection);
ElementUnionConstructor(PointIndexDirection);
Element(const EmptyElement& ele) : m_EmptyElement(ele) { }
Element(const CellVertexElement& ele) : m_CellVertexElement(ele) { }
Element(const CellIndexElement& ele) : m_CellIndexElement(ele) { }
Element(const PointDirectionElement& ele) : m_PointDirectionElement(ele) { }
Element(const PointIndexDirectionElement& ele) : m_PointIndexDirectionElement(ele) { }
} m_element;
CollisionElementType m_type;
......
......@@ -28,9 +28,9 @@ namespace imstk
{
struct VertexMassPair
{
Vec3d* vertex = nullptr;
double invMass = 0.0;
Vec3d* velocity = nullptr;
Vec3d* vertex;
double invMass;
Vec3d* velocity;
};
///
......
......@@ -20,7 +20,6 @@
=========================================================================*/
#include "imstkLooseOctree.h"
#include "imstkDebugRenderGeometry.h"
#include "imstkLogger.h"
#include "imstkSurfaceMesh.h"
......
Markdown is supported
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