7 #include "PlusConfigure.h" 12 #include "vtkImageData.h" 13 #include "vtkDICOMImageReader.h" 14 #include "vtkObjectFactory.h" 17 #include "vtkIGSIOTrackedFrameList.h" 20 #include <vtkImageFlip.h> 21 #include <vtkPointData.h> 22 #include <vtkDirectory.h> 30 : KeepReceivedDicomFiles(false)
59 desc +=
": Acquire the exam data from the StealthLink Server. The exam data contains the image being displayed on the StealthLink Server. The 3D volume will be constructed using these images";
78 if (aConfig->GetAttribute(
"DicomImagesOutputDirectory"))
80 this->SetDicomImagesOutputDirectory(aConfig->GetAttribute(
"DicomImagesOutputDirectory"));
84 LOG_INFO(
"The dicom images from stealthlink will be saved into the: " <<
vtkPlusConfig::GetInstance()->GetOutputDirectory() <<
"/StealthLinkDicomOutput");
86 this->SetDicomImagesOutputDirectory(dicomImagesDefaultOutputDirectory.c_str());
91 if (aConfig->GetAttribute(
"VolumeEmbeddedTransformToFrame"))
93 this->SetVolumeEmbeddedTransformToFrame(aConfig->GetAttribute(
"VolumeEmbeddedTransformToFrame"));
97 LOG_INFO(
"The dicom images from stealthlink will be represented in Ras coordinate system");
98 this->SetVolumeEmbeddedTransformToFrame(
"Ras");
123 LOG_DEBUG(
"vtkPlusStealthLinkCommand::Execute: " << (!this->
Name.empty() ? this->
Name :
"(undefined)")
126 if (this->
Name.empty())
133 if (stealthLinkDevice == NULL)
142 LOG_INFO(
"Acquiring the exam data from StealthLink Server: Device ID: " << GetStealthLinkDeviceId());
146 std::string requestedImageId;
147 std::string assignedImageId;
148 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
149 vtkSmartPointer<vtkMatrix4x4> ijkToReferenceTransform = vtkSmartPointer<vtkMatrix4x4>::New();
152 if (stealthLinkDevice->
GetImage(requestedImageId, assignedImageId, std::string(this->GetVolumeEmbeddedTransformToFrame()), imageData, ijkToReferenceTransform) !=
PLUS_SUCCESS)
157 std::string resultMessage;
169 LOG_DEBUG(
"Send image to client through OpenIGTLink");
170 vtkSmartPointer<vtkPlusCommandImageResponse> imageResponse = vtkSmartPointer<vtkPlusCommandImageResponse>::New();
172 imageResponse->SetClientId(this->
ClientId);
173 imageResponse->SetImageName(imageId);
174 imageResponse->SetImageData(volumeToSend);
175 imageResponse->SetImageToReferenceTransform(imageToReferenceOrientationMatrix);
176 LOG_INFO(
"Send reconstructed volume to client through OpenIGTLink");
177 resultMessage.clear();
178 resultMessage = std::string(
", volume sent as: ") + imageResponse->GetImageName();
186 if (dataCollector == NULL)
188 LOG_ERROR(
"Data collector is invalid");
191 if (!GetStealthLinkDeviceId().empty())
197 LOG_ERROR(
"No StealthLink device has been found by the name " << this->GetStealthLinkDeviceId());
202 if (stealthLinkDevice == NULL)
205 LOG_ERROR(
"The specified device " << GetStealthLinkDeviceId() <<
" is not StealthLink Device");
208 return stealthLinkDevice;
216 if (stealthLinkDevice != NULL)
219 SetStealthLinkDeviceId(stealthLinkDevice->
GetDeviceId());
220 return stealthLinkDevice;
223 LOG_ERROR(
"No StealthLink Device has been found");
void SetDicomImagesOutputDirectory(std::string dicomImagesOutputDirectory)
static const std::string GET_STEALTHLINK_EXAM_DATA_CMD
std::string VolumeEmbeddedTransformToFrame
virtual void PrintSelf(ostream &os, vtkIndent indent)
Abstract interface for tracker and video devices.
std::vector< vtkPlusDevice * >::const_iterator DeviceCollectionConstIterator
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
PlusStatus GetDevice(vtkPlusDevice *&aDevice, const std::string &aDeviceId) const
std::string StealthLinkDeviceId
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual std::string GetDeviceId() const
PlusStatus ProcessImageReply(const std::string &imageId, vtkImageData *volumeToSend, vtkMatrix4x4 *imageToReferenceOrientationMatrixWithSpacing, std::string &resultMessage)
bool KeepReceivedDicomFiles
virtual vtkPlusOpenIGTLinkServer * GetPlusServer()
virtual std::string GetDescription(const std::string &commandName)
static vtkPlusConfig * GetInstance()
DeviceCollectionConstIterator GetDeviceConstIteratorBegin() const
vtkPlusCommandProcessor * CommandProcessor
vtkPlusStealthLinkTracker * GetStealthLinkDevice()
DeviceCollectionConstIterator GetDeviceConstIteratorEnd() const
Manages devices that record image or positional data.
std::string GetOutputDirectory()
PlusStatus UpdateTransformRepository(vtkIGSIOTransformRepository *sharedTransformRepository)
virtual void GetCommandNames(std::list< std::string > &cmdNames)
static vtkPlusStealthLinkTracker * SafeDownCast(vtkObject *o)
virtual bool GetKeepReceivedDicomFiles()
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
vtkPlusStealthLinkCommand()
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
vtkStandardNewMacro(vtkPlusStealthLinkCommand)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual void PrintSelf(ostream &os, vtkIndent indent)
std::string DicomImagesOutputDirectory
virtual ~vtkPlusStealthLinkCommand()
PlusCommandResponseList CommandResponseQueue
virtual PlusStatus Execute()
void SetKeepReceivedDicomFiles(bool keepReceivedDicomFiles)
virtual PlusStatus GetImage(const std::string &requestedImageId, std::string &assignedImageId, const std::string &imageReferenceFrameName, vtkImageData *imageData, vtkMatrix4x4 *ijkToReferenceTransform)
This command reconstructs a volume from an image sequence and saves it to disk or sends it to the cli...