diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp index bbf2ad8648..8f1b74f773 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp @@ -1,129 +1,127 @@ /*========================================================================= 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_Type = tracker->GetType(); - this->m_Data = mitk::GetFirstCompatibleDeviceDataForLine(m_Type); + this->m_Data = mitk::GetFirstCompatibleDeviceDataForLine(tracker->GetType()); } void mitk::TrackingVolumeGenerator::GenerateData() { mitk::Surface::Pointer output = this->GetOutput();//the surface wich represents the tracking volume - std::string filename = ""; + 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(); 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: { 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; } } */ - std::string fn = this->m_Data.VolumeModelLocation; - filename = mitk::StandardFileLocations::GetInstance()->FindFile(fn.c_str()); - if (filename.empty()) + std::string filename = this->m_Data.VolumeModelLocation; + 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( filename.c_str() ); + 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); - m_Type = m_Data.Line; } 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/IGTFilters/mitkTrackingVolumeGenerator.h b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h index 1e1a1bd8ef..5a9cda4dc5 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h @@ -1,90 +1,89 @@ /*========================================================================= 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" 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. * * To generate the specific dimensions of the tracking volume of a tracking device * 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. * * \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 generated 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). */ void SetTrackingDeviceType(mitk::TrackingDeviceType deviceType); mitk::TrackingDeviceType GetTrackingDeviceType() const; void SetTrackingDeviceData(mitk::TrackingDeviceData deviceData); mitk::TrackingDeviceData GetTrackingDeviceData() const; /** - * \brief Sets the tracking device type of the volume. After doing this + * \brief Deprecated! Use set DeviceData instead. 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. 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::TrackingDeviceData m_Data; - mitk::TrackingDeviceType m_Type; void GenerateData(); }; } #endif // MITKTRACKINGVOLUMEGENERATOR_H diff --git a/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h b/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h index e10efd9d90..79e902425c 100644 --- a/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h +++ b/Modules/IGT/IGTTrackingDevices/mitkTrackingTypes.h @@ -1,249 +1,250 @@ /*========================================================================= 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 Represents the setting of the tracking volume of a NDI tracking device. The tracking volume of + * \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) - * This enum is deprecated. In future, please use the new TrackingDeviceData to model Specific tracking Volumes + * */ 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" */ 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 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, 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_ */