diff --git a/CMake/FindDCMTK.cmake b/CMake/FindDCMTK.cmake index 1ebd82cb10..7996817cd4 100644 --- a/CMake/FindDCMTK.cmake +++ b/CMake/FindDCMTK.cmake @@ -1,180 +1,183 @@ # adapted version of FindDCMTK, better suited for super-builds # - find DCMTK libraries and applications # # DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK # DCMTK_LIBRARIES - Files to link against to use DCMTK # DCMTK_FOUND - If false, don't try to use DCMTK # DCMTK_DIR - (optional) Source directory for DCMTK # # DCMTK_DIR can be used to make it simpler to find the various include # directories and compiled libraries if you've just compiled it in the # source tree. Just set it to the root of the tree where you extracted # the source (default to /usr/include/dcmtk/) #============================================================================= # Copyright 2004-2009 Kitware, Inc. # Copyright 2009-2010 Mathieu Malaterre # Copyright 2010 Thomas Sondergaard # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) # # Written for VXL by Amitha Perera. # Upgraded for GDCM by Mathieu Malaterre. # Modified for EasyViz by Thomas Sondergaard. # # prefer DCMTK_DIR over default system paths like /usr/lib set(CMAKE_PREFIX_PATH ${DCMTK_DIR}/lib ${CMAKE_PREFIX_PATH}) # this is given to FIND_LIBRARY or FIND_PATH if(NOT DCMTK_FOUND AND NOT DCMTK_DIR) set(DCMTK_DIR "/usr/include/dcmtk/" CACHE PATH "Root of DCMTK source tree (optional).") mark_as_advanced(DCMTK_DIR) endif() # Find all libraries, store debug and release separately foreach(lib dcmpstat dcmsr dcmsign dcmtls dcmqrdb dcmnet dcmjpeg dcmimage dcmimgle dcmdata + dcmrt oflog ofstd ijg12 ijg16 ijg8 ) # Find Release libraries find_library(DCMTK_${lib}_LIBRARY_RELEASE ${lib} PATHS ${DCMTK_DIR}/${lib}/libsrc ${DCMTK_DIR}/${lib}/libsrc/Release ${DCMTK_DIR}/${lib}/Release ${DCMTK_DIR}/lib ${DCMTK_DIR}/lib/Release ${DCMTK_DIR}/dcmjpeg/lib${lib}/Release NO_DEFAULT_PATH ) # Find Debug libraries find_library(DCMTK_${lib}_LIBRARY_DEBUG ${lib} PATHS ${DCMTK_DIR}/${lib}/libsrc ${DCMTK_DIR}/${lib}/libsrc/Debug ${DCMTK_DIR}/${lib}/Debug ${DCMTK_DIR}/lib ${DCMTK_DIR}/lib/Debug ${DCMTK_DIR}/dcmjpeg/lib${lib}/Debug NO_DEFAULT_PATH ) mark_as_advanced(DCMTK_${lib}_LIBRARY_RELEASE) mark_as_advanced(DCMTK_${lib}_LIBRARY_DEBUG) # Add libraries to variable according to build type set(DCMTK_${lib}_LIBRARY) if(DCMTK_${lib}_LIBRARY_RELEASE) list(APPEND DCMTK_LIBRARIES optimized ${DCMTK_${lib}_LIBRARY_RELEASE}) list(APPEND DCMTK_${lib}_LIBRARY optimized ${DCMTK_${lib}_LIBRARY_RELEASE}) endif() if(DCMTK_${lib}_LIBRARY_DEBUG) list(APPEND DCMTK_LIBRARIES debug ${DCMTK_${lib}_LIBRARY_DEBUG}) list(APPEND DCMTK_${lib}_LIBRARY debug ${DCMTK_${lib}_LIBRARY_DEBUG}) endif() endforeach() set(DCMTK_config_TEST_HEADER osconfig.h) set(DCMTK_dcmdata_TEST_HEADER dctypes.h) set(DCMTK_dcmimage_TEST_HEADER dicoimg.h) set(DCMTK_dcmimgle_TEST_HEADER dcmimage.h) set(DCMTK_dcmjpeg_TEST_HEADER djdecode.h) set(DCMTK_dcmnet_TEST_HEADER assoc.h) set(DCMTK_dcmpstat_TEST_HEADER dcmpstat.h) set(DCMTK_dcmqrdb_TEST_HEADER dcmqrdba.h) set(DCMTK_dcmsign_TEST_HEADER sicert.h) set(DCMTK_dcmsr_TEST_HEADER dsrtree.h) set(DCMTK_dcmtls_TEST_HEADER tlslayer.h) set(DCMTK_ofstd_TEST_HEADER ofstdinc.h) +set(DCMTK_dcmrt_TEST_HEADER drtstrct.h) foreach(dir config dcmdata dcmimage dcmimgle dcmjpeg dcmnet dcmpstat dcmqrdb dcmsign dcmsr dcmtls + dcmrt ofstd) find_path(DCMTK_${dir}_INCLUDE_DIR ${DCMTK_${dir}_TEST_HEADER} PATHS ${DCMTK_DIR}/${dir}/include ${DCMTK_DIR}/${dir} ${DCMTK_DIR}/include/dcmtk/${dir} ${DCMTK_DIR}/include/${dir}) mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR) #message("** DCMTKs ${dir} found at ${DCMTK_${dir}_INCLUDE_DIR}") if(DCMTK_${dir}_INCLUDE_DIR) list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_${dir}_INCLUDE_DIR}) endif() endforeach() if(WIN32) list(APPEND DCMTK_LIBRARIES netapi32 wsock32) endif() if(DCMTK_ofstd_INCLUDE_DIR) get_filename_component(DCMTK_dcmtk_INCLUDE_DIR ${DCMTK_ofstd_INCLUDE_DIR} PATH CACHE) list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR}) mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(DCMTK DEFAULT_MSG DCMTK_config_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR DCMTK_ofstd_LIBRARY DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmdata_LIBRARY DCMTK_dcmimgle_INCLUDE_DIR DCMTK_dcmimgle_LIBRARY ) # Compatibility: This variable is deprecated set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS}) diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake index b8c6f8f53d..e764edaba2 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake @@ -1,36 +1,36 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) - set(revision_tag de6afaad) + set(revision_tag acedec01) # ^^^^^^^^ these are just to check correct length of hash part ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index d99efaf7d7..4115ae5781 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,79 +1,80 @@ # Modules must be listed according to their dependencies set(module_dirs DataTypesExt AlgorithmsExt MapperExt IOExt DICOMReader DICOMTesting Qt4Qt5TestModule SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport SceneSerialization GraphAlgorithms ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QmlItems Overlays QtWidgets QtWidgetsExt SegmentationUI DiffusionImaging GPGPU IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport QtOverlays InputDevices ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Remeshing Python Persistence IGTUI VtkShaders + DicomRT ) if(MITK_ENABLE_PIC_READER) list(APPEND module_dirs IpPicSupportIO) endif() set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/DicomRT/CMakeLists.txt b/Modules/DicomRT/CMakeLists.txt new file mode 100644 index 0000000000..770c6c7415 --- /dev/null +++ b/Modules/DicomRT/CMakeLists.txt @@ -0,0 +1,10 @@ +# CREATE MODULE HERE +IF (NOT DEFINED DCMTK_dcmrt_LIBRARY OR DCMTK_dcmrt_LIBRARY) +MITK_CREATE_MODULE( + DEPENDS MitkSegmentation MitkSceneSerializationBase + PACKAGE_DEPENDS DCMTK +) +ADD_SUBDIRECTORY(Testing) +ELSE() +MESSAGE("MITK DicomRT Support disabled because the DCMTK dcmrt library not found") +ENDIF() diff --git a/Modules/DicomRT/Testing/CMakeLists.txt b/Modules/DicomRT/Testing/CMakeLists.txt new file mode 100644 index 0000000000..153cd81e2e --- /dev/null +++ b/Modules/DicomRT/Testing/CMakeLists.txt @@ -0,0 +1 @@ +MITK_CREATE_MODULE_TESTS() diff --git a/Modules/DicomRT/Testing/files.cmake b/Modules/DicomRT/Testing/files.cmake new file mode 100644 index 0000000000..0c2dfa33a6 --- /dev/null +++ b/Modules/DicomRT/Testing/files.cmake @@ -0,0 +1,3 @@ +SET(MODULE_TESTS + mitkRTStructureSetReaderTest.cpp +) diff --git a/Modules/DicomRT/Testing/mitkRTStructureSetReaderTest.cpp b/Modules/DicomRT/Testing/mitkRTStructureSetReaderTest.cpp new file mode 100644 index 0000000000..6615729171 --- /dev/null +++ b/Modules/DicomRT/Testing/mitkRTStructureSetReaderTest.cpp @@ -0,0 +1,165 @@ +/*=================================================================== + +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 "mitkTestingMacros.h" +#include + +#include "mitkRTStructureSetReader.h" +#include +#include +#include + +class mitkRTStructureSetReaderTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkRTStructureSetReaderTestSuite); +// MITK_TEST(TestBody); + MITK_TEST(TestStructureSets); + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::RTStructureSetReader::Pointer m_rtStructureReader; + +public: + + void setUp() + { + m_rtStructureReader = mitk::RTStructureSetReader::New(); + CPPUNIT_ASSERT_MESSAGE("Failed to initialize RTStructureSetReader", m_rtStructureReader.IsNotNull()); + } + + void TestStructureSets() + { + std::deque contourModelVectorCorrect; + std::deque contourModelVectorCorrectSequ; + std::deque contourModelVectorTest; + std::deque contourModelVectorTestDel; + + LoadData(contourModelVectorCorrect); + + contourModelVectorTest = m_rtStructureReader->ReadStructureSet(GetTestDataFilePath("RT/StructureSet/RS.dcm").c_str()); + + //Deleting all empty contourmodelsets - empty contourmodelsets cant be + //saved so we have reference for the comparison + for(unsigned int i=0; i(contourModelVectorTest.at(i)->GetData())->GetSize()>0){ + contourModelVectorTestDel.push_back(dynamic_cast(contourModelVectorTest.at(i)->GetData())); + } + } + + //Loop for ordering the loaded contourmodelsets(contourModelVectorCorrect) + for(unsigned int i=0; iGetProperty("name"); + for(unsigned int j=0; jGetProperty("name"); + if(tmp->GetValueAsString().compare(name->GetValueAsString()) == 0) + contourModelVectorCorrectSequ.push_back(contourModelVectorCorrect.at(j)); + } + } + + //Testing wheather the two deques are equal + bool equal = true; + for(unsigned int i=0;iGetSize()!=c2->GetSize()) + { + MITK_INFO << "Number of ContourModelSets different" << endl; + return false; + } + else + { + for(int i=0;iGetSize();++i) + { + mitk::ContourModel::Pointer cm1 = c1->GetContourModelAt(i); + mitk::ContourModel::Pointer cm2 = c2->GetContourModelAt(i); + if(cm1->GetNumberOfVertices()!=cm2->GetNumberOfVertices()) + { + MITK_INFO << "Number of Vertices different" << endl; + return false; + } + else + { + float ep = 0.001; + for(int j=0;jGetNumberOfVertices();++j) + { + mitk::Point3D p1 = cm1->GetVertexAt(i)->Coordinates; + mitk::Point3D p2 = cm2->GetVertexAt(i)->Coordinates; + if(abs(p1[0]-p2[0]) > ep || abs(p1[0]-p2[0]) > ep || abs(p1[0]-p2[0]) > ep) + { + return false; + } + } + } + } + } + return true; + } + + void LoadData(std::deque &r) + { + mitk::ContourModelSetReader::Pointer reader = mitk::ContourModelSetReader::New(); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/BODY.cnt_set")); + reader->Update(); + mitk::ContourModelSet::Pointer cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("BODY")); + r.push_back(cnt_set); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/Bladder.cnt_set")); + reader->Update(); + cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("Bladder")); + r.push_back(cnt_set); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/Femoral Head Lt.cnt_set")); + reader->Update(); + cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("Femoral Head Lt")); + r.push_back(cnt_set); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/Femoral Head RT.cnt_set")); + reader->Update(); + cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("Femoral Head RT")); + r.push_back(cnt_set); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/PTV.cnt_set")); + reader->Update(); + cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("PTV")); + r.push_back(cnt_set); + + reader->SetFileName(GetTestDataFilePath("RT/StructureSet/Rectum.cnt_set")); + reader->Update(); + cnt_set = reader->GetOutput(); + cnt_set->SetProperty("name", mitk::StringProperty::New("Rectum")); + r.push_back(cnt_set); + } + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkRTStructureSetReader) diff --git a/Modules/DicomRT/files.cmake b/Modules/DicomRT/files.cmake new file mode 100644 index 0000000000..e9c78095e7 --- /dev/null +++ b/Modules/DicomRT/files.cmake @@ -0,0 +1,13 @@ +SET(CPP_FILES + mitkRTStructureSetReader.cpp +) + +set(H_FILES + mitkRTStructureSetReader.h +) + +set(TPP_FILES +) + +set(MOC_H_FILES +) diff --git a/Modules/DicomRT/mitkRTStructureSetReader.cpp b/Modules/DicomRT/mitkRTStructureSetReader.cpp new file mode 100644 index 0000000000..923609a878 --- /dev/null +++ b/Modules/DicomRT/mitkRTStructureSetReader.cpp @@ -0,0 +1,248 @@ +/*=================================================================== + +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 "mitkRTStructureSetReader.h" +#include + +#include + +namespace mitk +{ + RTStructureSetReader::RTStructureSetReader(){} + + RTStructureSetReader::~RTStructureSetReader(){} + + RTStructureSetReader::RoiEntry::RoiEntry() + { + Number = 0; + DisplayColor[0]=1.0; + DisplayColor[1]=0.0; + DisplayColor[2]=0.0; + ContourModelSet=mitk::ContourModelSet::New(); + } + + RTStructureSetReader::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]; + ContourModelSet=mitk::ContourModelSet::New(); + SetPolyData(src.ContourModelSet); + } + + RTStructureSetReader::RoiEntry::~RoiEntry(){} + + RTStructureSetReader::RoiEntry& RTStructureSetReader:: + 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.ContourModelSet); + return (*this); + } + + void RTStructureSetReader::RoiEntry:: + SetPolyData(mitk::ContourModelSet::Pointer roiPolyData) + { + if (roiPolyData == this->ContourModelSet) + return; + this->ContourModelSet = roiPolyData; + } + + size_t RTStructureSetReader::GetNumberOfROIs() + { + return this->ROISequenceVector.size(); + } + + RTStructureSetReader::RoiEntry* RTStructureSetReader:: + FindRoiByNumber(unsigned int roiNum) + { + for(unsigned int i=0; iROISequenceVector.size(); ++i) + { + if(this->ROISequenceVector[i].Number == roiNum) + return &this->ROISequenceVector[i]; + } + return NULL; + } + + RTStructureSetReader::ContourModelSetNodes RTStructureSetReader:: + ReadStructureSet(const char* filepath) + { + DcmFileFormat file; + OFCondition output = file.loadFile(filepath, EXS_Unknown); + if(output.bad()) + { + MITK_ERROR << "Cant read the file" << endl; + } + DcmDataset *dataset = file.getDataset(); + + DRTStructureSetIOD structureSetObject; + OFCondition outp = structureSetObject.read(*dataset); + if(!outp.good()) + { + MITK_ERROR << "Error reading the file" << endl; + RTStructureSetReader::ContourModelSetNodes x; + return x; + } + DRTStructureSetROISequence &roiSequence = + structureSetObject.getStructureSetROISequence(); + if(!roiSequence.gotoFirstItem().good()) + { + MITK_ERROR << "Error reading the structure sequence" << endl; + RTStructureSetReader::ContourModelSetNodes 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()); + + Sint32 refRoiNumber; + DRTROIContourSequence &roiContourSeqObject = + structureSetObject.getROIContourSequence(); + if(!roiContourSeqObject.gotoFirstItem().good()) + { + MITK_ERROR << "Error reading the contour sequence" << endl; + RTStructureSetReader::ContourModelSetNodes 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; + } + OFString contourNumber; + OFString numberOfPoints; + OFVector contourData_LPS; + mitk::ContourModel::Pointer contourSequence = + mitk::ContourModel::New(); + + contourItem.getContourNumber(contourNumber); + contourItem.getNumberOfContourPoints(numberOfPoints); + contourItem.getContourData(contourData_LPS); + + for(unsigned int i=0; iAddVertex(point); + } + contourSequence->Close(); + contourSet->AddContourModel(contourSequence); + } + while(contourSeqObject.gotoNextItem().good()); + } + else + { + MITK_ERROR << "Error reading contourSeqObject" << endl; + } + RoiEntry* refROI = this->FindRoiByNumber(refRoiNumber); + if(refROI==NULL) + { + MITK_ERROR << "Can not find references ROI" << endl; + continue; + } + Sint32 roiColor; + for(int j=0;j<3;j++) + { + currentRoiObject.getROIDisplayColor(roiColor, j); + refROI->DisplayColor[j] = roiColor/255.0; + } + refROI->ContourModelSet = contourSet; + contourSet->SetProperty("name", mitk::StringProperty::New(refROI->Name)); + contourSet->SetProperty("contour.color", mitk::ColorProperty::New( + refROI->DisplayColor[0], + refROI->DisplayColor[1], + refROI->DisplayColor[2])); + + } + while(roiContourSeqObject.gotoNextItem().good()); + + std::deque nodes; + + for(unsigned int i=0; iSetData(ROISequenceVector.at(i).ContourModelSet); + node->SetProperty("name", + ROISequenceVector.at(i).ContourModelSet->GetProperty("name")); + node->SetProperty("color", + ROISequenceVector.at(i).ContourModelSet->GetProperty("contour.color")); + node->SetProperty("contour.color", + ROISequenceVector.at(i).ContourModelSet->GetProperty("contour.color")); + + /*The StructureSets should only be visible in the axial-view and the + 3D-view because in the other views they are just points and lines*/ + node->SetVisibility(true, mitk::BaseRenderer::GetInstance + ( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))); + node->SetVisibility(false, mitk::BaseRenderer::GetInstance + ( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget2"))); + node->SetVisibility(false, mitk::BaseRenderer::GetInstance + ( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget3"))); + node->SetVisibility(true, mitk::BaseRenderer::GetInstance + ( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4"))); + nodes.push_back(node); + } + + return nodes; + } +} diff --git a/Modules/DicomRT/mitkRTStructureSetReader.h b/Modules/DicomRT/mitkRTStructureSetReader.h new file mode 100644 index 0000000000..9741553474 --- /dev/null +++ b/Modules/DicomRT/mitkRTStructureSetReader.h @@ -0,0 +1,93 @@ +/*=================================================================== + +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 MITKRTSTRUCTURESETREADER_H +#define MITKRTSTRUCTURESETREADER_H + +#include +#include + +#include +#include +#include + +#include "dcmtk/dcmrt/drtstrct.h" + +#include + +namespace mitk +{ + class MitkDicomRT_EXPORT RTStructureSetReader: public itk::Object + { + typedef std::deque ContourModelSetNodes; + + /** + * Represent a region of interest (ROI) + */ + class RoiEntry + { + public: + RoiEntry(); + RoiEntry( const RoiEntry& src); + virtual ~RoiEntry(); + RoiEntry &operator=(const RoiEntry &src); + + void SetPolyData(ContourModelSet::Pointer roiPolyData); + + unsigned int Number; + std::string Name; + std::string Description; + double DisplayColor[3]; + mitk::ContourModelSet::Pointer ContourModelSet; + }; + + public: + mitkClassMacro( RTStructureSetReader, itk::Object ) + itkNewMacro( Self ) + + /** + * @brief Reading a RT StructureSet from the DICOM file and returns the ROIs + * (region of interest) as a ContourModelSet. One ContourModelSet represent + * one ROI. A ContourModelSet contains ContourModels which represent the + * single structures. + * @param filepath to the RT StructureSet (.dmc) file + * @return Returns a std::deque filled with ContourModelSet::Pointer the + * deque contains all ROIs from the DICOM file + */ + ContourModelSetNodes ReadStructureSet(const char* filepath); + + protected: + /** + * containing the ROIs meta information like name number and description + */ + std::vector ROISequenceVector; + + RTStructureSetReader(); + virtual ~RTStructureSetReader(); + + /** + * Returns the number of ROIs from the ROISequenceVector + */ + size_t GetNumberOfROIs(); + + /** + * Returns the relevant ROI from the ROISequenceVector by its number + */ + RoiEntry* FindRoiByNumber(unsigned int roiNum); + }; +} + +#endif // MITKRTSTRUCTURESETREADER_H