diff --git a/examples/AlphaMap/AlphaMappingExample.cpp b/examples/AlphaMap/AlphaMappingExample.cpp index 7fd70cc76fdcc1af03a08679a20ade0251414680..6d91bda2185b47b3b7e1cee7c91cf45b95ac1265 100644 --- a/examples/AlphaMap/AlphaMappingExample.cpp +++ b/examples/AlphaMap/AlphaMappingExample.cpp @@ -50,8 +50,8 @@ AlphaMapExample::AlphaMapExample() motionTrans = NULL; hapticInterface = NULL; - simmedtkSDK = smSDK::createSDK(); - object1 = new smStaticSceneObject(); + simmedtkSDK = SDK::createSDK(); + object1 = new StaticSceneObject(); smMetalShader *metalShader = new smMetalShader("../../resources/shaders/VertexBumpMap1.cg", "../../resources/shaders/FragmentBumpMap1.cg"); @@ -65,7 +65,7 @@ AlphaMapExample::AlphaMapExample() - smTextureManager::init(smSDK::getErrorLog()); + smTextureManager::init(SDK::getErrorLog()); smTextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); smTextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); smTextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); @@ -88,7 +88,7 @@ AlphaMapExample::AlphaMapExample() SIMMEDTK_RENDER_TEXTURE | SIMMEDTK_RENDER_MATERIALCOLOR | SIMMEDTK_RENDER_TRANSPARENT); object1->getRenderDetail()->addShader(metalShader->getUniqueId()); object1->mesh->translate(0, 10, -110); - object1->mesh->scale(smVec3d(5, 5, 5)); + object1->mesh->scale(core::Vec3d(5, 5, 5)); object1->getRenderDetail()->lineSize = 2; object1->getRenderDetail()->pointSize = 5; diff --git a/examples/AlphaMap/AlphaMappingExample.h b/examples/AlphaMap/AlphaMappingExample.h index a866e52b875f24fe835dea85dadfdc6c2654e5aa..385207603ebe00da76cced116657f82633e37e4c 100644 --- a/examples/AlphaMap/AlphaMappingExample.h +++ b/examples/AlphaMap/AlphaMappingExample.h @@ -36,13 +36,13 @@ #include "Rendering/metalShader.h" -class AlphaMapExample: public smSimulationMain, public smCoreClass +class AlphaMapExample: public SimulationMain, public CoreClass { public: - smStaticSceneObject *object1; - smSDK* simmedtkSDK; - smScene *scene1; + StaticSceneObject *object1; + SDK* simmedtkSDK; + Scene *scene1; smViewer *viewer; smPhantomInterface* hapticInterface; @@ -51,7 +51,7 @@ public: AlphaMapExample(); void initHapticCamMotion(); - virtual void simulateMain(smSimulationMainParam p_param) + virtual void simulateMain(SimulationMainParam p_param) { } void draw() override; diff --git a/examples/AudioExample/AudioExample.cpp b/examples/AudioExample/AudioExample.cpp index d03a95687d291e9277e390acd0b72d8aaea5cd31..ec70fad8d37809ea0199d20d1b8c013dd06a891b 100644 --- a/examples/AudioExample/AudioExample.cpp +++ b/examples/AudioExample/AudioExample.cpp @@ -43,7 +43,7 @@ void AudioKeyboardController::setSound(std::shared_ptr<smAudio> a) sound = a; } -void AudioKeyboardController::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void AudioKeyboardController::handleEvent(std::shared_ptr<mstk::Event::Event> event) { assert(sound); @@ -88,13 +88,13 @@ void AudioKeyboardController::handleEvent(std::shared_ptr<mstk::Event::smEvent> void runAudioExample() { - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smViewer> viewer; std::shared_ptr<smAudio> sound; std::shared_ptr<AudioKeyboardController> audioCtl; //Create an instance of the SimMedTK framework/SDK - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); //Create a viewer to see the scene through viewer = std::make_shared<smViewer>(); diff --git a/examples/AudioExample/AudioExample.h b/examples/AudioExample/AudioExample.h index ab6b491c5f74d73d6ed1caca4669babd25c5cbca..e6de836b17997ab5bd2736abd0f0193c26c3b06b 100644 --- a/examples/AudioExample/AudioExample.h +++ b/examples/AudioExample/AudioExample.h @@ -27,7 +27,7 @@ #include "Core/SDK.h" #include "Devices/Audio.h" -class AudioKeyboardController : public smCoreClass +class AudioKeyboardController : public CoreClass { public: /// \brief Default constructor @@ -39,10 +39,10 @@ public: /// \param a Pointer to sound to be controlled AudioKeyboardController(std::shared_ptr<smAudio> a); - /// \brief Event handling function from smCoreClass + /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief Set the sound to be controlled /// diff --git a/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp b/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp index d66a3130d5ae9bff42b7ff4b68077305eca5140a..5642537e9f568eabc75dfb0436ba549ebd2d8db8 100644 --- a/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp +++ b/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp @@ -37,7 +37,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() moveObj = 9; // Create the sdk - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); // Create scene scene = sdk->createScene(); @@ -67,7 +67,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() smTextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); // Create collision models - std::shared_ptr<smMeshCollisionModel> collisionModelA = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<MeshCollisionModel> collisionModelA = std::make_shared<MeshCollisionModel>(); collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); collisionModelA->getMesh()->assignTexture("livertexture1"); collisionModelA->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); @@ -75,23 +75,23 @@ CollisionDetectionBVH::CollisionDetectionBVH() collisionModelA->getMesh()->getRenderDetail()->lineSize = 2; collisionModelA->getMesh()->getRenderDetail()->pointSize = 5; - std::shared_ptr<smMeshCollisionModel> collisionModelB = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<MeshCollisionModel> collisionModelB = std::make_shared<MeshCollisionModel>(); collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); collisionModelB->getMesh()->assignTexture("livertexture2"); - collisionModelB->getMesh()->translate(smVec3d(2, 0, 0)); + collisionModelB->getMesh()->translate(core::Vec3d(2, 0, 0)); collisionModelB->getMesh()->assignTexture("livertexture2"); collisionModelB->getMesh()->getRenderDetail()->shadowColor.rgba[0] = 1.0; collisionModelB->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); // Add models to a collision pair so they can be queried for collision - std::shared_ptr<smCollisionPair> collisionPair = std::make_shared<smCollisionPair>(); + std::shared_ptr<CollisionPair> collisionPair = std::make_shared<CollisionPair>(); collisionPair->setModels(collisionModelA,collisionModelB); // Collision detection to be used - collisionDetection = std::make_shared<smMeshToMeshCollision>(); + collisionDetection = std::make_shared<MeshToMeshCollision>(); // Create a static scene - modelA = std::make_shared<smStaticSceneObject>(); + modelA = std::make_shared<StaticSceneObject>(); modelA->setModel(collisionModelA); sdk->registerSceneObject(modelA); sdk->registerMesh(collisionModelA->getMesh()); @@ -100,7 +100,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() modelA->attachObjectSimulator(defaultSimulator); // Initialize the scecond object - modelB = std::make_shared<smStaticSceneObject>(); + modelB = std::make_shared<StaticSceneObject>(); modelB->setModel(collisionModelB); sdk->registerSceneObject(modelB); sdk->registerMesh(collisionModelB->getMesh()); @@ -110,7 +110,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() scene->addSceneObject(modelB); // Setup Scene lighting - auto light = smLight::getDefaultLighting(); + auto light = Light::getDefaultLighting(); assert(light); scene->addLight(light); @@ -138,7 +138,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); } -void CollisionDetectionBVH::simulateMain(const smSimulationMainParam &/*p_param*/) +void CollisionDetectionBVH::simulateMain(const SimulationMainParam &/*p_param*/) { if ((10 > moveObj) && (moveObj > 0)) { diff --git a/examples/CollisionDetectionBVH/CollisionDetectionBVH.h b/examples/CollisionDetectionBVH/CollisionDetectionBVH.h index 7e84593b6b75592c64cfd68396b9736d94a80b6f..4231c247d24be713fbfe39b191da658a8e7921fe 100644 --- a/examples/CollisionDetectionBVH/CollisionDetectionBVH.h +++ b/examples/CollisionDetectionBVH/CollisionDetectionBVH.h @@ -41,25 +41,25 @@ #include "Collision/MeshToMeshCollision.h" #include "Rendering/Viewer.h" -class CollisionDetectionBVH: public smSimulationMain +class CollisionDetectionBVH: public SimulationMain { public: CollisionDetectionBVH(); ~CollisionDetectionBVH(){} - void simulateMain (const smSimulationMainParam &p_param) override; + void simulateMain (const SimulationMainParam &p_param) override; void run(); public: - std::shared_ptr<smSDK> sdk; - std::shared_ptr<smStaticSceneObject> modelA; - std::shared_ptr<smStaticSceneObject> modelB; - std::shared_ptr<smScene> scene; + std::shared_ptr<SDK> sdk; + std::shared_ptr<StaticSceneObject> modelA; + std::shared_ptr<StaticSceneObject> modelB; + std::shared_ptr<Scene> scene; std::shared_ptr<smViewer> viewer; std::shared_ptr<smDummySimulator> defaultSimulator; - std::shared_ptr<smSimulator> simulator; - std::shared_ptr<smMeshToMeshCollision> collisionDetection; + std::shared_ptr<Simulator> simulator; + std::shared_ptr<MeshToMeshCollision> collisionDetection; int moveObj; }; diff --git a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp index fc3a5ca576516c39438b1a946cac9b56b4a4cc02..4e0f97665180b161afc45394f71094671eb39f0a 100644 --- a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp +++ b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp @@ -36,7 +36,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() moveObj = 9; // Create the sdk - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); // Create scene scene = sdk->createScene(); @@ -48,7 +48,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() sdk->addViewer(viewer); // Intializes the spatial spatialHashinging - spatialHashing = std::make_shared<smSpatialHashCollision>(10000, 2, 2, 2); + spatialHashing = std::make_shared<SpatialHashCollision>(10000, 2, 2, 2); //Create the camera controller std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl = std::make_shared<mstk::Examples::Common::wasdCameraController>(); @@ -69,7 +69,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() smTextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); // Create collision models - std::shared_ptr<smMeshCollisionModel> collisionModelA = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<MeshCollisionModel> collisionModelA = std::make_shared<MeshCollisionModel>(); collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); collisionModelA->getMesh()->assignTexture("livertexture1"); collisionModelA->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); @@ -77,16 +77,16 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() collisionModelA->getMesh()->getRenderDetail()->lineSize = 2; collisionModelA->getMesh()->getRenderDetail()->pointSize = 5; - std::shared_ptr<smMeshCollisionModel> collisionModelB = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<MeshCollisionModel> collisionModelB = std::make_shared<MeshCollisionModel>(); collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); collisionModelB->getMesh()->assignTexture("livertexture2"); - collisionModelB->getMesh()->translate(smVec3d(2, 0, 0)); + collisionModelB->getMesh()->translate(core::Vec3d(2, 0, 0)); collisionModelB->getMesh()->assignTexture("livertexture2"); collisionModelB->getMesh()->getRenderDetail()->shadowColor.rgba[0] = 1.0; collisionModelB->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); // Create a static scene - modelA = std::make_shared<smStaticSceneObject>(); + modelA = std::make_shared<StaticSceneObject>(); modelA->setModel(collisionModelA); sdk->registerSceneObject(modelA); sdk->registerMesh(collisionModelA->getMesh()); @@ -96,7 +96,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() spatialHashing->addMesh(collisionModelA->getMesh()); // Initialize the scecond object - modelB = std::make_shared<smStaticSceneObject>(); + modelB = std::make_shared<StaticSceneObject>(); sdk->registerSceneObject(modelB); sdk->registerMesh(collisionModelB->getMesh()); @@ -107,7 +107,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() scene->addSceneObject(modelB); // Setup Scene lighting - auto light = smLight::getDefaultLighting(); + auto light = Light::getDefaultLighting(); assert(light); scene->addLight(light); @@ -123,7 +123,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() simulator->registerCollisionDetection(spatialHashing); // Create dummy collision pair - std::shared_ptr<smCollisionPair> collisionPair = std::make_shared<smCollisionPair>(); + std::shared_ptr<CollisionPair> collisionPair = std::make_shared<CollisionPair>(); collisionPair->setModels(collisionModelA,collisionModelB); simulator->addCollisionPair(collisionPair); @@ -137,7 +137,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); } -void CollisionDetectionSpatialHashing::simulateMain(const smSimulationMainParam &/*p_param*/) +void CollisionDetectionSpatialHashing::simulateMain(const SimulationMainParam &/*p_param*/) { if ((10 > moveObj) && (moveObj > 0)) { diff --git a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h index b4a69ba9dd2921e1a5c92001b46585abefbe4741..457e23c5daa669eb00febacf656f4f941a97294b 100644 --- a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h +++ b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h @@ -40,7 +40,7 @@ #include "Collision/SpatialHashCollision.h" #include "Rendering/Viewer.h" -class CollisionDetectionSpatialHashing: public smSimulationMain +class CollisionDetectionSpatialHashing: public SimulationMain { public: @@ -48,18 +48,18 @@ public: virtual ~CollisionDetectionSpatialHashing(){} void draw (); - void simulateMain (const smSimulationMainParam &p_param) override; + void simulateMain (const SimulationMainParam &p_param) override; void run(); public: - std::shared_ptr<smSDK> sdk; - std::shared_ptr<smStaticSceneObject> modelA; - std::shared_ptr<smStaticSceneObject> modelB; - std::shared_ptr<smScene> scene; + std::shared_ptr<SDK> sdk; + std::shared_ptr<StaticSceneObject> modelA; + std::shared_ptr<StaticSceneObject> modelB; + std::shared_ptr<Scene> scene; std::shared_ptr<smViewer> viewer; std::shared_ptr<smDummySimulator> defaultSimulator; - std::shared_ptr<smSimulator> simulator; - std::shared_ptr<smSpatialHashCollision> spatialHashing; + std::shared_ptr<Simulator> simulator; + std::shared_ptr<SpatialHashCollision> spatialHashing; int moveObj; }; diff --git a/examples/CollisionGrid/CollisionDetectionExample.cpp b/examples/CollisionGrid/CollisionDetectionExample.cpp index 66658629b7c5ac691912be86d6093615a699d8b8..ba7fd30680e25f8990ddc7f5c9559a3e6b5da954 100644 --- a/examples/CollisionGrid/CollisionDetectionExample.cpp +++ b/examples/CollisionGrid/CollisionDetectionExample.cpp @@ -51,10 +51,10 @@ CollisionDetectionExample::CollisionDetectionExample() spatGrid = new smSpatialGrid(); ///create the sdk - simmedtkSDK = smSDK::createSDK(); + simmedtkSDK = SDK::createSDK(); ///create scene objects - object1 = new smStaticSceneObject(); - object2 = new smStaticSceneObject(); + object1 = new StaticSceneObject(); + object2 = new StaticSceneObject(); ///create a 3D lattice for each object lat = new smLattice(); @@ -64,11 +64,11 @@ CollisionDetectionExample::CollisionDetectionExample() scene1 = simmedtkSDK->createScene(); ///dummy simulator. it translates the object - dummySim = new smDummySimulator(smSDK::getErrorLog()); + dummySim = new smDummySimulator(SDK::getErrorLog()); simmedtkSDK->getEventDispatcher()->registerEventHandler(dummySim, SIMMEDTK_EVENTTYPE_KEYBOARD); ///init texture manager and give the texture file names to be loaded - smTextureManager::init(smSDK::getErrorLog()); + smTextureManager::init(SDK::getErrorLog()); smTextureManager::loadTexture("../../resources/textures/fat9.bmp", "livertexture1"); smTextureManager::loadTexture("../../resources/textures/blood.jpg", "livertexture2"); @@ -95,9 +95,9 @@ CollisionDetectionExample::CollisionDetectionExample() spatGrid->addLattice(lat); ///the similiar routines for object2 - object2 = new smStaticSceneObject(); + object2 = new StaticSceneObject(); object2->mesh->loadMeshLegacy("../../resources/models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); - object2->mesh->translate(smVec3d(2, 0, 0)); + object2->mesh->translate(core::Vec3d(2, 0, 0)); object2->mesh->assignTexture("livertexture2"); object2getRenderDetail()->shadowColor.rgba[0] = 1.0; @@ -126,7 +126,7 @@ CollisionDetectionExample::CollisionDetectionExample() //specify the viewer global settings viewer->viewerRenderDetail = viewer->viewerRenderDetail | SIMMEDTK_VIEWERRENDER_GROUND; - viewer->camera()->setFieldOfView(SM_DEGREES2RADIANS(60)); + viewer->camera()->setFieldOfView(0.0174532925199433*(60)); viewer->camera()->setZClippingCoefficient(1000); viewer->camera()->setZNearCoefficient(0.001); viewer->list(); diff --git a/examples/CollisionGrid/CollisionDetectionExample.h b/examples/CollisionGrid/CollisionDetectionExample.h index bd68a4bd0bbed4ab234ce13e2f464f7822aba378..54d36b36815b64295c2dac2a323fcb0eee0e9d87 100644 --- a/examples/CollisionGrid/CollisionDetectionExample.h +++ b/examples/CollisionGrid/CollisionDetectionExample.h @@ -36,18 +36,17 @@ #include "Collision/SpatialGrid.h" -class CollisionDetectionExample: public smSimulationMain, public smCoreClass +class CollisionDetectionExample: public SimulationMain, public CoreClass { public: - smStaticSceneObject *object1; - smStaticSceneObject *object2; - smSDK* simmedtkSDK; - smScene *scene1; + StaticSceneObject *object1; + StaticSceneObject *object2; + SDK* simmedtkSDK; + Scene *scene1; smDummySimulator *dummySim; smViewer *viewer; - smSimulator *simulator; - smPipeRegisteration myCollInformation; + Simulator *simulator; smPhantomInterface* hapticInterface; smHapticCameraTrans *motionTrans; smSpatialGrid *spatGrid; @@ -57,7 +56,7 @@ public: CollisionDetectionExample(); void initHapticCamMotion(); - virtual void simulateMain(smSimulationMainParam p_param) + virtual void simulateMain(SimulationMainParam p_param) { } diff --git a/examples/ExampleTool/exampleTool.cpp b/examples/ExampleTool/exampleTool.cpp index d7bf13d987fc1759a2f4a7fec4f9857bc7c4bfa8..003c692c1a3bc490381193de9b99a45164aab21d 100644 --- a/examples/ExampleTool/exampleTool.cpp +++ b/examples/ExampleTool/exampleTool.cpp @@ -57,7 +57,7 @@ public: { } - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) + void handleEvent(std::shared_ptr<mstk::Event::Event> event) { s MyStylus::handleEvent(p_event); @@ -82,14 +82,14 @@ void main() MyStylus *hapticStylus; HookCautery *hapticStylus1; smPhantomInterface * hapticInterface; - smSDK* simmedtkSDK; - smScene *scene1; + SDK* simmedtkSDK; + Scene *scene1; smViewer *viewer; - smSimulator *simulator; + Simulator *simulator; smToolSimulator *toolSim; ///Initializes the lights - smLight light("light0", SIMMEDTK_LIGHT_INFINITELIGHT, SIMMEDTK_LIGHTPOS_EYE); + Light light("light0", InfiniteLight, Eye); light.lightColorDiffuse.setValue(0.8, 0.8, 0.8, 1); light.lightColorAmbient.setValue(0.4, 0.4, 0.4, 1); light.lightColorSpecular.setValue(0.9, 0.9, 0.9, 1); @@ -97,11 +97,11 @@ void main() light.lightPos.pos.setValue(0, 20.0, 20); - light.direction = smVec3d(0.0, 0.0, -1.0); + light.direction = core::Vec3d(0.0, 0.0, -1.0); light.drawEnabled = false; - smLight light2("light1", SIMMEDTK_LIGHT_SPOTLIGHT, SIMMEDTK_LIGHTPOS_WORLD); + Light light2("light1", Spotlight, World); light2.lightColorDiffuse.setValue(0.4, 0.4, 0.4, 1); light2.lightColorAmbient.setValue(0.1, 0.1, 0.1, 1); light2.lightColorSpecular.setValue(0.1, 0.1, 0.1, 1); @@ -152,7 +152,7 @@ void main() hapticStylus1getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE | SIMMEDTK_RENDER_MATERIALCOLOR); ///creates tool simulator - toolSim = new smToolSimulator(smSDK::getErrorLog()); + toolSim = new smToolSimulator(SDK::getErrorLog()); ///define the execution of the simulator. toolSim->setExecutionType(SIMMEDTK_SIMEXECUTION_ASYNCMODE); @@ -162,7 +162,7 @@ void main() hapticStylus1->attachObjectSimulator(toolSim); ///creates SDK - simmedtkSDK = smSDK::createSDK(); + simmedtkSDK = SDK::createSDK(); ///create a scene. scene1 = simmedtkSDK->createScene(); diff --git a/examples/ExampleTool2/exampleTool2.cpp b/examples/ExampleTool2/exampleTool2.cpp index 8c6e45886e1b51a4a15424fe2f1547c9717496e0..aab247f9991ed7df4814652c27f0ce10070bdbc6 100644 --- a/examples/ExampleTool2/exampleTool2.cpp +++ b/examples/ExampleTool2/exampleTool2.cpp @@ -47,24 +47,24 @@ using namespace std; void main() { smPhantomInterface * hapticInterface; - smSDK* simmedtkSDK; - smScene *scene1; + SDK* simmedtkSDK; + Scene *scene1; smViewer *viewer; - smSimulator *simulator; + Simulator *simulator; ///create lights - smLight light("Light0", SIMMEDTK_LIGHT_INFINITELIGHT, SIMMEDTK_LIGHTPOS_EYE); + Light light("Light0", InfiniteLight, Eye); light.lightColorDiffuse.setValue(0.8, 0.8, 0.8, 1); light.lightColorAmbient.setValue(0.1, 0.1, 0.1, 1); light.lightColorSpecular.setValue(0.9, 0.0, 0.0, 1); light.spotCutOffAngle = 180.0; light.lightPos.pos.setValue(0, 2.0, 0); - light.direction = smVec3d(0.0, 0.0, 1.0); + light.direction = core::Vec3d(0.0, 0.0, 1.0); light.drawEnabled = true; - smLight light2("Light1", SIMMEDTK_LIGHT_SPOTLIGHT, SIMMEDTK_LIGHTPOS_WORLD); + Light light2("Light1", Spotlight, World); light2.lightColorDiffuse.setValue(0.4, 0.4, 0.4, 1); light2.lightColorAmbient.setValue(0.1, 0.1, 0.1, 1); light2.lightColorSpecular.setValue(0.1, 0.1, 0.1, 1); @@ -77,7 +77,7 @@ void main() light2.castShadow = true; ///Creat the SDK. SDK is a singleton object. - simmedtkSDK = smSDK::createSDK(); + simmedtkSDK = SDK::createSDK(); scene1 = simmedtkSDK->createScene(); scene1->setName("Scene1"); @@ -98,7 +98,7 @@ void main() metalShader->registerShader(); ///tools are maniuplated with smToolSimulator - smToolSimulator *toolSim = new smToolSimulator(smSDK::getErrorLog()); + smToolSimulator *toolSim = new smToolSimulator(SDK::getErrorLog()); ///curved grasper requires device ID and models for pivot, upper and lower mesh curvedGrasper *curvedTool; @@ -120,8 +120,8 @@ void main() curvedTool->mesh_lowerJawgetRenderDetail()->shininess = 5.0; curvedTool->mesh_upperJawgetRenderDetail()->shininess = 5.0; curvedTool->mesh_pivotgetRenderDetail()->shininess = 5.0; - curvedTool->mesh_lowerJaw->scale(smVec3d(1.0, 1.0, 1.5)); - curvedTool->mesh_upperJaw->scale(smVec3d(1.0, 1.0, 1.5)); + curvedTool->mesh_lowerJaw->scale(core::Vec3d(1.0, 1.0, 1.5)); + curvedTool->mesh_upperJaw->scale(core::Vec3d(1.0, 1.0, 1.5)); ///Each mesh is attached with proper shader texture bindings metalShader->attachMesh(curvedTool->mesh_lowerJaw, "bump", "metal", "specTex", "specTex", "specTex"); diff --git a/examples/MultipleObjects/MultipleObjects.cpp b/examples/MultipleObjects/MultipleObjects.cpp index 637e76d398589231362c88f795b73e7e5baac695..92562f8a12d158bf5d207315a625d1852ff9ba2e 100644 --- a/examples/MultipleObjects/MultipleObjects.cpp +++ b/examples/MultipleObjects/MultipleObjects.cpp @@ -31,21 +31,21 @@ void createPBDandFEM() { - smSDK *simmedtkSDK; + SDK *simmedtkSDK; smFemSceneObject *femobj; smFemSimulator *femSim; smPBDSurfaceSceneObject *pbdObject; smPBDObjectSimulator * pbd; - smMatrix33d mat; - smSimulator *simulator; + Matrix33d mat; + Simulator *simulator; smViewer *viewer; - smScene *scene1; + Scene *scene1; ///create rotation matrix - mat.rotAroundX(SM_PI); + mat.rotAroundX(M_PI); ///SDK is singlenton class so create SDK and return SDK returns the same SDK - simmedtkSDK = smSDK::getInstance(); + simmedtkSDK = SDK::getInstance(); ///init texture manager and load the textures smTextureManager::init(simmedtkSDK->getErrorLog()); @@ -72,13 +72,13 @@ void createPBDandFEM() femobj->v_mesh->LoadTetra("../../resources/models/cylinder_Mesh.txt"); femobj->v_mesh->getSurface("../../resources/models/cylinder_smesh.txt"); femobj->v_mesh->readBC("../../resources/models/cylinder_BC.txt"); - femobj->v_mesh->scaleVolumeMesh(smVec3d(1, 1, 1)); - femobjgetRenderDetail()->colorDiffuse = smColor::colorBlue; - femobjgetRenderDetail()->colorAmbient = smColor::colorBlue; - femobjgetRenderDetail()->shadowColor = smColor(0.2, 0.2, 0.2); + femobj->v_mesh->scaleVolumeMesh(core::Vec3d(1, 1, 1)); + femobjgetRenderDetail()->colorDiffuse = Color::colorBlue; + femobjgetRenderDetail()->colorAmbient = Color::colorBlue; + femobjgetRenderDetail()->shadowColor = Color(0.2, 0.2, 0.2); femobj->v_mesh->rotate(mat); - femobj->v_mesh->scaleVolumeMesh(smVec3d(0.5, 0.5, 1.0)); - femobj->v_mesh->translateVolumeMesh(smVec3d(20, 15, 20)); + femobj->v_mesh->scaleVolumeMesh(core::Vec3d(0.5, 0.5, 1.0)); + femobj->v_mesh->translateVolumeMesh(core::Vec3d(20, 15, 20)); femobjgetRenderDetail()->renderType = (SIMMEDTK_RENDER_MATERIALCOLOR | SIMMEDTK_RENDER_SHADOWS | SIMMEDTK_RENDER_FACES); femobjgetRenderDetail()->lineSize = 1.0; femobjgetRenderDetail()->pointSize = 5; @@ -88,13 +88,13 @@ void createPBDandFEM() ///create a position based dynamics(PBD) surface object pbdObject = new smPBDSurfaceSceneObject(); - pbdObjectgetRenderDetail()->colorDiffuse = smColor::colorWhite; - pbdObjectgetRenderDetail()->colorAmbient = smColor::colorWhite; + pbdObjectgetRenderDetail()->colorDiffuse = Color::colorWhite; + pbdObjectgetRenderDetail()->colorAmbient = Color::colorWhite; pbdObject->mesh->loadMeshLegacy("../../resources/models/clothtextured.3ds", SM_FILETYPE_3DS); //pbdObject->mesh->rotate(mat); - pbdObject->mesh->scale(smVec3d(2.3, 0.5, 2)); - pbdObject->mesh->translate(smVec3d(11, 25, 0)); + pbdObject->mesh->scale(core::Vec3d(2.3, 0.5, 2)); + pbdObject->mesh->translate(core::Vec3d(11, 25, 0)); pbdObject->mesh->assignTexture("clothtexture"); pbdObjectgetRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE | SIMMEDTK_RENDER_MATERIALCOLOR); pbdObject->initMeshStructure(); @@ -104,7 +104,7 @@ void createPBDandFEM() pbdObject->findFixedCorners(); ///can use sphere shape to fix the vertices - ///pbdObject->findFixedMassWrtSphere(smVec3d(11,23,0),5); + ///pbdObject->findFixedMassWrtSphere(core::Vec3d(11,23,0),5); ///attach object to the simulator pbdObject->attachObjectSimulator(pbd); diff --git a/examples/common/KeyPressSDKShutdown.cpp b/examples/common/KeyPressSDKShutdown.cpp index c791f85dd7a9b6ae4ec633fffd6a2da9a5439489..6216d7053d361d305f726e2993ef4671d1ed41fd 100644 --- a/examples/common/KeyPressSDKShutdown.cpp +++ b/examples/common/KeyPressSDKShutdown.cpp @@ -34,14 +34,14 @@ KeyPressSDKShutdown::KeyPressSDKShutdown() : key(mstk::Event::smKey::Escape) { } -void KeyPressSDKShutdown::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void KeyPressSDKShutdown::handleEvent(std::shared_ptr<mstk::Event::Event> event) { auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); if(keyboardEvent->getPressed()) { if (keyboardEvent->getKeyPressed() == this->key) { - smSDK::getInstance()->shutDown(); + SDK::getInstance()->shutDown(); } } } diff --git a/examples/common/KeyPressSDKShutdown.h b/examples/common/KeyPressSDKShutdown.h index f17b316e86b8ace394e2c97a0e12a775d01cfd7c..b477b21a925ade51b4cbf4547d38954f71a1d255 100644 --- a/examples/common/KeyPressSDKShutdown.h +++ b/examples/common/KeyPressSDKShutdown.h @@ -32,7 +32,7 @@ namespace Examples { namespace Common { /// \brief Will shutdown the SDK when the a specified key is pressed -class KeyPressSDKShutdown : public smCoreClass +class KeyPressSDKShutdown : public CoreClass { public: /// \brief Default constructor @@ -40,10 +40,10 @@ public: /// \detail Default key is escape KeyPressSDKShutdown(); - /// \brief Event handling function from smCoreClass + /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief Set the keyboard key to listen for /// diff --git a/examples/common/hapticController.cpp b/examples/common/hapticController.cpp index d0c27a73b0e7ad4a2383c057b723a369afa74459..410b2eb255edf30cb6927998e59ccbf1dc62591b 100644 --- a/examples/common/hapticController.cpp +++ b/examples/common/hapticController.cpp @@ -28,7 +28,7 @@ using namespace mstk::Examples::Common; -void hapticController::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void hapticController::handleEvent(std::shared_ptr<mstk::Event::Event> event) { auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(event); if(hapticEvent != nullptr && hapticEvent->getButtonState(0)) diff --git a/examples/common/hapticController.h b/examples/common/hapticController.h index 28a99af234650872a2f4070d073bbc15e0a725fb..6b36bc8820f0c9b5211448d06be9c932da051c60 100644 --- a/examples/common/hapticController.h +++ b/examples/common/hapticController.h @@ -33,7 +33,7 @@ namespace Examples { namespace Common { /// \brief Will shutdown the SDK when the a specified key is pressed -class hapticController : public smCoreClass +class hapticController : public CoreClass { public: /// \brief Default constructor @@ -41,10 +41,10 @@ public: /// \detail Default key is escape hapticController(){} - /// \brief Event handling function from smCoreClass + /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief Set the scene objects which gets affected by this haptic event /// diff --git a/examples/common/pzrMouseCameraController.cpp b/examples/common/pzrMouseCameraController.cpp index 37c86de94bacbea1043ffab59a91c2c77461e1d1..915c5f6155a88ea47df7f546a947d39633d379db 100644 --- a/examples/common/pzrMouseCameraController.cpp +++ b/examples/common/pzrMouseCameraController.cpp @@ -25,7 +25,6 @@ #include "Event/MouseButtonEvent.h" #include "Event/MouseMoveEvent.h" -#include "Core/Math.h" namespace mstk { namespace Examples { @@ -54,7 +53,7 @@ void pzrMouseCameraController::setStepSize(float size) moveDistance = size; } -void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event) { assert(nullptr != event); assert(nullptr != camera); @@ -83,8 +82,8 @@ void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::smEvent> auto mouseMoveEvent = std::dynamic_pointer_cast<Event::smMouseMoveEvent>(event); if(mouseMoveEvent != nullptr) { - smVec2f diff; - smVec2f newCoords; + core::Vec2f diff; + core::Vec2f newCoords; newCoords = mouseMoveEvent->getWindowCoord().cast<float>(); diff = coords - newCoords; @@ -92,15 +91,16 @@ void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::smEvent> if(lmbPressed && rmbPressed) { //pan x and y - this->camera->pan(smVec3f(diff(0), diff(1), 0) * moveDistance); + this->camera->pan(core::Vec3f(diff(0), diff(1), 0) * moveDistance); //reset coords for next mouse move event coords = newCoords; } else if(lmbPressed) { //rotate - this->camera->rotateFocusX(SM_DEGREES2RADIANS(moveDistance * diff(1))); - this->camera->rotateFocusY(SM_DEGREES2RADIANS(moveDistance * diff(0))); + // In radians + this->camera->rotateFocusX(0.0174532925199433*(moveDistance * diff(1))); + this->camera->rotateFocusY(0.0174532925199433*(moveDistance * diff(0))); //reset coords for next mouse move event coords = newCoords; } diff --git a/examples/common/pzrMouseCameraController.h b/examples/common/pzrMouseCameraController.h index 040019138f49476c27fb6bc1ad6f828b8d82c8e3..7ccae54e03c3efd395d3bf32cc87862cb4779c81 100644 --- a/examples/common/pzrMouseCameraController.h +++ b/examples/common/pzrMouseCameraController.h @@ -38,7 +38,7 @@ namespace Common { /// Shift + W = up, Shift + S = down /// To use this class, it must be registered with the event system. /// -class pzrMouseCameraController : public smCoreClass +class pzrMouseCameraController : public CoreClass { public: /// \brief Default constructor @@ -50,10 +50,10 @@ public: /// \param cam Pointer to camera to be controlled pzrMouseCameraController(std::shared_ptr<smCamera> cam); - /// \brief Event handling function from smCoreClass + /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief Set the camera to be controlled /// @@ -70,7 +70,7 @@ private: float moveDistance; ///< Modifier to the movement distance for operations bool lmbPressed; ///< Left mouse button (un)pressed bool rmbPressed; ///< Right mouse button (un)pressed - smVec2f coords; ///< Record of last window coords manipulated + core::Vec2f coords; ///< Record of last window coords manipulated }; }//Common diff --git a/examples/common/wasdCameraController.cpp b/examples/common/wasdCameraController.cpp index 3c4b011be021ae6bb30bd444594a154c3f296082..67e3fa2a5a831e3157d18323598045bcdbd522c6 100644 --- a/examples/common/wasdCameraController.cpp +++ b/examples/common/wasdCameraController.cpp @@ -50,7 +50,7 @@ void wasdCameraController::setStepSize(float size) moveDistance = size; } -void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event) { assert(nullptr != event); assert(nullptr != camera); @@ -58,7 +58,7 @@ void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::smEvent> eve auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); if(keyboardEvent->getPressed()) { - smVec3f dispVec = smVec3f::Zero(); //Vector to store displacement of camera + core::Vec3f dispVec = core::Vec3f::Zero(); //Vector to store displacement of camera switch(keyboardEvent->getKeyPressed()) { case mstk::Event::smKey::W: diff --git a/examples/common/wasdCameraController.h b/examples/common/wasdCameraController.h index 2843bf1859146466403a2171d45e62cbf16cfcf7..06e35a68a6eea1a60cd3e513047dc70551e2d4ba 100644 --- a/examples/common/wasdCameraController.h +++ b/examples/common/wasdCameraController.h @@ -38,7 +38,7 @@ namespace Common { /// Shift + W = up, Shift + S = down /// To use this class, it must be registered with the event system. /// -class wasdCameraController : public smCoreClass +class wasdCameraController : public CoreClass { public: /// \brief Default constructor @@ -50,10 +50,10 @@ public: /// \param cam Pointer to camera to be controlled wasdCameraController(std::shared_ptr<smCamera> cam); - /// \brief Event handling function from smCoreClass + /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief Set the camera to be controlled /// diff --git a/examples/renderCube/main.cpp b/examples/renderCube/main.cpp index 569117ac499aa69efa3bc5a61d59b11215bdaf25..9d0ab129cf5bd7977d5b6f1c1c1dd0a9526f22ca 100644 --- a/examples/renderCube/main.cpp +++ b/examples/renderCube/main.cpp @@ -35,17 +35,17 @@ int main() { SIMMEDTK_REGISTER_RENDER_DELEGATES(); - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smViewer> viewer; - std::shared_ptr<smScene> scene1; - std::shared_ptr<smLight> light; + std::shared_ptr<Scene> scene1; + std::shared_ptr<Light> light; std::shared_ptr<smCamera> sceneCamera; - std::shared_ptr<smStaticSceneObject> cube; + std::shared_ptr<StaticSceneObject> cube; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; std::shared_ptr<mstk::Examples::Common::pzrMouseCameraController> pzrCamCtl; //Create an instance of the SimMedTK framework/SDK - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); //Create a new scene to work in scene1 = sdk->createScene(); @@ -62,10 +62,10 @@ int main() auto cubeModel = std::make_shared<smMeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); - auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); cubeModel->setRenderDetail(renderDetail); - cube = std::make_shared<smStaticSceneObject>(); + cube = std::make_shared<StaticSceneObject>(); cube->setModel(cubeModel); //Add the cube to the scene to be rendered @@ -84,7 +84,7 @@ int main() //viewer->viewerRenderDetail |= SIMMEDTK_VIEWERRENDER_FULLSCREEN; // Setup Scene lighting - light = smLight::getDefaultLighting(); + light = Light::getDefaultLighting(); assert(light); scene1->addLight(light); diff --git a/examples/renderCubeOculus/main.cpp b/examples/renderCubeOculus/main.cpp index d027ce70111beac8834c1e5652aec3724287ffbe..69eb6a785dc17d95aefdf22e4b6cf00787485664 100644 --- a/examples/renderCubeOculus/main.cpp +++ b/examples/renderCubeOculus/main.cpp @@ -33,17 +33,17 @@ int main() { - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smOculusViewer> viewer; - std::shared_ptr<smScene> scene1; - std::shared_ptr<smLight> light; + std::shared_ptr<Scene> scene1; + std::shared_ptr<Light> light; std::shared_ptr<smCamera> sceneCamera; - std::shared_ptr<smStaticSceneObject> cube; + std::shared_ptr<StaticSceneObject> cube; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; //Create an instance of the SimMedTK framework/SDK - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); //Create a new scene to work in scene1 = sdk->createScene(); @@ -59,10 +59,10 @@ int main() auto cubeModel = std::make_shared<smMeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); - auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); cubeModel->setRenderDetail(renderDetail); - cube = std::make_shared<smStaticSceneObject>(); + cube = std::make_shared<StaticSceneObject>(); cube->setModel(cubeModel); //Add the cube to the scene to be rendered @@ -81,7 +81,7 @@ int main() viewer->viewerRenderDetail |= SIMMEDTK_VIEWERRENDER_FULLSCREEN; // Setup Scene lighting - light = smLight::getDefaultLighting(); + light = Light::getDefaultLighting(); assert(light); scene1->addLight(light); diff --git a/examples/renderCubeToTexture/main.cpp b/examples/renderCubeToTexture/main.cpp index 75ee8b83349e4ca15741c60ca2f38f955fb78270..d206d7132eb93d36f4114bb8e2d14326c212c29f 100644 --- a/examples/renderCubeToTexture/main.cpp +++ b/examples/renderCubeToTexture/main.cpp @@ -32,17 +32,17 @@ int main() { - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smViewer> viewer; - std::shared_ptr<smScene> scene1, scene2; - std::shared_ptr<smLight> light1, light2; + std::shared_ptr<Scene> scene1, scene2; + std::shared_ptr<Light> light1, light2; std::shared_ptr<smCamera> sceneCamera1, sceneCamera2; - std::shared_ptr<smStaticSceneObject> cube, square; + std::shared_ptr<StaticSceneObject> cube, square; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; //Create an instance of the SimMedTK framework/SDK - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); //Create the scenes scene1 = sdk->createScene(); //internal scene containing cube @@ -59,10 +59,10 @@ int main() auto cubeModel = std::make_shared<smMeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); - auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); cubeModel->setRenderDetail(renderDetail); - cube = std::make_shared<smStaticSceneObject>(); + cube = std::make_shared<StaticSceneObject>(); cube->setModel(cubeModel); //Add the cube to the scene to be rendered @@ -76,10 +76,10 @@ int main() std::shared_ptr<smMeshModel> squareModel = std::make_shared<smMeshModel>(); squareModel->load("models/square.obj", SM_FILETYPE_OBJ); squareModel->getMesh()->assignTexture("colorTex1"); - renderDetail= std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + renderDetail= std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); squareModel->setRenderDetail(renderDetail); - square = std::make_shared<smStaticSceneObject>(); + square = std::make_shared<StaticSceneObject>(); square->setModel(squareModel); //Setup an FBO for rendering in the viewer. @@ -106,13 +106,13 @@ int main() //viewer->viewerRenderDetail |= SIMMEDTK_VIEWERRENDER_FULLSCREEN; // Setup Scene lighting - light1 = smLight::getDefaultLighting(); + light1 = Light::getDefaultLighting(); assert(light1); scene1->addLight(light1); - light2 = smLight::getDefaultLighting(); + light2 = Light::getDefaultLighting(); assert(light2); - light2->lightPos.setPosition(smVec3d(0.0, 0.0, 5.0)); + light2->lightPos.setPosition(core::Vec3d(0.0, 0.0, 5.0)); scene2->addLight(light2); // Camera setup diff --git a/examples/renderCubeToTextureOculus/main.cpp b/examples/renderCubeToTextureOculus/main.cpp index 2e19b0ed55da6cc1f77801ca24a454c4d2061dd8..6d1036039d887cac1a7f4e273e3e998d7d2f5885 100644 --- a/examples/renderCubeToTextureOculus/main.cpp +++ b/examples/renderCubeToTextureOculus/main.cpp @@ -33,17 +33,17 @@ int main() { - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smOculusViewer> viewer; - std::shared_ptr<smScene> scene1, scene2; - std::shared_ptr<smLight> light1, light2; + std::shared_ptr<Scene> scene1, scene2; + std::shared_ptr<Light> light1, light2; std::shared_ptr<smCamera> sceneCamera1, sceneCamera2; - std::shared_ptr<smStaticSceneObject> cube, square; + std::shared_ptr<StaticSceneObject> cube, square; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; //Create an instance of the SimMedTK framework/SDK - sdk = smSDK::getInstance(); + sdk = SDK::getInstance(); //Create the scenes scene1 = sdk->createScene(); //internal scene containing cube @@ -60,10 +60,10 @@ int main() auto cubeModel = std::make_shared<smMeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); - auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); cubeModel->setRenderDetail(renderDetail); - cube = std::make_shared<smStaticSceneObject>(); + cube = std::make_shared<StaticSceneObject>(); cube->setModel(cubeModel); //Add the cube to the scene to be rendered @@ -77,10 +77,10 @@ int main() std::shared_ptr<smMeshModel> squareModel = std::make_shared<smMeshModel>(); squareModel->load("models/square.obj", SM_FILETYPE_OBJ); squareModel->getMesh()->assignTexture("colorTex1"); - renderDetail= std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); + renderDetail= std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); squareModel->setRenderDetail(renderDetail); - square = std::make_shared<smStaticSceneObject>(); + square = std::make_shared<StaticSceneObject>(); square->setModel(squareModel); //Setup an FBO for rendering in the viewer. @@ -107,13 +107,13 @@ int main() viewer->viewerRenderDetail |= SIMMEDTK_VIEWERRENDER_FULLSCREEN; // Setup Scene lighting - light1 = smLight::getDefaultLighting(); + light1 = Light::getDefaultLighting(); assert(light1); scene1->addLight(light1); - light2 = smLight::getDefaultLighting(); + light2 = Light::getDefaultLighting(); assert(light2); - light2->lightPos.setPosition(smVec3d(0.0, 0.0, 5.0)); + light2->lightPos.setPosition(core::Vec3d(0.0, 0.0, 5.0)); scene2->addLight(light2); // Camera setup diff --git a/examples/vegaFem/main.cpp b/examples/vegaFem/main.cpp index cf90afe3c37941779679515b3e71638c87d9a483..ac5213821caf25b89f4f65f9f7b1658089a0493e 100644 --- a/examples/vegaFem/main.cpp +++ b/examples/vegaFem/main.cpp @@ -54,28 +54,28 @@ int main() { SIMMEDTK_REGISTER_RENDER_DELEGATES(); - std::shared_ptr<smSDK> sdk; + std::shared_ptr<SDK> sdk; std::shared_ptr<smVegaFemSceneObject> femObject; - std::shared_ptr<smStaticSceneObject> staticObject; + std::shared_ptr<StaticSceneObject> staticObject; std::shared_ptr<smVegaFemSimulator> femSimulator; std::shared_ptr<smDummySimulator> staticSimulator; - std::shared_ptr<smPlaneCollisionModel> plane; + std::shared_ptr<PlaneCollisionModel> plane; std::shared_ptr<smViewer> viewer; - std::shared_ptr<smScene> scene; - std::shared_ptr<smLight> light; + std::shared_ptr<Scene> scene; + std::shared_ptr<Light> light; std::shared_ptr<smCamera> sceneCamera; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; std::shared_ptr<mstk::Examples::Common::pzrMouseCameraController> pzrCamCtl; //std::shared_ptr<mstk::Examples::Common::hapticController> hapticCtl; - smMatrix33d mat; + Matrix33d mat; //------------------------------------------------------- // 1. Create an instance of the SoFMIS framework/SDK // 2. Create viewer // 3. Create default scene (scene 0) //------------------------------------------------------- - sdk = smSDK::createStandardSDK(); + sdk = SDK::createStandardSDK(); //------------------------------------------------------- // Create scene actor 1: fem scene object + fem simulator @@ -89,13 +89,13 @@ int main() sdk->getErrorLog(), "asianDragon/asianDragon.config"); - auto femObjRenderDetail = std::make_shared<smRenderDetail>( + auto femObjRenderDetail = std::make_shared<RenderDetail>( //SIMMEDTK_RENDER_WIREFRAME //| SIMMEDTK_RENDER_VERTICES SIMMEDTK_RENDER_FACES ); femObjRenderDetail->setPointSize(4.0); - smColor maroon(165.0f / 255, 42.0f / 255, 42.0f / 255, 1.0); + Color maroon(165.0f / 255, 42.0f / 255, 42.0f / 255, 1.0); femObjRenderDetail->setVertexColor(maroon); femObjRenderDetail->setNormalLength(0.02); @@ -114,10 +114,10 @@ int main() staticSimulator = std::make_shared<smDummySimulator>(sdk->getErrorLog()); // create a static plane scene object of given normal and position - staticObject = std::make_shared<smStaticSceneObject>(); + staticObject = std::make_shared<StaticSceneObject>(); - plane = std::make_shared<smPlaneCollisionModel>(smVec3d(0.0, -3.0, 0.0), - smVec3d(0.0, 1.0, 0.0)); + plane = std::make_shared<PlaneCollisionModel>(core::Vec3d(0.0, -3.0, 0.0), + core::Vec3d(0.0, 1.0, 0.0)); staticObject->setModel(plane); sdk->addSceneActor(staticObject, staticSimulator); @@ -133,24 +133,24 @@ int main() //------------------------------------------------------- // Enable collision between scene actors 1 and 2 //------------------------------------------------------- - auto meshModel = std::make_shared<smMeshCollisionModel>(); + auto meshModel = std::make_shared<MeshCollisionModel>(); meshModel->setMesh(femObject->getPrimarySurfaceMesh()); - auto planeMeshCollisionPairs = std::make_shared<smCollisionPair>(); + auto planeMeshCollisionPairs = std::make_shared<CollisionPair>(); planeMeshCollisionPairs->setModels(meshModel, plane); sdkSimulator->addCollisionPair(planeMeshCollisionPairs); - auto planeToMeshCollisionDetection = std::make_shared<smPlaneToMeshCollision>(); + auto planeToMeshCollisionDetection = std::make_shared<PlaneToMeshCollision>(); sdkSimulator->registerCollisionDetection(planeToMeshCollisionDetection); //------------------------------------------------------- // Enable contact handling between scene actors 1 and 2 //------------------------------------------------------- - auto planeToMeshContact = std::make_shared<smPenaltyContactFemToStatic>(false); + auto planeToMeshContact = std::make_shared<PenaltyContactFemToStatic>(false); planeToMeshContact->setCollisionPairs(planeMeshCollisionPairs); @@ -174,7 +174,7 @@ int main() viewer->registerScene(scene, SMRENDERTARGET_SCREEN, "Collision pipeline demo"); // Setup Scene lighting - light = smLight::getDefaultLighting(); + light = Light::getDefaultLighting(); scene->addLight(light); // Camera setup diff --git a/src/Collision/CollisionMoller.cpp b/src/Collision/CollisionMoller.cpp index 2fdd8b5ae7a162855b0cd154bba166831f0c9dcf..aab4cc1ebbd6564ce77b67a2622bf3cf996ffd06 100644 --- a/src/Collision/CollisionMoller.cpp +++ b/src/Collision/CollisionMoller.cpp @@ -28,22 +28,22 @@ #include "External/moller.h" #include "External/moller2.h" -bool smCollisionMoller::tri2tri( smVec3d &tri1Point1, - smVec3d &tri1Point2, - smVec3d &tri1Point3, - smVec3d &tri2Point1, - smVec3d &tri2Point2, - smVec3d &tri2Point3, +bool CollisionMoller::tri2tri( core::Vec3d &tri1Point1, + core::Vec3d &tri1Point2, + core::Vec3d &tri1Point3, + core::Vec3d &tri2Point1, + core::Vec3d &tri2Point2, + core::Vec3d &tri2Point3, double &depth, - smVec3d &contactPoint, - smVec3d &normal) + core::Vec3d &contactPoint, + core::Vec3d &normal) { int coplanar; - smVec3d intersectionPoint2; + core::Vec3d intersectionPoint2; short tri1SinglePointIndex; short tri2SinglePointIndex; - smVec3d projPoint1; - smVec3d projPoint2; + core::Vec3d projPoint1; + core::Vec3d projPoint2; if ( tri_tri_intersect_with_isectline_penetrationDepth( tri1Point1.data(), tri1Point2.data(), tri1Point3.data(), @@ -66,22 +66,22 @@ bool smCollisionMoller::tri2tri( smVec3d &tri1Point1, return false; } -bool smCollisionMoller::tri2tri( smVec3d &p_tri1Point1, - smVec3d &p_tri1Point2, - smVec3d &p_tri1Point3, - smVec3d &p_tri2Point1, - smVec3d &p_tri2Point2, - smVec3d &p_tri2Point3, +bool CollisionMoller::tri2tri( core::Vec3d &p_tri1Point1, + core::Vec3d &p_tri1Point2, + core::Vec3d &p_tri1Point3, + core::Vec3d &p_tri2Point1, + core::Vec3d &p_tri2Point2, + core::Vec3d &p_tri2Point3, int &coplanar, - smVec3d &p_intersectionPoint1, - smVec3d &p_intersectionPoint2, + core::Vec3d &p_intersectionPoint1, + core::Vec3d &p_intersectionPoint2, short &p_tri1SinglePointIndex, short &p_tri2SinglePointIndex, - smVec3d &p_projPoint1, - smVec3d &p_projPoint2 ) + core::Vec3d &p_projPoint1, + core::Vec3d &p_projPoint2 ) { double depth; - smVec3d normal; + core::Vec3d normal; if ( tri_tri_intersect_with_isectline_penetrationDepth( p_tri1Point1.data(), p_tri1Point2.data(), p_tri1Point3.data(), @@ -101,14 +101,14 @@ bool smCollisionMoller::tri2tri( smVec3d &p_tri1Point1, return false; } -bool smCollisionMoller::tri2tri( smVec3d &p_tri1Point1, smVec3d &p_tri1Point2, smVec3d &p_tri1Point3, smVec3d &p_tri2Point1, smVec3d &p_tri2Point2, smVec3d &p_tri2Point3 ) +bool CollisionMoller::tri2tri( core::Vec3d &p_tri1Point1, core::Vec3d &p_tri1Point2, core::Vec3d &p_tri1Point3, core::Vec3d &p_tri2Point1, core::Vec3d &p_tri2Point2, core::Vec3d &p_tri2Point3 ) { return ( tri_tri_intersect( p_tri1Point1.data(), p_tri1Point2.data(), p_tri1Point3.data(), p_tri2Point1.data(), p_tri2Point2.data(), p_tri2Point3.data() ) == 1 ? true : false ); } -bool smCollisionMoller::checkOverlapAABBAABB( smAABB &aabbA, smAABB &aabbB, smAABB &result ) +bool CollisionMoller::checkOverlapAABBAABB( AABB &aabbA, AABB &aabbB, AABB &result ) { if ( aabbA.aabbMin[0] > aabbB.aabbMax[0] || @@ -133,11 +133,11 @@ bool smCollisionMoller::checkOverlapAABBAABB( smAABB &aabbA, smAABB &aabbB, smAA } } -bool smCollisionMoller::checkOverlapAABBAABB( const smAABB &aabbA, const smAABB &aabbB ) +bool CollisionMoller::checkOverlapAABBAABB( const AABB &aabbA, const AABB &aabbB ) { - const smVec3d &min = aabbA.getMin(); - const smVec3d &max = aabbA.getMax(); + const core::Vec3d &min = aabbA.getMin(); + const core::Vec3d &max = aabbA.getMax(); if ( min[0] > aabbB.aabbMax[0] || max[0] < aabbB.aabbMin[0] || @@ -154,7 +154,7 @@ bool smCollisionMoller::checkOverlapAABBAABB( const smAABB &aabbA, const smAABB } } -bool smCollisionMoller::checkOverlapAABBAABB( smAABB &aabbA, smVec3d &p_vertex ) +bool CollisionMoller::checkOverlapAABBAABB( AABB &aabbA, core::Vec3d &p_vertex ) { if ( aabbA.aabbMin[0] <= p_vertex[0] && aabbA.aabbMax[0] >= p_vertex[0] && @@ -169,7 +169,7 @@ bool smCollisionMoller::checkOverlapAABBAABB( smAABB &aabbA, smVec3d &p_vertex ) } } -bool smCollisionMoller::checkAABBPoint( const smAABB &p_aabb, const smVec3d &p_v ) +bool CollisionMoller::checkAABBPoint( const AABB &p_aabb, const core::Vec3d &p_v ) { if ( p_v[0] >= p_aabb.aabbMin[0] && p_v[1] >= p_aabb.aabbMin[1] && @@ -186,19 +186,19 @@ bool smCollisionMoller::checkAABBPoint( const smAABB &p_aabb, const smVec3d &p_v } } -bool smCollisionMoller::checkLineTri( smVec3d &p_linePoint1, smVec3d &p_linePoint2, smVec3d &p_tri1Point1, smVec3d &p_tri1Point2, smVec3d &p_tri1Point3, smVec3d &p_interSection ) +bool CollisionMoller::checkLineTri( core::Vec3d &p_linePoint1, core::Vec3d &p_linePoint2, core::Vec3d &p_tri1Point1, core::Vec3d &p_tri1Point2, core::Vec3d &p_tri1Point3, core::Vec3d &p_interSection ) { //First find that ray intersect the polygon or not int i1, i2; - smVec3d U, V; + core::Vec3d U, V; double plane[4], P[3], u[3], v[3], alpha, beta; //Now find the Normal vector U = p_tri1Point2 - p_tri1Point1; V = p_tri1Point3 - p_tri1Point1; - smVec3d cProd; + core::Vec3d cProd; cProd = U.cross( V ); cProd.normalize(); @@ -209,7 +209,7 @@ bool smCollisionMoller::checkLineTri( smVec3d &p_linePoint1, smVec3d &p_linePoin //Now we got the plane equation and we can test whether our ray intersect or not double d1, d2, d, t; - smVec3d dir; + core::Vec3d dir; d1 = p_linePoint1.dot( cProd ) + plane[3]; d2 = p_linePoint2.dot( cProd ) + plane[3]; @@ -283,12 +283,12 @@ bool smCollisionMoller::checkLineTri( smVec3d &p_linePoint1, smVec3d &p_linePoin return false; } -bool smCollisionMoller::checkAABBTriangle( smAABB &p_aabb, smVec3d &v1, smVec3d &v2, smVec3d &v3 ) +bool CollisionMoller::checkAABBTriangle( AABB &p_aabb, core::Vec3d &v1, core::Vec3d &v2, core::Vec3d &v3 ) { - smVec3d boxhalfsize; - smVec3d boxCenter; - smMatrix33d triverts; + core::Vec3d boxhalfsize; + core::Vec3d boxCenter; + Matrix33d triverts; triverts << v1[0],v1[1],v1[2], v2[0],v2[1],v2[2], v3[0],v3[1],v3[2]; diff --git a/src/Collision/CollisionMoller.h b/src/Collision/CollisionMoller.h index 0f7ead014204f0e94442e83435f4eb8850383905..b194dcb154f908acbed39c54979df408cf72e730 100644 --- a/src/Collision/CollisionMoller.h +++ b/src/Collision/CollisionMoller.h @@ -30,63 +30,63 @@ #include "Core/Vector.h" /// \brief Collision utililites -class smCollisionMoller +class CollisionMoller { public: /// \brief triangle and triangle collision retursn intersection and projection points - static bool tri2tri(smVec3d &p_tri1Point1, - smVec3d &p_tri1Point2, - smVec3d &p_tri1Point3, - smVec3d &p_tri2Point1, - smVec3d &p_tri2Point2, - smVec3d &p_tri2Point3, + static bool tri2tri(core::Vec3d &p_tri1Point1, + core::Vec3d &p_tri1Point2, + core::Vec3d &p_tri1Point3, + core::Vec3d &p_tri2Point1, + core::Vec3d &p_tri2Point2, + core::Vec3d &p_tri2Point3, int &coplanar, - smVec3d &p_intersectionPoint1, - smVec3d &p_intersectionPoint2, + core::Vec3d &p_intersectionPoint1, + core::Vec3d &p_intersectionPoint2, short &p_tri1SinglePointIndex, short &p_tri2SinglePointIndex, - smVec3d &p_projPoint1, - smVec3d &p_projPoint2); + core::Vec3d &p_projPoint1, + core::Vec3d &p_projPoint2); - static bool tri2tri( smVec3d &p_tri1Point1, - smVec3d &p_tri1Point2, - smVec3d &p_tri1Point3, - smVec3d &p_tri2Point1, - smVec3d &p_tri2Point2, - smVec3d &p_tri2Point3, + static bool tri2tri( core::Vec3d &p_tri1Point1, + core::Vec3d &p_tri1Point2, + core::Vec3d &p_tri1Point3, + core::Vec3d &p_tri2Point1, + core::Vec3d &p_tri2Point2, + core::Vec3d &p_tri2Point3, double &depth, - smVec3d &contactPoint, - smVec3d &normal); + core::Vec3d &contactPoint, + core::Vec3d &normal); /// \brief checks if the two triangles intersect - static bool tri2tri(smVec3d &p_tri1Point1, - smVec3d &p_tri1Point2, - smVec3d &p_tri1Point3, - smVec3d &p_tri2Point1, - smVec3d &p_tri2Point2, - smVec3d &p_tri2Point3); + static bool tri2tri(core::Vec3d &p_tri1Point1, + core::Vec3d &p_tri1Point2, + core::Vec3d &p_tri1Point3, + core::Vec3d &p_tri2Point1, + core::Vec3d &p_tri2Point2, + core::Vec3d &p_tri2Point3); /// \brief check if the two AABB overlap returns encapsulating AABB of two - static bool checkOverlapAABBAABB(smAABB &aabbA, smAABB &aabbB, smAABB &result); + static bool checkOverlapAABBAABB(AABB &aabbA, AABB &aabbB, AABB &result); /// \brief check the AABBs overlap. returns true if they intersect - static bool checkOverlapAABBAABB(const smAABB &aabbA, const smAABB &aabbB); + static bool checkOverlapAABBAABB(const AABB &aabbA, const AABB &aabbB); /// \brief check if the point p_vertex is inside the AABB - static inline bool checkOverlapAABBAABB(smAABB &aabbA, smVec3d &p_vertex); + static inline bool checkOverlapAABBAABB(AABB &aabbA, core::Vec3d &p_vertex); /// \brief checks if the line intersects the tirangle. returns if it is true. the intersection is returned in p_interSection - static bool checkLineTri(smVec3d &p_linePoint1, - smVec3d &p_linePoint2, - smVec3d &p_tri1Point1, - smVec3d &p_tri1Point2, - smVec3d &p_tri1Point3, - smVec3d &p_interSection); + static bool checkLineTri(core::Vec3d &p_linePoint1, + core::Vec3d &p_linePoint2, + core::Vec3d &p_tri1Point1, + core::Vec3d &p_tri1Point2, + core::Vec3d &p_tri1Point3, + core::Vec3d &p_interSection); /// \brief checks if the triangles points are within the AABB - static bool checkAABBTriangle(smAABB &p_aabb, smVec3d &v1, smVec3d &v2, smVec3d &v3); + static bool checkAABBTriangle(AABB &p_aabb, core::Vec3d &v1, core::Vec3d &v2, core::Vec3d &v3); - static bool checkAABBPoint(const smAABB &p_aabb, const smVec3d &p_v); + static bool checkAABBPoint(const AABB &p_aabb, const core::Vec3d &p_v); }; #endif // SM_COLLISIONMOLLER_H diff --git a/src/Collision/CollisionUtilities.cpp b/src/Collision/CollisionUtilities.cpp index 572da30cb85ac98197b24ce701fef110cb6bd69d..051960723b90899f010eeb1ca9bea15b4ab5ae1c 100644 --- a/src/Collision/CollisionUtilities.cpp +++ b/src/Collision/CollisionUtilities.cpp @@ -23,11 +23,11 @@ #include "CollisionUtilities.h" -int intersect3D_RayTriangleWithBarycentric( smVec3d P0, smVec3d P1, smVec3d V0, smVec3d V1, smVec3d V2, smVec3d *I, float &p_baryU, float &p_baryV, float &p_baryW, bool considerFrontFaceOnly ) +int intersect3D_RayTriangleWithBarycentric( core::Vec3d P0, core::Vec3d P1, core::Vec3d V0, core::Vec3d V1, core::Vec3d V2, core::Vec3d *I, float &p_baryU, float &p_baryV, float &p_baryW, bool considerFrontFaceOnly ) { - smVec3d u, v, n; // triangle vectors - smVec3d dir, w0, w; // ray vectors + core::Vec3d u, v, n; // triangle vectors + core::Vec3d dir, w0, w; // ray vectors float r, a, b; // params to calc ray-plane intersect // get triangle edge vectors and plane normal diff --git a/src/Collision/CollisionUtilities.h b/src/Collision/CollisionUtilities.h index bdb4ace124deb1cde374c8ee8e94e2f38d9b5bb8..aa1b05ed0b0a60bb98026bc095955b8fc67bc725 100644 --- a/src/Collision/CollisionUtilities.h +++ b/src/Collision/CollisionUtilities.h @@ -28,8 +28,8 @@ #include "Core/Vector.h" /// \brief If the point is in the triangle, it will also send the barycentric coord. -int intersect3D_RayTriangleWithBarycentric(smVec3d P0, smVec3d P1, smVec3d V0, - smVec3d V1, smVec3d V2, smVec3d *I, +int intersect3D_RayTriangleWithBarycentric(core::Vec3d P0, core::Vec3d P1, core::Vec3d V0, + core::Vec3d V1, core::Vec3d V2, core::Vec3d *I, float &p_baryU, float &p_baryV, float &p_baryW, bool considerFrontFaceOnly); diff --git a/src/Collision/MeshCollisionModel.cpp b/src/Collision/MeshCollisionModel.cpp index fbbf8d2619603e285d7e3a1b9cff6387e397608e..bc9264122374c623ca70fb4685c6875a1ca934b1 100644 --- a/src/Collision/MeshCollisionModel.cpp +++ b/src/Collision/MeshCollisionModel.cpp @@ -23,38 +23,38 @@ #include "MeshCollisionModel.h" -smMeshCollisionModel::smMeshCollisionModel() +MeshCollisionModel::MeshCollisionModel() { } -smMeshCollisionModel::~smMeshCollisionModel() +MeshCollisionModel::~MeshCollisionModel() { } -void smMeshCollisionModel::setMesh(std::shared_ptr<smMesh> modelMesh) +void MeshCollisionModel::setMesh(std::shared_ptr<smMesh> modelMesh) { this->setModelMesh(modelMesh); this->aabbTree.reset(); this->initAABBTree(1); } -void smMeshCollisionModel::loadTriangleMesh(const std::string& meshName, const smMeshFileType &type) +void MeshCollisionModel::loadTriangleMesh(const std::string& meshName, const smMeshFileType &type) { this->load(meshName,type); this->initAABBTree(1); } -std::shared_ptr< smMeshCollisionModel::AABBTreeType > smMeshCollisionModel::getAABBTree() +std::shared_ptr< MeshCollisionModel::AABBTreeType > MeshCollisionModel::getAABBTree() { return this->aabbTree; } -void smMeshCollisionModel::setAABBTree(std::shared_ptr<smMeshCollisionModel::AABBTreeType> modelAabbTree) +void MeshCollisionModel::setAABBTree(std::shared_ptr<MeshCollisionModel::AABBTreeType> modelAabbTree) { this->aabbTree.reset(); this->aabbTree = modelAabbTree; } -void smMeshCollisionModel::initAABBTree(const int& numLevels) +void MeshCollisionModel::initAABBTree(const int& numLevels) { this->aabbTree = std::make_shared<AABBTreeType>(std::static_pointer_cast<smSurfaceMesh>(this->mesh), numLevels); this->aabbTree->initStructure(); diff --git a/src/Collision/MeshCollisionModel.h b/src/Collision/MeshCollisionModel.h index 3e0b5d742c6d21bd9b88889da6872b844b064c8b..bc7e4b529b866d5ea42dbd86884b2d34e070e677 100644 --- a/src/Collision/MeshCollisionModel.h +++ b/src/Collision/MeshCollisionModel.h @@ -42,18 +42,18 @@ /// This class facilitates collision detection between a mesh and another /// model. /// -/// @see smMeshToMeshCollision +/// @see MeshToMeshCollision /// -class smMeshCollisionModel : public smMeshModel +class MeshCollisionModel : public smMeshModel { public: - using AABBNodeType = smOctreeCell; - using AABBTreeType = smSurfaceTree<AABBNodeType>; + using AABBNodeType = OctreeCell; + using AABBTreeType = SurfaceTree<AABBNodeType>; using NodePairType = std::pair<std::shared_ptr<AABBNodeType>,std::shared_ptr<AABBNodeType>>; public: - smMeshCollisionModel(); - ~smMeshCollisionModel(); + MeshCollisionModel(); + ~MeshCollisionModel(); /// /// @brief Set internal mesh data structure diff --git a/src/Collision/MeshToMeshCollision.cpp b/src/Collision/MeshToMeshCollision.cpp index 13811b2ad782180caf85ab816fbc35a182f091ed..f7f0db09e4edf2c436ca5bee3ff3be21420bfd8c 100644 --- a/src/Collision/MeshToMeshCollision.cpp +++ b/src/Collision/MeshToMeshCollision.cpp @@ -31,17 +31,17 @@ // STL includes #include <vector> -void smMeshToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> pairs) +void MeshToMeshCollision::doComputeCollision(std::shared_ptr<CollisionPair> pairs) { - auto meshA = std::static_pointer_cast<smMeshCollisionModel>(pairs->getFirst()); - auto meshB = std::static_pointer_cast<smMeshCollisionModel>(pairs->getSecond()); + auto meshA = std::static_pointer_cast<MeshCollisionModel>(pairs->getFirst()); + auto meshB = std::static_pointer_cast<MeshCollisionModel>(pairs->getSecond()); - std::vector<smMeshCollisionModel::NodePairType> + std::vector<MeshCollisionModel::NodePairType> intersectionNodes = meshA->getAABBTree()->getIntersectingNodes(meshB->getAABBTree()); double depth; - smVec3d normal; - smVec3d contactPoint; + core::Vec3d normal; + core::Vec3d contactPoint; for(auto & intersection : intersectionNodes) { auto nodeA = intersection.first; @@ -55,7 +55,7 @@ void smMeshToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> for(const auto & i : triangleListA) { - const smVec3d& normalA = meshA->getNormal(i); + const core::Vec3d& normalA = meshA->getNormal(i); if(normalA.isZero()) { continue; @@ -64,7 +64,7 @@ void smMeshToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> auto verticesA = meshA->getTrianglePositions(i); for(auto & j : triangleListB) { - const smVec3d& normalB = meshB->getNormal(j); + const core::Vec3d& normalB = meshB->getNormal(j); if(normalB.isZero()) { continue; @@ -73,7 +73,7 @@ void smMeshToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> auto verticesB = meshB->getTrianglePositions(j); // Chech for intersection - if(smCollisionMoller::tri2tri(verticesA[0], verticesA[1], verticesA[2], + if(CollisionMoller::tri2tri(verticesA[0], verticesA[1], verticesA[2], verticesB[0], verticesB[1], verticesB[2], depth, contactPoint, normal) ) diff --git a/src/Collision/MeshToMeshCollision.h b/src/Collision/MeshToMeshCollision.h index a0aa6d00dcafce6f51ebdd306b5c2510633ca76e..253bbb5a11caa53460a33c20e047de3e1e2619c7 100644 --- a/src/Collision/MeshToMeshCollision.h +++ b/src/Collision/MeshToMeshCollision.h @@ -28,22 +28,22 @@ // SimMedTK includes #include "Core/CollisionDetection.h" -class smCollisionPair; +class CollisionPair; /// /// @brief COllision detection based on BVH queries and /// triangle-triangle intersection tests. /// -class smMeshToMeshCollision : public smCollisionDetection +class MeshToMeshCollision : public CollisionDetection { public: - smMeshToMeshCollision() {} - virtual ~smMeshToMeshCollision() {} + MeshToMeshCollision() {} + virtual ~MeshToMeshCollision() {} - smMeshToMeshCollision(const smMeshToMeshCollision &) = delete; + MeshToMeshCollision(const MeshToMeshCollision &) = delete; private: - virtual void doComputeCollision(std::shared_ptr<smCollisionPair> pairs) override; + virtual void doComputeCollision(std::shared_ptr<CollisionPair> pairs) override; }; diff --git a/src/Collision/OctreeCell.cpp b/src/Collision/OctreeCell.cpp index ecd1b29bc0ee82a914ee429d63558e19a18ad6a6..bd8d28566db5e9572fe725a8bd604590b900d939 100644 --- a/src/Collision/OctreeCell.cpp +++ b/src/Collision/OctreeCell.cpp @@ -29,97 +29,97 @@ // SimMedTK includes #include "Collision/CollisionMoller.h" -smOctreeCell::smOctreeCell() : BaseType() +OctreeCell::OctreeCell() : BaseType() { } -smOctreeCell::~smOctreeCell() +OctreeCell::~OctreeCell() { } -smVec3d &smOctreeCell::getCenter() +core::Vec3d &OctreeCell::getCenter() { return cube.center; } -const smVec3d &smOctreeCell::getCenter() const +const core::Vec3d &OctreeCell::getCenter() const { return cube.center; } -void smOctreeCell::setCenter( const smVec3d ¢er ) +void OctreeCell::setCenter( const core::Vec3d ¢er ) { cube.center = center; } -double &smOctreeCell::getLength() +double &OctreeCell::getLength() { return cube.sideLength; } -const double &smOctreeCell::getLength() const +const double &OctreeCell::getLength() const { return cube.sideLength; } -void smOctreeCell::setLength( const double length ) +void OctreeCell::setLength( const double length ) { cube.sideLength = length; } -void smOctreeCell::copyShape( const smOctreeCell &cell ) +void OctreeCell::copyShape( const OctreeCell &cell ) { cube = cell.cube; } -void smOctreeCell::expand( const double expandScale ) +void OctreeCell::expand( const double expandScale ) { cube.expand( expandScale ); } -bool smOctreeCell::isCollidedWithTri( smVec3d &v0, smVec3d &v1, smVec3d &v2 ) +bool OctreeCell::isCollidedWithTri( core::Vec3d &v0, core::Vec3d &v1, core::Vec3d &v2 ) { - smAABB tempAABB; + AABB tempAABB; tempAABB.aabbMin = cube.leftMinCorner(); tempAABB.aabbMax = cube.rightMaxCorner(); - return smCollisionMoller::checkAABBTriangle( tempAABB, v0, v1, v2 ); + return CollisionMoller::checkAABBTriangle( tempAABB, v0, v1, v2 ); } -bool smOctreeCell::isCollidedWithPoint() +bool OctreeCell::isCollidedWithPoint() { - std::cerr << "Error::smOctreeCell::isCollidedWithPoint(): Function not implemented." << std::endl; + std::cerr << "Error::OctreeCell::isCollidedWithPoint(): Function not implemented." << std::endl; return 0; } -void smOctreeCell::subDivide( const int divisionPerAxis, - std::array<smOctreeCell, smOctreeCell::numberOfSubdivisions> &cells ) +void OctreeCell::subDivide( const int divisionPerAxis, + std::array<OctreeCell, OctreeCell::numberOfSubdivisions> &cells ) { size_t totalCubes = divisionPerAxis * divisionPerAxis * divisionPerAxis; assert( cells.size() == totalCubes ); - std::vector<smCube> cubes( smOctreeCell::numberOfSubdivisions ); + std::vector<Cube> cubes( OctreeCell::numberOfSubdivisions ); cube.subDivide( divisionPerAxis, cubes.data() ); - for ( size_t i = 0; i < smOctreeCell::numberOfSubdivisions; i++ ) + for ( size_t i = 0; i < OctreeCell::numberOfSubdivisions; i++ ) { cells[i].cube = cubes[i]; } } -const smCube &smOctreeCell::getCube() const +const Cube &OctreeCell::getCube() const { return cube; } -smCube &smOctreeCell::getCube() +Cube &OctreeCell::getCube() { return cube; } -void smOctreeCell::setCube(const smCube &otherCube) +void OctreeCell::setCube(const Cube &otherCube) { this->cube.center = otherCube.center; this->cube.sideLength = otherCube.sideLength; diff --git a/src/Collision/OctreeCell.h b/src/Collision/OctreeCell.h index 6a409423c8a00be781f484a98623f6ff7967e4b0..7e22ec0c9eebc2133e997e18427d75c27dd31bac 100644 --- a/src/Collision/OctreeCell.h +++ b/src/Collision/OctreeCell.h @@ -33,35 +33,35 @@ #include <memory> /// \brief cell of an octree -class smOctreeCell : public smSurfaceTreeCell<smOctreeCell> +class OctreeCell : public SurfaceTreeCell<OctreeCell> { protected: - using BaseType = smSurfaceTreeCell<smOctreeCell>; - using SelfType = smOctreeCell; + using BaseType = SurfaceTreeCell<OctreeCell>; + using SelfType = OctreeCell; public: - smOctreeCell(); - ~smOctreeCell(); + OctreeCell(); + ~OctreeCell(); enum { numberOfSubdivisions = 8 }; /// \brief get a constant reference to the cell primitive - const smCube &getCube() const; + const Cube &getCube() const; /// \brief get a reference to the cell primitive - smCube &getCube(); + Cube &getCube(); /// \brief set the primitive - void setCube(const smCube &other); + void setCube(const Cube &other); /// \brief get the center of the octree cell - smVec3d &getCenter(); + core::Vec3d &getCenter(); /// \brief get constant reference to the center of the octree cell - const smVec3d &getCenter() const; + const core::Vec3d &getCenter() const; /// \brief set the center of the octree cell - void setCenter ( const smVec3d ¢er ); + void setCenter ( const core::Vec3d ¢er ); /// \brief get reference to the side length of the octree cell double &getLength (); @@ -70,7 +70,7 @@ public: const double &getLength() const; /// \brief set the octree cell - void copyShape ( const smOctreeCell &cell ); + void copyShape ( const OctreeCell &cell ); /// \brief !! expand the cell of the octree structure void expand ( const double expandScale ); @@ -79,26 +79,26 @@ public: void setLength ( const double length ); /// \brief check if a triangle is intersecting the octree cell - bool isCollidedWithTri ( smVec3d &v0, smVec3d &v1, smVec3d &v2 ); + bool isCollidedWithTri ( core::Vec3d &v0, core::Vec3d &v1, core::Vec3d &v2 ); /// \brief check if a point lies inside an octree cell bool isCollidedWithPoint (); /// \brief subdivide the cells of octree cells void subDivide ( const int divisionPerAxis, - std::array<smOctreeCell,numberOfSubdivisions> &cells ); + std::array<OctreeCell,numberOfSubdivisions> &cells ); - const smAABB &getAabb() const + const AABB &getAabb() const { return aabb; } - void setAabb(const smAABB &newAabb) + void setAabb(const AABB &newAabb) { this->aabb = newAabb; } - void getIntersections(const smAABB &aabb, std::vector<size_t> &triangles) + void getIntersections(const AABB &aabb, std::vector<size_t> &triangles) { for(auto &i : data) { @@ -109,33 +109,33 @@ public: } } - inline void addTriangleData(const smAABB &aabb, size_t index) + inline void addTriangleData(const AABB &aabb, size_t index) { return data.emplace_back(aabb,index); } - std::shared_ptr<smOctreeCell> getChildNode(size_t i) + std::shared_ptr<OctreeCell> getChildNode(size_t i) { return childNodes[i]; } - const std::array<std::shared_ptr<smOctreeCell>,numberOfSubdivisions> + const std::array<std::shared_ptr<OctreeCell>,numberOfSubdivisions> &getChildNodes() const { return childNodes; } - void setChildNode(size_t i, std::shared_ptr<smOctreeCell> node) + void setChildNode(size_t i, std::shared_ptr<OctreeCell> node) { childNodes[i] = node; } - std::shared_ptr<smOctreeCell> getParentNode() + std::shared_ptr<OctreeCell> getParentNode() { return parentNode; } - void setParentNode(std::shared_ptr<smOctreeCell> parent) + void setParentNode(std::shared_ptr<OctreeCell> parent) { parentNode = parent; } @@ -162,12 +162,12 @@ public: } private: - smCube cube; ///< cube - smAABB aabb; + Cube cube; ///< cube + AABB aabb; - std::array<std::shared_ptr<smOctreeCell>,numberOfSubdivisions> childNodes; - std::shared_ptr<smOctreeCell> parentNode; - std::vector<std::pair<smAABB,size_t>> data; + std::array<std::shared_ptr<OctreeCell>,numberOfSubdivisions> childNodes; + std::shared_ptr<OctreeCell> parentNode; + std::vector<std::pair<AABB,size_t>> data; }; diff --git a/src/Collision/PlaneCollisionModel.cpp b/src/Collision/PlaneCollisionModel.cpp index 625beb3fde5225f8f48d65aaa49e686d7266e8fb..84b74b58364c86272b47715c334fee753acacad4 100644 --- a/src/Collision/PlaneCollisionModel.cpp +++ b/src/Collision/PlaneCollisionModel.cpp @@ -24,10 +24,10 @@ #include "PlaneCollisionModel.h" -smPlaneCollisionModel::smPlaneCollisionModel(const smVec3d& p, const smVec3d& n) +PlaneCollisionModel::PlaneCollisionModel(const core::Vec3d& p, const core::Vec3d& n) : smPlaneModel(p, n) { } -smPlaneCollisionModel::~smPlaneCollisionModel() {} +PlaneCollisionModel::~PlaneCollisionModel() {} diff --git a/src/Collision/PlaneCollisionModel.h b/src/Collision/PlaneCollisionModel.h index d4ab897f6745c1deb597ab3eb543a741de1f04e3..1494bc87391ea197fead35bea971841a4921deda 100644 --- a/src/Collision/PlaneCollisionModel.h +++ b/src/Collision/PlaneCollisionModel.h @@ -24,19 +24,14 @@ #ifndef SMPLANECOLLISIONMODEL_H #define SMPLANECOLLISIONMODEL_H -#include <memory> - -// Eigen include -#include<Eigen/Geometry> - #include "Geometry/PlaneModel.h" -class smPlaneCollisionModel : public smPlaneModel +class PlaneCollisionModel : public smPlaneModel { public: - smPlaneCollisionModel(const smVec3d &p, const smVec3d &n); + PlaneCollisionModel(const core::Vec3d &p, const core::Vec3d &n); - ~smPlaneCollisionModel(); + ~PlaneCollisionModel(); }; diff --git a/src/Collision/PlaneToMeshCollision.cpp b/src/Collision/PlaneToMeshCollision.cpp index 841854379ecc38bd5d8b920a7a8ff86d15502251..b6068fc93cde513b09ba9e371a886b36243e41d4 100644 --- a/src/Collision/PlaneToMeshCollision.cpp +++ b/src/Collision/PlaneToMeshCollision.cpp @@ -32,10 +32,10 @@ // STL includes #include <limits> -void smPlaneToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> pair) +void PlaneToMeshCollision::doComputeCollision(std::shared_ptr<CollisionPair> pair) { - auto mesh = std::static_pointer_cast<smMeshCollisionModel>(pair->getFirst()); - auto plane = std::static_pointer_cast<smPlaneCollisionModel>(pair->getSecond()); + auto mesh = std::static_pointer_cast<MeshCollisionModel>(pair->getFirst()); + auto plane = std::static_pointer_cast<PlaneCollisionModel>(pair->getSecond()); if (!mesh || !plane) { @@ -43,10 +43,10 @@ void smPlaneToMeshCollision::doComputeCollision(std::shared_ptr<smCollisionPair> } double d; - smVec3d planeNormal = plane->getPlaneModel()->getUnitNormal(); - smVec3d planePos = plane->getPlaneModel()->getPoint(); + core::Vec3d planeNormal = plane->getPlaneModel()->getUnitNormal(); + core::Vec3d planePos = plane->getPlaneModel()->getPoint(); - smVec3d vert; + core::Vec3d vert; pair->clearContacts(); for (int i = 0; i < mesh->getVertices().size(); i++)//const auto& vertex : mesh->getVertices() { diff --git a/src/Collision/PlaneToMeshCollision.h b/src/Collision/PlaneToMeshCollision.h index 641b1a56283fb86f597bcf0589abdd99d6b4458b..ec2961b6036e1ac6e52a2a23181ef0b836c5570e 100644 --- a/src/Collision/PlaneToMeshCollision.h +++ b/src/Collision/PlaneToMeshCollision.h @@ -28,21 +28,21 @@ // SimMedTK includes #include "Core/CollisionDetection.h" -class smCollisionPair; +class CollisionPair; /// /// @brief Brute force collision detection between a mesh and a static plane /// -class smPlaneToMeshCollision : public smCollisionDetection +class PlaneToMeshCollision : public CollisionDetection { public: - smPlaneToMeshCollision() {} - virtual ~smPlaneToMeshCollision() {} + PlaneToMeshCollision() {} + virtual ~PlaneToMeshCollision() {} - smPlaneToMeshCollision(const smPlaneToMeshCollision &) = delete; + PlaneToMeshCollision(const PlaneToMeshCollision &) = delete; private: - virtual void doComputeCollision(std::shared_ptr<smCollisionPair> pairs) override; + virtual void doComputeCollision(std::shared_ptr<CollisionPair> pairs) override; }; diff --git a/src/Collision/SpatialHashCollision.cpp b/src/Collision/SpatialHashCollision.cpp index 0f0bdbfd04fc6ee51aeb960792243baee6ceaea7..035015dbcde586ed7099aa83f94215eec41b9646 100644 --- a/src/Collision/SpatialHashCollision.cpp +++ b/src/Collision/SpatialHashCollision.cpp @@ -34,7 +34,7 @@ #include "Core/SDK.h" -struct smSpatialHashCollision::HashFunction +struct SpatialHashCollision::HashFunction { HashFunction(unsigned int hashConst1 = 73856093, unsigned int hashConst2 = 19349663, @@ -50,7 +50,7 @@ struct smSpatialHashCollision::HashFunction unsigned int const3; }; -smSpatialHashCollision::smSpatialHashCollision(int hashTableSize, +SpatialHashCollision::SpatialHashCollision(int hashTableSize, float _cellSizeX, float _cellSizeY, float _cellSizeZ): @@ -66,44 +66,44 @@ smSpatialHashCollision::smSpatialHashCollision(int hashTableSize, cellSizeZ = _cellSizeZ; } -smSpatialHashCollision::~smSpatialHashCollision() +SpatialHashCollision::~SpatialHashCollision() { } -void smSpatialHashCollision::addCollisionModel(std::shared_ptr<SurfaceTreeType> CollMode) +void SpatialHashCollision::addCollisionModel(std::shared_ptr<SurfaceTreeType> CollMode) { colModel.push_back(CollMode); } -void smSpatialHashCollision::addMesh(std::shared_ptr<smMesh> mesh) +void SpatialHashCollision::addMesh(std::shared_ptr<smMesh> mesh) { meshes.push_back(mesh); mesh->allocateAABBTris(); } -void smSpatialHashCollision::addMesh(std::shared_ptr<smLineMesh> mesh) +void SpatialHashCollision::addMesh(std::shared_ptr<smLineMesh> mesh) { lineMeshes.push_back(mesh); } -void smSpatialHashCollision::removeMesh(std::shared_ptr<smMesh> mesh) +void SpatialHashCollision::removeMesh(std::shared_ptr<smMesh> mesh) { auto it = std::find(meshes.begin(),meshes.end(),mesh); if(it != meshes.end()) meshes.erase(it); } -bool smSpatialHashCollision::findCandidatePoints(std::shared_ptr<smMesh> mesh, - std::shared_ptr<smSpatialHashCollision::SurfaceTreeType> colModel) +bool SpatialHashCollision::findCandidatePoints(std::shared_ptr<smMesh> mesh, + std::shared_ptr<SpatialHashCollision::SurfaceTreeType> colModel) { - smAABB tempAABB; + AABB tempAABB; tempAABB.aabbMin = colModel->root->getCube().leftMinCorner(); tempAABB.aabbMax = colModel->root->getCube().rightMaxCorner(); bool found = false; for (int i = 0; i < mesh->nbrVertices; i++) { - if (smCollisionMoller::checkAABBPoint(tempAABB, mesh->vertices[i])) + if (CollisionMoller::checkAABBPoint(tempAABB, mesh->vertices[i])) { addPoint(mesh, i, cellsForModelPoints); found = true; @@ -112,11 +112,11 @@ bool smSpatialHashCollision::findCandidatePoints(std::shared_ptr<smMesh> mesh, return found; } -bool smSpatialHashCollision::findCandidateTris(std::shared_ptr<smMesh> meshA, std::shared_ptr<smMesh> meshB) +bool SpatialHashCollision::findCandidateTris(std::shared_ptr<smMesh> meshA, std::shared_ptr<smMesh> meshB) { - smAABB aabboverlap; + AABB aabboverlap; - if (smCollisionMoller::checkOverlapAABBAABB(meshA->aabb, meshB->aabb, aabboverlap) == false) + if (CollisionMoller::checkOverlapAABBAABB(meshA->aabb, meshB->aabb, aabboverlap) == false) { return false; } @@ -134,18 +134,18 @@ bool smSpatialHashCollision::findCandidateTris(std::shared_ptr<smMesh> meshA, st return true; } -bool smSpatialHashCollision::findCandidateTrisLines(std::shared_ptr<smMesh> meshA, std::shared_ptr<smLineMesh> meshB) +bool SpatialHashCollision::findCandidateTrisLines(std::shared_ptr<smMesh> meshA, std::shared_ptr<smLineMesh> meshB) { - smAABB aabboverlap; + AABB aabboverlap; - if (smCollisionMoller::checkOverlapAABBAABB(meshA->aabb, meshB->aabb, aabboverlap) == false) + if (CollisionMoller::checkOverlapAABBAABB(meshA->aabb, meshB->aabb, aabboverlap) == false) { return false; } for (int i = 0; i < meshA->nbrTriangles; i++) { - if (smCollisionMoller::checkOverlapAABBAABB(aabboverlap, meshA->triAABBs[i])) + if (CollisionMoller::checkOverlapAABBAABB(aabboverlap, meshA->triAABBs[i])) { addTriangle(meshA, i, cellsForTri2Line); } @@ -153,7 +153,7 @@ bool smSpatialHashCollision::findCandidateTrisLines(std::shared_ptr<smMesh> mesh for (int i = 0; i < meshB->nbrEdges; i++) { - if (smCollisionMoller::checkOverlapAABBAABB(aabboverlap, meshB->edgeAABBs[i])) + if (CollisionMoller::checkOverlapAABBAABB(aabboverlap, meshB->edgeAABBs[i])) { addLine(meshB, i, cellLines); } @@ -162,14 +162,14 @@ bool smSpatialHashCollision::findCandidateTrisLines(std::shared_ptr<smMesh> mesh return true; } -void smSpatialHashCollision::computeCollisionTri2Tri() +void SpatialHashCollision::computeCollisionTri2Tri() { - smHashIterator<smCellTriangle> iterator; - smHashIterator<smCellTriangle> iterator1; + smHashIterator<CellTriangle> iterator; + smHashIterator<CellTriangle> iterator1; - smCellTriangle triA; - smCellTriangle triB; - smVec3d proj1, proj2, inter1, inter2; + CellTriangle triA; + CellTriangle triB; + core::Vec3d proj1, proj2, inter1, inter2; short point1, point2; int coPlanar; @@ -187,7 +187,7 @@ void smSpatialHashCollision::computeCollisionTri2Tri() continue; } - if (smCollisionMoller::tri2tri(triA.vert[0], + if (CollisionMoller::tri2tri(triA.vert[0], triA.vert[1], triA.vert[2], triB.vert[0], @@ -212,13 +212,13 @@ void smSpatialHashCollision::computeCollisionTri2Tri() } ///line to triangle collision -void smSpatialHashCollision::computeCollisionLine2Tri() +void SpatialHashCollision::computeCollisionLine2Tri() { smHashIterator<smCellLine > iteratorLine; - smHashIterator<smCellTriangle > iteratorTri; + smHashIterator<CellTriangle > iteratorTri; smCellLine line; - smCellTriangle tri; - smVec3d intersection; + CellTriangle tri; + core::Vec3d intersection; while (cellLines.next(iteratorLine) && cellsForTri2Line.next(iteratorTri)) { @@ -235,7 +235,7 @@ void smSpatialHashCollision::computeCollisionLine2Tri() continue; } - if (smCollisionMoller::checkLineTri(line.vert[0], + if (CollisionMoller::checkLineTri(line.vert[0], line.vert[1], tri.vert[0], tri.vert[1], @@ -253,7 +253,7 @@ void smSpatialHashCollision::computeCollisionLine2Tri() } } -void smSpatialHashCollision::computeCollisionModel2Points() +void SpatialHashCollision::computeCollisionModel2Points() { smHashIterator<smCellModel > iteratorModel; smHashIterator<smCellPoint > iteratorPoint; @@ -285,7 +285,7 @@ void smSpatialHashCollision::computeCollisionModel2Points() } } -void smSpatialHashCollision::computeHash(std::shared_ptr<smMesh> mesh, const std::vector<int> &triangleIndexes) +void SpatialHashCollision::computeHash(std::shared_ptr<smMesh> mesh, const std::vector<int> &triangleIndexes) { for(auto&& i : triangleIndexes) { @@ -301,14 +301,14 @@ void smSpatialHashCollision::computeHash(std::shared_ptr<smMesh> mesh, const std for (int iy = yStartIndex; iy <= yEndIndex; iy++) for (int iz = zStartIndex; iz <= zEndIndex; iz++) { - cells.insert(smCellTriangle(i), hasher->getKey(cells.tableSize, ix, iy, iz)); + cells.insert(CellTriangle(i), hasher->getKey(cells.tableSize, ix, iy, iz)); } } } -void smSpatialHashCollision::addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<smCellTriangle> &cells) +void SpatialHashCollision::addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<CellTriangle> &cells) { - smCellTriangle triangle; + CellTriangle triangle; triangle.meshID = mesh->getUniqueId(); triangle.primID = triangleId; @@ -332,7 +332,7 @@ void smSpatialHashCollision::addTriangle(std::shared_ptr<smMesh> mesh, int trian } } -void smSpatialHashCollision::addLine(std::shared_ptr<smLineMesh> mesh, +void SpatialHashCollision::addLine(std::shared_ptr<smLineMesh> mesh, int edgeId, smHash<smCellLine> &cells) { smCellLine line; @@ -357,7 +357,7 @@ void smSpatialHashCollision::addLine(std::shared_ptr<smLineMesh> mesh, } } -void smSpatialHashCollision::addPoint(std::shared_ptr<smMesh> mesh, int vertId, smHash<smCellPoint> &cells) +void SpatialHashCollision::addPoint(std::shared_ptr<smMesh> mesh, int vertId, smHash<smCellPoint> &cells) { smCellPoint cellPoint; cellPoint.meshID = mesh->getUniqueId(); @@ -371,12 +371,12 @@ void smSpatialHashCollision::addPoint(std::shared_ptr<smMesh> mesh, int vertId, cells.checkAndInsert(cellPoint, hasher->getKey(cells.tableSize, xStartIndex, yStartIndex, zStartIndex)); } -void smSpatialHashCollision::addOctreeCell(std::shared_ptr<smSpatialHashCollision::SurfaceTreeType> colModel, smHash<smCellModel> &cells) +void SpatialHashCollision::addOctreeCell(std::shared_ptr<SpatialHashCollision::SurfaceTreeType> colModel, smHash<smCellModel> &cells) { smCellModel cellModel; - smAABB temp; + AABB temp; - smSurfaceTreeIterator<smOctreeCell> iter = colModel->getLevelIterator(); + SurfaceTreeIterator<OctreeCell> iter = colModel->getLevelIterator(); cellModel.meshID = colModel->getAttachedMeshID(); for (int i = iter.start(); i != iter.end(); ++i) @@ -408,7 +408,7 @@ void smSpatialHashCollision::addOctreeCell(std::shared_ptr<smSpatialHashCollisio } } -void smSpatialHashCollision::reset() +void SpatialHashCollision::reset() { cells.clearAll(); cellLines.clearAll(); @@ -419,7 +419,7 @@ void smSpatialHashCollision::reset() collidedModelPoints.clear(); collidedTriangles.clear(); } -bool smSpatialHashCollision::findCandidates() +bool SpatialHashCollision::findCandidates() { for(size_t i = 0; i < colModel.size(); i++) for(size_t i = 0; i < meshes.size(); i++) @@ -457,7 +457,7 @@ bool smSpatialHashCollision::findCandidates() } return 0; } -void smSpatialHashCollision::updateBVH() +void SpatialHashCollision::updateBVH() { for(size_t i = 0; i < meshes.size(); i++) { @@ -469,11 +469,11 @@ void smSpatialHashCollision::updateBVH() meshes[i]->upadateAABB(); } } -const std::vector< std::shared_ptr< smCollidedTriangles > >& smSpatialHashCollision::getCollidedTriangles() const +const std::vector< std::shared_ptr< smCollidedTriangles > >& SpatialHashCollision::getCollidedTriangles() const { return collidedTriangles; } -std::vector< std::shared_ptr< smCollidedTriangles > >& smSpatialHashCollision::getCollidedTriangles() +std::vector< std::shared_ptr< smCollidedTriangles > >& SpatialHashCollision::getCollidedTriangles() { return collidedTriangles; } diff --git a/src/Collision/SpatialHashCollision.h b/src/Collision/SpatialHashCollision.h index c1db276fd1ef29e9f145bf5079e967fa91ceb3a7..31e4b57290ac4b1f277461dda6c8481f19fc7305 100644 --- a/src/Collision/SpatialHashCollision.h +++ b/src/Collision/SpatialHashCollision.h @@ -35,16 +35,16 @@ class smCellLine; class smCellModel; class smCellPoint; -class smCellTriangle; +class CellTriangle; class smCollidedLineTris; class smCollidedModelPoints; class smCollidedTriangles; class smLineMesh; class smMesh; -class smOctreeCell; +class OctreeCell; template<typename CellType> -class smSurfaceTree; +class SurfaceTree; /// \brief enum smCollisionSetting @@ -55,21 +55,21 @@ enum smCollisionSetting }; /// \brief spatial hash -class smSpatialHashCollision: public smCollisionDetection +class SpatialHashCollision: public CollisionDetection { public: - using SurfaceTreeType = smSurfaceTree<smOctreeCell>; + using SurfaceTreeType = SurfaceTree<OctreeCell>; public: /// \brief !! - smSpatialHashCollision(int hashTableSize, + SpatialHashCollision(int hashTableSize, float cellSizeX, float cellSizeY, float cellSizeZ); /// \brief destructor clear some memory - ~smSpatialHashCollision(); + ~SpatialHashCollision(); /// \brief !! void addCollisionModel(std::shared_ptr<SurfaceTreeType> CollModel); @@ -113,7 +113,7 @@ public: protected: /// \brief adds triangle to hash - void addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<smCellTriangle> &cells); + void addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<CellTriangle> &cells); /// \brief adds line to hash void addLine(std::shared_ptr<smLineMesh> mesh, int edgeId, smHash<smCellLine> &cells); @@ -130,7 +130,7 @@ protected: void updateBVH(); private: - void doComputeCollision(std::shared_ptr<smCollisionPair> /*pairs*/) + void doComputeCollision(std::shared_ptr<CollisionPair> /*pairs*/) { reset(); updateBVH(); @@ -145,9 +145,9 @@ private: float cellSizeY; ///< cell spacing in y-direction float cellSizeZ; ///< cell spacing in z-direction - smHash<smCellTriangle> cells; // Candidate triangles + smHash<CellTriangle> cells; // Candidate triangles smHash<smCellLine> cellLines; // Lines that stored in the scene. - smHash<smCellTriangle> cellsForTri2Line; // Candidate triangles in the scene. + smHash<CellTriangle> cellsForTri2Line; // Candidate triangles in the scene. smHash<smCellModel> cellsForModel; // Candidate cells for collision model smHash<smCellPoint> cellsForModelPoints; // Candidate for Collision model to point std::vector<std::shared_ptr<smMesh>> meshes; // Mesh models diff --git a/src/Collision/SurfaceTree.h b/src/Collision/SurfaceTree.h index 2e6d063c4194cb30674d56771dd9841d387c4e20..153833f98ed7b8cc881c1eb85332bc914ad73e3a 100644 --- a/src/Collision/SurfaceTree.h +++ b/src/Collision/SurfaceTree.h @@ -29,17 +29,17 @@ #include <array> // SimMedTK includes -#include "Core/CollisionModel.h" +#include "Core/CollisionModelIterator.h" #include "Collision/SurfaceTreeCell.h" #include "Collision/CollisionMoller.h" #include "Mesh/SurfaceMesh.h" /// \brief !! template<typename CellType> -class smSurfaceTree : public smCoreClass +class SurfaceTree : public CoreClass { protected: - typedef smMatrix44d MatrixType; + typedef Matrix44d MatrixType; protected: std::shared_ptr<smSurfaceMesh> mesh; ///< surface mesh @@ -54,10 +54,10 @@ protected: public: /// \brief constructor - smSurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels = 6); + SurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels = 6); /// \brief destructor - ~smSurfaceTree(); + ~SurfaceTree(); MatrixType transRot; ///< matrix for translation and rotation int maxLevel; ///< max level of the tree @@ -79,20 +79,20 @@ public: /// \brief initialize the surface tree structure virtual void initStructure(); - virtual smCollisionModelIterator<CellType> getLevelIterator(int level) ; + virtual CollisionModelIterator<CellType> getLevelIterator(int level) ; - virtual smCollisionModelIterator<CellType> getLevelIterator() ; + virtual CollisionModelIterator<CellType> getLevelIterator() ; /// \brief !! - inline std::shared_ptr<smUnifiedId> getAttachedMeshID() + inline std::shared_ptr<UnifiedId> getAttachedMeshID() { return mesh->getUniqueId(); } /// \brief !! - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; - /// \brief !! smSurfaceTree structure + /// \brief !! SurfaceTree structure void updateStructure(); /// \brief !! @@ -104,7 +104,7 @@ public: } std::vector<std::pair<std::shared_ptr<CellType>,std::shared_ptr<CellType>>> - getIntersectingNodes(std::shared_ptr<smSurfaceTree<CellType>> otherTree) + getIntersectingNodes(std::shared_ptr<SurfaceTree<CellType>> otherTree) { std::vector<std::pair<std::shared_ptr<CellType>,std::shared_ptr<CellType>>> intersectingNodes; getIntersectingNodes(root, otherTree->getRoot(),intersectingNodes); diff --git a/src/Collision/SurfaceTree.hpp b/src/Collision/SurfaceTree.hpp index 353fd425036909fa2f358a562ad91e92ec210e39..d9438bcbf77948c2694e5c6633e2e2a133ac9630 100644 --- a/src/Collision/SurfaceTree.hpp +++ b/src/Collision/SurfaceTree.hpp @@ -24,9 +24,6 @@ #ifndef SM_SMSURFACETREE_HPP #define SM_SMSURFACETREE_HPP -// STL includes -#include <string> - // SimMedTK includes #include "Rendering/Viewer.h" #include "Collision/SurfaceTreeIterator.h" @@ -35,9 +32,9 @@ /// \brief initialize the surface tree structure template <typename CellType> -void smSurfaceTree<CellType>::initStructure() +void SurfaceTree<CellType>::initStructure() { - smVec3d center; + core::Vec3d center; double edge; std::vector<int> triangles; @@ -62,13 +59,13 @@ void smSurfaceTree<CellType>::initStructure() /// \brief destructor template<typename CellType> -smSurfaceTree<CellType>::~smSurfaceTree() +SurfaceTree<CellType>::~SurfaceTree() { } /// \brief template<typename CellType> -smSurfaceTree<CellType>::smSurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels) +SurfaceTree<CellType>::SurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels) { mesh = surfaceMesh; totalCells = 0; @@ -79,7 +76,7 @@ smSurfaceTree<CellType>::smSurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMes //compute the total cells for (int i = 0; i < maxLevel; ++i) { - totalCells += smMath::pow(CellType::numberOfSubdivisions, i); + totalCells += std::pow(int(CellType::numberOfSubdivisions), i); } treeAllLevels.resize(totalCells); @@ -91,7 +88,7 @@ smSurfaceTree<CellType>::smSurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMes for (int i = 1; i < maxLevel; ++i) { - levelStartIndex[i][0] = levelStartIndex[i-1][0] + smMath::pow(CellType::numberOfSubdivisions, i-1); + levelStartIndex[i][0] = levelStartIndex[i-1][0] + std::pow(int(CellType::numberOfSubdivisions), i-1); levelStartIndex[i-1][1] = levelStartIndex[i][0]; } @@ -106,13 +103,13 @@ smSurfaceTree<CellType>::smSurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMes mesh->allocateAABBTris(); this->setRenderDelegate( - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "SurfaceTreeRenderDelegate")); } /// \brief handle key press events template<typename CellType> -void smSurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void SurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::Event> event) { if(!this->isListening()) { @@ -186,7 +183,7 @@ void smSurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::smEvent> /// \brief create the surface tree template<typename CellType> -bool smSurfaceTree<CellType>::createTree(std::shared_ptr<CellType> Node, +bool SurfaceTree<CellType>::createTree(std::shared_ptr<CellType> Node, const std::vector<int> &triangles, int siblingIndex) { @@ -300,9 +297,9 @@ bool smSurfaceTree<CellType>::createTree(std::shared_ptr<CellType> Node, /// \brief !! template <typename CellType> -smCollisionModelIterator<CellType> smSurfaceTree<CellType>::getLevelIterator(int level) +CollisionModelIterator<CellType> SurfaceTree<CellType>::getLevelIterator(int level) { - smSurfaceTreeIterator<CellType> iter(this); + SurfaceTreeIterator<CellType> iter(this); iter.startIndex = iter.currentIndex = this->levelStartIndex[level][0]; iter.endIndex = this->levelStartIndex[level][1]; iter.currentLevel = level; @@ -311,9 +308,9 @@ smCollisionModelIterator<CellType> smSurfaceTree<CellType>::getLevelIterator(int /// \brief !! template <typename CellType> -smCollisionModelIterator<CellType> smSurfaceTree<CellType>::getLevelIterator() +CollisionModelIterator<CellType> SurfaceTree<CellType>::getLevelIterator() { - smSurfaceTreeIterator<CellType> iter(this); + SurfaceTreeIterator<CellType> iter(this); iter.startIndex = iter.currentIndex = this->levelStartIndex[currentLevel][0]; iter.endIndex = this->levelStartIndex[currentLevel][1]; iter.currentLevel = currentLevel; @@ -322,14 +319,14 @@ smCollisionModelIterator<CellType> smSurfaceTree<CellType>::getLevelIterator() /// \brief update the surface tree template <typename CellType> -void smSurfaceTree<CellType>::updateStructure() +void SurfaceTree<CellType>::updateStructure() { CellType *current; for (int i = levelStartIndex[maxLevel-1][0]; i < levelStartIndex[maxLevel-1][1]; ++i) { current = &treeAllLevels[i]; - smVec3d tempCenter(0, 0, 0); + core::Vec3d tempCenter(0, 0, 0); int counter = 0; if (!current->isEmpty()) @@ -347,7 +344,7 @@ void smSurfaceTree<CellType>::updateStructure() /// \brief !! template <typename CellType> -void smSurfaceTree<CellType>::translateRot() +void SurfaceTree<CellType>::translateRot() { CellType *current; CellType *initial; diff --git a/src/Collision/SurfaceTreeCell.h b/src/Collision/SurfaceTreeCell.h index fa9799e69eee0d2ab0d7851bf5dd8e087f0229c8..7dccd14440c9899a2682ec9d63837f0b7722a016 100644 --- a/src/Collision/SurfaceTreeCell.h +++ b/src/Collision/SurfaceTreeCell.h @@ -35,11 +35,11 @@ /// \brief contains the cell of the surface tree structure template <typename Derived> -class smSurfaceTreeCell +class SurfaceTreeCell { public: /// \brief constructor - smSurfaceTreeCell() + SurfaceTreeCell() { empty = true; isLeaf = false; @@ -66,13 +66,13 @@ public: } /// \brief checks if the cell collided with a triangle primitive - inline bool isCollidedWithTri(const smVec3d &v0, const smVec3d &v1, const smVec3d &v2) + inline bool isCollidedWithTri(const core::Vec3d &v0, const core::Vec3d &v1, const core::Vec3d &v2) { return derived()->isCollidedWithTri(v0,v1,v2); } /// \brief checks if the cell contains the point primitive - inline bool isCollidedWithPoint(const smVec3d &point) + inline bool isCollidedWithPoint(const core::Vec3d &point) { return derived()->isCollidedWithPoint(point); } @@ -84,7 +84,7 @@ public: } /// \brief set the center of the cell of surface tree - inline void setCenter(const smVec3d ¢er) + inline void setCenter(const core::Vec3d ¢er) { derived()->setCenter(center); } @@ -96,7 +96,7 @@ public: } /// \brief get the center of the cell of surface tree - inline smVec3d &getCenter() + inline core::Vec3d &getCenter() { return derived()->getCenter(); } @@ -108,7 +108,7 @@ public: } /// \brief get the center of the cell of surface tree - inline const smVec3d &getCenter() const + inline const core::Vec3d &getCenter() const { return derived()->getCenter(); } @@ -119,8 +119,8 @@ public: return derived()->getLength(); } - template<typename smAABB> - inline void addTriangleData(const smAABB &aabb, size_t index) + template<typename AABB> + inline void addTriangleData(const AABB &aabb, size_t index) { return derived()->addTriangleData(aabb,index); } diff --git a/src/Collision/SurfaceTreeIterator.h b/src/Collision/SurfaceTreeIterator.h index 6b5e06eca441a453142899fbcccfbf3937e105bc..58730f68626f0e49424bc3d83a0334d90fc9e286 100644 --- a/src/Collision/SurfaceTreeIterator.h +++ b/src/Collision/SurfaceTreeIterator.h @@ -30,24 +30,24 @@ /// \brief !! template<typename CellType> -class smSurfaceTreeIterator: public smCollisionModelIterator<CellType> +class SurfaceTreeIterator: public CollisionModelIterator<CellType> { public: - smSurfaceTree<CellType> *tree; + SurfaceTree<CellType> *tree; /// \brief - smSurfaceTreeIterator(smSurfaceTree<CellType> * p_tree) + SurfaceTreeIterator(SurfaceTree<CellType> * p_tree) { tree = p_tree; } /// \brief - smSurfaceTreeIterator(const smCollisionModelIterator<CellType> &i) - : smCollisionModelIterator<CellType>() + SurfaceTreeIterator(const CollisionModelIterator<CellType> &i) + : CollisionModelIterator<CellType>() { this->tree = nullptr; - const smSurfaceTreeIterator<CellType> &otherTree = static_cast<const smSurfaceTreeIterator<CellType>&>(i); + const SurfaceTreeIterator<CellType> &otherTree = static_cast<const SurfaceTreeIterator<CellType>&>(i); if(otherTree.tree) this->tree = otherTree.tree; this->startIndex = i.startIndex; @@ -98,7 +98,7 @@ public: return this->endIndex; } - friend smSurfaceTree<CellType>; + friend SurfaceTree<CellType>; }; #endif diff --git a/src/Collision/UnitTests/CollisionPairSpec.cpp b/src/Collision/UnitTests/CollisionPairSpec.cpp index 82da3dc03cc39d401fd18d88fc286968193288a9..e4bbd7e7956cbd3e0956bf23c0a564fa110ae2af 100644 --- a/src/Collision/UnitTests/CollisionPairSpec.cpp +++ b/src/Collision/UnitTests/CollisionPairSpec.cpp @@ -33,13 +33,13 @@ using namespace bandit; go_bandit([](){ describe("Collision pair", []() { it("constructs ", []() { - std::unique_ptr<smCollisionPair> collisionPair(make_unique<smCollisionPair>()); + std::unique_ptr<CollisionPair> collisionPair(make_unique<CollisionPair>()); }); it("attaches models ", []() { - std::unique_ptr<smCollisionPair> collisionPair(make_unique<smCollisionPair>()); + std::unique_ptr<CollisionPair> collisionPair(make_unique<CollisionPair>()); - std::shared_ptr<smModelRepresentation> modelA = std::make_shared<smMeshCollisionModel>(); - std::shared_ptr<smModelRepresentation> modelB = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<ModelRepresentation> modelA = std::make_shared<MeshCollisionModel>(); + std::shared_ptr<ModelRepresentation> modelB = std::make_shared<MeshCollisionModel>(); collisionPair->setModels(modelA,modelB); @@ -48,14 +48,14 @@ go_bandit([](){ }); it("attaches contacts ", []() { - std::unique_ptr<smCollisionPair> collisionPair(make_unique<smCollisionPair>()); + std::unique_ptr<CollisionPair> collisionPair(make_unique<CollisionPair>()); float depth = 1.0; - smVec3d contactPoint(0,0,1); - smVec3d normal(1,0,0); + core::Vec3d contactPoint(0,0,1); + core::Vec3d normal(1,0,0); collisionPair->addContact(depth,contactPoint,1,normal); - std::shared_ptr<smContact> contact = collisionPair->getContacts().back(); + std::shared_ptr<Contact> contact = collisionPair->getContacts().back(); AssertThat(collisionPair->hasContacts(), IsTrue()); AssertThat(contact->normal, Equals(normal)); diff --git a/src/Collision/UnitTests/MeshCollisionModelSpec.cpp b/src/Collision/UnitTests/MeshCollisionModelSpec.cpp index a7ea208517d6674e8a1c741811463f926f1d6ab6..c2f1c63e3a8a4b2c6114c0da32397dd7a65311e7 100644 --- a/src/Collision/UnitTests/MeshCollisionModelSpec.cpp +++ b/src/Collision/UnitTests/MeshCollisionModelSpec.cpp @@ -32,10 +32,10 @@ using namespace bandit; go_bandit([](){ describe("Mesh collision model used by collision detection algorithms.", []() { it("construct ", []() { - std::unique_ptr<smMeshCollisionModel> meshCollisionModel = make_unique<smMeshCollisionModel>(); + std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); }); it("loads mesh ", []() { - std::unique_ptr<smMeshCollisionModel> meshCollisionModel = make_unique<smMeshCollisionModel>(); + std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); @@ -45,7 +45,7 @@ go_bandit([](){ }); it("can access positions ", []() { - std::unique_ptr<smMeshCollisionModel> meshCollisionModel = make_unique<smMeshCollisionModel>(); + std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); meshCollisionModel->setMesh(mesh); @@ -54,7 +54,7 @@ go_bandit([](){ mesh->initVertexArrays(4); mesh->initTriangleArrays(2); - smStdVector3d vertices; + core::StdVector3d vertices; vertices.emplace_back(1.0,2.0,-1.0); vertices.emplace_back(2.0,3.0,1.0); vertices.emplace_back(2.0,1.0,-1.0); @@ -92,7 +92,7 @@ go_bandit([](){ AssertThat(meshCollisionModel->getTrianglePositions(1)[2], Equals(vertices[3])); }); it("can access normals ", []() { - std::unique_ptr<smMeshCollisionModel> meshCollisionModel = make_unique<smMeshCollisionModel>(); + std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); meshCollisionModel->setMesh(mesh); @@ -101,7 +101,7 @@ go_bandit([](){ mesh->initVertexArrays(4); mesh->initTriangleArrays(2); - smStdVector3d vertices; + core::StdVector3d vertices; vertices.emplace_back(1.0,2.0,-1.0); vertices.emplace_back(2.0,3.0,1.0); vertices.emplace_back(2.0,1.0,-1.0); @@ -131,14 +131,14 @@ go_bandit([](){ mesh->allocateAABBTris(); - smVec3d normalA = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]).normalized(); - smVec3d normalB = (vertices[2]-vertices[1]).cross(vertices[3]-vertices[1]).normalized(); + core::Vec3d normalA = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]).normalized(); + core::Vec3d normalB = (vertices[2]-vertices[1]).cross(vertices[3]-vertices[1]).normalized(); AssertThat((meshCollisionModel->getNormal(0)-normalA).squaredNorm(), EqualsWithDelta(0.0,.00001)); AssertThat((meshCollisionModel->getNormal(1)-normalB).squaredNorm(), EqualsWithDelta(0.0,.00001)); }); it("create BVH ", []() { - std::unique_ptr<smMeshCollisionModel> meshCollisionModel = make_unique<smMeshCollisionModel>(); + std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); meshCollisionModel->setMesh(mesh); @@ -147,7 +147,7 @@ go_bandit([](){ mesh->initVertexArrays(4); mesh->initTriangleArrays(2); - smStdVector3d vertices; + core::StdVector3d vertices; vertices.emplace_back(1.0,2.0,-1.0); vertices.emplace_back(2.0,3.0,1.0); vertices.emplace_back(2.0,1.0,-1.0); @@ -176,8 +176,8 @@ go_bandit([](){ mesh->upadateAABB(); mesh->allocateAABBTris(); - std::shared_ptr<smMeshCollisionModel::AABBTreeType> - modelAabbTree = std::make_shared<smMeshCollisionModel::AABBTreeType>( + std::shared_ptr<MeshCollisionModel::AABBTreeType> + modelAabbTree = std::make_shared<MeshCollisionModel::AABBTreeType>( std::static_pointer_cast<smSurfaceMesh>(mesh),6); modelAabbTree->initStructure(); diff --git a/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp b/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp index f4f62aefb8ba530ede7f0bd70fb9e1642198760c..d33d3d2b340056bf125e82a7058cf4550830538e 100644 --- a/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp +++ b/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp @@ -31,9 +31,9 @@ using namespace bandit; -std::shared_ptr<smMeshCollisionModel> getModel(const smStdVector3d &vertices) +std::shared_ptr<MeshCollisionModel> getModel(const core::StdVector3d &vertices) { - std::shared_ptr<smMeshCollisionModel> model = std::make_shared<smMeshCollisionModel>(); + std::shared_ptr<MeshCollisionModel> model = std::make_shared<MeshCollisionModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); // Add two triangles to the data structure @@ -66,27 +66,27 @@ std::shared_ptr<smMeshCollisionModel> getModel(const smStdVector3d &vertices) go_bandit([](){ describe("BVH Collision Detection Algorithm", []() { it("constructs ", []() { - std::unique_ptr<smCollisionDetection> meshToMeshCollision = make_unique<smMeshToMeshCollision>(); + std::unique_ptr<CollisionDetection> meshToMeshCollision = make_unique<MeshToMeshCollision>(); AssertThat(meshToMeshCollision == nullptr, IsFalse()); }); it("performs collision detection ", []() { - std::unique_ptr<smCollisionDetection> meshToMeshCollision = make_unique<smMeshToMeshCollision>(); + std::unique_ptr<CollisionDetection> meshToMeshCollision = make_unique<MeshToMeshCollision>(); - smStdVector3d verticesA; + core::StdVector3d verticesA; verticesA.emplace_back(1.0,2.0,0); verticesA.emplace_back(2.0,3.0,0); verticesA.emplace_back(2.0,1.0,0); - smStdVector3d verticesB; + core::StdVector3d verticesB; verticesB.emplace_back(1.0,2.0,0.5); verticesB.emplace_back(2.0,3.0,0); verticesB.emplace_back(2.0,1.0,0); - std::shared_ptr<smModelRepresentation> modelA = getModel(verticesA); + std::shared_ptr<ModelRepresentation> modelA = getModel(verticesA); - std::shared_ptr<smModelRepresentation> modelB = getModel(verticesB); + std::shared_ptr<ModelRepresentation> modelB = getModel(verticesB); - std::shared_ptr<smCollisionPair> collisionPair = std::make_shared<smCollisionPair>(); + std::shared_ptr<CollisionPair> collisionPair = std::make_shared<CollisionPair>(); collisionPair->setModels(modelA,modelB); diff --git a/src/Collision/UnitTests/OctreeCellSpec.cpp b/src/Collision/UnitTests/OctreeCellSpec.cpp index 62814c255cd69f5dc8b6963414024cd6f145f1c9..b380afc5b94dd477f206aac4ec2e157df8bcdc10 100644 --- a/src/Collision/UnitTests/OctreeCellSpec.cpp +++ b/src/Collision/UnitTests/OctreeCellSpec.cpp @@ -32,11 +32,11 @@ using namespace bandit; go_bandit([](){ describe("octree data structure", []() { - smOctreeCell treeCell; + OctreeCell treeCell; - const int numberOfSubdivisions = smOctreeCell::numberOfSubdivisions; + const int numberOfSubdivisions = OctreeCell::numberOfSubdivisions; - smVec3d center(1.,1.,1.); + core::Vec3d center(1.,1.,1.); treeCell.setCenter(center); float lenght = 14.5; diff --git a/src/Collision/UnitTests/SpatialHashSpec.cpp b/src/Collision/UnitTests/SpatialHashSpec.cpp index b5932aadb30ebcb2b9d4b8bc0d0b4efbf7f6f0f0..488e65766c52029e315fd1aaee758d9222bec1e4 100644 --- a/src/Collision/UnitTests/SpatialHashSpec.cpp +++ b/src/Collision/UnitTests/SpatialHashSpec.cpp @@ -25,7 +25,6 @@ #include "Collision/SpatialHashCollision.h" #include "Core/ErrorLog.h" -#include "Core/Pipe.h" #include "Core/MakeUnique.h" using namespace bandit; @@ -34,7 +33,7 @@ go_bandit([](){ describe("the spatial hash collision detector", []() { it("initializes properly ", []() { - std::unique_ptr<smSpatialHashCollision> spatialHash(make_unique<smSpatialHashCollision>(10,1.0,1.0,1.0)); + std::unique_ptr<SpatialHashCollision> spatialHash(make_unique<SpatialHashCollision>(10,1.0,1.0,1.0)); // AssertThat( spatialHash->pipe->getElements(), Equals( 1 ) ); // AssertThat( spatialHash->pipeTriangles->getElements(), Equals( 1 ) ); diff --git a/src/ContactHandling/PenaltyContactFemToStatic.cpp b/src/ContactHandling/PenaltyContactFemToStatic.cpp index fac15fa8a2cda8dc9dd6a2758fe17aa51dcc8582..841d8076fe80c77764a4493700082e54323c198c 100644 --- a/src/ContactHandling/PenaltyContactFemToStatic.cpp +++ b/src/ContactHandling/PenaltyContactFemToStatic.cpp @@ -25,31 +25,31 @@ #include "Core/CollisionPair.h" -smPenaltyContactFemToStatic::smPenaltyContactFemToStatic(bool typeBilateral) : smPenaltyContactHandling(typeBilateral) +PenaltyContactFemToStatic::PenaltyContactFemToStatic(bool typeBilateral) : PenaltyContactHandling(typeBilateral) { - type = smContactHandlingType::PenaltyFemToStatic; + type = ContactHandlingType::PenaltyFemToStatic; } -smPenaltyContactFemToStatic::smPenaltyContactFemToStatic( +PenaltyContactFemToStatic::PenaltyContactFemToStatic( bool typeBilateral, - const std::shared_ptr<smSceneObject>& sceneObjFirst, - const std::shared_ptr<smSceneObject>& sceneObjSecond) - : smPenaltyContactHandling(typeBilateral, sceneObjFirst, sceneObjSecond) + const std::shared_ptr<SceneObject>& sceneObjFirst, + const std::shared_ptr<SceneObject>& sceneObjSecond) + : PenaltyContactHandling(typeBilateral, sceneObjFirst, sceneObjSecond) { - type = smContactHandlingType::PenaltyFemToStatic; + type = ContactHandlingType::PenaltyFemToStatic; } -smPenaltyContactFemToStatic::~smPenaltyContactFemToStatic() +PenaltyContactFemToStatic::~PenaltyContactFemToStatic() { } -void smPenaltyContactFemToStatic::computeUnilateralContactForces() +void PenaltyContactFemToStatic::computeUnilateralContactForces() { int penetratedNode, nodeDofID; const double stiffness = 1.0e4, damping = 1.0e5; - smVec3d velocityProjection; + core::Vec3d velocityProjection; - std::vector<std::shared_ptr<smContact>> contactInfo = this->getCollisionPairs()->getContacts(); + std::vector<std::shared_ptr<Contact>> contactInfo = this->getCollisionPairs()->getContacts(); if (this->getSecondSceneObject()->getType() == core::ClassType::VegaFemSceneObject && this->getFirstSceneObject()->getType() == core::ClassType::StaticSceneObject) @@ -57,7 +57,7 @@ void smPenaltyContactFemToStatic::computeUnilateralContactForces() auto femSceneObject = std::static_pointer_cast<smVegaFemSceneObject>(this->getSecondSceneObject()); femSceneObject->setContactForcesToZero(); - smVec3d force; + core::Vec3d force; for (int i = 0; i < contactInfo.size(); i++) { nodeDofID = 3 * contactInfo[i]->index; @@ -76,6 +76,6 @@ void smPenaltyContactFemToStatic::computeUnilateralContactForces() } } -void smPenaltyContactFemToStatic::computeBilateralContactForces() +void PenaltyContactFemToStatic::computeBilateralContactForces() { } diff --git a/src/ContactHandling/PenaltyContactFemToStatic.h b/src/ContactHandling/PenaltyContactFemToStatic.h index 3e6cc4882e20cb7e24ec1c6e42e0a1c221e4a5b2..cdfa2a6dee1466bdac5ba8995156b1516e7686d7 100644 --- a/src/ContactHandling/PenaltyContactFemToStatic.h +++ b/src/ContactHandling/PenaltyContactFemToStatic.h @@ -32,16 +32,16 @@ /// /// @brief Penalty based for contact handling /// -class smPenaltyContactFemToStatic : public smPenaltyContactHandling +class PenaltyContactFemToStatic : public PenaltyContactHandling { public: - smPenaltyContactFemToStatic(bool typeBilateral); + PenaltyContactFemToStatic(bool typeBilateral); - smPenaltyContactFemToStatic(bool typeBilateral, - const std::shared_ptr<smSceneObject>& sceneObjFirst, - const std::shared_ptr<smSceneObject>& sceneObjSecond); + PenaltyContactFemToStatic(bool typeBilateral, + const std::shared_ptr<SceneObject>& sceneObjFirst, + const std::shared_ptr<SceneObject>& sceneObjSecond); - virtual ~smPenaltyContactFemToStatic(); + virtual ~PenaltyContactFemToStatic(); /// \brief Get the forces on one the first scene object using penalty method virtual void computeUnilateralContactForces() override; diff --git a/src/ContactHandling/PenaltyContactHandling.cpp b/src/ContactHandling/PenaltyContactHandling.cpp index 06594db6ef2768022ac127e1f213be52168d9c50..07b2b22d14f7cbef011090929e981a253e3c4607 100644 --- a/src/ContactHandling/PenaltyContactHandling.cpp +++ b/src/ContactHandling/PenaltyContactHandling.cpp @@ -26,22 +26,22 @@ #include "Simulators/VegaFemSceneObject.h" #include "Core/CollisionPair.h" -smPenaltyContactHandling::smPenaltyContactHandling(bool typeBilateral) : smContactHandling(typeBilateral) +PenaltyContactHandling::PenaltyContactHandling(bool typeBilateral) : ContactHandling(typeBilateral) { } -smPenaltyContactHandling::smPenaltyContactHandling( bool typeBilateral, - const std::shared_ptr<smSceneObject>& sceneObjFirst, - const std::shared_ptr<smSceneObject>& sceneObjSecond) - : smContactHandling(typeBilateral,sceneObjFirst,sceneObjSecond) +PenaltyContactHandling::PenaltyContactHandling( bool typeBilateral, + const std::shared_ptr<SceneObject>& sceneObjFirst, + const std::shared_ptr<SceneObject>& sceneObjSecond) + : ContactHandling(typeBilateral,sceneObjFirst,sceneObjSecond) { } -smPenaltyContactHandling::~smPenaltyContactHandling() +PenaltyContactHandling::~PenaltyContactHandling() { }; -void smPenaltyContactHandling::resolveContacts() +void PenaltyContactHandling::resolveContacts() { if (!isBilateral) { diff --git a/src/ContactHandling/PenaltyContactHandling.h b/src/ContactHandling/PenaltyContactHandling.h index 62c2969339d33d809a6fd63afb5fffc77c9799c8..038ee0c682cbb9b7fc411e63cc1aef999e900fca 100644 --- a/src/ContactHandling/PenaltyContactHandling.h +++ b/src/ContactHandling/PenaltyContactHandling.h @@ -29,16 +29,16 @@ #include "Core/ContactHandling.h" /// \brief Penalty based for contact handling -class smPenaltyContactHandling : public smContactHandling +class PenaltyContactHandling : public ContactHandling { public: - smPenaltyContactHandling(bool typeBilateral); + PenaltyContactHandling(bool typeBilateral); - smPenaltyContactHandling(bool typeBilateral, - const std::shared_ptr<smSceneObject>& sceneObjFirst, - const std::shared_ptr<smSceneObject>& sceneObjSecond); + PenaltyContactHandling(bool typeBilateral, + const std::shared_ptr<SceneObject>& sceneObjFirst, + const std::shared_ptr<SceneObject>& sceneObjSecond); - virtual ~smPenaltyContactHandling(); + virtual ~PenaltyContactHandling(); void resolveContacts(); diff --git a/src/ContactHandling/UnitTests/PenaltyContactHandlingSpec.cpp b/src/ContactHandling/UnitTests/PenaltyContactHandlingSpec.cpp index 0aa27fb2a8878a84ab82c7c6d975a14e2694456e..cd2a5aa892d002ccb30e0111f52fb03ab3ae1501 100644 --- a/src/ContactHandling/UnitTests/PenaltyContactHandlingSpec.cpp +++ b/src/ContactHandling/UnitTests/PenaltyContactHandlingSpec.cpp @@ -33,11 +33,11 @@ using namespace bandit; -std::shared_ptr<smStaticSceneObject> createStaticPlaneSceneObject() +std::shared_ptr<StaticSceneObject> createStaticPlaneSceneObject() { - auto staticPlane = std::make_shared<smStaticSceneObject>(); + auto staticPlane = std::make_shared<StaticSceneObject>(); - std::shared_ptr<smPlaneCollisionModel> plane = std::make_shared<smPlaneCollisionModel>( smVec3d(0.0, 0.0, 0.0), smVec3d(0.0, 0.0, 1.0) ); + std::shared_ptr<PlaneCollisionModel> plane = std::make_shared<PlaneCollisionModel>( core::Vec3d(0.0, 0.0, 0.0), core::Vec3d(0.0, 0.0, 1.0) ); staticPlane->setModel(plane); @@ -45,13 +45,13 @@ std::shared_ptr<smStaticSceneObject> createStaticPlaneSceneObject() } -std::shared_ptr<smCollisionPair> createSampleCollisionPair() +std::shared_ptr<CollisionPair> createSampleCollisionPair() { - auto collisionPair = std::make_shared<smCollisionPair>(); + auto collisionPair = std::make_shared<CollisionPair>(); float depth = 1.0; - smVec3d contactPoint(0,0,1); - smVec3d normal(1,0,0); + core::Vec3d contactPoint(0,0,1); + core::Vec3d normal(1,0,0); collisionPair->addContact(depth,contactPoint,1,normal); @@ -65,20 +65,20 @@ go_bandit([]() { it("initializes properly ", []() { - auto handler = std::make_shared<smPenaltyContactFemToStatic>(false); + auto handler = std::make_shared<PenaltyContactFemToStatic>(false); AssertThat(handler != nullptr, IsTrue()); - AssertThat(handler->getContactHandlingType() == smContactHandlingType::PenaltyFemToStatic, IsTrue()); + AssertThat(handler->getContactHandlingType() == ContactHandlingType::PenaltyFemToStatic, IsTrue()); }); it("attches a collision pair ", []() { - auto handler = std::make_shared<smPenaltyContactFemToStatic>(false); + auto handler = std::make_shared<PenaltyContactFemToStatic>(false); auto collisionPair = createSampleCollisionPair(); handler->setCollisionPairs(collisionPair); AssertThat(handler->getCollisionPairs() == collisionPair, IsTrue()); }); it("attaches a scene object ", []() { - auto handler = std::make_shared<smPenaltyContactFemToStatic>(false); + auto handler = std::make_shared<PenaltyContactFemToStatic>(false); auto fem = std::make_shared<smVegaFemSceneObject>(); auto plane = createStaticPlaneSceneObject(); handler->setSceneObjects(plane,fem); @@ -89,7 +89,7 @@ go_bandit([]() { }); it("computes contact force ", []() { - auto handler = std::make_shared<smPenaltyContactFemToStatic>(false); + auto handler = std::make_shared<PenaltyContactFemToStatic>(false); auto fem = std::make_shared<smVegaFemSceneObject>(); auto collisionPair = createSampleCollisionPair(); auto plane = createStaticPlaneSceneObject(); diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 3b78e32d56c48d3eb97209f0ae2023a330e58ac2..4e7ea648ff191c469525baca687f9d01fd4f7086 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -15,7 +15,6 @@ simmedtk_add_library(Core Geometry.cpp IOStream.cpp Light.cpp - Math.cpp Module.cpp ObjectSimulator.cpp RenderDetail.cpp @@ -25,7 +24,6 @@ simmedtk_add_library(Core Simulator.cpp StaticSceneObject.cpp Timer.cpp - Pipe.cpp UnifiedId.cpp ViewerBase.cpp PUBLIC_HEADERS @@ -38,7 +36,6 @@ simmedtk_add_library(Core CoreClass.h Dispatcher.h DisplayText.h - Pipe.h ErrorLog.h EventData.h Event.h @@ -50,7 +47,6 @@ simmedtk_add_library(Core MemoryBlock.h Module.h ObjectSimulator.h - Pipe.h Scene.h SceneObject.h Scheduler.h diff --git a/src/Core/CollisionConfig.cpp b/src/Core/CollisionConfig.cpp index b6ceaaab8ae64e1a6b87046cf5c419e89457d864..3ea01b95c4d1729d09767f04acc0901e50806676 100644 --- a/src/Core/CollisionConfig.cpp +++ b/src/Core/CollisionConfig.cpp @@ -23,17 +23,17 @@ #include "CollisionConfig.h" -bool smCellTriangle::operator==( unsigned int p_ID ) +bool CellTriangle::operator==( unsigned int p_ID ) { return ( primID == p_ID ? true : false ); } -bool smCellTriangle::operator==( smCellTriangle &p_tri ) +bool CellTriangle::operator==( CellTriangle &p_tri ) { return ( p_tri.primID == primID ? true : false ); } -std::ostream &operator<<( std::ostream &out, smCellTriangle &tri ) +std::ostream &operator<<( std::ostream &out, CellTriangle &tri ) { out << tri.primID; return out; diff --git a/src/Core/CollisionConfig.h b/src/Core/CollisionConfig.h index 8489556482234f9b2e4f393f6551ee3159960c22..d3e74bfc8b64e07216b8aca13f62fe838f242458 100644 --- a/src/Core/CollisionConfig.h +++ b/src/Core/CollisionConfig.h @@ -33,19 +33,19 @@ struct GeometryRepresentation {}; /// \brief Contains information related to the triangles that are present in a cell /// at any given point -struct smCellTriangle : public GeometryRepresentation +struct CellTriangle : public GeometryRepresentation { - smCellTriangle() : primID(0) {} - smCellTriangle(const unsigned int &id) : primID(id) {} + CellTriangle() : primID(0) {} + CellTriangle(const unsigned int &id) : primID(id) {} unsigned int primID; - std::shared_ptr<smUnifiedId> meshID; - smVec3d vert[3]; + std::shared_ptr<UnifiedId> meshID; + core::Vec3d vert[3]; bool operator ==(unsigned int p_ID); - bool operator ==(smCellTriangle &p_tri); + bool operator ==(CellTriangle &p_tri); - friend std::ostream &operator<<(std::ostream &out, smCellTriangle &tri); + friend std::ostream &operator<<(std::ostream &out, CellTriangle &tri); }; /// \brief Contains information related to the a line segments that are present in a cell @@ -55,8 +55,8 @@ struct smCellLine : public GeometryRepresentation smCellLine() : primID(0) {} smCellLine(const unsigned int &id) : primID(id) {} unsigned int primID; ///< Edge id - std::shared_ptr<smUnifiedId> meshID; ///< smMeshLine id - smVec3d vert[2]; ///< Vertices + std::shared_ptr<UnifiedId> meshID; ///< smMeshLine id + core::Vec3d vert[2]; ///< Vertices bool operator ==(unsigned int p_ID); bool operator ==(smCellLine &p_line); @@ -70,8 +70,8 @@ struct smCellModel : public GeometryRepresentation smCellModel() : primID(0) {} smCellModel(const unsigned int &id) : primID(id) {} unsigned int primID; ///< Model Prim id - std::shared_ptr<smUnifiedId> meshID; ///< smMeshLine id - smVec3d center; ///< Vertices + std::shared_ptr<UnifiedId> meshID; ///< smMeshLine id + core::Vec3d center; ///< Vertices double radius; bool operator ==(unsigned int p_ID); @@ -89,8 +89,8 @@ struct smCellPoint : public GeometryRepresentation smCellPoint() : primID(0) {} smCellPoint(const unsigned int &id) : primID(id) {} unsigned int primID; ///< Model Prim id - std::shared_ptr<smUnifiedId> meshID; ///< smMeshLine id - smVec3d vert; ///< Vertices + std::shared_ptr<UnifiedId> meshID; ///< smMeshLine id + core::Vec3d vert; ///< Vertices bool operator ==(unsigned int p_ID); @@ -103,18 +103,18 @@ struct smCellPoint : public GeometryRepresentation /// \brief Contains triangle pair that have collided struct smCollidedTriangles { - smCellTriangle tri1; - smCellTriangle tri2; - smVec3d proj1, proj2; + CellTriangle tri1; + CellTriangle tri2; + core::Vec3d proj1, proj2; short point1, point2; }; /// \brief Contains line pair that have collided struct smCollidedLineTris { - smCellTriangle tri; + CellTriangle tri; smCellLine line; - smVec3d intersection; + core::Vec3d intersection; }; /// \brief Contains model-point pair that have collided diff --git a/src/Core/CollisionDetection.cpp b/src/Core/CollisionDetection.cpp index 1b2fe12bc42ae505368eeaefdb5321bbe6383ad2..cd55e24be8f1d92fe548f56fd4056d61feaf56bc 100644 --- a/src/Core/CollisionDetection.cpp +++ b/src/Core/CollisionDetection.cpp @@ -23,7 +23,7 @@ #include "CollisionDetection.h" -void smCollisionDetection::computeCollision(std::shared_ptr< smCollisionPair > pairs) +void CollisionDetection::computeCollision(std::shared_ptr< CollisionPair > pairs) { this->doComputeCollision(pairs); } diff --git a/src/Core/CollisionDetection.h b/src/Core/CollisionDetection.h index 1a1cfb72c6e9a0967db532ee26c1b690201cbe14..1a75e8b116e2c333ab675b16929c948ca285d40c 100644 --- a/src/Core/CollisionDetection.h +++ b/src/Core/CollisionDetection.h @@ -31,22 +31,22 @@ #include "CoreClass.h" class smMesh; -class smCollisionPair; +class CollisionPair; /// \brief Base class to calculate contact information between two meshes /// It determines if two meshes are in close proximity and calculates contacts /// if they are. -class smCollisionDetection: public smCoreClass +class CollisionDetection: public CoreClass { public: - smCollisionDetection() {} + CollisionDetection() {} - virtual ~smCollisionDetection() {} + virtual ~CollisionDetection() {} - void computeCollision(std::shared_ptr<smCollisionPair> pairs); + void computeCollision(std::shared_ptr<CollisionPair> pairs); private: - virtual void doComputeCollision(std::shared_ptr<smCollisionPair> pairs) = 0; + virtual void doComputeCollision(std::shared_ptr<CollisionPair> pairs) = 0; }; #endif diff --git a/src/Core/CollisionModel.h b/src/Core/CollisionModel.h deleted file mode 100644 index 9749fa430150d5aa0631d04377dc1da2afecd24d..0000000000000000000000000000000000000000 --- a/src/Core/CollisionModel.h +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and 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 -// -// 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. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef SM_COLLISIONMODEL_H -#define SM_COLLISIONMODEL_H - -// SimMedTK includes -#include "CoreClass.h" -#include "CollisionModelIterator.h" -#include "Matrix.h" - -/// \brief !! -template<typename T> -class smCollisionModel: public smCoreClass -{ -protected: - typedef smMatrix44f MatrixType; - -public: - /// \brief !! - virtual void initStructure() = 0; - - /// \brief !! - virtual void reCreateStructure() = 0; - - /// \brief !! - virtual void updateStructure() = 0; - - /// \brief !! - virtual void translateRot() = 0; - - /// \brief !! - virtual void setTranslateRot(MatrixType &) = 0; - - /// \brief !! - virtual smCollisionModelIterator<T> getLevelIterator(int level) = 0; - - /// \brief !! - virtual smCollisionModelIterator<T> getLevelIterator() = 0; -}; - - -#endif diff --git a/src/Core/CollisionModelIterator.h b/src/Core/CollisionModelIterator.h index cf9cf551bbae33a136ff5cc7f6ea4b91a4e6fd44..dfe17ff9dcbc8a436b5adefa3f28a0eaab6a391d 100644 --- a/src/Core/CollisionModelIterator.h +++ b/src/Core/CollisionModelIterator.h @@ -26,7 +26,7 @@ /// \brief !! template <typename T> -class smCollisionModelIterator +class CollisionModelIterator { public: diff --git a/src/Core/CollisionPair.cpp b/src/Core/CollisionPair.cpp index 920f6a0bb66636f38364e543ec975735b1a1a769..14612776c9d41589c751a59f6fdc9b394c032ed3 100644 --- a/src/Core/CollisionPair.cpp +++ b/src/Core/CollisionPair.cpp @@ -23,65 +23,65 @@ #include "CollisionPair.h" -smCollisionPair::smCollisionPair() {} -smCollisionPair::~smCollisionPair() {} +CollisionPair::CollisionPair() {} +CollisionPair::~CollisionPair() {} -void smCollisionPair::setModels(const std::shared_ptr< smModelRepresentation >& first, - const std::shared_ptr< smModelRepresentation >& second) +void CollisionPair::setModels(const std::shared_ptr< ModelRepresentation >& first, + const std::shared_ptr< ModelRepresentation >& second) { this->modelRepresentations.first = first; this->modelRepresentations.second = second; } -void smCollisionPair::addContact(const double& penetrationDepth, const smVec3d& vert, const int index, const smVec3d& contactNornmal) +void CollisionPair::addContact(const double& penetrationDepth, const core::Vec3d& vert, const int index, const core::Vec3d& contactNornmal) { - auto contact = std::make_shared<smContact>(penetrationDepth, vert, index, contactNornmal); + auto contact = std::make_shared<Contact>(penetrationDepth, vert, index, contactNornmal); //std::shared_ptr<smContact> contact(new smContact(penetrationDepth, vert, index, contactNornmal)); this->contacts.emplace_back(contact); } -const std::pair< std::shared_ptr< smModelRepresentation >, std::shared_ptr< smModelRepresentation > >& -smCollisionPair::getModels() const +const std::pair< std::shared_ptr< ModelRepresentation >, std::shared_ptr< ModelRepresentation > >& +CollisionPair::getModels() const { return modelRepresentations; } -void smCollisionPair::clearContacts() +void CollisionPair::clearContacts() { contacts.clear(); } -int smCollisionPair::getNumberOfContacts() +int CollisionPair::getNumberOfContacts() { return contacts.size(); } -std::shared_ptr< smModelRepresentation > smCollisionPair::getFirst() +std::shared_ptr< ModelRepresentation > CollisionPair::getFirst() { return this->modelRepresentations.first; } -std::shared_ptr< smModelRepresentation > smCollisionPair::getSecond() +std::shared_ptr< ModelRepresentation > CollisionPair::getSecond() { return this->modelRepresentations.second; } -bool smCollisionPair::hasContacts() +bool CollisionPair::hasContacts() { return !this->contacts.empty(); } -std::vector< std::shared_ptr< smContact > >& smCollisionPair::getContacts() +std::vector< std::shared_ptr< Contact > >& CollisionPair::getContacts() { return contacts; } -const std::vector< std::shared_ptr< smContact > >& smCollisionPair::getContacts() const +const std::vector< std::shared_ptr< Contact > >& CollisionPair::getContacts() const { return contacts; } -void smCollisionPair::printCollisionPairs() +void CollisionPair::printCollisionPairs() { std::cout << "# Contacts: " << this->contacts.size() << std::endl; for (int i = 0; i < this->contacts.size(); i++) diff --git a/src/Core/CollisionPair.h b/src/Core/CollisionPair.h index dfdaede52688bc24deff2e50678e7d45617d3248..7351b2a09f959c40be112fcc41a771f9b4e9d643 100644 --- a/src/Core/CollisionPair.h +++ b/src/Core/CollisionPair.h @@ -33,18 +33,18 @@ #include <vector> #include <iostream> -class smModelRepresentation; +class ModelRepresentation; /// /// \brief Contact point representation /// -class smContact +class Contact { public: - smContact ( const double penetrationDepth, - const smVec3d& p, + Contact ( const double penetrationDepth, + const core::Vec3d& p, const int ind, - const smVec3d& contactNornmal + const core::Vec3d& contactNornmal ) : depth(penetrationDepth), point(p), index(ind), normal(contactNornmal){} void printInfo() @@ -56,8 +56,8 @@ public: } double depth; - smVec3d point; - smVec3d normal; + core::Vec3d point; + core::Vec3d normal; int index; }; @@ -65,31 +65,31 @@ public: /// \brief Contains pair of potential collision models /// This class also stores contacts between those models. /// -class smCollisionPair +class CollisionPair { public: - smCollisionPair(); - ~smCollisionPair(); + CollisionPair(); + ~CollisionPair(); /// /// @brief Set the pair of collision models /// - void setModels(const std::shared_ptr<smModelRepresentation>& first, - const std::shared_ptr<smModelRepresentation>& second ); + void setModels(const std::shared_ptr<ModelRepresentation>& first, + const std::shared_ptr<ModelRepresentation>& second ); /// /// @brief Get the pair of collision models /// - const std::pair<std::shared_ptr<smModelRepresentation>, std::shared_ptr<smModelRepresentation>>& + const std::pair<std::shared_ptr<ModelRepresentation>, std::shared_ptr<ModelRepresentation>>& getModels() const; /// /// @brief Add contact between the models /// void addContact( const double& penetrationDepth, - const smVec3d& vert, + const core::Vec3d& vert, const int index, - const smVec3d& contactNornmal); + const core::Vec3d& contactNornmal); /// /// @brief Clear contact list @@ -99,12 +99,12 @@ public: /// /// @brief Get first model /// - std::shared_ptr<smModelRepresentation> getFirst(); + std::shared_ptr<ModelRepresentation> getFirst(); /// /// @brief Get second model /// - std::shared_ptr<smModelRepresentation> getSecond(); + std::shared_ptr<ModelRepresentation> getSecond(); /// /// @brief Returns wether the contact container is empty @@ -119,8 +119,8 @@ public: /// /// @brief Returns contact array for these two models /// - std::vector<std::shared_ptr<smContact>> &getContacts(); - const std::vector<std::shared_ptr<smContact>> &getContacts() const; + std::vector<std::shared_ptr<Contact>> &getContacts(); + const std::vector<std::shared_ptr<Contact>> &getContacts() const; /// /// @brief Returns contact array for these two models @@ -128,10 +128,10 @@ public: void printCollisionPairs(); private: - std::pair<std::shared_ptr<smModelRepresentation>, - std::shared_ptr<smModelRepresentation>> modelRepresentations; // Models + std::pair<std::shared_ptr<ModelRepresentation>, + std::shared_ptr<ModelRepresentation>> modelRepresentations; // Models - std::vector<std::shared_ptr<smContact>> contacts; // List of contacts + std::vector<std::shared_ptr<Contact>> contacts; // List of contacts }; #endif // SMCOLLISIONPAIR_H diff --git a/src/Core/Color.cpp b/src/Core/Color.cpp index de98ea924f574dfd07cf128cf2354cd0d0db4708..442b60b43b3a0327cc8c3f0ed4215ee7b4ff07ed 100644 --- a/src/Core/Color.cpp +++ b/src/Core/Color.cpp @@ -16,15 +16,15 @@ #include "Color.h" -smColor smColor::colorWhite(1.0, 1.0, 1.0, 1.0); -smColor smColor::colorBlue(0.0, 0.0, 1.0, 1.0); -smColor smColor::colorGreen(0.0, 1.0, 0.0, 1.0); -smColor smColor::colorRed(1.0, 0.0, 0.0, 1.0); -smColor smColor::colorGray(0.8, 0.8, 0.8, 1.0); -smColor smColor::colorYellow(1, 1, 0, 1); -smColor smColor::colorPink(1, 0, 1, 1); +Color Color::colorWhite(1.0, 1.0, 1.0, 1.0); +Color Color::colorBlue(0.0, 0.0, 1.0, 1.0); +Color Color::colorGreen(0.0, 1.0, 0.0, 1.0); +Color Color::colorRed(1.0, 0.0, 0.0, 1.0); +Color Color::colorGray(0.8, 0.8, 0.8, 1.0); +Color Color::colorYellow(1, 1, 0, 1); +Color Color::colorPink(1, 0, 1, 1); -smColor::smColor() +Color::Color() { rgba[0] = 0.8f; rgba[1] = 0.8f; @@ -32,7 +32,7 @@ smColor::smColor() rgba[3] = 1.0f; } -smColor::smColor( float r, float g, float b, float a ) +Color::Color( float r, float g, float b, float a ) { rgba[0] = r; rgba[1] = g; @@ -40,7 +40,7 @@ smColor::smColor( float r, float g, float b, float a ) rgba[3] = a; } -void smColor::darken( float p_darkFactor ) +void Color::darken( float p_darkFactor ) { rgba[0] = ( rgba[1] - rgba[1] * ( p_darkFactor ) ); @@ -51,7 +51,7 @@ void smColor::darken( float p_darkFactor ) rgba[2] = ( rgba[2] < 0 ? 0 : rgba[2] ); } -void smColor::lighten( float p_darkFactor ) +void Color::lighten( float p_darkFactor ) { rgba[0] = rgba[1] + rgba[1] * ( p_darkFactor ); @@ -63,7 +63,7 @@ void smColor::lighten( float p_darkFactor ) rgba[2] = ( rgba[2] < 1.0 ? 1.0 : rgba[2] ); } -float smColor::operator()( int p_i ) +float Color::operator()( int p_i ) { if ( p_i < 0 || p_i > 3 ) { @@ -73,7 +73,7 @@ float smColor::operator()( int p_i ) return rgba[p_i]; } -smColor &smColor::operator=(const smColor &p_color ) +Color &Color::operator=(const Color &p_color ) { rgba[0] = p_color.rgba[0]; rgba[1] = p_color.rgba[1]; @@ -82,17 +82,17 @@ smColor &smColor::operator=(const smColor &p_color ) return *this; } -GLfloat *smColor::toGLColor() +GLfloat *Color::toGLColor() { return static_cast<GLfloat*>(rgba); } -const GLfloat *smColor::toGLColor() const +const GLfloat *Color::toGLColor() const { return static_cast<const GLfloat*>(rgba); } -void smColor::setValue( float p_red, float p_green, float p_blue, float p_alpha ) +void Color::setValue( float p_red, float p_green, float p_blue, float p_alpha ) { rgba[0] = p_red; rgba[1] = p_green; diff --git a/src/Core/Color.h b/src/Core/Color.h index 26ddf46141bdfa2eaff40802bb536edc3a235de8..dedb80ef29d4668af131b48b0990892a500ab2e2 100644 --- a/src/Core/Color.h +++ b/src/Core/Color.h @@ -18,7 +18,7 @@ #include "Config.h" -struct smColor +struct Color { union { @@ -31,8 +31,8 @@ struct smColor float a; }; }; - smColor(); - smColor(float r, float g, float b, float a = 1.0); + Color(); + Color(float r, float g, float b, float a = 1.0); /// \brief Dark ratio. the valu is between 0 and 1.0 void darken(float p_darkFactor); @@ -42,20 +42,20 @@ struct smColor /// \brief returns the color value given with the index float operator()(int p_i); /// \brief setting - smColor &operator=(const smColor &p_color); + Color &operator=(const Color &p_color); /// \brief converts to gl color GLfloat* toGLColor(); const GLfloat* toGLColor() const; /// \brief set RGB color void setValue(float p_red, float p_green, float p_blue, float p_alpha); - static smColor colorWhite; - static smColor colorBlue; - static smColor colorGreen; - static smColor colorRed; - static smColor colorGray; - static smColor colorPink; - static smColor colorYellow; + static Color colorWhite; + static Color colorBlue; + static Color colorGreen; + static Color colorRed; + static Color colorGray; + static Color colorPink; + static Color colorYellow; }; #endif // SMCOLOR_H diff --git a/src/Core/Config.h b/src/Core/Config.h index da44ec0aa8cd82516fb4d6ad10f502b701ffcc2f..b0509b2615331982657171e31a3342165940b7f2 100644 --- a/src/Core/Config.h +++ b/src/Core/Config.h @@ -37,9 +37,9 @@ #ifdef _WIN32 #ifndef MINGW32 - #define NOMINMAX +# define NOMINMAX #endif -#include <windows.h> +# include <windows.h> #endif #include <GL/glew.h> @@ -134,7 +134,7 @@ enum class ClassDrawOrder AfterObjects }; -} +} // namespace core // FIXME: This is currently hardwired into CMake, but must change // once we get SimMedTK declspec'd and building dynamically // on Windows. diff --git a/src/Core/ContactHandling.cpp b/src/Core/ContactHandling.cpp index ee49de64909a7670fa350f7d436bad76fa768f0c..f34bd68f68b344e7a191143042a2d73a6923c984 100644 --- a/src/Core/ContactHandling.cpp +++ b/src/Core/ContactHandling.cpp @@ -23,7 +23,7 @@ #include "ContactHandling.h" -smContactHandling::smContactHandling(const bool typeBilateral) +ContactHandling::ContactHandling(const bool typeBilateral) { if (typeBilateral) { @@ -34,12 +34,12 @@ smContactHandling::smContactHandling(const bool typeBilateral) isBilateral = false; } - type = smContactHandlingType::UNKNOWN; + type = ContactHandlingType::UNKNOWN; }; -smContactHandling::smContactHandling(const bool typeBilateral, - const std::shared_ptr< smSceneObject > first, - const std::shared_ptr< smSceneObject > second) +ContactHandling::ContactHandling(const bool typeBilateral, + const std::shared_ptr< SceneObject > first, + const std::shared_ptr< SceneObject > second) { if (typeBilateral) { @@ -52,47 +52,47 @@ smContactHandling::smContactHandling(const bool typeBilateral, setSceneObjects(first, second); - type = smContactHandlingType::UNKNOWN; + type = ContactHandlingType::UNKNOWN; } -smContactHandling::~smContactHandling() +ContactHandling::~ContactHandling() { } /// \brief Set the scene objects that are colliding -void smContactHandling::setSceneObjects(const std::shared_ptr< smSceneObject > first, - const std::shared_ptr< smSceneObject > second) +void ContactHandling::setSceneObjects(const std::shared_ptr< SceneObject > first, + const std::shared_ptr< SceneObject > second) { collidingSceneObjects.first = first; collidingSceneObjects.second = second; } -void smContactHandling::setCollisionPairs(const std::shared_ptr< smCollisionPair > colPair) +void ContactHandling::setCollisionPairs(const std::shared_ptr< CollisionPair > colPair) { collisionPairs = colPair; } -std::shared_ptr<smCollisionPair> smContactHandling::getCollisionPairs() const +std::shared_ptr<CollisionPair> ContactHandling::getCollisionPairs() const { return collisionPairs; } -smContactHandlingType smContactHandling::getContactHandlingType() const +ContactHandlingType ContactHandling::getContactHandlingType() const { return type; } -std::shared_ptr<smSceneObject> smContactHandling::getFirstSceneObject() const +std::shared_ptr<SceneObject> ContactHandling::getFirstSceneObject() const { return this->collidingSceneObjects.first; } -std::shared_ptr<smSceneObject> smContactHandling::getSecondSceneObject() const +std::shared_ptr<SceneObject> ContactHandling::getSecondSceneObject() const { return this->collidingSceneObjects.second; } -bool smContactHandling::isUnilateral() const +bool ContactHandling::isUnilateral() const { return !isBilateral; } diff --git a/src/Core/ContactHandling.h b/src/Core/ContactHandling.h index bb3643f65de194e19738db7827a60a8e62d7ea5f..f8aab6aeceb5e4862a3eae5a456a6faae610a1f5 100644 --- a/src/Core/ContactHandling.h +++ b/src/Core/ContactHandling.h @@ -32,9 +32,9 @@ #include <memory> class smMesh; -class smCollisionPair; +class CollisionPair; -enum class smContactHandlingType +enum class ContactHandlingType { PenaltyFemToStatic, UNKNOWN @@ -43,53 +43,53 @@ enum class smContactHandlingType /// \brief Base class to for handling contact for collision response /// Input: collision pairs containing the collision information /// Output: contact forces or Jacobians or projection/PBD constraints -class smContactHandling: public smCoreClass +class ContactHandling: public CoreClass { public: - smContactHandling(const bool typeBilateral); + ContactHandling(const bool typeBilateral); - smContactHandling(const bool typeBilateral, - const std::shared_ptr<smSceneObject> sceneObjFirst, - const std::shared_ptr<smSceneObject> sceneObjSecond); + ContactHandling(const bool typeBilateral, + const std::shared_ptr<SceneObject> sceneObjFirst, + const std::shared_ptr<SceneObject> sceneObjSecond); - virtual ~smContactHandling(); + virtual ~ContactHandling(); /// \brief returns true if bilateral bool isUnilateral() const; /// \brief Set the scene objects that are colliding - void setSceneObjects(const std::shared_ptr< smSceneObject > first, - const std::shared_ptr< smSceneObject > second); + void setSceneObjects(const std::shared_ptr< SceneObject > first, + const std::shared_ptr< SceneObject > second); /// \brief Set the collision pair data structure in which the information /// needs to be stored - void setCollisionPairs(const std::shared_ptr< smCollisionPair > colPair); + void setCollisionPairs(const std::shared_ptr< CollisionPair > colPair); /// \brief Get the colliison information contained in the collision pairs - std::shared_ptr<smCollisionPair> getCollisionPairs() const; + std::shared_ptr<CollisionPair> getCollisionPairs() const; /// \brief Get if the contact handling is unilateral or bilateral - smContactHandlingType getContactHandlingType() const; + ContactHandlingType getContactHandlingType() const; /// \brief Get the first scene object - std::shared_ptr<smSceneObject> getFirstSceneObject() const; + std::shared_ptr<SceneObject> getFirstSceneObject() const; /// \brief Get the second scene object - std::shared_ptr<smSceneObject> getSecondSceneObject() const; + std::shared_ptr<SceneObject> getSecondSceneObject() const; /// \brief Implementation of how the contacts between colliding /// objects is resolved virtual void resolveContacts() = 0; protected: - smContactHandlingType type; + ContactHandlingType type; bool isBilateral; - std::pair<std::shared_ptr<smSceneObject>, std::shared_ptr<smSceneObject>> collidingSceneObjects; + std::pair<std::shared_ptr<SceneObject>, std::shared_ptr<SceneObject>> collidingSceneObjects; - std::shared_ptr<smCollisionPair> collisionPairs; + std::shared_ptr<CollisionPair> collisionPairs; }; #endif //SMCONTACTHANDLING_H diff --git a/src/Core/CoreClass.cpp b/src/Core/CoreClass.cpp index 2fd85b051ebad8afdaf594c429fd38aaefdb0652..7f0d761550b8bf83022fd35d33c44b55b9820ce9 100644 --- a/src/Core/CoreClass.cpp +++ b/src/Core/CoreClass.cpp @@ -27,88 +27,88 @@ #include "RenderDelegate.h" std::shared_ptr<mstk::Event::smEventHandler> -smCoreClass::eventHandler = std::make_shared<mstk::Event::smEventHandler>(); +CoreClass::eventHandler = std::make_shared<mstk::Event::smEventHandler>(); -smCoreClass::smCoreClass() : +CoreClass::CoreClass() : name(""), listening(false) { drawOrder = core::ClassDrawOrder::BeforeObjects; - uniqueId = std::make_shared<smUnifiedId>(); - renderDetail = std::make_shared<smRenderDetail>(); + uniqueId = std::make_shared<UnifiedId>(); + renderDetail = std::make_shared<RenderDetail>(); } -smCoreClass::smCoreClass(const std::string &_name) : +CoreClass::CoreClass(const std::string &_name) : name(_name), listening(false) { drawOrder = core::ClassDrawOrder::BeforeObjects; - uniqueId = std::make_shared<smUnifiedId>(); - renderDetail = std::make_shared<smRenderDetail>(); + uniqueId = std::make_shared<UnifiedId>(); + renderDetail = std::make_shared<RenderDetail>(); } -const core::ClassType &smCoreClass::getType() const +const core::ClassType &CoreClass::getType() const { return type; } -void smCoreClass::setType(const core::ClassType& newType) +void CoreClass::setType(const core::ClassType& newType) { this->type = newType; } -void smCoreClass::initSimulate( const smSimulationParam &/*p_params*/ ) +void CoreClass::initSimulate( const smSimulationParam &/*p_params*/ ) { std::cout << "Default initSimulate" << std::endl; } -void smCoreClass::simulate( const smSimulationParam &/*p_params*/ ) +void CoreClass::simulate( const smSimulationParam &/*p_params*/ ) { std::cout << "Default simulate" << std::endl; } -void smCoreClass::print() const +void CoreClass::print() const { std::cout << "Default print" << std::endl; } -void smCoreClass::handleEvent(std::shared_ptr< mstk::Event::smEvent > event) +void CoreClass::handleEvent(std::shared_ptr< mstk::Event::Event > event) { std::cout << "Default handleEvent" << std::endl; std::cout << "Sender " << int(event->getSender()) << std::endl; std::cout << "Priority " << int(event->getPriority()) << std::endl; - std::cout << "Type " << int(mstk::Event::smEvent::EventName) << std::endl; + std::cout << "Type " << int(mstk::Event::Event::EventName) << std::endl; } -void smCoreClass::setName( const std::string &p_objectName ) +void CoreClass::setName( const std::string &p_objectName ) { name = p_objectName; } -const std::string &smCoreClass::getName() const +const std::string &CoreClass::getName() const { return name; } /// \brief Get render delegate -std::shared_ptr<smRenderDelegate> smCoreClass::getRenderDelegate() const +std::shared_ptr<RenderDelegate> CoreClass::getRenderDelegate() const { return this->renderDelegate; } /// \brief Set the delegate used to render this instance -void smCoreClass::setRenderDelegate(std::shared_ptr<smRenderDelegate> delegate) +void CoreClass::setRenderDelegate(std::shared_ptr<RenderDelegate> delegate) { this->renderDelegate = delegate; if (this->renderDelegate) this->renderDelegate->setSourceGeometry(this); } -void smCoreClass::initDraw() +void CoreClass::initDraw() { if (this->renderDelegate) this->renderDelegate->initDraw(); } -void smCoreClass::draw() const +void CoreClass::draw() const { if (this->renderDelegate) this->renderDelegate->draw(); diff --git a/src/Core/CoreClass.h b/src/Core/CoreClass.h index 218f299efaf664e8735fdc355ebc3dca25793f9d..655b970cd4a368a67489a9e46e92a749020446aa 100644 --- a/src/Core/CoreClass.h +++ b/src/Core/CoreClass.h @@ -36,16 +36,16 @@ #include "EventHandler.h" #include "Rendering/ConfigRendering.h" -class smSDK; -class smCoreClass; -class smRenderDelegate; -class smObjectSimulator; +class SDK; +class CoreClass; +class RenderDelegate; +class ObjectSimulator; class smViewer; /// \brief simulator calls object and sends this structure struct smSimulationParam { - std::shared_ptr<smObjectSimulator> objectSimulator; + std::shared_ptr<ObjectSimulator> objectSimulator; void *caller; void *data; }; @@ -70,10 +70,10 @@ public: /// \brief core base class of all objects in framework -class smCoreClass : public std::enable_shared_from_this<smCoreClass> +class CoreClass : public std::enable_shared_from_this<CoreClass> { public: - using Pointer = std::shared_ptr<smCoreClass>; + using Pointer = std::shared_ptr<CoreClass>; static std::shared_ptr<mstk::Event::smEventHandler> eventHandler; @@ -81,12 +81,12 @@ public: /// /// \brief Default constructor /// - smCoreClass(); + CoreClass(); /// /// \brief Default constructor /// - smCoreClass(const std::string &); + CoreClass(const std::string &); /// /// \brief get type of the class @@ -128,7 +128,7 @@ public: /// This function is called by the event handler after observing /// events. /// - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent>); + virtual void handleEvent(std::shared_ptr<mstk::Event::Event>); /// /// \brief set the name of object @@ -202,20 +202,20 @@ public: /// /// \brief Get the unique id of this object /// - std::shared_ptr<smUnifiedId> getUniqueId() {return uniqueId;} + std::shared_ptr<UnifiedId> getUniqueId() {return uniqueId;} /// \brief Get render detail - std::shared_ptr<smRenderDetail> getRenderDetail() const + std::shared_ptr<RenderDetail> getRenderDetail() const {return renderDetail;} /// \brief Set the render details (properties affecting visual depiction) - void setRenderDetail(std::shared_ptr<smRenderDetail> newRenderDetail) + void setRenderDetail(std::shared_ptr<RenderDetail> newRenderDetail) { this->renderDetail = newRenderDetail; } - std::shared_ptr<smRenderDelegate> getRenderDelegate() const; - void setRenderDelegate(std::shared_ptr<smRenderDelegate> delegate); + std::shared_ptr<RenderDelegate> getRenderDelegate() const; + void setRenderDelegate(std::shared_ptr<RenderDelegate> delegate); - void attachEvent(const mstk::Event::EventType &eventType, std::shared_ptr<smCoreClass> component) + void attachEvent(const mstk::Event::EventType &eventType, std::shared_ptr<CoreClass> component) { eventHandler->attachEvent(eventType,component); } @@ -238,18 +238,12 @@ protected: std::map< mstk::Event::EventType, mstk::Event::smEventHandler::FunctionContainerType::iterator> eventIndexMap; - std::shared_ptr<smRenderDelegate> renderDelegate; ///!< Class that can render this class + std::shared_ptr<RenderDelegate> renderDelegate; ///!< Class that can render this class private: - std::shared_ptr<smUnifiedId> uniqueId; ///< unique Id - std::shared_ptr<smRenderDetail> renderDetail; ///< specifies visualization type + std::shared_ptr<UnifiedId> uniqueId; ///< unique Id + std::shared_ptr<RenderDetail> renderDetail; ///< specifies visualization type core::ClassDrawOrder drawOrder; ///< draw order of the object }; -/// \brief for future use -class interface : public smCoreClass -{ - -}; - #endif diff --git a/src/Core/DataStructures.h b/src/Core/DataStructures.h index 80e8b78f6e4717da12c7230f4250fa0393a7991e..198c88d17ff53153f657e6ee23c09ef173492ec6 100644 --- a/src/Core/DataStructures.h +++ b/src/Core/DataStructures.h @@ -28,11 +28,11 @@ #include "Config.h" template<typename T> -class smIndiceArrayIter; +class IndiceArrayIter; /// \brief inidice array for fast access to index template<typename T> -class smIndiceArray +class IndiceArray { protected: /// \brief storage @@ -47,9 +47,9 @@ protected: int maxStorage; public: /// \brief destructor - ~smIndiceArray(); + ~IndiceArray(); /// \brief constructor; gets maximum number of elements - inline smIndiceArray(int p_maxStorage); + inline IndiceArray(int p_maxStorage); /// \brief add item inline int add(T p_item); /// \brief check if the item exists, if not add @@ -66,7 +66,7 @@ public: /// \brief get element by reference with string inline T& getByRef(std::string p_string); /// \brief for iterative access - friend smIndiceArrayIter<T>; + friend IndiceArrayIter<T>; /// \brief print the elements inline void print() const; /// \brief operators @@ -74,18 +74,18 @@ public: inline int size(); /// \brief copy from another p_array - inline bool copy(smIndiceArray &p_array); + inline bool copy(IndiceArray &p_array); }; /// \brief iteration template<class T> -class smIndiceArrayIter +class IndiceArrayIter { int index; - smIndiceArray<T> *arrayPtr; + IndiceArray<T> *arrayPtr; public: /// \brief constructor that require index array - smIndiceArrayIter(smIndiceArray<T> *p_array); + IndiceArrayIter(IndiceArray<T> *p_array); /// \brief operators for accessing and iteration T& operator[](int p_index); diff --git a/src/Core/DataStructures.hpp b/src/Core/DataStructures.hpp index 05969de8811c7861d7f5b559b2f5b8099973bec7..80c567fe41a4a671395d83c78869af392fbf2cb3 100644 --- a/src/Core/DataStructures.hpp +++ b/src/Core/DataStructures.hpp @@ -25,14 +25,14 @@ #define SMDATASTUCTURES_HPP template<typename T> -smIndiceArray<T>::~smIndiceArray() +IndiceArray<T>::~IndiceArray() { delete [] indices; delete [] storage; delete [] isEmpty; } template<typename T> -smIndiceArray<T>::smIndiceArray( int p_maxStorage ) +IndiceArray<T>::IndiceArray( int p_maxStorage ) { maxStorage = p_maxStorage; indices = new int[p_maxStorage]; @@ -47,7 +47,7 @@ smIndiceArray<T>::smIndiceArray( int p_maxStorage ) nbrElements = 0; } template<typename T> int -smIndiceArray<T>::add( T p_item ) +IndiceArray<T>::add( T p_item ) { int index = -1; @@ -75,7 +75,7 @@ smIndiceArray<T>::add( T p_item ) return index; } template<typename T> int -smIndiceArray<T>::checkAndAdd( T p_item ) +IndiceArray<T>::checkAndAdd( T p_item ) { int index = -1; @@ -93,7 +93,7 @@ smIndiceArray<T>::checkAndAdd( T p_item ) return index; } template<typename T> bool -smIndiceArray<T>::remove( int p_itemIndex ) +IndiceArray<T>::remove( int p_itemIndex ) { int counter = 0; @@ -120,7 +120,7 @@ smIndiceArray<T>::remove( int p_itemIndex ) } } template<typename T> bool -smIndiceArray<T>::replace( int p_index, T &p_item ) +IndiceArray<T>::replace( int p_index, T &p_item ) { if ( isEmpty[p_index] == false ) { @@ -131,12 +131,12 @@ smIndiceArray<T>::replace( int p_index, T &p_item ) return false; } template<typename T> -T &smIndiceArray<T>::getByRef( int p_index ) +T &IndiceArray<T>::getByRef( int p_index ) { return storage[p_index]; } template<typename T> bool -smIndiceArray<T>::getByRefSafe( int p_index, T &p_item ) +IndiceArray<T>::getByRefSafe( int p_index, T &p_item ) { if ( isEmpty[p_index] ) { @@ -149,7 +149,7 @@ smIndiceArray<T>::getByRefSafe( int p_index, T &p_item ) } } template<typename T> -T &smIndiceArray<T>::getByRef( std::string p_string ) +T &IndiceArray<T>::getByRef( std::string p_string ) { for ( int i = 0; i < nbrElements; i++ ) { @@ -160,7 +160,7 @@ T &smIndiceArray<T>::getByRef( std::string p_string ) } } template<typename T> void -smIndiceArray<T>::print() const +IndiceArray<T>::print() const { for ( int i = 0; i < nbrElements; i++ ) { @@ -168,17 +168,17 @@ smIndiceArray<T>::print() const } } template<typename T> -T &smIndiceArray<T>::operator[]( int p_index ) +T &IndiceArray<T>::operator[]( int p_index ) { return storage[indices[p_index]]; } template<typename T> int -smIndiceArray<T>::size() +IndiceArray<T>::size() { return nbrElements; } template<typename T> bool -smIndiceArray<T>::copy( smIndiceArray &p_array ) +IndiceArray<T>::copy( IndiceArray &p_array ) { if ( maxStorage < p_array.maxStorage ) { @@ -201,43 +201,43 @@ smIndiceArray<T>::copy( smIndiceArray &p_array ) } template<typename T> -smIndiceArrayIter<T>::smIndiceArrayIter( smIndiceArray< T > *p_array ) +IndiceArrayIter<T>::IndiceArrayIter( IndiceArray< T > *p_array ) { arrayPtr = p_array; } template<typename T> -T &smIndiceArrayIter<T>::operator[]( int p_index ) +T &IndiceArrayIter<T>::operator[]( int p_index ) { return arrayPtr->storage[ arrayPtr->indices[p_index]]; } template<typename T> int& -smIndiceArrayIter<T>::operator++() +IndiceArrayIter<T>::operator++() { return ++index; } template<typename T> int -smIndiceArrayIter<T>::operator++( const int ) +IndiceArrayIter<T>::operator++( const int ) { return index++; } template<typename T> int& -smIndiceArrayIter<T>::operator--() +IndiceArrayIter<T>::operator--() { return --index; } template<typename T> int -smIndiceArrayIter<T>::operator--( const int ) +IndiceArrayIter<T>::operator--( const int ) { return index--; } template<typename T> int -smIndiceArrayIter<T>::begin() +IndiceArrayIter<T>::begin() { index = 0; return index; } template<typename T> int -smIndiceArrayIter<T>::end() +IndiceArrayIter<T>::end() { return arrayPtr->nbrElements; } diff --git a/src/Core/Dispatcher.cpp b/src/Core/Dispatcher.cpp index 002a70b90de64ad568f66cdd88224cf4811fd04b..93db05bd455b494425304d11e6422662dedb96c6 100644 --- a/src/Core/Dispatcher.cpp +++ b/src/Core/Dispatcher.cpp @@ -24,22 +24,22 @@ #include "Dispatcher.h" -void smDispatcher::handleViewer(std::shared_ptr<smCoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) +void Dispatcher::handleViewer(std::shared_ptr<CoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) { } -void smDispatcher::handleSimulator(std::shared_ptr<smCoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) +void Dispatcher::handleSimulator(std::shared_ptr<CoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) { } -void smDispatcher::handleCollisionDetection(std::shared_ptr<smCoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) +void Dispatcher::handleCollisionDetection(std::shared_ptr<CoreClass> /*p_caller*/, core::CallerState /*p_callerState*/) { } -void smDispatcher::handleAll() +void Dispatcher::handleAll() { } @@ -48,7 +48,7 @@ void smDispatcher::handleAll() /// \param p_caller p_caller has pointer to the object which the function is called /// \param p_callerState p_callerState is stores the state of the at the moment of the function called. /// such as whether it is the beginning of the simulator frameor end of the simulator frame for now etc.. -core::ResultDispatcher smDispatcher::handle(std::shared_ptr<smCoreClass> p_caller, core::CallerState p_callerState) +core::ResultDispatcher Dispatcher::handle(std::shared_ptr<CoreClass> p_caller, core::CallerState p_callerState) { core::ClassType classType; @@ -77,7 +77,7 @@ core::ResultDispatcher smDispatcher::handle(std::shared_ptr<smCoreClass> p_calle handleAll(); return core::ResultDispatcher::Success; } -smDispatcher::smDispatcher() +Dispatcher::Dispatcher() { type = core::ClassType::Dispathcer; } diff --git a/src/Core/Dispatcher.h b/src/Core/Dispatcher.h index e4aaa0a993e453318191d9a067eecbade43f7d62..840fb2c43807518c72ab87b7183c99d91a6d43e0 100644 --- a/src/Core/Dispatcher.h +++ b/src/Core/Dispatcher.h @@ -31,30 +31,30 @@ ///The dispacther class is responsible of taking care of the ///tasks that need to proppgated over the whole modules.For instance, adding a new ///phyiscs at run-time -class smDispatcher: public smCoreClass +class Dispatcher: public CoreClass { private: ///handle viewer events /// \param p_caller this is the caller class /// \param p_callerState it indicates the state of the called which is predefined at the smConfig.h - void handleViewer(std::shared_ptr<smCoreClass> p_caller, core::CallerState p_callerState); + void handleViewer(std::shared_ptr<CoreClass> p_caller, core::CallerState p_callerState); ///handle simulator events - void handleSimulator(std::shared_ptr<smCoreClass> p_caller, core::CallerState p_callerState); + void handleSimulator(std::shared_ptr<CoreClass> p_caller, core::CallerState p_callerState); ///handle collision detection events - void handleCollisionDetection(std::shared_ptr<smCoreClass> p_caller, core::CallerState p_callerState); + void handleCollisionDetection(std::shared_ptr<CoreClass> p_caller, core::CallerState p_callerState); ///handle all events void handleAll(); public: - smDispatcher(); + Dispatcher(); public: ///handle all event and call corresponding events - core::ResultDispatcher handle(std::shared_ptr<smCoreClass> p_caller, core::CallerState p_callerState); + core::ResultDispatcher handle(std::shared_ptr<CoreClass> p_caller, core::CallerState p_callerState); }; diff --git a/src/Core/DisplayText.cpp b/src/Core/DisplayText.cpp index 496a7ee15be5ff93d98491ea5a8fb1c70fbe937a..9914be06da75aacd3e7646dcb764d0e6aa735f2d 100644 --- a/src/Core/DisplayText.cpp +++ b/src/Core/DisplayText.cpp @@ -29,7 +29,7 @@ // SimMedTK includes -void smDisplayText::addText ( smDisplayMessage message ) +void DisplayText::addText ( DisplayMessage message ) { switch ( message.outputStream ) { diff --git a/src/Core/DisplayText.h b/src/Core/DisplayText.h index 7729a07c7645bf531481d12e03f5beddf4e3a645..4a99794c1455f80985e3bd178eb4b39dba456912 100644 --- a/src/Core/DisplayText.h +++ b/src/Core/DisplayText.h @@ -37,7 +37,7 @@ enum SMDISPLAY_STREAM }; /// \brief message type -struct smDisplayMessage +struct DisplayMessage { /// \brief text to display std::string text; @@ -51,11 +51,11 @@ struct smDisplayMessage }; /// \brief display text class console, window, error log etc. -class smDisplayText: smCoreClass +class DisplayText: CoreClass { public: - smDisplayText(); - void addText(smDisplayMessage message); + DisplayText(); + void addText(DisplayMessage message); }; #endif diff --git a/src/Core/ErrorLog.cpp b/src/Core/ErrorLog.cpp index 05328d072f8f199abe86a3ff09b4f7e1cd8e17cc..dfc1ede97d1fbcb62251c03d6176b6077c621c65 100644 --- a/src/Core/ErrorLog.cpp +++ b/src/Core/ErrorLog.cpp @@ -27,14 +27,14 @@ #include <string> #include <chrono> -smErrorLog::smErrorLog() +ErrorLog::ErrorLog() { time.start(); consoleOutput = true; } -bool smErrorLog::addError(const std::string& p_text) +bool ErrorLog::addError(const std::string& p_text) { if (0 >= p_text.length()) { @@ -60,7 +60,7 @@ bool smErrorLog::addError(const std::string& p_text) } ///Clean up all the errors in the repository.It is thread safe. -void smErrorLog::cleanAllErrors() +void ErrorLog::cleanAllErrors() { std::lock_guard<std::mutex> lock(logLock); //Lock is released when leaves scope errors.clear(); @@ -68,19 +68,19 @@ void smErrorLog::cleanAllErrors() } ///Print the last error.It is not thread safe. -void smErrorLog::printLastErrUnsafe() +void ErrorLog::printLastErrUnsafe() { std::cout << "Last Error:" << errors.back() << " Time:" << timeStamps.back() << " ms" << "\n"; } ///Print the last error in Thread Safe manner. -void smErrorLog::printLastErr() +void ErrorLog::printLastErr() { std::lock_guard<std::mutex> lock(logLock); //Lock is released when leaves scope printLastErr(); } -void smErrorLog::setConsoleOutput(bool flag) +void ErrorLog::setConsoleOutput(bool flag) { consoleOutput = flag; } diff --git a/src/Core/ErrorLog.h b/src/Core/ErrorLog.h index a1abc5166603bc1be73256027ae4ac099d5829db..96a1002c4a33686db2f364f6a4b1878dc62225a2 100644 --- a/src/Core/ErrorLog.h +++ b/src/Core/ErrorLog.h @@ -41,19 +41,19 @@ /// \brief This is class is for error logging of the whole SimMedTK system. /// All errors should be reported to the instance of this class. /// Functions are thread-safe unless indicated. -class smErrorLog : public smCoreClass +class ErrorLog : public CoreClass { private: std::vector<std::string> errors; ///< error messages std::vector<int> timeStamps; ///< time stamps for errors std::mutex logLock; ///< mutex to sync access to logs - smTimer time; ///< Timer for timestamps + Timer time; ///< Timer for timestamps bool consoleOutput; ///< Flag to print errors to stdout public: bool isOutputtoConsoleEnabled; - smErrorLog(); + ErrorLog(); /// \brief Add the error in the repository.It is thread safe. It can be called by multiple threads. /// diff --git a/src/Core/Event.cpp b/src/Core/Event.cpp index cb735cebd938924e55365ee12b2bf8a3f839a70c..c9dd4e7230e39e9dbcb9c0094b2a04b78e589c2c 100644 --- a/src/Core/Event.cpp +++ b/src/Core/Event.cpp @@ -26,33 +26,33 @@ namespace mstk { namespace Event { -EventType smEvent::EventName = EventType::None; +EventType Event::EventName = EventType::None; -smEvent::smEvent(): priority(EventPriority::Normal), sender(EventSender::Other), enabled(true) {} +Event::Event(): priority(EventPriority::Normal), sender(EventSender::Other), enabled(true) {} -smEvent::~smEvent() {} +Event::~Event() {} -void smEvent::setPriority(const EventPriority& eventPriority) +void Event::setPriority(const EventPriority& eventPriority) { this->priority = eventPriority; } -const EventPriority& smEvent::getPriority() +const EventPriority& Event::getPriority() { return this->priority; } -void smEvent::setSender(const EventSender& eventSender) +void Event::setSender(const EventSender& eventSender) { this->sender = eventSender; } -const EventSender& smEvent::getSender() +const EventSender& Event::getSender() { return this->sender; } -void smEvent::setEnabled(const bool& eventEnabled) +void Event::setEnabled(const bool& eventEnabled) { this->enabled = eventEnabled; } -const bool& smEvent::getEnabled() +const bool& Event::getEnabled() { return this->enabled; } diff --git a/src/Core/Event.h b/src/Core/Event.h index c92602969d9a6552d156de8b59a424ba93186ca1..6406b717662ec66515fc5d9eb87c4f5f1248de6c 100644 --- a/src/Core/Event.h +++ b/src/Core/Event.h @@ -71,17 +71,17 @@ enum class EventSender /// @brief Base event class /// Base class from which all events should derive. /// -class smEvent +class Event { public: - using Pointer = std::shared_ptr<smEvent>; + using Pointer = std::shared_ptr<Event>; public: static EventType EventName; public: - smEvent(); - virtual ~smEvent(); + Event(); + virtual ~Event(); void setPriority(const EventPriority &eventPriority); diff --git a/src/Core/EventHandler.cpp b/src/Core/EventHandler.cpp index 56352e81037a330edc20d36a71615bbbea57d12f..085ec254493cc6134115d00c262800a109f646be 100644 --- a/src/Core/EventHandler.cpp +++ b/src/Core/EventHandler.cpp @@ -27,11 +27,11 @@ namespace mstk { namespace Event { -void smEventHandler::attachEvent(const EventType& eventType, std::shared_ptr<smCoreClass> component) +void smEventHandler::attachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) { - // Bind handleEvent to a void(std::shared_ptr<smEvent>) function - std::function<void(std::shared_ptr<smEvent>)> - fn = std::bind(&smCoreClass::handleEvent,component,std::placeholders::_1); + // Bind handleEvent to a void(std::shared_ptr<Event>) function + std::function<void(std::shared_ptr<Event>)> + fn = std::bind(&CoreClass::handleEvent,component,std::placeholders::_1); // Register the function and return index FunctionContainerType::iterator index = this->registerEvent(eventType, fn); @@ -39,13 +39,13 @@ void smEventHandler::attachEvent(const EventType& eventType, std::shared_ptr<smC // Add index to the component observer component->setEventIndex(eventType,index); } -void smEventHandler::detachEvent(const EventType& eventType, std::shared_ptr<smCoreClass> component) +void smEventHandler::detachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) { auto index = component->getEventIndex(eventType); this->unregisterEvent(eventType,index); component->removeEventIndex(eventType); } -bool smEventHandler::isAttached(const EventType& eventType, std::shared_ptr<smCoreClass> component) +bool smEventHandler::isAttached(const EventType& eventType, std::shared_ptr<CoreClass> component) { auto index = component->getEventIndex(eventType); diff --git a/src/Core/EventHandler.h b/src/Core/EventHandler.h index 4600ce7c1b774e6135cb890b04411bb21d79529c..65666f2107562e12503f759a7b910ec4877ae07c 100644 --- a/src/Core/EventHandler.h +++ b/src/Core/EventHandler.h @@ -35,7 +35,7 @@ // SimMedTK includes #include "Event.h" -class smCoreClass; +class CoreClass; namespace mstk { namespace Event { @@ -47,14 +47,14 @@ namespace Event { /// https://juanchopanzacpp.wordpress.com/2013/02/24/simple-observer-pattern-implementation-c11/ /// /// The only requirement is that the observer function to bind has -/// the following signature: void handleEvent(std::shared_ptr<mstk::Event::smEvent> e) -/// This means that anything inheriting from the smCoreClass can be +/// the following signature: void handleEvent(std::shared_ptr<mstk::Event::Event> e) +/// This means that anything inheriting from the CoreClass can be /// binded to an event. /// class smEventHandler { public: - using FunctionType = std::function<void ( std::shared_ptr<smEvent> )>; + using FunctionType = std::function<void ( std::shared_ptr<Event> )>; using FunctionContainerType = std::list<FunctionType>; public: @@ -96,9 +96,9 @@ public: /// /// @brief Triger all events correspontding to the event name (EventType::EventName). - /// @param event Event to be triggered, see @smEvent and derived classes. + /// @param event Event to be triggered, see @Event and derived classes. /// - /// @tparam EventObserverType The event that trigges evaluation, child class of smEvent. + /// @tparam EventObserverType The event that trigges evaluation, child class of Event. /// /// @Note If EventType::EventName is not a key in the event map, then an insertion is /// automatically performed. @@ -117,21 +117,21 @@ public: /// @param eventType Event name /// @param component Listener (or observer) of triggered events to attach /// - void attachEvent ( const EventType& eventType, std::shared_ptr<smCoreClass> component ); + void attachEvent ( const EventType& eventType, std::shared_ptr<CoreClass> component ); /// /// @brief Helper function to facilitate detachment of events. /// @param eventType Event name /// @param component Listener (or observer) of triggered events to detach /// - void detachEvent ( const EventType& eventType, std::shared_ptr<smCoreClass> component ); + void detachEvent ( const EventType& eventType, std::shared_ptr<CoreClass> component ); /// /// @brief Verify if the event has been stored. /// @param eventType Event name /// @param component Listener (or observer) of triggered events to detach /// - bool isAttached( const EventType& eventType, std::shared_ptr<smCoreClass> component ); + bool isAttached( const EventType& eventType, std::shared_ptr<CoreClass> component ); /// /// @brief Verify if the event has been stored. diff --git a/src/Core/Factory.h b/src/Core/Factory.h index 558a29e714b24ecfa0c730b2b09f2bfc21053eb8..d261da6ce376c836f600aaa4a05c0d008e1f900a 100644 --- a/src/Core/Factory.h +++ b/src/Core/Factory.h @@ -7,7 +7,7 @@ #include <set> #include <string> -/**\brief A macro to register a concrete subclass of an abstract base class with smFactory. +/**\brief A macro to register a concrete subclass of an abstract base class with Factory. * * A macro to help register a concrete subclass with a factory. * It should be called inside dynamic loader macros like so: @@ -26,17 +26,17 @@ * during your application's startup. * * This macro should only be used outside of the smCore library; - * inside smCore, just modify smFactory so that s_catalog is + * inside smCore, just modify Factory so that s_catalog is * initialized with the proper entries directly. That's because - * inside smCore, smFactory::s_catalog might not be initialized + * inside smCore, Factory::s_catalog might not be initialized * before the first registration call is made. * * A more specific example is the way the smRendering library - * registers the smViewer class as a concrete child of smViewerBase: + * registers the smViewer class as a concrete child of ViewerBase: * <pre> * SIMMEDTK_BEGIN_DYNAMIC_LOADER() * SIMMEDTK_BEGIN_ONLOAD(register_viewer_children) - * SIMMEDTK_REGISTER_CLASS(smCoreClass,smViewerBase,smViewer,0); + * SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,smViewer,0); * SIMMEDTK_FINISH_ONLOAD() * SIMMEDTK_FINISH_DYNAMIC_LOADER() * </pre> @@ -47,7 +47,7 @@ * at startup. */ #define SIMMEDTK_REGISTER_CLASS(BASECLASS,TARGETCLASS,SUBCLASS,GROUP) \ - smFactory<BASECLASS>::registerClassConfiguration( \ + Factory<BASECLASS>::registerClassConfiguration( \ #TARGETCLASS, \ #SUBCLASS, \ []() { return std::shared_ptr<BASECLASS>(new SUBCLASS); }, \ @@ -56,7 +56,7 @@ /**\brief A factory provides a way to discover and construct subclasses of abstract classes. * * Concrete subclasses of abstract bases should call - * smFactory::registerClassConfiguration() in an initializer + * Factory::registerClassConfiguration() in an initializer * function. * Once this is done, the abstract class name can be * used as a key to fetch a list of possible subclasses @@ -79,13 +79,13 @@ * above text rendering. */ template<typename T> -class smFactory +class Factory { public: - /// A function object whose signature returns a shared pointer to an smCoreClass instance. + /// A function object whose signature returns a shared pointer to an CoreClass instance. typedef std::function<std::shared_ptr<T>()> SharedPointerConstructor; - /// An internal structure used by smFactory to track subclasses of abstract classes. + /// An internal structure used by Factory to track subclasses of abstract classes. struct smFactoryEntry { std::string subclassname; diff --git a/src/Core/Factory.hpp b/src/Core/Factory.hpp index 4d8b611f6516bb078d0b52e4988f3400258eab29..e5c6ed3bccf5029634baa859cbdc830fab70918c 100644 --- a/src/Core/Factory.hpp +++ b/src/Core/Factory.hpp @@ -4,7 +4,7 @@ #include <stdlib.h> // for atexit() template<typename T> -void smFactory<T>::registerClassConfiguration( +void Factory<T>::registerClassConfiguration( const std::string& classname, const std::string& subclassname, SharedPointerConstructor ctor, @@ -13,39 +13,39 @@ void smFactory<T>::registerClassConfiguration( if (classname.empty()) return; - if (!smFactory::s_catalog) + if (!Factory::s_catalog) { - smFactory::s_catalog = - new std::map<std::string, typename smFactory<T>::smFactoryConfigurationOptions>; - atexit( []() { delete smFactory::s_catalog; } ); + Factory::s_catalog = + new std::map<std::string, typename Factory<T>::smFactoryConfigurationOptions>; + atexit( []() { delete Factory::s_catalog; } ); } smFactoryEntry entry; entry.subclassname = subclassname; entry.constructor = ctor; entry.group = group; - (*smFactory::s_catalog)[classname].insert(entry); + (*Factory::s_catalog)[classname].insert(entry); } template<typename T> -const typename smFactory<T>::smFactoryConfigurationOptions& smFactory<T>::optionsForClass(const std::string& classname) +const typename Factory<T>::smFactoryConfigurationOptions& Factory<T>::optionsForClass(const std::string& classname) { static smFactoryConfigurationOptions emptyOptions; - if (!smFactory::s_catalog) + if (!Factory::s_catalog) return emptyOptions; typename std::map<std::string, smFactoryConfigurationOptions>::const_iterator it; - if (classname.empty() || (it = smFactory::s_catalog->find(classname)) == smFactory::s_catalog->end()) + if (classname.empty() || (it = Factory::s_catalog->find(classname)) == Factory::s_catalog->end()) return emptyOptions; return it->second; } template<typename T> -std::shared_ptr<T> smFactory<T>::createDefault( +std::shared_ptr<T> Factory<T>::createDefault( const std::string& classname) { const smFactoryConfigurationOptions& opts( - smFactory::optionsForClass(classname)); + Factory::optionsForClass(classname)); if (opts.empty()) return std::shared_ptr<T>(); //std::cout << "Creating default " << classname << ", " << opts.begin()->subclassname << "\n"; @@ -53,12 +53,12 @@ std::shared_ptr<T> smFactory<T>::createDefault( } template<typename T> -std::shared_ptr<T> smFactory<T>::createSubclass( +std::shared_ptr<T> Factory<T>::createSubclass( const std::string& classname, const std::string& subclassname) { const smFactoryConfigurationOptions& opts( - smFactory::optionsForClass(classname)); + Factory::optionsForClass(classname)); typename smFactoryConfigurationOptions::const_iterator it; for (it = opts.begin(); it != opts.end(); ++it) @@ -78,15 +78,15 @@ std::shared_ptr<T> smFactory<T>::createSubclass( * class. */ template<typename T> -std::shared_ptr<T> smFactory<T>::createConcreteClass( +std::shared_ptr<T> Factory<T>::createConcreteClass( const std::string& classname) { - if (classname.empty() || !smFactory::s_catalog) + if (classname.empty() || !Factory::s_catalog) return std::shared_ptr<T>(); typename std::map<std::string, smFactoryConfigurationOptions>::const_iterator bit; typename smFactoryConfigurationOptions::const_iterator cit; - for (bit = smFactory::s_catalog->begin(); bit != smFactory::s_catalog->end(); ++bit) + for (bit = Factory::s_catalog->begin(); bit != Factory::s_catalog->end(); ++bit) for (cit = bit->second.begin(); cit != bit->second.end(); ++cit) if (cit->subclassname == classname) { @@ -98,12 +98,12 @@ std::shared_ptr<T> smFactory<T>::createConcreteClass( } template<typename T> -std::shared_ptr<T> smFactory<T>::createSubclassForGroup( +std::shared_ptr<T> Factory<T>::createSubclassForGroup( const std::string& classname, int group) { const smFactoryConfigurationOptions& opts( - smFactory::optionsForClass(classname)); + Factory::optionsForClass(classname)); typename smFactoryConfigurationOptions::const_iterator it; for (it = opts.begin(); it != opts.end(); ++it) @@ -118,6 +118,6 @@ std::shared_ptr<T> smFactory<T>::createSubclassForGroup( /// Class-static map from abstract class names to registered concrete children. template<typename T> -std::map<std::string, typename smFactory<T>::smFactoryConfigurationOptions>* smFactory<T>::s_catalog = NULL; +std::map<std::string, typename Factory<T>::smFactoryConfigurationOptions>* Factory<T>::s_catalog = NULL; #endif // SMFACTORY_HPP diff --git a/src/Core/Geometry.cpp b/src/Core/Geometry.cpp index 468f35f01bc68a77d3c9c9959042b81020ef576b..3d1e38429777007b1d754d260147b09c575fd456 100644 --- a/src/Core/Geometry.cpp +++ b/src/Core/Geometry.cpp @@ -27,26 +27,26 @@ #include "Geometry.h" #include "RenderDelegate.h" -smAABB::smAABB() +AABB::AABB() { this->reset(); this->renderDelegate = - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "AABBRenderDelegate"); if (this->renderDelegate) this->renderDelegate->setSourceGeometry(this); } -smVec3d smAABB::center() const +core::Vec3d AABB::center() const { - smVec3d output; + core::Vec3d output; output << 0.5f * ( this->aabbMin[0] + this->aabbMax[0] ), 0.5f * ( this->aabbMin[1] + this->aabbMax[1] ), 0.5f * ( this->aabbMin[2] + this->aabbMax[2] ); return output; } -bool smAABB::checkOverlap( const smAABB &p_aabbA, const smAABB &p_aabbB ) +bool AABB::checkOverlap( const AABB &p_aabbA, const AABB &p_aabbB ) { if ( p_aabbA.aabbMin[0] > p_aabbB.aabbMax[0] || @@ -61,7 +61,7 @@ bool smAABB::checkOverlap( const smAABB &p_aabbA, const smAABB &p_aabbB ) return true; } -bool smAABB::overlaps( const smAABB &other ) const +bool AABB::overlaps( const AABB &other ) const { if ( this->aabbMin[0] > other.aabbMax[0] || @@ -76,21 +76,21 @@ bool smAABB::overlaps( const smAABB &other ) const return true; } -const smAABB &smAABB::operator=( const smAABB &p_aabb ) +const AABB &AABB::operator=( const AABB &p_aabb ) { this->aabbMax = p_aabb.aabbMax; this->aabbMin = p_aabb.aabbMin; return *this; } -smAABB &smAABB::operator*( const double p_scale ) +AABB &AABB::operator*( const double p_scale ) { this->aabbMin *= p_scale; this->aabbMax *= p_scale; return *this; } -void smAABB::subDivide( const double p_length, const int p_divison, smAABB *p_aabb ) const +void AABB::subDivide( const double p_length, const int p_divison, AABB *p_aabb ) const { int index = 0; @@ -109,7 +109,7 @@ void smAABB::subDivide( const double p_length, const int p_divison, smAABB *p_aa } } -void smAABB::subDivide( const int p_divisionX, const int p_divisionY, const int p_divisionZ, smAABB *p_aabb ) const +void AABB::subDivide( const int p_divisionX, const int p_divisionY, const int p_divisionZ, AABB *p_aabb ) const { double stepX; double stepY; @@ -136,41 +136,41 @@ void smAABB::subDivide( const int p_divisionX, const int p_divisionY, const int } } -void smAABB::subDivide( const int p_division, smAABB *p_aabb ) const +void AABB::subDivide( const int p_division, AABB *p_aabb ) const { subDivide( p_division, p_division, p_division, p_aabb ); } -double smAABB::halfSizeX() const +double AABB::halfSizeX() const { return .5 * ( aabbMax[0] - aabbMin[0] ); } -double smAABB::halfSizeY() const +double AABB::halfSizeY() const { return .5 * ( aabbMax[1] - aabbMin[1] ); } -double smAABB::halfSizeZ() const +double AABB::halfSizeZ() const { return .5 * ( aabbMax[2] - aabbMin[2] ); } -void smAABB::expand( const double &p_factor ) +void AABB::expand( const double &p_factor ) { this->aabbMin -= .5 * ( this->aabbMax - this->aabbMin ) * p_factor; this->aabbMax += .5 * ( this->aabbMax - this->aabbMin ) * p_factor; } -smCube::smCube() +Cube::Cube() { center << 0, 0, 0; sideLength = 1.0; } -void smCube::subDivide( int p_divisionPerAxis, smCube *p_cube ) +void Cube::subDivide( int p_divisionPerAxis, Cube *p_cube ) { - smVec3d minPoint; + core::Vec3d minPoint; double divLength = ( sideLength / p_divisionPerAxis ); int index = 0; minPoint << center[0] - sideLength * 0.5, @@ -191,36 +191,36 @@ void smCube::subDivide( int p_divisionPerAxis, smCube *p_cube ) } } -void smCube::expand( double p_expansion ) +void Cube::expand( double p_expansion ) { sideLength = sideLength + sideLength * p_expansion; } -smVec3d smCube::leftMinCorner() const +core::Vec3d Cube::leftMinCorner() const { - return smVec3d( center[0] - sideLength * 0.5, + return core::Vec3d( center[0] - sideLength * 0.5, center[1] - sideLength * 0.5, center[2] - sideLength * 0.5 ); } -smVec3d smCube::rightMaxCorner() const +core::Vec3d Cube::rightMaxCorner() const { - return smVec3d( center[0] + sideLength * 0.5, + return core::Vec3d( center[0] + sideLength * 0.5, center[1] + sideLength * 0.5, center[2] + sideLength * 0.5 ); } -smSphere smCube::getCircumscribedSphere() +Sphere Cube::getCircumscribedSphere() { - return smSphere( center, 0.866025 * sideLength ); + return Sphere( center, 0.866025 * sideLength ); } -smSphere smCube::getInscribedSphere() +Sphere Cube::getInscribedSphere() { - return smSphere( center, sideLength * 0.5 ); + return Sphere( center, sideLength * 0.5 ); } -smSphere smCube::getTangent2EdgeSphere() +Sphere Cube::getTangent2EdgeSphere() { - return smSphere( center, sideLength * 0.707106 ); + return Sphere( center, sideLength * 0.707106 ); } diff --git a/src/Core/Geometry.h b/src/Core/Geometry.h index 35d601f0639b6524db0ea2545196b7a075aafd7e..d40c07ec335e50b880c8ed815bfc60d0cd1fac20 100644 --- a/src/Core/Geometry.h +++ b/src/Core/Geometry.h @@ -34,12 +34,12 @@ #include "RenderDelegate.h" //forward declaration -struct smSphere; +struct Sphere; -class smVisualArtifact +class VisualArtifact { public: - virtual void setRenderDelegate(smRenderDelegate::Ptr delegate) + virtual void setRenderDelegate(RenderDelegate::Ptr delegate) { this->renderDelegate = delegate; if (delegate) @@ -51,62 +51,62 @@ public: this->renderDelegate->draw(); } - smRenderDelegate::Ptr renderDelegate; + RenderDelegate::Ptr renderDelegate; }; -class smAnalyticalGeometry : public smVisualArtifact +class AnalyticalGeometry : public VisualArtifact { public: - smAnalyticalGeometry(){} - ~smAnalyticalGeometry(){} + AnalyticalGeometry(){} + ~AnalyticalGeometry(){} - virtual void translate(const smVec3d &t) = 0; - virtual void rotate(const smMatrix33d &rot) = 0; + virtual void translate(const core::Vec3d &t) = 0; + virtual void rotate(const Matrix33d &rot) = 0; }; /// \brief Simple Plane definition with unit normal and spatial location -class smPlane : public smAnalyticalGeometry +class Plane : public AnalyticalGeometry { public: - smPlane() + Plane() { this->setRenderDelegate( - smFactory<smRenderDelegate>::createSubclass( + Factory<RenderDelegate>::createSubclass( "RenderDelegate", "PlaneRenderDelegate")); } - ~smPlane(){} + ~Plane(){} /// \brief create a plane with point and unit normal - smPlane(const smVec3d &p, const smVec3d &n) + Plane(const core::Vec3d &p, const core::Vec3d &n) { this->point = p; this->unitNormal = n; this->width = 100.0; - this->drawPointsOrig[0] = smVec3d(width, 0, 0); - this->drawPointsOrig[1] = smVec3d(0, width, 0); - this->drawPointsOrig[2] = smVec3d(-width, 0, 0); - this->drawPointsOrig[3] = smVec3d(0, -width, 0); + this->drawPointsOrig[0] = core::Vec3d(width, 0, 0); + this->drawPointsOrig[1] = core::Vec3d(0, width, 0); + this->drawPointsOrig[2] = core::Vec3d(-width, 0, 0); + this->drawPointsOrig[3] = core::Vec3d(0, -width, 0); this->movedOrRotated = true; this->setRenderDelegate( - smFactory<smRenderDelegate>::createSubclass( + Factory<RenderDelegate>::createSubclass( "RenderDelegate", "PlaneRenderDelegate")); } - double distance(const smVec3d &p_vector) + double distance(const core::Vec3d &p_vector) { auto m = (p_vector - this->point).dot(this->unitNormal); return m; }; - smVec3d project(const smVec3d &p_vector) + core::Vec3d project(const core::Vec3d &p_vector) { return p_vector - ((this->point - p_vector)*this->unitNormal.transpose())*this->unitNormal; }; - const smVec3d &getUnitNormal() const + const core::Vec3d &getUnitNormal() const { return this->unitNormal; } @@ -116,40 +116,40 @@ public: this->movedOrRotated = s; }; - void setUnitNormal(const smVec3d &normal) + void setUnitNormal(const core::Vec3d &normal) { this->unitNormal = normal; this->movedOrRotated = true; } - const smVec3d &getPoint() const + const core::Vec3d &getPoint() const { return this->point; } - void setPoint(const smVec3d &p) + void setPoint(const core::Vec3d &p) { this->point = p; this->movedOrRotated = true; } - void translate(const smVec3d &t) + void translate(const core::Vec3d &t) { this->point += t; this->movedOrRotated = true; } - void rotate(const smMatrix33d &rot) + void rotate(const Matrix33d &rot) { this->unitNormal = rot * this->unitNormal; this->movedOrRotated = true; } - void setDrawPoint(const smVec3d &p1, const smVec3d &p2, const smVec3d &p3, const smVec3d &p4) + void setDrawPoint(const core::Vec3d &p1, const core::Vec3d &p2, const core::Vec3d &p3, const core::Vec3d &p4) { this->drawPointsOrig[0] = p1; this->drawPointsOrig[1] = p2; @@ -166,12 +166,12 @@ public: void updateDrawPoints() { - smVec3d ny = smVec3d(0.0, unitNormal[2], -unitNormal[1]); - smVec3d nz = ny.cross(unitNormal); + core::Vec3d ny = core::Vec3d(0.0, unitNormal[2], -unitNormal[1]); + core::Vec3d nz = ny.cross(unitNormal); ny.normalize(); nz.normalize(); - smMatrix33d R; + Matrix33d R; R << this->unitNormal[0], ny[1], nz[2], this->unitNormal[0], ny[1], nz[2], this->unitNormal[0], ny[1], nz[2]; @@ -185,10 +185,10 @@ public: private: /// \brief unit normal of the plane - smVec3d unitNormal; + core::Vec3d unitNormal; /// \brief any point on the plane - smVec3d point; + core::Vec3d point; /// \brief true if the plane is static bool movedOrRotated; @@ -197,35 +197,35 @@ private: double width; /// \brief four points used to render plane - smVec3d drawPoints[4]; + core::Vec3d drawPoints[4]; /// \brief four points used to render plane - smVec3d drawPointsOrig[4]; + core::Vec3d drawPointsOrig[4]; }; /// \brief sphere with center and radius -class smSphere : public smAnalyticalGeometry +class Sphere : public AnalyticalGeometry { public: /// \brief constructor - smSphere(); + Sphere(); /// \brief sphere constructor with center and radius - smSphere(const smVec3d &c, const double &r) + Sphere(const core::Vec3d &c, const double &r) { this->center = c; this->radius = r; } - ~smSphere(){} + ~Sphere(){} void setRadius(const double r) { this->radius = r; } - void setCenter(const smVec3d& c) + void setCenter(const core::Vec3d& c) { this->center = c; } @@ -235,12 +235,12 @@ public: this->radius += r; } - void translate(const smVec3d &t) + void translate(const core::Vec3d &t) { center += t; } - void rotate(const smMatrix33d &rot) + void rotate(const Matrix33d &rot) { //Its a sphere! nothing to be done. } @@ -250,102 +250,102 @@ public: return this->radius; } - const smVec3d &getCenter() const + const core::Vec3d &getCenter() const { return this->center; } private: /// \brief center of sphere - smVec3d center; + core::Vec3d center; /// \brief radius of sshere double radius; }; /// \brief cube -struct smCube +struct Cube { /// \brief cube center - smVec3d center; + core::Vec3d center; /// \brief cube length double sideLength; /// \brief constructor - smCube(); + Cube(); /// \brief subdivides the cube in mulitple cube with given number of cubes identified for each axis with p_divisionPerAxis - void subDivide(int p_divisionPerAxis, smCube *p_cube); + void subDivide(int p_divisionPerAxis, Cube *p_cube); /// \brief expands the cube. increases the edge length with expansion*edge length void expand(double p_expansion); /// \brief returns the left most corner - smVec3d leftMinCorner() const ; + core::Vec3d leftMinCorner() const ; /// \brief returns right most corner - smVec3d rightMaxCorner() const; + core::Vec3d rightMaxCorner() const; /// \brief returns the smallest sphere encapsulates the cube - smSphere getCircumscribedSphere(); + Sphere getCircumscribedSphere(); /// \brief returns the sphere with half edge of the cube as a radius - smSphere getInscribedSphere(); + Sphere getInscribedSphere(); /// \brief get tangent sphere - smSphere getTangent2EdgeSphere(); + Sphere getTangent2EdgeSphere(); }; /// \brief Axis Aligned bounding box declarions -class smAABB : public smVisualArtifact +class AABB : public VisualArtifact { public: /// \brief minimum x,y,z point - smVec3d aabbMin; + core::Vec3d aabbMin; /// \brief maximum x,y,z point - smVec3d aabbMax; + core::Vec3d aabbMax; - const smVec3d &getMax() const + const core::Vec3d &getMax() const { return aabbMax; } - const smVec3d &getMin() const + const core::Vec3d &getMin() const { return aabbMin; } /// \brief constrcutor. The default is set to origin for aabbMin and aabbMax - smAABB(); + AABB(); /// \brief center of the AABB - smVec3d center() const; + core::Vec3d center() const; /// \brief check if two AABB overlaps - static bool checkOverlap(const smAABB &p_aabbA, const smAABB &p_aabbB); + static bool checkOverlap(const AABB &p_aabbA, const AABB &p_aabbB); /// \brief check if two AABB overlaps - bool overlaps(const smAABB &other) const; + bool overlaps(const AABB &other) const; /// \brief set p_aabb to the current one - const smAABB &operator=(const smAABB &p_aabb); + const AABB &operator=(const AABB &p_aabb); /// \brief scale the AABB - smAABB &operator*(const double p_scale); + AABB &operator*(const double p_scale); /// \brief sub divides p_length will be used to create the slices - void subDivide(const double p_length, const int p_divison, smAABB *p_aabb) const; + void subDivide(const double p_length, const int p_divison, AABB *p_aabb) const; /// \brief divides current AABB in x,y,z axes with specificed divisions. results are placed in p_aabb - void subDivide(const int p_divisionX, const int p_divisionY, const int p_divisionZ, smAABB *p_aabb) const; + void subDivide(const int p_divisionX, const int p_divisionY, const int p_divisionZ, AABB *p_aabb) const; /// \brief divides current AABB in all axes with specificed p_division. results are placed in p_aabb - void subDivide(const int p_division, smAABB *p_aabb) const; + void subDivide(const int p_division, AABB *p_aabb) const; /// \brief returns half of X edge of AABB double halfSizeX() const; @@ -369,7 +369,7 @@ public: std::numeric_limits<float>::min(); } - void extend(const smAABB &other) + void extend(const AABB &other) { this->aabbMin = this->aabbMin.array().min(other.getMin().array()); this->aabbMax = this->aabbMax.array().max(other.getMax().array()); diff --git a/src/Core/IOStream.cpp b/src/Core/IOStream.cpp index 282b65886eca79d9c12989267f7d5e60026e9b9c..a36abef6d1e2abdd0bef23140fec91fec973aaf9 100644 --- a/src/Core/IOStream.cpp +++ b/src/Core/IOStream.cpp @@ -27,12 +27,12 @@ smConsoleStream::smConsoleStream() { } -smIOStream& smConsoleStream::operator<<(std::string p_string) +IOStream& smConsoleStream::operator<<(std::string p_string) { std::cout << p_string; return *this; } -smIOStream& smConsoleStream::operator>>(std::string &p_string) +IOStream& smConsoleStream::operator>>(std::string &p_string) { std::getline(std::cin, inputBuffer); p_string = inputBuffer; @@ -67,11 +67,11 @@ void smWindowString::operator=(smWindowString& p_windowString) x = p_windowString.x; y = p_windowString.y; } -smIOStream& smWindowStream::operator<<(std::string /*p_string*/) +IOStream& smWindowStream::operator<<(std::string /*p_string*/) { return *this; } -smIOStream& smWindowStream::operator>>(std::string& /*p_string*/) +IOStream& smWindowStream::operator>>(std::string& /*p_string*/) { return *this; } diff --git a/src/Core/IOStream.h b/src/Core/IOStream.h index 956c9f65677232a9ff38b3f13d89315ea305a1b6..c813376b615ca3ea96b6c7ae8b3b2a2793908ac4 100644 --- a/src/Core/IOStream.h +++ b/src/Core/IOStream.h @@ -39,33 +39,33 @@ namespace mstk { namespace Event { - class smEvent; + class Event; class smEventHandler; class smCameraEvent; } } /// \brief I/O stream -class smIOStream : public smCoreClass +class IOStream : public CoreClass { public: - virtual smIOStream& operator >>(std::string &p_string) = 0; - virtual smIOStream& operator <<(std::string p_string) = 0; + virtual IOStream& operator >>(std::string &p_string) = 0; + virtual IOStream& operator <<(std::string p_string) = 0; protected: std::shared_ptr<mstk::Event::smEventHandler> eventHanlder; }; /// \brief console stream; for printing text on the console -class smConsoleStream: public smIOStream +class smConsoleStream: public IOStream { std::string inputBuffer; public: smConsoleStream(); /// \brief operator to print text - virtual smIOStream& operator <<(std::string p_string); + virtual IOStream& operator <<(std::string p_string); /// \brief to input from use - virtual smIOStream& operator >>(std::string &p_string); + virtual IOStream& operator >>(std::string &p_string); }; /// \brief window string @@ -96,11 +96,11 @@ struct smWindowData smWindowString windowString; }; /// \brief window stream for putting window string on text -class smWindowStream: public smIOStream +class smWindowStream: public IOStream { public: - virtual smIOStream& operator <<(std::string p_string); - virtual smIOStream& operator >>(std::string &p_string); + virtual IOStream& operator <<(std::string p_string); + virtual IOStream& operator >>(std::string &p_string); }; /// \brief opengl window stream for putting text on the screen @@ -113,7 +113,7 @@ public: bool enabled; /// \brief text color - smColor textColor; + Color textColor; /// \brief constructors smOpenGLWindowStream(int p_totalTexts = SM_WINDOW_TOTALSTRINGS_ONWINDOW); @@ -134,7 +134,7 @@ public: bool removeText(std::string p_tag); /// \brief handle events - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent> /*p_event*/) override {} + virtual void handleEvent(std::shared_ptr<mstk::Event::Event> /*p_event*/) override {} protected: /// \brief fonts @@ -172,7 +172,7 @@ protected: float right; float top; /// \brief background color - smColor backGroundColor; + Color backGroundColor; }; #endif diff --git a/src/Core/Light.cpp b/src/Core/Light.cpp index 0ce29dc0813febf051dea2807cf3135ba8885aa5..0ad07b9913da6dd0bdeed55c809148419546e088 100644 --- a/src/Core/Light.cpp +++ b/src/Core/Light.cpp @@ -28,19 +28,19 @@ #include "Light.h" #include "Quaternion.h" -smVec3d smLight::defaultDir(0, 0, -1.0); -smVec3d smLight::defaultUpDir(0, 1, 0.0); -smVec3d smLight::defaultTransDir(1, 0, 0.0); +core::Vec3d Light::defaultDir(0, 0, -1.0); +core::Vec3d Light::defaultUpDir(0, 1, 0.0); +core::Vec3d Light::defaultTransDir(1, 0, 0.0); -void smLight::updateDirection() +void Light::updateDirection() { double angle; - smVec3d dirNorm = direction.normalized(); + core::Vec3d dirNorm = direction.normalized(); angle = std::acos(dirNorm.dot(defaultDir)); - smVec3d axisOfRot = dirNorm.cross(defaultDir).normalized(); + core::Vec3d axisOfRot = dirNorm.cross(defaultDir).normalized(); - smQuaterniond rot = getRotationQuaternion(-angle,axisOfRot); + Quaterniond rot = getRotationQuaternion(-angle,axisOfRot); upVector = rot*defaultUpDir; transverseDir = rot*defaultTransDir; @@ -51,14 +51,14 @@ smLightPos::smLightPos( float p_x, float p_y, float p_z, float /*p_w*/ ) position << p_x, p_y, p_z; } -smLight::smLight( std::string p_name, smLightType p_lightType, smLightLocationType p_lightLocation ) +Light::Light( std::string p_name, LightType p_lightType, LightLocationType p_lightLocation ) { name = p_name; enabled = false; previousState = false; - lightPos.setPosition(smVec3d::Zero()); + lightPos.setPosition(core::Vec3d::Zero()); - if ( p_lightType == SIMMEDTK_LIGHT_INFINITELIGHT ) + if ( p_lightType == InfiniteLight ) { lightPos.w = 0.0; } @@ -90,9 +90,9 @@ smLight::smLight( std::string p_name, smLightType p_lightType, smLightLocationTy attn_linear = 0.0; attn_quadratic = 0.0; } -void smLight::setType( smLightType p_lightType ) +void Light::setType( LightType p_lightType ) { - if ( p_lightType == SIMMEDTK_LIGHT_INFINITELIGHT ) + if ( p_lightType == InfiniteLight ) { lightPos.w = 0.0; } @@ -101,11 +101,11 @@ void smLight::setType( smLightType p_lightType ) lightPos.w = 1.0; } } -bool smLight::isEnabled() +bool Light::isEnabled() { return enabled; } -void smLight::activate( bool p_state ) +void Light::activate( bool p_state ) { enabled = p_state; previousState = enabled; diff --git a/src/Core/Light.h b/src/Core/Light.h index 2a28a2f28980f0e481075076d3e3c6af64103eba..07d8d9e66daf99ecaf5604f000d08157e9c7d12a 100644 --- a/src/Core/Light.h +++ b/src/Core/Light.h @@ -35,51 +35,52 @@ #define SMLIGHT_SPOTMAX 128 -class smLight; -/// \brief light type; infinite or spotlight -enum smLightType -{ - SIMMEDTK_LIGHT_SPOTLIGHT, - SIMMEDTK_LIGHT_INFINITELIGHT -}; -/// \brief location of the light type -enum smLightLocationType -{ - SIMMEDTK_LIGHTPOS_EYE, - SIMMEDTK_LIGHTPOS_WORLD -}; +class Light; /// \brief light position. light at inifinite position can be defined with w struct smLightPos { public: + smLightPos(float p_x = 0.0, float p_y = 0.0, float p_z = 0.0, float p_w = 1.0); - void setPosition(const smVec3d &p) + void setPosition(const core::Vec3d &p) { position = p; } - const smVec3d &getPosition() const + const core::Vec3d &getPosition() const { return position; } private: float w; - smVec3d position; - friend smLight; + core::Vec3d position; + friend Light; }; /// \brief Basic light funtionality for the viewer..Be aware that if the light is ///infinite the cutoff angle is still in active. You could see sudden shade in the objects ///if you don't pay attention to the cut-off angle..If you want the scene to be fully lit ///set cut-off angle 180 degrees. -///Also when the params SIMMEDTK_LIGHT_INFINITELIGHT,SIMMEDTK_LIGHTPOS_EYE are used, this means +///Also when the params InfiniteLight,Eye are used, this means //the light will be positioned with respect to eye coord and the light will be inifinite //Therefore, the light should be positioned with a slight offset respect to eye pos(0,0,0); ///such as (0,0.5,0)(like a head lamp) -struct smLight +struct Light { - +public: + /// \brief light type; infinite or spotlight + enum LightType + { + Spotlight, + InfiniteLight + }; + /// \brief location of the light type + enum LightLocationType + { + Eye, + World + }; protected: bool enabled; bool previousState; @@ -89,25 +90,25 @@ public: int renderUsage; std::string name; - smLightLocationType lightLocationType; - smLightType lightType; + LightLocationType lightLocationType; + LightType lightType; float attn_constant; float attn_linear; float attn_quadratic; - smLight(std::string p_name = "", smLightType p_lightType = SIMMEDTK_LIGHT_INFINITELIGHT, - smLightLocationType p_lightLocation = SIMMEDTK_LIGHTPOS_EYE); + Light(std::string p_name = "", LightType p_lightType = InfiniteLight, + LightLocationType p_lightLocation = Eye); /// \brief set light type - void setType(smLightType p_lightType); + void setType(LightType p_lightType); /// \brief returns if the light is enabled or not bool isEnabled(); /// \brief activate the light void activate(bool p_state); /// \brief light properties - smColor lightColorDiffuse; - smColor lightColorAmbient; - smColor lightColorSpecular; + Color lightColorDiffuse; + Color lightColorAmbient; + Color lightColorSpecular; smLightPos lightPos; //Vec3d direction; @@ -118,16 +119,16 @@ public: ///angle between 0-90 and 180 is also accepted float spotCutOffAngle; /// \brief light direction, up vector, transverse direction, focus point - smVec3d direction; - smVec3d upVector; - smVec3d transverseDir; - smVec3d focusPosition;//it is for shadow + core::Vec3d direction; + core::Vec3d upVector; + core::Vec3d transverseDir; + core::Vec3d focusPosition;//it is for shadow /// \brief update light direction void updateDirection(); /// \brief default direction for light, upvector and transverse direction - static smVec3d defaultDir; - static smVec3d defaultUpDir; - static smVec3d defaultTransDir; + static core::Vec3d defaultDir; + static core::Vec3d defaultUpDir; + static core::Vec3d defaultTransDir; /// \brief if the light casts shadow, this should be enabled. Unfortunately, we only support one light at a time for shadows bool castShadow; @@ -137,16 +138,16 @@ public: float shadowRatio; float shadorAngle; - static std::shared_ptr<smLight> getDefaultLighting(const std::string &name = "SceneLight") + static std::shared_ptr<Light> getDefaultLighting(const std::string &name = "SceneLight") { - std::shared_ptr<smLight> - light = std::make_shared<smLight>(name,SIMMEDTK_LIGHT_SPOTLIGHT,SIMMEDTK_LIGHTPOS_WORLD); - light->lightPos.setPosition(smVec3d(10.0, 10.0, 10.0)); + std::shared_ptr<Light> + light = std::make_shared<Light>(name, Spotlight, World); + light->lightPos.setPosition(core::Vec3d(10.0, 10.0, 10.0)); light->lightColorDiffuse.setValue(0.8, 0.8, 0.8, 1); light->lightColorAmbient.setValue(0.1, 0.1, 0.1, 1); light->lightColorSpecular.setValue(0.9, 0.9, 0.9, 1); light->spotCutOffAngle = 60; - light->direction = smVec3d(0.0, 0.0, -1.0); + light->direction = core::Vec3d(0.0, 0.0, -1.0); light->drawEnabled = false; light->attn_constant = 1.0; light->attn_linear = 0.0; diff --git a/src/Core/Math.cpp b/src/Core/Math.cpp deleted file mode 100644 index 05863bca4fc05dbccf9348af0dc72d8ec6e50f71..0000000000000000000000000000000000000000 --- a/src/Core/Math.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and 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 -// -// 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. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -// SimMedTK includes -#include "Math.h" - -smMath::smMath() -{ - type = core::ClassType::Math; -} - -int smMath::pow(int p_base, int p_pow) -{ - int res = 1; - - for (int i = 0; i < p_pow; i++) - { - res *= p_base; - } - - return res; -} - -float smMath::interpolate(int current, int min, int max) -{ - if (current < min) - { - return 0.0; - } - else if (current > max) - { - return 1.0; - } - return (current - min) / (max - min); -} diff --git a/src/Core/Math.h b/src/Core/Math.h deleted file mode 100644 index 1a52d50d73782a0f690bb249f37811bc80f49c3b..0000000000000000000000000000000000000000 --- a/src/Core/Math.h +++ /dev/null @@ -1,78 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and 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 -// -// 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. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef SMMATH_H -#define SMMATH_H -#include "Config.h" -#include "CoreClass.h" - -/// \brief generic definitions -#define SM_PI 3.141592653589793 -#define SM_PI_HALF 1.57079632679489661923 -#define SM_PI_QUARTER 0.78539816339744830961 -#define SM_PI_TWO 6.28318530717958647692 -#define SM_PI_INV 0.31830988618379067154 - - -#define SM_MATRIX_PRECISION 0.000000001 -#define SM_DEGREES2RADIANS(X) X*0.0174532925 -#define SM_RADIANS2DEGREES(X) X*57.2957795 - -/// \brief generic math class -class smMath: smCoreClass -{ -public: - - smMath(); - /// \brief computes power - static int pow(int p_base, int p_pow); - /// \brief linear interpolation with min, max - static float interpolate(int current, int min, int max); -}; -/// \brief hash function -template<class T> -class smBaseHash: public smCoreClass -{ -public: - smBaseHash() - { - } - /// \brief computes hash based on the has table size, given one number x - template<T> - inline unsigned int computeHash(unsigned int p_tableSize, T p_x); - - /// \brief computes hash based on the has table size, given numbers x,y - template<T> - inline unsigned int computeHash(unsigned int p_tableSize, T p_x, T p_y); - /// \brief computes hash based on the has table size, given numbers x,y,z - template<T> - inline unsigned int computeHash(unsigned int p_tableSize, T p_x, T p_y, T p_z); -}; - -template<class T> -class smCollisionHash: public smBaseHash<T> -{ - -}; - -#endif diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index f95c9fc360421b056a2c39d28c82a1fdbc2ead3b..d9c313a05f1fae236227032fc434a31bce6faf94 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -38,19 +38,19 @@ /// A 2x2 matrix template<typename T> -using smMatrix22 = Eigen::Matrix<T, 2, 2>; +using Matrix22 = Eigen::Matrix<T, 2, 2>; /// A 3x3 matrix template<typename T> -using smMatrix33 = Eigen::Matrix<T, 3, 3>; +using Matrix33 = Eigen::Matrix<T, 3, 3>; /// A 4x4 matrix template<typename T> -using smMatrix44 = Eigen::Matrix<T, 4, 4>; +using Matrix44 = Eigen::Matrix<T, 4, 4>; /// A 4x4 matrix template<typename T> -using smMatrix66 = Eigen::Matrix<T, 6, 6>; +using Matrix66 = Eigen::Matrix<T, 6, 6>; /// A dynamic size diagonal matrix template<typename T> @@ -58,32 +58,32 @@ using smDiagonalMatrix = Eigen::DiagonalMatrix<T, Eigen::Dynamic>; /// A dynamic size dense matrix template<typename T> -using smMatrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>; +using Matrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>; /// A dynamic size sparse column-major matrix -template<typename T, int StorageType = Eigen::ColMajor> -using smSparseMatrix = Eigen::SparseMatrix<T,StorageType>; +// template<typename T, int StorageType = Eigen::ColMajor> +// using SparseMatrix = Eigen::SparseMatrix<T,StorageType>; /// A 2x2 matrix of floats. -using smMatrix22f = smMatrix22<float>; +using Matrix22f = Matrix22<float>; /// A 3x3 matrix of floats. -using smMatrix33f = smMatrix33<float>; +using Matrix33f = Matrix33<float>; /// A 4x4 matrix of floats. -using smMatrix44f = smMatrix44<float>; +using Matrix44f = Matrix44<float>; /// A 2x2 matrix of doubles. -using smMatrix22d = smMatrix22<double>; +using Matrix22d = Matrix22<double>; /// A 3x3 matrix of doubles. -using smMatrix33d = smMatrix33<double>; +using Matrix33d = Matrix33<double>; /// A 4x4 matrix of doubles. -using smMatrix44d = smMatrix44<double>; +using Matrix44d = Matrix44<double>; /// A 6x6 matrix of doubles. -using smMatrix66d = smMatrix66<double>; +using Matrix66d = Matrix66<double>; /// A dynamic size diagonal matrix of floats using smDiagonalMatrixf = smDiagonalMatrix<float>; @@ -92,26 +92,26 @@ using smDiagonalMatrixf = smDiagonalMatrix<float>; using smDiagonalMatrixd = smDiagonalMatrix<double>; /// A dynamic size matrix of floats -using smMatrixf = smMatrix<float>; +using Matrixf = Matrix<float>; /// A dynamic size matrix of doubles -using smMatrixd = smMatrix<double>; +using Matrixd = Matrix<double>; -template<typename T, int StorageType> -void fillSparseMatrix(const std::vector<Eigen::Triplet<T>> &triplets, Eigen::SparseMatrix<T,StorageType> &A) -{ - A.setFromTriplets(triplets.begin(),triplets.end()); -} - -template<typename T, int StorageType, int opt> -void solveSparseSystemCholesky(const Eigen::SparseMatrix<T,StorageType> &A, - const Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &b, - Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &x) -{ - // Solving: - Eigen::SimplicialCholesky<Eigen::SparseMatrix<T,StorageType>> solver(A); // performs a Cholesky factorization of A - x = solver.solve(b); // use the factorization to solve for the given right hand side -} +// template<typename T, int StorageType> +// void fillSparseMatrix(const std::vector<Eigen::Triplet<T>> &triplets, Eigen::SparseMatrix<T,StorageType> &A) +// { +// A.setFromTriplets(triplets.begin(),triplets.end()); +// } +// +// template<typename T, int StorageType, int opt> +// void solveSparseSystemCholesky(const Eigen::SparseMatrix<T,StorageType> &A, +// const Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &b, +// Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &x) +// { +// // Solving: +// Eigen::SimplicialCholesky<Eigen::SparseMatrix<T,StorageType>> solver(A); // performs a Cholesky factorization of A +// x = solver.solve(b); // use the factorization to solve for the given right hand side +// } // WARNING: The input matrix A should be in a compressed and column-major form. Otherwise an expensive copy will be made. // template<typename T, int StorageType, int opt> diff --git a/src/Core/ModelRepresentation.cpp b/src/Core/ModelRepresentation.cpp index 40f9f86cb7f28b81266b1d78012d8c5e95ff131b..1f38fd75edeb79848cb7047f5bcff99f974c8d58 100644 --- a/src/Core/ModelRepresentation.cpp +++ b/src/Core/ModelRepresentation.cpp @@ -23,14 +23,14 @@ #include "ModelRepresentation.h" -smModelRepresentation::smModelRepresentation() +ModelRepresentation::ModelRepresentation() { } -smModelRepresentation::~smModelRepresentation() +ModelRepresentation::~ModelRepresentation() { } -smModelRepresentation::smModelRepresentation() {} -smModelRepresentation::~smModelRepresentation() {} +ModelRepresentation::ModelRepresentation() {} +ModelRepresentation::~ModelRepresentation() {} diff --git a/src/Core/ModelRepresentation.h b/src/Core/ModelRepresentation.h index b7850f813afbebb53470fe5443ae3a142081bd62..41d822db686852d5aa5ee4e5831a3702588ec6c1 100644 --- a/src/Core/ModelRepresentation.h +++ b/src/Core/ModelRepresentation.h @@ -33,14 +33,14 @@ class smMesh; -class smModelRepresentation +class ModelRepresentation { public: - smModelRepresentation(){} - ~smModelRepresentation(){} + ModelRepresentation(){} + ~ModelRepresentation(){} virtual std::shared_ptr<smMesh> getMesh(){ std::shared_ptr<smMesh> s; return s; } - virtual std::shared_ptr<smCoreClass> getObject(){ std::shared_ptr<smCoreClass> s; return s; } + virtual std::shared_ptr<CoreClass> getObject(){ std::shared_ptr<CoreClass> s; return s; } virtual void draw(){} }; diff --git a/src/Core/Module.cpp b/src/Core/Module.cpp index 1da1a371a402d71f7ac334841ad9f1d90eb0df2a..1433d3ee005ca3174ec3b79e2471058802169bd9 100644 --- a/src/Core/Module.cpp +++ b/src/Core/Module.cpp @@ -24,28 +24,28 @@ #include "Module.h" /// \brief Begin frame will be called before the cycle -void smModule::beginModule() +void Module::beginModule() { - dispathcer->handle(std::static_pointer_cast<smCoreClass>(shared_from_this()), core::CallerState::BeginFrame); + dispathcer->handle(std::static_pointer_cast<CoreClass>(shared_from_this()), core::CallerState::BeginFrame); beginFrame(); } /// \brief End frame will be called after the cycle -void smModule::endModule() +void Module::endModule() { endFrame(); - dispathcer->handle(std::static_pointer_cast<smCoreClass>(shared_from_this()), core::CallerState::EndFrame); + dispathcer->handle(std::static_pointer_cast<CoreClass>(shared_from_this()), core::CallerState::EndFrame); } -void smModule::terminate() +void Module::terminate() { terminateExecution = true; } -bool smModule::isTerminationDone() +bool Module::isTerminationDone() { return terminationCompleted; } -void smModule::waitTermination() +void Module::waitTermination() { while ( 1 ) { @@ -55,11 +55,11 @@ void smModule::waitTermination() } } } -int smModule::getModuleId() +int Module::getModuleId() { return this->getUniqueId()->getId(); } -smModule::smModule() +Module::Module() { terminateExecution = false; isInitialized = false; diff --git a/src/Core/Module.h b/src/Core/Module.h index 3b034301aab523a1d57da42abb51bf5c48c55c47..e1c155da4f6a99b15d52b39ab097941ddd522b44 100644 --- a/src/Core/Module.h +++ b/src/Core/Module.h @@ -35,11 +35,11 @@ #include "SceneObject.h" ///this class is module major. Every other thread should derive this class -class smModule: public smCoreClass +class Module: public CoreClass { private: - friend class smSDK; + friend class SDK; protected: ///initialization flag @@ -52,16 +52,16 @@ protected: bool terminationCompleted; ///scene list in the environment - std::vector<std::shared_ptr<smScene>> sceneList; + std::vector<std::shared_ptr<Scene>> sceneList; /// \brief call are made for begin module and end module before and after each frame virtual void beginModule(); virtual void endModule(); /// \brief dispatcher reference - std::shared_ptr<smDispatcher> dispathcer; + std::shared_ptr<Dispatcher> dispathcer; public: /// \brief constructor initializes the module - smModule(); + Module(); /// \brief virtual functions virtual void init() = 0; diff --git a/src/Core/ObjectSimulator.cpp b/src/Core/ObjectSimulator.cpp index 3c754881aa5c0fcb3491e40f29e63b641c74c0e8..9e9f9ca9df03e9a63ee816a28d3d013ee148f1cd 100644 --- a/src/Core/ObjectSimulator.cpp +++ b/src/Core/ObjectSimulator.cpp @@ -25,10 +25,10 @@ #include "Rendering/Viewer.h" #include "SDK.h" -smObjectSimulator::smObjectSimulator(std::shared_ptr<smErrorLog> p_log) +ObjectSimulator::ObjectSimulator(std::shared_ptr<ErrorLog> p_log) { this->log = p_log; -// smSDK::getInstance()->registerObjectSim(safeDownCast<smObjectSimulator>()); +// SDK::getInstance()->registerObjectSim(safeDownCast<ObjectSimulator>()); name = "objecSimulator" + std::to_string(this->getUniqueId()->getId()); type = core::ClassType::Simulator; @@ -45,22 +45,22 @@ smObjectSimulator::smObjectSimulator(std::shared_ptr<smErrorLog> p_log) execType = SIMMEDTK_SIMEXECUTION_SYNCMODE; } -void smObjectSimulator::addObject(std::shared_ptr<smSceneObject> p_object) +void ObjectSimulator::addObject(std::shared_ptr<SceneObject> p_object) { - p_object->objectSim = safeDownCast<smObjectSimulator>(); + p_object->objectSim = safeDownCast<ObjectSimulator>(); objectsSimulated.emplace_back( p_object ); } -void smObjectSimulator::removeObject(std::shared_ptr<smSceneObject> /*p_object*/ ) +void ObjectSimulator::removeObject(std::shared_ptr<SceneObject> /*p_object*/ ) { } -void smObjectSimulator::setPriority( smThreadPriority p_priority ) +void ObjectSimulator::setPriority( smThreadPriority p_priority ) { threadPriority = p_priority; } -void smObjectSimulator::setExecutionType( smSimulatorExecutionType p_type ) +void ObjectSimulator::setExecutionType( smSimulatorExecutionType p_type ) { if ( execType != p_type ) { @@ -70,12 +70,12 @@ void smObjectSimulator::setExecutionType( smSimulatorExecutionType p_type ) execType = p_type; } -smThreadPriority smObjectSimulator::getPriority() +smThreadPriority ObjectSimulator::getPriority() { return threadPriority; } -void smObjectSimulator::init() +void ObjectSimulator::init() { if ( isObjectSimInitialized == false ) { @@ -85,12 +85,12 @@ void smObjectSimulator::init() } } -void smObjectSimulator::beginSim() +void ObjectSimulator::beginSim() { frameCounter++; timer.start(); } -void smObjectSimulator::endSim() +void ObjectSimulator::endSim() { timerPerFrame = timer.elapsed(); totalTime += timerPerFrame; @@ -103,12 +103,12 @@ void smObjectSimulator::endSim() } } -void smObjectSimulator::updateSceneList() +void ObjectSimulator::updateSceneList() { } -smObjectSimulator::smObjectSimulatorObjectIter::smObjectSimulatorObjectIter( smScheduleGroup &p_group, - std::vector<std::shared_ptr<smSceneObject>> &p_objectsSimulated, +ObjectSimulator::smObjectSimulatorObjectIter::smObjectSimulatorObjectIter( ScheduleGroup &p_group, + std::vector<std::shared_ptr<SceneObject>> &p_objectsSimulated, int p_threadIndex ) { @@ -146,17 +146,17 @@ smObjectSimulator::smObjectSimulatorObjectIter::smObjectSimulatorObjectIter( smS } } } -void smObjectSimulator::smObjectSimulatorObjectIter::setThreadIndex( short int p_threadIndex ) +void ObjectSimulator::smObjectSimulatorObjectIter::setThreadIndex( short int p_threadIndex ) { threadIndex = p_threadIndex; } -int smObjectSimulator::smObjectSimulatorObjectIter::begin() +int ObjectSimulator::smObjectSimulatorObjectIter::begin() { return beginIndex; } -int smObjectSimulator::smObjectSimulatorObjectIter::end() +int ObjectSimulator::smObjectSimulatorObjectIter::end() { return endIndex; } diff --git a/src/Core/ObjectSimulator.h b/src/Core/ObjectSimulator.h index 215404191051b5cdd77b2c467051adf58fee6554..f5693dbbc17398a32ae84bd46d6717ca476791b8 100644 --- a/src/Core/ObjectSimulator.h +++ b/src/Core/ObjectSimulator.h @@ -52,27 +52,22 @@ enum smSimulatorExecutionType }; //forward declarations -class smSceneObject; - -struct smObjectSimulatorParam -{ - short threadIndex; -}; +class SceneObject; ///This is the major object simulator. Each object simulator should derive this class. ///you want particular object simualtor to work over an object just set pointer of the object. the rest will be taken care of the simulator and object simulator. -class smObjectSimulator : public smCoreClass +class ObjectSimulator : public CoreClass { - ///friend class since smSimulator is the encapsulates the other simulators. - friend class smSimulator; + ///friend class since Simulator is the encapsulates the other simulators. + friend class Simulator; protected: ///log of the object - std::shared_ptr<smErrorLog> log; + std::shared_ptr<ErrorLog> log; bool isObjectSimInitialized; smThreadPriority threadPriority; - smTimer timer; + Timer timer; long double timerPerFrame; long double FPS; unsigned int frameCounter; @@ -82,18 +77,18 @@ protected: public: ///This is for scheduler - smScheduleGroup scheduleGroup; + ScheduleGroup scheduleGroup; - //std::shared_ptr<smUnifiedId> objectSimulatorId; + //std::shared_ptr<UnifiedId> objectSimulatorId; bool enabled; ///the function is reentrant it is not thread safe. - virtual void addObject(std::shared_ptr<smSceneObject> p_object); + virtual void addObject(std::shared_ptr<SceneObject> p_object); /// \brief remove object from the simulator - virtual void removeObject(std::shared_ptr<smSceneObject> p_object); + virtual void removeObject(std::shared_ptr<SceneObject> p_object); - smObjectSimulator(std::shared_ptr<smErrorLog> p_log); + ObjectSimulator(std::shared_ptr<ErrorLog> p_log); /// \brief set thread priority void setPriority(smThreadPriority p_priority); @@ -105,7 +100,7 @@ public: protected: ///objects that are simulated by this will be added to the list - std::vector<std::shared_ptr<smSceneObject>> objectsSimulated; + std::vector<std::shared_ptr<SceneObject>> objectsSimulated; virtual void initCustom() = 0; @@ -139,8 +134,8 @@ protected: short threadIndex; public: - smObjectSimulatorObjectIter(smScheduleGroup &p_group, - std::vector<std::shared_ptr<smSceneObject>> &p_objectsSimulated, + smObjectSimulatorObjectIter(ScheduleGroup &p_group, + std::vector<std::shared_ptr<SceneObject>> &p_objectsSimulated, int p_threadIndex); inline void setThreadIndex(short p_threadIndex); diff --git a/src/Core/Pipe.cpp b/src/Core/Pipe.cpp deleted file mode 100644 index cd4cfb2535a7da81f76ac8f6e95ee9624010a125..0000000000000000000000000000000000000000 --- a/src/Core/Pipe.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and 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 -// -// 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. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#include "Pipe.h" - -smPipeData::smPipeData() -{ - dataLocation = NULL; - dataReady = false; - nbrElements = 0; - timeStamp = 0; -} -smPipeRegisteration::smPipeRegisteration() -{ - regType = SIMMEDTK_PIPE_BYREF; -} -smPipeRegisteration::smPipeRegisteration ( smPipeRegType p_reg ) -{ - regType = p_reg; -} -void smPipeRegisteration::print() -{ - if ( regType == SIMMEDTK_PIPE_BYREF ) - { - std::cout << "Listener Object" << " By Reference" << "\n"; - } - - if ( regType == SIMMEDTK_PIPE_BYVALUE ) - { - std::cout << "Listener Object" << " By Value" << "\n"; - } -} -smPipe::~smPipe() -{ - smIndiceArrayIter<smPipeRegisteration*> iterValue ( &byValue ); - - for ( int i = iterValue.begin(); i < iterValue.end(); i++ ) - { - delete [] static_cast<char*>(iterValue[i]->data.dataLocation); - } -} -smPipe::smPipe ( std::string p_name, int p_elementSize, int p_maxElements, smPipeType p_pipeType ) : - byRefs ( SIMMEDTK_PIPE_MAXLISTENERS ), - byValue ( SIMMEDTK_PIPE_MAXLISTENERS ) -{ - name = p_name; - maxElements = p_maxElements; - elementSize = p_elementSize; - data = new char[elementSize * maxElements]; //change it to memory block later on - pipeType = p_pipeType; -} -int smPipe::getElements() -{ - return maxElements; -} -void* smPipe::beginWrite() -{ - return data; -} -void smPipe::endWrite ( int p_elements ) -{ - currentElements = p_elements; - timeStamp++; - acknowledgeRefListeners(); -} -int smPipe::registerListener ( smPipeRegisteration* p_pipeReg ) -{ - if ( p_pipeReg->regType == SIMMEDTK_PIPE_BYREF ) - { - p_pipeReg->data.dataLocation = data; - return byRefs.add ( p_pipeReg ); - } - p_pipeReg->data.dataLocation = new char[elementSize * maxElements]; - p_pipeReg->data.dataReady = false; - p_pipeReg->data.nbrElements = 0; - p_pipeReg->data.timeStamp = timeStamp; - return byValue.add ( p_pipeReg ); -} -void smPipe::acknowledgeRefListeners() -{ - smIndiceArrayIter<smPipeRegisteration*> iterRef ( &byRefs ); - - for ( int i = iterRef.begin(); i < iterRef.end(); i++ ) - { - ( iterRef[i]->data.nbrElements ) = currentElements; - ( iterRef[i]->data.timeStamp ) = timeStamp; - ( iterRef[i]->data.dataReady ) = true; - } -} -void smPipe::acknowledgeValueListeners() -{ - smIndiceArrayIter<smPipeRegisteration*> iter ( &byValue ); - - for ( int i = iter.begin(); i < iter.end(); i++ ) - { - memcpy ( iter[i]->data.dataLocation, data, currentElements * elementSize ); - ( iter[i]->data.nbrElements ) = currentElements; - ( iter[i]->data.dataReady ) = true; - } -} -void smPipe::checkAndCopyNewData ( int p_handleByValue ) -{ - smPipeRegisteration *reg = byValue.getByRef ( p_handleByValue ); - - if ( reg->data.timeStamp < timeStamp ) - { - memcpy ( reg->data.dataLocation, data, currentElements * elementSize ); - } - - reg->data.nbrElements = currentElements; -} -void smPipe::copyData ( int p_handleByValue ) -{ - memcpy ( byValue.getByRef ( p_handleByValue )->data.dataLocation, data, currentElements * elementSize ); - ( byValue.getByRef ( p_handleByValue )->data.nbrElements ) = currentElements; -} -void smPipe::print() const -{ - byRefs.print(); - byValue.print(); -} -bool operator== ( smPipe& p_pipe, std::string p_name ) -{ - return ( p_pipe.name == p_name ? true : false ); -} diff --git a/src/Core/Pipe.h b/src/Core/Pipe.h deleted file mode 100644 index 959607539a46c7009cb4b3bf5bbefc8dc5282bcc..0000000000000000000000000000000000000000 --- a/src/Core/Pipe.h +++ /dev/null @@ -1,138 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and 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 -// -// 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. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef SMPIPE_H -#define SMPIPE_H - -// STL includes -#include <cstdlib> -#include <cstring> -#include <iostream> -#include <mutex> -#include <condition_variable> - -// SimMedTK includes -#include "Config.h" -#include "CoreClass.h" -#include "DataStructures.h" - -#define SIMMEDTK_PIPE_MAXLISTENERS 10 - -/// \brief pipe registration type such as reference or a value -enum smPipeRegType -{ - SIMMEDTK_PIPE_BYREF, - SIMMEDTK_PIPE_BYVALUE -}; -/// \brief pipe type -enum smPipeType -{ - SIMMEDTK_PIPE_TYPEREF, - SIMMEDTK_PIPE_TYPEVALUE, - SIMMEDTK_PIPE_TYPEANY -}; -/// \brief holder for pipe data -struct smPipeData -{ - smPipeData(); - - void *dataLocation;//if the data is call-by-value data is written here - volatile int nbrElements; - volatile bool dataReady;///flag is raised when the data is ready - volatile unsigned int timeStamp; -}; -/// \brief pipe registration holder -struct smPipeRegisteration -{ - /// \brief constructor - smPipeRegisteration(); - - smPipeRegisteration(smPipeRegType p_reg); - - smCoreClass *listenerObject;///pointer to the listener for future use - smPipeData data;///information about the data. - smPipeRegType regType;///registration type. Will it be reference or value registration. - /// \brief print pipe registration information - void print(); - -}; -/// \brief pipe is used for communication among the entities in the framework -class smPipe: public smCoreClass -{ -protected: - /// \brief pipe stype - smPipeType pipeType; - /// \brief number of elements - int maxElements; - /// \brief pointer to the data - void *data; - /// \brief enable/disable - bool enabled; - /// \brief indices to the objects that register by reference - smIndiceArray<smPipeRegisteration*> byRefs; - /// \brief ndices to the objects that register by value - smIndiceArray<smPipeRegisteration*> byValue; - /// \brief number of current elements in the pipe - volatile int currentElements; - volatile unsigned int timeStamp;//For stamping the data - /// \brief element size - volatile int elementSize; - -public: - /// \brief destructor - ~smPipe(); - /// \brief pipe constructor - smPipe(std::string p_name, int p_elementSize, int p_maxElements, - smPipeType p_pipeType = SIMMEDTK_PIPE_TYPEANY); - /// \brief get maximum number of elements - int getElements(); - /// \brief begin writing - void *beginWrite(); - /// \brief end writing - void endWrite(int p_elements); - /// \brief register for the pipe - int registerListener(smPipeRegisteration *p_pipeReg); - - ///Acknowledge only raises the flag so that it will enable the listeners - void acknowledgeRefListeners(); - - ///This is for copy-by-value listeners..With this, the data will be copied to the listener provided data location - void acknowledgeValueListeners(); - - ///For copy by value, the function checks - void checkAndCopyNewData(int p_handleByValue); - - ///for copy by value usage - void copyData(int p_handleByValue); - - friend bool operator==(smPipe &p_pipe, std::string p_name); - /// \brief print all the listeners (both reference and value) - void print() const; -}; -/// \brief secure pipe is for consumer-producer relation. not implemented yet -class smSecurePipe: public smPipe -{ - -}; - -#endif // SMPIPE_H diff --git a/src/Core/Quaternion.h b/src/Core/Quaternion.h index 87972f53dee1e0b7ca55b0dcf741e51e5dd4f210..2312be1e2621582c51d411bc599e970dac613a8d 100644 --- a/src/Core/Quaternion.h +++ b/src/Core/Quaternion.h @@ -33,13 +33,13 @@ /// A quaternion. template<typename T> -using smQuaternion = Eigen::Quaternion<T>; +using Quaternion = Eigen::Quaternion<T>; /// A quaternion of floats. -using smQuaternionf = smQuaternion<float>; +using Quaternionf = Quaternion<float>; /// A quaternion of doubles. -using smQuaterniond = smQuaternion<double>; +using Quaterniond = Quaternion<double>; /// Create a quaternion rotation corresponding to the specified angle (in radians) and axis. /// \tparam T the numeric data type. diff --git a/src/Core/RenderDelegate.h b/src/Core/RenderDelegate.h index 2f28afe1f3f631b509edd3f3c5115ecdafdf8600..a5d8d2b77473fb1b957fdaa7dda2fa7cc23d029b 100644 --- a/src/Core/RenderDelegate.h +++ b/src/Core/RenderDelegate.h @@ -1,14 +1,14 @@ #ifndef SMRENDERABLE_H #define SMRENDERABLE_H -#include "RenderDetail.h" // for smGeometrySource +#include "RenderDetail.h" // for GeometrySource #include <memory> // for shared_ptr -class smRenderDelegate +class RenderDelegate { public: - typedef std::shared_ptr<smRenderDelegate> Ptr; + typedef std::shared_ptr<RenderDelegate> Ptr; virtual void initDraw() const { } @@ -27,7 +27,7 @@ public: { return this->sourceGeometry.sourceAs<T>(); } protected: - smGeometrySource sourceGeometry; // object to render when draw() is called + GeometrySource sourceGeometry; // object to render when draw() is called }; #endif // SMRENDERABLE_H diff --git a/src/Core/RenderDetail.cpp b/src/Core/RenderDetail.cpp index 70b3e66099b0150f3d45c43bf26ecf98ce6d7522..791a87103402462a88976993591d82c70b6859c9 100644 --- a/src/Core/RenderDetail.cpp +++ b/src/Core/RenderDetail.cpp @@ -16,32 +16,32 @@ #include "RenderDetail.h" //#include "Shader/Shader.h" -void smRenderDetail::addShader(std::shared_ptr<smUnifiedId> p_shaderID) +void RenderDetail::addShader(std::shared_ptr<UnifiedId> p_shaderID) { shaderEnable.push_back(true); shaders.push_back(p_shaderID); } -void smRenderDetail::addVAO(std::shared_ptr<smUnifiedId> p_shaderID) +void RenderDetail::addVAO(std::shared_ptr<UnifiedId> p_shaderID) { VAOs.push_back(p_shaderID); VAOEnable.push_back(true); } -smRenderDetail::smRenderDetail() +RenderDetail::RenderDetail() { this->reset(); } -smRenderDetail::smRenderDetail(unsigned int type) +RenderDetail::RenderDetail(unsigned int type) { this->reset(); normalLength = 1.0; this->renderType = type; } -void smRenderDetail::reset() +void RenderDetail::reset() { renderType = 0; highLightColor.rgba[0] = 1.0f; @@ -53,138 +53,138 @@ void smRenderDetail::reset() shadowColor.rgba[1] = 0.0f; shadowColor.rgba[2] = 0.0f; shadowColor.rgba[3] = 0.5f; - colorDiffuse = smColor::colorWhite; - colorAmbient = smColor::colorWhite; - colorSpecular = smColor::colorWhite; - normalColor = smColor::colorGreen; - wireFrameColor = smColor::colorBlue; + colorDiffuse = Color::colorWhite; + colorAmbient = Color::colorWhite; + colorSpecular = Color::colorWhite; + normalColor = Color::colorGreen; + wireFrameColor = Color::colorBlue; shininess = 50.0; debugDraw = false; castShadow = true; canGetShadow = true; } -void smRenderDetail::setNormalLength(const float len) +void RenderDetail::setNormalLength(const float len) { this->normalLength = len; } -void smRenderDetail::setLineSize(const float size) +void RenderDetail::setLineSize(const float size) { this->lineSize = size; } -void smRenderDetail::setPointSize(const float size) +void RenderDetail::setPointSize(const float size) { this->pointSize = size; } -void smRenderDetail::setVertexColor(const smColor vertColor) +void RenderDetail::setVertexColor(const Color vertColor) { this->vertexRenderColor = vertColor; } -void smRenderDetail::setNormalColor(const smColor normColor) +void RenderDetail::setNormalColor(const Color normColor) { this->normalColor = normColor; } -void smRenderDetail::setDiffuseColor(const smColor diffColor) +void RenderDetail::setDiffuseColor(const Color diffColor) { this->colorDiffuse = diffColor; } -void smRenderDetail::setAmbientColor(const smColor ambColor) +void RenderDetail::setAmbientColor(const Color ambColor) { this->colorAmbient = ambColor; } -void smRenderDetail::setSpecularColor(const smColor specColor) +void RenderDetail::setSpecularColor(const Color specColor) { this->colorSpecular = specColor; } -void smRenderDetail::setShadowColor(const smColor shadColor) +void RenderDetail::setShadowColor(const Color shadColor) { this->shadowColor = shadColor; } -void smRenderDetail::setWireframeColor(const smColor wireColor) +void RenderDetail::setWireframeColor(const Color wireColor) { this->wireFrameColor = wireColor; } -void smRenderDetail::setShininess(const float s) +void RenderDetail::setShininess(const float s) { this->shininess = s; } -void smRenderDetail::setHighlightColor(const smColor highlightColor) +void RenderDetail::setHighlightColor(const Color highlightColor) { this->highLightColor = highlightColor; } -const smColor& smRenderDetail::getColorDiffuse() const +const Color& RenderDetail::getColorDiffuse() const { return colorDiffuse; } -const smColor& smRenderDetail::getColorAmbient() const +const Color& RenderDetail::getColorAmbient() const { return colorAmbient; } -const smColor& smRenderDetail::getColorSpecular() const +const Color& RenderDetail::getColorSpecular() const { return colorSpecular; } -const float& smRenderDetail::getShininess() const +const float& RenderDetail::getShininess() const { return shininess; } -const unsigned int& smRenderDetail::getRenderType() const +const unsigned int& RenderDetail::getRenderType() const { return renderType; } -const float& smRenderDetail::getPointSize() const +const float& RenderDetail::getPointSize() const { return pointSize; } -const float& smRenderDetail::getLineSize() const +const float& RenderDetail::getLineSize() const { return lineSize; } -const smColor& smRenderDetail::getNormalColor() const +const Color& RenderDetail::getNormalColor() const { return this->normalColor; } -const smColor& smRenderDetail::getHighLightColor() const +const Color& RenderDetail::getHighLightColor() const { return this->highLightColor; } -const smColor& smRenderDetail::getVertexColor() const +const Color& RenderDetail::getVertexColor() const { return this->vertexRenderColor; } -const smColor& smRenderDetail::getShadowColor() const +const Color& RenderDetail::getShadowColor() const { return this->shadowColor; } -const bool& smRenderDetail::getCastShadow() const +const bool& RenderDetail::getCastShadow() const { return this->castShadow; } -const bool& smRenderDetail::getCanGetShadow() const +const bool& RenderDetail::getCanGetShadow() const { return this->canGetShadow; } -const smColor& smRenderDetail::getWireFrameColor() const +const Color& RenderDetail::getWireFrameColor() const { return this->wireFrameColor; } -const bool& smRenderDetail::getDebugDraw() const +const bool& RenderDetail::getDebugDraw() const { return this->debugDraw; } -const std::vector< std::shared_ptr<smUnifiedId> >& smRenderDetail::getShaders() const +const std::vector< std::shared_ptr<UnifiedId> >& RenderDetail::getShaders() const { return this->shaders; } -const std::vector< bool >& smRenderDetail::getShaderEnable() const +const std::vector< bool >& RenderDetail::getShaderEnable() const { return this->shaderEnable; } -const std::vector< std::shared_ptr<smUnifiedId> >& smRenderDetail::getVAOs() const +const std::vector< std::shared_ptr<UnifiedId> >& RenderDetail::getVAOs() const { return this->VAOs; } -const std::vector< bool >& smRenderDetail::getVAOEnable() const +const std::vector< bool >& RenderDetail::getVAOEnable() const { return this->VAOEnable; } diff --git a/src/Core/RenderDetail.h b/src/Core/RenderDetail.h index 4cda36ae4ed6cb96f4e850251c911dc561791df6..29b3f31bc6255530446560baa0f6ff83c03d3c55 100644 --- a/src/Core/RenderDetail.h +++ b/src/Core/RenderDetail.h @@ -23,24 +23,24 @@ #include <memory> #include <vector> -class smVisualArtifact; -class smCoreClass; -struct smUnifiedId; +class VisualArtifact; +class CoreClass; +struct UnifiedId; ///\brief Hold a pointer to a source of geometry that render details can use for drawing. -struct smGeometrySource { - smCoreClass* sceneObject; - smVisualArtifact* analyticObject; +struct GeometrySource { + CoreClass* sceneObject; + VisualArtifact* analyticObject; - smGeometrySource() + GeometrySource() : sceneObject(nullptr), analyticObject(nullptr) { } - void setSource(smCoreClass* src) + void setSource(CoreClass* src) { this->sceneObject = src; this->analyticObject = nullptr; } - void setSource(smVisualArtifact* src) + void setSource(VisualArtifact* src) { this->sceneObject = nullptr; this->analyticObject = src; @@ -57,29 +57,29 @@ struct smGeometrySource { } }; -/// \brief smRenderDetail has rendering options and features. +/// \brief RenderDetail has rendering options and features. ///It shows how the mesh should be rendered -struct smRenderDetail +struct RenderDetail { public: - typedef std::shared_ptr<smRenderDetail> Ptr; + typedef std::shared_ptr<RenderDetail> Ptr; - smRenderDetail(); - smRenderDetail(unsigned int type); + RenderDetail(); + RenderDetail(unsigned int type); void reset(); /// \brief attachment of shader - void addShader(std::shared_ptr<smUnifiedId> p_shaderID); + void addShader(std::shared_ptr<UnifiedId> p_shaderID); /// \brief attachment of VAO - void addVAO(std::shared_ptr<smUnifiedId> p_shaderID); + void addVAO(std::shared_ptr<UnifiedId> p_shaderID); - const smColor &getColorDiffuse() const; + const Color &getColorDiffuse() const; - const smColor &getColorAmbient() const; + const Color &getColorAmbient() const; - const smColor &getColorSpecular() const; + const Color &getColorSpecular() const; const float &getShininess() const; @@ -89,27 +89,27 @@ public: const float &getLineSize() const; - const smColor &getNormalColor() const; + const Color &getNormalColor() const; - const smColor &getHighLightColor() const; + const Color &getHighLightColor() const; - const smColor &getVertexColor() const; + const Color &getVertexColor() const; - const smColor &getShadowColor() const; + const Color &getShadowColor() const; const bool &getCastShadow() const; const bool &getCanGetShadow() const; - const smColor &getWireFrameColor() const; + const Color &getWireFrameColor() const; const bool &getDebugDraw() const; - const std::vector<std::shared_ptr<smUnifiedId>> &getShaders() const; + const std::vector<std::shared_ptr<UnifiedId>> &getShaders() const; const std::vector<bool> &getShaderEnable() const; - const std::vector<std::shared_ptr<smUnifiedId>> &getVAOs() const; + const std::vector<std::shared_ptr<UnifiedId>> &getVAOs() const; const std::vector<bool> &getVAOEnable() const; @@ -117,46 +117,46 @@ public: void setLineSize(const float size); - void setVertexColor(const smColor vertColor); + void setVertexColor(const Color vertColor); - void setHighlightColor(const smColor highlightColor); + void setHighlightColor(const Color highlightColor); - void setNormalColor(const smColor highlightColor); + void setNormalColor(const Color highlightColor); void setShininess(const float s); void setNormalLength(const float len); - void setDiffuseColor(const smColor diffColor); + void setDiffuseColor(const Color diffColor); - void setAmbientColor(const smColor ambColor); + void setAmbientColor(const Color ambColor); - void setSpecularColor(const smColor specColor); + void setSpecularColor(const Color specColor); - void setShadowColor(const smColor shadColor); + void setShadowColor(const Color shadColor); - void setWireframeColor(const smColor wireColor); + void setWireframeColor(const Color wireColor); public: unsigned int renderType; // render type - smColor colorDiffuse; // diffuse color - smColor colorAmbient; // ambient color - smColor colorSpecular; // specular color - smColor highLightColor; // highlight color - smColor vertexRenderColor; // vertex color - smColor shadowColor; // shadow color + Color colorDiffuse; // diffuse color + Color colorAmbient; // ambient color + Color colorSpecular; // specular color + Color highLightColor; // highlight color + Color vertexRenderColor; // vertex color + Color shadowColor; // shadow color bool castShadow; // object can generate a shadow or not bool canGetShadow; // object can get the shadow or not - smColor normalColor; // normal color - smColor wireFrameColor; // wire frame color + Color normalColor; // normal color + Color wireFrameColor; // wire frame color float pointSize; // point size if rendering of vertices are enabled float lineSize; // line width size float shininess; // specular shinness bool debugDraw; // debug draw enabled or not float normalLength; // length of rendered normals - std::vector<std::shared_ptr<smUnifiedId>> shaders; // attached shaders + std::vector<std::shared_ptr<UnifiedId>> shaders; // attached shaders std::vector<bool> shaderEnable; // enable/disable any attached shader - std::vector<std::shared_ptr<smUnifiedId>> VAOs; // stores VAO IDs + std::vector<std::shared_ptr<UnifiedId>> VAOs; // stores VAO IDs std::vector<bool> VAOEnable; // enable/disable any attached VAO }; diff --git a/src/Core/SDK.cpp b/src/Core/SDK.cpp index bbfd5c41cb059ff4c9327cf4dcaf4195f1efe603..2e98a24c4e0098502ad2e7a644817580bcf71621 100644 --- a/src/Core/SDK.cpp +++ b/src/Core/SDK.cpp @@ -29,18 +29,18 @@ #include <string> /// \brief SDK is singlenton class -// std::unique_ptr<smErrorLog> smSDK::errorLog; -std::once_flag smSDK::sdkCallOnceFlag; +// std::unique_ptr<ErrorLog> SDK::errorLog; +std::once_flag SDK::sdkCallOnceFlag; -smIndiceArray<smMeshHolder> *smSDK::meshesRef; -smIndiceArray<smModuleHolder> *smSDK::modulesRef; -smIndiceArray<smObjectSimulatorHolder> *smSDK::objectSimulatorsRef; -smIndiceArray<smObjectSimulatorHolder>*smSDK::collisionDetectorsRef; -smIndiceArray<smSceneHolder>*smSDK::scenesRef; -smIndiceArray<smSceneObjectHolder>*smSDK::sceneObjectsRef; +IndiceArray<MeshHolder> *SDK::meshesRef; +IndiceArray<ModuleHolder> *SDK::modulesRef; +IndiceArray<ObjectSimulatorHolder> *SDK::objectSimulatorsRef; +IndiceArray<ObjectSimulatorHolder>*SDK::collisionDetectorsRef; +IndiceArray<SceneHolder>*SDK::scenesRef; +IndiceArray<SceneObjectHolder>*SDK::sceneObjectsRef; /// \brief constructor -smSDK::smSDK() +SDK::SDK() { shutdown = false; sceneIdCounter = 1; @@ -50,39 +50,39 @@ smSDK::smSDK() simulator = nullptr; sceneList.clear(); - errorLog = std::make_shared<smErrorLog>(); + errorLog = std::make_shared<ErrorLog>(); // TODO: Fix these! Leaking... - meshesRef = new smIndiceArray<smMeshHolder>(SIMMEDTK_SDK_MAXMESHES); - modulesRef = new smIndiceArray<smModuleHolder>(SIMMEDTK_SDK_MAXMODULES) ; - objectSimulatorsRef = new smIndiceArray<smObjectSimulatorHolder>(SIMMEDTK_SDK_MAXOBJECTSIMULATORS); - collisionDetectorsRef = new smIndiceArray<smObjectSimulatorHolder>(SIMMEDTK_SDK_MAXOBJECTSIMULATORS) ; - scenesRef = new smIndiceArray<smSceneHolder>(SIMMEDTK_SDK_MAXSCENES); - sceneObjectsRef = new smIndiceArray<smSceneObjectHolder>(SIMMEDTK_SDK_MAXSCENEOBJTECTS); + meshesRef = new IndiceArray<MeshHolder>(SIMMEDTK_SDK_MAXMESHES); + modulesRef = new IndiceArray<ModuleHolder>(SIMMEDTK_SDK_MAXMODULES) ; + objectSimulatorsRef = new IndiceArray<ObjectSimulatorHolder>(SIMMEDTK_SDK_MAXOBJECTSIMULATORS); + collisionDetectorsRef = new IndiceArray<ObjectSimulatorHolder>(SIMMEDTK_SDK_MAXOBJECTSIMULATORS) ; + scenesRef = new IndiceArray<SceneHolder>(SIMMEDTK_SDK_MAXSCENES); + sceneObjectsRef = new IndiceArray<SceneObjectHolder>(SIMMEDTK_SDK_MAXSCENEOBJTECTS); } -smSDK::~smSDK() +SDK::~SDK() { std::cout << "Killing SDK" << std::endl; } /// \brief creates the scene of the simulator -std::shared_ptr<smScene> smSDK::createScene() +std::shared_ptr<Scene> SDK::createScene() { - auto scene = std::make_shared<smScene>(errorLog); + auto scene = std::make_shared<Scene>(errorLog); registerScene(scene); scene->setName("Scene" + std::to_string(scene->getUniqueId()->getId())); return scene; } -void smSDK::releaseScene(std::shared_ptr<smScene> scene) +void SDK::releaseScene(std::shared_ptr<Scene> scene) { scene.reset(); } -std::shared_ptr<smViewerBase> smSDK::createViewer() +std::shared_ptr<ViewerBase> SDK::createViewer() { - this->viewer = smFactory<smCoreClass>::createDefaultAs<smViewerBase>("ViewerBase"); + this->viewer = Factory<CoreClass>::createDefaultAs<ViewerBase>("ViewerBase"); if (!!this->viewer) { this->viewer->log = this->errorLog; @@ -92,7 +92,7 @@ std::shared_ptr<smViewerBase> smSDK::createViewer() return this->viewer; } -void smSDK::addViewer(std::shared_ptr<smViewerBase> p_viewer) +void SDK::addViewer(std::shared_ptr<ViewerBase> p_viewer) { assert(p_viewer); @@ -104,17 +104,17 @@ void smSDK::addViewer(std::shared_ptr<smViewerBase> p_viewer) /// \brief Returns a pointer to the viewer object /// /// \return Returns a pointer to the viewer object -std::shared_ptr<smViewerBase> smSDK::getViewerInstance() +std::shared_ptr<ViewerBase> SDK::getViewerInstance() { return this->viewer; } /// \brief -std::shared_ptr<smSimulator> smSDK::createSimulator() +std::shared_ptr<Simulator> SDK::createSimulator() { if (this->simulator == nullptr) { - simulator = std::make_shared<smSimulator>(errorLog); + simulator = std::make_shared<Simulator>(errorLog); for (int j = 0; j < (*scenesRef).size(); j++) { @@ -128,12 +128,12 @@ std::shared_ptr<smSimulator> smSDK::createSimulator() } /// \brief -void smSDK::updateSceneListAll() +void SDK::updateSceneListAll() { } /// \brief Initialize all modules registered to the SimMedTK SDK -void smSDK::initRegisteredModules() +void SDK::initRegisteredModules() { for (int i = 0; i < modulesRef->size(); i++) @@ -145,14 +145,14 @@ void smSDK::initRegisteredModules() /** \brief Run the registered modules * - * This will not run any modules that inherit smViewerBase as + * This will not run any modules that inherit ViewerBase as * on some platforms (Mac OS X) only the main thread can run * user interface code. The return value is -1 if the modules - * are already running or no module inherits smViewerBase. + * are already running or no module inherits ViewerBase. * Otherwise, the index of the last viewer module encountered * is returned. */ -int smSDK::runRegisteredModules() +int SDK::runRegisteredModules() { int viewerIndex = -1; @@ -163,7 +163,7 @@ int smSDK::runRegisteredModules() for (int i = 0; i < modulesRef->size(); i++) { - auto view = std::dynamic_pointer_cast<smViewerBase>((*modulesRef)[i].module); + auto view = std::dynamic_pointer_cast<ViewerBase>((*modulesRef)[i].module); if (view) viewerIndex = i; else @@ -175,7 +175,7 @@ int smSDK::runRegisteredModules() } ///\brief shutdowns all the modules -void smSDK::shutDown() +void SDK::shutDown() { for (int i = 0; i < modulesRef->size(); i++) @@ -186,7 +186,7 @@ void smSDK::shutDown() } /// \brief runs the simulator -void smSDK::run() +void SDK::run() { updateSceneListAll(); initRegisteredModules(); @@ -208,29 +208,29 @@ void smSDK::run() } /// \brief -void smSDK::addRef(std::shared_ptr<smCoreClass> p_coreClass) +void SDK::addRef(std::shared_ptr<CoreClass> p_coreClass) { ++*p_coreClass; } /// \brief -void smSDK::removeRef(std::shared_ptr<smCoreClass> p_coreClass) +void SDK::removeRef(std::shared_ptr<CoreClass> p_coreClass) { --*p_coreClass; } -std::shared_ptr<smSDK> smSDK::createSDK() +std::shared_ptr<SDK> SDK::createSDK() { - static std::shared_ptr<smSDK> sdk; ///< singleton sdk. + static std::shared_ptr<SDK> sdk; ///< singleton sdk. std::call_once(sdkCallOnceFlag, [] { - sdk.reset(new smSDK); + sdk.reset(new SDK); }); return sdk; } -std::shared_ptr<smSDK> smSDK::createStandardSDK() +std::shared_ptr<SDK> SDK::createStandardSDK() { auto sdk = createSDK(); @@ -242,12 +242,12 @@ std::shared_ptr<smSDK> smSDK::createStandardSDK() return sdk; } -std::shared_ptr<smSDK> smSDK::getInstance() +std::shared_ptr<SDK> SDK::getInstance() { - return smSDK::createSDK(); + return SDK::createSDK(); } -void smSDK::terminateAll() +void SDK::terminateAll() { for(int i = 0; i < (*modulesRef).size(); i++) @@ -270,49 +270,49 @@ void smSDK::terminateAll() } /// \brief register functions -int smSDK::registerMesh(std::shared_ptr<smBaseMesh> p_mesh) +int SDK::registerMesh(std::shared_ptr<smBaseMesh> p_mesh) { - smMeshHolder mh; + MeshHolder mh; mh.mesh = p_mesh; return meshesRef->checkAndAdd(mh); } -int smSDK::registerModule(std::shared_ptr<smModule> p_mod) +int SDK::registerModule(std::shared_ptr<Module> p_mod) { - smModuleHolder mh; + ModuleHolder mh; mh.module = p_mod; return modulesRef->checkAndAdd(mh); } -void smSDK::registerObjectSim(std::shared_ptr<smObjectSimulator> p_os) +void SDK::registerObjectSim(std::shared_ptr<ObjectSimulator> p_os) { - smObjectSimulatorHolder os; + ObjectSimulatorHolder os; os.objectSim = p_os; objectSimulatorsRef->checkAndAdd(os); } -void smSDK::registerCollDet(std::shared_ptr<smObjectSimulator> p_col) +void SDK::registerCollDet(std::shared_ptr<ObjectSimulator> p_col) { - smObjectSimulatorHolder col; + ObjectSimulatorHolder col; col.objectSim = p_col; collisionDetectorsRef->checkAndAdd(col); } -void smSDK::registerScene(std::shared_ptr<smScene> p_sc) +void SDK::registerScene(std::shared_ptr<Scene> p_sc) { - smSceneHolder sc; + SceneHolder sc; sc.scene = p_sc; scenesRef->checkAndAdd(sc); } -void smSDK::registerSceneObject(std::shared_ptr<smSceneObject> p_sco) +void SDK::registerSceneObject(std::shared_ptr<SceneObject> p_sco) { - smSceneObjectHolder sh; + SceneObjectHolder sh; sh.sceneObject = p_sco; sceneObjectsRef->checkAndAdd(sh); } -void smSDK::addSceneActor(std::shared_ptr<smSceneObject> p_sco, std::shared_ptr<smObjectSimulator> p_os, int p_scId) +void SDK::addSceneActor(std::shared_ptr<SceneObject> p_sco, std::shared_ptr<ObjectSimulator> p_os, int p_scId) { assert(p_os); assert(p_sco); @@ -327,12 +327,12 @@ void smSDK::addSceneActor(std::shared_ptr<smSceneObject> p_sco, std::shared_ptr< } ///SDK returns logger for the system -std::shared_ptr<smErrorLog> smSDK::getErrorLog() +std::shared_ptr<ErrorLog> SDK::getErrorLog() { return errorLog; }; -std::shared_ptr<smSimulator> smSDK::getSimulator() +std::shared_ptr<Simulator> SDK::getSimulator() { return this->simulator; } diff --git a/src/Core/SDK.h b/src/Core/SDK.h index 3bc4f4f606b48e85a064ffadf34bb0957c9c9c4b..1067899565bfac560eeff75ccf905b5989342252 100644 --- a/src/Core/SDK.h +++ b/src/Core/SDK.h @@ -42,9 +42,8 @@ #define SIMMEDTK_SDK_MAXSCENEOBJTECTS 100 class smMotionTransformer; -class smPipe; -template<typename T> class smIndiceArray; -class smScene; +template<typename T> class IndiceArray; +class Scene; /// \brief module registration enum smSDKReturnType @@ -53,71 +52,68 @@ enum smSDKReturnType SIMMEDTK_SDK_MODULEREGISTEREDALREADY }; -struct smBaseHolder -{ -}; /// \brief mesh holder -struct smMeshHolder: public smBaseHolder +struct MeshHolder { - smMeshHolder() + MeshHolder() { mesh = NULL; } std::shared_ptr<smBaseMesh> mesh; - inline bool operator ==(smMeshHolder &p_param) + inline bool operator ==(MeshHolder &p_param) { return mesh == p_param.mesh; } }; /// \brief module holder -struct smModuleHolder: public smBaseHolder +struct ModuleHolder { - smModuleHolder() + ModuleHolder() { module = NULL; } - std::shared_ptr<smModule> module; + std::shared_ptr<Module> module; - inline bool operator ==(smModuleHolder &p_param) + inline bool operator ==(ModuleHolder &p_param) { return module == p_param.module; } }; /// \brief simulator holder -struct smObjectSimulatorHolder: public smBaseHolder +struct ObjectSimulatorHolder { - smObjectSimulatorHolder() + ObjectSimulatorHolder() { objectSim = NULL; } - std::shared_ptr<smObjectSimulator> objectSim; + std::shared_ptr<ObjectSimulator> objectSim; - inline bool operator ==(smObjectSimulatorHolder &p_param) + inline bool operator ==(ObjectSimulatorHolder &p_param) { return objectSim == p_param.objectSim; } }; /// \brief scene holders -struct smSceneHolder: public smBaseHolder +struct SceneHolder { - smSceneHolder() + SceneHolder() { scene = NULL; } - std::shared_ptr<smScene> scene; - inline bool operator ==(smSceneHolder &p_param) + std::shared_ptr<Scene> scene; + inline bool operator ==(SceneHolder &p_param) { return scene == p_param.scene; } @@ -125,47 +121,25 @@ struct smSceneHolder: public smBaseHolder }; /// \brief scene object holder -struct smSceneObjectHolder: public smBaseHolder +struct SceneObjectHolder { - smSceneObjectHolder() + SceneObjectHolder() { sceneObject = NULL; } - std::shared_ptr<smSceneObject> sceneObject; - inline bool operator ==(smSceneObjectHolder &p_param) + std::shared_ptr<SceneObject> sceneObject; + inline bool operator ==(SceneObjectHolder &p_param) { return sceneObject == p_param.sceneObject; } }; -/// \brief pipe holder -struct smPipeHolder: public smBaseHolder -{ - - smPipe *pipe; - - smPipeHolder() - { - pipe = NULL; - } - - inline bool operator ==(smPipeHolder &p_param) - { - return pipe == p_param.pipe; - } - - inline friend bool operator==(smPipeHolder &p_pipe, std::string &p_name) - { - return (*(p_pipe.pipe) == p_name); - } - -}; /// \brief SDK class. it is a singlenton class for each machine runs the framework -class smSDK: public smCoreClass +class SDK: public CoreClass { private: static std::once_flag sdkCallOnceFlag; @@ -176,27 +150,27 @@ private: char argv; bool isModulesStarted; - std::shared_ptr<smErrorLog> errorLog; ///< error log - std::shared_ptr<smViewerBase> viewer; ///< Reference to the sdk viewer object - std::shared_ptr<smSimulator> simulator; ///< Reference to the sdk simulator object - std::vector<std::shared_ptr<smScene>> sceneList; ///< scene list + std::shared_ptr<ErrorLog> errorLog; ///< error log + std::shared_ptr<ViewerBase> viewer; ///< Reference to the sdk viewer object + std::shared_ptr<Simulator> simulator; ///< Reference to the sdk simulator object + std::vector<std::shared_ptr<Scene>> sceneList; ///< scene list ///holds the references to the entities in the framework - static smIndiceArray<smMeshHolder> *meshesRef; - static smIndiceArray<smModuleHolder> *modulesRef; - static smIndiceArray<smObjectSimulatorHolder> *objectSimulatorsRef; - static smIndiceArray<smObjectSimulatorHolder> *collisionDetectorsRef; - static smIndiceArray<smSceneHolder> *scenesRef; - static smIndiceArray<smSceneObjectHolder> *sceneObjectsRef; + static IndiceArray<MeshHolder> *meshesRef; + static IndiceArray<ModuleHolder> *modulesRef; + static IndiceArray<ObjectSimulatorHolder> *objectSimulatorsRef; + static IndiceArray<ObjectSimulatorHolder> *collisionDetectorsRef; + static IndiceArray<SceneHolder> *scenesRef; + static IndiceArray<SceneObjectHolder> *sceneObjectsRef; std::vector<std::thread> modules; ///< Stores a list of running module threads /// \brief constructor - smSDK(); + SDK(); public: /// \brief destructor - ~smSDK(); + ~SDK(); /// \brief update scene list. not implemented void updateSceneListAll(); @@ -206,71 +180,71 @@ public: void shutDown(); ///for now both functions below are the same. But it maybe subject to change. - static std::shared_ptr<smSDK> createSDK(); + static std::shared_ptr<SDK> createSDK(); ///Creates the sdk, viewer and scene 0 - static std::shared_ptr<smSDK> createStandardSDK(); + static std::shared_ptr<SDK> createStandardSDK(); - static std::shared_ptr<smSDK> getInstance(); + static std::shared_ptr<SDK> getInstance(); /// \brief Registers a viewer object with the SDK /// - void addViewer(std::shared_ptr<smViewerBase> p_viewer); + void addViewer(std::shared_ptr<ViewerBase> p_viewer); /// \brief Creates and registers a viewer object with the SDK /// - std::shared_ptr<smViewerBase> createViewer(); + std::shared_ptr<ViewerBase> createViewer(); ///SDK returns a pointer to the viewer - std::shared_ptr<smViewerBase> getViewerInstance(); + std::shared_ptr<ViewerBase> getViewerInstance(); ///SDK creates simualtor - std::shared_ptr<smSimulator> createSimulator(); + std::shared_ptr<Simulator> createSimulator(); ///SDK creates simualtor - std::shared_ptr<smSimulator> getSimulator(); + std::shared_ptr<Simulator> getSimulator(); ///SDK creates scene - std::shared_ptr<smScene> createScene(); + std::shared_ptr<Scene> createScene(); ///SDK creates scene - std::shared_ptr<smScene> getScene(size_t sceneId) + std::shared_ptr<Scene> getScene(size_t sceneId) { return scenesRef->getByRef(sceneId).scene; } ///SDK returns logger for the system - std::shared_ptr<smErrorLog> getErrorLog(); + std::shared_ptr<ErrorLog> getErrorLog(); ///terminates every module. Do it later on with smMessager void terminateAll(); ///release the scene from the SDK..not implemented yet - void releaseScene(std::shared_ptr<smScene> scene); + void releaseScene(std::shared_ptr<Scene> scene); /// \brief run the SDK void run(); /// \brief add reference to a core class - void addRef(std::shared_ptr<smCoreClass> p_coreClass); + void addRef(std::shared_ptr<CoreClass> p_coreClass); /// \brief removes reference on core class - void removeRef(std::shared_ptr<smCoreClass> p_coreClass); + void removeRef(std::shared_ptr<CoreClass> p_coreClass); /// \brief register functions int registerMesh(std::shared_ptr<smBaseMesh> p_mesh); - int registerModule(std::shared_ptr<smModule> p_mod); + int registerModule(std::shared_ptr<Module> p_mod); - void registerObjectSim(std::shared_ptr<smObjectSimulator> p_os); + void registerObjectSim(std::shared_ptr<ObjectSimulator> p_os); - void registerCollDet(std::shared_ptr<smObjectSimulator> p_col); + void registerCollDet(std::shared_ptr<ObjectSimulator> p_col); - void registerScene(std::shared_ptr<smScene> p_sc); + void registerScene(std::shared_ptr<Scene> p_sc); - void registerSceneObject(std::shared_ptr<smSceneObject> p_sco); + void registerSceneObject(std::shared_ptr<SceneObject> p_sco); - void addSceneActor(std::shared_ptr<smSceneObject> p_sco, std::shared_ptr<smObjectSimulator> p_os, int p_scId=0); + void addSceneActor(std::shared_ptr<SceneObject> p_sco, std::shared_ptr<ObjectSimulator> p_os, int p_scId=0); }; #endif diff --git a/src/Core/Scene.cpp b/src/Core/Scene.cpp index d1e3365d4026dbf40c4aa7fa21758e8501308189..544a2f0cd924a7ab6c8ba7b6aab1aadbf3871bef 100644 --- a/src/Core/Scene.cpp +++ b/src/Core/Scene.cpp @@ -24,32 +24,32 @@ #include "Scene.h" -smScene::smScene(std::shared_ptr<smErrorLog> p_log) : - smCoreClass() +Scene::Scene(std::shared_ptr<ErrorLog> p_log) : + CoreClass() { this->log = p_log; type = core::ClassType::Scene; sceneUpdatedTimeStamp = 0; } -std::shared_ptr<smUnifiedId> smScene::getSceneId() +std::shared_ptr<UnifiedId> Scene::getSceneId() { return this->getUniqueId(); } -std::vector<std::shared_ptr<smSceneObject>> &smScene::getSceneObject() +std::vector<std::shared_ptr<SceneObject>> &Scene::getSceneObject() { std::lock_guard<std::mutex> lock(sceneLock); //Lock is released when leaves scope return sceneObjects; } -std::shared_ptr<smScene> smScene::operator+=(std::shared_ptr<smSceneObject> p_sceneObject) +std::shared_ptr<Scene> Scene::operator+=(std::shared_ptr<SceneObject> p_sceneObject) { addSceneObject(p_sceneObject); - return safeDownCast<smScene>(); + return safeDownCast<Scene>(); } -void smScene::addSceneObject(std::shared_ptr<smSceneObject> p_sceneObject) +void Scene::addSceneObject(std::shared_ptr<SceneObject> p_sceneObject) { if (p_sceneObject != nullptr) { @@ -60,7 +60,7 @@ void smScene::addSceneObject(std::shared_ptr<smSceneObject> p_sceneObject) } /// \brief removes the scene object based on scene object id -void smScene::removeSceneObject(std::shared_ptr<smSceneObject> p_sceneObject) +void Scene::removeSceneObject(std::shared_ptr<SceneObject> p_sceneObject) { if (p_sceneObject != nullptr) { @@ -79,7 +79,7 @@ void smScene::removeSceneObject(std::shared_ptr<smSceneObject> p_sceneObject) } /// \brief removes the object from the scene based on its object id -void smScene::removeSceneObject(std::shared_ptr<smUnifiedId> p_sceneObjectId) +void Scene::removeSceneObject(std::shared_ptr<UnifiedId> p_sceneObjectId) { std::lock_guard<std::mutex> lock(sceneLock); //Lock is released when leaves scope short id = p_sceneObjectId->getId(); @@ -98,7 +98,7 @@ void smScene::removeSceneObject(std::shared_ptr<smUnifiedId> p_sceneObjectId) sceneUpdatedTimeStamp++; } -void smScene::copySceneObjects(std::shared_ptr<smScene> p_scene) +void Scene::copySceneObjects(std::shared_ptr<Scene> p_scene) { p_scene->sceneObjects.clear(); @@ -108,15 +108,15 @@ void smScene::copySceneObjects(std::shared_ptr<smScene> p_scene) } } -std::shared_ptr<smScene> smScene::operator=(std::shared_ptr<smScene> p_scene) +std::shared_ptr<Scene> Scene::operator=(std::shared_ptr<Scene> p_scene) { copySceneObjects(p_scene); - return safeDownCast<smScene>(); + return safeDownCast<Scene>(); } -void smScene::initLights() +void Scene::initLights() { - smVec3f casted; + core::Vec3f casted; for (auto light: lights) { @@ -133,16 +133,16 @@ void smScene::initLights() } } -int smScene::addLight(std::shared_ptr<smLight> p_light) +int Scene::addLight(std::shared_ptr<Light> p_light) { lights.push_back(p_light); lights.back()->renderUsage = GL_LIGHT0 + (lights.size() - 1); return (lights.size() - 1); } -void smScene::refreshLights() +void Scene::refreshLights() { - smVec3f casted; + core::Vec3f casted; for (auto light: lights) { @@ -159,22 +159,22 @@ void smScene::refreshLights() } } -void smScene::setLightPos(int p_lightId, smLightPos p_pos) +void Scene::setLightPos(int p_lightId, smLightPos p_pos) { - std::shared_ptr<smLight> temp = lights.at(p_lightId); + std::shared_ptr<Light> temp = lights.at(p_lightId); temp->lightPos = p_pos; temp->updateDirection(); } -void smScene::setLightPos(int p_lightId, smLightPos p_pos, smVec3d p_direction) +void Scene::setLightPos(int p_lightId, smLightPos p_pos, core::Vec3d p_direction) { - std::shared_ptr<smLight> temp = lights.at(p_lightId); + std::shared_ptr<Light> temp = lights.at(p_lightId); temp->lightPos = p_pos; temp->direction = p_direction; temp->updateDirection(); } -void smScene::enableLights() +void Scene::enableLights() { glEnable(GL_LIGHTING); @@ -191,7 +191,7 @@ void smScene::enableLights() } } -void smScene::disableLights() +void Scene::disableLights() { for (auto light: lights) { @@ -201,11 +201,11 @@ void smScene::disableLights() glDisable(GL_LIGHTING); } -void smScene::placeLights() +void Scene::placeLights() { for (auto light: lights) { - smVec3f casted; + core::Vec3f casted; if (!(light->isEnabled())) { continue; @@ -216,7 +216,7 @@ void smScene::placeLights() glLightf(light->renderUsage, GL_QUADRATIC_ATTENUATION, light->attn_quadratic); casted = light->lightPos.getPosition().cast<float>(); - if (light->lightLocationType == SIMMEDTK_LIGHTPOS_EYE) + if (light->lightLocationType == Light::Eye) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -230,14 +230,14 @@ void smScene::placeLights() } casted = light->direction.cast<float>(); - if (light->lightType == SIMMEDTK_LIGHT_SPOTLIGHT) + if (light->lightType == Light::Spotlight) { glLightfv(light->renderUsage, GL_SPOT_DIRECTION, casted.data()); } } } -void smScene::copySceneToLocal(smSceneLocal &p_local) +void Scene::copySceneToLocal(SceneLocal &p_local) { std::lock_guard<std::mutex> lock(this->sceneLock); //Lock is released when leaves scope diff --git a/src/Core/Scene.h b/src/Core/Scene.h index 4543663db07e1b65b26c54032dd8df43027b929c..4c38f131914060b09cf27ce0b1e563796ed5469c 100644 --- a/src/Core/Scene.h +++ b/src/Core/Scene.h @@ -32,7 +32,6 @@ // SimMedTK includes #include "Config.h" #include "CoreClass.h" -#include "Pipe.h" #include "ErrorLog.h" #include "Light.h" #include "SceneObject.h" @@ -42,64 +41,64 @@ #include "Event/MouseMoveEvent.h" #include "Rendering/Camera.h" -class smScene; -class smSDK; +class Scene; +class SDK; -struct smSceneLocal +struct SceneLocal { public: int id; - smSceneLocal() + SceneLocal() { sceneUpdatedTimeStamp = 0; } - bool operator ==(smSceneLocal &p_param) + bool operator ==(SceneLocal &p_param) { return id == p_param.id; } - std::vector<std::shared_ptr<smSceneObject>> sceneObjects; + std::vector<std::shared_ptr<SceneObject>> sceneObjects; unsigned int sceneUpdatedTimeStamp; }; ///Physics class should have all parameters such as material properties, mesh etc.. for ///note that when you remove the Physics do not delete it.Since propagation of the physics over the -class smScene: public smCoreClass +class Scene: public CoreClass { public: - smScene(std::shared_ptr<smErrorLog> p_log = nullptr); + Scene(std::shared_ptr<ErrorLog> p_log = nullptr); - virtual ~smScene(){} + virtual ~Scene(){} ///add physics in the scene - void addSceneObject(std::shared_ptr<smSceneObject> p_sceneObject); + void addSceneObject(std::shared_ptr<SceneObject> p_sceneObject); ///remove the phyics in the scene. ///The removal of the phsyics in the scene needs some sync all over the modules ///so not implemented yet. Be aware that when you remove the phyics do no free the smPhysics class - void removeSceneObject(std::shared_ptr<smSceneObject> p_sceneObject); + void removeSceneObject(std::shared_ptr<SceneObject> p_sceneObject); ///the same as - void removeSceneObject(std::shared_ptr<smUnifiedId> p_objectId); + void removeSceneObject(std::shared_ptr<UnifiedId> p_objectId); ///in order to get the phsyics in the scene call this function. ///it is thread safe. but it shouldn't be called frequently. ///it should be called in the initialization of the viewer, simulation or any other module. ///and the the list should be stored internally. ///The scene list removal will be taken care of later since the list should be update. - std::vector<std::shared_ptr<smSceneObject>> &getSceneObject(); + std::vector<std::shared_ptr<SceneObject>> &getSceneObject(); /// \brief retursn scene id - std::shared_ptr<smUnifiedId> getSceneId(); + std::shared_ptr<UnifiedId> getSceneId(); ///Same functionality as addSceneObject - std::shared_ptr<smScene> operator+=(std::shared_ptr<smSceneObject> p_sceneObject); + std::shared_ptr<Scene> operator+=(std::shared_ptr<SceneObject> p_sceneObject); - void copySceneObjects(std::shared_ptr<smScene> p_scene); + void copySceneObjects(std::shared_ptr<Scene> p_scene); - std::shared_ptr<smScene> operator=(std::shared_ptr<smScene> p_scene); + std::shared_ptr<Scene> operator=(std::shared_ptr<Scene> p_scene); /// \brief Initializes lights for rendering void initLights(); @@ -122,14 +121,14 @@ public: void placeLights(); /// \brief addlight - int addLight(std::shared_ptr<smLight> p_light); + int addLight(std::shared_ptr<Light> p_light); /// \brief refresh lights. updates light position based on the gl matrix void refreshLights(); void setLightPos(int p_lightId, smLightPos p_pos); - void setLightPos(int p_lightId, smLightPos p_pos, smVec3d p_direction); + void setLightPos(int p_lightId, smLightPos p_pos, core::Vec3d p_direction); std::shared_ptr<smCamera> getCamera() { @@ -142,13 +141,13 @@ public: } /// \brief adds the objects in the local scene storage - void copySceneToLocal(smSceneLocal &p_local); + void copySceneToLocal(SceneLocal &p_local); private: std::shared_ptr<smCamera> camera; //Camera for the scene - std::vector<std::shared_ptr<smLight> > lights; //Lights in the scene - std::vector<std::shared_ptr<smSceneObject>> sceneObjects; // scene objects storage - std::shared_ptr<smErrorLog> log; // error logging + std::vector<std::shared_ptr<Light> > lights; //Lights in the scene + std::vector<std::shared_ptr<SceneObject>> sceneObjects; // scene objects storage + std::shared_ptr<ErrorLog> log; // error logging std::mutex sceneLock; // scene list lock for thread safe manipulation of the scene unsigned int sceneUpdatedTimeStamp; // last updated time stamp }; diff --git a/src/Core/SceneObject.cpp b/src/Core/SceneObject.cpp index f217d0eef12ff8d4e9f6fdf4eafdf79c8f6535b1..f3538f55ce8d7818173f1592f33746a29be46a26 100644 --- a/src/Core/SceneObject.cpp +++ b/src/Core/SceneObject.cpp @@ -25,79 +25,79 @@ #include "ObjectSimulator.h" #include "SDK.h" -smSceneObject::smSceneObject() +SceneObject::SceneObject() { type = core::ClassType::Unknown; isActive = true; objectSim = nullptr; customRender = nullptr; - // smSDK::getInstance()->registerSceneObject(safeDownCast<smSceneObject>()); + // SDK::getInstance()->registerSceneObject(safeDownCast<SceneObject>()); flags.isViewerInit = false; flags.isSimulatorInit = false; name = "SceneObject" + std::to_string(this->getUniqueId()->getId()); } -smSceneObject::~smSceneObject() +SceneObject::~SceneObject() { } -void smSceneObject::attachObjectSimulator(std::shared_ptr<smObjectSimulator> p_objectSim) +void SceneObject::attachObjectSimulator(std::shared_ptr<ObjectSimulator> p_objectSim) { - p_objectSim->addObject(safeDownCast<smSceneObject>()); + p_objectSim->addObject(safeDownCast<SceneObject>()); } -void smSceneObject::releaseObjectSimulator() +void SceneObject::releaseObjectSimulator() { - objectSim->removeObject(safeDownCast<smSceneObject>()); + objectSim->removeObject(safeDownCast<SceneObject>()); objectSim = nullptr; } -std::shared_ptr<smObjectSimulator> smSceneObject::getObjectSimulator() +std::shared_ptr<ObjectSimulator> SceneObject::getObjectSimulator() { return objectSim; } -void smSceneObject::attachCustomRenderer(std::shared_ptr<smCustomRenderer> p_customeRenderer) +void SceneObject::attachCustomRenderer(std::shared_ptr<smCustomRenderer> p_customeRenderer) { customRender = p_customeRenderer; } -void smSceneObject::releaseCustomeRenderer() +void SceneObject::releaseCustomeRenderer() { customRender = nullptr; } -int smSceneObject::getObjectId() +int SceneObject::getObjectId() { return this->getUniqueId()->getId(); } -smUnifiedId::Pointer smSceneObject::getObjectUnifiedID() +UnifiedId::Pointer SceneObject::getObjectUnifiedID() { - return std::make_shared<smUnifiedId>(); + return std::make_shared<UnifiedId>(); } -smStdVector3d & smSceneObject::getLocalVertices() +core::StdVector3d & SceneObject::getLocalVertices() { return localVertices; } -smObjectInitFlags & smSceneObject::getFlags() +ObjectInitFlags & SceneObject::getFlags() { return flags; } -std::shared_ptr<smCustomRenderer> smSceneObject::getRenderer() +std::shared_ptr<smCustomRenderer> SceneObject::getRenderer() { return customRender; } -void smSceneObject::freeze() +void SceneObject::freeze() { this->isActive = false; } -void smSceneObject::activate() +void SceneObject::activate() { this->isActive = true; } diff --git a/src/Core/SceneObject.h b/src/Core/SceneObject.h index 2ba1cd5587a17954a1698c5e70e0e3fef13b6952..8099fd8b37619baf08bf829068bae16dfa97105d 100644 --- a/src/Core/SceneObject.h +++ b/src/Core/SceneObject.h @@ -36,11 +36,11 @@ #include "Rendering/CustomRenderer.h" //forward class declaration -class smObjectSimulator; +class ObjectSimulator; class smCustomRenderer; ///booleans for objects indicate whether they're initialized or not. -struct smObjectInitFlags +struct ObjectInitFlags { bool isViewerInit; bool isSimulatorInit; @@ -49,20 +49,20 @@ struct smObjectInitFlags /// \brief Base class for any object in the scene both /// physical and otherwise -class smSceneObject : public smCoreClass +class SceneObject : public CoreClass { - friend class smSDK; - friend class smViewerBase; + friend class SDK; + friend class ViewerBase; friend class smViewer; - friend class smScene; - friend class smObjectSimulator; + friend class Scene; + friend class ObjectSimulator; public: /// \brief constructor - smSceneObject(); + SceneObject(); /// \brief destructor - ~smSceneObject(); + ~SceneObject(); /// \brief Abstract object initialization virtual void initialize() = 0; @@ -74,7 +74,7 @@ public: /// \brief attach simulator to the object. /// This function that needs to be called to associate the simulator to the object - virtual void attachObjectSimulator(std::shared_ptr<smObjectSimulator> p_objectSim); + virtual void attachObjectSimulator(std::shared_ptr<ObjectSimulator> p_objectSim); /// \brief to release the simulator virtual void releaseObjectSimulator(); @@ -86,7 +86,7 @@ public: void activate(); /// \brief get object simulator - std::shared_ptr<smObjectSimulator> getObjectSimulator(); + std::shared_ptr<ObjectSimulator> getObjectSimulator(); /// \brief attach custome renderer for the object. /// If the default rendering is not helpful @@ -99,11 +99,11 @@ public: int getObjectId(); /// \brief get unified object id - smUnifiedId::Pointer getObjectUnifiedID(); + UnifiedId::Pointer getObjectUnifiedID(); - smStdVector3d &getLocalVertices(); + core::StdVector3d &getLocalVertices(); - smObjectInitFlags &getFlags(); + ObjectInitFlags &getFlags(); std::shared_ptr<smCustomRenderer> getRenderer(); @@ -117,7 +117,7 @@ public: ///this function may not be used ///every Scene Object should know how to clone itself. Since the data structures will be ///in the beginning of the modules(such as simulator, viewer, collision etc.) - virtual std::shared_ptr<smSceneObject> clone() = 0; + virtual std::shared_ptr<SceneObject> clone() = 0; /// \brief print information related the scene object virtual void printInfo() const = 0; @@ -126,10 +126,10 @@ protected: bool isActive; private: - std::shared_ptr<smObjectSimulator> objectSim; // object simulator that will simulate the object + std::shared_ptr<ObjectSimulator> objectSim; // object simulator that will simulate the object std::shared_ptr<smCustomRenderer> customRender; - smStdVector3d localVertices; // local copy of vertices - smObjectInitFlags flags; + core::StdVector3d localVertices; // local copy of vertices + ObjectInitFlags flags; }; #endif diff --git a/src/Core/Scheduler.h b/src/Core/Scheduler.h index f733af9ff929783f730e0eadde834bd02e1d2d63..fadc659518ac51813156cd475620a23041696b65 100644 --- a/src/Core/Scheduler.h +++ b/src/Core/Scheduler.h @@ -24,7 +24,7 @@ #ifndef SMSCHEDULER_H #define SMSCHEDULER_H -class smSimulator; +class Simulator; enum smSchedulingPriority { @@ -33,7 +33,7 @@ enum smSchedulingPriority SIMMEDTK_SCHEDULING_BACKGROUND }; -struct smScheduleGroup +struct ScheduleGroup { #ifdef _WIN32 @@ -48,7 +48,7 @@ public: short minObservedFPSThreadIndex; short maxObservedFPSThreadIndex; - smScheduleGroup() + ScheduleGroup() { totalThreads = 1; minTargetFPS = maxTargetFPS = maxObservedFPS = minObservedFPS = 0; @@ -60,7 +60,7 @@ public: } float maxTargetFPS; float minTargetFPS; - friend class smSimulator; + friend class Simulator; }; -#endif \ No newline at end of file +#endif diff --git a/src/Core/Simulator.cpp b/src/Core/Simulator.cpp index e9bbad19cce75d68115978ae502552b8040d5d85..04a3aa0fbdfe1fe5372d2d0032f73f2e384c9671 100644 --- a/src/Core/Simulator.cpp +++ b/src/Core/Simulator.cpp @@ -24,18 +24,18 @@ #include "Simulator.h" /// \brief starts the tasks with the threads from thread pool -void smSimulator::beginFrame() +void Simulator::beginFrame() { frameCounter++; } /// \brief waits until the frame ends -void smSimulator::endFrame() +void Simulator::endFrame() { } -void smSimulator::initAsyncThreadPool() +void Simulator::initAsyncThreadPool() { asyncThreadPoolSize = 0; @@ -51,11 +51,11 @@ void smSimulator::initAsyncThreadPool() } /// \brief the main simulation loop -void smSimulator::run() +void Simulator::run() { std::vector< std::future<int> > results; std::vector< std::future<int> > asyncResults; - std::shared_ptr<smObjectSimulator> objectSimulator; + std::shared_ptr<ObjectSimulator> objectSimulator; if (isInitialized == false) { @@ -64,7 +64,7 @@ void smSimulator::run() } results.reserve(this->simulators.size()); //make space for results - smSimulationMainParam param; + SimulationMainParam param; param.sceneList = sceneList; //Start up async threads @@ -137,7 +137,7 @@ void smSimulator::run() } results.clear(); //clear the results buffer for new - std::shared_ptr<smCollisionDetection> collisionDetection; + std::shared_ptr<CollisionDetection> collisionDetection; for (size_t i = 0; i < this->collisionDetectors.size(); i++) { collisionDetection = collisionDetectors[i]; @@ -172,7 +172,7 @@ void smSimulator::run() //} results.clear(); //clear the results buffer for new - std::shared_ptr<smContactHandling> contactHandling; + std::shared_ptr<ContactHandling> contactHandling; for (size_t i = 0; i < this->contactHandlers.size(); i++) { contactHandlers[i]->resolveContacts(); @@ -195,32 +195,32 @@ void smSimulator::run() } /// \brief -void smSimulator::registerObjectSimulator(std::shared_ptr<smObjectSimulator> objectSimulator) +void Simulator::registerObjectSimulator(std::shared_ptr<ObjectSimulator> objectSimulator) { simulators.emplace_back(objectSimulator); objectSimulator->enabled = true; } /// \brief -void smSimulator::registerCollisionDetection(std::shared_ptr<smCollisionDetection> p_collisionDetection) +void Simulator::registerCollisionDetection(std::shared_ptr<CollisionDetection> p_collisionDetection) { collisionDetectors.emplace_back(p_collisionDetection); } /// \brief -void smSimulator::registerContactHandling(std::shared_ptr<smContactHandling> p_contactHandling) +void Simulator::registerContactHandling(std::shared_ptr<ContactHandling> p_contactHandling) { contactHandlers.emplace_back(p_contactHandling); } /// \brief -void smSimulator::registerSimulationMain(std::shared_ptr<smSimulationMain> p_main) +void Simulator::registerSimulationMain(std::shared_ptr<SimulationMain> p_main) { changedMain = p_main; this->changedMainTimeStamp++; } -void smSimulator::init() +void Simulator::init() { if(isInitialized == true) { @@ -241,7 +241,7 @@ void smSimulator::init() isInitialized = true; } -smSimulator::smSimulator(std::shared_ptr< smErrorLog > p_log) +Simulator::Simulator(std::shared_ptr< ErrorLog > p_log) { type = core::ClassType::Simulator; isInitialized = false; @@ -255,7 +255,7 @@ smSimulator::smSimulator(std::shared_ptr< smErrorLog > p_log) asyncThreadPoolSize = 0; } -void smSimulator::setMaxThreadCount(int p_threadMaxCount) +void Simulator::setMaxThreadCount(int p_threadMaxCount) { if(p_threadMaxCount < 0) { @@ -267,7 +267,7 @@ void smSimulator::setMaxThreadCount(int p_threadMaxCount) } } -void smSimulator::exec() +void Simulator::exec() { if(isInitialized) { diff --git a/src/Core/Simulator.h b/src/Core/Simulator.h index 85156d3744dae697323c1c42ffdac66b9cae37d4..04c53f0c89bc325e1cac0a56294b453cddacf18d 100644 --- a/src/Core/Simulator.h +++ b/src/Core/Simulator.h @@ -37,21 +37,21 @@ #include "CollisionDetection.h" #include "ContactHandling.h" -struct smSimulationMainParam +struct SimulationMainParam { - std::vector<std::shared_ptr<smScene>> sceneList; + std::vector<std::shared_ptr<Scene>> sceneList; }; /// \brief call back for simulator module. simulateMain is called in every simulation module frame. -class smSimulationMain +class SimulationMain { public: - virtual void simulateMain(const smSimulationMainParam &) = 0; + virtual void simulateMain(const SimulationMainParam &) = 0; }; -class smSimulator: public smModule +class Simulator: public Module { - friend class smSDK; + friend class SDK; private: /// \brief Initializes up asynchronous threadpool @@ -62,20 +62,20 @@ public: void init(); /// \brief constructor gets error log - smSimulator(std::shared_ptr<smErrorLog> p_log); + Simulator(std::shared_ptr<ErrorLog> p_log); void setMaxThreadCount(int p_threadMaxCount); ///Simualtor registers the simulator and schedules it. ///the function is reentrant it is not thread safe. - void registerObjectSimulator(std::shared_ptr<smObjectSimulator> objectSimulator); + void registerObjectSimulator(std::shared_ptr<ObjectSimulator> objectSimulator); - void registerCollisionDetection(std::shared_ptr<smCollisionDetection> p_collisionDetection); + void registerCollisionDetection(std::shared_ptr<CollisionDetection> p_collisionDetection); - void registerContactHandling(std::shared_ptr<smContactHandling> p_contactHandling); + void registerContactHandling(std::shared_ptr<ContactHandling> p_contactHandling); ///Registration of the Simulation main. It is called in each and every frame - void registerSimulationMain(std::shared_ptr<smSimulationMain> p_main); + void registerSimulationMain(std::shared_ptr<SimulationMain> p_main); /// \brief the actual implementation of the simulator module resides in run function void run(); @@ -89,22 +89,22 @@ public: /// \brief this is called by SDK. it lanuches the simulator module virtual void exec(); - void addCollisionPair(std::shared_ptr<smCollisionPair> pair) + void addCollisionPair(std::shared_ptr<CollisionPair> pair) { collisionPairs.emplace_back(pair); } private: - std::vector<std::shared_ptr<smObjectSimulator>> simulators; - std::vector<std::shared_ptr<smCollisionDetection>> collisionDetectors; - std::vector<std::shared_ptr<smCollisionPair>> collisionPairs; - std::vector<std::shared_ptr<smContactHandling>> contactHandlers; + std::vector<std::shared_ptr<ObjectSimulator>> simulators; + std::vector<std::shared_ptr<CollisionDetection>> collisionDetectors; + std::vector<std::shared_ptr<CollisionPair>> collisionPairs; + std::vector<std::shared_ptr<ContactHandling>> contactHandlers; std::unique_ptr<ThreadPool> threadPool; // std::unique_ptr<ThreadPool> asyncPool; // asynchronous thread pool - std::shared_ptr<smErrorLog> log; // error log - std::shared_ptr<smSimulationMain> main; // Simulation main registration - std::shared_ptr<smSimulationMain> changedMain; // for updating the main in real-time. The change has effect after a frame is completed + std::shared_ptr<ErrorLog> log; // error log + std::shared_ptr<SimulationMain> main; // Simulation main registration + std::shared_ptr<SimulationMain> changedMain; // for updating the main in real-time. The change has effect after a frame is completed unsigned int frameCounter; // module keeps track of frame number int maxThreadCount; // maximum number of threads diff --git a/src/Core/StaticSceneObject.cpp b/src/Core/StaticSceneObject.cpp index 6345aa90cf4b2739edd5250f8082dba5e8fab51f..fc63f05ed8253809a36b1d0dee3a1ea8bc0da153 100644 --- a/src/Core/StaticSceneObject.cpp +++ b/src/Core/StaticSceneObject.cpp @@ -24,58 +24,58 @@ #include "StaticSceneObject.h" #include "Factory.h" -smStaticSceneObject::smStaticSceneObject(std::shared_ptr<smErrorLog> p_log) : smSceneObject() +StaticSceneObject::StaticSceneObject(std::shared_ptr<ErrorLog> p_log) : SceneObject() { type = core::ClassType::StaticSceneObject; name = "Static_SceneObject_" + std::to_string(this->getUniqueId()->getId()); this->setRenderDelegate( - smFactory<smRenderDelegate>::createSubclass( + Factory<RenderDelegate>::createSubclass( "RenderDelegate","StaticSceneObjectRenderDelegate")); } -smStaticSceneObject::~smStaticSceneObject() +StaticSceneObject::~StaticSceneObject() { } -void smStaticSceneObject::unSerialize ( void* /*p_memoryBlock*/ ) +void StaticSceneObject::unSerialize ( void* /*p_memoryBlock*/ ) { } -void smStaticSceneObject::serialize ( void* /*p_memoryBlock*/ ) +void StaticSceneObject::serialize ( void* /*p_memoryBlock*/ ) { } -void smStaticSceneObject::initialize() +void StaticSceneObject::initialize() { } -void smStaticSceneObject::loadInitialStates() +void StaticSceneObject::loadInitialStates() { } -bool smStaticSceneObject::configure(const std::string ConfigFile) +bool StaticSceneObject::configure(const std::string ConfigFile) { return false; } -std::shared_ptr<smSceneObject> smStaticSceneObject::clone() +std::shared_ptr<SceneObject> StaticSceneObject::clone() { - return safeDownCast<smSceneObject>(); + return safeDownCast<SceneObject>(); } -void smStaticSceneObject::setModel(std::shared_ptr<smModelRepresentation> model) +void StaticSceneObject::setModel(std::shared_ptr<ModelRepresentation> model) { this->staticModel = model; } -std::shared_ptr<smModelRepresentation> smStaticSceneObject::getModel() +std::shared_ptr<ModelRepresentation> StaticSceneObject::getModel() { return staticModel; } -void smStaticSceneObject::printInfo() const +void StaticSceneObject::printInfo() const { std::cout << "\t-------------------------------------\n"; std::cout << "\t Name : " << this->getName() << std::endl; diff --git a/src/Core/StaticSceneObject.h b/src/Core/StaticSceneObject.h index 183f21312fbe89f87b5619586e8777a679807cf2..e80d9fa0fc43e188e801eff8fba1cad38a394930 100644 --- a/src/Core/StaticSceneObject.h +++ b/src/Core/StaticSceneObject.h @@ -34,20 +34,20 @@ namespace mstk{ namespace Event{ - class smEvent; + class Event; } } /// \brief static scene object -class smStaticSceneObject: public smSceneObject +class StaticSceneObject: public SceneObject { public: /// \brief constructor - smStaticSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + StaticSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); /// \brief destructor - ~smStaticSceneObject(); + ~StaticSceneObject(); //not implemented yet..tansel virtual void serialize(void *p_memoryBlock) override; @@ -56,7 +56,7 @@ public: virtual void unSerialize(void *p_memoryBlock) override; ///not implemented yet. - virtual std::shared_ptr<smSceneObject> clone() override; + virtual std::shared_ptr<SceneObject> clone() override; /// \brief Initialize the parameters and properties of the simulation object void initialize() override; @@ -69,15 +69,15 @@ public: void printInfo() const override; - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent>) override {} + virtual void handleEvent(std::shared_ptr<mstk::Event::Event>) override {} - void setModel(std::shared_ptr<smModelRepresentation> model); + void setModel(std::shared_ptr<ModelRepresentation> model); - std::shared_ptr<smModelRepresentation> getModel(); + std::shared_ptr<ModelRepresentation> getModel(); public: /// \brief static scene object contains a mesh - std::shared_ptr<smModelRepresentation> staticModel; + std::shared_ptr<ModelRepresentation> staticModel; }; #endif diff --git a/src/Core/Synchronization.h b/src/Core/Synchronization.h index 467deb430348c3dd8622d467cb0b3e09e2573b7d..0f029c6e0fccbc476027dd1bc56432ca3914d6dd 100644 --- a/src/Core/Synchronization.h +++ b/src/Core/Synchronization.h @@ -38,7 +38,7 @@ ///simply set number of worker threads in the constructor ///then each worker threads should call waitTaskStart function when the taks ///is completed they should call signalTaskDone -class smSynchronization: public smCoreClass +class Synchronization: public CoreClass { std::condition_variable taskDone; @@ -53,7 +53,7 @@ class smSynchronization: public smCoreClass public: /// \param p_threadsForWorkers choose the number of worker threads - smSynchronization(int p_threadsForWorkers) + Synchronization(int p_threadsForWorkers) { type = core::ClassType::Synchronization; totalWorkers = p_threadsForWorkers; @@ -126,8 +126,8 @@ public: void startTasksandSignalEvent(int moduleId) { - smEvent *eventSynch; - eventSynch = new smEvent(); + Event *eventSynch; + eventSynch = new Event(); eventSynch->eventType = SIMMEDTK_EVENTTYPE_SYNCH; eventSynch->senderId = moduleId; eventSynch->senderType = SIMMEDTK_SENDERTYPE_EVENTSOURCE; diff --git a/src/Core/Texture.h b/src/Core/Texture.h index 8f302ec7c19bc1791a2d11e799b361fb6e28ce3e..c751a22483a6c5499b1c4b6410ecec14e2317761 100644 --- a/src/Core/Texture.h +++ b/src/Core/Texture.h @@ -41,7 +41,7 @@ enum ImageColorType SIMMEDTK_IMAGECOLOR_DEPTH }; /// \brief texture structure -struct smTexture +struct Texture { /// \brief texture file name std::string textureFileName; @@ -60,9 +60,9 @@ struct smTexture /// \brief true when initilized bool isInitialized; /// \brief to make a copy of the texture. - inline smTexture *copy() + inline Texture *copy() { - smTexture *myCopy = new smTexture(); + Texture *myCopy = new Texture(); myCopy->textureFileName = this->textureFileName; myCopy->textureGLId = this->textureGLId; myCopy->width = this->width; diff --git a/src/Core/Timer.cpp b/src/Core/Timer.cpp index b953c512283c862f6eb09c0e9932864d65678669..5322b7e0a71fafac9d8603724aad5270945cc2f4 100644 --- a/src/Core/Timer.cpp +++ b/src/Core/Timer.cpp @@ -24,15 +24,15 @@ // SimMedTK includes #include "Timer.h" -smTimer::smTimer() +Timer::Timer() { start(); } -void smTimer::start() +void Timer::start() { begin = ClockType::now(); } -long double smTimer::elapsed() +long double Timer::elapsed() { long double deltaSec; TimePointType now = ClockType::now(); diff --git a/src/Core/Timer.h b/src/Core/Timer.h index efa6263d25527644d850df5cf2feda2b5dca2d9d..f4bfd385e37ac8abb4ca15a64ab8d62406940635 100644 --- a/src/Core/Timer.h +++ b/src/Core/Timer.h @@ -32,7 +32,7 @@ #include "CoreClass.h" /// \brief timer class -class smTimer: public smCoreClass +class Timer: public CoreClass { public: using ClockType = std::chrono::high_resolution_clock; @@ -41,7 +41,7 @@ public: using PeriodType = ClockType::period; /// \brief constructor - smTimer(); + Timer(); /// \brief start the timer void start(); diff --git a/src/Core/UnifiedId.cpp b/src/Core/UnifiedId.cpp index 6456060fea173686e0a61f4f7e3340d1e9223336..6f4ef01a7a111e35b85fd63ba4fa54f3478e69b3 100644 --- a/src/Core/UnifiedId.cpp +++ b/src/Core/UnifiedId.cpp @@ -23,16 +23,16 @@ #include "UnifiedId.h" -std::atomic_int smUnifiedId::IDcounter; -smUnifiedId::smUnifiedId() +std::atomic_int UnifiedId::IDcounter; +UnifiedId::UnifiedId() { ID = IDcounter.fetch_add(1); } -bool smUnifiedId::operator==(const smUnifiedId* id) +bool UnifiedId::operator==(const UnifiedId* id) { return (ID == id->getId()); } -bool smUnifiedId::operator!=(const short int& id) +bool UnifiedId::operator!=(const short int& id) { return (ID != id); } diff --git a/src/Core/UnifiedId.h b/src/Core/UnifiedId.h index 398d082dd709c1e892483f5b6d4124b1e1cd0a82..18bc2d86e18b31b6c2d2fdab79016c6d747012d7 100644 --- a/src/Core/UnifiedId.h +++ b/src/Core/UnifiedId.h @@ -30,17 +30,17 @@ /// \brief This class creates a unique unified id of each object in the framework -struct smUnifiedId +struct UnifiedId { public: - typedef std::shared_ptr<smUnifiedId> Pointer; + typedef std::shared_ptr<UnifiedId> Pointer; public: /// \brief constructor - smUnifiedId(); + UnifiedId(); - /// \brief comparison with another std::shared_ptr<smUnifiedId> - bool operator==(const smUnifiedId *id); + /// \brief comparison with another std::shared_ptr<UnifiedId> + bool operator==(const UnifiedId *id); /// \brief comparison with id bool operator!=(const short &id); @@ -56,8 +56,8 @@ private: static std::atomic_int IDcounter; // atomic integer counter that is used to assign a unique number for each object short ID; // unique ID - smUnifiedId(const smUnifiedId&) = delete; - smUnifiedId &operator=(const smUnifiedId&) = delete; + UnifiedId(const UnifiedId&) = delete; + UnifiedId &operator=(const UnifiedId&) = delete; }; #endif // SMUNIFIEDID_H diff --git a/src/Core/UnitTests/Factory.cpp b/src/Core/UnitTests/Factory.cpp index c8aa4bde466c29c29b3eccd2d178e5d378d302d1..c6b221c9a1df4a08587bd781a6c72ca27f314064 100644 --- a/src/Core/UnitTests/Factory.cpp +++ b/src/Core/UnitTests/Factory.cpp @@ -4,7 +4,7 @@ #include <iostream> -class abstract : public smCoreClass +class abstract : public CoreClass { public: virtual std::string stupid() const = 0; @@ -24,8 +24,8 @@ public: SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_abstract_children) - SIMMEDTK_REGISTER_CLASS(smCoreClass, abstract, A, 65); - SIMMEDTK_REGISTER_CLASS(smCoreClass, abstract, B, 66); + SIMMEDTK_REGISTER_CLASS(CoreClass, abstract, A, 65); + SIMMEDTK_REGISTER_CLASS(CoreClass, abstract, B, 66); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() @@ -36,23 +36,23 @@ go_bandit([](){ SIMMEDTK_RUN_LOADER(register_abstract_children); it("shows 2 subclasses of \"abstract\"", [&]() { - AssertThat(smFactory<smCoreClass>::optionsForClass("abstract").size(), Equals(2)); + AssertThat(Factory<CoreClass>::optionsForClass("abstract").size(), Equals(2)); }); it("creates a non-NULL default class instance", [&]() { - AssertThat(!!smFactory<smCoreClass>::createDefault("abstract").get(), IsTrue()); + AssertThat(!!Factory<CoreClass>::createDefault("abstract").get(), IsTrue()); }); it("creates the *proper* non-NULL default class instance", [&]() { - AssertThat(smFactory<smCoreClass>::createDefaultAs<abstract>("abstract")->stupid()[0], Equals('A')); + AssertThat(Factory<CoreClass>::createDefaultAs<abstract>("abstract")->stupid()[0], Equals('A')); }); it("creates the proper non-NULL *specified group* class instance", [&]() { - AssertThat(smFactory<smCoreClass>::createSubclassForGroupAs<abstract>("abstract", 66)->stupid()[0], Equals('B')); + AssertThat(Factory<CoreClass>::createSubclassForGroupAs<abstract>("abstract", 66)->stupid()[0], Equals('B')); }); it("creates a non-NULL instance given only a concrete class name", [&]() { - AssertThat(smFactory<smCoreClass>::createConcreteClassAs<A>("A")->stupid()[0], Equals('A')); + AssertThat(Factory<CoreClass>::createConcreteClassAs<A>("A")->stupid()[0], Equals('A')); }); }); diff --git a/src/Core/Vector.h b/src/Core/Vector.h index c1a61981cdcdbd9d39c3d6d52cdd5a6e3ef1039d..b7219796841ce51dcbfc2300e6fd2b6532cef401 100644 --- a/src/Core/Vector.h +++ b/src/Core/Vector.h @@ -33,75 +33,75 @@ // namespace SimMedTK // { -// namespace Math -// { /// Aliases for vectors /// A 2D vector template<typename T> -using smVector2 = Eigen::Matrix<T,2,1>; +using Vector2 = Eigen::Matrix<T,2,1>; /// A 3D vector template<typename T> -using smVector3 = Eigen::Matrix<T,3,1>; +using Vector3 = Eigen::Matrix<T,3,1>; /// A 4D vector template<typename T> -using smVector4 = Eigen::Matrix<T,4,1>; +using Vector4 = Eigen::Matrix<T,4,1>; /// A 6D vector template<typename T> -using smVector6 = Eigen::Matrix<T,6,1>; +using Vector6 = Eigen::Matrix<T,6,1>; /// A dynamic size column vector template<typename T> -using smVector = Eigen::Matrix<T, Eigen::Dynamic, 1>; +using Vector = Eigen::Matrix<T, Eigen::Dynamic, 1>; // STD vectors of vectors template<typename T> -using smStdVector3 = std::vector<smVector3<T>, - Eigen::aligned_allocator<smVector3<T>>>; +using StdVector3 = std::vector<Vector3<T>, + Eigen::aligned_allocator<Vector3<T>>>; +namespace core +{ /// A 2D vector of floats. -using smVec2f = smVector2<float>; +using Vec2f = Vector2<float>; /// A 3D vector of floats. -using smVec3f = smVector3<float>; +using Vec3f = Vector3<float>; /// A 4D vector of floats. -using smVec4f = smVector4<float>; +using Vec4f = Vector4<float>; /// A 6D vector of floats. -using smVec6f = smVector6<float>; +using Vec6f = Vector6<float>; /// A 2D vector of doubles. -using smVec2d = smVector2<double>; +using Vec2d = Vector2<double>; /// A 3D vector of doubles. -using smVec3d = smVector3<double>; +using Vec3d = Vector3<double>; /// A 4D vector of doubles. -using smVec4d = smVector4<double>; +using Vec4d = Vector4<double>; /// A 6D matrix of doubles. -using smVec6d = smVector6<double>; +using Vec6d = Vector6<double>; /// A dynamic size column vector -using smVectorf = smVector<float>; +using Vectorf = Vector<float>; /// A dynamic size column vector -using smVectord = smVector<double>; +using Vectord = Vector<double>; // STL vectors of float vectors -using smStdVector3f = smStdVector3<float>; +using StdVector3f = StdVector3<float>; // STL vectors of double vectors -using smStdVector3d = smStdVector3<double>; +using StdVector3d = StdVector3<double>; template<typename T> -void flattenVectorArray(const smStdVector3<T> &v, Eigen::Matrix<T, 3, Eigen::Dynamic> &out) +void flattenVectorArray(const StdVector3<T> &v, Eigen::Matrix<T, 3, Eigen::Dynamic> &out) { out.resize(v.size()); for(size_t i = 0, end = v.size(); i < end; ++i) @@ -110,7 +110,7 @@ void flattenVectorArray(const smStdVector3<T> &v, Eigen::Matrix<T, 3, Eigen::Dyn } } -// } // Math +} // core // } // SimMedTK #endif // SMVECTOR_H diff --git a/src/Core/ViewerBase.cpp b/src/Core/ViewerBase.cpp index 4d5d7ef174f9c9a1f7900274b965a8d22ec1ef67..9b8b0c5d596909d00881a8a335e9187a30534ab5 100644 --- a/src/Core/ViewerBase.cpp +++ b/src/Core/ViewerBase.cpp @@ -28,14 +28,14 @@ #include "DataStructures.h" #include "External/tree.hh" -smRenderOperation::smRenderOperation() +RenderOperation::RenderOperation() { fbo = nullptr; scene = nullptr; fboName = ""; } -smViewerBase::smViewerBase() +ViewerBase::ViewerBase() { type = core::ClassType::Viewer; viewerRenderDetail = SIMMEDTK_VIEWERRENDER_FADEBACKGROUND; @@ -55,19 +55,19 @@ smViewerBase::smViewerBase() } ///affects the framebuffer size and depth buffer size -void smViewerBase::setScreenResolution(int p_width, int p_height) +void ViewerBase::setScreenResolution(int p_width, int p_height) { this->screenResolutionHeight = p_height; this->screenResolutionWidth = p_width; } -void smViewerBase::setUnlimitedFPS(bool p_enableFPS) +void ViewerBase::setUnlimitedFPS(bool p_enableFPS) { unlimitedFPSEnabled = p_enableFPS; unlimitedFPSVariableChanged++; } -void smViewerBase::initObjects() +void ViewerBase::initObjects() { for (size_t i = 0; i < objectList.size(); i++) { @@ -82,12 +82,12 @@ void smViewerBase::initObjects() } } -void smViewerBase::initScenes() +void ViewerBase::initScenes() { //traverse all the scene and the objects in the scene for(auto&& scene : sceneList) { - smSceneLocal sceneLocal; + SceneLocal sceneLocal; scene->initLights(); scene->copySceneToLocal(sceneLocal); @@ -105,7 +105,7 @@ void smViewerBase::initScenes() } ///initialization of the viewer module -void smViewerBase::init() +void ViewerBase::init() { if (isInitialized) { @@ -121,12 +121,12 @@ void smViewerBase::init() isInitialized = true; } -void smViewerBase::addFBO(const std::string &p_fboName, - smTexture *p_colorTex, - smTexture *p_depthTex, +void ViewerBase::addFBO(const std::string &p_fboName, + Texture *p_colorTex, + Texture *p_depthTex, unsigned int p_width, unsigned int p_height) { - smFboListItem item; + FboListItem item; item.fboName = p_fboName; item.width = p_width; @@ -143,7 +143,7 @@ void smViewerBase::addFBO(const std::string &p_fboName, this->fboListItems.push_back(item); } -void smViewerBase::processRenderOperation(const smRenderOperation &p_rop) +void ViewerBase::processRenderOperation(const RenderOperation &p_rop) { switch (p_rop.target) { @@ -158,11 +158,11 @@ void smViewerBase::processRenderOperation(const smRenderOperation &p_rop) } } -void smViewerBase::registerScene(std::shared_ptr<smScene> p_scene, +void ViewerBase::registerScene(std::shared_ptr<Scene> p_scene, smRenderTargetType p_target, const std::string &p_fboName) { - smRenderOperation rop; + RenderOperation rop; //sanity checks assert(p_scene); @@ -179,7 +179,7 @@ void smViewerBase::registerScene(std::shared_ptr<smScene> p_scene, renderOperations.push_back(rop); } -inline void smViewerBase::adjustFPS() +inline void ViewerBase::adjustFPS() { static int _unlimitedFPSVariableChanged = 0; @@ -202,7 +202,7 @@ inline void smViewerBase::adjustFPS() } ///main drawing routine for Rendering of all objects in the scene -void smViewerBase::render() +void ViewerBase::render() { if (viewerRenderDetail & SIMMEDTK_VIEWERRENDER_DISABLE) { @@ -213,7 +213,7 @@ void smViewerBase::render() adjustFPS(); - smRenderDelegate::Ptr delegate; + RenderDelegate::Ptr delegate; for (size_t i = 0; i < objectList.size(); i++) { delegate = objectList[i]->getRenderDelegate(); @@ -236,19 +236,19 @@ void smViewerBase::render() endModule(); } -void smViewerBase::addObject(std::shared_ptr<smCoreClass> object) +void ViewerBase::addObject(std::shared_ptr<CoreClass> object) { - smSDK::getInstance()->addRef(object); + SDK::getInstance()->addRef(object); objectList.push_back(object); } -void smViewerBase::setWindowTitle(const std::string &str) +void ViewerBase::setWindowTitle(const std::string &str) { windowTitle = str; } -void smViewerBase::exec() +void ViewerBase::exec() { // Init the viewer this->init(); @@ -259,28 +259,28 @@ void smViewerBase::exec() cleanUp(); } -void smViewerBase::cleanUp() +void ViewerBase::cleanUp() { //Must be set when all cleanup is done terminationCompleted = true; } -int smViewerBase::height(void) +int ViewerBase::height(void) { return screenResolutionHeight; } -int smViewerBase::width(void) +int ViewerBase::width(void) { return screenResolutionWidth; } -float smViewerBase::aspectRatio(void) +float ViewerBase::aspectRatio(void) { return screenResolutionHeight / screenResolutionWidth; } -void smViewerBase::setGlobalAxisLength(const float len) +void ViewerBase::setGlobalAxisLength(const float len) { this->globalAxisLength = len; } diff --git a/src/Core/ViewerBase.h b/src/Core/ViewerBase.h index a292ce5ab6079c562f7ac9bc16461b1c05e0b7f4..d7a465ced9125478b5f13130b0a7aba64e108d76 100644 --- a/src/Core/ViewerBase.h +++ b/src/Core/ViewerBase.h @@ -31,21 +31,14 @@ #include "Module.h" #include "StaticSceneObject.h" #include "DataStructures.h" -#include "Pipe.h" // Forward declaration -class smSDK; +class SDK; class smOpenGLWindowStream; class smMetalShader; class smSceneTextureShader; class smFrameBuffer; -class smTexture; - -class smCameraCollisionInterface -{ -public: - virtual bool checkCameraCollision() = 0; -}; +class Texture; enum smRenderingStageType { @@ -62,38 +55,38 @@ enum smRenderTargetType }; /// \brief Describes what to render and where the rendering should take place -struct smRenderOperation +struct RenderOperation { - smRenderOperation(); - std::shared_ptr<smScene> scene; ///< The scene full of objects to render + RenderOperation(); + std::shared_ptr<Scene> scene; ///< The scene full of objects to render smFrameBuffer *fbo; ///< Only required if rendering to FBO, specifies the FBO to render to std::string fboName; ///< Only required if rendering to FBO, named reference to look up the FBO pointer smRenderTargetType target; ///< Specifies where the rendered result should be placed see smRenderTargetType }; -struct smFboListItem +struct FboListItem { std::string fboName; ///< String identification smFrameBuffer* fbo; ///< The FBO pointer - smTexture *depthTex; ///< The FBO depth texture pointer - smTexture *colorTex; ///< The FBO color texture pointer + Texture *depthTex; ///< The FBO depth texture pointer + Texture *colorTex; ///< The FBO color texture pointer unsigned int width; ///< The width of the FBO unsigned int height; ///< The height of the FBO }; /// \brief Handles all rendering routines. -class smViewerBase : public smModule +class ViewerBase : public Module { protected: - std::vector<std::shared_ptr<smCoreClass>> objectList; - std::vector<smRenderOperation> renderOperations; - std::vector<smFboListItem> fboListItems; - std::shared_ptr<smErrorLog> log; + std::vector<std::shared_ptr<CoreClass>> objectList; + std::vector<RenderOperation> renderOperations; + std::vector<FboListItem> fboListItems; + std::shared_ptr<ErrorLog> log; int unlimitedFPSVariableChanged; bool unlimitedFPSEnabled; int screenResolutionWidth; int screenResolutionHeight; - friend class smSDK; + friend class SDK; public: @@ -113,13 +106,13 @@ public: /// \brief disable vSync virtual void setUnlimitedFPS(bool p_enableFPS); /// \brief default constructor - smViewerBase(); + ViewerBase(); /// \brief initialization for viewer virtual void init() override; /// \brief for exit viewer virtual void exitViewer() = 0; /// \brief add object for rendering - virtual void addObject(std::shared_ptr<smCoreClass> object); + virtual void addObject(std::shared_ptr<CoreClass> object); /// \brief add text for display virtual void addText(std::string p_tag) = 0; /// \brief update text @@ -132,7 +125,7 @@ public: /// \brief enable/disable VSync virtual void setVSync(bool sync) = 0; /// \brief Registers a scene for rendering with the viewer - virtual void registerScene(std::shared_ptr<smScene> p_scene, smRenderTargetType p_target, const std::string &p_fboName); + virtual void registerScene(std::shared_ptr<Scene> p_scene, smRenderTargetType p_target, const std::string &p_fboName); /// \brief Adds an FBO to the viewer to allow rendering to it. /// /// \detail The FBO will be created an initialized in the viewer. @@ -144,14 +137,14 @@ public: /// \param p_height The height of the fbo virtual void addFBO( const std::string &p_fboName, - smTexture *p_colorTex, smTexture *p_depthTex, + Texture *p_colorTex, Texture *p_depthTex, unsigned int p_width, unsigned int p_height); virtual void setGlobalAxisLength(const float len); std::string windowTitle; - smColor defaultDiffuseColor; - smColor defaultAmbientColor; - smColor defaultSpecularColor; + Color defaultDiffuseColor; + Color defaultAmbientColor; + Color defaultSpecularColor; protected: /// \brief Initializes rendering system (e.g., OpenGL) capabilities and flags @@ -171,15 +164,15 @@ protected: /// \brief Renders the internal sceneList void renderSceneList(); /// \brief Processes a render operation - virtual void processRenderOperation(const smRenderOperation &p_rop); + virtual void processRenderOperation(const RenderOperation &p_rop); /// \brief Processes viewerRenderDetail options virtual void processViewerOptions() = 0; /// \brief Process window events and render as the major part of an event loop virtual void processWindowEvents() = 0; /// \brief Renders the render operation to screen - virtual void renderToScreen(const smRenderOperation &p_rop) = 0; + virtual void renderToScreen(const RenderOperation &p_rop) = 0; /// \brief Renders the render operation to an FBO - virtual void renderToFBO(const smRenderOperation &p_rop) = 0; + virtual void renderToFBO(const RenderOperation &p_rop) = 0; /// \brief Set the color and other viewer defaults virtual void setToDefaults() = 0; /// \brief draw routines diff --git a/src/Core/WorkerThread.h b/src/Core/WorkerThread.h index 5ea91eaf9715736a01c70ab6d6abfe9212dcd39a..63b2b7cac89bf161606e934cb24959702180392c 100644 --- a/src/Core/WorkerThread.h +++ b/src/Core/WorkerThread.h @@ -28,17 +28,19 @@ #include "CoreClass.h" #include "Synchronization.h" -/// \brief process(used as conceptual meaning) numbering scheme -enum smProcessNumbering -{ - SIMMEDTK_PROCNUMSCHEME_X__, - SIMMEDTK_PROCNUMSCHEME_XY_, - SIMMEDTK_PROCNUMSCHEME_XYZ, -}; /// \brief process id -struct smProcessID +struct ProcessID { public: + + /// \brief process(used as conceptual meaning) numbering scheme + enum class ProcessNumbering + { + X, + XY, + XYZ, + }; + /// \brief numbering scheme in x,y,z unsigned short x; unsigned short y; @@ -52,16 +54,16 @@ public: /// \brief data size int sizeOfData; /// \brief numbering sceheme - smProcessNumbering numbScheme; + ProcessNumbering numbScheme; - smProcessID() + ProcessID() { x = y = z = totalProcX = totalProcY = totalProcZ = sizeOfData = 0; data = NULL; - numbScheme = SIMMEDTK_PROCNUMSCHEME_X__; + numbScheme = ProcessNumbering::X; } - inline void operator=(smProcessID p_ID) + inline void operator=(ProcessID p_ID) { x = p_ID.x; y = p_ID.y; @@ -79,15 +81,15 @@ public: /// \brief process. Process is a atomic execution unit(thread). -class smProcess: public smCoreClass +class Process: public CoreClass { protected: - smProcessID id; + ProcessID id; bool termination; public: - smProcess() + Process() { id.x = 0; id.y = 0; @@ -97,17 +99,17 @@ public: id.totalProcZ = 0; id.data = NULL; id.sizeOfData = 0; - id.numbScheme = SIMMEDTK_PROCNUMSCHEME_X__; + id.numbScheme = ProcessID::ProcessNumbering::X; termination = false; } - smProcess(smProcessID p_id) + Process(ProcessID p_id) { id = p_id; termination = false; } - void setId(smProcessID p_id) + void setId(ProcessID p_id) { id = p_id; } @@ -120,30 +122,30 @@ public: } }; /// \brief worker thread extends process -class smWorkerThread: public smProcess +class WorkerThread: public Process { protected: /// \brief for synchronization - smSynchronization *synch; + Synchronization *synch; public: - smWorkerThread() + WorkerThread() { } - smWorkerThread(smProcessID p_ID): smProcess(p_ID) + WorkerThread(ProcessID p_ID): Process(p_ID) { termination = false; } - smWorkerThread(smSynchronization &p_synch, smProcessID p_ID): smProcess(p_ID) + WorkerThread(Synchronization &p_synch, ProcessID p_ID): Process(p_ID) { synch = &p_synch; termination = false; } - void setSynchObject(smSynchronization &p_synch) + void setSynchObject(Synchronization &p_synch) { synch = &p_synch; } diff --git a/src/Devices/ADUInterface.cpp b/src/Devices/ADUInterface.cpp index 8e4b8c36b633b3c3c15bc3739167e75a3b382372..037351ad81b62e53320e938847ac31f5b1575703 100644 --- a/src/Devices/ADUInterface.cpp +++ b/src/Devices/ADUInterface.cpp @@ -66,7 +66,7 @@ smADUInterface::smADUInterface() std::cout << "Check the USB connection of the ADU device or the serial number: Couldn't initialize the device" << "\n"; } - ADUpipe = new smPipe("ADU_Data", sizeof(ADUDeviceData), 10); +// ADUpipe = new smPipe("ADU_Data", sizeof(ADUDeviceData), 10); } /// \brief @@ -168,7 +168,7 @@ smADUInterface::smADUInterface(const std::string& calibrationFile) std::cout << "Check the USB connection of the ADU device or the serial number: Couldn't initialize the device" << "\n"; } - ADUpipe = new smPipe("ADU_Data", sizeof(ADUDeviceData), 10); +// ADUpipe = new smPipe("ADU_Data", sizeof(ADUDeviceData), 10); sw = 0; updateFlag = 0; } @@ -255,17 +255,17 @@ void smADUInterface::runDevice() void smADUInterface::sendDataToPipe() { - ADUDeviceData *pipeData; - pipeData = (ADUDeviceData*)ADUpipe->beginWrite(); - pipeData->calibration[0] = calibrationData->minValue1; - pipeData->calibration[1] = calibrationData->maxValue1; - pipeData->calibration[2] = calibrationData->minValue2; - pipeData->calibration[3] = calibrationData->maxValue2; - pipeData->anValue[0] = deviceData->anValue[0]; - pipeData->anValue[1] = deviceData->anValue[1]; - pipeData->deviceOpen = isOpened; - ADUpipe->endWrite(1); - ADUpipe->acknowledgeValueListeners(); +// ADUDeviceData *pipeData; +// pipeData = (ADUDeviceData*)ADUpipe->beginWrite(); +// pipeData->calibration[0] = calibrationData->minValue1; +// pipeData->calibration[1] = calibrationData->maxValue1; +// pipeData->calibration[2] = calibrationData->minValue2; +// pipeData->calibration[3] = calibrationData->maxValue2; +// pipeData->anValue[0] = deviceData->anValue[0]; +// pipeData->anValue[1] = deviceData->anValue[1]; +// pipeData->deviceOpen = isOpened; +// ADUpipe->endWrite(1); +// ADUpipe->acknowledgeValueListeners(); } /// \brief diff --git a/src/Devices/ADUInterface.h b/src/Devices/ADUInterface.h index 186b365368806286529c829fffaac93195f62fd2..12bdb97ac49aec66cd749021770a30f4685a08eb 100644 --- a/src/Devices/ADUInterface.h +++ b/src/Devices/ADUInterface.h @@ -28,9 +28,8 @@ #define SM_ADU_INTERFACE_H #include "smExternalDevices/smDeviceInterface.h" -#include "smCore/smEvent.h" +#include "smCore/Event.h" #include "smCore/smEventData.h" -#include "smCore/smPipe.h" /// \brief holds data for calibration of ADU device struct ADUDeviceCalibrationData @@ -105,10 +104,10 @@ public: void run() override; /// \brief - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override{}; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override{}; public: - smPipe *ADUpipe; ///< !! +// smPipe *ADUpipe; ///< !! /// \brief !! void sendDataToPipe(); diff --git a/src/Devices/Audio.h b/src/Devices/Audio.h index 3508a86ac2ca660e532b712f23b0cc5458140839..617912ec6e5d5565557277d1701a3772334b7563 100644 --- a/src/Devices/Audio.h +++ b/src/Devices/Audio.h @@ -33,13 +33,13 @@ #include "Event/AudioEvent.h" /// \brief class to enable audio rendering -class smAudio: public smCoreClass +class smAudio: public CoreClass { private: sf::Sound sound; ///< SFML Sound object, controls the sound data sf::SoundBuffer soundBuffer; ///< SFML Sound buffer, contains the sound data - std::shared_ptr<smErrorLog> log; ///< log for errors + std::shared_ptr<ErrorLog> log; ///< log for errors std::string referenceName; ///< A human readable string to refer to the object mstk::Event::AudioState state; ///< state of audio mstk::Event::AudioState prevState; ///< state of audio in previous cycle @@ -61,7 +61,7 @@ public: /// \brief constructor initialize various states smAudio(const std::string& fileName, const std::string& p_referenceName, - smErrorLog *p_log = nullptr, + ErrorLog *p_log = nullptr, bool p_loop = false) : referenceName(p_referenceName), loop(p_loop) diff --git a/src/Devices/DeviceInterface.h b/src/Devices/DeviceInterface.h index d1939d64b742d9408e9e0ef3ffda6b7853caa2e9..d80268a71b76c1c6b8ac07472acb224315a21752 100644 --- a/src/Devices/DeviceInterface.h +++ b/src/Devices/DeviceInterface.h @@ -35,7 +35,7 @@ const int SIMMEDTK_MSG_SUCCESS = 0; /// \brief Abstract base interface class with virtual functions. /// Device specific implementation should be done by instantiating this class -class smDeviceInterface: public smModule +class smDeviceInterface: public Module { public: diff --git a/src/Devices/HapticInterface.h b/src/Devices/HapticInterface.h index c13ec11dfd1405252cfe374a4ed35829314863f2..6328b6da7fd4b524317cc75a9d685737d449cefc 100644 --- a/src/Devices/HapticInterface.h +++ b/src/Devices/HapticInterface.h @@ -33,10 +33,10 @@ struct hapticDeviceData_t { int deviceID; std::string deviceName; - smVec3 <smDouble> position; - smVec3 <smDouble> velocity; - smVec3 <smDouble> angles; - smMatrix44 <smDouble> transform; + core::Vec3 <smDouble> position; + core::Vec3 <smDouble> velocity; + core::Vec3 <smDouble> angles; + Matrix44 <smDouble> transform; bool buttonState[SM_MAX_BUTTONS]; }; @@ -71,31 +71,31 @@ public: } /// \brief get the position of the end effector the haptic device - virtual int getPosition(smVec3d & d_pos) + virtual int getPosition(core::Vec3d & d_pos) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief get the orientation of the end effector the haptic device - virtual int getOreintation(smMatrix33 <smDouble> *d_rot) + virtual int getOreintation(Matrix33 <smDouble> *d_rot) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief get the transform (position + orientation) of the end effector the haptic device - virtual int getDeviceTransform(smMatrix44 <smDouble> *d_transform) + virtual int getDeviceTransform(Matrix44 <smDouble> *d_transform) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief set force to the haptic device - virtual int setForce(smVec3d & force) + virtual int setForce(core::Vec3d & force) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief set torque to the haptic device - virtual int setForceandTorque(smVec3 <smDouble>& force, smVec3 <smDouble> & torque) + virtual int setForceandTorque(core::Vec3 <smDouble>& force, core::Vec3 <smDouble> & torque) { return SIMMEDTK_MSG_UNKNOWN; } diff --git a/src/Devices/NIUSB6008Interface.cpp b/src/Devices/NIUSB6008Interface.cpp index d1b2f9c1d76ab5c0d406b21efc1c2063a6ee007f..023b56e70165a101dc736693b80d6a8e8e5ba5f5 100644 --- a/src/Devices/NIUSB6008Interface.cpp +++ b/src/Devices/NIUSB6008Interface.cpp @@ -137,7 +137,7 @@ smNIUSB6008Interface::smNIUSB6008Interface(int VBLaST_Task_ID) NI_on = false; } - NIUSB6008pipe = new smPipe("NIUSB6008_Data", sizeof(NIUSB6008Data), 10); +// NIUSB6008pipe = new smPipe("NIUSB6008_Data", sizeof(NIUSB6008Data), 10); aveData[0] = aveData[1] = 0.0; } @@ -327,7 +327,7 @@ smNIUSB6008Interface::~smNIUSB6008Interface() DAQmxStopTask(taskHandle); DAQmxClearTask(taskHandle); - delete NIUSB6008pipe; +// delete NIUSB6008pipe; delete [] regTool; } @@ -336,7 +336,7 @@ void smNIUSB6008Interface::sendDataToPipe() { NIUSB6008Data *pipeData; - pipeData = (NIUSB6008Data*)NIUSB6008pipe->beginWrite(); +// pipeData = (NIUSB6008Data*)NIUSB6008pipe->beginWrite(); float tF; int cid; pipeData->on = NI_on; @@ -359,8 +359,8 @@ void smNIUSB6008Interface::sendDataToPipe() pipeData->value[i] = tF; } - NIUSB6008pipe->endWrite(1); - NIUSB6008pipe->acknowledgeValueListeners(); +// NIUSB6008pipe->endWrite(1); +// NIUSB6008pipe->acknowledgeValueListeners(); } /// \brief diff --git a/src/Devices/NIUSB6008Interface.h b/src/Devices/NIUSB6008Interface.h index c75da5c0cb0cb4e065c7b74092695793b426ae26..2ec9e2fcce75bf0fba5b78583f242f61257fdeb5 100644 --- a/src/Devices/NIUSB6008Interface.h +++ b/src/Devices/NIUSB6008Interface.h @@ -30,7 +30,7 @@ #define SM_NIUSB6008_INTERFACE_H #include "smExternalDevices/smDeviceInterface.h" -#include "smCore/smEvent.h" +#include "smCore/Event.h" #include "smCore/smEventData.h" #include "smCore/smPipe.h" @@ -60,7 +60,7 @@ public: smNIUSB6008Interface(int VBLaST_Task_ID); ~smNIUSB6008Interface(); - smPipe *NIUSB6008pipe; ///< +// smPipe *NIUSB6008pipe; ///< int32 NI_error; ///< char NI_errBuff[2048]; ///< int initCount; ///< @@ -97,7 +97,7 @@ public: void run(); /// \brief handle event related to NIUSB6008 device - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override { }; diff --git a/src/Devices/PhantomInterface.cpp b/src/Devices/PhantomInterface.cpp index 6fb258078cad8cf1333003a7976ea645fcf73d8d..59d17419b5e7e65a481eef38d9053c9aed17992e 100644 --- a/src/Devices/PhantomInterface.cpp +++ b/src/Devices/PhantomInterface.cpp @@ -23,11 +23,11 @@ #include "smExternalDevices/smPhantomInterface.h" #include "smRendering/smGLRenderer.h" -#include "smCore/smTimer.h" +#include "smCore/Timer.h" #include <iostream> HDCallbackCode HDCALLBACK hapticCallback(void *pData); -smTimer hapticTimer; +Timer hapticTimer; /// \brief additions to provide compabilibity with all the modules structures void smPhantomInterface::init() @@ -77,7 +77,7 @@ smPhantomInterface::smPhantomInterface() hdEnable(HD_FORCE_RAMPING); //Stream Event Creation - hapticEvent[incr] = new smEvent(); + hapticEvent[incr] = new Event(); hapticEventData[incr] = new smHapticOutEventData(); hapticEvent[incr]->data = hapticEventData[incr]; incr++; @@ -134,21 +134,21 @@ int smPhantomInterface::openDevice(int phantomNumber) } /// \brief -int smPhantomInterface::getPosition(smVec3 <smDouble> &d_pos) +int smPhantomInterface::getPosition(core::Vec3 <smDouble> &d_pos) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief -int smPhantomInterface::getOreintation(smMatrix33 <smDouble> *d_rot) +int smPhantomInterface::getOreintation(Matrix33 <smDouble> *d_rot) { return SIMMEDTK_MSG_UNKNOWN; } /// \brief -int smPhantomInterface::getDeviceTransform(smMatrix44 <smDouble> *d_transform) +int smPhantomInterface::getDeviceTransform(Matrix44 <smDouble> *d_transform) { return SIMMEDTK_MSG_UNKNOWN; @@ -240,7 +240,7 @@ HDCallbackCode HDCALLBACK hapticCallback(void *pData) while (count < phantomInterface->numPhantomDevices) { - //phantomInterface->hapticEvent[count]=new smEvent(); + //phantomInterface->hapticEvent[count]=new Event(); //hapticEventData[count]=new smHapticOutEventData(); memcpy(phantomInterface->hapticEventData[count], (const void*)&phantomInterface->hapticDeviceData[count], sizeof(phantomInterface->hapticDeviceData[count])); phantomInterface->hapticEvent[count]->eventType = SIMMEDTK_EVENTTYPE_HAPTICOUT; @@ -282,7 +282,7 @@ HDCallbackCode HDCALLBACK hapticCallback(void *pData) } /// \brief -void smPhantomInterface::handleEvent(std::shared_ptr<mstk::Event::smEvent> event) +void smPhantomInterface::handleEvent(std::shared_ptr<mstk::Event::Event> event) { smHapticInEventData *hapticEventData; diff --git a/src/Devices/PhantomInterface.h b/src/Devices/PhantomInterface.h index f4e0150e39631f8ede47af602cc2121662b78e03..9e4d7eae06984e71bfba9900b18b1a4419a1d686 100644 --- a/src/Devices/PhantomInterface.h +++ b/src/Devices/PhantomInterface.h @@ -37,7 +37,7 @@ class smPhantomInterface: public smHapticInterface { protected: - smEvent *hapticEvent[SM_MAX_PHANTOM_DEVICES]; ///< + Event *hapticEvent[SM_MAX_PHANTOM_DEVICES]; ///< smHapticOutEventData *hapticEventData[SM_MAX_PHANTOM_DEVICES]; ///< public: @@ -65,13 +65,13 @@ public: int startDevice(); /// \brief get phantom position - int getPosition(smVec3 <smDouble>& d_pos); + int getPosition(core::Vec3 <smDouble>& d_pos); /// \brief get phantom orientation - int getOreintation(smMatrix33 <smDouble> *d_rot); + int getOreintation(Matrix33 <smDouble> *d_rot); /// \brief get phantom transformation - int getDeviceTransform(smMatrix44 <smDouble> *d_transform); + int getDeviceTransform(Matrix44 <smDouble> *d_transform); HHD dHandle[SM_MAX_PHANTOM_DEVICES]; ///< handles for devices available int numPhantomDevices; ///< number of phantom devices @@ -99,7 +99,7 @@ public: friend HDCallbackCode HDCALLBACK hapticCallback(void *pData); ///< !! /// \brief handle events related to phantom omni - void handleEvent(std::shared_ptr<mstk::Event::smEvent> event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; /// \brief initialize (nothing happens) void init() override; diff --git a/src/Event/AudioEvent.h b/src/Event/AudioEvent.h index 9e997e02d4b7c46ebc1601b7257b9f25d787d353..3fef6f40fe37545e64ac73d4ff9b6106ef197ec5 100644 --- a/src/Event/AudioEvent.h +++ b/src/Event/AudioEvent.h @@ -41,7 +41,7 @@ enum class AudioState Stop, }; -class smAudioEvent: public smEvent +class smAudioEvent: public Event { public: static EventType EventName; diff --git a/src/Event/CameraEvent.cpp b/src/Event/CameraEvent.cpp index 8fa94e96e87afba8ce215a146eeb7ab23663d47e..ed42edebe1875e54cb21a4d1f4f69f8dacf2008f 100644 --- a/src/Event/CameraEvent.cpp +++ b/src/Event/CameraEvent.cpp @@ -30,31 +30,31 @@ EventType smCameraEvent::EventName = EventType::CameraUpdate; smCameraEvent::smCameraEvent() { - position = smVec3d::Zero(); - direction = smVec3d::Zero(); - upDirection = smVec3d::Zero(); + position = core::Vec3d::Zero(); + direction = core::Vec3d::Zero(); + upDirection = core::Vec3d::Zero(); } -void smCameraEvent::setPosition(const smVec3d& cameraPosition) +void smCameraEvent::setPosition(const core::Vec3d& cameraPosition) { this->position = cameraPosition; } -const smVec3d& smCameraEvent::getPosition() +const core::Vec3d& smCameraEvent::getPosition() { return this->position; } -void smCameraEvent::setDirection(const smVec3d& cameraDirection) +void smCameraEvent::setDirection(const core::Vec3d& cameraDirection) { this->direction = cameraDirection; } -const smVec3d& smCameraEvent::getDirection() +const core::Vec3d& smCameraEvent::getDirection() { return this->direction; } -void smCameraEvent::setUpDirection(const smVec3d& cameraUpDirection) +void smCameraEvent::setUpDirection(const core::Vec3d& cameraUpDirection) { this->upDirection = cameraUpDirection; } -const smVec3d& smCameraEvent::getUpDirection() +const core::Vec3d& smCameraEvent::getUpDirection() { return this->upDirection; } diff --git a/src/Event/CameraEvent.h b/src/Event/CameraEvent.h index 4a3932b578174c1365fd03a6bdee6efde59c4ba9..951fb6f65a95d852f1335da5b9546a4e594e2a4d 100644 --- a/src/Event/CameraEvent.h +++ b/src/Event/CameraEvent.h @@ -32,7 +32,7 @@ namespace mstk { namespace Event { -class smCameraEvent : public smEvent +class smCameraEvent : public Event { public: static EventType EventName; @@ -40,28 +40,28 @@ public: public: smCameraEvent(); - void setPosition(const smVec3d &cameraPosition); + void setPosition(const core::Vec3d &cameraPosition); - const smVec3d &getPosition(); + const core::Vec3d &getPosition(); - void setDirection(const smVec3d &cameraDirection); + void setDirection(const core::Vec3d &cameraDirection); - const smVec3d &getDirection(); + const core::Vec3d &getDirection(); - void setUpDirection(const smVec3d &cameraUpDirection); + void setUpDirection(const core::Vec3d &cameraUpDirection); - const smVec3d &getUpDirection(); + const core::Vec3d &getUpDirection(); - void applyRotation(const smQuaterniond &quat) + void applyRotation(const Quaterniond &quat) { direction = quat*direction; upDirection = quat*upDirection; } private: - smVec3d position; // camera position - smVec3d direction; // direction - smVec3d upDirection; // upward direction + core::Vec3d position; // camera position + core::Vec3d direction; // direction + core::Vec3d upDirection; // upward direction }; } // Event namespace diff --git a/src/Event/HapticEvent.cpp b/src/Event/HapticEvent.cpp index d994e0bc66f87c55798ab107db7e384c8e36680c..a3e9513dfd91b2691ed918a3081ff0a32dcf1af6 100644 --- a/src/Event/HapticEvent.cpp +++ b/src/Event/HapticEvent.cpp @@ -31,52 +31,52 @@ EventType smHapticEvent::EventName = EventType::Haptic; smHapticEvent::smHapticEvent(const size_t& deviceId, const std::string& deviceName): id(deviceId), name(deviceName) {} -void smHapticEvent::setPosition(const smVec3d& coordinates) +void smHapticEvent::setPosition(const core::Vec3d& coordinates) { this->position = coordinates; } -const smVec3d& smHapticEvent::getPosition() +const core::Vec3d& smHapticEvent::getPosition() { return this->position; } -void smHapticEvent::setVelocity(const smVec3d& deviceVelocity) +void smHapticEvent::setVelocity(const core::Vec3d& deviceVelocity) { this->velocity = deviceVelocity; } -const smVec3d& smHapticEvent::getVelocity() +const core::Vec3d& smHapticEvent::getVelocity() { return this->velocity; } -void smHapticEvent::setAngles(const smVec3d& deviceAngles) +void smHapticEvent::setAngles(const core::Vec3d& deviceAngles) { this->angles = deviceAngles; } -const smVec3d& smHapticEvent::getAngles() +const core::Vec3d& smHapticEvent::getAngles() { return this->angles; } -const smMatrix44d& smHapticEvent::getTransform() +const Matrix44d& smHapticEvent::getTransform() { return this->transform; } -void smHapticEvent::setTransform(const smMatrix44d& deviceTransform) +void smHapticEvent::setTransform(const Matrix44d& deviceTransform) { this->transform = deviceTransform; } -const smVec3d& smHapticEvent::getForce() +const core::Vec3d& smHapticEvent::getForce() { return this->force; } -void smHapticEvent::setForce(const smVec3d& deviceForce) +void smHapticEvent::setForce(const core::Vec3d& deviceForce) { this->force = deviceForce; } -const smVec3d& smHapticEvent::getTorque() +const core::Vec3d& smHapticEvent::getTorque() { return this->torque; } -void smHapticEvent::setTorque(const smVec3d& deviceTorque) +void smHapticEvent::setTorque(const core::Vec3d& deviceTorque) { this->torque = deviceTorque; } diff --git a/src/Event/HapticEvent.h b/src/Event/HapticEvent.h index 96f6cc9ef6f62451024aba1a37bbe4d7729c6a8c..d8da483b2c8a76336edd6a5dfd31e5830e7fa3cb 100644 --- a/src/Event/HapticEvent.h +++ b/src/Event/HapticEvent.h @@ -36,7 +36,7 @@ namespace mstk { namespace Event { -class smHapticEvent : public smEvent +class smHapticEvent : public Event { public: static EventType EventName; @@ -44,29 +44,29 @@ public: public: smHapticEvent(const size_t &deviceId, const std::string &deviceName); - void setPosition(const smVec3d &coordinates); + void setPosition(const core::Vec3d &coordinates); - const smVec3d &getPosition(); + const core::Vec3d &getPosition(); - void setVelocity(const smVec3d &deviceVelocity); + void setVelocity(const core::Vec3d &deviceVelocity); - const smVec3d &getVelocity(); + const core::Vec3d &getVelocity(); - void setAngles(const smVec3d &deviceAngles); + void setAngles(const core::Vec3d &deviceAngles); - const smVec3d &getAngles(); + const core::Vec3d &getAngles(); - const smMatrix44d &getTransform(); + const Matrix44d &getTransform(); - void setTransform(const smMatrix44d &deviceTransform); + void setTransform(const Matrix44d &deviceTransform); - const smVec3d &getForce(); + const core::Vec3d &getForce(); - void setForce(const smVec3d &deviceForce); + void setForce(const core::Vec3d &deviceForce); - const smVec3d &getTorque(); + const core::Vec3d &getTorque(); - void setTorque(const smVec3d &deviceTorque); + void setTorque(const core::Vec3d &deviceTorque); size_t getDeviceId() { @@ -86,12 +86,12 @@ public: private: size_t id; // device id std::string name; // device name - smVec3d position; // position - smVec3d velocity; // velocity of the tip - smVec3d angles; // angles - smVec3d force; // input force - smVec3d torque; // input torque - smMatrix44d transform; // transformation matrix + core::Vec3d position; // position + core::Vec3d velocity; // velocity of the tip + core::Vec3d angles; // angles + core::Vec3d force; // input force + core::Vec3d torque; // input torque + Matrix44d transform; // transformation matrix std::array<bool,4> buttonState;//will be chnage later on }; diff --git a/src/Event/KeyboardEvent.h b/src/Event/KeyboardEvent.h index 3f29ee8ba638d542a975e1ff3da766d8ea7aa7a2..5413ddffc33a831cbd373cae70ebb770546448cf 100644 --- a/src/Event/KeyboardEvent.h +++ b/src/Event/KeyboardEvent.h @@ -31,7 +31,7 @@ namespace mstk { namespace Event { -class smKeyboardEvent : public smEvent +class smKeyboardEvent : public Event { public: static EventType EventName; diff --git a/src/Event/LightMotionEvent.cpp b/src/Event/LightMotionEvent.cpp index 4e3d69321b7534da888df9a36e6041c12d40c5d5..1f50718932ad7ce3a30910c982a9c9ab89902792 100644 --- a/src/Event/LightMotionEvent.cpp +++ b/src/Event/LightMotionEvent.cpp @@ -30,22 +30,22 @@ EventType smLightMotionEvent::EventName = EventType::LightMotion; smLightMotionEvent::smLightMotionEvent(const int& lightIndex): index(lightIndex) { - position = smVec3d::Zero(); - direction = smVec3d::Zero(); + position = core::Vec3d::Zero(); + direction = core::Vec3d::Zero(); } -void smLightMotionEvent::setPosition(const smVec3d& lightPosition) +void smLightMotionEvent::setPosition(const core::Vec3d& lightPosition) { this->position = lightPosition; } -const smVec3d& smLightMotionEvent::getPosition() +const core::Vec3d& smLightMotionEvent::getPosition() { return this->position; } -void smLightMotionEvent::setDirection(const smVec3d& lightDirection) +void smLightMotionEvent::setDirection(const core::Vec3d& lightDirection) { this->direction = lightDirection; } -const smVec3d& smLightMotionEvent::getDirection() +const core::Vec3d& smLightMotionEvent::getDirection() { return this->direction; } diff --git a/src/Event/LightMotionEvent.h b/src/Event/LightMotionEvent.h index cae5aa36eceab56219476a74398a79759b4b102e..a8f265b192905ad364cbff11006066f278a14972 100644 --- a/src/Event/LightMotionEvent.h +++ b/src/Event/LightMotionEvent.h @@ -31,7 +31,7 @@ namespace mstk { namespace Event { -class smLightMotionEvent : public smEvent +class smLightMotionEvent : public Event { public: static EventType EventName; @@ -39,13 +39,13 @@ public: public: smLightMotionEvent(const int &lightIndex); - void setPosition(const smVec3d &lightPosition); + void setPosition(const core::Vec3d &lightPosition); - const smVec3d &getPosition(); + const core::Vec3d &getPosition(); - void setDirection(const smVec3d &lightDirection); + void setDirection(const core::Vec3d &lightDirection); - const smVec3d &getDirection(); + const core::Vec3d &getDirection(); void setLightIndex(const int &lightIndex); @@ -53,8 +53,8 @@ public: private: int index; // light index - smVec3d position; // light position - smVec3d direction; // direction + core::Vec3d position; // light position + core::Vec3d direction; // direction }; } // Event namespace diff --git a/src/Event/MouseButtonEvent.cpp b/src/Event/MouseButtonEvent.cpp index fecf8721a7d674c7fbdd734ae88d9ecd067a4dcf..d0ac3c029257237bf2afd0bbd826b809f5ffeda9 100644 --- a/src/Event/MouseButtonEvent.cpp +++ b/src/Event/MouseButtonEvent.cpp @@ -46,11 +46,11 @@ const bool& smMouseButtonEvent::togglePressed() { return this->pressed = !this->pressed; } -void smMouseButtonEvent::setWindowCoord(const smVec2d& coordinates) +void smMouseButtonEvent::setWindowCoord(const core::Vec2d& coordinates) { this->coord = coordinates; } -const smVec2d& smMouseButtonEvent::getWindowCoord() +const core::Vec2d& smMouseButtonEvent::getWindowCoord() { return this->coord; } diff --git a/src/Event/MouseButtonEvent.h b/src/Event/MouseButtonEvent.h index 0f40031c6d660bed4783bd875fe8ecca054ed8dd..231514766a02caf6fe445705ddfd970927decf84 100644 --- a/src/Event/MouseButtonEvent.h +++ b/src/Event/MouseButtonEvent.h @@ -42,7 +42,7 @@ enum class smMouseButton Reset }; -class smMouseButtonEvent : public smEvent +class smMouseButtonEvent : public Event { public: static EventType EventName; @@ -58,14 +58,14 @@ public: const bool &togglePressed(); - void setWindowCoord(const smVec2d &coordinates); + void setWindowCoord(const core::Vec2d &coordinates); - const smVec2d &getWindowCoord(); + const core::Vec2d &getWindowCoord(); private: bool pressed; // If the button was pressed or released in this event smMouseButton mouseButton; // Which mouse button was pressed - smVec2d coord; // X,Y coorindate relative to left edge + core::Vec2d coord; // X,Y coorindate relative to left edge }; } // Event namespace diff --git a/src/Event/MouseMoveEvent.cpp b/src/Event/MouseMoveEvent.cpp index 370073fe4c6bf894d1f59fada911fb4fc70206bb..9bd258c143af03001653edfa92ee38412d9505b7 100644 --- a/src/Event/MouseMoveEvent.cpp +++ b/src/Event/MouseMoveEvent.cpp @@ -28,11 +28,11 @@ namespace Event { EventType smMouseMoveEvent::EventName = EventType::MouseMove; -void smMouseMoveEvent::setWindowCoord(const smVec2d& coordinates) +void smMouseMoveEvent::setWindowCoord(const core::Vec2d& coordinates) { this->coord = coordinates; } -const smVec2d& smMouseMoveEvent::getWindowCoord() +const core::Vec2d& smMouseMoveEvent::getWindowCoord() { return this->coord; } diff --git a/src/Event/MouseMoveEvent.h b/src/Event/MouseMoveEvent.h index 811ded6fd60b9e327b6700fc8b469ed6eca5c50f..c20a9599e88dfccf1b59bc56230f677cd1825685 100644 --- a/src/Event/MouseMoveEvent.h +++ b/src/Event/MouseMoveEvent.h @@ -31,18 +31,18 @@ namespace mstk { namespace Event { -class smMouseMoveEvent : public smEvent +class smMouseMoveEvent : public Event { public: static EventType EventName; public: - void setWindowCoord(const smVec2d &coordinates); + void setWindowCoord(const core::Vec2d &coordinates); - const smVec2d &getWindowCoord(); + const core::Vec2d &getWindowCoord(); private: - smVec2d coord; // X,Y coorindate relative to left edge + core::Vec2d coord; // X,Y coorindate relative to left edge }; } // Event namespace diff --git a/src/Event/ObjectClickedEvent.cpp b/src/Event/ObjectClickedEvent.cpp index dac158229843214e8d26af3f55fcd52ef20e28f1..bc253b521a9d0af94fa9628809e470e47afd6205 100644 --- a/src/Event/ObjectClickedEvent.cpp +++ b/src/Event/ObjectClickedEvent.cpp @@ -30,11 +30,11 @@ EventType smObjectClickedEvent::EventName = EventType::ObjectClicked; smObjectClickedEvent::smObjectClickedEvent(const size_t& objectId): id(objectId) {} -void smObjectClickedEvent::setWindowCoord(const smVec3d& coordinates) +void smObjectClickedEvent::setWindowCoord(const core::Vec3d& coordinates) { this->coord = coordinates; } -const smVec3d& smObjectClickedEvent::getWindowCoord() +const core::Vec3d& smObjectClickedEvent::getWindowCoord() { return this->coord; } diff --git a/src/Event/ObjectClickedEvent.h b/src/Event/ObjectClickedEvent.h index 1684b50ff0c125470f24367dbdd3c2a7482a913e..d9f8a5eefcea4af6c6e7e5bb2c2e91318ccb91ce 100644 --- a/src/Event/ObjectClickedEvent.h +++ b/src/Event/ObjectClickedEvent.h @@ -32,7 +32,7 @@ namespace mstk { namespace Event { -class smObjectClickedEvent : public smEvent +class smObjectClickedEvent : public Event { public: static EventType EventName; @@ -40,13 +40,13 @@ public: public: smObjectClickedEvent(const size_t &objectId); - void setWindowCoord(const smVec3d &coordinates); + void setWindowCoord(const core::Vec3d &coordinates); - const smVec3d &getWindowCoord(); + const core::Vec3d &getWindowCoord(); private: size_t id; // object id - smVec3d coord; // position + core::Vec3d coord; // position }; } // Event namespace diff --git a/src/Event/UnitTests/EventHandlerSpec.cpp b/src/Event/UnitTests/EventHandlerSpec.cpp index b285a21f47a08609a43f1c9467cdcc26097aae57..df9af8c3041308c8c4d5465d31003c08be1f10de 100644 --- a/src/Event/UnitTests/EventHandlerSpec.cpp +++ b/src/Event/UnitTests/EventHandlerSpec.cpp @@ -39,11 +39,11 @@ using namespace bandit; using namespace mstk::Event; -struct MyObserver : public smCoreClass +struct MyObserver : public CoreClass { MyObserver(mstk::Event::EventType _eventType) : success(false), eventType(_eventType) {} - void handleEvent(std::shared_ptr<smEvent> event) override + void handleEvent(std::shared_ptr<Event> event) override { std::shared_ptr<smKeyboardEvent> keyboardEvent = std::static_pointer_cast<smKeyboardEvent>(event); if(keyboardEvent != nullptr && smKeyboardEvent::EventName == eventType) @@ -109,8 +109,8 @@ go_bandit([](){ it("attaches events ", []() { std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); - smEvent::Pointer event = std::make_shared<smEvent>(); - smCoreClass::Pointer observer = std::make_shared<smCoreClass>(); + Event::Pointer event = std::make_shared<Event>(); + CoreClass::Pointer observer = std::make_shared<CoreClass>(); eventHandler->attachEvent(mstk::Event::EventType::Audio,observer); @@ -120,8 +120,8 @@ go_bandit([](){ it("detaches events ", []() { std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); - smEvent::Pointer event = std::make_shared<smEvent>(); - smCoreClass::Pointer observer = std::make_shared<smCoreClass>(); + Event::Pointer event = std::make_shared<Event>(); + CoreClass::Pointer observer = std::make_shared<CoreClass>(); eventHandler->attachEvent(mstk::Event::EventType::Audio,observer); @@ -135,12 +135,12 @@ go_bandit([](){ it("dispatches events ", []() { std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); - smEvent::Pointer event = std::make_shared<smEvent>(); + Event::Pointer event = std::make_shared<Event>(); std::shared_ptr<MyObserver> observer; observer = std::make_shared<MyObserver>(mstk::Event::EventType::None); eventHandler->attachEvent(mstk::Event::EventType::None,observer); - eventHandler->triggerEvent(std::make_shared<smEvent>()); + eventHandler->triggerEvent(std::make_shared<Event>()); AssertThat(observer->success, IsFalse()); observer = std::make_shared<MyObserver>(mstk::Event::EventType::Audio); diff --git a/src/Geometry/MeshModel.cpp b/src/Geometry/MeshModel.cpp index 178a35eda5255b76ad6fac9d716e4ae00a900e66..05008ff084ebea961a5dda4e62dd93104cf769f0 100644 --- a/src/Geometry/MeshModel.cpp +++ b/src/Geometry/MeshModel.cpp @@ -58,26 +58,26 @@ void smMeshModel::load(const std::string& meshName, const smMeshFileType& type) this->mesh->loadMesh(meshName, type); } -const smVec3d& smMeshModel::getNormal(size_t i) const +const core::Vec3d& smMeshModel::getNormal(size_t i) const { return this->mesh->triNormals[i]; } -std::array<smVec3d,3> smMeshModel::getTrianglePositions(size_t i) const +std::array<core::Vec3d,3> smMeshModel::getTrianglePositions(size_t i) const { - std::array<smVec3d, 3> vertices; + std::array<core::Vec3d, 3> vertices; vertices[0] = this->mesh->vertices[this->mesh->triangles[i].vert[0]]; vertices[1] = this->mesh->vertices[this->mesh->triangles[i].vert[1]]; vertices[2] = this->mesh->vertices[this->mesh->triangles[i].vert[2]]; return vertices; } -const smStdVector3d& smMeshModel::getVertices() const +const core::StdVector3d& smMeshModel::getVertices() const { return mesh->getVertices(); } void smMeshModel::draw() { - smRenderDelegate::Ptr delegate = this->mesh->getRenderDelegate(); + RenderDelegate::Ptr delegate = this->mesh->getRenderDelegate(); if (delegate) delegate->draw(); } @@ -104,7 +104,7 @@ void smMeshModel::load(const std::string& meshFileName, const std::string& textu this->mesh->assignTexture(textureName); } } -void smMeshModel::setRenderDetail(std::shared_ptr< smRenderDetail > renderDetail) +void smMeshModel::setRenderDetail(std::shared_ptr< RenderDetail > renderDetail) { this->mesh->setRenderDetail(renderDetail); } diff --git a/src/Geometry/MeshModel.h b/src/Geometry/MeshModel.h index a06a87c7fd81250c70239e4bf4fc2b3770e42830..8def4d5ceaa3e38107f2efd898e88dc87ae374e3 100644 --- a/src/Geometry/MeshModel.h +++ b/src/Geometry/MeshModel.h @@ -39,7 +39,7 @@ /// /// @see smMeshCollisionModel /// -class smMeshModel : public smModelRepresentation +class smMeshModel : public ModelRepresentation { public: /// @@ -65,22 +65,22 @@ public: /// /// @brief Set the rendering details for this mesh /// - void setRenderDetail(std::shared_ptr<smRenderDetail> renderDetail); + void setRenderDetail(std::shared_ptr<RenderDetail> renderDetail); /// /// @brief Returns normal vectors for triangles on mesh surface /// - const smVec3d &getNormal(size_t i) const; + const core::Vec3d &getNormal(size_t i) const; /// /// @brief Returns array of vertices for triangle on surface /// - std::array<smVec3d,3> getTrianglePositions(size_t i) const; + std::array<core::Vec3d,3> getTrianglePositions(size_t i) const; /// /// @brief Returns array of vertices /// - const smStdVector3d &getVertices() const; + const core::StdVector3d &getVertices() const; /// /// @brief Draw this mesh diff --git a/src/Geometry/PlaneModel.cpp b/src/Geometry/PlaneModel.cpp index 2674aafb26922526c189d12bf9e035221208f4ac..3da792313522dd34e07eadf540e098bf41677b97 100644 --- a/src/Geometry/PlaneModel.cpp +++ b/src/Geometry/PlaneModel.cpp @@ -23,9 +23,9 @@ #include "PlaneModel.h" -smPlaneModel::smPlaneModel(const smVec3d& p, const smVec3d& n) +smPlaneModel::smPlaneModel(const core::Vec3d& p, const core::Vec3d& n) { - this->plane = std::make_shared<smPlane>(p, n); + this->plane = std::make_shared<Plane>(p, n); this->transform = RigidTransformType::Identity(); } smPlaneModel::~smPlaneModel() {} @@ -33,18 +33,18 @@ void smPlaneModel::draw() { this->plane->draw(); } -const smVec3d& smPlaneModel::getNormal() const +const core::Vec3d& smPlaneModel::getNormal() const { return this->transform.linear() * this->plane->getUnitNormal(); } -void smPlaneModel::setNormal(const smVec3d& normal) +void smPlaneModel::setNormal(const core::Vec3d& normal) { this->plane->setUnitNormal(normal); } -const smVec3d& smPlaneModel::getPosition() const +const core::Vec3d& smPlaneModel::getPosition() const { // NB: This static variable makes the function thread-unsafe. - static smVec3d result; + static core::Vec3d result; result = this->transform * this->plane->getPoint(); return result; } @@ -57,12 +57,12 @@ void smPlaneModel::setTransform(const smPlaneModel::RigidTransformType& t) this->transform = t; } -void smPlaneModel::setPlaneModel(const std::shared_ptr<smPlane> &p) +void smPlaneModel::setPlaneModel(const std::shared_ptr<Plane> &p) { this->plane = p; } -std::shared_ptr<smPlane> smPlaneModel::getPlaneModel() const +std::shared_ptr<Plane> smPlaneModel::getPlaneModel() const { return plane; } diff --git a/src/Geometry/PlaneModel.h b/src/Geometry/PlaneModel.h index 95e431c7b077ffb1de34ae7728f69d757eea13eb..ffa2415ce2f17f7b584efc3540611fd95fd892d1 100644 --- a/src/Geometry/PlaneModel.h +++ b/src/Geometry/PlaneModel.h @@ -41,7 +41,7 @@ /// /// @see smPlaneCollisionModel /// -class smPlaneModel : public smModelRepresentation +class smPlaneModel : public ModelRepresentation { public: using RigidTransformType = Eigen::Transform<double, 3, Eigen::Isometry>; @@ -50,7 +50,7 @@ public: /// /// @brief Constructor /// - smPlaneModel(const smVec3d& p, const smVec3d& n); + smPlaneModel(const core::Vec3d& p, const core::Vec3d& n); /// /// @brief Destructor @@ -65,17 +65,17 @@ public: /// /// @brief Returns normal vectors for triangles on mesh surface /// - const smVec3d &getNormal() const; + const core::Vec3d &getNormal() const; /// /// @brief Set plane normal /// - void setNormal(const smVec3d &normal); + void setNormal(const core::Vec3d &normal); /// /// @brief Get relative position of the plane /// - const smVec3d &getPosition() const; + const core::Vec3d &getPosition() const; /// /// @brief Get transformation operator @@ -90,16 +90,16 @@ public: /// /// @brief Set transformation operator /// - void setPlaneModel(const std::shared_ptr<smPlane> &p); + void setPlaneModel(const std::shared_ptr<Plane> &p); /// /// @brief Set transformation operator /// - std::shared_ptr<smPlane> getPlaneModel() const; + std::shared_ptr<Plane> getPlaneModel() const; protected: // Plane data and transform - std::shared_ptr<smPlane> plane; + std::shared_ptr<Plane> plane; RigidTransformType transform; }; diff --git a/src/Geometry/UnitTests/MeshModelSpec.cpp b/src/Geometry/UnitTests/MeshModelSpec.cpp index e1a8210007dc1b45f7c644061aec94378b0631a5..0855b49930b6b72fae13ad1b7998a417b221b514 100644 --- a/src/Geometry/UnitTests/MeshModelSpec.cpp +++ b/src/Geometry/UnitTests/MeshModelSpec.cpp @@ -28,7 +28,7 @@ using namespace bandit; -std::shared_ptr<smMeshModel> getModel(const smStdVector3d &vertices) +std::shared_ptr<smMeshModel> getModel(const core::StdVector3d &vertices) { std::shared_ptr<smMeshModel> model = std::make_shared<smMeshModel>(); std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); @@ -61,7 +61,7 @@ go_bandit([](){ }); it("can access mesh vertices", []() { - smStdVector3d vertices; + core::StdVector3d vertices; vertices.emplace_back(1.0,2.0,0); vertices.emplace_back(2.0,3.0,0); vertices.emplace_back(2.0,1.0,0); @@ -75,14 +75,14 @@ go_bandit([](){ }); it("can access mesh face normals", []() { - smStdVector3d vertices; + core::StdVector3d vertices; vertices.emplace_back(1.0,2.0,0); vertices.emplace_back(2.0,3.0,0); vertices.emplace_back(2.0,1.0,0); auto model = getModel(vertices); - smVec3d normalA = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]).normalized(); + core::Vec3d normalA = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]).normalized(); AssertThat((model->getNormal(0)-normalA).squaredNorm(), EqualsWithDelta(0.0,.00001)); }); diff --git a/src/Mesh/ImportExport.h b/src/Mesh/ImportExport.h index 6f336ed64326bf28e62f59998434cdabbbf07288..1d13f730e4e6a072b81154a972b7ce85b2e03f30 100644 --- a/src/Mesh/ImportExport.h +++ b/src/Mesh/ImportExport.h @@ -36,7 +36,7 @@ enum smExportOptions }; /// \brief class for importing and exporting meshes -class smImportExport: public smCoreClass +class smImportExport: public CoreClass { public: diff --git a/src/Mesh/Lattice.cpp b/src/Mesh/Lattice.cpp index 731eb1f3f314b6db0cf5f0f4169e799af596ce23..9cfb7ceec226a1a996aaa565124b0bcfa0f01de1 100644 --- a/src/Mesh/Lattice.cpp +++ b/src/Mesh/Lattice.cpp @@ -35,7 +35,7 @@ smLattice::smLattice() this->ySeperation = 0; this->zSeperation = 0; this->setRenderDelegate( - smFactory<smRenderDelegate>::createSubclass( + Factory<RenderDelegate>::createSubclass( "RenderDelegate", "LatticeRenderDelegate")); } float smLattice::getXStep() @@ -50,15 +50,15 @@ float smLattice::getZStep() { return zStep; } -smVec3d smLattice::getLatticeCenter() +core::Vec3d smLattice::getLatticeCenter() { return latticeCenter; } -smVec3d smLattice::getLeftMinCorner() +core::Vec3d smLattice::getLeftMinCorner() { return cells[0].cellLeftCorner; } -smVec3d smLattice::getRightMaxCorner() +core::Vec3d smLattice::getRightMaxCorner() { return cells[totalCells - 1].cellRightCorner; } @@ -67,7 +67,7 @@ smLattice::~smLattice() delete[] cells; delete[] aabb; } -smLatticeReturnType smLattice::init( smVec3d p_leftCorner, smVec3d p_rightCorner, int p_xSeperation, int p_ySeperation, int p_zSeperation ) +smLatticeReturnType smLattice::init( core::Vec3d p_leftCorner, core::Vec3d p_rightCorner, int p_xSeperation, int p_ySeperation, int p_zSeperation ) { int x, y, z; @@ -153,7 +153,7 @@ void smLattice::linkPrimitivetoCell( int p_primitiveIndex ) int maxY; int maxZ; int index; - smVec3d leftCorner = getLeftMinCorner(); + core::Vec3d leftCorner = getLeftMinCorner(); minX = ( aabb[p_primitiveIndex].aabbMin[0] - leftCorner[0] ) / xStep; minY = ( aabb[p_primitiveIndex].aabbMin[1] - leftCorner[1] ) / yStep; @@ -232,7 +232,7 @@ void smLattice::linkPrims() linkPrimitivetoCell( i ); } } -void smLattice::addObject( smSceneObject *obj ) +void smLattice::addObject( SceneObject *obj ) { core::ClassType objectType; linkedObject = obj->getObjectUnifiedID(); @@ -242,7 +242,7 @@ void smLattice::addObject( smSceneObject *obj ) { case core::ClassType::StaticSceneObject: { - auto staticSceneObject = static_cast<smStaticSceneObject*>(obj); + auto staticSceneObject = static_cast<StaticSceneObject*>(obj); auto model = staticSceneObject->getModel(); if(nullptr == model) { diff --git a/src/Mesh/Lattice.h b/src/Mesh/Lattice.h index a2fff5b08bfff2d442bd5e37e02f78bf87017199..edcb202ffc5923eaa6d84a4e4c755eaedf0f1619 100644 --- a/src/Mesh/Lattice.h +++ b/src/Mesh/Lattice.h @@ -59,8 +59,8 @@ enum smLatticeReturnType /// \brief !! holds the collision primitive pairs struct smCollisionPairs { - std::shared_ptr<smUnifiedId> objectIndex; - std::shared_ptr<smUnifiedId> objectIndex2; + std::shared_ptr<UnifiedId> objectIndex; + std::shared_ptr<UnifiedId> objectIndex2; int primIndex; int primIndex2; }; @@ -79,9 +79,9 @@ class smCell public: int id; int cellId[3]; - smVec3d cellCenter; - smVec3d cellLeftCorner; - smVec3d cellRightCorner; + core::Vec3d cellCenter; + core::Vec3d cellLeftCorner; + core::Vec3d cellRightCorner; smCellPrim cellPrimitives[SIMMEDTK_SPATIALGRID_MAXPRIMITIVES]; int lastPrimitiveIndex; int timeStamp; @@ -93,13 +93,13 @@ public: }; /// \brief !! -class smLattice: public smCoreClass +class smLattice: public CoreClass { public: /// \brief !! void boundingBoxInit() { - aabb = new smAABB[mesh->nbrTriangles]; + aabb = new AABB[mesh->nbrTriangles]; } /// \brief constructor @@ -115,19 +115,19 @@ public: float getZStep(); /// \brief get the center of the lattice - smVec3d getLatticeCenter(); + core::Vec3d getLatticeCenter(); /// \brief !! get the left corner of cell 0 - smVec3d getLeftMinCorner(); + core::Vec3d getLeftMinCorner(); /// \brief !! get the right corner of cell 0 - smVec3d getRightMaxCorner(); + core::Vec3d getRightMaxCorner(); /// \brief destructor ~smLattice(); /// \brief Initialize the lattice - smLatticeReturnType init(smVec3d p_leftCorner, smVec3d p_rightCorner, + smLatticeReturnType init(core::Vec3d p_leftCorner, core::Vec3d p_rightCorner, int p_xSeperation, int p_ySeperation, int p_zSeperation); /// \brief !! @@ -149,13 +149,13 @@ public: void linkPrims(); /// \brief !! - void addObject(smSceneObject *obj); + void addObject(SceneObject *obj); public: friend class smLatticeRenderDelegate; //these should be templated..Current design is based on the triangle - smAABB *aabb; + AABB *aabb; std::shared_ptr<smSurfaceMesh> mesh; smCell *cells; int totalCells; @@ -165,9 +165,9 @@ public: float xStep; float yStep; float zStep; - smVec3d latticeCenter; + core::Vec3d latticeCenter; int time; - std::shared_ptr<smUnifiedId> linkedObject; + std::shared_ptr<UnifiedId> linkedObject; }; #endif diff --git a/src/Mesh/Mesh.cpp b/src/Mesh/Mesh.cpp index 43c7e7cd3eb1bd96b9572164495f7725cdaaacec..4a994c87cbe7b375ddedff3be71d297a024bbae8 100644 --- a/src/Mesh/Mesh.cpp +++ b/src/Mesh/Mesh.cpp @@ -32,7 +32,7 @@ smBaseMesh::smBaseMesh() { -// smSDK::getInstance()->registerMesh(safeDownCast<smBaseMesh>()); +// SDK::getInstance()->registerMesh(safeDownCast<smBaseMesh>()); } void smBaseMesh::updateOriginalVertsWithCurrent() @@ -55,7 +55,7 @@ smMesh::smMesh() isTextureCoordAvailable = false; tangentChannel = false; this->setRenderDelegate( - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "MeshRenderDelegate")); } @@ -79,15 +79,15 @@ void smMesh::allocateAABBTris() } /// \brief -void CalculateTangentArray(int vertexCount, const smVec3d *vertex, - const smVec3d *normal, const smTexCoord *texcoord, +void CalculateTangentArray(int vertexCount, const core::Vec3d *vertex, + const core::Vec3d *normal, const smTexCoord *texcoord, long triangleCount, const smTriangle *triangle, - smVec3d *tangent) + core::Vec3d *tangent) { - smVec3d *tan1 = new smVec3d[vertexCount * 2]; - smVec3d *tan2 = tan1 + vertexCount; - memset(tan1, 0, vertexCount * sizeof(smVec3d) * 2); + core::Vec3d *tan1 = new core::Vec3d[vertexCount * 2]; + core::Vec3d *tan2 = tan1 + vertexCount; + memset(tan1, 0, vertexCount * sizeof(core::Vec3d) * 2); for (long a = 0; a < triangleCount; a++) { @@ -95,9 +95,9 @@ void CalculateTangentArray(int vertexCount, const smVec3d *vertex, long i2 = triangle->vert[1]; long i3 = triangle->vert[2]; - const smVec3d& v1 = vertex[i1]; - const smVec3d& v2 = vertex[i2]; - const smVec3d& v3 = vertex[i3]; + const core::Vec3d& v1 = vertex[i1]; + const core::Vec3d& v2 = vertex[i2]; + const core::Vec3d& v3 = vertex[i3]; const smTexCoord& w1 = texcoord[i1]; const smTexCoord& w2 = texcoord[i2]; @@ -116,9 +116,9 @@ void CalculateTangentArray(int vertexCount, const smVec3d *vertex, float t2 = w3.v - w1.v; float r = 1.0F / (s1 * t2 - s2 * t1); - smVec3d sdir((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, + core::Vec3d sdir((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); - smVec3d tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, + core::Vec3d tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); tan1[i1] += sdir; @@ -134,8 +134,8 @@ void CalculateTangentArray(int vertexCount, const smVec3d *vertex, for (long a = 0; a < vertexCount; a++) { - smVec3d n = normal[a]; - smVec3d t = tan1[a]; + core::Vec3d n = normal[a]; + core::Vec3d t = tan1[a]; tangent[a] = (t - n * n.dot(t)); tangent[a].normalize(); } @@ -153,9 +153,9 @@ void smMesh::calcTriangleTangents() for (t = 0; t < nbrTriangles; t++) { smTriangle *tmpTri = &triangles[t]; - smVec3d *v0 = &vertices[tmpTri->vert[0]]; - smVec3d *v1 = &vertices[tmpTri->vert[1]]; - smVec3d *v2 = &vertices[tmpTri->vert[2]]; + core::Vec3d *v0 = &vertices[tmpTri->vert[0]]; + core::Vec3d *v1 = &vertices[tmpTri->vert[1]]; + core::Vec3d *v2 = &vertices[tmpTri->vert[2]]; smTexCoord *t0 = &texCoord[tmpTri->vert[0]]; smTexCoord *t1 = &texCoord[tmpTri->vert[1]]; smTexCoord *t2 = &texCoord[tmpTri->vert[2]]; @@ -190,11 +190,11 @@ void smMesh::calcTriangleTangents() } /// \brief calucate the triangle tangent for rendering purposes -void smMesh::calculateTangent(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, smVec3d& t) +void smMesh::calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t) { - smVec3d v1; - smVec3d v2; + core::Vec3d v1; + core::Vec3d v2; v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; @@ -215,11 +215,11 @@ void smMesh::calculateTangent(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexCoord& } /// \brief -void smMesh::calculateTangent_test(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, smVec3d& t) +void smMesh::calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t) { - smVec3d v1; - smVec3d v2; + core::Vec3d v1; + core::Vec3d v2; v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; @@ -243,7 +243,7 @@ void smMesh::calculateTangent_test(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexC /// \brief calculates the normal of the vertex void smMesh::updateVertexNormals() { - smVec3d temp = smVec3d::Zero(); + core::Vec3d temp = core::Vec3d::Zero(); for (int i = 0; i < nbrVertices; i++) { @@ -254,7 +254,7 @@ void smMesh::updateVertexNormals() vertNormals[i] = temp; vertNormals[i].normalized(); - temp = smVec3d::Zero(); + temp = core::Vec3d::Zero(); } } @@ -269,10 +269,10 @@ void smMesh::updateTriangleNormals() } /// \brief calculates the normal of a triangle -smVec3d smMesh::calculateTriangleNormal(int triNbr) +core::Vec3d smMesh::calculateTriangleNormal(int triNbr) { - smVec3d v[3]; + core::Vec3d v[3]; smTriangle temp = this->triangles[triNbr]; v[0] = this->vertices[temp.vert[0]]; @@ -294,8 +294,8 @@ bool smMesh::initVertexArrays(int nbr) this->nbrVertices = nbr; this->vertices.resize(nbr); this->origVerts.resize(nbr); - this->vertNormals = new smVec3d[nbr]; - this->vertTangents = new smVec3d[nbr]; + this->vertNormals = new core::Vec3d[nbr]; + this->vertTangents = new core::Vec3d[nbr]; this->texCoord = new smTexCoord[nbr]; return true; } @@ -312,8 +312,8 @@ bool smMesh::initTriangleArrays(int nbr) this->nbrTriangles = nbr; this->triangles = new smTriangle[nbr]; - this->triNormals = new smVec3d[nbr]; - this->triTangents = new smVec3d[nbr]; + this->triNormals = new core::Vec3d[nbr]; + this->triTangents = new core::Vec3d[nbr]; return true; } @@ -472,7 +472,7 @@ void smMesh::translate(float p_offsetX, float p_offsetY, float p_offsetZ) } /// \brief -void smMesh::translate(smVec3d p_offset) +void smMesh::translate(core::Vec3d p_offset) { for (int i = 0; i < nbrVertices; i++) @@ -485,7 +485,7 @@ void smMesh::translate(smVec3d p_offset) } /// \brief -void smMesh::scale(smVec3d p_scaleFactors) +void smMesh::scale(core::Vec3d p_scaleFactors) { for (int i = 0; i < nbrVertices; i++) @@ -503,7 +503,7 @@ void smMesh::scale(smVec3d p_scaleFactors) } /// \brief -void smMesh::rotate(const smMatrix33d &p_rot) +void smMesh::rotate(const Matrix33d &p_rot) { for (int i = 0; i < nbrVertices; i++) @@ -654,7 +654,7 @@ smLineMesh::smLineMesh( int p_nbrVertices ) : smBaseMesh() nbrVertices = p_nbrVertices; vertices.reserve( nbrVertices ); origVerts.reserve( nbrVertices ); - edgeAABBs = new smAABB[nbrVertices - 1]; + edgeAABBs = new AABB[nbrVertices - 1]; texCoord = new smTexCoord[nbrVertices]; edges = new smEdge[nbrVertices - 1]; nbrEdges = nbrVertices - 1; @@ -694,11 +694,11 @@ void smLineMesh::createAutoEdges() } void smLineMesh::updateAABB() { - smAABB tempAABB; - smVec3d minOffset( -2.0, -2.0, -2.0 ); - smVec3d maxOffset( 1.0, 1.0, 1.0 ); - smVec3d minEdgeOffset( -0.1, -0.1, -0.1 ); - smVec3d maxEdgeOffset( 0.1, 0.1, 0.1 ); + AABB tempAABB; + core::Vec3d minOffset( -2.0, -2.0, -2.0 ); + core::Vec3d maxOffset( 1.0, 1.0, 1.0 ); + core::Vec3d minEdgeOffset( -0.1, -0.1, -0.1 ); + core::Vec3d maxEdgeOffset( 0.1, 0.1, 0.1 ); tempAABB.aabbMin[0] = std::numeric_limits<double>::max(); tempAABB.aabbMin[1] = std::numeric_limits<double>::max(); @@ -745,7 +745,7 @@ void smLineMesh::translate( float p_offsetX, float p_offsetY, float p_offsetZ ) updateAABB(); } -void smLineMesh::translate( smVec3d p_offset ) +void smLineMesh::translate( core::Vec3d p_offset ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -756,7 +756,7 @@ void smLineMesh::translate( smVec3d p_offset ) updateAABB(); } -void smLineMesh::rotate( smMatrix33d p_rot ) +void smLineMesh::rotate( Matrix33d p_rot ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -767,7 +767,7 @@ void smLineMesh::rotate( smMatrix33d p_rot ) updateAABB(); } -void smLineMesh::scale( smVec3d p_scaleFactors ) +void smLineMesh::scale( core::Vec3d p_scaleFactors ) { for ( int i = 0; i < nbrVertices; i++ ) diff --git a/src/Mesh/Mesh.h b/src/Mesh/Mesh.h index d204f2ca94a39063492acf1e36a567e612b1b9c0..4365a3af24e44cb700ed8c62667bee76e54c3b03 100644 --- a/src/Mesh/Mesh.h +++ b/src/Mesh/Mesh.h @@ -75,7 +75,7 @@ struct smTextureAttachment }; /// \brief base class for the mesh -class smBaseMesh: public smCoreClass +class smBaseMesh: public CoreClass { public: /// \brief constructor @@ -93,7 +93,7 @@ public: /// \brief update the original texture vertices with the current void updateOriginalVertsWithCurrent(); - const smStdVector3d &getVertices() const + const core::StdVector3d &getVertices() const { return this->vertices; } @@ -106,11 +106,11 @@ public: public: smCollisionGroup collisionGroup; ///< !! GLint renderingID; ///< !! - std::shared_ptr<smErrorLog> log; ///< record the log - smStdVector3d vertices; ///< vertices co-ordinate data at time t - smStdVector3d origVerts; ///< vertices co-ordinate data at time t=0 + std::shared_ptr<ErrorLog> log; ///< record the log + core::StdVector3d vertices; ///< vertices co-ordinate data at time t + core::StdVector3d origVerts; ///< vertices co-ordinate data at time t=0 int nbrVertices; ///< number of vertices - smAABB aabb; ///< Axis aligned bounding box + AABB aabb; ///< Axis aligned bounding box bool isTextureCoordAvailable; ///< true if the texture co-ordinate is available smTexCoord *texCoord; ///< texture co-ordinates std::vector<smTextureAttachment> textureIds; ///< !! @@ -146,7 +146,7 @@ public: void allocateAABBTris(); /// \brief compute the normal of a triangle - smVec3d calculateTriangleNormal(int triNbr); + core::Vec3d calculateTriangleNormal(int triNbr); /// \brief update the normals of triangles after they moved void updateTriangleNormals(); @@ -164,10 +164,10 @@ public: void calcTriangleTangents(); /// \brief compute the tangent give the three vertices - void calculateTangent(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, smVec3d& t); + void calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t); /// \brief !! - void calculateTangent_test(smVec3d& p1, smVec3d& p2, smVec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, smVec3d& t); + void calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t); /// \brief find the neighbors of all vertices of mesh void calcNeighborsVertices(); @@ -179,13 +179,13 @@ public: void translate(float, float, float); /// \brief translate the mesh - void translate(smVec3d p_offset); + void translate(core::Vec3d p_offset); /// \brief scale the mesh - void scale(smVec3d p_scaleFactors); + void scale(core::Vec3d p_scaleFactors); /// \brief rotate the mesh - void rotate(const smMatrix33d &p_rot); + void rotate(const Matrix33d &p_rot); /// \brief check if there is a consistent orientation of triangle vertices /// across the entire surface mesh @@ -217,10 +217,10 @@ public: smTriangle *triangles; ///< list of triangles smTexCoord *texCoordForTrianglesOBJ; ///< !! tansel for OBJ int nbrTexCoordForTrainglesOBJ; ///< !! tansel for OBJ - smVec3d *triNormals; ///< triangle normals - smVec3d *vertNormals; ///< vertex normals - smVec3d *triTangents; ///< triangle tangents - smVec3d *vertTangents; ///< vertex tangents + core::Vec3d *triNormals; ///< triangle normals + core::Vec3d *vertNormals; ///< vertex normals + core::Vec3d *triTangents; ///< triangle tangents + core::Vec3d *vertTangents; ///< vertex tangents bool tangentChannel; ///< !! std::vector< std::vector<int> > vertTriNeighbors; ///< list of neighbors for a triangle std::vector< std::vector<int> > vertVertNeighbors; ///< list of neighbors for a vertex @@ -229,7 +229,7 @@ public: ///AABBB of the mesh. ///This value is allocated and computed by only collision detection module ///Therefore it is initially NULL - std::vector<smAABB> triAABBs; + std::vector<AABB> triAABBs; smMeshType meshType; ///< type of mesh (rigid, deformable etc.) smMeshFileType meshFileType; ///< type of input mesh @@ -290,19 +290,19 @@ public: void translate(float p_offsetX, float p_offsetY, float p_offsetZ); /// \brief translate the vertices of mesh - void translate(smVec3d p_offset); + void translate(core::Vec3d p_offset); /// \brief scale the mesh - void scale(smVec3d p_scaleFactors); + void scale(core::Vec3d p_scaleFactors); /// \brief rotate the mesh - void rotate(smMatrix33d p_rot); + void rotate(Matrix33d p_rot); /// \brief query if the mesh is textured bool isMeshTextured(); public: - smAABB *edgeAABBs;///< AABBs for the edges in the mesh + AABB *edgeAABBs;///< AABBs for the edges in the mesh smEdge *edges;///< edges of the line mesh int nbrEdges;///< number of edges of the line mesh diff --git a/src/Mesh/SurfaceMesh.cpp b/src/Mesh/SurfaceMesh.cpp index a4010ba77b91a16ba04bffb3fac111a061123ed2..72e925f7f25f85b60c2c534320cae510b8a699a1 100644 --- a/src/Mesh/SurfaceMesh.cpp +++ b/src/Mesh/SurfaceMesh.cpp @@ -50,7 +50,7 @@ size_t Filelength(const char * filename, int) #endif /// \brief constructor -smSurfaceMesh::smSurfaceMesh(const smMeshType &p_meshtype, std::shared_ptr<smErrorLog> log) +smSurfaceMesh::smSurfaceMesh(const smMeshType &p_meshtype, std::shared_ptr<ErrorLog> log) { this->log_SF = log; @@ -212,7 +212,7 @@ bool smSurfaceMesh::LoadMeshAssimp(const std::string& fileName) //Get indexed vertex data for (size_t i = 0; i < mesh->mNumVertices; i++) { - this->vertices[i] = smVec3d(mesh->mVertices[i][0], + this->vertices[i] = core::Vec3d(mesh->mVertices[i][0], mesh->mVertices[i][1], mesh->mVertices[i][2]); } @@ -342,8 +342,8 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) this->nbrVertices = l_qty; this->vertices.reserve(l_qty); this->origVerts.reserve(l_qty); - this->vertNormals = new smVec3d[l_qty]; - this->vertTangents = new smVec3d[l_qty]; + this->vertNormals = new core::Vec3d[l_qty]; + this->vertTangents = new core::Vec3d[l_qty]; this->texCoord = new smTexCoord[l_qty]; for (int fpt = 0; fpt < this->nbrVertices; fpt++) @@ -366,8 +366,8 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) fread(&l_qty, sizeof(unsigned short), 1, l_file); this->nbrTriangles = l_qty; this->triangles = new smTriangle[l_qty]; - this->triNormals = new smVec3d[l_qty]; - this->triTangents = new smVec3d[l_qty]; + this->triNormals = new core::Vec3d[l_qty]; + this->triTangents = new core::Vec3d[l_qty]; for (i = 0; i < l_qty; i++) { @@ -422,7 +422,7 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) } smSurfaceMesh::smSurfaceMesh() { - this->log_SF = std::shared_ptr<smErrorLog>(); + this->log_SF = std::shared_ptr<ErrorLog>(); meshType = SMMESH_DEFORMABLE; meshFileType = SM_FILETYPE_NONE; } diff --git a/src/Mesh/SurfaceMesh.h b/src/Mesh/SurfaceMesh.h index 4f24fdda5abc5074d2200316623e83738d284464..161147dd197ff33c7c806cd380669da0c9275193 100644 --- a/src/Mesh/SurfaceMesh.h +++ b/src/Mesh/SurfaceMesh.h @@ -33,13 +33,13 @@ class smSurfaceMesh: public smMesh public: /// \brief push smMesh class specific errors here - std::shared_ptr<smErrorLog> log_SF; + std::shared_ptr<ErrorLog> log_SF; /// \brief constructor smSurfaceMesh(); /// \brief constructor - smSurfaceMesh(const smMeshType &meshtype, std::shared_ptr<smErrorLog> log); + smSurfaceMesh(const smMeshType &meshtype, std::shared_ptr<ErrorLog> log); /// \brief destructor virtual ~smSurfaceMesh(); diff --git a/src/Mesh/VegaVolumetricMesh.cpp b/src/Mesh/VegaVolumetricMesh.cpp index 146fd97dc7fe83b9c1cfd534444e96f68685ca38..b0286ce8f0389cfeb32fd05c32cbbe646f08fad1 100644 --- a/src/Mesh/VegaVolumetricMesh.cpp +++ b/src/Mesh/VegaVolumetricMesh.cpp @@ -67,7 +67,7 @@ size_t smVegaVolumetricMesh::getNumberOfElements() const } void smVegaVolumetricMesh::attachSurfaceMesh(std::shared_ptr<smSurfaceMesh> surfaceMesh, const double &radius) { - const smStdVector3d &meshVertices = surfaceMesh->getVertices(); + const core::StdVector3d &meshVertices = surfaceMesh->getVertices(); int numElementVertices = this->mesh->getNumElementVertices(); int surfaceMeshSize = meshVertices.size(); diff --git a/src/Mesh/VolumeMesh.cpp b/src/Mesh/VolumeMesh.cpp index 53a4a2f7a07deabec338e9d70cda649b526e109f..7d9d3c6e0624403660e03b7f86a7ad48db33402b 100644 --- a/src/Mesh/VolumeMesh.cpp +++ b/src/Mesh/VolumeMesh.cpp @@ -25,7 +25,7 @@ /// \brief constructor -smVolumeMesh::smVolumeMesh(const smMeshType &p_meshtype, std::shared_ptr<smErrorLog> log) +smVolumeMesh::smVolumeMesh(const smMeshType &p_meshtype, std::shared_ptr<ErrorLog> log) { this->log_VM = log; @@ -63,7 +63,7 @@ bool smVolumeMesh::loadMesh(const std::string& fileName, const smMeshFileType &f } /// \brief -void smVolumeMesh::translateVolumeMesh(const smVec3d &p_offset) +void smVolumeMesh::translateVolumeMesh(const core::Vec3d &p_offset) { this->translate(p_offset); @@ -75,7 +75,7 @@ void smVolumeMesh::translateVolumeMesh(const smVec3d &p_offset) } /// \brief -void smVolumeMesh::scaleVolumeMesh(const smVec3d &p_offset) +void smVolumeMesh::scaleVolumeMesh(const core::Vec3d &p_offset) { scale(p_offset); @@ -87,7 +87,7 @@ void smVolumeMesh::scaleVolumeMesh(const smVec3d &p_offset) } /// \brief -void smVolumeMesh::rotVolumeMesh(const smMatrix33d &p_rot) +void smVolumeMesh::rotVolumeMesh(const Matrix33d &p_rot) { rotate(p_rot); @@ -131,8 +131,8 @@ bool smVolumeMesh::LoadTetra(const std::string& fileName) for (i = 0; i < nbrNodes; i++) { - nodes.emplace_back(smVec3d()); - smVec3d &node = nodes.back(); + nodes.emplace_back(core::Vec3d()); + core::Vec3d &node = nodes.back(); fscanf(fp, "%f", &number); nodeNumber[i] = number; fscanf(fp, "%c", &comma); diff --git a/src/Mesh/VolumeMesh.h b/src/Mesh/VolumeMesh.h index a23cc8051bc779ba14dd50410b9ecd4968f4786a..26155c693ab4510478cd4997a33b26461125eb1a 100644 --- a/src/Mesh/VolumeMesh.h +++ b/src/Mesh/VolumeMesh.h @@ -40,7 +40,7 @@ public: smVolumeMesh(); /// \brief constructor - smVolumeMesh(const smMeshType &meshtype, std::shared_ptr<smErrorLog> log); + smVolumeMesh(const smMeshType &meshtype, std::shared_ptr<ErrorLog> log); /// \brief destructor ~smVolumeMesh(); @@ -64,13 +64,13 @@ public: void copySurface(); /// \brief translate mesh vertices in x, y and z directions - void translateVolumeMesh(const smVec3d &p_translate); + void translateVolumeMesh(const core::Vec3d &p_translate); /// \brief scale the volume mesh - void scaleVolumeMesh(const smVec3d &p_scale); + void scaleVolumeMesh(const core::Vec3d &p_scale); /// \brief rotate mesh vertices in x, y and z directions - void rotVolumeMesh(const smMatrix33d &p_rot); + void rotVolumeMesh(const Matrix33d &p_rot); /// \brief load the mesh bool loadMesh(const std::string& fileName, const smMeshFileType &fileType); @@ -85,8 +85,8 @@ public: /// push smMesh class specific errors here int nbrTetra; ///< number of tetrahedra int nbrNodes; ///< total number of nodes of the volume mesh - std::shared_ptr<smErrorLog> log_VM; ///< log the errors with volume mesh class - smStdVector3d nodes; ///< data of nodal co-ordinates + std::shared_ptr<ErrorLog> log_VM; ///< log the errors with volume mesh class + core::StdVector3d nodes; ///< data of nodal co-ordinates std::vector<smTetrahedra> tetra; ///< tetrahedra data std::vector<int> surfaceNodeIndex; ///< std::vector<bool> fixed; ///< indicates if the node is fixed or not diff --git a/src/RenderDelegates/AABBRenderDelegate.cpp b/src/RenderDelegates/AABBRenderDelegate.cpp index edc6617049f12b46d324139d912b19db9d3fcf5a..9f062310245000efbd3a54365e30a8e41e049bfb 100644 --- a/src/RenderDelegates/AABBRenderDelegate.cpp +++ b/src/RenderDelegates/AABBRenderDelegate.cpp @@ -2,7 +2,7 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smAABBRenderDelegate : public smRenderDelegate +class smAABBRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -10,7 +10,7 @@ public: void smAABBRenderDelegate::draw() const { - smAABB* geom = this->getSourceGeometryAs<smAABB>(); + AABB* geom = this->getSourceGeometryAs<AABB>(); if (!geom) return; @@ -48,6 +48,6 @@ void smAABBRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_aabb_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smAABBRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smAABBRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/FemSceneRenderDelegate.cpp b/src/RenderDelegates/FemSceneRenderDelegate.cpp index 653d58cfdc18e6455fb403c2feb157957846d3f1..4efb7b862d12fc7e33bb7d9da35f4d8497d98284 100644 --- a/src/RenderDelegates/FemSceneRenderDelegate.cpp +++ b/src/RenderDelegates/FemSceneRenderDelegate.cpp @@ -3,7 +3,7 @@ #include "Core/Factory.h" #include "Mesh/VolumeMesh.h" -class smFemSceneRenderDelegate : public smRenderDelegate +class smFemSceneRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -12,13 +12,13 @@ public: void smFemSceneRenderDelegate::draw() const { smVolumeMesh* v_mesh = this->getSourceGeometryAs<smFemSceneObject>()->v_mesh; - smRenderDelegate::Ptr delegate = v_mesh->getRenderDelegate(); + RenderDelegate::Ptr delegate = v_mesh->getRenderDelegate(); if (delegate) delegate->draw(); } SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_fem_scene_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smFemSceneRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smFemSceneRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/LatticeRenderDelegate.cpp b/src/RenderDelegates/LatticeRenderDelegate.cpp index b16b262d250bc0ef46a82661eafe2083d05894d0..e70575c3a5ab94379176434c3df987db9675743c 100644 --- a/src/RenderDelegates/LatticeRenderDelegate.cpp +++ b/src/RenderDelegates/LatticeRenderDelegate.cpp @@ -2,7 +2,7 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smLatticeRenderDelegate : public smRenderDelegate +class smLatticeRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -25,14 +25,14 @@ void smLatticeRenderDelegate::draw() const } glMatrixMode( GL_MODELVIEW ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&smColor::colorYellow)); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorYellow)); if ( latticeMode & SIMMEDTK_SMLATTICE_SEPERATIONLINES ) { for ( int j = 0; j < geom->ySeperation; j++ ) { glDisable( GL_LIGHTING ); - glColor3fv(reinterpret_cast<GLfloat*>(&smColor::colorWhite)); + glColor3fv(reinterpret_cast<GLfloat*>(&Color::colorWhite)); glBegin( GL_LINES ); @@ -84,7 +84,7 @@ void smLatticeRenderDelegate::draw() const glEnable( GL_COLOR_MATERIAL ); glBegin( GL_LINE_STRIP ); - glColor3fv( reinterpret_cast<GLfloat*>(&smColor::colorWhite)); + glColor3fv( reinterpret_cast<GLfloat*>(&Color::colorWhite)); glVertex3dv( geom->cells[index].cellLeftCorner.data() ); glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, geom->cells[index].cellLeftCorner[1], @@ -115,7 +115,7 @@ void smLatticeRenderDelegate::draw() const glEnd(); glBegin( GL_LINES ); - glColor3fv( reinterpret_cast<GLfloat*>(&smColor::colorWhite)); + glColor3fv( reinterpret_cast<GLfloat*>(&Color::colorWhite)); glVertex3dv( geom->cells[index].cellLeftCorner.data() ); glVertex3d( geom->cells[index].cellLeftCorner[0], geom->cells[index].cellLeftCorner[1] + geom->yStep, @@ -153,7 +153,7 @@ void smLatticeRenderDelegate::draw() const glPushMatrix(); glPushMatrix(); glTranslatef( geom->cells[0].cellLeftCorner[0], geom->cells[0].cellLeftCorner[1], geom->cells[0].cellLeftCorner[2] ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&smColor::colorYellow)); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorYellow)); // glutSolidSphere( 2, 20, 20 ); glPopMatrix(); @@ -161,7 +161,7 @@ void smLatticeRenderDelegate::draw() const glTranslatef( geom->cells[geom->totalCells - 1].cellRightCorner[0], geom->cells[geom->totalCells - 1].cellRightCorner[1], geom->cells[geom->totalCells - 1].cellRightCorner[2] ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&smColor::colorRed)); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorRed)); // glutSolidSphere( 2, 20, 20 ); glPopMatrix(); glPopMatrix(); @@ -170,6 +170,6 @@ void smLatticeRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_lattice_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smLatticeRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smLatticeRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/MeshRenderDelegate.cpp b/src/RenderDelegates/MeshRenderDelegate.cpp index b153ce71959f0244e856f31dcfa515a93fa6885f..b0d74104c13d5214ea4b598a7a48626ea2d97e67 100644 --- a/src/RenderDelegates/MeshRenderDelegate.cpp +++ b/src/RenderDelegates/MeshRenderDelegate.cpp @@ -3,7 +3,7 @@ #include "Core/Factory.h" #include "Mesh/Mesh.h" -class smMeshRenderDelegate : public smRenderDelegate +class smMeshRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -38,6 +38,6 @@ bool smMeshRenderDelegate::isTargetTextured() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_mesh_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smMeshRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smMeshRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp b/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp index fe4fc4e32aa5756effd75dea0af6b9ff8ab2ddb1..b2b86073f62ceaeccd47da8888b37f4050c86986 100644 --- a/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp +++ b/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp @@ -2,7 +2,7 @@ #include "Core/RenderDelegate.h" #include "Simulators/PBDSceneObject.h" -class smPBDSurfaceRenderDelegate : public smRenderDelegate +class smPBDSurfaceRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -16,6 +16,6 @@ void smPBDSurfaceRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_pbd_surface_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smPBDSurfaceRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smPBDSurfaceRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/PlaneRenderDelegate.cpp b/src/RenderDelegates/PlaneRenderDelegate.cpp index 2123a7375383e15f2cb19516a50aed5d435d61a3..3ea795ad1589117d2468ff494409c179269585f4 100644 --- a/src/RenderDelegates/PlaneRenderDelegate.cpp +++ b/src/RenderDelegates/PlaneRenderDelegate.cpp @@ -2,7 +2,7 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smPlaneRenderDelegate : public smRenderDelegate +class smPlaneRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -10,16 +10,16 @@ public: void smPlaneRenderDelegate::draw() const { - smGLRenderer::draw(*this->getSourceGeometryAs<smPlane>()); + smGLRenderer::draw(*this->getSourceGeometryAs<Plane>()); // if (this->movedOrRotated) // { // updateDrawPoints(); // } // glEnable(GL_LIGHTING); // -// glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, smColor::colorGray.toGLColor()); -// glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, smColor::colorWhite.toGLColor()); -// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, smColor::colorGray.toGLColor()); +// glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Color::colorGray.toGLColor()); +// glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Color::colorWhite.toGLColor()); +// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Color::colorGray.toGLColor()); // // glEnable(GL_BLEND); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -41,6 +41,6 @@ void smPlaneRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_plane_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smPlaneRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smPlaneRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp b/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp index ec466e4d55196e3b468a6b8394e2f8285bcd6f29..0c909ffd912246b1379e118c81e010b5563aea7e 100644 --- a/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp +++ b/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp @@ -4,7 +4,7 @@ /// \brief Displays the fem object with primary or secondary mesh, fixed vertices, /// vertices interacted with, ground plane etc. -class smSceneObjectDeformableRenderDelegate : public smRenderDelegate +class smSceneObjectDeformableRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -28,6 +28,6 @@ void smSceneObjectDeformableRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_scene_object_deformable_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smSceneObjectDeformableRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smSceneObjectDeformableRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp b/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp index e16c413c0f18a5d64104bf1c68e98f8ffdd1db9e..78ac3c645cd6e1840b5e981fce6746f04b72f45f 100644 --- a/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp +++ b/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp @@ -2,7 +2,7 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smStaticSceneObjectRenderDelegate : public smRenderDelegate +class smStaticSceneObjectRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -10,7 +10,7 @@ public: void smStaticSceneObjectRenderDelegate::draw() const { - smStaticSceneObject* geom = this->getSourceGeometryAs<smStaticSceneObject>(); + StaticSceneObject* geom = this->getSourceGeometryAs<StaticSceneObject>(); if (!geom) return; @@ -19,6 +19,6 @@ void smStaticSceneObjectRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_static_scene_object_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smStaticSceneObjectRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smStaticSceneObjectRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/StylusRenderDelegate.cpp b/src/RenderDelegates/StylusRenderDelegate.cpp index 849b963b07fe6521b26b80626c67f442b0d898c4..5ab106aa84f5174be80d946f0190be6d9690679c 100644 --- a/src/RenderDelegates/StylusRenderDelegate.cpp +++ b/src/RenderDelegates/StylusRenderDelegate.cpp @@ -4,7 +4,7 @@ #include "Rendering/GLUtils.h" #include "Simulators/StylusObject.h" -class smStylusRenderDelegate : public smRenderDelegate +class smStylusRenderDelegate : public RenderDelegate { public: virtual void initDraw() const override; @@ -35,7 +35,7 @@ void smStylusRenderDelegate::initDraw() const void smStylusRenderDelegate::draw() const { smStylusRigidSceneObject* geom = this->getSourceGeometryAs<smStylusRigidSceneObject>(); - smMatrix44d viewMatrix; + Matrix44d viewMatrix; #pragma unroll @@ -85,6 +85,6 @@ void smStylusRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_stylus_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smStylusRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smStylusRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp b/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp index 252feec2dd38aab724e113ad54fc89fdfdf9b598..4c9e2eba48974352e168d8a0b30288db80d1e60d 100644 --- a/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp +++ b/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp @@ -3,7 +3,7 @@ #include "Collision/MeshCollisionModel.h" #include "Collision/SurfaceTree.h" -class smSurfaceTreeRenderDelegate : public smRenderDelegate +class SurfaceTreeRenderDelegate : public RenderDelegate { public: virtual void draw() const override; @@ -13,32 +13,32 @@ public: }; /// \brief Draw the surface tree. -void smSurfaceTreeRenderDelegate::draw() const +void SurfaceTreeRenderDelegate::draw() const { - if (this->drawTree<smSurfaceTree<smMeshCollisionModel::AABBNodeType>>()) + if (this->drawTree<SurfaceTree<MeshCollisionModel::AABBNodeType>>()) return; - if (this->drawTree<smSurfaceTree<smOctreeCell>>()) + if (this->drawTree<SurfaceTree<OctreeCell>>()) return; } template<typename T> -bool smSurfaceTreeRenderDelegate::drawTree() const +bool SurfaceTreeRenderDelegate::drawTree() const { T* geom = this->getSourceGeometryAs<T>(); if (!geom) return false; - smVec3d center; + core::Vec3d center; double length; - glColor3fv(smColor::colorGreen.toGLColor()); + glColor3fv(Color::colorGreen.toGLColor()); glEnable(GL_LIGHTING); glPushAttrib(GL_LIGHTING_BIT); - glColor3fv(smColor::colorGreen.toGLColor()); - glColor3fv(smColor::colorBlue.toGLColor()); + glColor3fv(Color::colorGreen.toGLColor()); + glColor3fv(Color::colorBlue.toGLColor()); glPushMatrix(); - glColor3fv(smColor::colorPink.toGLColor()); + glColor3fv(Color::colorPink.toGLColor()); geom->getRoot()->draw(); @@ -52,6 +52,6 @@ bool smSurfaceTreeRenderDelegate::drawTree() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_surface_tree_render_delegate) - SIMMEDTK_REGISTER_CLASS(smRenderDelegate,smRenderDelegate,smSurfaceTreeRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,SurfaceTreeRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/Rendering/Camera.cpp b/src/Rendering/Camera.cpp index 80543fd6592271fe24d58b8c49b8ebba81e3a6cd..4644ae5a2a04e2e09f7a2d338968cce0a99ab718 100644 --- a/src/Rendering/Camera.cpp +++ b/src/Rendering/Camera.cpp @@ -21,14 +21,13 @@ // Contact: //--------------------------------------------------------------------------- -#include "Core/Math.h" #include "Core/Quaternion.h" #include "Core/Vector.h" #include "Camera.h" smCamera::smCamera() : ar(4.0 / 3.0), - angle(SM_DEGREES2RADIANS(45.0)), + angle(M_PI_4), nearClip(0.1), farClip(100.0), pos(0, 0, 0), @@ -40,7 +39,7 @@ smCamera::smCamera() orientDirty.store(false); } -smVec3f smCamera::getPos() +core::Vec3f smCamera::getPos() { std::lock_guard<std::mutex> lock(posLock); return this->pos; @@ -48,10 +47,10 @@ smVec3f smCamera::getPos() void smCamera::setPos(const float x, const float y, const float z) { - this->setPos(smVec3f(x, y, z)); + this->setPos(core::Vec3f(x, y, z)); } -void smCamera::setPos(const smVec3f& v) +void smCamera::setPos(const core::Vec3f& v) { {//scoped for mutex release std::lock_guard<std::mutex> lock(posLock); @@ -61,7 +60,7 @@ void smCamera::setPos(const smVec3f& v) this->orientDirty.store(true); } -smVec3f smCamera::getFocus() +core::Vec3f smCamera::getFocus() { std::lock_guard<std::mutex> lock(fpLock); return this->fp; @@ -69,10 +68,10 @@ smVec3f smCamera::getFocus() void smCamera::setFocus(const float x, const float y, const float z) { - this->setFocus(smVec3f(x, y, z)); + this->setFocus(core::Vec3f(x, y, z)); } -void smCamera::setFocus(const smVec3f& v) +void smCamera::setFocus(const core::Vec3f& v) { { //scoped for mutex release std::lock_guard<std::mutex> lock(fpLock); @@ -82,14 +81,14 @@ void smCamera::setFocus(const smVec3f& v) this->orientDirty.store(true); } -smVec3f smCamera::getUpVec() +core::Vec3f smCamera::getUpVec() { - return getOrientation() * smVec3f::UnitY(); + return getOrientation() * core::Vec3f::UnitY(); } -smVec3f smCamera::getDirection() +core::Vec3f smCamera::getDirection() { - return -(getOrientation() * smVec3f::UnitZ()); + return -(getOrientation() * core::Vec3f::UnitZ()); } float smCamera::getAspectRatio() @@ -116,12 +115,14 @@ void smCamera::setViewAngle(const float a) float smCamera::getViewAngleDeg() { - return SM_RADIANS2DEGREES(getViewAngle()); + // Return degrees + return 57.2957795130823*getViewAngle(); } void smCamera::setViewAngleDeg(const float a) { - setViewAngle(SM_DEGREES2RADIANS(a)); + // Use radians + setViewAngle(0.0174532925199433*a); } float smCamera::getNearClipDist() @@ -146,7 +147,7 @@ void smCamera::setFarClipDist(const float d) this->projDirty.store(true); } -void smCamera::setOrientation(const smQuaternionf q) +void smCamera::setOrientation(const Quaternionf q) { { //scoped for mutex release std::lock_guard<std::mutex> lock(orientationLock); @@ -155,22 +156,22 @@ void smCamera::setOrientation(const smQuaternionf q) this->orientDirty.store(false); } -void smCamera::setOrientFromDir(const smVec3f d) +void smCamera::setOrientFromDir(const core::Vec3f d) { - smMatrix33f camAxes; - smVec3f tempUp; + Matrix33f camAxes; + core::Vec3f tempUp; { //scoped for mutex release std::lock_guard<std::mutex> lock(orientationLock); - tempUp = this->orientation * smVec3f::UnitY(); + tempUp = this->orientation * core::Vec3f::UnitY(); } camAxes.col(2) = (-d).normalized(); camAxes.col(0) = tempUp.cross( camAxes.col(2) ).normalized(); camAxes.col(1) = camAxes.col(2).cross( camAxes.col(0) ).normalized(); - setOrientation(smQuaternionf(camAxes)); + setOrientation(Quaternionf(camAxes)); } -smQuaternionf smCamera::getOrientation() +Quaternionf smCamera::getOrientation() { if (true == this->orientDirty.load()) { @@ -180,7 +181,7 @@ smQuaternionf smCamera::getOrientation() return this->orientation; } -smMatrix44f smCamera::getViewMat() +Matrix44f smCamera::getViewMat() { if (true == this->viewDirty.load()) { @@ -190,7 +191,7 @@ smMatrix44f smCamera::getViewMat() return this->view; } -void smCamera::setViewMat(const smMatrix44f &m) +void smCamera::setViewMat(const Matrix44f &m) { { //scoped for mutex release std::lock_guard<std::mutex> lock(viewLock); @@ -199,7 +200,7 @@ void smCamera::setViewMat(const smMatrix44f &m) this->viewDirty.store(false); } -smMatrix44f smCamera::getProjMat() +Matrix44f smCamera::getProjMat() { if (true == this->projDirty.load()) { @@ -209,7 +210,7 @@ smMatrix44f smCamera::getProjMat() return this->proj; } -void smCamera::setProjMat(const smMatrix44f &m) +void smCamera::setProjMat(const Matrix44f &m) { { //scoped for mutex release std::lock_guard<std::mutex> lock(projLock); @@ -218,7 +219,7 @@ void smCamera::setProjMat(const smMatrix44f &m) this->projDirty.store(false); } -void smCamera::pan(smVec3f v) +void smCamera::pan(core::Vec3f v) { v = getOrientation() * v; setPos(getPos() + v); @@ -234,20 +235,20 @@ void smCamera::zoom(const float d) } } -void smCamera::rotateLocal(const float angle, const smVec3f axis) +void smCamera::rotateLocal(const float angle, const core::Vec3f axis) { float dist = (getPos() - getFocus()).norm(); - smQuaternionf q; + Quaternionf q; q = Eigen::AngleAxisf(angle, axis.normalized()); setOrientation(getOrientation() * q); setFocus(getPos() + dist * getDirection()); } -void smCamera::rotateFocus(const float angle, const smVec3f axis) +void smCamera::rotateFocus(const float angle, const core::Vec3f axis) { float dist = (getFocus() - getPos()).norm(); - smQuaternionf q; + Quaternionf q; q = Eigen::AngleAxisf(angle, axis.normalized()); setOrientation(getOrientation() * q); @@ -256,47 +257,47 @@ void smCamera::rotateFocus(const float angle, const smVec3f axis) void smCamera::rotateLocalX(const float angle) { - rotateLocal(angle, smVec3f::UnitX()); + rotateLocal(angle, core::Vec3f::UnitX()); } void smCamera::rotateLocalY(const float angle) { - rotateLocal(angle, smVec3f::UnitY()); + rotateLocal(angle, core::Vec3f::UnitY()); } void smCamera::rotateLocalZ(const float angle) { - rotateLocal(angle, smVec3f::UnitZ()); + rotateLocal(angle, core::Vec3f::UnitZ()); } void smCamera::rotateFocusX(const float angle) { - rotateFocus(angle, smVec3f::UnitX()); + rotateFocus(angle, core::Vec3f::UnitX()); } void smCamera::rotateFocusY(const float angle) { - rotateFocus(angle, smVec3f::UnitY()); + rotateFocus(angle, core::Vec3f::UnitY()); } void smCamera::rotateFocusZ(const float angle) { - rotateFocus(angle, smVec3f::UnitZ()); + rotateFocus(angle, core::Vec3f::UnitZ()); } // Implementation adapted from Sylvain Pointeau's Blog: // http://spointeau.blogspot.com/2013/12/hello-i-am-looking-at-opengl-3.html -smMatrix44f smCamera::lookAt(const smVec3f pos, - const smVec3f fp, - const smVec3f up) +Matrix44f smCamera::lookAt(const core::Vec3f pos, + const core::Vec3f fp, + const core::Vec3f up) { - smVec3f f = (fp - pos).normalized(); - smVec3f u = up.normalized(); - smVec3f s = f.cross(u).normalized(); + core::Vec3f f = (fp - pos).normalized(); + core::Vec3f u = up.normalized(); + core::Vec3f s = f.cross(u).normalized(); u = s.cross(f); - smMatrix44f res; + Matrix44f res; res << s.x(),s.y(),s.z(),-s.dot(pos), u.x(),u.y(),u.z(),-u.dot(pos), -f.x(),-f.y(),-f.z(),f.dot(pos), @@ -312,14 +313,14 @@ void smCamera::genViewMat() // Implementation adapted from Sylvain Pointeau's Blog: // http://spointeau.blogspot.com/2013/12/hello-i-am-looking-at-opengl-3.html -smMatrix44f smCamera::perspective(const float fovy, const float ar, +Matrix44f smCamera::perspective(const float fovy, const float ar, const float zNear, const float zFar) { assert(ar > 0); assert(zFar > zNear); double tanHalfFovy = tan(fovy / 2.0); - smMatrix44f res = smMatrix44f::Zero(); + Matrix44f res = Matrix44f::Zero(); res(0,0) = 1.0 / (ar * tanHalfFovy); res(1,1) = 1.0 / (tanHalfFovy); diff --git a/src/Rendering/Camera.h b/src/Rendering/Camera.h index e8df5628821f7e5430db25f5a52f24f3933ee214..4557053be82b06b8d105ef396f4f5f1dad62c936 100644 --- a/src/Rendering/Camera.h +++ b/src/Rendering/Camera.h @@ -31,6 +31,7 @@ /// STL icludes #include <memory> #include <mutex> +#include <atomic> /// \brief A simple camera class to calculate view and projection matrices /// @@ -53,12 +54,12 @@ public: /// \brief Set the position of the camera /// /// \param v 3 Dimensional vector describing the position of the camera - void setPos(const smVec3f& v); + void setPos(const core::Vec3f& v); /// \brief Get the position of the camera /// /// \return 3 Dimensional vector containing the position of the camera - smVec3f getPos(); + core::Vec3f getPos(); /// \brief Set the focal point of the camera /// @@ -70,22 +71,22 @@ public: /// \brief Set the focal point of the camera /// /// \param v 3 Dimensional vector describing the focal point of the camera - void setFocus(const smVec3f& v); + void setFocus(const core::Vec3f& v); /// \brief Get the focal point of the camera /// /// \return 3 Dimensional vector containing the focal point of the camera - smVec3f getFocus(); + core::Vec3f getFocus(); /// \brief Get the up direction of the camera /// /// \return 3 Dimensional vector containing the up direction of the camera - smVec3f getUpVec(); + core::Vec3f getUpVec(); /// \brief Get the direction the camera is facing /// /// \return 3 Dimensional vector containing the direction of the camera - smVec3f getDirection(); + core::Vec3f getDirection(); //Projection settings /// \brief Set the aspect ratio of the camera @@ -146,12 +147,12 @@ public: /// \brief Returns the internal view matrix for the camera /// /// \return A 4 by 4 matrix containing the view matrix of the camera - smMatrix44f getViewMat(); + Matrix44f getViewMat(); /// \brief Returns the internal projection matrix for the camera /// /// \return A 4 by 4 matrix containing the projection matrix of the camera - smMatrix44f getProjMat(); + Matrix44f getProjMat(); /// \brief Pan the camera view /// @@ -159,7 +160,7 @@ public: /// amount /// /// \param v Vector describing how much to pan by in each direction - void pan(const smVec3f v); + void pan(const core::Vec3f v); /// \brief Zoom the camera /// @@ -173,13 +174,13 @@ public: /// /// \param angle The angle in radians to rotate /// \param axis The axis to rotate about - void rotateLocal(const float angle, const smVec3f axis); + void rotateLocal(const float angle, const core::Vec3f axis); /// \brief Rotates about an arbitrary axis in focus point coordinates /// /// \param angle The angle in radians to rotate /// \param axis The axis to rotate about - void rotateFocus(const float angle, const smVec3f axis); + void rotateFocus(const float angle, const core::Vec3f axis); /// \brief Rotates about the camera's local X axis /// @@ -237,9 +238,9 @@ public: /// \param up Upward facing direction of the camera /// /// \return A 4 by 4 matrix containing the view matrix - smMatrix44f lookAt(const smVec3f pos, - const smVec3f fp, - const smVec3f up); + Matrix44f lookAt(const core::Vec3f pos, + const core::Vec3f fp, + const core::Vec3f up); /// \brief Creates a perspective matrix for use with OpenGL /// @@ -249,7 +250,7 @@ public: /// \param zFar The far clipping distance /// /// \return A 4 by 4 matrix containing the perspective matrix - smMatrix44f perspective(const float fovy, const float ar, + Matrix44f perspective(const float fovy, const float ar, const float zNear, const float zFar); //Create matrices @@ -288,13 +289,13 @@ public: private: //View matrix variables - smVec3f pos; ///< position of the camera + core::Vec3f pos; ///< position of the camera std::mutex posLock; //< Controls access to the pos variable - smVec3f fp; ///< focal point of the camera + core::Vec3f fp; ///< focal point of the camera std::mutex fpLock; //< Controls access to the fp variable - smQuaternionf orientation; ///< orientation of the camera + Quaternionf orientation; ///< orientation of the camera std::mutex orientationLock; //< Controls access to the orientation variable - smMatrix44f view; ///< View matrix for OpenGL + Matrix44f view; ///< View matrix for OpenGL std::mutex viewLock; //< Controls access to the view variable std::atomic_bool viewDirty; ///< True if view variables have been updated std::atomic_bool orientDirty; ///< True if orientation needs to be recalculated @@ -304,7 +305,7 @@ private: std::atomic<float> angle; ///< angle in radians std::atomic<float> nearClip; ///< near clipping distance std::atomic<float> farClip; ///< far clipping distance - smMatrix44f proj; ///< Projection matrix for OpenGL + Matrix44f proj; ///< Projection matrix for OpenGL std::mutex projLock; //< Controls access to the proj variable std::atomic_bool projDirty; ///< True if projection variables have been updated @@ -314,7 +315,7 @@ private: /// updated also /// /// \param m The new view matrix of the camera - void setViewMat(const smMatrix44f &m); + void setViewMat(const Matrix44f &m); /// \brief Replace the internal projection matrix of the camera /// @@ -322,24 +323,24 @@ private: /// updated also /// /// \param m The new projection matrix of the camera - void setProjMat(const smMatrix44f &m); + void setProjMat(const Matrix44f &m); /// \brief Sets the orientation of the camera from a given direction /// /// \detail Generally used to orient the camera toward the focal point /// /// \param d Directional vector to orient the camera with - void setOrientFromDir(const smVec3f d); + void setOrientFromDir(const core::Vec3f d); /// \brief Replaces the internal quaternion with the one provided /// /// \param q New internal orientation quaternion - void setOrientation(const smQuaternionf q); + void setOrientation(const Quaternionf q); /// \brief Returns the orientation of the camera /// /// \return The orientation of the camera as a quaternion - smQuaternionf getOrientation(); + Quaternionf getOrientation(); }; #endif diff --git a/src/Rendering/ConfigRendering.h b/src/Rendering/ConfigRendering.h index 233707a5e0159ef9204eefcd9250fa81991960eb..c9110f4d3391e914a151413c10b60f908064880c 100644 --- a/src/Rendering/ConfigRendering.h +++ b/src/Rendering/ConfigRendering.h @@ -105,7 +105,7 @@ enum smVBOResult struct smViewerDetail { unsigned int environment; - smColor backGroundColor; + Color backGroundColor; }; #endif // SMCONFIGRENDERING_H diff --git a/src/Rendering/CustomRenderer.h b/src/Rendering/CustomRenderer.h index 463c2c4c1d0dd706303fc2dad7661e8b9d8b7043..7e0e50f05174576eaadc93c29af41b947b1fea74 100644 --- a/src/Rendering/CustomRenderer.h +++ b/src/Rendering/CustomRenderer.h @@ -31,22 +31,22 @@ #include "Core/SceneObject.h" //forward declaration -class smSceneObject; +class SceneObject; /// \brief custom renderer for the object. ///you could draw with one custom renderer with multiple objects. ///This is the reason why the functions are taken objects. -class smCustomRenderer: public smCoreClass +class smCustomRenderer: public CoreClass { public: /// \briefthis function should be implemented based on objects //virtual void init(); /// \brief draw pre, default and post draw routines - virtual void preDraw(const smSceneObject &p_object); + virtual void preDraw(const SceneObject &p_object); virtual void draw(); - virtual void draw(const smSceneObject &p_object); - virtual void postDraw(const smSceneObject &p_object); + virtual void draw(const SceneObject &p_object); + virtual void postDraw(const SceneObject &p_object); }; /// \briefderive this class if you want to render a class in the viewer. diff --git a/src/Rendering/FrameBuffer.cpp b/src/Rendering/FrameBuffer.cpp index e8531e72ddbaba8f65e15ad8b3894070105959fe..3c3f3c57c5dc708d14f6d98b15dad70e484f8493 100644 --- a/src/Rendering/FrameBuffer.cpp +++ b/src/Rendering/FrameBuffer.cpp @@ -236,7 +236,7 @@ void smFrameBuffer::attachRenderBuffer( smRenderBuffer *p_renderBuf ) _fbo.AttachRenderBuffer( p_renderBuf->getRenderBufId(), p_renderBuf->getGLAttachmentId() ); } } -void smFrameBuffer::attachDepthTexture( smTexture *p_texture ) +void smFrameBuffer::attachDepthTexture( Texture *p_texture ) { if ( p_texture == NULL ) { @@ -246,7 +246,7 @@ void smFrameBuffer::attachDepthTexture( smTexture *p_texture ) _fbo.AttachTexture( p_texture->GLtype, p_texture->textureGLId, GL_DEPTH_ATTACHMENT_EXT ); isDepthTexAttached = true; } -void smFrameBuffer::attachColorTexture( smTexture *p_texture, int p_attachmentOrder ) +void smFrameBuffer::attachColorTexture( Texture *p_texture, int p_attachmentOrder ) { defaultColorAttachment = p_attachmentOrder; _fbo.AttachTexture( p_texture->GLtype, p_texture->textureGLId, GL_COLOR_ATTACHMENT0_EXT + p_attachmentOrder ); diff --git a/src/Rendering/FrameBuffer.h b/src/Rendering/FrameBuffer.h index a27adbda947d7c1a4da56293513e289f76c6c665..d640fa2d9d16da4f91375699e3d3dc9c40193da6 100644 --- a/src/Rendering/FrameBuffer.h +++ b/src/Rendering/FrameBuffer.h @@ -51,7 +51,7 @@ enum smRenderBufferType SIMMEDTK_RENDERBUFFER_COLOR_RGB = GL_RGB }; /// \brief render buffer type used for frame buffer attachment -class smRenderBuffer: public smCoreClass +class smRenderBuffer: public CoreClass { protected: /// \brief renderbuffer @@ -95,7 +95,7 @@ public: }; /// \brief GL frame buffer class -class smFrameBuffer: public smCoreClass +class smFrameBuffer: public CoreClass { public: /// \brief GL frame buffer @@ -131,9 +131,9 @@ public: /// \brief attach render buffer to te frame buffer void attachRenderBuffer(smRenderBuffer *p_renderBuf); /// \brief attach depth texture - void attachDepthTexture(smTexture *p_texture); + void attachDepthTexture(Texture *p_texture); /// \brief attach a color texture - void attachColorTexture(smTexture *p_texture, int p_attachmentOrder); + void attachColorTexture(Texture *p_texture, int p_attachmentOrder); /// \brief activate color buffer in the specified order void activeColorBuf(int p_order); /// \brief enable the framebuffer diff --git a/src/Rendering/GLRenderer.h b/src/Rendering/GLRenderer.h index 7356eda4a3dafdf7e84664ffa127926429e03787..d10a49badabf1c011e0d5dd71e780ac2f180ecb0 100644 --- a/src/Rendering/GLRenderer.h +++ b/src/Rendering/GLRenderer.h @@ -34,55 +34,55 @@ #include "Core/Matrix.h" class smMesh; -class smAABB; +class AABB; class smLineMesh; class smViewer; -class smPlane; -class smScene; +class Plane; +class Scene; -struct smRenderDetail; +struct RenderDetail; /// \brief gl rendering utilities -class smGLRenderer: public smCoreClass +class smGLRenderer: public CoreClass { public: /// \brief constructor smGLRenderer(); /// \brief draws surface mesh with given rendertdail and draw paramters - static void drawSurfaceMeshTriangles(std::shared_ptr<smMesh> p_surfaceMesh, std::shared_ptr<smRenderDetail> renderDetail); + static void drawSurfaceMeshTriangles(std::shared_ptr<smMesh> p_surfaceMesh, std::shared_ptr<RenderDetail> renderDetail); /// \brief draw normals - static void drawNormals(std::shared_ptr<smMesh> p_mesh, smColor p_color = smColor::colorBlue, float length=1.0); + static void drawNormals(std::shared_ptr<smMesh> p_mesh, Color p_color = Color::colorBlue, float length=1.0); /// \brief draw line mesh - static void drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<smRenderDetail> renderDetail); + static void drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail); /// \brief draw coordinate system - static void drawCoordSystem(std::shared_ptr<smViewer> viewer, std::string p_name, smVec3d p_pos, smVec3d dirX, smVec3d dirY, smVec3d dirZ); + static void drawCoordSystem(std::shared_ptr<smViewer> viewer, std::string p_name, core::Vec3d p_pos, core::Vec3d dirX, core::Vec3d dirY, core::Vec3d dirZ); /// \brief begin rendering triangle static void beginTriangles(); /// \brief draw triangle - static void drawTriangle(smVec3d &p_1, smVec3d &p_2, smVec3d &p_3); + static void drawTriangle(core::Vec3d &p_1, core::Vec3d &p_2, core::Vec3d &p_3); /// \brief end triangle rendering static void endTriangles(); /// \brief draw AABB - static void draw(smAABB &aabb, smColor p_color = smColor(1.0, 1.0, 1.0)); + static void draw(AABB &aabb, Color p_color = Color(1.0, 1.0, 1.0)); /// \brief draw plane - static void draw(smPlane &p_plane, float p_scale = 10.0, smColor p_color = smColor::colorYellow); + static void draw(Plane &p_plane, float p_scale = 10.0, Color p_color = Color::colorYellow); /// \brief draw axes given rotation matrix, position and length to draw - static void drawAxes(const smMatrix33f &rotMat, const smVec3f &pos, const float length); + static void drawAxes(const Matrix33f &rotMat, const core::Vec3f &pos, const float length); /// \brief draw global axes length to draw static void drawAxes(const float length); /// \brief draw arrow given starting position, ending poistion and width of the arrow head - static void drawArrow(const smVec3f &start, const smVec3f &end, const float D); + static void drawArrow(const core::Vec3f &start, const core::Vec3f &end, const float D); /// \brief draw function is called for visualization the object virtual void draw(){} @@ -90,28 +90,28 @@ public: /// \brief switch to default rendering static void enableDefaultGLRendering(); - /// \brief Renders an smScene's objects + /// \brief Renders an Scene's objects /// /// \detail Requires the caller to have called registerForScene() on p_scene /// \param p_scene The scene to render /// \param p_param The drawing parameters - static void renderScene(std::shared_ptr<smScene> p_scene); - /// \brief Renders a smScene's objects + static void renderScene(std::shared_ptr<Scene> p_scene); + /// \brief Renders a Scene's objects /// /// \detail Requires the caller to have called registerForScene() on p_scene /// \param p_scene The scene to render /// \param p_param The drawing parameters /// \param p_proj A custom projection matrix to use instead of that provided with the scene /// \param p_view A custom view matrix to use instead of that provided with the scene - static void renderScene(std::shared_ptr<smScene> p_scene, - const smMatrix44f &p_proj, - const smMatrix44f &p_view); + static void renderScene(std::shared_ptr<Scene> p_scene, + const Matrix44f &p_proj, + const Matrix44f &p_view); - /// \brief Renders a single smSceneObject + /// \brief Renders a single SceneObject /// /// \param p_sceneObject The scene object to render /// \param p_param The drawing parameters - static void renderSceneObject(std::shared_ptr<smSceneObject> p_sceneObject); + static void renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject); }; #endif diff --git a/src/Rendering/GLUtils.cpp b/src/Rendering/GLUtils.cpp index 1c5a30b168911f2d04e882a2b8af6e5666592331..c98b70962a5b946baaabb12a0771165ee6c1ba13 100644 --- a/src/Rendering/GLUtils.cpp +++ b/src/Rendering/GLUtils.cpp @@ -91,7 +91,7 @@ void smGLUtils::fadeBackgroundDraw() glPopAttrib(); } -void smGLUtils::drawQuadOnScreen(smColor p_color, float p_left, +void smGLUtils::drawQuadOnScreen(Color p_color, float p_left, float p_bottom, float p_right, float p_top) { @@ -139,11 +139,11 @@ void smGLUtils::drawUnitQuadOnScreen() glVertex3d(-1, 1.0, -1); glEnd(); } -void smGLUtils::queryProjectionMatrix(smMatrix44f& p_matrix) +void smGLUtils::queryProjectionMatrix(Matrix44f& p_matrix) { glGetFloatv(GL_PROJECTION_MATRIX, p_matrix.data()); } -void smGLUtils::queryModelViewMatrix(smMatrix44f& p_matrix) +void smGLUtils::queryModelViewMatrix(Matrix44f& p_matrix) { glGetFloatv(GL_MODELVIEW_MATRIX, p_matrix.data()); } diff --git a/src/Rendering/GLUtils.h b/src/Rendering/GLUtils.h index 58be11bdc8a75602ec1c5f7c3ac70fc0afe74113..9c618a6d8467ec485fe6cb7510bfcf6e33b67142 100644 --- a/src/Rendering/GLUtils.h +++ b/src/Rendering/GLUtils.h @@ -34,7 +34,7 @@ struct smGroundRenderInfo; /// \brief opengl rendering utilities are here. -class smGLUtils : public smCoreClass +class smGLUtils : public CoreClass { public: // OpenGL 3.0 adds the concept of indexed strings and @@ -64,7 +64,7 @@ public: static void fadeBackgroundDraw(); /// \brief draw quad on screen with color and left, botton, right, top positions - static void drawQuadOnScreen(smColor p_color, + static void drawQuadOnScreen(Color p_color, float p_left, float p_bottom, float p_right, @@ -73,9 +73,9 @@ public: /// \brief draw unit quad static void drawUnitQuadOnScreen(); - static void queryProjectionMatrix(smMatrix44f &p_matrix); + static void queryProjectionMatrix(Matrix44f &p_matrix); /// \brief to query current model view matrix. p_matrix will have the final values. - static void queryModelViewMatrix(smMatrix44f &p_matrix); + static void queryModelViewMatrix(Matrix44f &p_matrix); private: std::vector<std::string> openGLExtensions; diff --git a/src/Rendering/MetalShader.cpp b/src/Rendering/MetalShader.cpp index ee3df1d15d0e63b9e67928ab17e8099558907189..b72f52f7ce1f5e17f0b3a972d989f5380af495cb 100644 --- a/src/Rendering/MetalShader.cpp +++ b/src/Rendering/MetalShader.cpp @@ -29,9 +29,9 @@ smMetalShader::smMetalShader( const std::string &p_verteShaderFileName, const std::string &p_fragmentFileName ) : - smShader(smSDK::getInstance()->getErrorLog()) + smShader(SDK::getInstance()->getErrorLog()) { - this->log = smSDK::getInstance()->getErrorLog(); + this->log = SDK::getInstance()->getErrorLog(); this->log->isOutputtoConsoleEnabled = false; this->checkErrorEnabled = true; setShaderFileName( p_verteShaderFileName, NULL, p_fragmentFileName ); @@ -110,7 +110,7 @@ void smMetalShader::predraw(std::shared_ptr<smMesh> mesh ) } } -void smMetalShader::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) +void smMetalShader::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) { auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); if(keyboardEvent) diff --git a/src/Rendering/MetalShader.h b/src/Rendering/MetalShader.h index d19e3af101023c631a7da31f64968fe63db6b31e..d3f653f2b160364c684902e6c66e5b605c2598d5 100644 --- a/src/Rendering/MetalShader.h +++ b/src/Rendering/MetalShader.h @@ -30,7 +30,7 @@ namespace mstk{ namespace Event{ - class smEvent; + class Event; } } @@ -61,7 +61,7 @@ public: virtual void predraw(std::shared_ptr<smSurfaceMesh> mesh) override; /// \brief handle keyboard event - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief any disable and enable shader options need to be here virtual void switchEnable(); diff --git a/src/Rendering/OculusViewer.cpp b/src/Rendering/OculusViewer.cpp index e12e890a16db7eb0f0064a23f304004150a6a6f4..5196f82eaa66911d3c761c2bed982cf7bebfa7c8 100644 --- a/src/Rendering/OculusViewer.cpp +++ b/src/Rendering/OculusViewer.cpp @@ -122,7 +122,7 @@ void smOculusViewer::endFrame() // Oculus doesn't like it when you swap buffers } -void smOculusViewer::renderToScreen(const smRenderOperation &p_rop) +void smOculusViewer::renderToScreen(const RenderOperation &p_rop) { int i; ovrMatrix4f ovrProj; @@ -140,8 +140,8 @@ void smOculusViewer::renderToScreen(const smRenderOperation &p_rop) //for each eye ... for (i = 0; i < 2; i++) { ovrEyeType eye = hmd->EyeRenderOrder[i]; - smMatrix44f proj; - smMatrix44f view; + Matrix44f proj; + Matrix44f view; Eigen::Affine3f viewRotation; Eigen::Affine3f headTracking; Eigen::Affine3f playerHeight; @@ -162,7 +162,7 @@ void smOculusViewer::renderToScreen(const smRenderOperation &p_rop) // OpenGL expects, so we have to transpose them. ovrProj = ovrMatrix4f_Projection(hmd->DefaultEyeFov[eye], 0.1, 500.0, 1); //copy the ovr matrix into a matrix and transpose it - proj = Eigen::Map<smMatrix44f>(&(ovrProj.M[0][0])); + proj = Eigen::Map<Matrix44f>(&(ovrProj.M[0][0])); proj.transposeInPlace(); // -- view/camera transformation -- @@ -173,7 +173,7 @@ void smOculusViewer::renderToScreen(const smRenderOperation &p_rop) //retrieve the orientation quaternion and // convert it to a rotation matrix - viewRotation = smQuaternionf(-pose[eye].Orientation.w, + viewRotation = Quaternionf(-pose[eye].Orientation.w, pose[eye].Orientation.x, pose[eye].Orientation.y, pose[eye].Orientation.z); @@ -192,7 +192,7 @@ void smOculusViewer::renderToScreen(const smRenderOperation &p_rop) playerHeight = (Eigen::Translation3f( 0, -ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, 1.65), 0)); - smMatrix44f trans = (viewRotation * headTracking * playerHeight).matrix(); + Matrix44f trans = (viewRotation * headTracking * playerHeight).matrix(); view = trans * view; //Render Scene diff --git a/src/Rendering/OculusViewer.h b/src/Rendering/OculusViewer.h index b770fb6f7ce9d6be11327a4f4dceefed863e5bec..72be54d5dc43ffb4df3a836659cb86779f2398f1 100644 --- a/src/Rendering/OculusViewer.h +++ b/src/Rendering/OculusViewer.h @@ -42,7 +42,7 @@ public: protected: virtual void beginFrame() override; virtual void endFrame() override; - virtual void renderToScreen(const smRenderOperation &p_rop) override; + virtual void renderToScreen(const RenderOperation &p_rop) override; private: ovrHmd hmd; ovrSizei eyeRes[2]; diff --git a/src/Rendering/Renderer.cpp b/src/Rendering/Renderer.cpp index d36be30a92d885c0cc526839e53413512cb5f1ae..ac0ed8fc251e853b7eb8597d6287fb63e6601f1a 100644 --- a/src/Rendering/Renderer.cpp +++ b/src/Rendering/Renderer.cpp @@ -38,12 +38,12 @@ smGLRenderer::smGLRenderer() } #if 0 -void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<smRenderDetail> renderDetail) +void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail) { - static smVec3d origin(0, 0, 0); - static smVec3d xAxis(1, 0, 0); - static smVec3d yAxis(0, 1, 0); - static smVec3d zAxis(0, 0, 1); + static core::Vec3d origin(0, 0, 0); + static core::Vec3d xAxis(1, 0, 0); + static core::Vec3d yAxis(0, 1, 0); + static core::Vec3d zAxis(0, 0, 1); const int renderType = renderDetail->getRenderType(); @@ -175,7 +175,7 @@ void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::sha void smGLRenderer::drawSurfaceMeshTriangles( std::shared_ptr<smMesh> p_surfaceMesh, - std::shared_ptr<smRenderDetail> renderDetail) + std::shared_ptr<RenderDetail> renderDetail) { if (p_surfaceMesh->getRenderDetail()->getRenderType() & SIMMEDTK_RENDER_NONE) { @@ -301,13 +301,13 @@ void smGLRenderer::drawSurfaceMeshTriangles( glLineWidth(1.0); } -void smGLRenderer::drawNormals(std::shared_ptr<smMesh> p_mesh, smColor p_color, float length) +void smGLRenderer::drawNormals(std::shared_ptr<smMesh> p_mesh, Color p_color, float length) { glDisable(GL_LIGHTING); glColor3fv(reinterpret_cast<GLfloat*>(&p_color)); - smVec3d baryCenter; - smVec3d tmp; + core::Vec3d baryCenter; + core::Vec3d tmp; glBegin(GL_LINES); @@ -338,7 +338,7 @@ void smGLRenderer::beginTriangles() glBegin(GL_TRIANGLES); } -void smGLRenderer::drawTriangle(smVec3d &p_1, smVec3d &p_2, smVec3d &p_3) +void smGLRenderer::drawTriangle(core::Vec3d &p_1, core::Vec3d &p_2, core::Vec3d &p_3) { glVertex3dv(p_1.data()); @@ -352,7 +352,7 @@ void smGLRenderer::endTriangles() glEnd(); } -void smGLRenderer::draw(smAABB &aabb, smColor p_color) +void smGLRenderer::draw(AABB &aabb, Color p_color) { glPushAttrib(GL_LIGHTING_BIT); @@ -404,7 +404,7 @@ void smGLRenderer::draw(smAABB &aabb, smColor p_color) glPopAttrib(); } -void smGLRenderer::drawArrow(const smVec3f &start, const smVec3f &end, const float D) +void smGLRenderer::drawArrow(const core::Vec3f &start, const core::Vec3f &end, const float D) { float x = end[0] - start[0]; float y = end[1] - start[1]; @@ -465,17 +465,17 @@ void smGLRenderer::drawAxes(const float length) Eigen::Vector3f origin(0, 0, 0); - glColor3fv(smColor::colorRed.toGLColor()); + glColor3fv(Color::colorRed.toGLColor()); glPushMatrix(); drawArrow(origin, Eigen::Vector3f(length, 0, 0), headWidth); glPopMatrix(); - glColor3fv(smColor::colorGreen.toGLColor()); + glColor3fv(Color::colorGreen.toGLColor()); glPushMatrix(); drawArrow(origin, Eigen::Vector3f(0, length, 0), headWidth); glPopMatrix(); - glColor3fv(smColor::colorBlue.toGLColor()); + glColor3fv(Color::colorBlue.toGLColor()); glPushMatrix(); drawArrow(origin, Eigen::Vector3f(0, 0, length), headWidth); glPopMatrix(); @@ -483,27 +483,27 @@ void smGLRenderer::drawAxes(const float length) glEnable(GL_LIGHTING); } -void smGLRenderer::drawAxes(const smMatrix33f &rotMat, const smVec3f &pos, const float length) +void smGLRenderer::drawAxes(const Matrix33f &rotMat, const core::Vec3f &pos, const float length) { glDisable(GL_LIGHTING); GLfloat headWidth = length / 12; - glColor3fv(smColor::colorRed.toGLColor()); + glColor3fv(Color::colorRed.toGLColor()); glPushMatrix(); Eigen::Vector3f xVec(length, 0, 0); xVec = rotMat*xVec + pos; drawArrow(pos, xVec, headWidth); glPopMatrix(); - glColor3fv(smColor::colorGreen.toGLColor()); + glColor3fv(Color::colorGreen.toGLColor()); glPushMatrix(); Eigen::Vector3f yVec(0, length, 0); yVec = rotMat*yVec + pos; drawArrow(pos, yVec, headWidth); glPopMatrix(); - glColor3fv(smColor::colorBlue.toGLColor()); + glColor3fv(Color::colorBlue.toGLColor()); glPushMatrix(); Eigen::Vector3f zVec(0, 0, length); zVec = rotMat*zVec + pos; @@ -513,26 +513,26 @@ void smGLRenderer::drawAxes(const smMatrix33f &rotMat, const smVec3f &pos, const glEnable(GL_LIGHTING); } -void smGLRenderer::draw(smPlane &p_plane, float p_scale, smColor p_color) +void smGLRenderer::draw(Plane &p_plane, float p_scale, Color p_color) { double angle; - smVec3d axisOfRot; - smVec3d defaultDir(0, 0, 1); - smVec3d planePoints[4] = {smVec3d(-p_scale, p_scale, 0), - smVec3d(-p_scale, -p_scale, 0), - smVec3d(p_scale, -p_scale, 0), - smVec3d(p_scale, p_scale, 0) + core::Vec3d axisOfRot; + core::Vec3d defaultDir(0, 0, 1); + core::Vec3d planePoints[4] = {core::Vec3d(-p_scale, p_scale, 0), + core::Vec3d(-p_scale, -p_scale, 0), + core::Vec3d(p_scale, -p_scale, 0), + core::Vec3d(p_scale, p_scale, 0) }; - smVec3d tmp; + core::Vec3d tmp; - smVec3d normal = p_plane.getUnitNormal(); - smVec3d point = p_plane.getPoint(); + core::Vec3d normal = p_plane.getUnitNormal(); + core::Vec3d point = p_plane.getPoint(); angle = std::acos(defaultDir.dot(normal)); axisOfRot = normal.cross(defaultDir); axisOfRot.normalized(); - smQuaterniond rot = getRotationQuaternion(-angle,axisOfRot); + Quaterniond rot = getRotationQuaternion(-angle,axisOfRot); glDisable(GL_LIGHTING); glBegin(GL_QUADS); @@ -549,21 +549,21 @@ void smGLRenderer::draw(smPlane &p_plane, float p_scale, smColor p_color) glEnable(GL_LIGHTING); } -void smGLRenderer::renderScene(std::shared_ptr<smScene> p_scene) +void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene) { assert(p_scene); - smMatrix44f proj = p_scene->getCamera()->getProjMat(); - smMatrix44f view = p_scene->getCamera()->getViewMat(); + Matrix44f proj = p_scene->getCamera()->getProjMat(); + Matrix44f view = p_scene->getCamera()->getViewMat(); renderScene(p_scene, proj, view); } -void smGLRenderer::renderScene(std::shared_ptr<smScene> p_scene, - const smMatrix44f &p_proj, - const smMatrix44f &p_view) +void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene, + const Matrix44f &p_proj, + const Matrix44f &p_view) { - smSceneLocal sceneLocal; + SceneLocal sceneLocal; assert(p_scene); @@ -595,16 +595,16 @@ void smGLRenderer::renderScene(std::shared_ptr<smScene> p_scene, glPopMatrix(); } -void smGLRenderer::renderSceneObject(std::shared_ptr<smSceneObject> p_sceneObject) +void smGLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) { - smRenderDetail::Ptr detail = p_sceneObject->getRenderDetail(); + RenderDetail::Ptr detail = p_sceneObject->getRenderDetail(); if (!detail || detail->getRenderType() & SIMMEDTK_RENDER_NONE) { return; } //if the custom rendering enable only render this - smRenderDelegate::Ptr delegate = p_sceneObject->getRenderDelegate(); + RenderDelegate::Ptr delegate = p_sceneObject->getRenderDelegate(); std::shared_ptr<smCustomRenderer> renderer = p_sceneObject->getRenderer(); if (detail->getRenderType() & SIMMEDTK_RENDER_CUSTOMRENDERONLY) { diff --git a/src/Rendering/SceneTextureShader.cpp b/src/Rendering/SceneTextureShader.cpp index a272a4f596dc6bff69097c2ab267a97b51d18388..6e2e916bd168a1d063be78523e149f197e459587 100644 --- a/src/Rendering/SceneTextureShader.cpp +++ b/src/Rendering/SceneTextureShader.cpp @@ -26,9 +26,9 @@ #include "Core/SDK.h" smSceneTextureShader::smSceneTextureShader(const std::string &p_verteShaderFileName, const std::string &p_fragmentFileName) -: smShader(smSDK::getInstance()->getErrorLog()) +: smShader(SDK::getInstance()->getErrorLog()) { - this->log = smSDK::getInstance()->getErrorLog(); + this->log = SDK::getInstance()->getErrorLog(); this->log->isOutputtoConsoleEnabled = false; this->checkErrorEnabled = true; setShaderFileName(p_verteShaderFileName, "", p_fragmentFileName); @@ -45,7 +45,7 @@ void smSceneTextureShader::predraw(std::shared_ptr<smMesh>/*p_mesh*/) } -void smSceneTextureShader::handleEvent(std::shared_ptr<mstk::Event::smEvent> /*p_event*/) +void smSceneTextureShader::handleEvent(std::shared_ptr<mstk::Event::Event> /*p_event*/) { } diff --git a/src/Rendering/SceneTextureShader.h b/src/Rendering/SceneTextureShader.h index 353781bc5a50aa1a34f051342e6a149d32f9786c..2d3827aba57b828d580a3173b7bcb275e7611b5a 100644 --- a/src/Rendering/SceneTextureShader.h +++ b/src/Rendering/SceneTextureShader.h @@ -30,7 +30,7 @@ namespace mstk{ namespace Event{ - class smEvent; + class Event; } } @@ -54,7 +54,7 @@ public: virtual void predraw(std::shared_ptr<smSurfaceMesh>) override{}; /// \brief handle the events - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; public: /// \brief depth texture GL id that is sent to shader. It stores scene depth values diff --git a/src/Rendering/Shader.cpp b/src/Rendering/Shader.cpp index 981c4f844434ea994af70a9d6fe5d2a5e9c9945d..2cb5b3d93753e0be1d8fd5407a34a92806fd2a6a 100644 --- a/src/Rendering/Shader.cpp +++ b/src/Rendering/Shader.cpp @@ -51,7 +51,7 @@ void printInfoLog(GLhandleARB obj) } } -smShader::smShader(std::shared_ptr<smErrorLog> logger) +smShader::smShader(std::shared_ptr<ErrorLog> logger) { type = core::ClassType::Shader; log = logger; @@ -628,7 +628,7 @@ void smShader::enableCheckingErrors(bool p_checkError) this->checkErrorEnabled = p_checkError; } -void smShader::attachTexture(std::shared_ptr<smUnifiedId> p_meshID, int p_textureID) +void smShader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, int p_textureID) { smTextureShaderAssignment assign; @@ -636,7 +636,7 @@ void smShader::attachTexture(std::shared_ptr<smUnifiedId> p_meshID, int p_textur texAssignments.insert( {p_meshID->getId(), assign} ); } -bool smShader::attachTexture(std::shared_ptr<smUnifiedId> p_meshID, +bool smShader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, const std::string& p_textureName, const std::string& p_textureShaderName) { @@ -796,7 +796,7 @@ void smShader::initGLShaders() x.second->initDraw(); } -void smShader::activeGLTextures(std::shared_ptr<smUnifiedId> p_id) +void smShader::activeGLTextures(std::shared_ptr<UnifiedId> p_id) { int counter = 0; auto range = texAssignments.equal_range(p_id->getId()); @@ -809,7 +809,7 @@ void smShader::activeGLTextures(std::shared_ptr<smUnifiedId> p_id) } } -void smShader::activeGLVertAttribs(int p_id, smVec3d *p_vecs, int /*p_size*/) +void smShader::activeGLVertAttribs(int p_id, core::Vec3d *p_vecs, int /*p_size*/) { glVertexAttribPointer(attribShaderParams[p_id], 3, GL_FLOAT, GL_FALSE, 0, p_vecs); } @@ -855,7 +855,7 @@ bool smShader::setProjectionMatrixShaderName(const std::string& p_projectionName } void smShader::updateGLSLMatwithOPENGL() { - smMatrix44f proj, model; + Matrix44f proj, model; smGLUtils::queryModelViewMatrix( model ); smGLUtils::queryProjectionMatrix( proj ); @@ -867,7 +867,7 @@ GLint smShader::queryUniformLocation(const std::string& p_param) { return glGetUniformLocation(shaderProgramObject, p_param.data()); } -std::shared_ptr<smShader> smShader::getShader( std::shared_ptr<smUnifiedId> p_shaderID ) +std::shared_ptr<smShader> smShader::getShader( std::shared_ptr<UnifiedId> p_shaderID ) { return shaders[p_shaderID->getId()]; } diff --git a/src/Rendering/Shader.h b/src/Rendering/Shader.h index ab932400baea941ddc2f83ac098fa35de08ca136..d923d3aaf89949217b874ba49c5b349b5db69f90 100644 --- a/src/Rendering/Shader.h +++ b/src/Rendering/Shader.h @@ -51,7 +51,7 @@ struct smTextureShaderAssignment // \brief Base shader class. It provides loading, initializing, binding, // enabling disabling current shader functionality.Also it provides // frequent check of the shader code to make shader development easy. -class smShader: public smCoreClass +class smShader: public CoreClass { public: #ifdef SIMMEDTK_OPENGL_SHADER @@ -117,10 +117,10 @@ public: } // \brief Attaches The texture ID to the mesh - void attachTexture(std::shared_ptr<smUnifiedId> p_meshID, int p_textureID); + void attachTexture(std::shared_ptr<UnifiedId> p_meshID, int p_textureID); // \brief assigns the texture by name if you don't know the textureID - bool attachTexture(std::shared_ptr<smUnifiedId> p_meshID, const std::string& p_textureName, const std::string& p_textureShaderName); + bool attachTexture(std::shared_ptr<UnifiedId> p_meshID, const std::string& p_textureName, const std::string& p_textureShaderName); void autoGetTextureIds(); @@ -160,7 +160,7 @@ protected: public: // \brief constructor gets the error log class - smShader(std::shared_ptr<smErrorLog> logger); + smShader(std::shared_ptr<ErrorLog> logger); // \brief initialized the shaders. // \param vertexProgFileName vertex program file name @@ -242,15 +242,15 @@ public: virtual void posdraw(std::shared_ptr<smSurfaceMesh>/*mesh*/){}; - static std::shared_ptr<smShader> getShader(std::shared_ptr<smUnifiedId> p_shaderID); + static std::shared_ptr<smShader> getShader(std::shared_ptr<UnifiedId> p_shaderID); bool readShaderContent(const std::string& p_file, std::string& p_content); static void initGLShaders(); - void activeGLTextures(std::shared_ptr<smUnifiedId> p_id); + void activeGLTextures(std::shared_ptr<UnifiedId> p_id); - void activeGLVertAttribs(int p_id, smVec3d *p_vecs, int p_size); + void activeGLVertAttribs(int p_id, core::Vec3d *p_vecs, int p_size); void registerShader(); @@ -268,7 +268,7 @@ public: } protected: - std::shared_ptr<smErrorLog> log; // + std::shared_ptr<ErrorLog> log; // bool checkErrorEnabled; // if the error check is enabled or not. If it is checked, opengl errors are queried and if there is, they will be stored in logger GLint tangentAttrib; @@ -280,7 +280,7 @@ private: std::vector<std::string> fragmentShaderParamsString; // stores the parameters for fragment shader std::vector<std::string> geometryShaderParamsString; // stores the parameters for geometry shader std::vector<std::string> attribParamsString; // stores the attribute parameters - smTimer time; // time for periodically checnking the shader + Timer time; // time for periodically checnking the shader GLint projectionMatrix; // holds the unitform location for projection matrix. That is needed in newer versions of GLSL GLint modelViewMatrix; // holds the unitform location for modelview matrix. That is needed in newer versions of GLSL diff --git a/src/Rendering/TextureManager.cpp b/src/Rendering/TextureManager.cpp index ead14adca58c0e4c7019a9bc8c3d622c95eaa402..e37d95d03197eaf944a37fc08a8a36346516cacd 100644 --- a/src/Rendering/TextureManager.cpp +++ b/src/Rendering/TextureManager.cpp @@ -26,8 +26,8 @@ #include <cassert> -std::shared_ptr<smErrorLog> smTextureManager:: errorLog; -std::vector<smTexture*> smTextureManager:: textures; +std::shared_ptr<ErrorLog> smTextureManager:: errorLog; +std::vector<Texture*> smTextureManager:: textures; std::unordered_map<std::string, int> smTextureManager::textureIndexId; int smTextureManager:: activeTextures; bool smTextureManager::isInitialized = false; @@ -38,7 +38,7 @@ bool smTextureManager::isDeleteImagesEnabled = false; smTextureReturnType smTextureManager::initGLTextures() { std::string texManagerError; - smTexture *texture; + Texture *texture; for (size_t i = 0; i < textures.size(); i++) { @@ -108,7 +108,7 @@ smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, /// \brief smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, const std::string& p_textureReferenceName, bool p_flipImage) { - smTexture *texture = nullptr; + Texture *texture = nullptr; sf::Vector2u imageSize; assert(p_fileName != ""); @@ -119,7 +119,7 @@ smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, return SIMMEDTK_TEXTURE_DRIVERNOTINITIALIZED; } - texture = new smTexture(); + texture = new Texture(); assert(texture); if (false == texture->image.loadFromFile(p_fileName)) { @@ -166,7 +166,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; @@ -175,8 +175,8 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa return texture->textureGLId; } -/// \brief activate the texture given the smTexture argument -GLuint smTextureManager::activateTexture(smTexture *p_texture) +/// \brief activate the texture given the Texture argument +GLuint smTextureManager::activateTexture(Texture *p_texture) { glBindTexture(GL_TEXTURE_2D, p_texture->textureGLId); @@ -190,7 +190,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; glActiveTexture(GL_TEXTURE0 + p_textureGLOrder); @@ -208,7 +208,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; glActiveTexture(GL_TEXTURE0 + p_textureGLOrder); @@ -218,10 +218,10 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa return texture->textureGLId; } -/// \brief This function binds the smTexture to the appropriate shader texture. +/// \brief This function binds the Texture to the appropriate shader texture. /// For instance if the argument is 0, the it will bind to GL_TEXTURE0 /// Also for the shader the binded name will be p_shaderBindName -GLuint smTextureManager::activateTexture(smTexture *p_texture, +GLuint smTextureManager::activateTexture(Texture *p_texture, int p_textureGLOrder, int p_shaderBindGLId) { @@ -236,7 +236,7 @@ GLuint smTextureManager::activateTexture(smTexture *p_texture, GLuint smTextureManager::activateTexture(int p_textureId) { - smTexture *texture; + Texture *texture; texture = textures[p_textureId]; glBindTexture(GL_TEXTURE_2D, texture->textureGLId); glEnable(GL_TEXTURE_2D); @@ -248,7 +248,7 @@ GLuint smTextureManager::activateTexture(int p_textureId) GLuint smTextureManager::activateTexture(int p_textureId, int p_textureGLOrder) { - smTexture *texture; + Texture *texture; texture = textures[p_textureId]; glActiveTexture(GL_TEXTURE0 + p_textureGLOrder); glBindTexture(GL_TEXTURE_2D, texture->textureGLId); @@ -270,7 +270,7 @@ GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceNam { GLuint textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; glBindTexture(GL_TEXTURE_2D, texture->textureGLId); @@ -283,7 +283,7 @@ GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceNam { GLuint textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; @@ -297,7 +297,7 @@ GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceNam GLuint smTextureManager::disableTexture(int p_textureId) { - smTexture *texture; + Texture *texture; texture = textures[p_textureId]; glBindTexture(GL_TEXTURE_2D, texture->textureGLId); glDisable(GL_TEXTURE_2D); @@ -309,7 +309,7 @@ GLuint smTextureManager::getOpenglTextureId(const std::string& p_textureReferenc { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; return texture->textureGLId; @@ -320,7 +320,7 @@ GLuint smTextureManager::getOpenglTextureId(const std::string& p_textureReferenc GLuint smTextureManager::getOpenglTextureId(int p_textureId) { - smTexture *texture; + Texture *texture; texture = textures[p_textureId]; return texture->textureGLId; @@ -330,8 +330,8 @@ GLuint smTextureManager::getOpenglTextureId(int p_textureId) void smTextureManager::createDepthTexture(const std::string& p_textureReferenceName, int p_width, int p_height) { - smTexture *tex; - tex = new smTexture(); + Texture *tex; + tex = new Texture(); tex->height = p_height; tex->width = p_width; tex->GLtype = GL_TEXTURE_2D; @@ -343,11 +343,11 @@ void smTextureManager::createDepthTexture(const std::string& p_textureReferenceN } /// \brief -void smTextureManager::duplicateTexture(const std::string& p_textureReferenceName, smTexture *p_texture, ImageColorType p_type) +void smTextureManager::duplicateTexture(const std::string& p_textureReferenceName, Texture *p_texture, ImageColorType p_type) { - smTexture *tex; - tex = new smTexture(); + Texture *tex; + tex = new Texture(); tex->height = p_texture->height; tex->width = p_texture->width; tex->GLtype = GL_TEXTURE_2D; @@ -363,9 +363,9 @@ void smTextureManager::copyTexture(const std::string& /*p_textureDestinationName { // WARNING: This function does nothing // int textureDstId; -// smTexture *dstTex; +// Texture *dstTex; // int textureSrcId; -// smTexture *srcTex; +// Texture *srcTex; // // textureDstId = textureIndexId[p_textureDestinationName]; // dstTex = textures[textureDstId]; @@ -378,8 +378,8 @@ void smTextureManager::copyTexture(const std::string& /*p_textureDestinationName void smTextureManager::createColorTexture(const std::string& p_textureReferenceName, int p_width, int p_height) { - smTexture *tex; - tex = new smTexture(); + Texture *tex; + tex = new Texture(); tex->height = p_height; tex->width = p_width; tex->GLtype = GL_TEXTURE_2D; @@ -391,7 +391,7 @@ void smTextureManager::createColorTexture(const std::string& p_textureReferenceN } /// \brief -void smTextureManager::initDepthTexture(smTexture *p_texture) +void smTextureManager::initDepthTexture(Texture *p_texture) { glGenTextures(1, &p_texture->textureGLId); @@ -409,7 +409,7 @@ void smTextureManager::initDepthTexture(smTexture *p_texture) } /// \brief -void smTextureManager::initColorTexture(smTexture *p_texture) +void smTextureManager::initColorTexture(Texture *p_texture) { glGenTextures(1, &p_texture->textureGLId); @@ -424,11 +424,11 @@ void smTextureManager::initColorTexture(smTexture *p_texture) } /// \brief -smTexture *smTextureManager::getTexture(const std::string& p_textureReferenceName) +Texture *smTextureManager::getTexture(const std::string& p_textureReferenceName) { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; return texture = textures[textureId]; } @@ -437,7 +437,7 @@ smTexture *smTextureManager::getTexture(const std::string& p_textureReferenceNam void smTextureManager::generateMipMaps(int p_textureId) { - smTexture *texture; + Texture *texture; texture = textures[p_textureId]; glBindTexture(GL_TEXTURE_2D, texture->textureGLId); glGenerateMipmap(GL_TEXTURE_2D); @@ -448,7 +448,7 @@ void smTextureManager::generateMipMaps(const std::string& p_textureReferenceName { int textureId; - smTexture *texture; + Texture *texture; textureId = textureIndexId[p_textureReferenceName]; texture = textures[textureId]; glBindTexture(GL_TEXTURE_2D, texture->textureGLId); diff --git a/src/Rendering/TextureManager.h b/src/Rendering/TextureManager.h index f52dbb54481df77f5d71c5fdfa7fcfebc63e54b3..a24bde05de8068243f49abf64ba0a50b905f1974 100644 --- a/src/Rendering/TextureManager.h +++ b/src/Rendering/TextureManager.h @@ -38,11 +38,11 @@ #include "Core/ErrorLog.h" /// \brief texture manager. It loads any image format and initializes in the GL context -class smTextureManager: public smCoreClass +class smTextureManager: public CoreClass { - static std::shared_ptr<smErrorLog> errorLog; - static std::vector<smTexture*> textures; + static std::shared_ptr<ErrorLog> errorLog; + static std::vector<Texture*> textures; static std::unordered_map<std::string, int> textureIndexId; static int activeTextures; static bool isInitialized; @@ -53,7 +53,7 @@ public: /// \brief init function called by the renderer thread static smTextureReturnType initGLTextures(); /// \brief initialization function - static void init(std::shared_ptr<smErrorLog> p_errorLog = nullptr) + static void init(std::shared_ptr<ErrorLog> p_errorLog = nullptr) { if(!isInitialized) { @@ -77,14 +77,14 @@ public: static smTextureReturnType findTextureId(const std::string& p_textureReferenceName, int &p_textureId); /// \brief activate textures based on texture reference name, texture reference, texture id and GL order - static GLuint activateTexture(smTexture *p_texture); + static GLuint activateTexture(Texture *p_texture); static GLuint activateTexture(const std::string& p_textureReferenceName); static GLuint activateTexture(int p_textureId); static GLuint activateTexture(const std::string& p_textureReferenceName, int p_textureGLOrder); - static GLuint activateTexture(smTexture *p_texture, int p_textureGLOrder, + static GLuint activateTexture(Texture *p_texture, int p_textureGLOrder, int p_shaderBindGLId); static GLuint activateTexture(const std::string& p_textureReferenceName, @@ -104,7 +104,7 @@ public: static GLuint getOpenglTextureId(const std::string& p_textureReferenceName); static GLuint getOpenglTextureId(int p_textureId); /// \brief to get texture with given texture reference name - static smTexture * getTexture(const std::string& p_textureReferenceName); + static Texture * getTexture(const std::string& p_textureReferenceName); /// \brief to create a depth texture static void createDepthTexture(const std::string& p_textureReferenceName, int p_width, int p_height); @@ -113,14 +113,14 @@ public: static void createColorTexture(const std::string& p_textureReferenceName, int p_width, int p_height); /// \brief initialize depth texture and color texture - static void initDepthTexture(smTexture *p_texture); - static void initColorTexture(smTexture *p_texture); + static void initDepthTexture(Texture *p_texture); + static void initColorTexture(Texture *p_texture); /// \brief generate mip maps static void generateMipMaps(int p_textureId); static void generateMipMaps(const std::string& p_textureReferenceName); /// \brief to duplicate the texture static void duplicateTexture(const std::string& p_textureReferenceName, - smTexture *p_texture, ImageColorType p_type); + Texture *p_texture, ImageColorType p_type); /// \brief copy the texture specified with p_textureSourceName to the texture specified with p_textureDestinationName static void copyTexture(const std::string& p_textureDestinationName, diff --git a/src/Rendering/VAO.cpp b/src/Rendering/VAO.cpp index b9afce856141b10cb14b28dcdb390c738c27f5d3..2b2a5d4c69864cd7e5c954518ebc5087c5b8a336 100644 --- a/src/Rendering/VAO.cpp +++ b/src/Rendering/VAO.cpp @@ -182,7 +182,7 @@ smVBOBufferEntryInfo::smVBOBufferEntryInfo() nbrElements = 0; arrayBufferType = SMVBO_POS; } -smVAO::smVAO( std::shared_ptr<smErrorLog> p_log, smVBOType p_vboType, bool p_bindShaderObjects ) +smVAO::smVAO( std::shared_ptr<ErrorLog> p_log, smVBOType p_vboType, bool p_bindShaderObjects ) { this->log = p_log; renderingError = false; @@ -202,7 +202,7 @@ void smVAO::setBufferData( smVBOBufferType p_type, std::string p_ShaderAttribNam p_type == SMVBO_TANGENTS || p_type == SMVBO_VEC3F ) { - bufferInfo[totalNbrBuffers].size = sizeof( smVec3d ) * p_nbrElements; + bufferInfo[totalNbrBuffers].size = sizeof( core::Vec3d ) * p_nbrElements; } else if ( p_type == SMVBO_TEXTURECOORDS || p_type == SMVBO_VEC2F ) @@ -241,7 +241,7 @@ bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_s } bufferInfo[totalNbrBuffers].arrayBufferType = SMVBO_POS; - bufferInfo[totalNbrBuffers].size = sizeof( smVec3d ) * p_mesh->nbrVertices; + bufferInfo[totalNbrBuffers].size = sizeof( core::Vec3d ) * p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attribPointer = p_mesh->vertices.data(); bufferInfo[totalNbrBuffers].nbrElements = p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attributeIndex = totalNbrBuffers; @@ -249,7 +249,7 @@ bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_s totalNbrBuffers++; bufferInfo[totalNbrBuffers].arrayBufferType = SMVBO_NORMALS; - bufferInfo[totalNbrBuffers].size = sizeof( smVec3d ) * p_mesh->nbrVertices; + bufferInfo[totalNbrBuffers].size = sizeof( core::Vec3d ) * p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attribPointer = p_mesh->vertNormals; bufferInfo[totalNbrBuffers].nbrElements = p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attributeIndex = totalNbrBuffers; @@ -268,7 +268,7 @@ bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_s if ( p_mesh->tangentChannel ) { bufferInfo[totalNbrBuffers].arrayBufferType = SMVBO_TANGENTS; - bufferInfo[totalNbrBuffers].size = sizeof( smVec3d ) * p_mesh->nbrVertices; + bufferInfo[totalNbrBuffers].size = sizeof( core::Vec3d ) * p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attribPointer = p_mesh->vertTangents; bufferInfo[totalNbrBuffers].nbrElements = p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attributeIndex = totalNbrBuffers; @@ -293,7 +293,7 @@ void smVAO::initVAOs() x.second->initBuffers(); } } -std::shared_ptr<smVAO> smVAO::getVAO( std::shared_ptr<smUnifiedId> p_shaderID ) +std::shared_ptr<smVAO> smVAO::getVAO( std::shared_ptr<UnifiedId> p_shaderID ) { return VAOs[p_shaderID->getId()]; } diff --git a/src/Rendering/VAO.h b/src/Rendering/VAO.h index 47bb79c2b3637c36571c219708fd06fe0fdaa7d3..2e0e2e4334538b266e388ec9b2278ffb36ff3d11 100644 --- a/src/Rendering/VAO.h +++ b/src/Rendering/VAO.h @@ -71,11 +71,11 @@ public: }; /// \brief Vertex Array Object for fast rendering -class smVAO: public smCoreClass +class smVAO: public CoreClass { public: /// \brief need error log and totalBuffer Size - smVAO(std::shared_ptr<smErrorLog> p_log, smVBOType p_vboType = SIMMEDTK_VBO_DYNAMIC, bool p_bindShaderObjects = true); + smVAO(std::shared_ptr<ErrorLog> p_log, smVBOType p_vboType = SIMMEDTK_VBO_DYNAMIC, bool p_bindShaderObjects = true); /// \brief set internal buffer manually. type, attrib name, number of elements and pointer to the data void setBufferData(smVBOBufferType p_type, std::string p_ShaderAttribName, int p_nbrElements, void *p_ptr); @@ -99,7 +99,7 @@ public: void initBuffers(); /// \brief get VAO given the shader ID - static std::shared_ptr<smVAO> getVAO(std::shared_ptr<smUnifiedId> p_shaderID); + static std::shared_ptr<smVAO> getVAO(std::shared_ptr<UnifiedId> p_shaderID); /// \brief enable the vertex array object void enable() const; @@ -125,7 +125,7 @@ public: smMesh *mesh; private: - std::shared_ptr<smErrorLog> log; + std::shared_ptr<ErrorLog> log; std::shared_ptr<smShader> shader; bool renderingError; ///Used for attaching attribs to the vertex objects diff --git a/src/Rendering/VBO.cpp b/src/Rendering/VBO.cpp index 53a6ff4ffcc38ecf1fe891506c0b24bc543b5a0f..02b1c7aac8a28bd46225de5de498b599ffaa59e8 100644 --- a/src/Rendering/VBO.cpp +++ b/src/Rendering/VBO.cpp @@ -23,7 +23,7 @@ #include "VBO.h" -smVBO::smVBO( smErrorLog *p_log ) +smVBO::smVBO( ErrorLog *p_log ) { this->log = p_log; renderingError = false; @@ -37,9 +37,9 @@ smVBO::~smVBO() /// WARNING: This function takes arrays to Eigen 3d vectors, /// it is not clear to me that the memory is aligned. -smVBOResult smVBO::updateVertices(const smVectorf &p_vectors, - const smVectorf &p_normals, - const smVectorf &p_textureCoords, +smVBOResult smVBO::updateVertices(const core::Vectorf &p_vectors, + const core::Vectorf &p_normals, + const core::Vectorf &p_textureCoords, size_t p_objectId) { if (vboType == SIMMEDTK_VBO_STATIC) @@ -82,7 +82,7 @@ smVBOResult smVBO::updateVertices(const smVectorf &p_vectors, return SIMMEDTK_VBO_OK; } -smVBOResult smVBO::updateTriangleIndices(const smVector<size_t> &p_indices, size_t p_objectId) +smVBOResult smVBO::updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) { if ((vboType == SIMMEDTK_VBO_STATIC) | (vboType == SIMMEDTK_VBO_DYNAMIC)) { @@ -125,7 +125,7 @@ smVBOResult smVBO::drawElements(size_t p_objectId) indexOffset = indexOffsetMap[p_objectId]; glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboDataId); glVertexPointer(3, GL_FLOAT, 0, reinterpret_cast<void*>(dataOffset)); - glNormalPointer(GL_FLOAT, 0, reinterpret_cast<void*>(dataOffset + nbrVertices * sizeof(smVec3d))); + glNormalPointer(GL_FLOAT, 0, reinterpret_cast<void*>(dataOffset + nbrVertices * sizeof(core::Vec3d))); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboIndexId); glIndexPointer(GL_UNSIGNED_INT, 0, reinterpret_cast<void*>(indexOffset)); @@ -152,9 +152,9 @@ smVBOResult smVBO::drawElements(size_t p_objectId) ///Static Binding of the buffers. It is mandatory to call this function /// this function must be called when the binding is SIMMEDTK_VBO_STATIC -smVBOResult smVBO::initStaticVertices(const smVectorf &p_vectors, - const smVectorf &p_normals, - const smVectorf &p_textureCoords, +smVBOResult smVBO::initStaticVertices(const core::Vectorf &p_vectors, + const core::Vectorf &p_normals, + const core::Vectorf &p_textureCoords, size_t p_objectId) { if (vboType == SIMMEDTK_VBO_DYNAMIC) @@ -186,7 +186,7 @@ smVBOResult smVBO::initStaticVertices(const smVectorf &p_vectors, ///init Triangle Indices for the very first time for static objects ///this function must be called when the indices are not changing ///SIMMEDTK_VBO_NOINDICESCHANGE -smVBOResult smVBO::initTriangleIndices(const smVector<size_t> &p_indices, size_t p_objectId) +smVBOResult smVBO::initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) { size_t indexOffset; @@ -247,7 +247,7 @@ void smVBO::init( smVBOType p_vboType ) smVBOResult smVBO::addVerticestoBuffer( const size_t p_nbrVertices, const size_t p_nbrTriangles, const size_t p_objectId ) { - if ( sizeof( smVec3d )*p_nbrVertices + sizeof( smVec3d )*p_nbrVertices + sizeof( smTexCoord )*p_nbrVertices > sizeOfDataBuffer - currentDataOffset ) + if ( sizeof( core::Vec3d )*p_nbrVertices + sizeof( core::Vec3d )*p_nbrVertices + sizeof( smTexCoord )*p_nbrVertices > sizeOfDataBuffer - currentDataOffset ) { return SIMMEDTK_VBO_NODATAMEMORY; } @@ -262,7 +262,7 @@ smVBOResult smVBO::addVerticestoBuffer( const size_t p_nbrVertices, const size_t numberofVertices[p_objectId] = p_nbrVertices; numberofTriangles[p_objectId] = p_nbrTriangles; ///add the vertices and normals and the texture coordinates - currentDataOffset += sizeof( smVec3d ) * p_nbrVertices + sizeof( smVec3d ) * p_nbrVertices + sizeof( smTexCoord ) * p_nbrVertices; + currentDataOffset += sizeof( core::Vec3d ) * p_nbrVertices + sizeof( core::Vec3d ) * p_nbrVertices + sizeof( smTexCoord ) * p_nbrVertices; currentIndexOffset += p_nbrTriangles * sizeof( smTriangle ); return SIMMEDTK_VBO_OK; } diff --git a/src/Rendering/VBO.h b/src/Rendering/VBO.h index 301f138447e23802ccc0087ba7c52cb19d1e2736..3e95a26076ee1ff8c98081350bf54e2914905937 100644 --- a/src/Rendering/VBO.h +++ b/src/Rendering/VBO.h @@ -38,7 +38,7 @@ #include "Core/Vector.h" /// \brief VBO for rendering -class smVBO: public smCoreClass +class smVBO: public CoreClass { private: /// \brief offsets for each mesh @@ -61,13 +61,13 @@ private: /// \brief number of triangles std::unordered_map<size_t, size_t> numberofTriangles; /// \brief error log - smErrorLog *log; + ErrorLog *log; /// \brief rendering error bool renderingError; public: /// \brief constructor. gets error log or NULL - smVBO(smErrorLog *p_log); + smVBO(ErrorLog *p_log); /// \brief init with given VBO type void init(smVBOType p_vboType); @@ -78,25 +78,25 @@ public: const size_t p_objectId); /// \brief update vertex data buffer - smVBOResult updateVertices(const smVectorf &p_vectors, - const smVectorf &p_normals, - const smVectorf &p_textureCoords, + smVBOResult updateVertices(const core::Vectorf &p_vectors, + const core::Vectorf &p_normals, + const core::Vectorf &p_textureCoords, size_t p_objectId); /// \brief update triangle index - smVBOResult updateTriangleIndices(const smVector<size_t> &p_indices, size_t p_objectId); + smVBOResult updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); /// \brief draw elements in VBO smVBOResult drawElements(size_t p_objectId); /// \brief update the static vertices initially - smVBOResult initStaticVertices(const smVectorf &p_vectors, - const smVectorf &p_normals, - const smVectorf &p_textureCoords, + smVBOResult initStaticVertices(const core::Vectorf &p_vectors, + const core::Vectorf &p_normals, + const core::Vectorf &p_textureCoords, size_t p_objectId); /// \brief update the static triangle indices initially - smVBOResult initTriangleIndices(const smVector<size_t> &p_indices, size_t p_objectId); + smVBOResult initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); /// \brief deletion of the VBO buffers ~smVBO(); diff --git a/src/Rendering/Viewer.cpp b/src/Rendering/Viewer.cpp index c219bd05ae09806f613b50070d352cdab705fd68..448add6bf1c24e0cb1fed310a7e673029383628e 100644 --- a/src/Rendering/Viewer.cpp +++ b/src/Rendering/Viewer.cpp @@ -185,11 +185,11 @@ void smViewer::renderTextureOnView() /// \param p_width The width of the fbo /// \param p_height The height of the fbo void smViewer::addFBO(const std::string &p_fboName, - smTexture *p_colorTex, - smTexture *p_depthTex, + Texture *p_colorTex, + Texture *p_depthTex, unsigned int p_width, unsigned int p_height) { - smFboListItem item; + FboListItem item; item.fboName = p_fboName; item.width = p_width; @@ -211,7 +211,7 @@ void smViewer::initFboListItems() { for (size_t i = 0; i < this->fboListItems.size(); i++) { - smFboListItem *item = &fboListItems[i]; + FboListItem *item = &fboListItems[i]; item->fbo = new smFrameBuffer(); item->fbo->setDim(item->width, item->height); if (item->colorTex) @@ -265,7 +265,7 @@ void smViewer::processWindowEvents() } /// \brief Renders the render operation to an FBO -void smViewer::renderToFBO(const smRenderOperation &p_rop) +void smViewer::renderToFBO(const RenderOperation &p_rop) { assert(p_rop.fbo); //Enable FBO for rendering @@ -282,7 +282,7 @@ void smViewer::renderToFBO(const smRenderOperation &p_rop) } /// \brief Renders the render operation to screen -void smViewer::renderToScreen(const smRenderOperation &p_rop) +void smViewer::renderToScreen(const RenderOperation &p_rop) { //Setup Viewport & Clear buffers glViewport(0, 0, this->width(), this->height()); @@ -295,8 +295,8 @@ void smViewer::renderToScreen(const smRenderOperation &p_rop) //Render axis if (viewerRenderDetail & SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS) { - smMatrix44f proj = p_rop.scene->getCamera()->getProjMat(); - smMatrix44f view = p_rop.scene->getCamera()->getViewMat(); + Matrix44f proj = p_rop.scene->getCamera()->getProjMat(); + Matrix44f view = p_rop.scene->getCamera()->getViewMat(); glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -322,11 +322,11 @@ void smViewer::renderToScreen(const smRenderOperation &p_rop) } /// \brief Registers a scene for rendering with the viewer -void smViewer::registerScene(std::shared_ptr<smScene> p_scene, +void smViewer::registerScene(std::shared_ptr<Scene> p_scene, smRenderTargetType p_target, const std::string &p_fboName) { - smRenderOperation rop; + RenderOperation rop; //sanity checks assert(p_scene); @@ -411,7 +411,7 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) auto mouseEvent = std::make_shared<mstk::Event::smMouseButtonEvent>(mouseButton); mouseEvent->setPresed(sf::Event::MouseButtonPressed == p_event.type); - mouseEvent->setWindowCoord(smVec2d(p_event.mouseButton.x,p_event.mouseButton.y)); + mouseEvent->setWindowCoord(core::Vec2d(p_event.mouseButton.x,p_event.mouseButton.y)); eventHandler->triggerEvent(mouseEvent); break; } @@ -419,7 +419,7 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) { auto mouseEvent = std::make_shared<mstk::Event::smMouseMoveEvent>(); mouseEvent->setSender(mstk::Event::EventSender::Module); - mouseEvent->setWindowCoord(smVec2d(p_event.mouseMove.x, p_event.mouseMove.y)); + mouseEvent->setWindowCoord(core::Vec2d(p_event.mouseMove.x, p_event.mouseMove.y)); eventHandler->triggerEvent(mouseEvent); break; } @@ -428,14 +428,14 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) } } -void smViewer::addObject(std::shared_ptr<smCoreClass> object) +void smViewer::addObject(std::shared_ptr<CoreClass> object) { - smSDK::getInstance()->addRef(object); + SDK::getInstance()->addRef(object); objectList.push_back(object); } -void smViewer::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event ) +void smViewer::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) { } @@ -473,6 +473,6 @@ void smViewer::cleanUp() SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_rendering_viewer) - SIMMEDTK_REGISTER_CLASS(smCoreClass,smViewerBase,smViewer,100); + SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,smViewer,100); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/Rendering/Viewer.h b/src/Rendering/Viewer.h index 85cdddb3e46d0fd258f72623152b72350c150527..ce6f658546a18610197b69495d67d9e1e6c4c259 100644 --- a/src/Rendering/Viewer.h +++ b/src/Rendering/Viewer.h @@ -42,7 +42,7 @@ class smOpenGLWindowStream; /// \brief Handles all rendering routines. -class smViewer : public smViewerBase +class smViewer : public ViewerBase { public: std::unique_ptr<sf::Context> sfmlContext; @@ -55,7 +55,7 @@ public: /// \brief for exit viewer virtual void exitViewer() override; /// \brief add object for rendering - void addObject(std::shared_ptr<smCoreClass> object); + void addObject(std::shared_ptr<CoreClass> object); /// \brief add text for display virtual void addText(std::string p_tag) override; /// \brief update text @@ -67,15 +67,15 @@ public: void setWindowTitle(const std::string &str); /// \brief enable/disable VSync virtual void setVSync(bool sync) override; - virtual void registerScene(std::shared_ptr<smScene> p_scene, smRenderTargetType p_target, const std::string &p_fboName); + virtual void registerScene(std::shared_ptr<Scene> p_scene, smRenderTargetType p_target, const std::string &p_fboName); virtual void addFBO(const std::string &p_fboName, - smTexture *p_colorTex, smTexture *p_depthTex, + Texture *p_colorTex, Texture *p_depthTex, unsigned int p_width, unsigned int p_height); std::string windowTitle; - smColor defaultDiffuseColor; - smColor defaultAmbientColor; - smColor defaultSpecularColor; + Color defaultDiffuseColor; + Color defaultAmbientColor; + Color defaultSpecularColor; protected: virtual void initRenderingCapabilities() override; @@ -89,8 +89,8 @@ protected: virtual void processViewerOptions() override; virtual void processWindowEvents() override; - virtual void renderToScreen(const smRenderOperation &p_rop) override; - virtual void renderToFBO(const smRenderOperation &p_rop) override; + virtual void renderToScreen(const RenderOperation &p_rop) override; + virtual void renderToFBO(const RenderOperation &p_rop) override; virtual void initFboListItems(); virtual void destroyFboListItems(); virtual void setToDefaults() override; @@ -98,7 +98,7 @@ protected: virtual void endFrame() override; virtual void renderTextureOnView() override; /// \brief event handler - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief processes an SFML event void processSFMLEvents(const sf::Event& p_event); }; diff --git a/src/Simulators/DummySimulator.cpp b/src/Simulators/DummySimulator.cpp index d6a32f98b085d1d831ca253bd257ab6409d5bbf1..b58accf41c5a71285c043ffb68a54538ee47f33c 100644 --- a/src/Simulators/DummySimulator.cpp +++ b/src/Simulators/DummySimulator.cpp @@ -28,7 +28,7 @@ #include "Event/KeyboardEvent.h" #include "Collision/MeshCollisionModel.h" -smDummySimulator::smDummySimulator( std::shared_ptr<smErrorLog> p_errorLog ) : smObjectSimulator( p_errorLog ) +smDummySimulator::smDummySimulator( std::shared_ptr<ErrorLog> p_errorLog ) : ObjectSimulator( p_errorLog ) { } void smDummySimulator::beginSim() @@ -46,8 +46,8 @@ void smDummySimulator::initCustom() { case core::ClassType::StaticSceneObject: { - auto staticObject = std::static_pointer_cast<smStaticSceneObject>(object); - auto model = std::static_pointer_cast<smMeshCollisionModel>(staticObject->getModel()); + auto staticObject = std::static_pointer_cast<StaticSceneObject>(object); + auto model = std::static_pointer_cast<MeshCollisionModel>(staticObject->getModel()); if(nullptr == model) { break; @@ -77,8 +77,8 @@ void smDummySimulator::run() //ensure that dummy simulator will work on static scene objects only. if ( sceneObj->getType() == core::ClassType::StaticSceneObject ) { - auto staticSceneObject = std::static_pointer_cast<smStaticSceneObject>(sceneObj); - auto model = std::static_pointer_cast<smMeshCollisionModel>(staticSceneObject->getModel()); + auto staticSceneObject = std::static_pointer_cast<StaticSceneObject>(sceneObj); + auto model = std::static_pointer_cast<MeshCollisionModel>(staticSceneObject->getModel()); if(nullptr == model) { break; @@ -107,8 +107,8 @@ void smDummySimulator::syncBuffers() //ensure that dummy simulator will work on static scene objects only. if ( sceneObj->getType() == core::ClassType::StaticSceneObject ) { - auto staticSceneObject = std::static_pointer_cast<smStaticSceneObject>(sceneObj); - auto model = std::static_pointer_cast<smMeshCollisionModel>(staticSceneObject->getModel()); + auto staticSceneObject = std::static_pointer_cast<StaticSceneObject>(sceneObj); + auto model = std::static_pointer_cast<MeshCollisionModel>(staticSceneObject->getModel()); if(nullptr == model) { break; @@ -119,7 +119,7 @@ void smDummySimulator::syncBuffers() } } } -void smDummySimulator::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event ) +void smDummySimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) { if(!this->isListening()) { diff --git a/src/Simulators/DummySimulator.h b/src/Simulators/DummySimulator.h index cdb58762fa4e0df7703430fd7b4eed5a1618bb78..33af10a336494204ec96b9eb3f43587760a16ee9 100644 --- a/src/Simulators/DummySimulator.h +++ b/src/Simulators/DummySimulator.h @@ -30,12 +30,12 @@ #include "Core/ErrorLog.h" /// \brief Example simulator. This dummy simulator works on static scene objects for now. -class smDummySimulator: public smObjectSimulator +class smDummySimulator: public ObjectSimulator { public: /// \brief constructor - smDummySimulator(std::shared_ptr<smErrorLog> p_errorLog); + smDummySimulator(std::shared_ptr<ErrorLog> p_errorLog); virtual ~smDummySimulator(){} protected: @@ -54,7 +54,7 @@ protected: void syncBuffers() override; /// \brief catch events such as key presses and other user inputs - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; }; #endif diff --git a/src/Simulators/MyStylus.cpp b/src/Simulators/MyStylus.cpp index 2c428cb3b7a070ee12e7d65924df0d7b3f373a98..d6f9f228a5e6482c38b1066b068681da47112b95 100644 --- a/src/Simulators/MyStylus.cpp +++ b/src/Simulators/MyStylus.cpp @@ -35,24 +35,24 @@ MyStylus::MyStylus(const std::string& p_shaft, const std::string& p_lower, const std::string& p_upper) { angle = 0; - smMatrix33d rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitX()).matrix(); + Matrix33d rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); smSurfaceMesh *mesh = new smSurfaceMesh(SMMESH_RIGID, NULL); mesh->loadMesh(p_shaft, SM_FILETYPE_3DS); mesh->assignTexture("hookCautery"); - mesh->scale(smVec3d(0.2, 0.2, 0.2)); + mesh->scale(core::Vec3d(0.2, 0.2, 0.2)); mesh->rotate(rot); smSurfaceMesh *lowerMesh = new smSurfaceMesh(SMMESH_RIGID, NULL); lowerMesh->loadMesh(p_lower, SM_FILETYPE_3DS); lowerMesh->assignTexture("metal"); - lowerMesh->scale(smVec3d(0.2, 0.2, 0.2)); + lowerMesh->scale(core::Vec3d(0.2, 0.2, 0.2)); lowerMesh->rotate(rot); smSurfaceMesh *upperMesh = new smSurfaceMesh(SMMESH_RIGID, NULL); upperMesh->loadMesh(p_upper, SM_FILETYPE_3DS); upperMesh->assignTexture("metal"); - upperMesh->scale(smVec3d(0.2, 0.2, 0.2)); + upperMesh->scale(core::Vec3d(0.2, 0.2, 0.2)); upperMesh->rotate(rot); meshContainer.name = "HookCauteryPivot"; @@ -105,7 +105,7 @@ void MyStylus::updateOpenClose() } //This function is not fixed for a reason....I'll give you a hint...try to match the brackets -void MyStylus::handleEvent (std::shared_ptr<mstk::Event::smEvent> p_event) +void MyStylus::handleEvent (std::shared_ptr<mstk::Event::Event> p_event) { if(!this->isListening()) { @@ -183,12 +183,12 @@ void MyStylus::handleEvent (std::shared_ptr<mstk::Event::smEvent> p_event) HookCautery::HookCautery(const std::string& p_pivot) { - smMatrix33d rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitX()).matrix(); + Matrix33d rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); smSurfaceMesh *mesh = new smSurfaceMesh(SMMESH_RIGID, NULL); mesh->loadMesh(p_pivot, SM_FILETYPE_3DS); mesh->assignTexture("metal"); - mesh->scale(smVec3d(0.2, 0.2, 0.2)); + mesh->scale(core::Vec3d(0.2, 0.2, 0.2)); mesh->rotate(rot); meshContainer.name = "HookCauteryPivot"; @@ -198,7 +198,7 @@ HookCautery::HookCautery(const std::string& p_pivot) addMeshContainer(&meshContainer); } -void HookCautery::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) +void HookCautery::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) { if(!this->isListening()) { diff --git a/src/Simulators/MyStylus.h b/src/Simulators/MyStylus.h index 2831f3dba4ed54e5ea398092de2079446899f121..d86584406757751e2be7245450a70b6dd64989da 100644 --- a/src/Simulators/MyStylus.h +++ b/src/Simulators/MyStylus.h @@ -44,7 +44,7 @@ public: smMeshContainer meshContainer, meshContainerLower, meshContainerUpper; ///< !! /// \brief handle keyboard and omni button presses - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief constructor MyStylus(const std::string& p_shaft = "../../resources/models/blunt_diss_pivot.3DS", @@ -65,7 +65,7 @@ public: smMeshContainer meshContainer; ///< !! /// \brief handle keyboard and omni button presses - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief constructor HookCautery(const std::string& p_pivot = "../../resources/models/hook_cautery_new.3DS"); diff --git a/src/Simulators/PBDObjectSimulator.cpp b/src/Simulators/PBDObjectSimulator.cpp index 23a6cdac8445f3f4d20ca6ed84d164edf1206ed7..a69f31bc7ba47200ded85cab664a88bb9c45d1aa 100644 --- a/src/Simulators/PBDObjectSimulator.cpp +++ b/src/Simulators/PBDObjectSimulator.cpp @@ -27,7 +27,7 @@ void smPBDObjectSimulator::draw() { - smObjectSimulator::draw(); + ObjectSimulator::draw(); std::shared_ptr<smPBDSurfaceSceneObject> sceneObject; for (size_t i = 0; i < objectsSimulated.size(); i++) @@ -36,7 +36,7 @@ void smPBDObjectSimulator::draw() smGLRenderer::draw(sceneObject->mesh->aabb); } } -smPBDObjectSimulator::smPBDObjectSimulator( std::shared_ptr<smErrorLog> p_errorLog ) : smObjectSimulator( p_errorLog ) +smPBDObjectSimulator::smPBDObjectSimulator( std::shared_ptr<ErrorLog> p_errorLog ) : ObjectSimulator( p_errorLog ) { this->scheduleGroup.maxTargetFPS = 100; this->scheduleGroup.minTargetFPS = 30; @@ -57,7 +57,7 @@ void smPBDObjectSimulator::initObject( std::shared_ptr<smPBDSurfaceSceneObject> void smPBDObjectSimulator::initCustom() { core::ClassType type; - std::shared_ptr<smSceneObject> object; + std::shared_ptr<SceneObject> object; std::shared_ptr<smPBDSurfaceSceneObject> pbdSurfaceSceneObject; //do nothing for now @@ -82,10 +82,10 @@ void smPBDObjectSimulator::initCustom() } void smPBDObjectSimulator::run() { - std::shared_ptr<smSceneObject> sceneObj; + std::shared_ptr<SceneObject> sceneObj; std::shared_ptr<smPBDSurfaceSceneObject> pbdSurfaceSceneObject; float dist, lamda; - smVec3d dirVec, dP; + core::Vec3d dirVec, dP; int count = 0; int a, b; @@ -99,7 +99,7 @@ void smPBDObjectSimulator::run() if ( sceneObj->getType() == core::ClassType::PbdSurfaceSceneObject ) { pbdSurfaceSceneObject = std::static_pointer_cast<smPBDSurfaceSceneObject>(sceneObj); - smStdVector3d &vertices = pbdSurfaceSceneObject->getLocalVertices(); + core::StdVector3d &vertices = pbdSurfaceSceneObject->getLocalVertices(); if ( !pbdSurfaceSceneObject->getFlags().isSimulatorInit ) { @@ -108,7 +108,7 @@ void smPBDObjectSimulator::run() for ( int i = 0; i < pbdSurfaceSceneObject->nbrMass; i++ ) { - pbdSurfaceSceneObject->exF[i] = smVec3d::Zero(); + pbdSurfaceSceneObject->exF[i] = core::Vec3d::Zero(); } for ( int i = 0; i < pbdSurfaceSceneObject->nbrMass; i++ ) @@ -184,7 +184,7 @@ void smPBDObjectSimulator::run() } void smPBDObjectSimulator::syncBuffers() { - std::shared_ptr<smSceneObject> sceneObj; + std::shared_ptr<SceneObject> sceneObj; std::shared_ptr<smPBDSurfaceSceneObject> pbdSurfaceSceneObject; for ( size_t i = 0; i < this->objectsSimulated.size(); i++ ) @@ -202,7 +202,7 @@ void smPBDObjectSimulator::syncBuffers() } } } -void smPBDObjectSimulator::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event ) +void smPBDObjectSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) { ; diff --git a/src/Simulators/PBDObjectSimulator.h b/src/Simulators/PBDObjectSimulator.h index baea82a00a3dd87de14f75e1d39579facf06c300..d5b35390c4cf9de6408c9ee914dc709a62dc7a2f 100644 --- a/src/Simulators/PBDObjectSimulator.h +++ b/src/Simulators/PBDObjectSimulator.h @@ -28,17 +28,17 @@ #include "Core/ObjectSimulator.h" #include "Core/EventHandler.h" -class smErrorLog; +class ErrorLog; class smPBDSurfaceSceneObject; -class smEvent; +class Event; /// \brief Example Position based dynamics (PBD) simulator -class smPBDObjectSimulator: public smObjectSimulator +class smPBDObjectSimulator: public ObjectSimulator { public: /// \brief constructor - smPBDObjectSimulator(std::shared_ptr<smErrorLog> p_errorLog); + smPBDObjectSimulator(std::shared_ptr<ErrorLog> p_errorLog); protected: /// \brief initialize the PBD object @@ -53,7 +53,7 @@ protected: void syncBuffers() override; /// \brief handle key presses and other user events - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief render the PBD objects void draw() override; diff --git a/src/Simulators/PBDSceneObject.cpp b/src/Simulators/PBDSceneObject.cpp index 500297a896053cf0e419bfab646796b95c68fe10..b9f693608185f7952396513e00e68c549ee3ba49 100644 --- a/src/Simulators/PBDSceneObject.cpp +++ b/src/Simulators/PBDSceneObject.cpp @@ -23,7 +23,7 @@ #include "PBDSceneObject.h" -void smPBDSurfaceSceneObject::findFixedMassWrtSphere(smVec3d p_center, float p_radius) +void smPBDSurfaceSceneObject::findFixedMassWrtSphere(core::Vec3d p_center, float p_radius) { float dist = 0; @@ -38,14 +38,14 @@ void smPBDSurfaceSceneObject::findFixedMassWrtSphere(smVec3d p_center, float p_r } } } -smPBDSceneObject::smPBDSceneObject( std::shared_ptr<smErrorLog>/*p_log*/ ) +smPBDSceneObject::smPBDSceneObject( std::shared_ptr<ErrorLog>/*p_log*/ ) { type = core::ClassType::PbdSceneObject; } -std::shared_ptr<smSceneObject> smPBDSceneObject::clone() +std::shared_ptr<SceneObject> smPBDSceneObject::clone() { - return safeDownCast<smSceneObject>(); + return safeDownCast<SceneObject>(); } void smPBDSceneObject::serialize( void */*p_memoryBlock*/ ) @@ -58,14 +58,14 @@ void smPBDSceneObject::unSerialize( void */*p_memoryBlock*/ ) } -smPBDSurfaceSceneObject::smPBDSurfaceSceneObject( std::shared_ptr<smErrorLog> p_log ) +smPBDSurfaceSceneObject::smPBDSurfaceSceneObject( std::shared_ptr<ErrorLog> p_log ) { type = core::ClassType::PbdSurfaceSceneObject; mesh = new smSurfaceMesh( SMMESH_DEFORMABLE, p_log ); } -std::shared_ptr<smSceneObject> smPBDSurfaceSceneObject::clone() +std::shared_ptr<SceneObject> smPBDSurfaceSceneObject::clone() { - return safeDownCast<smSceneObject>(); + return safeDownCast<SceneObject>(); } void smPBDSurfaceSceneObject::serialize( void */*p_memoryBlock*/ ) { @@ -91,9 +91,9 @@ void smPBDSurfaceSceneObject::InitSurfaceObject() //surface mesh nbrMass = mesh->nbrVertices; - P = new smVec3d[nbrMass]; - V = new smVec3d[nbrMass]; - exF = new smVec3d[nbrMass]; + P = new core::Vec3d[nbrMass]; + V = new core::Vec3d[nbrMass]; + exF = new core::Vec3d[nbrMass]; fixedMass = new bool[nbrMass]; for ( int i = 0; i < nbrMass; i++ ) @@ -148,7 +148,7 @@ void smPBDSurfaceSceneObject::findFixedCorners() nbrFixedMass = 2; listFixedMass = new int[nbrFixedMass]; - smVec3d corner[2]; + core::Vec3d corner[2]; int i, j; float minmin, dist; corner[0] = mesh->aabb.aabbMax; diff --git a/src/Simulators/PBDSceneObject.h b/src/Simulators/PBDSceneObject.h index 491a13d20cf3a70188b0cf5a2ceba97e85160401..0340364d988d8eb6e9f5f54de4bd53efbbe114b0 100644 --- a/src/Simulators/PBDSceneObject.h +++ b/src/Simulators/PBDSceneObject.h @@ -31,14 +31,14 @@ #include "Mesh/Mesh.h" /// \brief Position based dynamics (PBD) object -class smPBDSceneObject: public smSceneObject +class smPBDSceneObject: public SceneObject { public: /// \brief constructor - smPBDSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + smPBDSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); /// \brief !! - virtual std::shared_ptr<smSceneObject> clone(); + virtual std::shared_ptr<SceneObject> clone(); /// \brief !! virtual void serialize(void *p_memoryBlock); @@ -55,18 +55,18 @@ public: float Damp; ///< damping values int nbrMass; ///< number of masses int **massIdx; ///< !! - smStdVector3d P; ///< !! position - smStdVector3d V; ///< !! velocity - smStdVector3d exF; ///< external force + core::StdVector3d P; ///< !! position + core::StdVector3d V; ///< !! velocity + core::StdVector3d exF; ///< external force int nbrSpr; ///< !! number of spheres float *L0; ///< !! Initial length bool *fixedMass; ///< true if masses are fixed int nbrFixedMass; ///< number of fixed masses int *listFixedMass; ///< list of IDs of masses that are fixed - smVec3d ball_pos; ///< !! position of ball - smVec3d ball_vel; ///< !! velocity of ball - smVec3d ball_frc; ///< !! + core::Vec3d ball_pos; ///< !! position of ball + core::Vec3d ball_vel; ///< !! velocity of ball + core::Vec3d ball_frc; ///< !! float ball_mass; ///< !! mass of ball float ball_rad; ///< !! radius of ball @@ -78,10 +78,10 @@ class smPBDSurfaceSceneObject: public smPBDSceneObject public: /// \brief constructor - smPBDSurfaceSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + smPBDSurfaceSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); /// \brief !! - virtual std::shared_ptr<smSceneObject> clone() override; + virtual std::shared_ptr<SceneObject> clone() override; /// \brief !! virtual void serialize(void *p_memoryBlock) override; @@ -99,7 +99,7 @@ public: ~smPBDSurfaceSceneObject(); /// \brief find the masses that will be fixed based on the spheres - void findFixedMassWrtSphere(smVec3d p_center, float pos); + void findFixedMassWrtSphere(core::Vec3d p_center, float pos); /// \brief find fixed corners void findFixedCorners(); diff --git a/src/Simulators/SceneObjectDeformable.cpp b/src/Simulators/SceneObjectDeformable.cpp index b55b47bdb38fbd083a8d7a3eca16d59a62d1f39e..80a7fb76396343ee0f0b1b850cb248d9103c51ff 100644 --- a/src/Simulators/SceneObjectDeformable.cpp +++ b/src/Simulators/SceneObjectDeformable.cpp @@ -33,7 +33,7 @@ smSceneObjectDeformable::smSceneObjectDeformable() : subTimestepCounter(0) { this->setRenderDelegate( - smFactory<smRenderDelegate>::createSubclass( + Factory<RenderDelegate>::createSubclass( "RenderDelegate", "SceneObjectDeformableRenderDelegate")); } @@ -58,30 +58,30 @@ void smSceneObjectDeformable::setContactForcesToZero() } void smSceneObjectDeformable::setContactForceOfNodeWithDofID(const int dofID, - const smVec3d force) + const core::Vec3d force) { f_contact[dofID] = force(0); f_contact[dofID + 1] = force(1); f_contact[dofID + 2] = force(2); } -smVec3d smSceneObjectDeformable::getVelocityOfNodeWithDofID(const int dofID) const +core::Vec3d smSceneObjectDeformable::getVelocityOfNodeWithDofID(const int dofID) const { - smVec3d vel(uvel[dofID], uvel[dofID + 1], uvel[dofID + 2]); + core::Vec3d vel(uvel[dofID], uvel[dofID + 1], uvel[dofID + 2]); return vel; } -smVec3d smSceneObjectDeformable::getDisplacementOfNodeWithDofID(const int dofID) const +core::Vec3d smSceneObjectDeformable::getDisplacementOfNodeWithDofID(const int dofID) const { - smVec3d disp(u[dofID], u[dofID + 1], u[dofID + 2]); + core::Vec3d disp(u[dofID], u[dofID + 1], u[dofID + 2]); return disp; } -smVec3d smSceneObjectDeformable::getAccelerationOfNodeWithDofID(const int dofID) const +core::Vec3d smSceneObjectDeformable::getAccelerationOfNodeWithDofID(const int dofID) const { - smVec3d accn(uaccel[dofID], uaccel[dofID + 1], uaccel[dofID + 2]); + core::Vec3d accn(uaccel[dofID], uaccel[dofID + 1], uaccel[dofID + 2]); return accn; } @@ -111,7 +111,7 @@ int smSceneObjectDeformable::getNumFixedDof() const return numFixedDof; } -void smSceneObjectDeformable::setRenderDetail(const std::shared_ptr<smRenderDetail> &r) +void smSceneObjectDeformable::setRenderDetail(const std::shared_ptr<RenderDetail> &r) { primarySurfaceMesh->setRenderDetail(r); diff --git a/src/Simulators/SceneObjectDeformable.h b/src/Simulators/SceneObjectDeformable.h index b9363473056b82c30a9df6f86c9d564cd3746602..b0da0a341ff544545e648d8903b157eb308c7b43 100644 --- a/src/Simulators/SceneObjectDeformable.h +++ b/src/Simulators/SceneObjectDeformable.h @@ -33,7 +33,7 @@ #include "Mesh/VegaSceneObjectDeformable.h" /// \brief Base class for any scene object that is defmormable -class smSceneObjectDeformable : public smSceneObject +class smSceneObjectDeformable : public SceneObject { public: @@ -76,19 +76,19 @@ public: /// \brief Sets the contact force at a given location /// (not given node) in contact force vector - void setContactForceOfNodeWithDofID(const int dofID, const smVec3d force); + void setContactForceOfNodeWithDofID(const int dofID, const core::Vec3d force); /// \brief returns displacement of at a given location /// (not given node) in contact force vector - smVec3d getDisplacementOfNodeWithDofID(const int dofID) const; + core::Vec3d getDisplacementOfNodeWithDofID(const int dofID) const; /// \brief returns velocity of at a given location /// (not given node) in contact force vector - smVec3d getVelocityOfNodeWithDofID(const int dofID) const; + core::Vec3d getVelocityOfNodeWithDofID(const int dofID) const; /// \brief returns acceleration of at a given location /// (not given node) in contact force vector - smVec3d getAccelerationOfNodeWithDofID(const int dofID) const; + core::Vec3d getAccelerationOfNodeWithDofID(const int dofID) const; /// \brief get the total number of nodes int getNumNodes() const; @@ -108,7 +108,7 @@ public: /// \brief sets the objects specific render details /// Should be moved to base class in near future - void setRenderDetail(const std::shared_ptr<smRenderDetail> &r); + void setRenderDetail(const std::shared_ptr<RenderDetail> &r); /// \brief enable drawing of secondary mesh (if initialized) void setRenderSecondaryMesh(); diff --git a/src/Simulators/StylusObject.cpp b/src/Simulators/StylusObject.cpp index 8bc2162b7bf16d13e1d0dded77f8bd5decc462ce..94c13ee9e7e14ee3f7311061fc2c31d93dad7db2 100644 --- a/src/Simulators/StylusObject.cpp +++ b/src/Simulators/StylusObject.cpp @@ -22,22 +22,21 @@ //--------------------------------------------------------------------------- #include "StylusObject.h" -#include "Core/CollisionModel.h" #include "Collision/SurfaceTree.h" #include "Collision/OctreeCell.h" #include "Mesh/Mesh.h" #include "Rendering/GLUtils.h" -smStylusSceneObject::smStylusSceneObject(std::shared_ptr<smErrorLog>/*p_log*/) : smSceneObject() +smStylusSceneObject::smStylusSceneObject(std::shared_ptr<ErrorLog>/*p_log*/) : SceneObject() { type = core::ClassType::StylusSceneObject; toolEnabled = true; this->setRenderDelegate( - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "StylusRenderDelegate")); } -smStylusRigidSceneObject::smStylusRigidSceneObject(std::shared_ptr<smErrorLog>/*p_log*/) +smStylusRigidSceneObject::smStylusRigidSceneObject(std::shared_ptr<ErrorLog>/*p_log*/) { type = core::ClassType::StylusRigidSceneObject; updateViewerMatrixEnabled = true; @@ -47,7 +46,7 @@ smStylusRigidSceneObject::smStylusRigidSceneObject(std::shared_ptr<smErrorLog>/* } smStylusDeformableSceneObject::smStylusDeformableSceneObject( - std::shared_ptr<smErrorLog>/*p_log*/) + std::shared_ptr<ErrorLog>/*p_log*/) : smStylusSceneObject() { type = core::ClassType::StylusSeformableSceneObject; @@ -84,13 +83,13 @@ smMeshContainer::smMeshContainer( std::string p_name ) offsetRotX = 0.0; offsetRotY = 0.0; offsetRotZ = 0.0; - preOffsetPos = smVec3d::Zero(); - posOffsetPos = smVec3d::Zero(); + preOffsetPos = core::Vec3d::Zero(); + posOffsetPos = core::Vec3d::Zero(); mesh = NULL; colModel = NULL; } -smMeshContainer::smMeshContainer( std::string p_name, smMesh */*p_mesh*/, smVec3d p_prePos, smVec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ ) +smMeshContainer::smMeshContainer( std::string p_name, smMesh */*p_mesh*/, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ ) { offsetRotX = p_offsetRotX; offsetRotY = p_offsetRotY; @@ -103,20 +102,21 @@ smMeshContainer::smMeshContainer( std::string p_name, smMesh */*p_mesh*/, smVec3 void smMeshContainer::computeCurrentMatrix() { + double pipi = 6.28318530717959; Eigen::Affine3d preTranslate( Eigen::Translation3d( preOffsetPos[0], preOffsetPos[1], preOffsetPos[2] ) ); Eigen::Affine3d posTranslate( Eigen::Translation3d( posOffsetPos[0], posOffsetPos[1], posOffsetPos[2] ) ); - Eigen::Affine3d rx( Eigen::Affine3d( Eigen::AngleAxisd( SM_PI_TWO * offsetRotX, smVec3d::UnitX() ) ) ); - Eigen::Affine3d ry( Eigen::Affine3d( Eigen::AngleAxisd( SM_PI_TWO * offsetRotY, smVec3d::UnitY() ) ) ); - Eigen::Affine3d rz( Eigen::Affine3d( Eigen::AngleAxisd( SM_PI_TWO * offsetRotZ, smVec3d::UnitZ() ) ) ); + Eigen::Affine3d rx( Eigen::Affine3d( Eigen::AngleAxisd( pipi * offsetRotX, core::Vec3d::UnitX() ) ) ); + Eigen::Affine3d ry( Eigen::Affine3d( Eigen::AngleAxisd( pipi * offsetRotY, core::Vec3d::UnitY() ) ) ); + Eigen::Affine3d rz( Eigen::Affine3d( Eigen::AngleAxisd( pipi * offsetRotZ, core::Vec3d::UnitZ() ) ) ); - smMatrix44d transform = ( preTranslate * rx * ry * rz * posTranslate ).matrix(); + Matrix44d transform = ( preTranslate * rx * ry * rz * posTranslate ).matrix(); tempCurrentMatrix *= transform; tempCurrentDeviceMatrix *= transform; } smStylusPoints::smStylusPoints() { - point = smVec3d::Zero(); + point = core::Vec3d::Zero(); container = NULL; } @@ -128,7 +128,7 @@ void smStylusSceneObject::unSerialize( void */*p_memoryBlock*/ ) { } -void smStylusSceneObject::handleEvent(std::shared_ptr<mstk::Event::smEvent>/*p_event*/ ) {} +void smStylusSceneObject::handleEvent(std::shared_ptr<mstk::Event::Event>/*p_event*/ ) {} void smStylusRigidSceneObject::posTraverseCallBack() { } @@ -179,9 +179,9 @@ tree< smMeshContainer * >::iterator smStylusRigidSceneObject::addMeshContainer( return meshes.insert( p_iterator, p_meshContainer ); } -void smStylusRigidSceneObject::handleEvent(std::shared_ptr<mstk::Event::smEvent>/*p_event*/ ) {} +void smStylusRigidSceneObject::handleEvent(std::shared_ptr<mstk::Event::Event>/*p_event*/ ) {} -std::shared_ptr<smSceneObject> smStylusRigidSceneObject::clone() +std::shared_ptr<SceneObject> smStylusRigidSceneObject::clone() { // WARNING: What is the purpose of this function std::shared_ptr<smStylusRigidSceneObject> ret = std::make_shared<smStylusRigidSceneObject>(); diff --git a/src/Simulators/StylusObject.h b/src/Simulators/StylusObject.h index 5bdb9894c33c53c018fd796537505dd36d0a9dc9..01eaf6da22cdb09f404dcad59a6f6fe6d323a9db 100644 --- a/src/Simulators/StylusObject.h +++ b/src/Simulators/StylusObject.h @@ -34,33 +34,31 @@ #include "Core/Config.h" #include "Mesh/Mesh.h" #include "Core/SceneObject.h" -#include "Core/Math.h" #include "External/tree.hh" namespace mstk { namespace Event { - class smEvent; + class Event; class smEventHandler; class smCameraEvent; } } -template<typename T> class smCollisionModel; -template<typename smSurfaceTreeCell> class smSurfaceTree; -class smOctreeCell; +template<typename SurfaceTreeCell> class SurfaceTree; +class OctreeCell; /// \brief !! class smMeshContainer { public: - using SurfaceTreeType = smSurfaceTree<smOctreeCell>; + using SurfaceTreeType = SurfaceTree<OctreeCell>; public: /// \brief constructor smMeshContainer(std::string p_name = ""); /// \brief constructor - smMeshContainer(std::string p_name, smMesh *p_mesh, smVec3d p_prePos, smVec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ); + smMeshContainer(std::string p_name, smMesh *p_mesh, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ); void computeCurrentMatrix(); @@ -69,16 +67,16 @@ public: float offsetRotX; // offset in rotation in x-direction float offsetRotY; // offset in rotation in y-direction float offsetRotZ; // offset in rotation in z-direction - smVec3d preOffsetPos; // !! - smVec3d posOffsetPos; // !! - smMatrix44d accumulatedMatrix; // !! - smMatrix44d accumulatedDeviceMatrix; // !! - - smMatrix44d currentMatrix; // !! - smMatrix44d currentViewerMatrix; // !! - smMatrix44d currentDeviceMatrix; // !! - smMatrix44d tempCurrentMatrix; // !! - smMatrix44d tempCurrentDeviceMatrix; // !! + core::Vec3d preOffsetPos; // !! + core::Vec3d posOffsetPos; // !! + Matrix44d accumulatedMatrix; // !! + Matrix44d accumulatedDeviceMatrix; // !! + + Matrix44d currentMatrix; // !! + Matrix44d currentViewerMatrix; // !! + Matrix44d currentDeviceMatrix; // !! + Matrix44d tempCurrentMatrix; // !! + Matrix44d tempCurrentDeviceMatrix; // !! smMesh * mesh; // mesh std::shared_ptr<SurfaceTreeType> colModel; // octree of surface }; @@ -89,16 +87,16 @@ struct smStylusPoints /// \brief constructor smStylusPoints(); - smVec3d point; // co-ordinates of points on stylus + core::Vec3d point; // co-ordinates of points on stylus smMeshContainer *container; // !! }; /// \brief stylus object of the scene (typically used for laparascopic VR simulations) -class smStylusSceneObject: public smSceneObject +class smStylusSceneObject: public SceneObject { public: /// \brief constructor - smStylusSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + smStylusSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); /// \brief !! virtual void serialize(void *p_memoryBlock) override; @@ -107,14 +105,14 @@ public: virtual void unSerialize(void *p_memoryBlock) override; /// \brief handle the events such as button presses related to stylus - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; public: - smVec3d pos; // position of stylus - smVec3d vel; // velocity of stylus - smMatrix33d rot; // rotation of stylus - smMatrix44d transRot; // !! translation and rotation matrix of stylus - smMatrix44d transRotDevice; // translation and rotation matrix of devide controlling the stylus + core::Vec3d pos; // position of stylus + core::Vec3d vel; // velocity of stylus + Matrix33d rot; // rotation of stylus + Matrix44d transRot; // !! translation and rotation matrix of stylus + Matrix44d transRotDevice; // translation and rotation matrix of devide controlling the stylus bool toolEnabled; // !! protected: @@ -144,7 +142,7 @@ public: bool posCallBackEnabledForEntireObject; // !! /// \brief !! - smStylusRigidSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + smStylusRigidSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); /// \brief !! tree<smMeshContainer*>::iterator addMeshContainer(smMeshContainer *p_meshContainer); @@ -158,10 +156,10 @@ public: /// \brief !! smMeshContainer *getMeshContainer(std::string p_string) const; - virtual void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief !! - std::shared_ptr<smSceneObject> clone() override; + std::shared_ptr<SceneObject> clone() override; /// \brief !! virtual void initialize() override {}; @@ -192,7 +190,7 @@ class smStylusDeformableSceneObject: public smStylusSceneObject { public: - smStylusDeformableSceneObject(std::shared_ptr<smErrorLog> p_log = nullptr); + smStylusDeformableSceneObject(std::shared_ptr<ErrorLog> p_log = nullptr); ~smStylusDeformableSceneObject(){}; @@ -219,7 +217,7 @@ public: return (std::shared_ptr<void>)newSO; } - std::shared_ptr<smSceneObject> clone() override + std::shared_ptr<SceneObject> clone() override { // WARNING: What is the purpose of this function std::shared_ptr<smStylusDeformableSceneObject> ret = std::make_shared<smStylusDeformableSceneObject>(); diff --git a/src/Simulators/ToolSimulator.cpp b/src/Simulators/ToolSimulator.cpp index 15f68b58509ad0aec181a9b1e21a18c99dcffe23..4fd1fa75cdc87745507e9b9ad4791e4405e9919a 100644 --- a/src/Simulators/ToolSimulator.cpp +++ b/src/Simulators/ToolSimulator.cpp @@ -27,8 +27,8 @@ void smToolSimulator::updateTool(std::shared_ptr<smStylusRigidSceneObject> p_tool) { - smMatrix44d tempMat, tempMatDevice; - smMatrix44d mat; + Matrix44d tempMat, tempMatDevice; + Matrix44d mat; tree<smMeshContainer*>::pre_order_iterator iter = p_tool->meshes.begin(); //update the Root node first iter.node->data->computeCurrentMatrix(); @@ -79,7 +79,7 @@ void smToolSimulator::updateTool(std::shared_ptr<smStylusRigidSceneObject> p_too } } -smToolSimulator::smToolSimulator( std::shared_ptr<smErrorLog> p_errorLog ) : smObjectSimulator( p_errorLog ) +smToolSimulator::smToolSimulator( std::shared_ptr<ErrorLog> p_errorLog ) : ObjectSimulator( p_errorLog ) { } @@ -118,7 +118,7 @@ void smToolSimulator::syncBuffers() { } -void smToolSimulator::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event ) +void smToolSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) { if(!this->isListening()) { diff --git a/src/Simulators/ToolSimulator.h b/src/Simulators/ToolSimulator.h index 39a1fbd2d6719f2f58101854ebf0f2201c828dbd..be8279e3a8c33e3488f8d6388842c38bc56d3be5 100644 --- a/src/Simulators/ToolSimulator.h +++ b/src/Simulators/ToolSimulator.h @@ -32,12 +32,12 @@ /// \brief Example tool simulator -class smToolSimulator: public smObjectSimulator +class smToolSimulator: public ObjectSimulator { public: /// \brief constructor - smToolSimulator(std::shared_ptr<smErrorLog> p_errorLog); + smToolSimulator(std::shared_ptr<ErrorLog> p_errorLog); /// \brief update everything related to tool void updateTool(std::shared_ptr<smStylusRigidSceneObject> p_tool); @@ -52,7 +52,7 @@ public: void syncBuffers() override; /// \brief handle the events such as button presses related to tool - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; }; #endif diff --git a/src/Simulators/VegaFemSceneObject.cpp b/src/Simulators/VegaFemSceneObject.cpp index 81a28939a8226df3918f8b70ae6b089f69644941..6f421233701903bc81f6a2fee9a41890c753bd53 100644 --- a/src/Simulators/VegaFemSceneObject.cpp +++ b/src/Simulators/VegaFemSceneObject.cpp @@ -42,11 +42,11 @@ smVegaFemSceneObject::smVegaFemSceneObject() : this->name = "VegaFem_SceneObject_" + std::to_string(this->getUniqueId()->getId()); this->setRenderDelegate( - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "SceneObjectDeformableRenderDelegate")); } -smVegaFemSceneObject::smVegaFemSceneObject(const std::shared_ptr<smErrorLog> p_log, +smVegaFemSceneObject::smVegaFemSceneObject(const std::shared_ptr<ErrorLog> p_log, const std::string ConfigFile): staticSolver(0), graphicFrame(0), @@ -63,7 +63,7 @@ smVegaFemSceneObject::smVegaFemSceneObject(const std::shared_ptr<smErrorLog> p_l // Create the default delegate before configuration so it // can be overridden. this->setRenderDelegate( - smFactory<smRenderDelegate>::createConcreteClass( + Factory<RenderDelegate>::createConcreteClass( "SceneObjectDeformableRenderDelegate")); ConfigFileName = ConfigFile; @@ -77,9 +77,9 @@ smVegaFemSceneObject::~smVegaFemSceneObject() { } -std::shared_ptr<smSceneObject> smVegaFemSceneObject::clone() +std::shared_ptr<SceneObject> smVegaFemSceneObject::clone() { - return safeDownCast<smSceneObject>(); + return safeDownCast<SceneObject>(); } bool smVegaFemSceneObject::configure(const std::string ConfigFile) @@ -1011,7 +1011,7 @@ inline void smVegaFemSceneObject::advanceOneTimeStep() } } -void smVegaFemSceneObject::setPulledVertex(const smVec3d &userPos) +void smVegaFemSceneObject::setPulledVertex(const core::Vec3d &userPos) { pulledVertex = this->volumetricMesh->getClosestVertex(Vec3d(userPos(0), userPos(1), userPos(2))); } @@ -1177,23 +1177,23 @@ void smVegaFemSceneObject::printInfo() const std::cout << "\t-------------------------------------\n"; } -smVec3d smVegaFemSceneObject::getVelocityOfNodeWithDofID(const int dofID) const +core::Vec3d smVegaFemSceneObject::getVelocityOfNodeWithDofID(const int dofID) const { - smVec3d vel(uvel[dofID], uvel[dofID + 1], uvel[dofID + 2]); + core::Vec3d vel(uvel[dofID], uvel[dofID + 1], uvel[dofID + 2]); return vel; } -smVec3d smVegaFemSceneObject::getDisplacementOfNodeWithDofID(const int dofID) const +core::Vec3d smVegaFemSceneObject::getDisplacementOfNodeWithDofID(const int dofID) const { - smVec3d disp(u[dofID], u[dofID + 1], u[dofID + 2]); + core::Vec3d disp(u[dofID], u[dofID + 1], u[dofID + 2]); return disp; } -smVec3d smVegaFemSceneObject::getAccelerationOfNodeWithDofID(const int dofID) const +core::Vec3d smVegaFemSceneObject::getAccelerationOfNodeWithDofID(const int dofID) const { - smVec3d accn(uaccel[dofID], uaccel[dofID + 1], uaccel[dofID + 2]); + core::Vec3d accn(uaccel[dofID], uaccel[dofID + 1], uaccel[dofID + 2]); return accn; } diff --git a/src/Simulators/VegaFemSceneObject.h b/src/Simulators/VegaFemSceneObject.h index 2d682fc6c0f48051618577eca6534813d35f9174..1b01b90aec1f69dffd4db2061bdee6480ccc5d70 100644 --- a/src/Simulators/VegaFemSceneObject.h +++ b/src/Simulators/VegaFemSceneObject.h @@ -76,7 +76,7 @@ public: smVegaFemSceneObject(); /// \brief Constructor - smVegaFemSceneObject(const std::shared_ptr<smErrorLog> p_log, const std::string ConfigFile); + smVegaFemSceneObject(const std::shared_ptr<ErrorLog> p_log, const std::string ConfigFile); /// \brief Destructor ~smVegaFemSceneObject(); @@ -146,19 +146,19 @@ public: /// \brief check all the surface nodes for the closest node within /// certain threshold and set it to be the pulled vertex - void setPulledVertex(const smVec3d &userPos); + void setPulledVertex(const core::Vec3d &userPos); /// \brief returns velocity given the /// localtion in the global velocity vector - smVec3d getVelocityOfNodeWithDofID(const int dofID) const; + core::Vec3d getVelocityOfNodeWithDofID(const int dofID) const; /// \brief returns displacement given the /// localtion in the global displacement vector - smVec3d getDisplacementOfNodeWithDofID(const int dofID) const; + core::Vec3d getDisplacementOfNodeWithDofID(const int dofID) const; /// \brief returns acceleration given the /// localtion in the global acceleration vector - smVec3d getAccelerationOfNodeWithDofID(const int dofID) const; + core::Vec3d getAccelerationOfNodeWithDofID(const int dofID) const; /// \brief returns the number of nodes int getNumNodes() const; @@ -186,10 +186,10 @@ public: ///every Scene Object should know how to clone itself. /// Since the data structures will be ///in the beginning of the modules(such as simulator, viewer, collision etc.) - //virtual std::shared_ptr<smSceneObject> clone() override { return nullptr; }; + //virtual std::shared_ptr<SceneObject> clone() override { return nullptr; }; /// \brief not implemented yet. - std::shared_ptr<smSceneObject> clone() override; + std::shared_ptr<SceneObject> clone() override; private: diff --git a/src/Simulators/VegaFemSimulator.cpp b/src/Simulators/VegaFemSimulator.cpp index 6ef21b16b736396627183a0580c1d2b28a4125dd..59649067bff69a3ab8c92aebb8cc42444c1a8a37 100644 --- a/src/Simulators/VegaFemSimulator.cpp +++ b/src/Simulators/VegaFemSimulator.cpp @@ -24,7 +24,7 @@ // SimMedTK includes #include "VegaFemSimulator.h" -smVegaFemSimulator::smVegaFemSimulator( std::shared_ptr<smErrorLog> p_errorLog ) : smObjectSimulator( p_errorLog ) +smVegaFemSimulator::smVegaFemSimulator( std::shared_ptr<ErrorLog> p_errorLog ) : ObjectSimulator( p_errorLog ) { hapticButtonPressed = false; } @@ -80,7 +80,7 @@ void smVegaFemSimulator::syncBuffers() { } -void smVegaFemSimulator::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event ) +void smVegaFemSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) { if (!this->isListening()) { diff --git a/src/Simulators/VegaFemSimulator.h b/src/Simulators/VegaFemSimulator.h index a0bbd213ae3210a63bf5ea36d76b631c3882781e..96513fd5873b046e173a365ed9424edcbde7e542 100644 --- a/src/Simulators/VegaFemSimulator.h +++ b/src/Simulators/VegaFemSimulator.h @@ -31,12 +31,12 @@ #include "VegaFemSceneObject.h" /// \brief Interface class between Vega and SimMedTK core -class smVegaFemSimulator: public smObjectSimulator +class smVegaFemSimulator: public ObjectSimulator { public: /// \brief constructor - smVegaFemSimulator(std::shared_ptr<smErrorLog> p_errorLog); + smVegaFemSimulator(std::shared_ptr<ErrorLog> p_errorLog); /// \brief start the job virtual void beginSim() override; @@ -54,10 +54,10 @@ public: void syncBuffers() override; /// \brief handle the keyboard and haptic button press events - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; private: - smVec3d hapticPosition; ///< position of the haptic device end effector + core::Vec3d hapticPosition; ///< position of the haptic device end effector bool hapticButtonPressed; ///< true of the button is pressed }; diff --git a/src/Tools/curvedGrasper.cpp b/src/Tools/curvedGrasper.cpp index af38fac7e82481fdc8346198f5e67466f32c690a..50b8b031022b60b70b29eeb723495c1dd26b1c3b 100644 --- a/src/Tools/curvedGrasper.cpp +++ b/src/Tools/curvedGrasper.cpp @@ -41,29 +41,29 @@ curvedGrasper::curvedGrasper(size_t p_PhantomID, maxangle = 10 * 3.14 / 360; this->phantomID = p_PhantomID; - smMatrix33d rot; + Matrix33d rot; mesh_pivot = new smSurfaceMesh(SMMESH_RIGID, NULL); mesh_pivot->loadMesh(p_pivotModelFileName, SM_FILETYPE_3DS); - mesh_pivot->scale(smVec3d(0.5, 0.5, 0.5)); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitX()).matrix(); + mesh_pivot->scale(core::Vec3d(0.5, 0.5, 0.5)); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); mesh_pivot->rotate(rot); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitZ()).matrix(); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitZ()).matrix(); mesh_pivot->rotate(rot); mesh_upperJaw = new smSurfaceMesh(SMMESH_RIGID, NULL); mesh_upperJaw->loadMesh(p_upperModelFileName, SM_FILETYPE_3DS); - mesh_upperJaw->scale(smVec3d(0.5, 0.5, 0.5)); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitY()).matrix(); + mesh_upperJaw->scale(core::Vec3d(0.5, 0.5, 0.5)); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitY()).matrix(); mesh_upperJaw->rotate(rot); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitZ()).matrix(); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitZ()).matrix(); mesh_upperJaw->rotate(rot); mesh_lowerJaw = new smSurfaceMesh(SMMESH_RIGID, NULL); mesh_lowerJaw->loadMesh(p_lowerModelFileName, SM_FILETYPE_3DS); - mesh_lowerJaw->scale(smVec3d(0.5, 0.5, 0.5)); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitY()).matrix(); + mesh_lowerJaw->scale(core::Vec3d(0.5, 0.5, 0.5)); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitY()).matrix(); mesh_lowerJaw->rotate(rot); - rot = Eigen::AngleAxisd(-SM_PI_HALF, smVec3d::UnitZ()).matrix(); + rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitZ()).matrix(); mesh_lowerJaw->rotate(rot); meshContainer_pivot.name = "curvedGrasperPivot"; @@ -84,7 +84,7 @@ curvedGrasper::curvedGrasper(size_t p_PhantomID, DAQdataID = 0; } -void curvedGrasper::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) +void curvedGrasper::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) { if(!this->isListening()) { @@ -96,7 +96,7 @@ void curvedGrasper::handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) { smMeshContainer *containerLower = this->getMeshContainer("curvedGrasperLower"); smMeshContainer *containerUpper = this->getMeshContainer("curvedGrasperUpper"); - smMatrix44d godPosMat = hapticEvent->getTransform(); + Matrix44d godPosMat = hapticEvent->getTransform(); transRot = godPosMat; pos = hapticEvent->getPosition(); vel = hapticEvent->getVelocity(); diff --git a/src/Tools/curvedGrasper.h b/src/Tools/curvedGrasper.h index 6335e17bd175aa6646cf484a7fd4346f29714fc3..4c8553df7fac29633b69f43b8ff3c9e66c24c4fe 100644 --- a/src/Tools/curvedGrasper.h +++ b/src/Tools/curvedGrasper.h @@ -30,7 +30,7 @@ namespace mstk { namespace Event { - class smEvent; + class Event; class smEventHandler; class smCameraEvent; } @@ -47,7 +47,7 @@ public: const std::string& p_upperModelFileName = "../../resources/models/curved_lower.3DS"); /// \brief event handler - void handleEvent(std::shared_ptr<mstk::Event::smEvent> p_event) override; + void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; /// \brief for open and close motion void updateOpenClose(); @@ -66,7 +66,7 @@ public: #ifdef smNIUSB6008DAQ smPipeRegisteration NIUSB6008pipeReg; // #endif - smVec3d godPos; // god object position + core::Vec3d godPos; // god object position double godMat[9]; // god object matrix int DAQdataID; // interface for DAQ double minValue; // read min data value