00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkTrackingVolume.h" 00019 #include "mitkSTLFileReader.h" 00020 #include "mitkStandardFileLocations.h" 00021 #include "mitkConfig.h" 00022 #include <vtkCubeSource.h> 00023 00024 00025 mitk::TrackingVolume::TrackingVolume() 00026 { 00027 m_TrackingDeviceType = mitk::TrackingSystemNotSpecified; 00028 00029 //####### initialize file locations for the volume-STL-files ######### 00030 std::string m_VolumeDir = MITK_ROOT; 00031 m_VolumeDir += "Modules/IGT/IGTTrackingDevices/TrackingVolumeData"; 00032 mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( m_VolumeDir.c_str(), false ); 00033 //#################################################################### 00034 00035 } 00036 00037 /* TODO: implementation of method 00038 bool mitk::TrackingVolume::IsInside(mitk::Point3D itkNotUsed(punkt)) 00039 { 00040 //NOT IMPLEMENTED YET! 00041 return false; 00042 } 00043 */ 00044 00045 void mitk::TrackingVolume::SetVolumeManually(vtkPolyData* volume) 00046 { 00047 this->SetVtkPolyData(volume); 00048 } 00049 00050 bool mitk::TrackingVolume::SetTrackingDeviceType(TrackingDeviceType type) 00051 { 00052 // get filename / perform custom initiation 00053 std::string filename = ""; 00054 00055 switch(type) 00056 { 00057 case mitk::ClaronMicron: 00058 filename = mitk::StandardFileLocations::GetInstance()->FindFile("ClaronMicron.stl"); 00059 break; 00060 case mitk::IntuitiveDaVinci: 00061 filename = mitk::StandardFileLocations::GetInstance()->FindFile("IntuitiveDaVinci.stl"); 00062 break; 00063 case mitk::NDIAurora: 00064 filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIAurora.stl"); 00065 break; 00066 case mitk::NDIPolaris: 00067 filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIPolaris.stl"); 00068 break; 00069 case mitk::VirtualTracker: 00070 { 00071 vtkCubeSource* cs = vtkCubeSource::New(); 00072 double bounds[6]; 00073 bounds[0] = bounds[2] = bounds[4] = -400.0; // initialize bounds to -400 ... +400 cube. This is the default value of the 00074 bounds[1] = bounds[3] = bounds[5] = 400.0; // virtual tracking device, but it can be changed. In that case, 00075 // the tracking volume polydata has be updated manually 00076 cs->SetBounds(bounds); 00077 cs->GetOutput()->Update(); 00078 this->SetVtkPolyData(cs->GetOutput()); 00079 cs->Delete(); 00080 return true; 00081 } 00082 default: 00083 return false; 00084 } 00085 00086 if (filename.empty()) 00087 return false; 00088 00089 mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); 00090 try 00091 { 00092 stlReader->SetFileName( filename.c_str() ); 00093 stlReader->Update(); 00094 } 00095 catch (...) 00096 { 00097 return false; 00098 } 00099 if ( stlReader->GetOutput() == NULL ) 00100 return false; 00101 00102 this->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData()); 00103 stlReader = NULL; 00104 return true; 00105 }