diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp index 8f1b74f773..625423fe23 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp @@ -1,127 +1,110 @@ /*========================================================================= 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_Data = mitk::Unspecified; } void mitk::TrackingVolumeGenerator::SetTrackingDevice (mitk::TrackingDevice::Pointer tracker) { this->m_Data = mitk::GetFirstCompatibleDeviceDataForLine(tracker->GetType()); } void mitk::TrackingVolumeGenerator::GenerateData() { - mitk::Surface::Pointer output = this->GetOutput();//the surface wich represents the tracking volume + mitk::Surface::Pointer output = this->GetOutput(); //the surface wich represents the tracking volume - std::string filepath = ""; - - /** - switch(m_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::NDIPolaris: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIPolaris.stl"); - break; - case mitk::NDIAurora: - filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIAurora.stl"); - break; - case mitk::TrackingSystemNotSpecified: - case mitk::VirtualTracker: - { - vtkSmartPointer cubeSource = vtkSmartPointer::New(); + std::string filepath = ""; // Full path to file + std::string filename = this->m_Data.VolumeModelLocation; // Name of the file or possibly a magic String like "cube" + + // See if filename mathes a magic String. + if (filename.compare("cube") == 0){ + 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 + // the tracking volume polydata has to be updated manually cubeSource->SetBounds(bounds); cubeSource->GetOutput()->Update(); output->SetVtkPolyData(cubeSource->GetOutput()); //set the vtkCubeSource as polyData of the surface return; - } - default: - { - output->SetVtkPolyData(vtkPolyData::New()); //initialize with empty poly data (otherwise old surfaces may be returned) => so an empty surface is returned - MITK_ERROR<< "No STL to given TrackingDevice found"; - return; - } - - } - */ + } + if (filename.compare("") == 0) // empty String means no model, return empty output + { + output->SetVtkPolyData(vtkPolyData::New()); //initialize with empty poly data (otherwise old surfaces may be returned) => so an empty surface is returned + return; + } - std::string filename = this->m_Data.VolumeModelLocation; + // In the following Code, we assume that filename contains an actual filename andn ot a magic string + filepath = mitk::StandardFileLocations::GetInstance()->FindFile(filename.c_str()); + if (filepath.empty()) { MITK_ERROR << "Filename is empty"; return; } mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); stlReader->SetFileName( filepath.c_str() ); stlReader->Update(); if ( stlReader->GetOutput() == NULL) { MITK_ERROR << "Error while reading file"; return ; } output->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData());//set the visible trackingvolume } void mitk::TrackingVolumeGenerator::SetTrackingDeviceType(mitk::TrackingDeviceType deviceType) { m_Data = mitk::GetFirstCompatibleDeviceDataForLine(deviceType); } mitk::TrackingDeviceType mitk::TrackingVolumeGenerator::GetTrackingDeviceType() const { return m_Data.Line; } void mitk::TrackingVolumeGenerator::SetTrackingDeviceData(mitk::TrackingDeviceData deviceData) { m_Data= deviceData; } mitk::TrackingDeviceData mitk::TrackingVolumeGenerator::GetTrackingDeviceData() const { return m_Data; } diff --git a/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h b/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h index 79e902425c..f3f30f36e1 100644 --- a/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h +++ b/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h @@ -1,250 +1,251 @@ /*========================================================================= 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. =========================================================================*/ #ifndef MITKTRACKINGTYPES_H_HEADER_INCLUDED_ #define MITKTRACKINGTYPES_H_HEADER_INCLUDED_ #include #include //#include namespace mitk { /**Documentation * \brief Error codes of NDI tracking devices */ enum NDIErrorCode { NDIOKAY = 0, NDIERROR = 1, SERIALINTERFACENOTSET, SERIALSENDERROR, SERIALRECEIVEERROR, SROMFILETOOLARGE, SROMFILETOOSMALL, NDICRCERROR, // reply has crc error, local computer detected the error NDIINVALIDCOMMAND, NDICOMMANDTOOLONG, NDICOMMANDTOOSHORT, NDICRCDOESNOTMATCH, // command had crc error, tracking device detected the error NDITIMEOUT, NDIUNABLETOSETNEWCOMMPARAMETERS, NDIINCORRECTNUMBEROFPARAMETERS, NDIINVALIDPORTHANDLE, NDIINVALIDTRACKINGPRIORITY, NDIINVALIDLED, NDIINVALIDLEDSTATE, NDICOMMANDINVALIDINCURRENTMODE, NDINOTOOLFORPORT, NDIPORTNOTINITIALIZED, NDISYSTEMNOTINITIALIZED, NDIUNABLETOSTOPTRACKING, NDIUNABLETOSTARTTRACKING, NDIINITIALIZATIONFAILED, NDIINVALIDVOLUMEPARAMETERS, NDICANTSTARTDIAGNOSTICMODE, NDICANTINITIRDIAGNOSTICS, NDIFAILURETOWRITESROM, NDIENABLEDTOOLSNOTSUPPORTED, NDICOMMANDPARAMETEROUTOFRANGE, NDINOMEMORYAVAILABLE, NDIPORTHANDLENOTALLOCATED, NDIPORTHASBECOMEUNOCCUPIED, NDIOUTOFHANDLES, NDIINCOMPATIBLEFIRMWAREVERSIONS, NDIINVALIDPORTDESCRIPTION, NDIINVALIDOPERATIONFORDEVICE, NDIWARNING, NDIUNKNOWNERROR, NDIUNEXPECTEDREPLY, UNKNOWNHANDLERETURNED, TRACKINGDEVICERESET, TRACKINGDEVICENOTSET }; /**Documentation * \brief identifier for tracking device. The way it is currently used * represents a product line rather than an actal type. Refactoring is a future option. */ enum TrackingDeviceType { NDIPolaris, ///< Polaris: optical Tracker from NDI NDIAurora, ///< Aurora: electromagnetic Tracker from NDI ClaronMicron, ///< Micron Tracker: optical Tracker from Claron IntuitiveDaVinci, ///< Intuitive Surgical: DaVinci Telemanipulator API Interface AscensionMicroBird, ///< Ascension microBird / PCIBird family VirtualTracker, ///< Virtual Tracking device class that produces random tracking coordinates TrackingSystemNotSpecified,///< entry for not specified or initialized tracking system TrackingSystemInvalid ///< entry for invalid state (mainly for testing) }; /**Documentation * \brief Error codes of NDI tracking devices */ enum OperationMode { ToolTracking6D, ToolTracking5D, MarkerTracking3D, HybridTracking }; /** * \brief This enum is deprecated. In future, please use the new TrackingDeviceData to model Specific tracking Volumes * Represents the setting of the tracking volume of a NDI tracking device. The tracking volume of * a tracking device itself (as 3d-Object) is represented by an instance of the class mitk::TrackingVolume * as defined by NDI API SFLIST (Aurora and Polaris API guide) * */ enum NDITrackingVolume { Standard, Pyramid, SpectraPyramid, VicraVolume, Cube, Dome }; /** * /brief This structure defines key variables of a device model and type. * It is specifically used to find out which models belong to which vendor, and what volume * to use for a specific Model. Leaving VolumeModelLocation set to null will instruct the Generator * to generate a field to the best of his ability */ struct TrackingDeviceData { TrackingDeviceType Line; std::string Model; std::string VolumeModelLocation; }; /** * Here all supported devices are defined. Dont forget to introduce new Devices into the TrackingDeviceList Array at the bottom! - * If a model does not have a corresponding tracking volume yet, pass an empty string to denote "No Model" + * If a model does not have a corresponding tracking volume yet, pass an empty string to denote "No Model". pass "cube" to render + * a default cube of 400x400 px. You can define additional magic strings in the TrackingVolumeGenerator. */ static TrackingDeviceData AuroraCompact = {NDIAurora, "CompactFG", "NDIAuroraCompactFG_Dome.stl"}; static TrackingDeviceData AuroraPlanarCube = {NDIAurora, "PlanarFG_Cube", "NDIAurora.stl"}; static TrackingDeviceData AuroraPlanarDome = {NDIAurora, "PlanarFG_Dome","NDIAuroraPlanarFG_Dome.stl"}; static TrackingDeviceData AuroraTabletop = {NDIAurora, "TabletopFG", "NDIAuroraTabletopFG_Dome.stl"}; static TrackingDeviceData Micron = {ClaronMicron, "Micron Tracker H40", "ClaronMicron.stl"}; static TrackingDeviceData PolarisSpectra = {NDIPolaris, "Spectra", "NDIPolaris.stl"}; static TrackingDeviceData PolarisVicra = {NDIPolaris, "Vicra", "NDIPolaris.stl"}; static TrackingDeviceData DaVinci = {IntuitiveDaVinci, "IntuitiveDaVinci", "IntuitiveDaVinci.stl"}; static TrackingDeviceData MicroBird = {AscensionMicroBird, "AscensionMicroBird", ""}; - static TrackingDeviceData VTracker = {VirtualTracker, "VirtualTracker", ""}; + static TrackingDeviceData VTracker = {VirtualTracker, "VirtualTracker", "cube"}; static TrackingDeviceData Unspecified = {TrackingSystemNotSpecified, "Unspecified System", ""}; // Careful when changing the "invalid" device: The mitkTrackingTypeTest is using it's data! static TrackingDeviceData Invalid = {TrackingSystemInvalid, "Invalid Tracking System", ""}; - static TrackingDeviceData TrackingDeviceList[] = {AuroraCompact, AuroraPlanarCube, AuroraPlanarDome, AuroraTabletop, Micron, PolarisSpectra, PolarisVicra, + static TrackingDeviceData TrackingDeviceList[] = {AuroraPlanarCube, AuroraCompact, AuroraPlanarDome, AuroraTabletop, Micron, PolarisSpectra, PolarisVicra, DaVinci, MicroBird, VTracker, Unspecified, Invalid}; /** * /brief Returns all devices compatibel to the given Line of Devices */ static std::vector GetDeviceDataForLine(TrackingDeviceType Type){ std::vector Result; int size = (sizeof (TrackingDeviceList) / sizeof*(TrackingDeviceList)); for(int i=0; i < size; i++) { if(TrackingDeviceList[i].Line == Type ) Result.push_back(TrackingDeviceList[i]); } return Result; } /** * /brief Returns the first TracingDeviceData mathing a given line. Useful for backward compatibility * with the old way to manage Devices */ static TrackingDeviceData GetFirstCompatibleDeviceDataForLine(TrackingDeviceType Type){ return GetDeviceDataForLine(Type).front(); } /** * /brief Returns the device Data set matching the model name or the invalid device, if none was found */ static TrackingDeviceData GetDeviceDataByName(std::string modelName){ int size = (sizeof (TrackingDeviceList) / sizeof*(TrackingDeviceList)); for(int i=0; i < size; i++) { if(TrackingDeviceList[i].Model.compare(modelName) == 0 ) return TrackingDeviceList[i]; } return Invalid; } /**Documentation * \brief activation rate of IR illuminator for NDI Polaris tracking device */ enum IlluminationActivationRate { Hz20 = 20, Hz30 = 30, Hz60 = 60 }; /**Documentation * \brief Data transfer mode for NDI tracking devices */ enum DataTransferMode { TX = 0, BX = 1 }; /**Documentation * \brief Query mode for NDI tracking devices */ enum PHSRQueryType { ALL = 0x00, FREED = 0x01, OCCUPIED = 0x02, INITIALIZED = 0x03, ENABLED = 0x04 }; typedef itk::Point MarkerPointType; typedef std::vector MarkerPointContainerType; /** * \brief Defines the tools (arms) of the daVinci system: * PSM1 - Patient side manipulator 1 * PSM2 - Patient side manipulator 2 * ECM - Endoscopic camera manipulator * MTML - Left master target manipulator * MTMR - Right master target manipulator * PSM - Patient side manipulator 3 (if not existent, its data will always be zero) **/ enum DaVinciToolType { PSM1 = 0, PSM2 = 1, ECM = 2, MTML = 3, MTMR = 4, PSM = 5, //UIEvents = 6, }; } // namespace mitk #endif /* MITKTRACKINGTYPES_H_HEADER_INCLUDED_ */