diff --git a/Modules/Simulation/files.cmake b/Modules/Simulation/files.cmake index c8d5eae9a9..21cf69321b 100644 --- a/Modules/Simulation/files.cmake +++ b/Modules/Simulation/files.cmake @@ -1,31 +1,32 @@ set(CPP_FILES mitkGetSimulationService.cpp mitkExportMitkVisitor.cpp mitkIndexROI.cpp mitkISimulationService.cpp + mitkPlaneIntersectionVisitor.cpp mitkRoundRobinSchedulingAlgorithm.cpp mitkSetVtkRendererVisitor.cpp mitkSchedulableProcess.cpp mitkScheduler.cpp mitkSchedulingAlgorithmBase.cpp mitkSimulation.cpp mitkSimulationActivator.cpp mitkSimulationGLMapper2D.cpp mitkSimulationInteractor.cpp mitkSimulationIOFactory.cpp mitkSimulationObjectFactory.cpp mitkSimulationReader.cpp mitkSimulationSerializer.cpp mitkSimulationService.cpp mitkSimulationVtkMapper3D.cpp mitkSimulationWriter.cpp mitkSimulationWriterFactory.cpp mitkVtkModel.cpp mitkVtkSimulationPolyDataMapper.cpp mitkWeightedRoundRobinSchedulingAlgorithm.cpp ) set(RESOURCE_FILES Interactions/Simulation.xml Interactions/SimulationConfig.xml ) diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp b/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp new file mode 100644 index 0000000000..0cb4e5dbcd --- /dev/null +++ b/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkPlaneIntersectionVisitor.h" +#include + +mitk::PlaneIntersectionVisitor::PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params) + : Visitor(params), + m_Point(point), + m_Normal(normal) +{ +} + +mitk::PlaneIntersectionVisitor::~PlaneIntersectionVisitor() +{ +} + +sofa::simulation::Visitor::Result mitk::PlaneIntersectionVisitor::processNodeTopDown(sofa::simulation::Node* node) +{ + for_each(this, node, node->visualModel, &PlaneIntersectionVisitor::processVisualModel); + return RESULT_CONTINUE; +} + +void mitk::PlaneIntersectionVisitor::processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel) +{ + using sofa::component::visualmodel::VisualModelImpl; + + VisualModelImpl* visualModelImpl = dynamic_cast(visualModel); +} diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.h b/Modules/Simulation/mitkPlaneIntersectionVisitor.h new file mode 100644 index 0000000000..487eb8860f --- /dev/null +++ b/Modules/Simulation/mitkPlaneIntersectionVisitor.h @@ -0,0 +1,46 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef mitkPlaneIntersectionVisitor_h +#define mitkPlaneIntersectionVisitor_h + +#include +#include +#include +#include + +namespace mitk +{ + class MitkSimulation_EXPORT PlaneIntersectionVisitor : public sofa::simulation::Visitor + { + public: + PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); + ~PlaneIntersectionVisitor(); + + Result processNodeTopDown(sofa::simulation::Node* node); + + private: + PlaneIntersectionVisitor(const PlaneIntersectionVisitor&); + PlaneIntersectionVisitor& operator=(const PlaneIntersectionVisitor&); + + void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); + + Point3D m_Point; + Vector3D m_Normal; + }; +} + +#endif diff --git a/Modules/Simulation/mitkSimulationGLMapper2D.cpp b/Modules/Simulation/mitkSimulationGLMapper2D.cpp index 254c57e640..2996ba5a0d 100644 --- a/Modules/Simulation/mitkSimulationGLMapper2D.cpp +++ b/Modules/Simulation/mitkSimulationGLMapper2D.cpp @@ -1,69 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkGetSimulationService.h" -#include "mitkISimulationService.h" -#include "mitkSetVtkRendererVisitor.h" +#include "mitkPlaneIntersectionVisitor.h" #include "mitkSimulation.h" #include "mitkSimulationGLMapper2D.h" -#include void mitk::SimulationGLMapper2D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) { if (node != NULL) { Superclass::SetDefaultProperties(node, renderer, overwrite); } } mitk::SimulationGLMapper2D::SimulationGLMapper2D() - : m_SimulationService(GetSimulationService()) { } mitk::SimulationGLMapper2D::~SimulationGLMapper2D() { } void mitk::SimulationGLMapper2D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) { } void mitk::SimulationGLMapper2D::Paint(BaseRenderer* renderer) { if (renderer == NULL) return; SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController(); if (sliceNavigationController == NULL) return; const PlaneGeometry* planeGeometry = sliceNavigationController->GetCurrentPlaneGeometry(); if (planeGeometry == NULL) return; DataNode* dataNode = this->GetDataNode(); if (dataNode == NULL) return; Simulation* simulation = static_cast(dataNode->GetData()); if (simulation == NULL) return; + + PlaneIntersectionVisitor planeIntersectionVisitor(planeGeometry->GetOrigin(), planeGeometry->GetNormal()); + simulation->GetRootNode()->executeVisitor(&planeIntersectionVisitor); } diff --git a/Modules/Simulation/mitkSimulationGLMapper2D.h b/Modules/Simulation/mitkSimulationGLMapper2D.h index 21c53c87be..b58d72974e 100644 --- a/Modules/Simulation/mitkSimulationGLMapper2D.h +++ b/Modules/Simulation/mitkSimulationGLMapper2D.h @@ -1,50 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkSimulationGLMapper2D_h #define mitkSimulationGLMapper2D_h #include #include namespace mitk { - class ISimulationService; - class MitkSimulation_EXPORT SimulationGLMapper2D : public GLMapper { public: static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false); mitkClassMacro(SimulationGLMapper2D, GLMapper); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void ApplyColorAndOpacityProperties(BaseRenderer* renderer, vtkActor* actor = NULL); void Paint(BaseRenderer* renderer); private: SimulationGLMapper2D(); ~SimulationGLMapper2D(); SimulationGLMapper2D(const Self&); Self& operator=(const Self&); - - ISimulationService* m_SimulationService; }; } #endif