diff --git a/Modules/DicomRT/mitkDicomRTReader.cpp b/Modules/DicomRT/mitkDicomRTReader.cpp index 1194169661..4a0e2b4a8a 100644 --- a/Modules/DicomRT/mitkDicomRTReader.cpp +++ b/Modules/DicomRT/mitkDicomRTReader.cpp @@ -1,580 +1,570 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDicomRTReader.h" namespace mitk { DicomRTReader::DicomRTReader(){} DicomRTReader::~DicomRTReader(){} DicomRTReader::RoiEntry::RoiEntry() { Number=0; DisplayColor[0]=1.0; DisplayColor[1]=0.0; DisplayColor[2]=0.0; PolyData=NULL; } DicomRTReader::RoiEntry::~RoiEntry() { SetPolyData(NULL); } DicomRTReader::RoiEntry::RoiEntry(const RoiEntry& src) { Number=src.Number; Name=src.Name; Description=src.Description; DisplayColor[0]=src.DisplayColor[0]; DisplayColor[1]=src.DisplayColor[1]; DisplayColor[2]=src.DisplayColor[2]; PolyData=NULL; SetPolyData(src.PolyData); } DicomRTReader::RoiEntry& DicomRTReader::RoiEntry::operator=(const RoiEntry &src) { Number=src.Number; Name=src.Name; Description=src.Description; DisplayColor[0]=src.DisplayColor[0]; DisplayColor[1]=src.DisplayColor[1]; DisplayColor[2]=src.DisplayColor[2]; SetPolyData(src.PolyData); return (*this); } void DicomRTReader::RoiEntry::SetPolyData(vtkPolyData* roiPolyData) { if (roiPolyData == this->PolyData) { // not changed return; } if (this->PolyData != NULL) { this->PolyData->UnRegister(NULL); } this->PolyData = roiPolyData; if (this->PolyData != NULL) { this->PolyData->Register(NULL); } } std::deque DicomRTReader::ReadDicomFile(char* filename) { std::cout << "\n\n" << "Filename:" << filename << "\n\n"; DcmFileFormat file; OFCondition outp; outp = file.loadFile(filename, EXS_Unknown); if(outp.good()) { DcmDataset *dataset = file.getDataset(); OFString sopClass; if(dataset->findAndGetOFString(DCM_SOPClassUID, sopClass).good() && !sopClass.empty()) { if(sopClass == UID_RTDoseStorage) { mitk::DataNode::Pointer x = mitk::DataNode::New(); x = this->DicomRTReader::LoadRTDose(dataset, filename); ContourModelSetVector y; return y; } else if(sopClass == UID_RTStructureSetStorage) { ContourModelSetVector x = this->DicomRTReader::ReadStructureSet(dataset); return x; } else if(sopClass == UID_RTPlanStorage) { int x = this->DicomRTReader::LoadRTPlan(dataset); ContourModelSetVector y; return y; } else { std::cout << "Error reading the RTStructureSetStorage\n\n"; ContourModelSetVector y; return y; } } else { std::cout << "Error reading the SOPClassID\n\n"; ContourModelSetVector y; return y; } } else { std::cout << "Cant read the input file\n\n"; ContourModelSetVector y; return y; } } size_t DicomRTReader::GetNumberOfRois() { return this->RoiSequenceVector.size(); } DicomRTReader::RoiEntry* DicomRTReader::FindRoiByNumber(int roiNumber) { for(int i=0; iRoiSequenceVector.size(); i++) { if(this->RoiSequenceVector[i].Number == roiNumber) { return &this->RoiSequenceVector[i]; } } return NULL; } std::deque DicomRTReader::ReadStructureSet(DcmDataset* dataset) { - //For storing contourmodelsets that belongs to the same object - //e.g. An eye consists of several contourmodels (contourmodel consists of several 3D-Points) - //and together they are a contourmodelset + /** + * @brief For storing contourmodelsets that belongs to the same object + * + * e.g. An eye consists of several contourmodels (contourmodel consists of several 3D-Points) + * and together they are a contourmodelset + */ ContourModelSetVector contourModelSetVector; DRTStructureSetIOD structureSetObject; OFCondition outp = structureSetObject.read(*dataset); if(!outp.good()) { std::cout << "Error reading the file\n\n"; std::deque x; return x; } DRTStructureSetROISequence &roiSequence = structureSetObject.getStructureSetROISequence(); if(!roiSequence.gotoFirstItem().good()) { std::cout << "Error reading the structure sequence\n\n"; std::deque x; return x; } do{ DRTStructureSetROISequence::Item ¤tSequence = roiSequence.getCurrentItem(); if(!currentSequence.isValid()) { continue; } OFString roiName; OFString roiDescription; Sint32 roiNumber; RoiEntry roi; currentSequence.getROIName(roiName); currentSequence.getROIDescription(roiDescription); currentSequence.getROINumber(roiNumber); roi.Name = roiName.c_str(); roi.Description = roiDescription.c_str(); roi.Number = roiNumber; this->RoiSequenceVector.push_back(roi); } while(roiSequence.gotoNextItem().good()); OFString refSOPInstUID = GetReferencedFrameOfReferenceSOPInstanceUID(structureSetObject); - //default slice thickness -> reads the thickness from a database ?! double sliceThickness = 2.0; Sint32 refRoiNumber; DRTROIContourSequence &roiContourSeqObject = structureSetObject.getROIContourSequence(); if(!roiContourSeqObject.gotoFirstItem().good()) { std::cout << "Error reading the contour sequence\n\n"; std::deque x; return x; } do { mitk::ContourModelSet::Pointer contourSet = mitk::ContourModelSet::New(); DRTROIContourSequence::Item ¤tRoiObject = roiContourSeqObject.getCurrentItem(); if(!currentRoiObject.isValid()) { continue; } currentRoiObject.getReferencedROINumber(refRoiNumber); DRTContourSequence &contourSeqObject = currentRoiObject.getContourSequence(); if(contourSeqObject.gotoFirstItem().good()) { do { DRTContourSequence::Item &contourItem = contourSeqObject.getCurrentItem(); if(!contourItem.isValid()) { continue; } int number; OFString contourNumber; OFString numberOfPoints; OFVector contourData_LPS; mitk::ContourModel::Pointer contourSequence = mitk::ContourModel::New(); contourItem.getContourNumber(contourNumber); contourItem.getNumberOfContourPoints(numberOfPoints); contourItem.getContourData(contourData_LPS); std::stringstream stream; stream << numberOfPoints; stream >> number; for(int i=0; iAddVertex(point); } contourSequence->Close(); contourSet->AddContourModel(contourSequence); - //Hier den namen des contoumodelsets setzen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - contourSet->SetProperty("name", mitk::StringProperty::New("blabal")); } while(contourSeqObject.gotoNextItem().good()); } else { std::cout << "Error reading contourSeqObject\n\n"; } RoiEntry* refROI = this->FindRoiByNumber(refRoiNumber); if(refROI==NULL) { std::cout << "Cant find referenced ROI\n\n"; continue; } Sint32 roiColor; for(int j=0;j<3;j++) { currentRoiObject.getROIDisplayColor(roiColor, j); - //what? refROI->DisplayColor[j] = roiColor/255.0; } - - //save all contours to one set here ! + contourSet->SetProperty("name", mitk::StringProperty::New(refROI->Name)); contourModelSetVector.push_back(contourSet); -// std::cout << "Before clearing: " << contourSet->GetSize() << "\n\n"; -// contourSet->Clear(); -// std::cout << "After clearing: " << contourSet->GetSize() << "\n\n"; } while(roiContourSeqObject.gotoNextItem().good()); std::cout << "Anzahl von ROI: " << contourModelSetVector.size() << "\n\n"; - for(int i=0; iGetSize() << "\n\n"; - } - return contourModelSetVector; } OFString DicomRTReader::GetReferencedFrameOfReferenceSOPInstanceUID(DRTStructureSetIOD &structSetObject) { OFString invalid; DRTReferencedFrameOfReferenceSequence &refFrameOfRefSeqObject = structSetObject.getReferencedFrameOfReferenceSequence(); if(!refFrameOfRefSeqObject.gotoFirstItem().good()) { return invalid; } DRTReferencedFrameOfReferenceSequence::Item ¤tRefFrameOfRefSeqItem = refFrameOfRefSeqObject.getCurrentItem(); if(!currentRefFrameOfRefSeqItem.isValid()) { return invalid; } DRTRTReferencedStudySequence &refStudySeqObject = currentRefFrameOfRefSeqItem.getRTReferencedStudySequence(); if(!refStudySeqObject.gotoFirstItem().good()) { return invalid; } DRTRTReferencedStudySequence::Item &refStudySeqItem = refStudySeqObject.getCurrentItem(); if(!refStudySeqItem.isValid()) { return invalid; } DRTRTReferencedSeriesSequence &refSeriesSeqObject = refStudySeqItem.getRTReferencedSeriesSequence(); if(!refSeriesSeqObject.gotoFirstItem().good()) { return invalid; } DRTRTReferencedSeriesSequence::Item &refSeriesSeqItem = refSeriesSeqObject.getCurrentItem(); if(!refSeriesSeqItem.isValid()) { return invalid; } DRTContourImageSequence &contourImageSeqObject = refSeriesSeqItem.getContourImageSequence(); if(!contourImageSeqObject.gotoFirstItem().good()) { return invalid; } DRTContourImageSequence::Item &contourImageSeqItem = contourImageSeqObject.getCurrentItem(); if(!contourImageSeqItem.isValid()) { return invalid; } OFString resultUid; contourImageSeqItem.getReferencedSOPInstanceUID(resultUid); return resultUid; } int DicomRTReader::LoadRTPlan(DcmDataset *dataset) { DRTPlanIOD planObject; OFCondition result = planObject.read(*dataset); if(result.good()) { OFString tmpString, dummyString; DRTBeamSequence &planeBeamSeqObject = planObject.getBeamSequence(); if(planeBeamSeqObject.gotoFirstItem().good()) { do { DRTBeamSequence::Item ¤tBeamSeqItem = planeBeamSeqObject.getCurrentItem(); if(!currentBeamSeqItem.isValid()) { std::cout << "Invalid Beam Sequence \n\n"; continue; } BeamEntry beamEntry; OFString beamName, beamDescription, beamType; Sint32 beamNumber; Float64 srcAxisDistance; currentBeamSeqItem.getBeamName(beamName); currentBeamSeqItem.getBeamDescription(beamDescription); currentBeamSeqItem.getBeamType(beamType); currentBeamSeqItem.getBeamNumber(beamNumber); currentBeamSeqItem.getSourceAxisDistance(srcAxisDistance); beamEntry.Name = beamName.c_str(); beamEntry.Description = beamDescription.c_str(); beamEntry.Type = beamType.c_str(); beamEntry.Number = beamNumber; beamEntry.SrcAxisDistance = srcAxisDistance; DRTControlPointSequence &controlPointSeqObject = currentBeamSeqItem.getControlPointSequence(); if(controlPointSeqObject.gotoFirstItem().good()) { DRTControlPointSequence::Item &controlPointItem = controlPointSeqObject.getCurrentItem(); if(controlPointItem.isValid()) { OFVector isocenterPosData_LPS; Float64 gantryAngle, patientSupportAngle, beamLimitingDeviceAngle; unsigned int numOfCollimatorPosItems = 0; controlPointItem.getIsocenterPosition(isocenterPosData_LPS); controlPointItem.getGantryAngle(gantryAngle); controlPointItem.getPatientSupportAngle(patientSupportAngle); controlPointItem.getBeamLimitingDeviceAngle(beamLimitingDeviceAngle); beamEntry.GantryAngle = gantryAngle; beamEntry.PatientSupportAngle = patientSupportAngle; beamEntry.BeamLimitingDeviceAngle = beamLimitingDeviceAngle; DRTBeamLimitingDevicePositionSequence ¤tCollimatorPosSeqObject = controlPointItem.getBeamLimitingDevicePositionSequence(); if(currentCollimatorPosSeqObject.gotoFirstItem().good()) { do { if(++numOfCollimatorPosItems > 2) { std::cout << "Number of collimator position items is higher than 2 but should be exactly 2 ..."; return 0; } DRTBeamLimitingDevicePositionSequence::Item &collimatorPositionItem = currentCollimatorPosSeqObject.getCurrentItem(); if(collimatorPositionItem.isValid()) { OFString beamLimitingDeviceType; OFVector leafJawPositions; collimatorPositionItem.getRTBeamLimitingDeviceType(beamLimitingDeviceType); collimatorPositionItem.getLeafJawPositions(leafJawPositions); if(!beamLimitingDeviceType.compare("ASYMX") || !beamLimitingDeviceType.compare("X")) { beamEntry.LeafJawPositions[0][0] = leafJawPositions[0]; beamEntry.LeafJawPositions[0][1] = leafJawPositions[1]; } else if(!beamLimitingDeviceType.compare("ASYMY") || !beamLimitingDeviceType.compare("Y")) { beamEntry.LeafJawPositions[1][0] = leafJawPositions[0]; beamEntry.LeafJawPositions[1][1] = leafJawPositions[0]; } else { std::cout << "Unknown collimator type: " << beamLimitingDeviceType << "\n\n"; } } } while(currentCollimatorPosSeqObject.gotoNextItem().good()); } }//endif controlPointItem.isValid() } this->BeamSequenceVector.push_back(beamEntry); } while(planeBeamSeqObject.gotoNextItem().good()); } } return 1; } mitk::DataNode::Pointer DicomRTReader::LoadRTDose(DcmDataset* dataset, char* filename) { std::string name = filename; itk::FilenamesContainer file; file.push_back(name); mitk::DicomSeriesReader* reader = new mitk::DicomSeriesReader; mitk::DataNode::Pointer originalNode = reader->LoadDicomSeries(file,false); mitk::Image::Pointer originalImage = dynamic_cast(originalNode->GetData()); mitk::Geometry3D::Pointer geo = originalImage->GetGeometry()->Clone(); DRTDoseIOD doseObject; OFCondition result = doseObject.read(*dataset); if(result.bad()) { std::cout << "Error reading the RT Dose dataset\n\n"; return 0; } Uint16 rows, columns, frames, planarConfig, samplesPP; OFString nrframes, doseUnits, doseType, summationType, gridScaling, photoInterpret, lutShape; Uint16 &rows_ref = rows; Uint16 &columns_ref = columns; Float32 gridscale; const Uint16 *pixelData = NULL; unsigned long count = 0; doseObject.getRows(rows_ref); doseObject.getColumns(columns_ref); doseObject.getNumberOfFrames(nrframes); doseObject.getDoseUnits(doseUnits); doseObject.getDoseType(doseType); doseObject.getDoseSummationType(summationType); doseObject.getDoseGridScaling(gridScaling); doseObject.getPhotometricInterpretation(photoInterpret); doseObject.getPlanarConfiguration(planarConfig); doseObject.getSamplesPerPixel(samplesPP); doseObject.getPresentationLUTShape(lutShape); gridscale = OFStandard::atof(gridScaling.c_str()); frames = atoi(nrframes.c_str()); dataset->findAndGetUint16Array(DCM_PixelData, pixelData, &count); mitk::Image::Pointer image = mitk::Image::New(); mitk::PixelType pt = mitk::MakeScalarPixelType(); unsigned int dim[] = {columns,rows,frames}; image->Initialize( pt, 3, dim); image->SetSpacing(1.0); mitk::Point3D m_origin; m_origin[0] = 0.0; m_origin[1] = 0.0; m_origin[2] = 0.0; image->SetOrigin(m_origin); float* pixel = (float*)image->GetData(); int size = dim[0]*dim[1]*dim[2]; int highest = 0; for(int i=0; ihighest) { highest = pixelData[i] * gridscale; } *pixel=pixelData[i] * gridscale; } image->SetGeometry(geo); double prescripeDose = highest * 0.8; double hsvValue = 0.002778; vtkSmartPointer transferFunction = vtkSmartPointer::New(); transferFunction->AddHSVPoint(highest*0.0,(240*hsvValue),1.0,1.0,1.0,1.0); transferFunction->AddHSVPoint(highest*0.2,(180*hsvValue),1.0,1.0,1.0,1.0); transferFunction->AddHSVPoint(highest*0.4,(120*hsvValue),1.0,0.5,1.0,1.0); transferFunction->AddHSVPoint(highest*0.5,(120*hsvValue),1.0,1.0,1.0,1.0); transferFunction->AddHSVPoint(highest*0.6,(060*hsvValue),1.0,1.0,1.0,1.0); transferFunction->AddHSVPoint(highest*0.7,(026*hsvValue),1.0,1.0,1.0,1.0); transferFunction->AddHSVPoint(prescripeDose,(0*hsvValue),1.0,1.0,1.0,1.0); transferFunction->Build(); mitk::TransferFunction::Pointer mitkTransFunc = mitk::TransferFunction::New(); mitk::TransferFunctionProperty::Pointer mitkTransFuncProp = mitk::TransferFunctionProperty::New(); mitkTransFunc->SetColorTransferFunction(transferFunction); mitkTransFuncProp->SetValue(mitkTransFunc); mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); renderingMode->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_LEVELWINDOW_COLOR); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetName("DicomRT Dosis"); node->SetProperty("Image Rendering.Mode", renderingMode); node->SetProperty("Image Rendering.Transfer Function", mitkTransFuncProp); node->SetProperty("opacity", mitk::FloatProperty::New(0.3)); node->SetProperty("texture interpolation", mitk::BoolProperty::New( true ) ); node->SetData(image); return node; } bool DicomRTReader::Equals(mitk::ContourModel::Pointer first, mitk::ContourModel::Pointer second) { if(first->GetNumberOfVertices() != second->GetNumberOfVertices()) { return false; } for( int i = 0; i < first->GetNumberOfVertices(); i++) { const mitk::ContourElement::VertexType* x = first->GetVertexAt(i); const mitk::ContourElement::VertexType* y = second->GetVertexAt(i); mitk::ContourElement::VertexType xx = *x; mitk::ContourElement::VertexType yy = *y; for(int j=0; j<3; j++) { if(xx.Coordinates[j] != yy.Coordinates[j]) { return false; } } } return true; } } diff --git a/Modules/DicomRT/mitkDicomRTReader.h b/Modules/DicomRT/mitkDicomRTReader.h index 22b5efac3d..f0998ca743 100644 --- a/Modules/DicomRT/mitkDicomRTReader.h +++ b/Modules/DicomRT/mitkDicomRTReader.h @@ -1,165 +1,237 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkDicomRTReader_h #define mitkDicomRTReader_h #include #include #include #include #include "mitkContourModel.h" #include "mitkContourElement.h" #include #include "dcmtk/config/osconfig.h" #include "dcmtk/ofstd/ofconapp.h" #include "dcmtk/ofstd/ofcond.h" #include "dcmtk/dcmrt/drtdose.h" #include "dcmtk/dcmrt/drtimage.h" #include "dcmtk/dcmrt/drtplan.h" #include "dcmtk/dcmrt/drttreat.h" #include "dcmtk/dcmrt/drtionpl.h" #include "dcmtk/dcmrt/drtiontr.h" //###################################################### #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //###################################################### #include "dcmtk/dcmrt/drtstrct.h" #include #include #include #include #include #include #include #include class vtkPolyData; class DcmDataset; class OFString; class DRTContourSequence; class DRTStructureSetIOD; namespace mitk { class mitkDicomRT_EXPORT DicomRTReader: public itk::Object { typedef std::deque ContourModelSetVector; + /** + * @brief Describes and holds some information about the beams. + */ class BeamEntry { public: BeamEntry() { Number=-1; SrcAxisDistance=0.0; GantryAngle=0.0; PatientSupportAngle=0.0; BeamLimitingDeviceAngle=0.0; LeafJawPositions[0][0]=0.0; LeafJawPositions[0][1]=0.0; LeafJawPositions[1][0]=0.0; LeafJawPositions[1][1]=0.0; } unsigned int Number; std::string Name; std::string Type; std::string Description; double SrcAxisDistance; double GantryAngle; double PatientSupportAngle; double BeamLimitingDeviceAngle; double LeafJawPositions[2][2]; }; + /** + * @brief Describes and holds some information about the Rois. + */ class RoiEntry { public: RoiEntry(); virtual ~RoiEntry(); RoiEntry(const RoiEntry& src); RoiEntry &operator=(const RoiEntry &src); void SetPolyData(vtkPolyData* roiPolyData); unsigned int Number; std::string Name; std::string Description; double DisplayColor[3]; + //vllt direkt durch die contourmodels ersetzen ?! vtkPolyData* PolyData; }; public: mitkClassMacro( DicomRTReader, itk::Object ); - itkNewMacro( Self ); + /** + * @brief Used for reading a DicomRT file + * @param filename The path with your file which you want to read + * + * Calls the right method for reading a dose, structure or plan file. + */ ContourModelSetVector ReadDicomFile(char* filename); + + /** + * @brief Reads a DcmDataset from a DicomRT structureset file + * @param dataset DcmDataset-object from DCMTK + * @return Returns a Deque with mitk::ContourModelSet + * + * The returned mitk::ContourModelSet represent exactly one Roi/Structureset. + * So the size of the returned deque is the number of Rois. The names of the + * rois is stored in their mitk::Property. + */ ContourModelSetVector ReadStructureSet(DcmDataset* dataset); + + /** + * @brief Reads a DcmDataset from a DicomRT plan file + * @param dataset DcmDataset-object from DCMTK + * @return The return doesnt make senese at the moment + * + * This method isnt ready for use at the moment. Dont use it! + */ int LoadRTPlan(DcmDataset* dataset); + + /** + * @brief Reads a DcmDataset from a DicomRT dose file + * @param dataset DcmDataset-object from DCMTK + * @param filename The path with the dose file used for getting the geometry + * @return Returns a mitk::DataNode::Pointer in which a mitk::Image is stored + * + * The method reads the PixelData from the DicomRT dose file and scales them + * with a factor for getting Gray-values instead of pixel-values. + * The Gray-values are stored in a mitk::Image with an vtkColorTransferFunction. + * Relative values are used for coloring the image. The relative values are + * relative to a PrescriptionDose definied in the RT-Plan. If there is no + * RT-Plan file PrescriptionDose is set to 80% of the maximum dose. + */ mitk::DataNode::Pointer LoadRTDose(DcmDataset* dataset, char* filename); + + /** + * @brief Returns the number of Rois stored in the RoiSequenceVector + * @return unsigned long size_t Number of Rois + */ size_t GetNumberOfRois(); + + /** + * @brief Find a Roi stored in the RoiSequenceVector by his number + * @param roiNumber The number of the searched roi + * @return Returns a mitk::DicomRTReader::RoiEntry object + */ RoiEntry* FindRoiByNumber(int roiNumber); + + /** + * @brief GetReferencedFrameOfReferenceSOPInstanceUID + * @param structSetObject + * @return + */ OFString GetReferencedFrameOfReferenceSOPInstanceUID(DRTStructureSetIOD &structSetObject); + /** + * @brief Compares two mitk::ContourModel::Pointer for testing the Structuresets. + * @param first The first mitk::ContourModel::Pointer + * @param second The second mitk::ContourModel::Pointer + * @return Returns true if they are equal and false if they are different + */ bool Equals(mitk::ContourModel::Pointer first, mitk::ContourModel::Pointer second); /** * Virtual destructor. */ virtual ~DicomRTReader(); protected: + /** + * @brief Storing the Rois found in the Structureset file + */ std::vector RoiSequenceVector; + + /** + * @brief Storing the Beams foud in the RT Plan file + */ std::vector BeamSequenceVector; /** * Constructor. */ DicomRTReader(); }; - - } #endif diff --git a/Plugins/org.mitk.dicomrtview/src/internal/DcmRTV.cpp b/Plugins/org.mitk.dicomrtview/src/internal/DcmRTV.cpp index 419263a80d..1c1848504e 100644 --- a/Plugins/org.mitk.dicomrtview/src/internal/DcmRTV.cpp +++ b/Plugins/org.mitk.dicomrtview/src/internal/DcmRTV.cpp @@ -1,207 +1,199 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include "DcmRTV.h" #include "mitkSegmentationObjectFactory.h" // Qt #include const std::string DcmRTV::VIEW_ID = "org.mitk.views.dcmrtv"; void DcmRTV::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void DcmRTV::CreateQtPartControl( QWidget *parent ) { RegisterSegmentationObjectFactory(); // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); connect( m_Controls.pushButton, SIGNAL(clicked()), this, SLOT(LoadRTDoseFile()) ); } void DcmRTV::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { // iterate all selected objects, adjust warning visibility foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_Controls.buttonPerformImageProcessing->setEnabled( true ); return; } } m_Controls.buttonPerformImageProcessing->setEnabled( true ); } void DcmRTV::DoImageProcessing() { QFileDialog dialog; dialog.setNameFilter(tr("Images (*.dcm")); mitk::DicomSeriesReader::StringContainer files; QStringList fileNames = dialog.getOpenFileNames(); if(fileNames.empty()) { return; } QStringListIterator fileNamesIterator(fileNames); while(fileNamesIterator.hasNext()) { files.push_back(fileNamesIterator.next().toStdString()); } std::string tmp = files.front(); const char* filename = tmp.c_str(); char* filenameC = const_cast(filename); DcmFileFormat file; OFCondition outp = file.loadFile(filename, EXS_Unknown); if(outp.bad()) { QMessageBox::information(NULL,"Error","Cant read the file"); } DcmDataset *dataset = file.getDataset(); mitk::DicomRTReader::Pointer readerRT = mitk::DicomRTReader::New(); std::deque modelVector; modelVector = readerRT->ReadDicomFile(filenameC); if(modelVector.empty()) { QMessageBox::information(NULL, "Error", "Vector is empty ..."); } for(int i=0; iSetData(modelVector.at(i)); - std::stringstream strstr; - if(i+1<10) - { - strstr << "ContourModel0" << i+1; - } - else - { - strstr << "ContourModel" << i+1; - } - x->SetName(strstr.str()); + x->SetProperty("name", modelVector.at(i)->GetProperty("name")); +// x->SetName(modelVector.at(i)->GetProperty("name")); x->SetVisibility(true); GetDataStorage()->Add(x); } mitk::TimeSlicedGeometry::Pointer geo = this->GetDataStorage()->ComputeBoundingGeometry3D(this->GetDataStorage()->GetAll()); mitk::RenderingManager::GetInstance()->InitializeViews( geo ); } void DcmRTV::LoadRTDoseFile() { QFileDialog dialog; dialog.setNameFilter(tr("Images (*.dcm")); mitk::DicomSeriesReader::StringContainer files; QStringList fileNames = dialog.getOpenFileNames(); if(fileNames.empty()) { return; } QStringListIterator fileNamesIterator(fileNames); while(fileNamesIterator.hasNext()) { files.push_back(fileNamesIterator.next().toStdString()); } std::string tmp = files.front(); const char* filename = tmp.c_str(); char* ncFilename = const_cast(filename); mitk::DicomRTReader::Pointer _DicomRTReader = mitk::DicomRTReader::New(); DcmFileFormat file; OFCondition outp = file.loadFile(filename, EXS_Unknown); if(outp.bad()) { QMessageBox::information(NULL,"Error","Cant read the file"); } DcmDataset *dataset = file.getDataset(); mitk::DataNode::Pointer mitkImage = mitk::DataNode::New(); mitkImage = _DicomRTReader->LoadRTDose(dataset,ncFilename); GetDataStorage()->Add(mitkImage); // mitk::DataNode::Pointer doseNode = GetDataStorage()->GetNamedNode("DicomRT Dose"); // mitk::Image::Pointer doseImage = dynamic_cast(doseNode->GetData()); // vtkMarchingSquares* contourFilter = vtkMarchingSquares::New(); // std::deque surfaceStorage; // mitk::ExtractImageFilter::Pointer imageExtractor = mitk::ExtractImageFilter::New(); // mitk::DataNode::Pointer img = this->GetDataStorage()->GetNamedNode("abc"); // mitk::Image::Pointer picture = dynamic_cast(img->GetData()); // imageExtractor->SetInput( picture ); // imageExtractor->SetSliceDimension( 2 ); // imageExtractor->SetSliceIndex( 12 ); // imageExtractor->Update(); // vtkMarchingSquares* contourFilter = vtkMarchingSquares::New(); // vtkPolyData* polyData = vtkPolyData::New(); // contourFilter->SetInput(imageExtractor->GetOutput()->GetVtkImageData()); // contourFilter->SetNumberOfContours(1); // contourFilter->SetValue(0,0.5); // polyData = contourFilter->GetOutput(); // mitk::Surface::Pointer c = mitk::Surface::New(); // c->SetVtkPolyData(polyData); // mitk::Geometry3D::Pointer geo = doseImage->GetGeometry()->Clone(); // mitk::Vector3D spacing; // spacing.Fill(1); // geo->SetSpacing(spacing); // surfaceStorage.push_back(c); // mitk::DataNode::Pointer extractNode = mitk::DataNode::New(); // mitk::Image::Pointer stuff = dynamic_cast(imageExtractor->GetOutput()); // mitk::Geometry3D::Pointer geo2 = stuff->GetGeometry()->Clone(); // mitk::Vector3D spacing2; // spacing2.Fill(1); // geo2->SetSpacing(spacing2); // stuff->SetGeometry(geo); // extractNode->SetData(stuff); // extractNode->SetName("ExtractImage"); // GetDataStorage()->Add(extractNode); // mitk::DataNode::Pointer contourNode = mitk::DataNode::New(); // c->SetGeometry(geo2); // contourNode->SetData(c); // contourNode->SetName("IsoDose"); // GetDataStorage()->Add(contourNode); mitk::TimeSlicedGeometry::Pointer geo3 = this->GetDataStorage()->ComputeBoundingGeometry3D(this->GetDataStorage()->GetAll()); mitk::RenderingManager::GetInstance()->InitializeViews( geo3 ); }