diff --git a/Source/Common/CMakeLists.txt b/Source/Common/CMakeLists.txt index b0481037b7c98eb248e67265bf5f0b17a679f499..c79c608b43470756b3635d4df1d0f732a208abe0 100644 --- a/Source/Common/CMakeLists.txt +++ b/Source/Common/CMakeLists.txt @@ -7,7 +7,6 @@ imstk_add_library( Common Eigen3::Eigen g3log tbb - # tsimd ) #----------------------------------------------------------------------------- diff --git a/Source/Common/TaskGraph/imstkTaskGraph.h b/Source/Common/TaskGraph/imstkTaskGraph.h index b38b474df84053e74b8a2056a7e2675471700ea2..1cdacadee1dc28897d33aa07c693cd1386009915 100644 --- a/Source/Common/TaskGraph/imstkTaskGraph.h +++ b/Source/Common/TaskGraph/imstkTaskGraph.h @@ -142,7 +142,7 @@ public: void addEdge(std::shared_ptr<TaskNode> srcNode, std::shared_ptr<TaskNode> destNode); /// - /// \brief Attachs another TaskGraph as a subgraph (copies nodes and edges, then connects source->subgraph::source, subgraph::sink->sink), + /// \brief Attaches another TaskGraph as a subgraph (copies nodes and edges, then connects source->subgraph::source, subgraph::sink->sink), /// source and sink must exist in this graph. Also serves as a graph sum between this and subgraph /// void nestGraph(std::shared_ptr<TaskGraph> subgraph, std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink); @@ -190,7 +190,7 @@ public: static std::shared_ptr<TaskGraph> resolveCriticalNodes(std::shared_ptr<TaskGraph> graph); /// - /// \brief Remove redudant edges. Removal is such that all vertices are still reachable and graph goes from source->sink + /// \brief Remove redundant edges. Removal is such that all vertices are still reachable and graph goes from source->sink /// returns nullptr if failed. Only fails if graph is cyclic. /// static std::shared_ptr<TaskGraph> transitiveReduce(std::shared_ptr<TaskGraph> graph); diff --git a/Source/Common/imstkEventObject.h b/Source/Common/imstkEventObject.h index 79b5eede77a2e20935758842dd10c065f891ee51..aa2dd08cbe0357c2f06e36f60f473180601f8f80 100644 --- a/Source/Common/imstkEventObject.h +++ b/Source/Common/imstkEventObject.h @@ -102,10 +102,10 @@ static void disconnect(EventObject*, EventObject*, std::string (*)()); /// \class EventObject /// /// \brief EventObject is the base class for all objects in iMSTK that -/// can recieve and emit events. It supports direct and queued observer functions. -/// Direct observers recieve events immediately on the same thread +/// can receive and emit events. It supports direct and queued observer functions. +/// Direct observers receive events immediately on the same thread /// This can either be posted on an object or be a function pointer -/// Queued observers recieve events within their queue which they can process whenever +/// Queued observers receive events within their queue which they can process whenever /// they like. /// These can be connected with the connect/queuedConnect/disconnect functions /// \todo ThreadObject affinity diff --git a/Source/Common/imstkModule.cpp b/Source/Common/imstkModule.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6ce00bc20289e447dae2335cce8ec86f886e0027 --- /dev/null +++ b/Source/Common/imstkModule.cpp @@ -0,0 +1,59 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#include "imstkModule.h" + +namespace imstk +{ +void +Module::update() +{ + if (m_init && !m_paused) + { + if (sleepDelay != 0.0) + { + std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(sleepDelay)); + } + + if (muteUpdateEvents) + { + this->updateModule(); + } + else + { + this->postEvent(Event(Module::preUpdate())); + this->updateModule(); + this->postEvent(Event(Module::postUpdate())); + } + } +} + +void +Module::uninit() +{ + // Can only uninit if, init'd + if (m_init) + { + uninitModule(); + m_init = false; + } +} +}// imstk diff --git a/Source/Common/imstkModule.h b/Source/Common/imstkModule.h index 7d2f88e7cf8f39f9d7add0c69664980c26c724f0..724083eaa06cddee5ad807a5b3ddf60bfb6180fa 100644 --- a/Source/Common/imstkModule.h +++ b/Source/Common/imstkModule.h @@ -74,7 +74,7 @@ public: public: /// - /// \brief Get/Set the timestep + /// \brief Get/Set the time step /// double getDt() const { return m_dt; } void setDt(const double dt) { m_dt = dt; } @@ -90,6 +90,9 @@ public: bool getPaused() const { return m_paused; } void setPaused(const bool paused) { m_paused = paused; } + /// + /// \brief Set/Get the execution type (see imstk::ExecutionType) + /// ExecutionType getExecutionType() const { return m_executionType; } void setExecutionType(const ExecutionType type) { m_executionType = type; } @@ -101,37 +104,9 @@ public: public: void init() { m_init = initModule(); } - void update() - { - if (m_init && !m_paused) - { - if (sleepDelay != 0.0) - { - std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(sleepDelay)); - } - - if (muteUpdateEvents) - { - this->updateModule(); - } - else - { - this->postEvent(Event(Module::preUpdate())); - this->updateModule(); - this->postEvent(Event(Module::postUpdate())); - } - } - } - - void uninit() - { - // Can only uninit if, init'd - if (m_init) - { - uninitModule(); - m_init = false; - } - } + void update(); + + void uninit(); public: virtual bool initModule() = 0; diff --git a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp index 718501404790638fd2b796f7b816196a0acb8718..19a809dd792811a57bf38fa82ddeef9a2b0f91d1 100644 --- a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp +++ b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp @@ -418,7 +418,6 @@ VTKRenderer::updateCamera() m_camera->SetViewUp(up[0], up[1], up[2]); m_camera->SetViewAngle(cam->getFieldOfView()); m_camera->SetClippingRange(cam->getNearZ(), cam->getFarZ()); - m_camera->SetClippingRange(cam->getNearZ(), cam->getFarZ()); } void diff --git a/Source/Scene/imstkInteractionPair.h b/Source/Scene/imstkInteractionPair.h index 585bba397924de58261c2c42101784a6416ee2bf..7714d919217b4bff94b8218b5778136eb57f9ce6 100644 --- a/Source/Scene/imstkInteractionPair.h +++ b/Source/Scene/imstkInteractionPair.h @@ -50,10 +50,10 @@ public: const Outputs& getTaskNodeOutputs() const { return m_taskNodeOutputs; } public: - /// - /// \brief Modifies the computational graph - /// - void compute(); +/// +/// \brief Modifies the computational graph +/// +//void compute(); protected: Inputs m_taskNodeInputs; ///> The interacting nodes diff --git a/Source/Scene/imstkObjectInteractionPair.h b/Source/Scene/imstkObjectInteractionPair.h index 35f92499ecd7ccef9b60aad126cae80eaa563c0e..14bed089b129dd1cf92e6668352c52469559ad16 100644 --- a/Source/Scene/imstkObjectInteractionPair.h +++ b/Source/Scene/imstkObjectInteractionPair.h @@ -31,7 +31,7 @@ class SceneObject; /// \class ObjectInteractionPair /// /// \brief This class defines an interaction between two SceneObjects -/// An interaction is a function occuring between two SceneObjects at some point +/// An interaction is a function occurring between two SceneObjects at some point /// class ObjectInteractionPair : public InteractionPair { @@ -46,7 +46,7 @@ protected: virtual ~ObjectInteractionPair() override = default; public: - /// \brief TODO + /// \brief Return the pair of scene objects involved in the interaction const SceneObjectPair& getObjectsPair() const { return m_objects; } public: diff --git a/Source/Scene/imstkPbdObjectCuttingPair.h b/Source/Scene/imstkPbdObjectCuttingPair.h index f045183f2ce511a857116b345e06f688155d3669..3f9a2d9f63103a70b22763ffe4113fc15c4f6122 100644 --- a/Source/Scene/imstkPbdObjectCuttingPair.h +++ b/Source/Scene/imstkPbdObjectCuttingPair.h @@ -71,7 +71,7 @@ protected: std::shared_ptr<VecDataArray<int, 3>> elements); /// - /// \brief Modify exsiting elements of pbdObj + /// \brief Modify existing elements of pbdObj /// void modifyTriangles(std::shared_ptr<SurfaceMesh> pbdMesh, std::shared_ptr<std::vector<size_t>> elementIndices, diff --git a/Source/SceneEntities/Camera/imstkCamera.cpp b/Source/SceneEntities/Camera/imstkCamera.cpp new file mode 100644 index 0000000000000000000000000000000000000000..945d1ded6a2830b5bb64a2981cbc679527e9ca88 --- /dev/null +++ b/Source/SceneEntities/Camera/imstkCamera.cpp @@ -0,0 +1,33 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#include "imstkCamera.h" + +namespace imstk +{ +void +Camera::print() +{ + std::cout << "CamPos: " << m_position[0] << ", " << m_position[1] << ", " << m_position[2] << std::endl; + std::cout << "FocalPoint: " << m_focalPoint[0] << ", " << m_focalPoint[1] << ", " << m_focalPoint[2] << std::endl; + std::cout << "Up: " << m_viewUp[0] << ", " << m_viewUp[1] << ", " << m_viewUp[2] << std::endl; +} +} \ No newline at end of file diff --git a/Source/SceneEntities/Camera/imstkCamera.h b/Source/SceneEntities/Camera/imstkCamera.h index a4e84dd8747bcc052f74e86a681204cea8a90d37..b5f2d368ae83d71179f30f403155904f26b3e219 100644 --- a/Source/SceneEntities/Camera/imstkCamera.h +++ b/Source/SceneEntities/Camera/imstkCamera.h @@ -81,44 +81,34 @@ public: /// \brief Get camera view matrix /// \returns Camera view matrix reference /// - Mat4d& getView() { return m_view; } + inline Mat4d& getView() { return m_view; } /// /// \brief Get the inverse view matrix /// - const Mat4d& getInvView() { return m_invView; } + inline const Mat4d& getInvView() { return m_invView; } /// /// \brief Set the camera view matrix /// - void setView(const Mat4d& view) + inline void setView(const Mat4d& view) { m_viewModified = false; m_view = view; m_invView = m_view.inverse(); } - /// - /// \brief Get camera projection matrix - /// - //const Mat4d& getProj() { return m_proj; } - - /// - /// \brief Set camera projection matrix - /// - //void setProj(const Mat4d& proj) { m_proj = proj; } - /// /// \brief Gets the field of view /// \returns vertical field of view in degrees /// - const double getFieldOfView() const { return m_fieldOfView; } + inline const double getFieldOfView() const { return m_fieldOfView; } /// /// \brief Sets the field of view /// \param vertical field of view in degrees /// - void setFieldOfView(const double fov) + inline void setFieldOfView(const double fov) { m_fieldOfView = fov; //m_projModified = true; @@ -129,20 +119,19 @@ public: /// note: You lose depth accuracy as the range between near and far increases /// could cause z fighting /// - void setNearZ(const double nearZ) { m_nearZ = nearZ; } - - const double getNearZ() const { return m_nearZ; } + inline void setNearZ(const double nearZ) { m_nearZ = nearZ; } + inline const double getNearZ() const { return m_nearZ; } /// /// \brief Set clipping near /// note: You lose depth accuracy as the range between near and far increases /// could cause z fighting /// - void setFarZ(const double farZ) { m_farZ = farZ; } + inline void setFarZ(const double farZ) { m_farZ = farZ; } - const double getFarZ() const { return m_farZ; } + inline const double getFarZ() const { return m_farZ; } - virtual void update() + inline virtual void update() { if (m_viewModified) { @@ -156,25 +145,24 @@ public: }*/ } -public: /// /// \brief Gets the camera position /// \returns camera position /// - const Vec3d& getPosition() const { return m_position; } + inline const Vec3d& getPosition() const { return m_position; } /// /// \brief Sets the camera position /// - void setPosition(const Vec3d& pos) + inline void setPosition(const Vec3d& pos) { m_position = pos; m_viewModified = true; } - void setPosition(const double x, - const double y, - const double z) + inline void setPosition(const double x, + const double y, + const double z) { setPosition(Vec3d(x, y, z)); } @@ -184,20 +172,20 @@ public: /// The focal point is the point that the camera points to /// \returns Focal point position /// - const Vec3d& getFocalPoint() const { return m_focalPoint; } + inline const Vec3d& getFocalPoint() const { return m_focalPoint; } /// /// \brief Sets the focal point /// - void setFocalPoint(const Vec3d& focalPt) + inline void setFocalPoint(const Vec3d& focalPt) { m_focalPoint = focalPt; m_viewModified = true; } - void setFocalPoint(const double x, - const double y, - const double z) + inline void setFocalPoint(const double x, + const double y, + const double z) { setFocalPoint(Vec3d(x, y, z)); } @@ -206,20 +194,20 @@ public: /// \brief Get the up vector /// \returns up vector of camera /// - const Vec3d& getViewUp() const { return m_viewUp; } + inline const Vec3d& getViewUp() const { return m_viewUp; } /// /// \brief Set the up vector /// - void setViewUp(const Vec3d& up) + inline void setViewUp(const Vec3d& up) { m_viewUp = up.normalized(); m_viewModified = true; } - void setViewUp(const double x, - const double y, - const double z) + inline void setViewUp(const double x, + const double y, + const double z) { setViewUp(Vec3d(x, y, z)); } @@ -227,12 +215,7 @@ public: /// /// \brief Utility function to quickly print cam stats /// - void print() - { - std::cout << "CamPos: " << m_position[0] << ", " << m_position[1] << ", " << m_position[2] << std::endl; - std::cout << "FocalPoint: " << m_focalPoint[0] << ", " << m_focalPoint[1] << ", " << m_focalPoint[2] << std::endl; - std::cout << "Up: " << m_viewUp[0] << ", " << m_viewUp[1] << ", " << m_viewUp[2] << std::endl; - } + void print(); protected: // Base camera values @@ -242,7 +225,6 @@ protected: bool m_viewModified = true; //bool m_projModified = true; -protected: // Base projection parameters double m_fieldOfView = 40.0; ///> field of view in degrees double m_nearZ = 0.01; ///> near plane of the camera diff --git a/Source/SceneEntities/Lights/imstkLight.h b/Source/SceneEntities/Lights/imstkLight.h index 8b2106aaf4f307e1f6ea4ec5292b7d2b9715f424..e3e5c96998a883992bb48dfcb0402335fbc94ec8 100644 --- a/Source/SceneEntities/Lights/imstkLight.h +++ b/Source/SceneEntities/Lights/imstkLight.h @@ -77,11 +77,6 @@ public: /// void switchOn() { m_switchState = true; } - /// - /// \brief Get the status (On/off) of the light - /// - bool isOff() const { return m_switchState; } - /// /// \brief Switch the light Off /// @@ -105,7 +100,7 @@ public: /// /// \brief Set the light intensity. This value is unbounded. /// - void setIntensity(double intensity) { m_intensity = (float)intensity; } + void setIntensity(const double intensity) { m_intensity = (float)intensity; } protected: Light(const LightType& type) : SceneEntity(), m_type(type) { } diff --git a/Source/SceneEntities/Objects/imstkAnimationModel.h b/Source/SceneEntities/Objects/imstkAnimationModel.h index 924fe863291df26ac3f4863d4641c2c1140634e9..66c2f16d1919bb84ec6883e2b5c39fa18f15883a 100644 --- a/Source/SceneEntities/Objects/imstkAnimationModel.h +++ b/Source/SceneEntities/Objects/imstkAnimationModel.h @@ -37,7 +37,6 @@ public: /// \brief Constructor /// explicit AnimationModel(std::shared_ptr<Geometry> geometry); - AnimationModel() = delete; /// diff --git a/Source/SceneEntities/Objects/imstkVisualModel.cpp b/Source/SceneEntities/Objects/imstkVisualModel.cpp index 1b3f017a333c77d85f83065fc6951493d91c713f..74f58c226ab18a3d94f13862797d080b5103be77 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.cpp +++ b/Source/SceneEntities/Objects/imstkVisualModel.cpp @@ -50,6 +50,20 @@ VisualModel::VisualModel() : m_renderMaterial(std::make_shared<RenderMaterial>() { } +void +VisualModel::setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial) +{ + m_renderMaterial = renderMaterial; + this->postModified(); +} + +void +VisualModel::setIsVisible(const bool visible) +{ + m_isVisible = visible; + this->postModified(); +} + bool VisualModel::getRenderDelegateCreated(Renderer* ren) { diff --git a/Source/SceneEntities/Objects/imstkVisualModel.h b/Source/SceneEntities/Objects/imstkVisualModel.h index 8fab729f22db2e7ac1e67050ea1a9e7f9e797534..21494f9be3af683e42f000500ca2a08c46acd5ec 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.h +++ b/Source/SceneEntities/Objects/imstkVisualModel.h @@ -81,11 +81,7 @@ public: /// /// \brief Set/Get render material /// - void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial) - { - m_renderMaterial = renderMaterial; - this->postModified(); - } + void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial); std::shared_ptr<RenderMaterial> getRenderMaterial() const { return m_renderMaterial; } @@ -95,11 +91,7 @@ public: void show() { setIsVisible(true); } void hide() { setIsVisible(false); } bool isVisible() const { return m_isVisible; } - void setIsVisible(const bool visible) - { - m_isVisible = visible; - this->postModified(); - } + void setIsVisible(const bool visible); /// /// \brief Get/Set whether the delegate has been created