diff --git a/Modules/Bundles/org.mitk.gui.qt.igttoolpairnavigation/src/internal/QmitkToolPairNavigationView.cpp b/Modules/Bundles/org.mitk.gui.qt.igttoolpairnavigation/src/internal/QmitkToolPairNavigationView.cpp index 1addee4b15..d388fe4318 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttoolpairnavigation/src/internal/QmitkToolPairNavigationView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.igttoolpairnavigation/src/internal/QmitkToolPairNavigationView.cpp @@ -1,401 +1,400 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ Version: $Revision: 17495 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkToolPairNavigationView.h" #include "QmitkNDIConfigurationWidget.h" #include "QmitkUpdateTimerWidget.h" #include "QmitkToolDistanceWidget.h" #include "mitkNodePredicateDataType.h" -#include #include "QmitkDataStorageComboBox.h" #include "QmitkStdMultiWidget.h" #include #include #include #include #include #include #include #include #include #define WARN LOG_WARN("ToolPairNavigation") const std::string QmitkToolPairNavigationView::VIEW_ID = "org.mitk.views.toolpairnavigation"; QmitkToolPairNavigationView::QmitkToolPairNavigationView() : QmitkFunctionality(), m_MultiWidget(NULL) { } QmitkToolPairNavigationView::~QmitkToolPairNavigationView() { delete m_NDIConfigWidget; delete m_DistanceWidget; m_NDIConfigWidget = NULL; m_DistanceWidget = NULL; m_Source = NULL; m_Visualizer = NULL; m_CameraVisualizer = NULL; } void QmitkToolPairNavigationView::CreateQtPartControl(QWidget *parent) { // create GUI widgets m_Controls.setupUi(parent); this->CreateBundleWidgets(parent); this->CreateConnections(); } void QmitkToolPairNavigationView::CreateBundleWidgets(QWidget* parent) { //get default data storage //mitk::DataStorage* ds = this->GetDefaultDataStorage(); //instanciate widget m_NDIConfigWidget = new QmitkNDIConfigurationWidget(parent); m_DistanceWidget = new QmitkToolDistanceWidget(parent); // removes all placeholder tabs from the toolbox that where created in the qt designer before int tabnr = this->m_Controls.m_ToolBox->count(); for(int i=0; i < tabnr ;i++) { this->m_Controls.m_ToolBox->removeItem(0); } // inserts this bundle's widgets into the toolbox this->m_Controls.m_ToolBox->insertItem(0,m_NDIConfigWidget,QString("Configuration")); this->m_Controls.m_ToolBox->insertItem(1,m_DistanceWidget,QString("Distances")); } void QmitkToolPairNavigationView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkToolPairNavigationView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkToolPairNavigationView::CreateConnections() { connect( m_NDIConfigWidget, SIGNAL(Connected()), this, SLOT(SetNavigationUp())); connect( m_NDIConfigWidget, SIGNAL(Connected()), this->m_Controls.m_RenderingTimerWidget, SLOT(EnableWidget())); connect( m_NDIConfigWidget, SIGNAL(Disconnected()), this, SLOT(Disconnected())); connect( m_NDIConfigWidget, SIGNAL(Disconnected()), this->m_Controls.m_RenderingTimerWidget, SLOT(DisableWidget())); //to be implemented for tool name changig e.g. // connect(m_NDIConfigWidget, SIGNAL(ToolsChanged()), this, SLOT(ToolsChanged())); } void QmitkToolPairNavigationView::Activated() { QmitkFunctionality::Activated(); //switch to 3D rendering mode in Widget3 m_LastMapperIDWidget3 = mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow())->GetMapperID(); mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow())->SetMapperID(2); mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget2->GetRenderWindow())->SetMapperID(2); } void QmitkToolPairNavigationView::Deactivated() { QmitkFunctionality::Deactivated(); //switch back cameravisualization view in Widget3 mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow())->SetMapperID(m_LastMapperIDWidget3); mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget2->GetRenderWindow())->SetMapperID(1); } void QmitkToolPairNavigationView::Disconnected() { if(m_Controls.m_RenderingTimerWidget != NULL) { this->m_Controls.m_RenderingTimerWidget->StopTimer(); } if(m_Source.IsNotNull() && m_Source->IsTracking()) { this->m_Source->StopTracking(); } this->DestroyIGTPipeline(); this->RemoveVisualizationObjects(this->GetDefaultDataStorage()); if(this->m_DistanceWidget != NULL) this->m_DistanceWidget->ClearDistanceMatrix(); } void QmitkToolPairNavigationView::ToolsAdded( QStringList /*tools*/ ) { } void QmitkToolPairNavigationView::SetNavigationUp() { if (m_Source.IsNotNull()) if (m_Source->IsTracking()) return; mitk::DataStorage* ds = this->GetDefaultDataStorage(); if (ds == NULL) { QMessageBox::warning(NULL, "ToolPairNavigation: Error", "can not access DataStorage. Navigation not possible"); return; } //1. build up the filter pipeline try { this->SetupIGTPipeline(); } catch(std::exception& e) { QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while building the IGT-Pipeline: %1").arg(e.what())); this->DestroyIGTPipeline(); return; } catch (...) { QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while building the IGT-Pipeline.")); this->DestroyIGTPipeline(); return; } //2. start IGT pipeline to display tracking devices (20 Hz update rate -> 50 msec timeout) try { // setup for the bundle's update timer widget m_Controls.m_RenderingTimerWidget->SetPurposeLabelText(QString("Navigation")); m_Controls.m_RenderingTimerWidget->SetTimerInterval( 50 ); connect( m_Controls.m_RenderingTimerWidget->GetUpdateTimer() , SIGNAL(timeout()) , this, SLOT (RenderScene()) ); connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Started()), this, SLOT(StartNavigation())); connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Stopped()) , this, SLOT (StopNavigation())); connect( m_Controls.m_RenderingTimerWidget, SIGNAL(Stopped()) , m_DistanceWidget, SLOT (SetDistanceLabelValuesInvalid())); } catch(std::exception& e) { QMessageBox::warning(NULL, "ToolPairNavigation: Error", QString("Error while starting the IGT-Pipeline: %1").arg(e.what())); this->m_Controls.m_RenderingTimerWidget->StopTimer(); this->DestroyIGTPipeline(); return; } } void QmitkToolPairNavigationView::StartNavigation() { if(m_Source.IsNotNull() && !m_Source->IsTracking()) { m_Source->StartTracking(); // creates the matrix with distances from the tracking source's outputs m_DistanceWidget->CreateToolDistanceMatrix(m_Source->GetOutputs()); } } // is for tool changing events, like name changes void QmitkToolPairNavigationView::ToolsChanged() { } void QmitkToolPairNavigationView::StopNavigation() { if(m_Source.IsNotNull() && m_Source->IsTracking()) { m_Source->StopTracking(); } } void QmitkToolPairNavigationView::SetupIGTPipeline() { mitk::DataStorage* ds = this->GetDefaultDataStorage(); // check if dataStorage is available if (ds == NULL) throw std::invalid_argument("DataStorage not available"); mitk::TrackingDevice::Pointer tracker = m_NDIConfigWidget->GetTracker(); // get current tracker from the configuration widget if (tracker.IsNull()) // check if tracker is valid throw std::invalid_argument("tracking device is NULL."); m_Source = mitk::TrackingDeviceSource::New(); // create a new source for the IGT filter pipeline m_Source->SetTrackingDevice(tracker); // set the found tracker to the source m_Visualizer = mitk::NavigationDataObjectVisualizationFilter::New(); // filter to display NDs m_CameraVisualizer = mitk::CameraVisualization::New(); //set widget 3 m_CameraVisualizer->SetRenderer(mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow())); //set viewing direction mitk::Vector3D viewVector; mitk::FillVector3D( viewVector, 0.0, 0.0, 1.0 ); m_CameraVisualizer->SetDirectionOfProjectionInToolCoordinates(viewVector); /* prepare visualization objects and filter */ for (unsigned int i = 0; i < m_Source->GetNumberOfOutputs(); ++i) //for each connected tool { m_Visualizer->SetInput(i, m_Source->GetOutput(i)); // set input for visualization filter const char* toolName = tracker->GetTool(i)->GetToolName(); mitk::DataNode::Pointer toolrepresentationNode = ds->GetNamedNode(toolName); if (toolrepresentationNode.IsNull()) { //the first tool represents the tool to guide //it will be represented as cone wheras the target tools will be represented by a sphere if (i<1) //tool to guide { toolrepresentationNode = this->CreateConeAsInstrumentVisualization(toolName); m_CameraVisualizer->SetInput(m_Source->GetOutput(i)); } else toolrepresentationNode = this->CreateSphereAsInstrumentVisualization(toolName); ds->Add(toolrepresentationNode); } m_Visualizer->SetRepresentationObject(i, toolrepresentationNode->GetData()); // set instrument nodes as baseData for visualisation filter } } void QmitkToolPairNavigationView::DestroyIGTPipeline() { if (m_Source.IsNotNull()) { m_Source->StopTracking(); m_Source->Disconnect(); m_Source = NULL; } m_Visualizer = NULL; m_CameraVisualizer = NULL; } mitk::DataNode::Pointer QmitkToolPairNavigationView::CreateConeAsInstrumentVisualization(const char* label) { //new data mitk::Cone::Pointer activeToolData = mitk::Cone::New(); vtkConeSource* vtkData = vtkConeSource::New(); vtkData->SetRadius(3.0); vtkData->SetHeight(6.0); vtkData->SetDirection(0.0, 0.0, 1.0); //(0.0, 0.0, -1.0) for 5DoF vtkData->SetCenter(0.0, 0.0, 0.0); vtkData->SetResolution(20); vtkData->CappingOn(); vtkData->Update(); activeToolData->SetVtkPolyData(vtkData->GetOutput()); vtkData->Delete(); //new node mitk::DataNode::Pointer coneNode = mitk::DataNode::New(); coneNode->SetData(activeToolData); coneNode->GetPropertyList()->SetProperty("name", mitk::StringProperty::New ( label ) ); coneNode->GetPropertyList()->SetProperty("layer", mitk::IntProperty::New(0)); coneNode->GetPropertyList()->SetProperty("visible",mitk::BoolProperty::New(true)); //don't display in widget 3 (3D camera view) coneNode->SetVisibility(false, mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow())); coneNode->SetColor(1.0,0.0,0.0);//red coneNode->SetOpacity(0.7); coneNode->Modified(); return coneNode; } mitk::DataNode::Pointer QmitkToolPairNavigationView::CreateSphereAsInstrumentVisualization(const char* label) { //new data mitk::Ellipsoid::Pointer activeToolData = mitk::Ellipsoid::New(); vtkSphereSource *vtkData = vtkSphereSource::New(); vtkData->SetRadius(1.0f); vtkData->SetCenter(0.0, 0.0, 0.0); vtkData->Update(); activeToolData->SetVtkPolyData(vtkData->GetOutput()); vtkData->Delete(); //new node mitk::DataNode::Pointer sphereNode = mitk::DataNode::New(); sphereNode->SetData(activeToolData); sphereNode->GetPropertyList()->SetProperty("name", mitk::StringProperty::New ( label ) ); sphereNode->GetPropertyList()->SetProperty("layer", mitk::IntProperty::New(0)); sphereNode->GetPropertyList()->SetProperty("visible",mitk::BoolProperty::New(true)); sphereNode->SetColor(0.0,1.0,0.0);//green sphereNode->SetOpacity(1.0); sphereNode->Modified(); return sphereNode; } void QmitkToolPairNavigationView::RenderScene() { try { if (m_Visualizer.IsNull() || m_CameraVisualizer.IsNull() || this->GetActiveStdMultiWidget() == NULL) return; try { m_Visualizer->Update(); m_CameraVisualizer->Update(); //every tenth update static int counter = 0; if (counter > 9) { this->m_DistanceWidget->ShowDistanceValues(m_Source->GetOutputs()); counter = 0; } else counter++; } catch(std::exception& e) { std::cout << "Exception during QmitkToolPairNavigationView::RenderScene():" << e.what() << "\n"; } //update all Widgets mitk::RenderingManager::GetInstance()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS); } catch (std::exception& e) { std::cout << "RenderAll exception: " << e.what() << "\n"; } catch (...) { std::cout << "RenderAll unknown exception\n"; } } void QmitkToolPairNavigationView::RemoveVisualizationObjects( mitk::DataStorage* ds ) { if (ds != NULL) ds->Remove(ds->GetSubset(mitk::NodePredicateProperty::New("ToolPairNavigation", mitk::BoolProperty::New(true)))); // remove all objects that have the ToolPairNavigation tag } diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp index 3a59f94d5e..71b227d47e 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp @@ -1,104 +1,104 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2011-01-18 13:22:38 +0100 (Di, 18 Jan 2011) $ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkTrackingVolumeGenerator.h" #include "mitkSTLFileReader.h" #include "mitkStandardFileLocations.h" #include "mitkConfig.h" #include #include #include #include #include #include mitk::TrackingVolumeGenerator::TrackingVolumeGenerator() { std::string volumeDir = MITK_ROOT; volumeDir += "Modules/IGT/IGTTrackingDevices/TrackingVolumeData"; //folder which contains the trackingdevices configs mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( volumeDir.c_str(), false ); //add this directory to StdFileLocations for the search - m_TrackingDeviceType ; + m_TrackingDeviceType = mitk::TrackingSystemNotSpecified; } void mitk::TrackingVolumeGenerator::SetTrackingDevice (mitk::TrackingDevice::Pointer tracker) { this->m_TrackingDeviceType = tracker->GetType(); } void mitk::TrackingVolumeGenerator::GenerateData() { mitk::Surface::Pointer output = this->GetOutput();//the surface wich represents the tracking volume std::string filename = ""; switch(m_TrackingDeviceType) { case mitk::ClaronMicron: filename = mitk::StandardFileLocations::GetInstance()->FindFile("ClaronMicron.stl"); break; case mitk::IntuitiveDaVinci: filename = mitk::StandardFileLocations::GetInstance()->FindFile("IntuitiveDaVinci.stl"); break; case mitk::NDIPolaris: filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIPolaris.stl"); break; case mitk::NDIAurora: filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIAurora.stl"); break; case mitk::VirtualTracker: { vtkSmartPointer cubeSource = vtkSmartPointer::New(); double bounds[6]; bounds[0] = bounds[2] = bounds[4] = -400.0; // initialize bounds to -400 ... +400 cube. This is the default value of the bounds[1] = bounds[3] = bounds[5] = 400.0; // virtual tracking device, but it can be changed. In that case, // the tracking volume polydata has be updated manually cubeSource->SetBounds(bounds); cubeSource->GetOutput()->Update(); output->SetVtkPolyData(cubeSource->GetOutput()); //set the vtkCubeSource as polyData of the surface return; } default: { - MITK_INFO<< "No STL to given TrackingDevice found"; + MITK_ERROR<< "No STL to given TrackingDevice found"; return; } } if (filename.empty()) { MITK_ERROR << "Filename is empty"; return; } mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); stlReader->SetFileName( filename.c_str() ); stlReader->Update(); if ( stlReader->GetOutput() == NULL) { MITK_ERROR << "Error while reading file"; return ; } output->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData());//set the visible trackingvolume } diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h index e0417af129..0b1ab0a819 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h @@ -1,85 +1,84 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2011-01-18 13:22:38 +0100 (Di, 18 Jan 2011) $ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKTRACKINGVOLUMEGENERATOR_H #define MITKTRACKINGVOLUMEGENERATOR_H #include "MitkIGTExports.h" #include #include "mitkTrackingTypes.h" #include "mitkTrackingDevice.h" -class vtkPolyData; - namespace mitk { /**Documentation * \brief An instance of this class represents a generator wich generates the tracking volume of a * given tracking device as a mitk:Surface. * - * As it inherits from mitk::Surface it can be - * displayed in the 3D-window of MITK. The coordinate system is the same - * as the coordination system of the tracking device. * To generate the specific dimensions of the tracking volume of a tracking device - * the methods SetTrackingDeviceType() or SetTrackingDevice ()needs to be called first. - * After the method GetOutput(), delivers the generatet TrackingVolume as mitk:Surface + * the methods SetTrackingDeviceType(trackingdevicetype) or SetTrackingDevice (tracker) have to be called first. Otherwise + * the TrackingDeviceType is set to "TrackingSystemNotSpecified". + * After setting the trackingdevice type, the update() method has to be called. + * Now the method GetOutput() delivers the generatet TrackingVolume as mitk:Surface + * + * The coordinate system of die TrackingVolume is the same as the coordination system of the tracking device. * * For tracking devices that have a modifiable tracking volume (e.g. VirtualTrackingDevice, - * this class produces a tracking volume with default values + * this class produces a tracking volume with default values. * * \ingroup IGT */ class MitkIGT_EXPORT TrackingVolumeGenerator : public mitk::SurfaceSource { public: mitkClassMacro(TrackingVolumeGenerator, mitk::SurfaceSource) itkNewMacro(Self); /** * \brief Sets the tracking device type of the volume. After doing this * the tracking volume gets generatet and set to the correct dimensions in the correct * coordinate system. The TV of a VirtualTrackingDevice is always a 400*400 cube. * \param type The type of the tracking device (currently supported:NDIAurora, NDIPolaris, ClaronMicron, IntuitiveDaVinci and the VirtualTracker). */ itkSetMacro(TrackingDeviceType, mitk::TrackingDeviceType); itkGetMacro(TrackingDeviceType, mitk::TrackingDeviceType); /** - * \brief Sets the tracking device of the volume. After doing this + * \brief Sets the tracking device type of the volume. After doing this * the tracking volume gets generatet and is set to the correct dimensions in the correct - * coordinate system. + * coordinate system. The TV of a VirtualTrackingDevice is always a 400*400 cube. * \param tracker The tracking device the tracking volume has to be created for (currently supported:NDIAurora, NDIPolaris, ClaronMicron, IntuitiveDaVinci and the VirtualTracker). */ void SetTrackingDevice(mitk::TrackingDevice::Pointer tracker); protected: TrackingVolumeGenerator(); mitk::TrackingDeviceType m_TrackingDeviceType; void GenerateData(); }; } #endif // MITKTRACKINGVOLUMEGENERATOR_H diff --git a/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.cpp b/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.cpp deleted file mode 100644 index bd06b7e5c4..0000000000 --- a/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkTrackingVolume.h" -#include "mitkSTLFileReader.h" -#include "mitkStandardFileLocations.h" -#include "mitkConfig.h" -#include - - -mitk::TrackingVolume::TrackingVolume() -{ - m_TrackingDeviceType = mitk::TrackingSystemNotSpecified; - - //####### initialize file locations for the volume-STL-files ######### - std::string m_VolumeDir = MITK_ROOT; - m_VolumeDir += "Modules/IGT/IGTTrackingDevices/TrackingVolumeData"; - mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( m_VolumeDir.c_str(), false ); - //#################################################################### - -} - -/* TODO: implementation of method -bool mitk::TrackingVolume::IsInside(mitk::Point3D itkNotUsed(punkt)) -{ -//NOT IMPLEMENTED YET! -return false; -} -*/ - -void mitk::TrackingVolume::SetVolumeManually(vtkPolyData* volume) -{ - this->SetVtkPolyData(volume); -} - -bool mitk::TrackingVolume::SetTrackingDeviceType(TrackingDeviceType type) -{ - // get filename / perform custom initiation - std::string filename = ""; - - switch(type) - { - case mitk::ClaronMicron: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("ClaronMicron.stl"); - break; - case mitk::IntuitiveDaVinci: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("IntuitiveDaVinci.stl"); - break; - case mitk::NDIAurora: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIAurora.stl"); - break; - case mitk::NDIPolaris: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIPolaris.stl"); - break; - case mitk::VirtualTracker: - { - vtkCubeSource* cs = vtkCubeSource::New(); - double bounds[6]; - bounds[0] = bounds[2] = bounds[4] = -400.0; // initialize bounds to -400 ... +400 cube. This is the default value of the - bounds[1] = bounds[3] = bounds[5] = 400.0; // virtual tracking device, but it can be changed. In that case, - // the tracking volume polydata has be updated manually - cs->SetBounds(bounds); - cs->GetOutput()->Update(); - this->SetVtkPolyData(cs->GetOutput()); - cs->Delete(); - return true; - } - default: - return false; - } - - if (filename.empty()) - return false; - - mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); - try - { - stlReader->SetFileName( filename.c_str() ); - stlReader->Update(); - } - catch (...) - { - return false; - } - if ( stlReader->GetOutput() == NULL ) - return false; - - this->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData()); - stlReader = NULL; - return true; -} diff --git a/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.h b/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.h deleted file mode 100644 index b7e263d83c..0000000000 --- a/Modules/IGT/IGTTrackingDevices/mitkTrackingVolume.h +++ /dev/null @@ -1,87 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKTRACKINGVOLUME_H_HEADER_INCLUDED_ -#define MITKTRACKINGVOLUME_H_HEADER_INCLUDED_ - - -#include - -#include "mitkSurface.h" -#include "vtkPolyData.h" -#include "mitkTrackingTypes.h" - -namespace mitk -{ - /**Documentation - * \brief An instance of this class represents the tracking volume of a tracking device. - * - * As it inherits from mitk::Surface it can be - * displayed in the 3D-window of MITK. The coordinate system is the same - * as the coordination system of the tracking device. - * To have the specific dimensions of the tracking volume of a tracking device - * the method SetTrackingDeviceType() needs to be called. - * For tracking devices that have a modifiable tracking volume (e.g. VirtualTrackingDevice, - * this class produces a tracking volume with default values (e.g. that are set in the class' - * constructor - * - * \ingroup IGT - */ - - class MitkIGT_EXPORT TrackingVolume : public mitk::Surface - { - public: - mitkClassMacro(TrackingVolume, mitk::Surface); - itkNewMacro(Self); - - /** - * \brief Sets the tracking device of the volume. After doing this - * the volume is set to the correct dimensions in the correct - * coordinate system. - * \param type The type of the tracking device (something like NDIAurora or NDIPolaris). - * \return Returns true if the type was set successfull, false if not. - */ - bool SetTrackingDeviceType(TrackingDeviceType type); - - /** - * \brief Sets the trackingvolume explicitly. Only use this method if your specific - * trackingvolume is not supported by this class. The type is set to - * TrackingSystemNotSpecified if doing this. - * \param volume The new tracking volume as vtkPolyData. - */ - void SetVolumeManually(vtkPolyData* volume); - - - //brief Checks wether a point is inside or outside the tracking - // volume. - //param p The point which should be checked. - //return Returns true if the point "p" is inside the - // tracking volume, false if not. - // - //bool IsInside(mitk::Point3D p); TODO: implemenation of method - - protected: - TrackingVolume(); - /** - * - * \brief The current type of the corresponding tracking device is hold here. - * If the type is unknown the value is set to TrackingSystemNotSpecified. - */ - TrackingDeviceType m_TrackingDeviceType; - }; -} -#endif // MITKTRACKINGVOLUME_H_HEADER_INCLUDED_ diff --git a/Modules/IGT/Testing/mitkTrackingVolumeTest.cpp b/Modules/IGT/Testing/mitkTrackingVolumeTest.cpp index 52eaf12721..3485376346 100644 --- a/Modules/IGT/Testing/mitkTrackingVolumeTest.cpp +++ b/Modules/IGT/Testing/mitkTrackingVolumeTest.cpp @@ -1,115 +1,109 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include "mitkCommon.h" #include "mitkTestingMacros.h" #include "vtkPolyData.h" #include class mitkTrackingVolumeTestClass { public: static void TestInstantiation() { // let's create an object of our class mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New(); - //MITK_TEST_CONDITION_REQUIRED(myTVGenerator.IsNotNull(),"Testing instantiation") + MITK_TEST_CONDITION_REQUIRED(myTVGenerator.IsNotNull(),"Testing instantiation") } + static void TestTrackingSystemNotSpecified() + { + MITK_TEST_OUTPUT(<<"---- Testing Trackingsystem not specified ----") + mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New(); + MITK_TEST_CONDITION((myTVGenerator->GetTrackingDeviceType() == mitk::TrackingSystemNotSpecified), "Trackling System not specified:") + } + static void TestClaronTrackingVolume() { MITK_TEST_OUTPUT(<< "---- Testing MicronTracker 2 Tracking Volume ----") mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New (); - //MITK_TEST_CONDITION(myTVGenerator->SetTrackingDeviceType(mitk::ClaronMicron),"loading MicronTracker Volume data:") + myTVGenerator->SetTrackingDeviceType(mitk::ClaronMicron); + MITK_TEST_CONDITION((myTVGenerator->GetTrackingDeviceType() == mitk::ClaronMicron),"loading MicronTracker Volume data:") } static void TestNDIAuroraTrackingVolume() { MITK_TEST_OUTPUT(<< "---- Testing NDI Aurora Tracking Volume ----") mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New (); - //MITK_TEST_CONDITION(myTVGenerator->SetTrackingDeviceType(mitk::NDIAurora),"loading Aurora Volume data:") + myTVGenerator->SetTrackingDeviceType(mitk::NDIAurora); + MITK_TEST_CONDITION((myTVGenerator->GetTrackingDeviceType() == mitk::NDIAurora),"loading Aurora Volume data:") } static void TestNDIPolarisTrackingVolume() { MITK_TEST_OUTPUT(<< "---- Testing NDI Polaris Tracking Volume ----") mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New (); - //MITK_TEST_CONDITION(myTVGenerator->SetTrackingDeviceType(mitk::NDIPolaris),"loading Polaris Volume data:") + myTVGenerator->SetTrackingDeviceType(mitk::NDIPolaris); + MITK_TEST_CONDITION((myTVGenerator->GetTrackingDeviceType() == mitk::NDIPolaris),"loading Polaris Volume data:") } static void TestIntuitiveDaVinciTrackingVolume() { MITK_TEST_OUTPUT(<< "---- Testing Intuitive Da Vinci Tracking Volume ----") mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New (); - //MITK_TEST_CONDITION(myTVGenerator->SetTrackingDeviceType(mitk::IntuitiveDaVinci),"loading Da Vinci Volume data:") + myTVGenerator->SetTrackingDeviceType(mitk::IntuitiveDaVinci); + MITK_TEST_CONDITION((myTVGenerator->GetTrackingDeviceType() == mitk::IntuitiveDaVinci),"loading Da Vinci Volume data:") } /* The isInside() method is not implemented so far. So please activate is as soon as this is done. Then we could load * the different Trackingvolumens (Polaris, MicronTracker, etc) and test different points inside and outside in this method. static void TestIsInside() { MITK_TEST_OUTPUT(<< "---- Testing IsInside-Method ----") mitk::TrackingVolume::Pointer myTrackingVolume = mitk::TrackingVolume::New(); mitk::Point3D p1; mitk::FillVector3D(p1,(float)0,(float)0,(float)0); MITK_TEST_CONDITION(myTrackingVolume->IsInside(p1)==false,"... successfull") } */ - - static void TestManualVolume() - { - MITK_TEST_OUTPUT(<< "---- Testing Manual Volume definition ----") - // mitk::TrackingVolumeGenerator::Pointer myTVGenerator = mitk::TrackingVolumeGenerator::New(); - try - { - // vtkPolyData* myPolyData = vtkPolyData::New(); - //myTVGenerator->SetVolumeManually(myPolyData); - // myPolyData->Delete(); - } - catch(...) - { - MITK_TEST_FAILED_MSG(<< "Failed loading manual volume!"); - } - - } }; /** This function is testing the TrackingVolume class. */ int mitkTrackingVolumeTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("TrackingVolume") mitkTrackingVolumeTestClass::TestInstantiation(); + mitkTrackingVolumeTestClass::TestTrackingSystemNotSpecified (); mitkTrackingVolumeTestClass::TestClaronTrackingVolume(); mitkTrackingVolumeTestClass::TestNDIAuroraTrackingVolume(); mitkTrackingVolumeTestClass::TestNDIPolarisTrackingVolume(); mitkTrackingVolumeTestClass::TestIntuitiveDaVinciTrackingVolume(); //mitkTrackingVolumeTestClass::TestIsInside(); Activate this code when method isInside() is implemented! - mitkTrackingVolumeTestClass::TestManualVolume(); - + MITK_TEST_END() } diff --git a/Modules/IGT/files.cmake b/Modules/IGT/files.cmake index 701731fe60..f1f197760a 100644 --- a/Modules/IGT/files.cmake +++ b/Modules/IGT/files.cmake @@ -1,58 +1,57 @@ SET(CPP_FILES IGTFilters/mitkNavigationDataLandmarkTransformFilter.cpp IGTFilters/mitkNavigationDataReferenceTransformFilter.cpp IGTFilters/mitkNavigationDataTransformFilter.cpp IGTFilters/mitkNavigationDataRecorder.cpp IGTFilters/mitkNavigationDataPlayer.cpp IGTFilters/mitkNavigationDataObjectVisualizationFilter.cpp IGTFilters/mitkCameraVisualization.cpp IGTFilters/mitkNavigationData.cpp IGTFilters/mitkNavigationDataDisplacementFilter.cpp IGTFilters/mitkNavigationDataSequentialPlayer.cpp IGTFilters/mitkNavigationDataSource.cpp IGTFilters/mitkNavigationDataToMessageFilter.cpp IGTFilters/mitkNavigationDataToNavigationDataFilter.cpp IGTFilters/mitkNavigationDataToOpenGLFilter.cpp IGTFilters/mitkNavigationDataToPointSetFilter.cpp IGTFilters/mitkTrackingDeviceSource.cpp IGTFilters/mitkTrackingVolumeGenerator.cpp IGTFilters/mitkTimeStamp.cpp IGTFilters/mitkRealTimeClock.cpp IGTFilters/mitkTrackingDeviceSourceConfigurator.cpp IGTTrackingDevices/mitkClaronTool.cpp IGTTrackingDevices/mitkClaronTrackingDevice.cpp IGTTrackingDevices/mitkInternalTrackingTool.cpp IGTTrackingDevices/mitkNDIPassiveTool.cpp IGTTrackingDevices/mitkNDIProtocol.cpp IGTTrackingDevices/mitkNDITrackingDevice.cpp IGTTrackingDevices/mitkSerialCommunication.cpp IGTTrackingDevices/mitkTrackingDevice.cpp IGTTrackingDevices/mitkTrackingTool.cpp - IGTTrackingDevices/mitkTrackingVolume.cpp IGTTrackingDevices/mitkVirtualTrackingDevice.cpp IGTTrackingDevices/mitkVirtualTrackingTool.cpp IGTToolManagement/mitkNavigationToolStorage.cpp IGTToolManagement/mitkNavigationToolStorageSerializer.cpp IGTToolManagement/mitkNavigationToolStorageDeserializer.cpp IGTToolManagement/mitkNavigationTool.cpp IGTToolManagement/mitkNavigationToolReader.cpp IGTToolManagement/mitkNavigationToolWriter.cpp ) IF(MITK_USE_MICRON_TRACKER) SET(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkClaronInterface.cpp) ELSE() SET(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkClaronInterfaceStub.cpp) ENDIF(MITK_USE_MICRON_TRACKER) IF(MITK_USE_MICROBIRD_TRACKER) SET(CPP_FILES ${CPP_FILES} IGTTrackingDevices/mitkMicroBirdTrackingDevice.cpp) ENDIF(MITK_USE_MICROBIRD_TRACKER) IF(WIN32) SET(CPP_FILES ${CPP_FILES} IGTFilters/mitkWindowsRealTimeClock.cpp) ELSE() SET(CPP_FILES ${CPP_FILES} IGTFilters/mitkLinuxRealTimeClock.cpp) ENDIF(WIN32)