diff --git a/Core/Code/Common/mitkCoreObjectFactory.cpp b/Core/Code/Common/mitkCoreObjectFactory.cpp index 4446750543..eeb17112c9 100644 --- a/Core/Code/Common/mitkCoreObjectFactory.cpp +++ b/Core/Code/Common/mitkCoreObjectFactory.cpp @@ -1,421 +1,403 @@ /*=================================================================== 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 "mitkConfig.h" #include "mitkCoreObjectFactory.h" #include "mitkAffineInteractor.h" #include "mitkColorProperty.h" #include "mitkDataNode.h" #include "mitkEnumerationProperty.h" #include "mitkGeometry2DData.h" #include "mitkGeometry2DDataMapper2D.h" #include "mitkGeometry2DDataVtkMapper3D.h" #include "mitkGeometry3D.h" #include "mitkGeometryData.h" #include "mitkImage.h" -#include "mitkLabelSetImage.h" #include "mitkImageVtkMapper2D.h" -#include "mitkLabelSetImageVtkMapper2D.h" #include "mitkLevelWindowProperty.h" #include "mitkLookupTable.h" #include "mitkLookupTableProperty.h" #include "mitkPlaneGeometry.h" #include "mitkPointSet.h" #include "mitkPointSetVtkMapper2D.h" #include "mitkPointSetVtkMapper3D.h" #include "mitkPolyDataGLMapper2D.h" #include "mitkProperties.h" #include "mitkPropertyList.h" #include "mitkSlicedGeometry3D.h" #include "mitkSmartPointerProperty.h" #include "mitkStringProperty.h" #include "mitkSurface.h" #include "mitkSurfaceGLMapper2D.h" #include "mitkSurfaceVtkMapper3D.h" #include "mitkTimeSlicedGeometry.h" #include "mitkTransferFunctionProperty.h" #include "mitkVolumeDataVtkMapper3D.h" #include "mitkVtkInterpolationProperty.h" #include "mitkVtkRepresentationProperty.h" #include "mitkVtkResliceInterpolationProperty.h" //#include "mitkPicFileIOFactory.h" #include "mitkPointSetIOFactory.h" #include "mitkItkImageFileIOFactory.h" #include "mitkSTLFileIOFactory.h" #include "mitkVtkSurfaceIOFactory.h" #include "mitkVtkImageIOFactory.h" #include "mitkVtiFileIOFactory.h" //#include "mitkPicVolumeTimeSeriesIOFactory.h" #include "mitkImageWriterFactory.h" #include "mitkImageWriter.h" #include "mitkPointSetWriterFactory.h" #include "mitkSurfaceVtkWriterFactory.h" mitk::CoreObjectFactory::FileWriterList mitk::CoreObjectFactory::m_FileWriters; void mitk::CoreObjectFactory::RegisterExtraFactory(CoreObjectFactoryBase* factory) { MITK_DEBUG << "CoreObjectFactory: registering extra factory of type " << factory->GetNameOfClass(); m_ExtraFactories.insert(CoreObjectFactoryBase::Pointer(factory)); } void mitk::CoreObjectFactory::UnRegisterExtraFactory(CoreObjectFactoryBase *factory) { MITK_DEBUG << "CoreObjectFactory: un-registering extra factory of type " << factory->GetNameOfClass(); try { m_ExtraFactories.erase(factory); } catch( std::exception const& e) { MITK_ERROR << "Caugt exception while unregistering: " << e.what(); } } mitk::CoreObjectFactory::Pointer mitk::CoreObjectFactory::GetInstance() { static mitk::CoreObjectFactory::Pointer instance; if (instance.IsNull()) { instance = mitk::CoreObjectFactory::New(); } return instance; } #include void mitk::CoreObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if(node==NULL) return; mitk::DataNode::Pointer nodePointer = node; mitk::Image::Pointer image = dynamic_cast(node->GetData()); if(image.IsNotNull() && image->IsInitialized()) { - mitk::LabelSetImage::Pointer lsimage = dynamic_cast(node->GetData()); - if(lsimage.IsNotNull() && lsimage->IsInitialized()) - { - mitk::LabelSetImageVtkMapper2D::SetDefaultProperties(node); - mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); - } - else - { mitk::ImageVtkMapper2D::SetDefaultProperties(node); mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); - } } mitk::Surface::Pointer surface = dynamic_cast(node->GetData()); if(surface.IsNotNull()) { mitk::SurfaceGLMapper2D::SetDefaultProperties(node); mitk::SurfaceVtkMapper3D::SetDefaultProperties(node); } mitk::PointSet::Pointer pointSet = dynamic_cast(node->GetData()); if(pointSet.IsNotNull()) { mitk::PointSetVtkMapper2D::SetDefaultProperties(node); mitk::PointSetVtkMapper3D::SetDefaultProperties(node); } for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { (*it)->SetDefaultProperties(node); } } mitk::CoreObjectFactory::CoreObjectFactory() { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "CoreObjectFactory c'tor" << std::endl; // FIXME itk::ObjectFactoryBase::RegisterFactory( PicFileIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( PointSetIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( STLFileIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( VtkSurfaceIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( VtkImageIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( VtiFileIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( ItkImageFileIOFactory::New() ); // FIXME itk::ObjectFactoryBase::RegisterFactory( PicVolumeTimeSeriesIOFactory::New() ); mitk::SurfaceVtkWriterFactory::RegisterOneFactory(); mitk::PointSetWriterFactory::RegisterOneFactory(); mitk::ImageWriterFactory::RegisterOneFactory(); m_FileWriters.push_back(mitk::ImageWriter::New().GetPointer()); CreateFileExtensionsMap(); alreadyDone = true; } } mitk::Mapper::Pointer mitk::CoreObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper = NULL; mitk::Mapper::Pointer tmpMapper = NULL; // check whether extra factories provide mapper for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { tmpMapper = (*it)->CreateMapper(node,id); if(tmpMapper.IsNotNull()) newMapper = tmpMapper; } if (newMapper.IsNull()) { mitk::BaseData *data = node->GetData(); if ( id == mitk::BaseRenderer::Standard2D ) { - if((dynamic_cast(data)!=NULL)) - { - newMapper = mitk::LabelSetImageVtkMapper2D::New(); - newMapper->SetDataNode(node); - } - else if((dynamic_cast(data)!=NULL)) + if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ImageVtkMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::Geometry2DDataMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::SurfaceGLMapper2D::New(); // cast because SetDataNode is not virtual mitk::SurfaceGLMapper2D *castedMapper = dynamic_cast(newMapper.GetPointer()); castedMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::PointSetVtkMapper2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { if((dynamic_cast(data) != NULL)) { newMapper = mitk::VolumeDataVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::Geometry2DDataVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::SurfaceVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::PointSetVtkMapper3D::New(); newMapper->SetDataNode(node); } } } return newMapper; } /* // @deprecated // #define EXTERNAL_FILE_EXTENSIONS \ "All known formats(*.dcm *.DCM *.dc3 *.DC3 *.gdcm *.ima *.mhd *.mps *.nii *.pic *.pic.gz *.bmp *.png *.jpg *.tiff *.pvtk *.stl *.vtk *.vtp *.vtu *.obj *.vti *.hdr *.nrrd *.nhdr );;" \ "DICOM files(*.dcm *.DCM *.dc3 *.DC3 *.gdcm);;" \ "DKFZ Pic (*.seq *.pic *.pic.gz *.seq.gz);;" \ "NRRD Vector Images (*.nrrd *.nhdr);;" \ "Point sets (*.mps);;" \ "Sets of 2D slices (*.pic *.pic.gz *.bmp *.png *.dcm *.gdcm *.ima *.tiff);;" \ "Surface files (*.stl *.vtk *.vtp *.obj);;" \ "NIfTI format (*.nii)" #define SAVE_FILE_EXTENSIONS "all (*.pic *.mhd *.vtk *.vti *.hdr *.png *.tiff *.jpg *.hdr *.bmp *.dcm *.gipl *.nii *.nrrd *.nhdr *.spr *.lsm *.dwi *.hdwi *.qbi *.hqbi)" */ /** * @brief This method gets the supported (open) file extensions as string. This string is can then used by the QT QFileDialog widget. * @return The c-string that contains the file extensions * */ const char* mitk::CoreObjectFactory::GetFileExtensions() { MultimapType aMap; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { aMap = (*it)->GetFileExtensionsMap(); this->MergeFileExtensions(m_FileExtensionsMap, aMap); } this->CreateFileExtensions(m_FileExtensionsMap, m_FileExtensions); return m_FileExtensions.c_str(); } /** * @brief Merge the input map into the fileExtensionsMap. Duplicate entries are removed * @param fileExtensionsMap the existing map, it contains value pairs like ("*.dcm", "DICOM files"),("*.dc3", "DICOM files"). * This map is extented/merged with the values from the input map. * @param inputMap the input map, it contains value pairs like ("*.dcm", "DICOM files"),("*.dc3", "DICOM files") returned by * the extra factories. * */ void mitk::CoreObjectFactory::MergeFileExtensions(MultimapType& fileExtensionsMap, MultimapType inputMap) { bool duplicateFound = false; std::pair pairOfIter; for (MultimapType::iterator it = inputMap.begin(); it != inputMap.end(); ++it) { duplicateFound = false; pairOfIter = fileExtensionsMap.equal_range((*it).first); for (MultimapType::iterator it2 = pairOfIter.first; it2 != pairOfIter.second; ++it2) { //cout << " [" << (*it).first << ", " << (*it).second << "]" << endl; std::string aString = (*it2).second; if (aString.compare((*it).second) == 0) { //cout << " DUP!! [" << (*it).first << ", " << (*it).second << "]" << endl; duplicateFound = true; break; } } if (!duplicateFound) { fileExtensionsMap.insert(std::pair((*it).first, (*it).second)); } } } /** * @brief get the defined (open) file extension map * @return the defined (open) file extension map */ mitk::CoreObjectFactoryBase::MultimapType mitk::CoreObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } /** * @brief initialize the file extension entries for open and save */ void mitk::CoreObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.dcm", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.DCM", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.dc3", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.DC3", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.gdcm", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.seq", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.pic", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.pic.gz", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.mhd", "MetaImage")); m_FileExtensionsMap.insert(std::pair("*.seq.gz", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.hdr", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.img", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.img.gz", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.nrrd", "Nearly Raw Raster Data")); m_FileExtensionsMap.insert(std::pair("*.nhdr", "NRRD with detached header")); m_FileExtensionsMap.insert(std::pair("*.mps", "Point sets")); m_FileExtensionsMap.insert(std::pair("*.pic", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.pic.gz", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.bmp", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.png", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.jpg", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.jpeg", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.dcm", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.gdcm", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.ima", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.tiff", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.tif", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.stl", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.vtk", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.vtp", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.obj", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.nii", "NIfTI format")); m_FileExtensionsMap.insert(std::pair("*.nii.gz", "NIfTI format")); -// m_FileExtensionsMap.insert(std::pair("*.lset", "Segmentation files")); //m_SaveFileExtensionsMap.insert(std::pair("*.pic", "DKFZ Pic")); m_SaveFileExtensionsMap.insert(std::pair("*.mhd", "MetaImage")); m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Surface Files")); m_SaveFileExtensionsMap.insert(std::pair("*.vti", "VTK Image Data Files")); m_SaveFileExtensionsMap.insert(std::pair("*.hdr", "Analyze Format")); m_SaveFileExtensionsMap.insert(std::pair("*.png", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.tiff", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.tif", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.jpg", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.jpeg", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.bmp", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.dcm", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.gipl", "UMDS GIPL Format Files")); m_SaveFileExtensionsMap.insert(std::pair("*.nii", "NIfTI format")); m_SaveFileExtensionsMap.insert(std::pair("*.nrrd", "Nearly Raw Raster Data")); m_SaveFileExtensionsMap.insert(std::pair("*.nhdr", "NRRD with detached header")); m_SaveFileExtensionsMap.insert(std::pair("*.lsm", "Microscope Images")); m_SaveFileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); -// m_SaveFileExtensionsMap.insert(std::pair("*.lset", "Segmentation Files")); } /** * @brief This method gets the supported (save) file extensions as string. This string is can then used by the QT QFileDialog widget. * @return The c-string that contains the (save) file extensions * */ const char* mitk::CoreObjectFactory::GetSaveFileExtensions() { MultimapType aMap; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { aMap = (*it)->GetSaveFileExtensionsMap(); this->MergeFileExtensions(m_SaveFileExtensionsMap, aMap); } this->CreateFileExtensions(m_SaveFileExtensionsMap, m_SaveFileExtensions); return m_SaveFileExtensions.c_str(); }; /** * @brief get the defined (save) file extension map * @return the defined (save) file extension map */ mitk::CoreObjectFactoryBase::MultimapType mitk::CoreObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } mitk::CoreObjectFactory::FileWriterList mitk::CoreObjectFactory::GetFileWriters() { FileWriterList allWriters = m_FileWriters; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { FileWriterList list2 = (*it)->GetFileWriters(); allWriters.merge(list2); } return allWriters; } void mitk::CoreObjectFactory::MapEvent(const mitk::Event*, const int) { } diff --git a/Core/Code/DataManagement/mitkLabelSetProperty.cpp b/Core/Code/DataManagement/mitkLabelSetProperty.cpp deleted file mode 100644 index 740bba19f1..0000000000 --- a/Core/Code/DataManagement/mitkLabelSetProperty.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*=================================================================== - -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 "mitkLabelSetProperty.h" - -mitk::LabelSetProperty::LabelSetProperty() -{ -} - -mitk::LabelSetProperty::LabelSetProperty(const LabelSetProperty& other) - : mitk::BaseProperty(other) - , m_LookupTable(other.m_LookupTable) -{ -} - -mitk::LabelSetProperty::LabelSetProperty(const mitk::LookupTable::Pointer lut) -{ - this->SetLookupTable(lut); -} - -bool mitk::LabelSetProperty::IsEqual(const BaseProperty& property) const -{ - return *(this->m_LookupTable) == *(static_cast(property).m_LookupTable); -} - -bool mitk::LabelSetProperty::Assign(const BaseProperty& property) -{ - this->m_LookupTable = static_cast(property).m_LookupTable; - return true; -} - -std::string mitk::LabelSetProperty::GetValueAsString() const -{ - std::stringstream ss; - ss << m_LookupTable; - return ss.str(); -} - -mitk::LabelSetProperty::ValueType mitk::LabelSetProperty::GetValue() const -{ - return m_LookupTable; -} - -void mitk::LabelSetProperty::SetLookupTable(const mitk::LookupTable::Pointer aLookupTable) -{ - if((m_LookupTable != aLookupTable) || (*m_LookupTable != *aLookupTable)) - { - m_LookupTable = aLookupTable; - Modified(); - } -} - -void mitk::LabelSetProperty::SetValue(const ValueType & value) -{ - SetLookupTable(value); -} - -itk::LightObject::Pointer mitk::LabelSetProperty::InternalClone() const -{ - itk::LightObject::Pointer result(new Self(*this)); - return result; -} diff --git a/Core/Code/DataManagement/mitkLabelSetProperty.h b/Core/Code/DataManagement/mitkLabelSetProperty.h deleted file mode 100644 index 67e45732d1..0000000000 --- a/Core/Code/DataManagement/mitkLabelSetProperty.h +++ /dev/null @@ -1,87 +0,0 @@ -/*=================================================================== - -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 __mitkLabelSetProperty_H_ -#define __mitkLabelSetProperty_H_ - -#include -#include "mitkBaseProperty.h" -#include "mitkLookupTable.h" - -namespace mitk { - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4522) -#endif - - //##Documentation - //## @brief Property for LookupTable data - //## - //## @ingroup DataManagement - class MITK_CORE_EXPORT LabelSetProperty : public BaseProperty - { - - protected: - LookupTable::Pointer m_LookupTable; - - LabelSetProperty(); - - LabelSetProperty(const LabelSetProperty&); - - LabelSetProperty(const mitk::LookupTable::Pointer lut); - - public: - - typedef LookupTable::Pointer ValueType; - - mitkClassMacro(LabelSetProperty, BaseProperty); - - itkNewMacro(LabelSetProperty); - mitkNewMacro1Param(LabelSetProperty, const mitk::LookupTable::Pointer); - - itkGetObjectMacro(LookupTable, LookupTable ); - ValueType GetValue() const; - - void SetLookupTable(const mitk::LookupTable::Pointer aLookupTable); - void SetValue(const ValueType&); - - virtual std::string GetValueAsString() const; - - using BaseProperty::operator=; - - private: - - // purposely not implemented - LabelSetProperty& operator=(const LabelSetProperty&); - - itk::LightObject::Pointer InternalClone() const; - - virtual bool IsEqual(const BaseProperty& property) const; - virtual bool Assign(const BaseProperty& property); - - }; - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // namespace mitk - - - -#endif // __mitkLabelSetProperty_H_ diff --git a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp index c31bf7e06a..e5d6637f84 100644 --- a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp +++ b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp @@ -1,1080 +1,1075 @@ /*=================================================================== 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 "mitkImageVtkMapper2D.h" //MITK #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //MITK Rendering #include "vtkMitkThickSlicesFilter.h" #include "vtkMitkLevelWindowFilter.h" #include "vtkNeverTranslucentTexture.h" //VTK #include #include #include #include #include #include #include #include #include #include #include #include //ITK #include #include mitk::ImageVtkMapper2D::ImageVtkMapper2D() { } mitk::ImageVtkMapper2D::~ImageVtkMapper2D() { //The 3D RW Mapper (Geometry2DDataVtkMapper3D) is listening to this event, //in order to delete the images from the 3D RW. this->InvokeEvent( itk::DeleteEvent() ); } //set the two points defining the textured plane according to the dimension and spacing void mitk::ImageVtkMapper2D::GeneratePlane(mitk::BaseRenderer* renderer, vtkFloatingPointType planeBounds[6]) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); float depth = this->CalculateLayerDepth(renderer); //Set the origin to (xMin; yMin; depth) of the plane. This is necessary for obtaining the correct //plane size in crosshair rotation and swivel mode. localStorage->m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth); //These two points define the axes of the plane in combination with the origin. //Point 1 is the x-axis and point 2 the y-axis. //Each plane is transformed according to the view (axial, coronal and saggital) afterwards. localStorage->m_Plane->SetPoint1(planeBounds[1] , planeBounds[2], depth); //P1: (xMax, yMin, depth) localStorage->m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth); //P2: (xMin, yMax, depth) } float mitk::ImageVtkMapper2D::CalculateLayerDepth(mitk::BaseRenderer* renderer) { //get the clipping range to check how deep into z direction we can render images double maxRange = renderer->GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1]; //Due to a VTK bug, we cannot use the whole clipping range. /100 is empirically determined float depth = -maxRange*0.01; // divide by 100 int layer = 0; GetDataNode()->GetIntProperty( "layer", layer, renderer); //add the layer property for each image to render images with a higher layer on top of the others depth += layer*10; //*10: keep some room for each image (e.g. for QBalls in between) if(depth > 0.0f) { depth = 0.0f; MITK_WARN << "Layer value exceeds clipping range. Set to minimum instead."; } return depth; } const mitk::Image* mitk::ImageVtkMapper2D::GetInput( void ) { return static_cast< const mitk::Image * >( GetDataNode()->GetData() ); } vtkProp* mitk::ImageVtkMapper2D::GetVtkProp(mitk::BaseRenderer* renderer) { //return the actor corresponding to the renderer return m_LSH.GetLocalStorage(renderer)->m_Actors; } void mitk::ImageVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); mitk::Image *input = const_cast< mitk::Image * >( this->GetInput() ); mitk::DataNode* datanode = this->GetDataNode(); if ( input == NULL || input->IsInitialized() == false ) { return; } //check if there is a valid worldGeometry const Geometry2D *worldGeometry = renderer->GetCurrentWorldGeometry2D(); if( ( worldGeometry == NULL ) || ( !worldGeometry->IsValid() ) || ( !worldGeometry->HasReferenceGeometry() )) { return; } input->Update(); // early out if there is no intersection of the current rendering geometry // and the geometry of the image that is to be rendered. if ( !RenderingGeometryIntersectsImage( worldGeometry, input->GetSlicedGeometry() ) ) { // set image to NULL, to clear the texture in 3D, because // the latest image is used there if the plane is out of the geometry // see bug-13275 localStorage->m_ReslicedImage = NULL; localStorage->m_Mapper->SetInput( localStorage->m_EmptyPolyData ); + localStorage->m_OutlineActor->SetVisibility(false); + localStorage->m_OutlineShadowActor->SetVisibility(false); return; } + localStorage->m_OutlineActor->SetVisibility(true); + //set main input for ExtractSliceFilter localStorage->m_Reslicer->SetInput(input); localStorage->m_Reslicer->SetWorldGeometry(worldGeometry); localStorage->m_Reslicer->SetTimeStep( this->GetTimestep() ); //set the transformation of the image to adapt reslice axis localStorage->m_Reslicer->SetResliceTransformByGeometry( input->GetTimeSlicedGeometry()->GetGeometry3D( this->GetTimestep() ) ); //is the geometry of the slice based on the input image or the worldgeometry? bool inPlaneResampleExtentByGeometry = false; datanode->GetBoolProperty("in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer); localStorage->m_Reslicer->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry); // Initialize the interpolation mode for resampling; switch to nearest // neighbor if the input image is too small. if ( (input->GetDimension() >= 3) && (input->GetDimension(2) > 1) ) { VtkResliceInterpolationProperty *resliceInterpolationProperty; datanode->GetProperty( resliceInterpolationProperty, "reslice interpolation" ); int interpolationMode = VTK_RESLICE_NEAREST; if ( resliceInterpolationProperty != NULL ) { interpolationMode = resliceInterpolationProperty->GetInterpolation(); } switch ( interpolationMode ) { case VTK_RESLICE_NEAREST: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_NEAREST); break; case VTK_RESLICE_LINEAR: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_LINEAR); break; case VTK_RESLICE_CUBIC: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_CUBIC); break; } } else { localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_NEAREST); } //set the vtk output property to true, makes sure that no unneeded mitk image convertion //is done. localStorage->m_Reslicer->SetVtkOutputRequest(true); //Thickslicing int thickSlicesMode = 0; int thickSlicesNum = 1; // Thick slices parameters if( input->GetPixelType().GetNumberOfComponents() == 1 ) // for now only single component are allowed { DataNode *dn=renderer->GetCurrentWorldGeometry2DNode(); if(dn) { ResliceMethodProperty *resliceMethodEnumProperty=0; if( dn->GetProperty( resliceMethodEnumProperty, "reslice.thickslices" ) && resliceMethodEnumProperty ) thickSlicesMode = resliceMethodEnumProperty->GetValueAsId(); IntProperty *intProperty=0; if( dn->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty ) { thickSlicesNum = intProperty->GetValue(); if(thickSlicesNum < 1) thickSlicesNum=1; if(thickSlicesNum > 10) thickSlicesNum=10; } } else { MITK_WARN << "no associated widget plane data tree node found"; } } const PlaneGeometry *planeGeometry = dynamic_cast< const PlaneGeometry * >( worldGeometry ); if(thickSlicesMode > 0) { double dataZSpacing = 1.0; Vector3D normInIndex, normal; if ( planeGeometry != NULL ){ normal = planeGeometry->GetNormal(); }else{ const mitk::AbstractTransformGeometry* abstractGeometry = dynamic_cast< const AbstractTransformGeometry * >(worldGeometry); if(abstractGeometry != NULL) normal = abstractGeometry->GetPlane()->GetNormal(); else return; //no fitting geometry set } normal.Normalize(); input->GetTimeSlicedGeometry()->GetGeometry3D( this->GetTimestep() )->WorldToIndex( normal, normInIndex ); dataZSpacing = 1.0 / normInIndex.GetNorm(); localStorage->m_Reslicer->SetOutputDimensionality( 3 ); localStorage->m_Reslicer->SetOutputSpacingZDirection(dataZSpacing); localStorage->m_Reslicer->SetOutputExtentZDirection( -thickSlicesNum, 0+thickSlicesNum ); // Do the reslicing. Modified() is called to make sure that the reslicer is // executed even though the input geometry information did not change; this // is necessary when the input /em data, but not the /em geometry changes. localStorage->m_TSFilter->SetThickSliceMode( thickSlicesMode-1 ); localStorage->m_TSFilter->SetInput( localStorage->m_Reslicer->GetVtkOutput() ); //vtkFilter=>mitkFilter=>vtkFilter update mechanism will fail without calling manually localStorage->m_Reslicer->Modified(); localStorage->m_Reslicer->Update(); localStorage->m_TSFilter->Modified(); localStorage->m_TSFilter->Update(); localStorage->m_ReslicedImage = localStorage->m_TSFilter->GetOutput(); } else { //this is needed when thick mode was enable bevore. These variable have to be reset to default values localStorage->m_Reslicer->SetOutputDimensionality( 2 ); localStorage->m_Reslicer->SetOutputSpacingZDirection(1.0); localStorage->m_Reslicer->SetOutputExtentZDirection( 0, 0 ); localStorage->m_Reslicer->Modified(); //start the pipeline with updating the largest possible, needed if the geometry of the input has changed localStorage->m_Reslicer->UpdateLargestPossibleRegion(); localStorage->m_ReslicedImage = localStorage->m_Reslicer->GetVtkOutput(); } // Bounds information for reslicing (only reuqired if reference geometry // is present) //this used for generating a vtkPLaneSource with the right size vtkFloatingPointType sliceBounds[6]; for ( int i = 0; i < 6; ++i ) { sliceBounds[i] = 0.0; } localStorage->m_Reslicer->GetClippedPlaneBounds(sliceBounds); //get the spacing of the slice localStorage->m_mmPerPixel = localStorage->m_Reslicer->GetOutputSpacing(); // calculate minimum bounding rect of IMAGE in texture { vtkFloatingPointType textureClippingBounds[6]; for ( int i = 0; i < 6; ++i ) { textureClippingBounds[i] = 0.0; } // Calculate the actual bounds of the transformed plane clipped by the // dataset bounding box; this is required for drawing the texture at the // correct position during 3D mapping. mitk::PlaneClipping::CalculateClippedPlaneBounds( input->GetGeometry(), planeGeometry, textureClippingBounds ); textureClippingBounds[0] = static_cast< int >( textureClippingBounds[0] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[1] = static_cast< int >( textureClippingBounds[1] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[2] = static_cast< int >( textureClippingBounds[2] / localStorage->m_mmPerPixel[1] + 0.5 ); textureClippingBounds[3] = static_cast< int >( textureClippingBounds[3] / localStorage->m_mmPerPixel[1] + 0.5 ); //clipping bounds for cutting the image localStorage->m_LevelWindowFilter->SetClippingBounds(textureClippingBounds); } //get the number of scalar components to distinguish between different image types int numberOfComponents = localStorage->m_ReslicedImage->GetNumberOfScalarComponents(); //get the binary property bool binary = false; bool binaryOutline = false; datanode->GetBoolProperty( "binary", binary, renderer ); if(binary) //binary image { datanode->GetBoolProperty( "outline binary", binaryOutline, renderer ); if(binaryOutline) //contour rendering { if ( input->GetPixelType().GetBpe() <= 8 ) { //generate contours/outlines localStorage->m_OutlinePolyData = CreateOutlinePolyData(renderer); float binaryOutlineWidth(1.0); if ( datanode->GetFloatProperty( "outline width", binaryOutlineWidth, renderer ) ) { - if ( localStorage->m_Actors->GetNumberOfPaths() > 1 ) - { - float binaryOutlineShadowWidth(1.5); - datanode->GetFloatProperty( "outline shadow width", binaryOutlineShadowWidth, renderer ); - - dynamic_cast(localStorage->m_Actors->GetParts()->GetItemAsObject(0)) - ->GetProperty()->SetLineWidth( binaryOutlineWidth * binaryOutlineShadowWidth ); - } + float binaryOutlineShadowWidth(1.5); + datanode->GetFloatProperty( "outline shadow width", binaryOutlineShadowWidth, renderer ); - localStorage->m_Actor->GetProperty()->SetLineWidth( binaryOutlineWidth ); + localStorage->m_OutlineShadowActor->GetProperty()->SetLineWidth( binaryOutlineWidth * binaryOutlineShadowWidth ); + localStorage->m_OutlineActor->GetProperty()->SetLineWidth( binaryOutlineWidth ); } } else { binaryOutline = false; this->ApplyLookuptable(renderer); MITK_WARN << "Type of all binary images should be (un)signed char. Outline does not work on other pixel types!"; } } else //standard binary image { if(numberOfComponents != 1) { MITK_ERROR << "Rendering Error: Binary Images with more then 1 component are not supported!"; } } } if (!(numberOfComponents == 1 || numberOfComponents == 3 || numberOfComponents == 4)) { MITK_WARN << "Unknown number of components!"; } this->ApplyOpacity( renderer ); this->ApplyRenderingMode(renderer); // do not use a VTK lookup table (we do that ourselves in m_LevelWindowFilter) localStorage->m_Texture->MapColorScalarsThroughLookupTableOff(); //connect the input with the levelwindow filter localStorage->m_LevelWindowFilter->SetInput(localStorage->m_ReslicedImage); //connect the texture with the output of the levelwindow filter // check for texture interpolation property bool textureInterpolation = false; GetDataNode()->GetBoolProperty( "texture interpolation", textureInterpolation, renderer ); //set the interpolation modus according to the property localStorage->m_Texture->SetInterpolate(textureInterpolation); localStorage->m_Texture->SetInputConnection(localStorage->m_LevelWindowFilter->GetOutputPort()); this->TransformActor( renderer ); - vtkActor* contourShadowActor = dynamic_cast (localStorage->m_Actors->GetParts()->GetItemAsObject(0)); - if(binary && binaryOutline) //connect the mapper with the polyData which contains the lines { //We need the contour for the binary outline property as actor localStorage->m_Mapper->SetInput(localStorage->m_OutlinePolyData); + localStorage->m_OutlineMapper->SetInput(localStorage->m_OutlinePolyData); localStorage->m_Actor->SetTexture(NULL); //no texture for contours bool binaryOutlineShadow( false ); datanode->GetBoolProperty( "outline binary shadow", binaryOutlineShadow, renderer ); if ( binaryOutlineShadow ) - contourShadowActor->SetVisibility( true ); + localStorage->m_OutlineShadowActor->SetVisibility( true ); else - contourShadowActor->SetVisibility( false ); + localStorage->m_OutlineShadowActor->SetVisibility( false ); } else { //Connect the mapper with the input texture. This is the standard case. //setup the textured plane this->GeneratePlane( renderer, sliceBounds ); //set the plane as input for the mapper localStorage->m_Mapper->SetInputConnection(localStorage->m_Plane->GetOutputPort()); //set the texture for the actor localStorage->m_Actor->SetTexture(localStorage->m_Texture); - contourShadowActor->SetVisibility( false ); + localStorage->m_OutlineActor->SetVisibility( false ); + localStorage->m_OutlineShadowActor->SetVisibility( false ); } // We have been modified => save this for next Update() // localStorage->m_LastDataUpdateTime.Modified(); } void mitk::ImageVtkMapper2D::ApplyLevelWindow(mitk::BaseRenderer *renderer) { LocalStorage *localStorage = this->GetLocalStorage( renderer ); LevelWindow levelWindow; this->GetDataNode()->GetLevelWindow( levelWindow, renderer, "levelwindow" ); localStorage->m_LevelWindowFilter->GetLookupTable()->SetRange( levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound() ); mitk::LevelWindow opacLevelWindow; if( this->GetDataNode()->GetLevelWindow( opacLevelWindow, renderer, "opaclevelwindow" ) ) { //pass the opaque level window to the filter localStorage->m_LevelWindowFilter->SetMinOpacity(opacLevelWindow.GetLowerWindowBound()); localStorage->m_LevelWindowFilter->SetMaxOpacity(opacLevelWindow.GetUpperWindowBound()); } else { //no opaque level window localStorage->m_LevelWindowFilter->SetMinOpacity(0.0); localStorage->m_LevelWindowFilter->SetMaxOpacity(255.0); } } void mitk::ImageVtkMapper2D::ApplyColor( mitk::BaseRenderer* renderer ) { LocalStorage *localStorage = this->GetLocalStorage( renderer ); float rgb[3]= { 1.0f, 1.0f, 1.0f }; // check for color prop and use it for rendering if it exists // binary image hovering & binary image selection bool isHovered = false; bool isSelected = false; bool isBinary = false; bool isOutlined = false; GetDataNode()->GetBoolProperty("binaryimage.ishovering", isHovered, renderer); GetDataNode()->GetBoolProperty("selected", isSelected, renderer); GetDataNode()->GetBoolProperty("binary", isBinary, renderer); GetDataNode()->GetBoolProperty( "outline binary", isOutlined, renderer ); if (isBinary) { if (isSelected) { mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty ("binaryimage.selectedcolor", renderer)); if(colorprop.IsNotNull()) { memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } else { GetDataNode()->GetColor(rgb, renderer, "color"); } } else if (isHovered) { mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty ("binaryimage.hoveringcolor", renderer)); if(colorprop.IsNotNull()) { memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } else { GetDataNode()->GetColor( rgb, renderer, "color" ); } } else { GetDataNode()->GetColor( rgb, renderer, "color" ); } if(isOutlined) { - if ( localStorage->m_Actors->GetParts()->GetNumberOfItems() > 1 ) + float rgb[3]= { 1.0f, 1.0f, 1.0f }; + mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty + ("outline binary shadow color", renderer)); + if(colorprop.IsNotNull()) { - float rgb[3]= { 1.0f, 1.0f, 1.0f }; - mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty - ("outline binary shadow color", renderer)); - if(colorprop.IsNotNull()) - { - memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); - } - double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; //conversion to double for VTK - - vtkActor* contourShadowActor = dynamic_cast (localStorage->m_Actors->GetParts()->GetItemAsObject(0)); - if (contourShadowActor) - { - contourShadowActor->GetProperty()->SetColor(rgbConv); - } + memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } + double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; //conversion to double for VTK + + localStorage->m_OutlineShadowActor->GetProperty()->SetColor(rgbConv); } } else { GetDataNode()->GetColor( rgb, renderer, "color" ); } // finally, set the color to the principal actor double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; //conversion to double for VTK localStorage->m_Actor->GetProperty()->SetColor(rgbConv); } void mitk::ImageVtkMapper2D::ApplyOpacity( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage( renderer ); float opacity = 1.0f; // check for opacity prop and use it for rendering if it exists GetDataNode()->GetOpacity( opacity, renderer, "opacity" ); //set the opacity according to the properties localStorage->m_Actor->GetProperty()->SetOpacity(opacity); - if ( localStorage->m_Actors->GetParts()->GetNumberOfItems() > 1 ) - { - dynamic_cast( localStorage->m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetOpacity(opacity); - } + localStorage->m_OutlineActor->GetProperty()->SetOpacity(opacity); + localStorage->m_OutlineShadowActor->GetProperty()->SetOpacity(opacity); } void mitk::ImageVtkMapper2D::ApplyRenderingMode( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); //all other image types can make use of the rendering mode int renderingMode = mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW; mitk::RenderingModeProperty::Pointer rmProp = dynamic_cast(this->GetDataNode()->GetProperty( "Image Rendering.Mode", renderer )); if (rmProp.IsNotNull()) { renderingMode = rmProp->GetRenderingMode(); } mitk::LookupTableProperty* lutProp = dynamic_cast (this->GetDataNode()->GetProperty("LookupTable")); mitk::EnumerationProperty* cmProp = dynamic_cast (this->GetDataNode()->GetProperty("colormap")); if ( cmProp && lutProp ) { if (cmProp->GetValueAsId() != localStorage->m_ColorMap) { lutProp->GetLookupTable()->SetActiveColormap( cmProp->GetValueAsId() ); /* mitk::LevelWindow lw; lw.SetAuto( static_cast(this->GetDataNode()->GetData()), false, true ); this->GetDataNode()->SetProperty( "levelwindow", mitk::LevelWindowProperty::New( lw ) ); */ localStorage->m_ColorMap = cmProp->GetValueAsId(); } } switch(renderingMode) { case mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW: MITK_DEBUG << "'Image Rendering.Mode' = LOOKUPTABLE_LEVELWINDOW"; this->ApplyLookuptable( renderer ); this->ApplyLevelWindow( renderer ); this->ApplyColor( renderer ); break; case mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_LEVELWINDOW: MITK_DEBUG << "'Image Rendering.Mode' = COLORTRANSFERFUNCTION_LEVELWINDOW"; this->ApplyColorTransferFunction( renderer ); this->ApplyLevelWindow( renderer ); break; case mitk::RenderingModeProperty::LOOKUPTABLE: MITK_DEBUG << "'Image Rendering.Mode' = LOOKUPTABLE"; this->ApplyLookuptable( renderer ); this->ApplyColor( renderer ); break; case mitk::RenderingModeProperty::COLORTRANSFERFUNCTION: MITK_DEBUG << "'Image Rendering.Mode' = COLORTRANSFERFUNCTION"; this->ApplyColorTransferFunction( renderer ); break; default: MITK_ERROR << "No valid 'Image Rendering.Mode' set"; break; } } void mitk::ImageVtkMapper2D::ApplyLookuptable( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); int colormap = mitk::ColormapProperty::CM_BW; mitk::ColormapProperty::Pointer cmProp = dynamic_cast(this->GetDataNode()->GetProperty( "colormap", renderer )); if(cmProp.IsNotNull()) { colormap = cmProp->GetColormap(); } mitk::LookupTableProperty::Pointer lutProp = dynamic_cast(this->GetDataNode()->GetProperty("LookupTable")); if( lutProp.IsNotNull() ) { localStorage->m_LevelWindowFilter->SetLookupTable(lutProp->GetLookupTable()->GetVtkLookupTable()); } else { MITK_WARN << "Image Rendering.Mode was set to use a lookup table but there is no property 'LookupTable'. A default (rainbow) lookup table will be used."; } } void mitk::ImageVtkMapper2D::ApplyColorTransferFunction(mitk::BaseRenderer *renderer) { mitk::TransferFunctionProperty::Pointer transferFunctionProp = dynamic_cast(this->GetDataNode()->GetProperty("Image Rendering.Transfer Function",renderer )); if( transferFunctionProp.IsNull() ) { MITK_ERROR << "'Image Rendering.Mode'' was set to use a color transfer function but there is no property 'Image Rendering.Transfer Function'. Nothing will be done."; return; } LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); //pass the transfer function to our level window filter localStorage->m_LevelWindowFilter->SetLookupTable(transferFunctionProp->GetValue()->GetColorTransferFunction()); localStorage->m_LevelWindowFilter->SetOpacityPiecewiseFunction(transferFunctionProp->GetValue()->GetScalarOpacityFunction()); } void mitk::ImageVtkMapper2D::Update(mitk::BaseRenderer* renderer) { bool visible = true; const DataNode *node = this->GetDataNode(); node->GetVisibility(visible, renderer, "visible"); if ( !visible ) { return; } mitk::Image* image = const_cast( this->GetInput() ); if ( image == NULL ) { return; } // Calculate time step of the input data for the specified renderer (integer value) this->CalculateTimeStep( renderer ); // Check if time step is valid const TimeSlicedGeometry *dataTimeGeometry = image->GetTimeSlicedGeometry(); if ( ( dataTimeGeometry == NULL ) || ( dataTimeGeometry->GetTimeSteps() == 0 ) || ( !dataTimeGeometry->IsValidTime( this->GetTimestep() ) ) ) { return; } image->UpdateOutputInformation(); LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //check if something important has changed and we need to rerender //(localStorage->m_LastDataUpdateTime < node->GetMTime()) // this one is too generic if ( (localStorage->m_LastDataUpdateTime < image->GetMTime()) //was the data modified? || (localStorage->m_LastDataUpdateTime < image->GetPipelineMTime()) || (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldGeometry2DUpdateTime()) //was the geometry modified? || (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldGeometry2D()->GetMTime()) ) { this->GenerateDataForRenderer( renderer ); localStorage->m_LastDataUpdateTime.Modified(); } else if ( (localStorage->m_LastPropertyUpdateTime < node->GetPropertyList()->GetMTime()) //was a property modified? || (localStorage->m_LastPropertyUpdateTime < node->GetPropertyList(renderer)->GetMTime()) ) { this->ApplyOpacity(renderer); this->ApplyRenderingMode(renderer); localStorage->m_LastPropertyUpdateTime.Modified(); } } void mitk::ImageVtkMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { mitk::Image::Pointer image = dynamic_cast(node->GetData()); if (image.IsNull()) { MITK_ERROR << "Setting default properties to a node without an image"; return; } // Properties common for both images and segmentations node->AddProperty( "depthOffset", mitk::FloatProperty::New( 0.0 ), renderer, overwrite ); node->AddProperty( "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "outline width", mitk::FloatProperty::New( 1.0 ), renderer, overwrite ); node->AddProperty( "outline binary shadow", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "outline binary shadow color", ColorProperty::New(0.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "outline shadow width", mitk::FloatProperty::New( 1.5 ), renderer, overwrite ); if(image->IsRotated()) node->AddProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New(VTK_RESLICE_CUBIC) ); else node->AddProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ); node->AddProperty( "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ); // set to user configurable default value (see global options) node->AddProperty( "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ); node->AddProperty( "bounding box", mitk::BoolProperty::New( false ) ); mitk::RenderingModeProperty::Pointer renderingModeProperty = mitk::RenderingModeProperty::New( mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW ); node->AddProperty( "Image Rendering.Mode", renderingModeProperty); mitk::ColormapProperty::Pointer colormapProperty = mitk::ColormapProperty::New(); node->AddProperty( "colormap", colormapProperty, renderer, overwrite ); mitk::LookupTableProperty::Pointer lutProp = mitk::LookupTableProperty::New(); node->AddProperty( "LookupTable", lutProp, renderer, overwrite ); std::string photometricInterpretation; // DICOM tag telling us how pixel values should be displayed if ( node->GetStringProperty( "dicom.pixel.PhotometricInterpretation", photometricInterpretation ) ) { // modality provided by DICOM or other reader if ( photometricInterpretation.find("MONOCHROME1") != std::string::npos ) // meaning: display MINIMUM pixels as WHITE { colormapProperty->SetValue(mitk::ColormapProperty::CM_BWINVERSE); } else if ( photometricInterpretation.find("MONOCHROME2") != std::string::npos ) // meaning: display MINIMUM pixels as BLACK { colormapProperty->SetValue(mitk::ColormapProperty::CM_BW); } // PALETTE interpretation should be handled ok by RGB loading } bool isBinaryImage(false); - if ( !node->GetBoolProperty("binary", isBinaryImage) ) + if ( !node->GetBoolProperty("binary", isBinaryImage) && overwrite ) { // ok, property is not set, use heuristic to determine if this // is a binary image mitk::Image::Pointer centralSliceImage; ScalarType minValue = 0.0; ScalarType maxValue = 0.0; ScalarType min2ndValue = 0.0; ScalarType max2ndValue = 0.0; mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New(); sliceSelector->SetInput(image); sliceSelector->SetSliceNr(image->GetDimension(2)/2); sliceSelector->SetTimeNr(image->GetDimension(3)/2); sliceSelector->SetChannelNr(image->GetDimension(4)/2); sliceSelector->Update(); centralSliceImage = sliceSelector->GetOutput(); if ( centralSliceImage.IsNotNull() && centralSliceImage->IsInitialized() ) { minValue = centralSliceImage->GetStatistics()->GetScalarValueMin(); maxValue = centralSliceImage->GetStatistics()->GetScalarValueMax(); min2ndValue = centralSliceImage->GetStatistics()->GetScalarValue2ndMin(); max2ndValue = centralSliceImage->GetStatistics()->GetScalarValue2ndMax(); } if ((maxValue == min2ndValue && minValue == max2ndValue) || minValue == maxValue) { // centralSlice is strange, lets look at all data minValue = image->GetStatistics()->GetScalarValueMin(); maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(); min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(); max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(); } isBinaryImage = ( maxValue == min2ndValue && minValue == max2ndValue ); } // some more properties specific for a binary... if (isBinaryImage) { - node->AddProperty( "opacity", FloatProperty::New(0.3f), renderer, overwrite ); + node->AddProperty( "opacity", FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.selectedcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.selectedannotationcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.hoveringcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.hoveringannotationcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binary", BoolProperty::New( true ), renderer, overwrite ); node->AddProperty( "layer", IntProperty::New(10), renderer, overwrite); colormapProperty->SetValue( ColormapProperty::CM_LEGACYBINARY ); } else // or regular image { node->AddProperty( "opacity", FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "color", ColorProperty::New(1.0,1.0,1.0), renderer, overwrite ); node->AddProperty( "binary", BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "layer", IntProperty::New(0), renderer, overwrite ); colormapProperty->SetValue( ColormapProperty::CM_BW ); // initialize level/window from DICOM tags std::string sLevel; std::string sWindow; if ( image->GetPropertyList()->GetStringProperty( "dicom.voilut.WindowCenter", sLevel ) && image->GetPropertyList()->GetStringProperty( "dicom.voilut.WindowWidth", sWindow ) ) { float level = atof( sLevel.c_str() ); float window = atof( sWindow.c_str() ); mitk::LevelWindow contrast; std::string sSmallestPixelValueInSeries; std::string sLargestPixelValueInSeries; if ( image->GetPropertyList()->GetStringProperty( "dicom.series.SmallestPixelValueInSeries", sSmallestPixelValueInSeries ) && image->GetPropertyList()->GetStringProperty( "dicom.series.LargestPixelValueInSeries", sLargestPixelValueInSeries ) ) { float smallestPixelValueInSeries = atof( sSmallestPixelValueInSeries.c_str() ); float largestPixelValueInSeries = atof( sLargestPixelValueInSeries.c_str() ); contrast.SetRangeMinMax( smallestPixelValueInSeries-1, largestPixelValueInSeries+1 ); // why not a little buffer? // might remedy some l/w widget challenges } else { contrast.SetAuto( static_cast(node->GetData()), false, true ); // we need this as a fallback } contrast.SetLevelWindow( level, window, true ); node->AddProperty( "levelwindow", LevelWindowProperty::New( contrast ), renderer ); } else { mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); mitk::LevelWindow levelwindow; levelwindow.SetAuto( image ); levWinProp->SetLevelWindow( levelwindow ); node->AddProperty( "levelwindow", levWinProp, renderer, overwrite ); } } if(((overwrite) || (node->GetProperty("opaclevelwindow", renderer)==NULL)) && (image->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA) && (image->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR) ) { mitk::LevelWindow opaclevwin; opaclevwin.SetRangeMinMax(0,255); opaclevwin.SetWindowBounds(0,255); mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(opaclevwin); node->AddProperty( "opaclevelwindow", levWinProp, renderer, overwrite ); } Superclass::SetDefaultProperties(node, renderer, overwrite); } mitk::ImageVtkMapper2D::LocalStorage* mitk::ImageVtkMapper2D::GetLocalStorage(mitk::BaseRenderer* renderer) { return m_LSH.GetLocalStorage(renderer); } vtkSmartPointer mitk::ImageVtkMapper2D::CreateOutlinePolyData(mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage(renderer); //get the min and max index values of each direction int* extent = localStorage->m_ReslicedImage->GetExtent(); int xMin = extent[0]; int xMax = extent[1]; int yMin = extent[2]; int yMax = extent[3]; int* dims = localStorage->m_ReslicedImage->GetDimensions(); //dimensions of the image int line = dims[0]; //how many pixels per line? int x = xMin; //pixel index x int y = yMin; //pixel index y char* currentPixel; //get the depth for each contour float depth = CalculateLayerDepth(renderer); vtkSmartPointer points = vtkSmartPointer::New(); //the points to draw vtkSmartPointer lines = vtkSmartPointer::New(); //the lines to connect the points // We take the pointer to the first pixel of the image currentPixel = static_cast(localStorage->m_ReslicedImage->GetScalarPointer() ); while (y <= yMax) { //if the current pixel value is set to something if ((currentPixel) && (*currentPixel != 0)) { //check in which direction a line is necessary //a line is added if the neighbor of the current pixel has the value 0 //and if the pixel is located at the edge of the image //if vvvvv not the first line vvvvv if (y > yMin && *(currentPixel-line) == 0) { //x direction - bottom edge of the pixel //add the 2 points vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); //add the line between both points lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last line vvvvv if (y < yMax && *(currentPixel+line) == 0) { //x direction - top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the first pixel vvvvv if ( (x > xMin || y > yMin) && *(currentPixel-1) == 0) { //y direction - left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last pixel vvvvv if ( (y < yMax || (x < xMax) ) && *(currentPixel+1) == 0) { //y direction - right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } /* now consider pixels at the edge of the image */ //if vvvvv left edge of image vvvvv if (x == xMin) { //draw left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv right edge of image vvvvv if (x == xMax) { //draw right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv bottom edge of image vvvvv if (y == yMin) { //draw bottom edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv top edge of image vvvvv if (y == yMax) { //draw top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } }//end if currentpixel is set x++; if (x > xMax) { //reached end of line x = xMin; y++; } // Increase the pointer-position to the next pixel. // This is safe, as the while-loop and the x-reset logic above makes // sure we do not exceed the bounds of the image currentPixel++; }//end of while // Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New(); // Add the points to the dataset polyData->SetPoints(points); // Add the lines to the dataset polyData->SetLines(lines); return polyData; } void mitk::ImageVtkMapper2D::TransformActor(mitk::BaseRenderer* renderer) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //get the transformation matrix of the reslicer in order to render the slice as axial, coronal or saggital vtkSmartPointer trans = vtkSmartPointer::New(); vtkSmartPointer matrix = localStorage->m_Reslicer->GetResliceAxes(); trans->SetMatrix(matrix); //transform the plane/contour (the actual actor) to the corresponding view (axial, coronal or saggital) localStorage->m_Actor->SetUserTransform(trans); //transform the origin to center based coordinates, because MITK is center based. localStorage->m_Actor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); - - if ( localStorage->m_Actors->GetNumberOfPaths() > 1 ) - { - vtkActor* secondaryActor = dynamic_cast( localStorage->m_Actors->GetParts()->GetItemAsObject(0) ); - secondaryActor->SetUserTransform(trans); - secondaryActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); - } + //same for outline actor + localStorage->m_OutlineActor->SetUserTransform(trans); + localStorage->m_OutlineActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); + //same for outline shadow actor + localStorage->m_OutlineShadowActor->SetUserTransform(trans); + localStorage->m_OutlineShadowActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); } bool mitk::ImageVtkMapper2D::RenderingGeometryIntersectsImage( const Geometry2D* renderingGeometry, SlicedGeometry3D* imageGeometry ) { // if either one of the two geometries is NULL we return true // for safety reasons if ( renderingGeometry == NULL || imageGeometry == NULL ) return true; // get the distance for the first cornerpoint ScalarType initialDistance = renderingGeometry->SignedDistance( imageGeometry->GetCornerPoint( 0 ) ); for( int i=1; i<8; i++ ) { mitk::Point3D cornerPoint = imageGeometry->GetCornerPoint( i ); // get the distance to the other cornerpoints ScalarType distance = renderingGeometry->SignedDistance( cornerPoint ); // if it has not the same signing as the distance of the first point if ( initialDistance * distance < 0 ) { // we have an intersection and return true return true; } } // all distances have the same sign, no intersection and we return false return false; } mitk::ImageVtkMapper2D::LocalStorage::~LocalStorage() { } mitk::ImageVtkMapper2D::LocalStorage::LocalStorage() { m_LevelWindowFilter = vtkSmartPointer::New(); //Do as much actions as possible in here to avoid double executions. m_Plane = vtkSmartPointer::New(); m_Texture = vtkSmartPointer::New().GetPointer(); m_Mapper = vtkSmartPointer::New(); m_Actor = vtkSmartPointer::New(); m_Actors = vtkSmartPointer::New(); m_Reslicer = mitk::ExtractSliceFilter::New(); m_TSFilter = vtkSmartPointer::New(); m_OutlinePolyData = vtkSmartPointer::New(); m_ReslicedImage = vtkSmartPointer::New(); m_EmptyPolyData = vtkSmartPointer::New(); + m_OutlineActor = vtkSmartPointer::New(); + m_OutlineMapper = vtkSmartPointer::New(); + m_OutlineShadowActor = vtkSmartPointer::New(); m_ColorMap = -1; //the following actions are always the same and thus can be performed //in the constructor for each image (i.e. the image-corresponding local storage) m_TSFilter->ReleaseDataFlagOn(); //do not repeat the texture (the image) m_Texture->RepeatOff(); - //set the mapper for the actor + //set corresponding mappers for the actors m_Actor->SetMapper( m_Mapper ); + m_OutlineActor->SetMapper( m_OutlineMapper ); + m_OutlineShadowActor->SetMapper( m_OutlineMapper ); - vtkSmartPointer outlineShadowActor = vtkSmartPointer::New(); - outlineShadowActor->SetMapper( m_Mapper ); + m_OutlineActor->SetVisibility( false ); + m_OutlineShadowActor->SetVisibility( false ); - m_Actors->AddPart( outlineShadowActor ); + m_Actors->AddPart( m_OutlineShadowActor ); + m_Actors->AddPart( m_OutlineActor ); m_Actors->AddPart( m_Actor ); } diff --git a/Core/Code/Rendering/mitkImageVtkMapper2D.h b/Core/Code/Rendering/mitkImageVtkMapper2D.h index 06d492931c..b56ea05ce1 100644 --- a/Core/Code/Rendering/mitkImageVtkMapper2D.h +++ b/Core/Code/Rendering/mitkImageVtkMapper2D.h @@ -1,304 +1,310 @@ /*=================================================================== 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 MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E #define MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E //MITK #include //MITK Rendering #include "mitkBaseRenderer.h" #include "mitkVtkMapper.h" #include "mitkExtractSliceFilter.h" //VTK #include #include class vtkActor; class vtkPolyDataMapper; class vtkPlaneSource; class vtkImageData; class vtkLookupTable; class vtkImageReslice; class vtkPoints; class vtkMitkThickSlicesFilter; class vtkPolyData; class vtkMitkLevelWindowFilter; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D image. * * The following image gives a brief overview of the mapping and the involved parts. * * \image html imageVtkMapper2Darchitecture.png * * First, the image is resliced by means of vtkImageReslice. The volume image * serves as input to the mapper in addition to spatial placement of the slice and a few other * properties such as thick slices. This code was already present in the old version * (mitkImageMapperGL2D). * * Next, the obtained slice (m_ReslicedImage) is put into a vtkMitkLevelWindowFilter * and the scalar levelwindow, opacity levelwindow and optional clipping to * local image bounds are applied * * Next, the output of the vtkMitkLevelWindowFilter is used to create a texture * (m_Texture) and a plane onto which the texture is rendered (m_Plane). For * mapping purposes, a vtkPolyDataMapper (m_Mapper) is utilized. Orthographic * projection is applied to create the effect of a 2D image. The mapper and the * texture are assigned to the actor (m_Actor) which is passed to the VTK rendering * pipeline via the method GetVtkProp(). * * In order to transform the textured plane to the correct position in space, the * same transformation as used for reslicing is applied to both the camera and the * vtkActor. All important steps are explained in more detail below. The resulting * 2D image (by reslicing the underlying 3D input image appropriately) can either * be directly rendered in a 2D view or just be calculated to be used later by another * rendering entity, e.g. in texture mapping in a 3D view. * * Properties that can be set for images and influence the imageMapper2D are: * * - \b "opacity": (FloatProperty) Opacity of the image * - \b "color": (ColorProperty) Color of the image * - \b "LookupTable": (mitkLookupTableProperty) If this property is set, * the default lookuptable will be ignored and the "LookupTable" value * will be used instead. * - \b "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink * - \b "Image Rendering.Transfer Function": (mitkTransferFunctionProperty) If this * property is set, a color transferfunction will be used to color the image. * - \b "binary": (BoolProperty) is the image a binary image or not * - \b "outline binary": (BoolProperty) show outline of the image or not * - \b "texture interpolation": (BoolProperty) texture interpolation of the image * - \b "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image * - \b "in plane resample extent by geometry": (BoolProperty) Do it or not * - \b "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not * - \b "layer": (IntProperty) Layer of the image * - \b "volume annotation color": (ColorProperty) color of the volume annotation, TODO has to be reimplemented * - \b "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml or cm3, TODO has to be reimplemented * The default properties are: * - \b "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ) * - \b "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ) * - \b "binary", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ) * - \b "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ) * - \b "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ) * - \b "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ) * - \b "bounding box", mitk::BoolProperty::New( false ) ) * - \b "layer", mitk::IntProperty::New(10), renderer, overwrite) * - \b "Image Rendering.Transfer Function": Default color transfer function for CTs * - \b "LookupTable": Rainbow color. * If the modality-property is set for an image, the mapper uses modality-specific default properties, * e.g. color maps, if they are defined. * \ingroup Mapper */ class MITK_CORE_EXPORT ImageVtkMapper2D : public VtkMapper { public: /** Standard class typedefs. */ mitkClassMacro( ImageVtkMapper2D,VtkMapper ); /** Method for creation through the object factory. */ itkNewMacro(Self); /** \brief Get the Image to map */ const mitk::Image *GetInput(void); /** \brief Checks whether this mapper needs to update itself and generate * data. */ virtual void Update(mitk::BaseRenderer * renderer); //### methods of MITK-VTK rendering pipeline virtual vtkProp* GetVtkProp(mitk::BaseRenderer* renderer); //### end of methods of MITK-VTK rendering pipeline /** \brief Internal class holding the mapper, actor, etc. for each of the 3 2D render windows */ /** * To render transveral, coronal, and sagittal, the mapper is called three times. * For performance reasons, the corresponding data for each view is saved in the * internal helper class LocalStorage. This allows rendering n views with just * 1 mitkMapper using n vtkMapper. * */ class MITK_CORE_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_Actor; vtkSmartPointer m_Actors; /** \brief Mapper of a 2D render window. */ vtkSmartPointer m_Mapper; /** \brief Current slice of a 2D render window.*/ vtkSmartPointer m_ReslicedImage; /** \brief Empty vtkPolyData that is set when rendering geometry does not * intersect the image geometry. * \warning This member variable is set to NULL, * if no image geometry is inside the plane geometry * of the respective render window. Any user of this * slice has to check whether it is set to NULL! */ vtkSmartPointer m_EmptyPolyData; /** \brief Plane on which the slice is rendered as texture. */ vtkSmartPointer m_Plane; /** \brief The texture which is used to render the current slice. */ vtkSmartPointer m_Texture; /** \brief The actual reslicer (one per renderer) */ mitk::ExtractSliceFilter::Pointer m_Reslicer; /** \brief Filter for thick slices */ vtkSmartPointer m_TSFilter; /** \brief PolyData object containg all lines/points needed for outlining the contour. This container is used to save a computed contour for the next rendering execution. For instance, if you zoom or pann, there is no need to recompute the contour. */ vtkSmartPointer m_OutlinePolyData; + /** \brief An actor for the outline */ + vtkSmartPointer m_OutlineActor; + /** \brief An actor for the outline shadow*/ + vtkSmartPointer m_OutlineShadowActor; + /** \brief A mapper for the outline */ + vtkSmartPointer m_OutlineMapper; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastDataUpdateTime; /** \brief Timestamp of last update of a property. */ itk::TimeStamp m_LastPropertyUpdateTime; /** \brief mmPerPixel relation between pixel and mm. (World spacing).*/ mitk::ScalarType* m_mmPerPixel; /** \brief Currently active color map. */ int m_ColorMap; /** \brief This filter is used to apply the level window to Grayvalue and RBG(A) images. */ vtkSmartPointer m_LevelWindowFilter; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; /** \brief The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. */ mitk::LocalStorageHandler m_LSH; /** \brief Get the LocalStorage corresponding to the current renderer. */ LocalStorage* GetLocalStorage(mitk::BaseRenderer* renderer); /** \brief Set the default properties for general image rendering. */ static void SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer = NULL, bool overwrite = false); /** \brief This method switches between different rendering modes (e.g. use a lookup table or a transfer function). * Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink */ void ApplyRenderingMode(mitk::BaseRenderer *renderer); protected: /** \brief Transforms the actor to the actual position in 3D. * \param renderer The current renderer corresponding to the render window. */ void TransformActor(mitk::BaseRenderer* renderer); /** \brief Generates a plane according to the size of the resliced image in milimeters. * * \image html texturedPlane.png * * In VTK a vtkPlaneSource is defined through three points. The origin and two * points defining the axes of the plane (see VTK documentation). The origin is * set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the * resliced image in space. Z is relevant for blending and the layer property. * The center of the plane (C) is also the center of the view plane (cf. the image above). * * \note For the standard MITK view with three 2D render windows showing three * different slices, three such planes are generated. All these planes are generated * in the XY-plane (even if they depict a YZ-slice of the volume). * */ void GeneratePlane(mitk::BaseRenderer* renderer, vtkFloatingPointType planeBounds[6]); /** \brief Generates a vtkPolyData object containing the outline of a given binary slice. \param renderer: Pointer to the renderer containing the needed information \note This code is based on code from the iil library. */ vtkSmartPointer CreateOutlinePolyData(mitk::BaseRenderer* renderer); /** Default constructor */ ImageVtkMapper2D(); /** Default deconstructor */ virtual ~ImageVtkMapper2D(); /** \brief Does the actual resampling, without rendering the image yet. * All the data is generated inside this method. The vtkProp (or Actor) * is filled with content (i.e. the resliced image). * * After generation, a 4x4 transformation matrix(t) of the current slice is obtained * from the vtkResliceImage object via GetReslicesAxis(). This matrix is * applied to each textured plane (actor->SetUserTransform(t)) to transform everything * to the actual 3D position (cf. the following image). * * \image html cameraPositioning3D.png * */ virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer); /** \brief This method uses the vtkCamera clipping range and the layer property * to calcualte the depth of the object (e.g. image or contour). The depth is used * to keep the correct order for the final VTK rendering.*/ float CalculateLayerDepth(mitk::BaseRenderer* renderer); /** \brief This method applies (or modifies) the lookuptable for all types of images. * \warning To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' * which uses the lookup table must be set. */ void ApplyLookuptable(mitk::BaseRenderer* renderer); /** \brief This method applies a color transfer function. * Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous * images (e.g. float) * \warning To use the color transfer function, the property 'Image Rendering.Transfer Function' must be set and a 'Image Rendering.Mode' which uses the color transfer function must be set. */ void ApplyColorTransferFunction(mitk::BaseRenderer* renderer); /** * @brief ApplyLevelWindow Apply the level window for the given renderer. * \warning To use the level window, the property 'LevelWindow' must be set and a 'Image Rendering.Mode' which uses the level window must be set. * @param renderer Level window for which renderer? */ void ApplyLevelWindow(mitk::BaseRenderer* renderer); /** \brief Set the color of the image/polydata */ void ApplyColor( mitk::BaseRenderer* renderer ); /** \brief Set the opacity of the actor. */ void ApplyOpacity( mitk::BaseRenderer* renderer ); /** * \brief Calculates whether the given rendering geometry intersects the * given SlicedGeometry3D. * * This method checks if the given Geometry2D intersects the given * SlicedGeometry3D. It calculates the distance of the Geometry2D to all * 8 cornerpoints of the SlicedGeometry3D. If all distances have the same * sign (all positive or all negative) there is no intersection. * If the distances have different sign, there is an intersection. **/ bool RenderingGeometryIntersectsImage( const Geometry2D* renderingGeometry, SlicedGeometry3D* imageGeometry ); }; } // namespace mitk #endif /* MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E */ diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index 6997b86d6f..f0f6e6a293 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -1,373 +1,368 @@ set(H_FILES Algorithms/itkImportMitkImageContainer.h Algorithms/itkImportMitkImageContainer.txx Algorithms/itkLocalVariationImageFilter.h Algorithms/itkLocalVariationImageFilter.txx Algorithms/itkMITKScalarImageToHistogramGenerator.h Algorithms/itkMITKScalarImageToHistogramGenerator.txx Algorithms/itkTotalVariationDenoisingImageFilter.h Algorithms/itkTotalVariationDenoisingImageFilter.txx Algorithms/itkTotalVariationSingleIterationImageFilter.h Algorithms/itkTotalVariationSingleIterationImageFilter.txx Algorithms/mitkBilateralFilter.h Algorithms/mitkBilateralFilter.cpp Algorithms/mitkInstantiateAccessFunctions.h Algorithms/mitkPixelTypeList.h # Preprocessor macros taken from Boost Algorithms/mitkPPArithmeticDec.h Algorithms/mitkPPArgCount.h Algorithms/mitkPPCat.h Algorithms/mitkPPConfig.h Algorithms/mitkPPControlExprIIf.h Algorithms/mitkPPControlIf.h Algorithms/mitkPPControlIIf.h Algorithms/mitkPPDebugError.h Algorithms/mitkPPDetailAutoRec.h Algorithms/mitkPPDetailDMCAutoRec.h Algorithms/mitkPPExpand.h Algorithms/mitkPPFacilitiesEmpty.h Algorithms/mitkPPFacilitiesExpand.h Algorithms/mitkPPLogicalBool.h Algorithms/mitkPPRepetitionDetailDMCFor.h Algorithms/mitkPPRepetitionDetailEDGFor.h Algorithms/mitkPPRepetitionDetailFor.h Algorithms/mitkPPRepetitionDetailMSVCFor.h Algorithms/mitkPPRepetitionFor.h Algorithms/mitkPPSeqElem.h Algorithms/mitkPPSeqForEach.h Algorithms/mitkPPSeqForEachProduct.h Algorithms/mitkPPSeq.h Algorithms/mitkPPSeqEnum.h Algorithms/mitkPPSeqSize.h Algorithms/mitkPPSeqToTuple.h Algorithms/mitkPPStringize.h Algorithms/mitkPPTupleEat.h Algorithms/mitkPPTupleElem.h Algorithms/mitkPPTupleRem.h Algorithms/mitkClippedSurfaceBoundsCalculator.h Algorithms/mitkExtractSliceFilter.h Algorithms/mitkConvert2Dto3DImageFilter.h Algorithms/mitkPlaneClipping.h Common/mitkExceptionMacro.h Common/mitkServiceBaseObject.h Common/mitkTestingMacros.h DataManagement/mitkImageAccessByItk.h DataManagement/mitkImageCast.h DataManagement/mitkImagePixelAccessor.h DataManagement/mitkImagePixelReadAccessor.h DataManagement/mitkImagePixelWriteAccessor.h DataManagement/mitkImageReadAccessor.h DataManagement/mitkImageWriteAccessor.h DataManagement/mitkITKImageImport.h DataManagement/mitkITKImageImport.txx DataManagement/mitkImageToItk.h DataManagement/mitkImageToItk.txx Interactions/mitkEventMapperAddOn.h Interfaces/mitkIDataNodeReader.h Rendering/mitkLocalStorageHandler.h IO/mitkPixelTypeTraits.h ) set(CPP_FILES Algorithms/mitkBaseDataSource.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Algorithms/mitkPadImageFilter.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkCoreActivator.cpp Controllers/mitkFocusManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkSlicesRotator.cpp Controllers/mitkSlicesSwiveller.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkInteractorCameraController.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataStorage.cpp #DataManagement/mitkDataTree.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataNodeFactory.cpp #DataManagement/mitkDataTreeStorage.cpp DataManagement/mitkDisplayGeometry.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkGeometry2D.cpp DataManagement/mitkGeometry2DData.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImage.cpp - DataManagement/mitkLabelSetImage.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkLandmarkBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStateTransitionOperation.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeSlicedGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkVector.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkMaterial.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkColormapProperty.cpp - DataManagement/mitkLabelSetProperty.cpp - DataManagement/mitkLabelSet.cpp - DataManagement/mitkLabel.cpp Interactions/mitkAction.cpp Interactions/mitkAffineInteractor.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCoordinateSupplier.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayPositionEvent.cpp # Interactions/mitkDisplayVectorInteractorLevelWindow.cpp # legacy, prob even now unneeded # Interactions/mitkDisplayVectorInteractorScroll.cpp Interactions/mitkEvent.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventDescription.cpp Interactions/mitkEventFactory.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkEventMapper.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkGlobalInteraction.cpp Interactions/mitkInteractor.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveBaseDataInteractor.cpp Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkState.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateEvent.cpp Interactions/mitkStateMachine.cpp Interactions/mitkStateMachineFactory.cpp Interactions/mitkTransition.cpp Interactions/mitkWheelEvent.cpp Interactions/mitkKeyEvent.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkCrosshairPositionEvent.cpp Interfaces/mitkInteractionEventObserver.cpp Interfaces/mitkIShaderRepository.cpp IO/mitkBaseDataIOFactory.cpp IO/mitkCoreDataNodeReader.cpp IO/mitkDicomSeriesReader.cpp IO/mitkFileReader.cpp IO/mitkFileSeriesReader.cpp IO/mitkFileWriter.cpp #IO/mitkIpPicGet.c IO/mitkImageGenerator.cpp IO/mitkImageWriter.cpp IO/mitkImageWriterFactory.cpp IO/mitkItkImageFileIOFactory.cpp IO/mitkItkImageFileReader.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkItkPictureWrite.cpp IO/mitkIOUtil.cpp IO/mitkLookupTableProperty.cpp IO/mitkOperation.cpp #IO/mitkPicFileIOFactory.cpp #IO/mitkPicFileReader.cpp #IO/mitkPicFileWriter.cpp #IO/mitkPicHelper.cpp #IO/mitkPicVolumeTimeSeriesIOFactory.cpp #IO/mitkPicVolumeTimeSeriesReader.cpp IO/mitkPixelType.cpp IO/mitkPointSetIOFactory.cpp IO/mitkPointSetReader.cpp IO/mitkPointSetWriter.cpp IO/mitkPointSetWriterFactory.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSTLFileIOFactory.cpp IO/mitkSTLFileReader.cpp IO/mitkSurfaceVtkWriter.cpp IO/mitkSurfaceVtkWriterFactory.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkVtiFileIOFactory.cpp IO/mitkVtiFileReader.cpp IO/mitkVtkImageIOFactory.cpp IO/mitkVtkImageReader.cpp IO/mitkVtkSurfaceIOFactory.cpp IO/mitkVtkSurfaceReader.cpp IO/vtkPointSetXMLParser.cpp IO/mitkLog.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkGeometry2DDataMapper2D.cpp Rendering/mitkGeometry2DDataVtkMapper3D.cpp Rendering/mitkGLMapper.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkManufacturerLogo.cpp Rendering/mitkMapper.cpp Rendering/mitkPointSetGLMapper2D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkPolyDataGLMapper2D.cpp Rendering/mitkSurfaceGLMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVolumeDataVtkMapper3D.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkShaderRepository.cpp Rendering/mitkImageVtkMapper2D.cpp - Rendering/mitkLabelSetImageVtkMapper2D.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp Rendering/mitkRenderingTestHelper.cpp Common/mitkException.cpp Common/mitkCommon.h Common/mitkCoreObjectFactoryBase.cpp Common/mitkCoreObjectFactory.cpp Common/mitkCoreServices.cpp ) list(APPEND CPP_FILES ${CppMicroServices_SOURCES}) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml Shaders/mitkShaderLighting.xml mitkLevelWindowPresets.xml ) diff --git a/Modules/Segmentation/Algorithms/mitkLabelSetImageToSurfaceThreadedFilter.h b/Modules/Segmentation/Algorithms/mitkLabelSetImageToSurfaceThreadedFilter.h index aeb6ea135d..9636427bb1 100644 --- a/Modules/Segmentation/Algorithms/mitkLabelSetImageToSurfaceThreadedFilter.h +++ b/Modules/Segmentation/Algorithms/mitkLabelSetImageToSurfaceThreadedFilter.h @@ -1,53 +1,53 @@ /*=================================================================== 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 _mitkLabelSetImageToSurfaceThreadedFilter_H_ -#define _mitkLabelSetImageToSurfaceThreadedFilter_H_ +#ifndef __mitkLabelSetImageToSurfaceThreadedFilter_H_ +#define __mitkLabelSetImageToSurfaceThreadedFilter_H_ #include "mitkSegmentationSink.h" #include "mitkSurface.h" namespace mitk { class Segmentation_EXPORT LabelSetImageToSurfaceThreadedFilter : public SegmentationSink { public: mitkClassMacro( LabelSetImageToSurfaceThreadedFilter, SegmentationSink ) mitkAlgorithmNewMacro( LabelSetImageToSurfaceThreadedFilter ); protected: LabelSetImageToSurfaceThreadedFilter(); // use smart pointers virtual ~LabelSetImageToSurfaceThreadedFilter(); virtual void Initialize(const NonBlockingAlgorithm* other = NULL); virtual bool ReadyToRun(); virtual bool ThreadedUpdateFunction(); // will be called from a thread after calling StartAlgorithm virtual void ThreadedUpdateSuccessful(); // will be called from a thread after calling StartAlgorithm private: int m_RequestedLabel; Surface::Pointer m_Result; }; } // namespace -#endif // _mitkLabelSetImageToSurfaceThreadedFilter_H_ +#endif // __mitkLabelSetImageToSurfaceThreadedFilter_H_ diff --git a/Modules/Segmentation/Algorithms/mitkSegmentationObjectFactory.cpp b/Modules/Segmentation/Algorithms/mitkSegmentationObjectFactory.cpp index e6b2e7ea33..97cf310987 100644 --- a/Modules/Segmentation/Algorithms/mitkSegmentationObjectFactory.cpp +++ b/Modules/Segmentation/Algorithms/mitkSegmentationObjectFactory.cpp @@ -1,193 +1,200 @@ /*=================================================================== 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 "mitkSegmentationObjectFactory.h" #include "mitkProperties.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include "mitkCoreObjectFactory.h" #include "mitkContour.h" #include "mitkContourMapper2D.h" #include "mitkContourSetMapper2D.h" #include "mitkContourSetVtkMapper3D.h" #include "mitkContourVtkMapper3D.h" #include "mitkContourModel.h" #include "mitkContourModelIOFactory.h" #include "mitkContourModelWriterFactory.h" #include "mitkContourModelWriter.h" //#include "mitkContourModelMapper2D.h" #include "mitkContourModelGLMapper2D.h" #include "mitkContourModelMapper3D.h" #include "mitkLabelSetImage.h" +#include "mitkLabelSetImageVtkMapper2D.h" #include "mitkNrrdLabelSetImageWriter.h" #include "mitkNrrdLabelSetImageWriterFactory.h" #include "mitkNrrdLabelSetImageIOFactory.h" mitk::SegmentationObjectFactory::SegmentationObjectFactory() :CoreObjectFactoryBase() { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "SegmentationObjectFactory c'tor" << std::endl; RegisterIOFactories(); alreadyDone = true; } } mitk::Mapper::Pointer mitk::SegmentationObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; mitk::BaseData *data = node->GetData(); if ( id == mitk::BaseRenderer::Standard2D ) { if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourSetMapper2D::New(); newMapper->SetDataNode(node); } - - std::string classname("ContourModel"); - if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) + else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourModelGLMapper2D::New(); newMapper->SetDataNode(node); } + else if((dynamic_cast(data)!=NULL)) + { + newMapper = mitk::LabelSetImageVtkMapper2D::New(); + newMapper->SetDataNode(node); + } } else if ( id == mitk::BaseRenderer::Standard3D ) { if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourSetVtkMapper3D::New(); newMapper->SetDataNode(node); } - - std::string classname("ContourModel"); - if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) + else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ContourModelMapper3D::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::SegmentationObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if(!node) return; - mitk::DataNode::Pointer nodePointer = node; - - std::string classname("ContourModel"); - if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) + mitk::ContourModel::Pointer contourModel = dynamic_cast(node->GetData()); + if(contourModel.IsNotNull()) { mitk::ContourModelGLMapper2D::SetDefaultProperties(node); mitk::ContourModelMapper3D::SetDefaultProperties(node); } // mitk::Image::Pointer image = dynamic_cast(node->GetData()); // if(image.IsNotNull() && image->IsInitialized()) // { // mitk::GPUVolumeMapper3D::SetDefaultProperties(node); // } // // if (dynamic_cast(node->GetData())) // { // mitk::UnstructuredGridVtkMapper3D::SetDefaultProperties(node); // } + mitk::LabelSetImage::Pointer lsImage = dynamic_cast(node->GetData()); + if(lsImage.IsNotNull()) + { + mitk::LabelSetImageVtkMapper2D::SetDefaultProperties(node); + } } const char* mitk::SegmentationObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::SegmentationObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } mitk::CoreObjectFactoryBase::MultimapType mitk::SegmentationObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::SegmentationObjectFactory::CreateFileExtensionsMap() { m_SaveFileExtensionsMap.insert(std::pair("*.cnt", "Contour Files")); // m_SaveFileExtensionsMap.insert(std::pair("*.lset", "Segmentation Files")); m_FileExtensionsMap.insert(std::pair("*.cnt", "Contour File")); // m_FileExtensionsMap.insert(std::pair("*.lset", "Segmentation Files")); + + m_FileExtensionsMap.insert(std::pair("*.lst", "Segmentation File")); } const char* mitk::SegmentationObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); } void mitk::SegmentationObjectFactory::RegisterIOFactories() { //register io classes of mitkContourModel mitk::ContourModelIOFactory::RegisterOneFactory(); mitk::ContourModelWriterFactory::RegisterOneFactory(); this->m_FileWriters.push_back(mitk::ContourModelWriter::New().GetPointer()); mitk::NrrdLabelSetImageIOFactory::RegisterOneFactory(); mitk::NrrdLabelSetImageWriterFactory::RegisterOneFactory(); this->m_FileWriters.push_back(mitk::NrrdLabelSetImageWriter::New().GetPointer()); CreateFileExtensionsMap(); } void RegisterSegmentationObjectFactory() { static bool oneSegmentationObjectFactoryRegistered = false; if ( ! oneSegmentationObjectFactoryRegistered ) { MITK_DEBUG << "Registering SegmentationObjectFactory..." << std::endl; mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::SegmentationObjectFactory::New()); oneSegmentationObjectFactoryRegistered = true; } } diff --git a/Core/Code/DataManagement/mitkLabel.cpp b/Modules/Segmentation/DataManagement/mitkLabel.cpp similarity index 95% rename from Core/Code/DataManagement/mitkLabel.cpp rename to Modules/Segmentation/DataManagement/mitkLabel.cpp index d2f161a3d7..7c5e5afb3d 100644 --- a/Core/Code/DataManagement/mitkLabel.cpp +++ b/Modules/Segmentation/DataManagement/mitkLabel.cpp @@ -1,89 +1,87 @@ /*=================================================================== 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 "mitkLabel.h" #include "itkProcessObject.h" mitk::Label::Label(): m_Locked(true), m_Visible(true), m_Filled(true), m_Exterior(false), m_Opacity(0.6), m_Volume(0.0), m_Index(0), -m_Layer(0), -m_StickyBorders(false) +m_Layer(0) { } mitk::Label::Label(const Label& other) : itk::Object() { this->m_Locked = other.GetLocked(); this->m_Visible = other.GetVisible(); this->m_Filled = other.GetFilled(); this->m_Exterior = other.GetExterior(); this->m_Opacity = other.GetOpacity(); - this->m_StickyBorders = other.GetStickyBorders(); this->m_Selected = other.GetSelected(); this->m_Name = other.GetName(); this->m_LatinName = other.GetLatinName(); this->m_Volume = other.GetVolume(); this->m_LastModified = other.GetLastModified(); this->m_Index = other.GetIndex(); this->m_Layer = other.GetLayer(); this->m_Color = other.GetColor(); } mitk::Label::~Label() { } void mitk::Label::SetColor(const mitk::Color &_color) { this->m_Color = _color; } void mitk::Label::PrintSelf(std::ostream &os, itk::Indent indent) const { // todo } void mitk::Label::SetCenterOfMassIndex(const mitk::Point3D& center) { this->m_CenterOfMassIndex = center; } const mitk::Point3D& mitk::Label::GetCenterOfMassIndex() { return this->m_CenterOfMassIndex; } void mitk::Label::SetCenterOfMassCoordinates(const mitk::Point3D& center) { this->m_CenterOfMassCoordinates = center; } const mitk::Point3D& mitk::Label::GetCenterOfMassCoordinates() { return this->m_CenterOfMassCoordinates; } diff --git a/Core/Code/DataManagement/mitkLabel.h b/Modules/Segmentation/DataManagement/mitkLabel.h similarity index 89% rename from Core/Code/DataManagement/mitkLabel.h rename to Modules/Segmentation/DataManagement/mitkLabel.h index 8bfffb36a6..3a130afd42 100644 --- a/Core/Code/DataManagement/mitkLabel.h +++ b/Modules/Segmentation/DataManagement/mitkLabel.h @@ -1,129 +1,123 @@ /*=================================================================== 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 _mitkLabel_H_ -#define _mitkLabel_H_ +#ifndef __mitkLabel_H_ +#define __mitkLabel_H_ -#include -#include +#include "SegmentationExports.h" #include #include #include #include namespace mitk { //## //##Documentation //## @brief A data structure describing a label. //## @ingroup Data //## -class MITK_CORE_EXPORT Label : public itk::Object +class Segmentation_EXPORT Label : public itk::Object { public: mitkClassMacro( Label, itk::Object ); itkNewMacro( Self ); itkSetMacro(Locked, bool); itkGetConstMacro(Locked, bool); itkBooleanMacro(Locked); itkSetMacro(Visible, bool); itkGetConstMacro(Visible, bool); itkBooleanMacro(Visible); itkSetMacro(Exterior, bool); itkGetConstMacro(Exterior, bool); itkBooleanMacro(Exterior); itkSetMacro(Filled, bool); itkGetConstMacro(Filled, bool); itkBooleanMacro(Filled); itkSetMacro(Selected, bool ); itkGetConstMacro( Selected, bool ); itkBooleanMacro(Selected); - itkSetMacro(StickyBorders, bool); - itkGetConstMacro(StickyBorders, bool); - itkBooleanMacro(StickyBorders); - itkSetMacro(Opacity, float); itkGetConstMacro(Opacity, float); itkSetMacro(Volume, float); itkGetConstMacro(Volume, float); itkSetStringMacro(Name); itkGetStringMacro(Name); itkSetMacro(LatinName, std::string); itkGetConstMacro(LatinName, std::string); itkSetMacro(LastModified, std::string); itkGetConstMacro(LastModified, std::string); void SetCenterOfMassIndex(const mitk::Point3D& center); const mitk::Point3D& GetCenterOfMassIndex(); void SetCenterOfMassCoordinates(const mitk::Point3D& center); const mitk::Point3D& GetCenterOfMassCoordinates(); void SetColor(const mitk::Color&); const mitk::Color& GetColor() const { return m_Color; }; itkSetMacro(Index, int); itkGetConstMacro(Index, int); itkSetMacro(Layer, int); itkGetConstMacro(Layer, int); Label(); virtual ~Label(); protected: void PrintSelf(std::ostream &os, itk::Indent indent) const; Label(const Label& other); bool m_Locked; bool m_Visible; bool m_Filled; bool m_Exterior; float m_Opacity; - bool m_StickyBorders; bool m_Selected; std::string m_Name; std::string m_LatinName; float m_Volume; std::string m_LastModified; int m_Index; int m_Layer; mitk::Color m_Color; mitk::Point3D m_CenterOfMassIndex; mitk::Point3D m_CenterOfMassCoordinates; }; } // namespace mitk -#endif // _mitkLabel_H_ +#endif // __mitkLabel_H_ diff --git a/Core/Code/DataManagement/mitkLabelSet.cpp b/Modules/Segmentation/DataManagement/mitkLabelSet.cpp similarity index 100% rename from Core/Code/DataManagement/mitkLabelSet.cpp rename to Modules/Segmentation/DataManagement/mitkLabelSet.cpp diff --git a/Core/Code/DataManagement/mitkLabelSet.h b/Modules/Segmentation/DataManagement/mitkLabelSet.h similarity index 96% rename from Core/Code/DataManagement/mitkLabelSet.h rename to Modules/Segmentation/DataManagement/mitkLabelSet.h index f144ab3479..c3ae23fce4 100644 --- a/Core/Code/DataManagement/mitkLabelSet.h +++ b/Modules/Segmentation/DataManagement/mitkLabelSet.h @@ -1,244 +1,243 @@ /*=================================================================== 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 _mitkLabelSet_H_ -#define _mitkLabelSet_H_ +#ifndef __mitkLabelSet_H_ +#define __mitkLabelSet_H_ -#include -#include +#include "SegmentationExports.h" #include #include #include #include #include namespace mitk { // //Documentation // @brief LabelSet containing the labels corresponding to a segmentation session. // @ingroup Data // -class MITK_CORE_EXPORT LabelSet : public itk::Object +class Segmentation_EXPORT LabelSet : public itk::Object { public: mitkClassMacro( LabelSet, itk::Object ); mitkNewMacro1Param( Self, int ); typedef std::vector LabelContainerType; typedef LabelContainerType::const_iterator LabelContainerConstIteratorType; typedef LabelContainerType::iterator LabelContainerIteratorType; void Initialize(const LabelSet* other); /** \brief Returns a const iterator poiting to the begining of the container. */ LabelContainerConstIteratorType IteratorBegin(); /** \brief Returns a const iterator pointing to the end of the container. */ LabelContainerConstIteratorType IteratorEnd(); /** \brief */ void SetActiveLabel(int); /** \brief */ void RemoveLabel(int); /** \brief */ void RemoveSelectedLabels(); /** \brief */ void RemoveLabels(int begin, int count); /** \brief */ void AddLabel(const Label& label); /** \brief */ void AddLabel(const std::string& name, const Color& color); /** \brief */ void RenameLabel(int, const std::string&, const Color&); /** \brief */ int GetNumberOfLabels() const; /** \brief */ void SetAllLabelsVisible(bool); /** \brief */ void SetAllLabelsLocked(bool); /** \brief */ void RemoveAllLabels(); /** \brief */ void SetLabelVisible(int index, bool value); /** \brief */ bool GetLabelVisible(int index); /** \brief */ void SetLabelLocked(int index, bool value); /** \brief */ bool GetLabelLocked(int index); /** \brief */ int GetLabelLayer(int index) const; /** \brief */ void SetLabelSelected(int index, bool value); /** \brief */ bool GetLabelSelected(int index); /** \brief */ void SetLabelOpacity(int index, float value); /** \brief */ float GetLabelOpacity(int index); /** \brief */ void SetLabelVolume(int index, float value); /** \brief */ float GetLabelVolume(int index); /** \brief */ void SetLabelName(int index, const std::string &name); /** \brief */ std::string GetLabelName(int index); /** \brief */ void SetLabelColor(int index, const Color &color); /** \brief */ const Color& GetLabelColor(int index); /** \brief */ const Label* GetActiveLabel() const { return m_ActiveLabel; }; /** \brief */ Label::ConstPointer GetLabel(int index) const; /** \brief */ int GetActiveLabelIndex() const; /** \brief */ int GetActiveLabelLayer() const; /** \brief */ void SetLabelCenterOfMassIndex(int index, const Point3D& center); /** \brief */ const Point3D& GetLabelCenterOfMassIndex(int index); /** \brief */ void SetLabelCenterOfMassCoordinates(int index, const Point3D& center); /** \brief */ const Point3D& GetLabelCenterOfMassCoordinates(int index); /** \brief */ void ResetLabels(); /** \brief */ int GetLayer() { return m_Layer; } /** \brief */ LookupTable* GetLookupTable(); /** \brief */ void SetLookupTable( LookupTable* lut ); /** \brief */ static bool IsSelected( Label::Pointer label ); protected: LabelSet(int layer); virtual ~LabelSet(); // LabelSet(const LabelSet& other); void PrintSelf(std::ostream &os, itk::Indent indent) const; LabelContainerType m_LabelContainer; LookupTable::Pointer m_LookupTable; Label* m_ActiveLabel; int m_Layer; private: // purposely not implemented LabelSet& operator=(const LabelSet&); itk::LightObject::Pointer InternalClone() const; }; } // namespace mitk -#endif // _mitkLabelSet_H_ +#endif // __mitkLabelSet_H_ diff --git a/Core/Code/DataManagement/mitkLabelSetImage.cpp b/Modules/Segmentation/DataManagement/mitkLabelSetImage.cpp similarity index 100% rename from Core/Code/DataManagement/mitkLabelSetImage.cpp rename to Modules/Segmentation/DataManagement/mitkLabelSetImage.cpp diff --git a/Core/Code/DataManagement/mitkLabelSetImage.h b/Modules/Segmentation/DataManagement/mitkLabelSetImage.h similarity index 99% rename from Core/Code/DataManagement/mitkLabelSetImage.h rename to Modules/Segmentation/DataManagement/mitkLabelSetImage.h index fe7ca70bad..fe8de05b8c 100644 --- a/Core/Code/DataManagement/mitkLabelSetImage.h +++ b/Modules/Segmentation/DataManagement/mitkLabelSetImage.h @@ -1,422 +1,422 @@ /*=================================================================== 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 __mitkLabelSetImage_H_ #define __mitkLabelSetImage_H_ #include "mitkImage.h" -#include "MitkExports.h" +#include "SegmentationExports.h" #include #include #include #include #include namespace mitk { //class ImageVtkAccessor; //##Documentation //## @brief LabelSetImage class for storing labels in a segmentation session. //## //## Handles operations for editing labels. //## @ingroup Data -class MITK_CORE_EXPORT LabelSetImage : public Image +class Segmentation_EXPORT LabelSetImage : public Image { public: mitkClassMacro(LabelSetImage, Image); itkNewMacro(Self); mitkNewMacro1Param(Self, LabelSetImage*); typedef unsigned char PixelType; typedef itk::Image< PixelType, 3 > LabelSetImageType; typedef itk::VariableLengthVector< PixelType > VariableVectorType; typedef itk::VectorImage< PixelType, 3 > VectorImageType; typedef itk::VectorImageToImageAdaptor< PixelType, 3 > ImageAdaptorType; /** * \brief this constructor creates a labelset image out of the provided reference image. * @throw mitk::Exception Throws an exception if there is a problem while creating the labelset image. */ // mitkNewMacro1Param(Self, Image::Pointer); /** * \brief AddLabelEvent is emitted whenever a new label has been added to the LabelSet. * * Observers should register to this event by calling myLabelSet->AddLabelEvent.AddListener(myObject, MyObject::MyMethod). * After registering, myObject->MyMethod() will be called every time a new label has been added to the LabelSet. * Observers should unregister by calling myLabelSet->AddLabelEvent.RemoveListener(myObject, MyObject::MyMethod). * * member variable is not needed to be locked in multi-threaded scenarios since the LabelSetEvent is a typedef for * a Message1 object which is thread safe */ Message<> AddLabelEvent; /** * \brief RemoveLabelEvent is emitted whenever a new label has been removed from the LabelSet. * * Observers should register to this event by calling myLabelSet->RemoveLabelEvent.AddListener(myObject, MyObject::MyMethod). * After registering, myObject->MyMethod() will be called every time a new label has been removed from the LabelSet. * Observers should unregister by calling myLabelSet->RemoveLabelEvent.RemoveListener(myObject, MyObject::MyMethod). * * member variable is not needed to be locked in multi-threaded scenarios since the LabelSetEvent is a typedef for * a Message object which is thread safe */ Message<> RemoveLabelEvent; /** * \brief ModifyLabelEvent is emitted whenever a new label has been removed from the LabelSet. * * Observers should register to this event by calling myLabelSet->ModifyLabelEvent.AddListener(myObject, MyObject::MyMethod). * After registering, myObject->MyMethod() will be called every time a new label has been removed from the LabelSet. * Observers should unregister by calling myLabelSet->ModifyLabelEvent.RemoveListener(myObject, MyObject::MyMethod). * * member variable is not needed to be locked in multi-threaded scenarios since the LabelSetEvent is a typedef for * a Message object which is thread safe */ Message1 ModifyLabelEvent; /** * \brief AllLabelsModifiedEvent is emitted whenever a new label has been removed from the LabelSet. * * Observers should register to this event by calling myLabelSet->AllLabelsModifiedEvent.AddListener(myObject, MyObject::MyMethod). * After registering, myObject->MyMethod() will be called every time a new label has been removed from the LabelSet. * Observers should unregister by calling myLabelSet->AllLabelsModifiedEvent.RemoveListener(myObject, MyObject::MyMethod). * * member variable is not needed to be locked in multi-threaded scenarios since the LabelSetEvent is a typedef for * a Message object which is thread safe */ Message<> AllLabelsModifiedEvent; /** * \brief */ virtual void Initialize(const mitk::Image* image); PixelType* GetImageLayer(int layer); /** * \brief */ void Concatenate(mitk::LabelSetImage* image); /** * \brief */ void ClearBuffer(); /** * \brief */ void AddLabel(const std::string& name, const mitk::Color& color); /** * \brief */ void AddLabel(const mitk::Label& label); /** * \brief */ void MergeLabels(int layer, std::vector& indexes, int index); /** * \brief */ void EraseLabel(int layer, int index, bool reorder); /** * \brief */ void SmoothLabel(int layer, int index); /** * \brief */ void CalculateLabelVolume(int layer, int index); /** * \brief */ void SetLastModificationTime(const std::string& date); /** * \brief */ const std::string& GetLastModificationTime(); /** * \brief */ void SetName(const std::string& date); /** * \brief */ const std::string& GetName(); /** * \brief */ void SetLabelColor(int layer, int index, const mitk::Color &color); /** * \brief */ const mitk::Color& GetLabelColor(int layer, int index); /** * \brief */ void SetLabelOpacity(int layer, int index, float value); /** * \brief */ void SetLabelVolume(int layer, int index, float value); /** * \brief */ void RenameLabel(int layer, int index, const std::string& name, const mitk::Color& color); /** * \brief */ void SetLabelName(int layer, int index, const std::string& name); /** * \brief */ std::string GetLabelName(int layer, int index); /** * \brief */ void SetAllLabelsLocked(int layer, bool); /** * \brief */ void SetAllLabelsVisible(int layer, bool); /** * \brief */ void SetLabelLocked(int layer, int index, bool value); /** * \brief */ void SetLabelSelected(int layer, int index, bool value); /** * \brief */ void SetLabelVisible(int layer, int index, bool value); /** * \brief */ void RemoveLabel(int layer, int index); /** * \brief */ void RemoveLabels(int layer, std::vector& indexes); /** * \brief */ void EraseLabels(int layer, std::vector& indexes); /** * \brief */ void SmoothLabels(int layer, std::vector& indexes); /** * \brief */ bool GetLabelSelected(int layer, int index) const; /** * \brief */ bool GetLabelLocked(int layer, int index) const; /** * \brief */ bool GetLabelVisible(int layer, int index) const; /** * \brief */ int GetActiveLabelIndex(int layer) const; /** * \brief */ const mitk::Color& GetActiveLabelColor(int layer) const; /** * \brief */ double GetActiveLabelOpacity(int layer) const; /** * \brief */ const mitk::Label* GetActiveLabel(int layer) const; /** * \brief */ int GetActiveLayer() const; /** * \brief */ void SetActiveLabel(int layer, int index, bool sendEvent); /** * \brief */ const mitk::Point3D& GetLabelCenterOfMassIndex(int layer, int index, bool forceUpdate); /** * \brief */ const mitk::Point3D& GetLabelCenterOfMassCoordinates(int layer, int index, bool forceUpdate); /** * \brief */ float GetLabelOpacity(int layer, int index); /** * \brief */ float GetLabelVolume(int layer, int index); /** * \brief */ int GetNumberOfLabels(int layer) const; /** * \brief */ int GetTotalNumberOfLabels() const; /** * \brief */ void RemoveAllLabels(int layer); /** * \brief */ mitk::LabelSet::ConstPointer GetLabelSet(int layer) const; /** * \brief */ mitk::LabelSet* GetLabelSet(int layer); /** * \brief */ const mitk::LookupTable* GetLookupTable(int layer); /** * \brief */ void SetLabelSet(int layer, mitk::LabelSet* labelset); /** * \brief */ // bool IsLabelSelected(mitk::Label::Pointer label); /** * \brief */ void ResetLabels(int layer); /** * \brief */ void SurfaceStamp(mitk::Surface* surface, bool forceOverwrite); /** * \brief */ mitk::Image::Pointer CreateLabelMask(int index); /** * \brief */ void InitializeByLabeledImage(mitk::Image::Pointer image); /** * \brief */ void MaskStamp(mitk::Image* mask, bool forceOverwrite); /** * \brief */ void SetActiveLayer(int layer); /** * \brief */ int GetNumberOfLayers(); VectorImageType::Pointer GetVectorImage(bool forceUpdate); void SetVectorImage(VectorImageType::Pointer image ); /** * \brief */ void AddLayer(); /** * \brief */ void RemoveLayer(); /** * \brief */ PixelType* GetLayerBufferPointer(int layer); protected: LabelSetImage(); LabelSetImage(mitk::LabelSetImage*); virtual ~LabelSetImage(); void CreateDefaultLabelSet(int layer); //mutable ImageVtkAccessor* m_VtkImageData; template < typename ImageType1, typename ImageType2 > void ChangeLayerProcessing( ImageType1* source, ImageType2* target ); template < typename ImageType > void AddLayerProcessing( ImageType* input); template < typename ImageType > void VectorToImageProcessing( ImageType* input, int layer); template < typename ImageType > void ImageToVectorProcessing( ImageType* input, int layer); template < typename ImageType > void CalculateCenterOfMassProcessing( ImageType* input, int index); template < typename ImageType > void ClearBufferProcessing( ImageType* input); template < typename ImageType > void EraseLabelProcessing( ImageType* input, int index, bool reorder); template < typename ImageType > void SmoothLabelProcessing( ImageType* input, int layer, int index); template < typename ImageType > void MergeLabelsProcessing( ImageType* input, int index); template < typename ImageType > void ConcatenateProcessing( ImageType* input, mitk::LabelSetImage* other); template < typename ImageType > void MaskStampProcessing( ImageType* input, mitk::Image* mask, bool forceOverwrite); template < typename ImageType > void CreateLabelMaskProcessing( ImageType* input, mitk::Image* mask, int index); template < typename ImageType1, typename ImageType2 > void InitializeByLabeledImageProcessing( ImageType1* input, ImageType2* other); std::vector< LabelSet::Pointer > m_LabelSetContainer; int m_ActiveLayer; std::string m_LastModificationTime; std::string m_Name; VectorImageType::Pointer m_VectorImage; ImageAdaptorType::Pointer m_ImageToVectorAdaptor; }; } // namespace mitk #endif // __mitkLabelSetImage_H_ diff --git a/Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.cpp b/Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.cpp similarity index 70% rename from Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.cpp rename to Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.cpp index 84bae0a583..7586b63c75 100644 --- a/Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.cpp +++ b/Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.cpp @@ -1,629 +1,504 @@ /*=================================================================== 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 "mitkLabelSetImageVtkMapper2D.h" //MITK -#include #include #include -#include #include -#include #include #include #include -#include -#include +//#include #include -#include #include #include - -//MITK Rendering -#include "vtkMitkLevelWindowFilter.h" -#include "vtkNeverTranslucentTexture.h" #include +#include //VTK #include #include #include #include -#include #include -#include #include -#include #include -#include //#include #include mitk::LabelSetImageVtkMapper2D::LabelSetImageVtkMapper2D() { } mitk::LabelSetImageVtkMapper2D::~LabelSetImageVtkMapper2D() { - //The 3D RW Mapper (Geometry2DDataVtkMapper3D) is listening to this event, - //in order to delete the images from the 3D RW. - this->InvokeEvent( itk::DeleteEvent() ); -} - -//set the two points defining the textured plane according to the dimension and spacing -void mitk::LabelSetImageVtkMapper2D::GeneratePlane(mitk::BaseRenderer* renderer, vtkFloatingPointType planeBounds[6]) -{ - LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); - - float depth = this->CalculateLayerDepth(renderer); - //Set the origin to (xMin; yMin; depth) of the plane. This is necessary for obtaining the correct - //plane size in crosshair rotation and swivel mode. - localStorage->m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth); - //These two points define the axes of the plane in combination with the origin. - //Point 1 is the x-axis and point 2 the y-axis. - //Each plane is transformed according to the view (axial, coronal and saggital) afterwards. - localStorage->m_Plane->SetPoint1(planeBounds[1] , planeBounds[2], depth); //P1: (xMax, yMin, depth) - localStorage->m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth); //P2: (xMin, yMax, depth) -} - -float mitk::LabelSetImageVtkMapper2D::CalculateLayerDepth(mitk::BaseRenderer* renderer) -{ - //get the clipping range to check how deep into z direction we can render images - double maxRange = renderer->GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1]; - - //Due to a VTK bug, we cannot use the whole clipping range. /100 is empirically determined - float depth = -maxRange*0.01; // divide by 100 - int layer = 0; - GetDataNode()->GetIntProperty( "layer", layer, renderer); - //add the layer property for each image to render images with a higher layer on top of the others - depth += layer*10; //*10: keep some room for each image (e.g. for QBalls in between) - if (depth > 0.0f) - { - depth = 0.0f; - MITK_WARN << "Layer value exceeds clipping range. Set to minimum instead."; - } - return depth; -} - -const mitk::LabelSetImage* mitk::LabelSetImageVtkMapper2D::GetInput( void ) -{ - return static_cast< const mitk::LabelSetImage * >( GetDataNode()->GetData() ); -} - -vtkProp* mitk::LabelSetImageVtkMapper2D::GetVtkProp(mitk::BaseRenderer* renderer) -{ - //return the actor corresponding to the renderer - return m_LSH.GetLocalStorage(renderer)->m_Actors; } void mitk::LabelSetImageVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); - mitk::LabelSetImage *input = const_cast< mitk::LabelSetImage* >( this->GetInput() ); + mitk::DataNode* node = this->GetDataNode(); + + mitk::LabelSetImage *input = dynamic_cast< mitk::LabelSetImage* >( node->GetData() ); if ( input == NULL || input->IsInitialized() == false ) return; //check if there is a valid worldGeometry const Geometry2D *worldGeometry = renderer->GetCurrentWorldGeometry2D(); if( ( worldGeometry == NULL ) || ( !worldGeometry->IsValid() ) || ( !worldGeometry->HasReferenceGeometry() )) return; input->Update(); // early out if there is no intersection of the current rendering geometry // and the geometry of the image that is to be rendered. if ( !RenderingGeometryIntersectsImage( worldGeometry, input->GetSlicedGeometry() ) ) { // set image to NULL, to clear the texture in 3D, because // the latest image is used there if the plane is out of the geometry // see bug-13275 localStorage->m_ReslicedImage = NULL; - localStorage->m_ReslicedImageMapper->SetInput( localStorage->m_EmptyPolyData ); - localStorage->m_ActiveLabelContourActor->SetVisibility(false); + localStorage->m_Mapper->SetInput( localStorage->m_EmptyPolyData ); + localStorage->m_OutlineActor->SetVisibility(false); return; } - mitk::DataNode* datanode = this->GetDataNode(); - // int numberOfLayers = input->GetNumberOfLayers(); // int activeLayer = input->GetActiveLayer(); // for (int layer=0; layerGetLayerBufferPointer(layer); //set main input for ExtractSliceFilter localStorage->m_Reslicer->SetInput(input); localStorage->m_Reslicer->SetWorldGeometry(worldGeometry); localStorage->m_Reslicer->SetTimeStep( this->GetTimestep() ); //set the transformation of the image to adapt reslice axis localStorage->m_Reslicer->SetResliceTransformByGeometry( input->GetTimeSlicedGeometry()->GetGeometry3D( this->GetTimestep() ) ); //is the geometry of the slice based on the input image or the worldgeometry? bool inPlaneResampleExtentByGeometry = false; - datanode->GetBoolProperty("in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer); + node->GetBoolProperty("in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer); localStorage->m_Reslicer->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry); localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_NEAREST); //set the vtk output property to true, makes sure that no unneeded mitk image convertion //is done. localStorage->m_Reslicer->SetVtkOutputRequest(true); //this is needed when thick mode was enable bevore. These variable have to be reset to default values localStorage->m_Reslicer->SetOutputDimensionality(2); localStorage->m_Reslicer->SetOutputSpacingZDirection(1.0); localStorage->m_Reslicer->SetOutputExtentZDirection(0,0); // Bounds information for reslicing (only reuqired if reference geometry // is present) //this used for generating a vtkPLaneSource with the right size double sliceBounds[6]; for (int i=0; i<6; ++i) { sliceBounds[i] = 0.0; } localStorage->m_Reslicer->GetClippedPlaneBounds(sliceBounds); //get the spacing of the slice localStorage->m_mmPerPixel = localStorage->m_Reslicer->GetOutputSpacing(); double textureClippingBounds[6]; for (int i=0; i<6; ++i) { textureClippingBounds[i] = 0.0; } localStorage->m_Reslicer->Modified(); //start the pipeline with updating the largest possible, needed if the geometry of the input has changed localStorage->m_Reslicer->UpdateLargestPossibleRegion(); localStorage->m_ReslicedImage = localStorage->m_Reslicer->GetVtkOutput(); //generate contours/outlines - localStorage->m_ActiveLabelContour = this->CreateOutlinePolyData( renderer ); + localStorage->m_OutlinePolyData = this->CreateOutlinePolyData( renderer ); // if (layer == activeLayer) // { bool contourAll = false; - datanode->GetBoolProperty( "labelset.contour.all", contourAll, renderer ); + node->GetBoolProperty( "labelset.contour.all", contourAll, renderer ); bool contourActive = false; - datanode->GetBoolProperty( "labelset.contour.active", contourActive, renderer ); + node->GetBoolProperty( "labelset.contour.active", contourActive, renderer ); /* if ( contourAll || contourActive ) { int activeLayer = input->GetActiveLayer(); localStorage->m_LabelOutline->SetInput( localStorage->m_ReslicedImage ); localStorage->m_LabelOutline->SetActiveLabel( input->GetActiveLabelIndex(activeLayer) ); localStorage->m_LabelOutline->SetOutlineAll( contourAll ); localStorage->m_LabelOutline->SetBackground(0.0); localStorage->m_LabelOutline->Update(); localStorage->m_ReslicedImage = localStorage->m_LabelOutline->GetOutput(); } */ // } // localStorage->m_ImageBlend->SetInput(layer, localStorage->m_ReslicedImage); // localStorage->m_ImageBlend->SetOpacity(layer, 1-(double)layer/(double)numberOfLayers); // } // localStorage->m_ImageBlend->Update(); const PlaneGeometry *planeGeometry = dynamic_cast< const PlaneGeometry * >( worldGeometry ); // Calculate the actual bounds of the transformed plane clipped by the // dataset bounding box; this is required for drawing the texture at the // correct position during 3D mapping. mitk::PlaneClipping::CalculateClippedPlaneBounds( input->GetGeometry(), planeGeometry, textureClippingBounds ); textureClippingBounds[0] = static_cast< int >( textureClippingBounds[0] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[1] = static_cast< int >( textureClippingBounds[1] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[2] = static_cast< int >( textureClippingBounds[2] / localStorage->m_mmPerPixel[1] + 0.5 ); textureClippingBounds[3] = static_cast< int >( textureClippingBounds[3] / localStorage->m_mmPerPixel[1] + 0.5 ); //clipping bounds for cutting the image localStorage->m_LevelWindowFilter->SetClippingBounds(textureClippingBounds); float contourWidth = 2.5; - datanode->GetFloatProperty( "labelset.contour.width", contourWidth, renderer ); - localStorage->m_ActiveLabelContourActor->GetProperty()->SetLineWidth( contourWidth ); - localStorage->m_ActiveLabelContourActor->SetVisibility(true); + node->GetFloatProperty( "labelset.contour.width", contourWidth, renderer ); + localStorage->m_OutlineActor->GetProperty()->SetLineWidth( contourWidth ); + localStorage->m_OutlineActor->SetVisibility(true); this->ApplyColor( renderer ); this->ApplyOpacity( renderer ); this->ApplyLookuptable( renderer ); // do not use a VTK lookup table (we do that ourselves in m_LevelWindowFilter) localStorage->m_Texture->MapColorScalarsThroughLookupTableOff(); //connect the input with the levelwindow filter localStorage->m_LevelWindowFilter->SetInput( localStorage->m_ReslicedImage ); //localStorage->m_ImageBlend->GetOutput() ); //connect the texture with the output of the levelwindow filter // check for texture interpolation property bool textureInterpolation = false; - datanode->GetBoolProperty( "texture interpolation", textureInterpolation, renderer ); + node->GetBoolProperty( "texture interpolation", textureInterpolation, renderer ); //set the interpolation modus according to the property localStorage->m_Texture->SetInterpolate(textureInterpolation); localStorage->m_Texture->SetInputConnection(localStorage->m_LevelWindowFilter->GetOutputPort()); this->TransformActor( renderer ); //we need the contour for the binary outline property as actor - localStorage->m_ActiveLabelContourMapper->SetInput( localStorage->m_ActiveLabelContour ); -// localStorage->m_ActiveLabelContourActor->SetTexture(NULL); //no texture for contours + localStorage->m_OutlineMapper->SetInput( localStorage->m_OutlinePolyData ); +// localStorage->m_OutlineActor->SetTexture(NULL); //no texture for contours //setup the textured plane this->GeneratePlane( renderer, sliceBounds ); //set the plane as input for the mapper - localStorage->m_ReslicedImageMapper->SetInputConnection(localStorage->m_Plane->GetOutputPort()); + localStorage->m_Mapper->SetInputConnection(localStorage->m_Plane->GetOutputPort()); //set the texture for the actor - localStorage->m_ReslicedImageActor->SetTexture(localStorage->m_Texture); + localStorage->m_Actor->SetTexture(localStorage->m_Texture); } void mitk::LabelSetImageVtkMapper2D::ApplyColor( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage( renderer ); mitk::LabelSetImage *input = dynamic_cast(this->GetDataNode()->GetData()); int activeLayer = input->GetActiveLayer(); const mitk::Color& activeLabelColor = input->GetActiveLabelColor( activeLayer ); double rgbConv[3] = {(double)activeLabelColor.GetRed(), (double)activeLabelColor.GetGreen(), (double)activeLabelColor.GetBlue()}; - localStorage->m_ActiveLabelContourActor->GetProperty()->SetColor(rgbConv); + localStorage->m_OutlineActor->GetProperty()->SetColor(rgbConv); } void mitk::LabelSetImageVtkMapper2D::ApplyOpacity( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage( renderer ); float opacity = 1.0f; this->GetDataNode()->GetOpacity( opacity, renderer, "opacity" ); - localStorage->m_ReslicedImageActor->GetProperty()->SetOpacity(opacity); - localStorage->m_ActiveLabelContourActor->GetProperty()->SetOpacity(opacity); + localStorage->m_Actor->GetProperty()->SetOpacity(opacity); + localStorage->m_OutlineActor->GetProperty()->SetOpacity(opacity); } void mitk::LabelSetImageVtkMapper2D::ApplyLookuptable( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); mitk::LabelSetImage* input = dynamic_cast(this->GetDataNode()->GetData()); localStorage->m_LevelWindowFilter->SetLookupTable( input->GetLookupTable(input->GetActiveLayer())->GetVtkLookupTable() ); } void mitk::LabelSetImageVtkMapper2D::Update(mitk::BaseRenderer* renderer) { bool visible = true; const DataNode *node = this->GetDataNode(); node->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; - mitk::LabelSetImage* image = const_cast( this->GetInput() ); - if ( !image ) + mitk::LabelSetImage *image = dynamic_cast< mitk::LabelSetImage* >( node->GetData() ); + + if ( image == NULL || image->IsInitialized() == false ) return; - // Calculate time step of the input data for the specified renderer (integer value) + // Calculate time step of the image data for the specified renderer (integer value) this->CalculateTimeStep( renderer ); // Check if time step is valid const TimeSlicedGeometry *dataTimeGeometry = image->GetTimeSlicedGeometry(); if ( ( dataTimeGeometry == NULL ) || ( dataTimeGeometry->GetTimeSteps() == 0 ) || ( !dataTimeGeometry->IsValidTime( this->GetTimestep() ) ) ) { return; } image->UpdateOutputInformation(); LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //check if something important has changed and we need to rerender //(localStorage->m_LastDataUpdateTime < node->GetMTime()) // this one is too generic if ( (localStorage->m_LastDataUpdateTime < image->GetMTime()) //was the data modified? || (localStorage->m_LastDataUpdateTime < image->GetPipelineMTime()) || (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldGeometry2DUpdateTime()) //was the geometry modified? || (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldGeometry2D()->GetMTime()) ) { this->GenerateDataForRenderer( renderer ); localStorage->m_LastDataUpdateTime.Modified(); } else if ( (localStorage->m_LastPropertyUpdateTime < node->GetPropertyList()->GetMTime()) //was a property modified? || (localStorage->m_LastPropertyUpdateTime < node->GetPropertyList(renderer)->GetMTime()) ) { this->ApplyColor(renderer); this->ApplyOpacity(renderer); this->ApplyLookuptable( renderer ); localStorage->m_LastPropertyUpdateTime.Modified(); } } void mitk::LabelSetImageVtkMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { - mitk::LabelSetImage::Pointer image = dynamic_cast(node->GetData()); - if (image.IsNull()) - { - MITK_ERROR << "Setting default properties to a node without an image"; - return; - } + mitk::LabelSetImage* image = dynamic_cast(node->GetData()); + assert(image); +/* // Properties common for both images and segmentations node->AddProperty( "depthOffset", FloatProperty::New( 0.0 ), renderer, overwrite ); if(image->IsRotated()) node->AddProperty( "reslice interpolation", VtkResliceInterpolationProperty::New(VTK_RESLICE_CUBIC) ); else node->AddProperty( "reslice interpolation", VtkResliceInterpolationProperty::New() ); node->AddProperty( "texture interpolation", BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ); // set to user configurable default value (see global options) node->AddProperty( "in plane resample extent by geometry", BoolProperty::New( false ) ); node->AddProperty( "bounding box", BoolProperty::New( false ) ); - +*/ mitk::RenderingModeProperty::Pointer renderingModeProperty = mitk::RenderingModeProperty::New( RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW ); node->AddProperty( "Image Rendering.Mode", renderingModeProperty); mitk::ColormapProperty::Pointer colormapProperty = mitk::ColormapProperty::New(); node->AddProperty( "colormap", colormapProperty, renderer, overwrite ); colormapProperty->SetValue( ColormapProperty::CM_MULTILABEL ); - node->AddProperty( "opacity", FloatProperty::New(1.0f), renderer, overwrite ); + node->AddProperty( "opacity", FloatProperty::New(0.9f), renderer, overwrite ); node->AddProperty( "color", ColorProperty::New(1.0,1.0,1.0), renderer, overwrite ); node->AddProperty( "binary", BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "labelset.contour.all", BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "labelset.contour.active", BoolProperty::New( true ), renderer, overwrite ); node->AddProperty( "labelset.contour.width", FloatProperty::New( 2.5 ), renderer, overwrite ); node->AddProperty( "layer", IntProperty::New(100), renderer, overwrite); mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); mitk::LevelWindow levelwindow; levelwindow.SetLevelWindow(127.5, 255.0); levelwindow.SetRangeMinMax(0, 255); levWinProp->SetLevelWindow( levelwindow ); node->AddProperty( "levelwindow", levWinProp, renderer, overwrite ); - Superclass::SetDefaultProperties(node, renderer, overwrite); -} - -mitk::LabelSetImageVtkMapper2D::LocalStorage* mitk::LabelSetImageVtkMapper2D::GetLocalStorage(mitk::BaseRenderer* renderer) -{ - return m_LSH.GetLocalStorage(renderer); + Superclass::SetDefaultProperties(node, renderer, false); } vtkSmartPointer mitk::LabelSetImageVtkMapper2D::CreateOutlinePolyData(mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage(renderer); + const DataNode *node = this->GetDataNode(); + mitk::LabelSetImage *image = dynamic_cast< mitk::LabelSetImage* >( node->GetData() ); + + if ( image == NULL || image->IsInitialized() == false ) + return NULL; + //get the min and max index values of each direction int* extent = localStorage->m_ReslicedImage->GetExtent(); int xMin = extent[0]; int xMax = extent[1]; int yMin = extent[2]; int yMax = extent[3]; int* dims = localStorage->m_ReslicedImage->GetDimensions(); //dimensions of the image int line = dims[0]; //how many pixels per line? int x = xMin; //pixel index x int y = yMin; //pixel index y LabelSetImage::PixelType* currentPixel; //get the depth for each contour float depth = this->CalculateLayerDepth(renderer); vtkSmartPointer points = vtkSmartPointer::New(); //the points to draw vtkSmartPointer lines = vtkSmartPointer::New(); //the lines to connect the points // We take the pointer to the first pixel of the image currentPixel = static_cast< LabelSetImage::PixelType* >( localStorage->m_ReslicedImage->GetScalarPointer() ); - int activeLayer = this->GetInput()->GetActiveLayer(); - int activeLabel = this->GetInput()->GetActiveLabelIndex(activeLayer); + int activeLayer = image->GetActiveLayer(); + int activeLabel = image->GetActiveLabelIndex(activeLayer); while (y <= yMax) { //if the current pixel value is set to something if ((currentPixel) && (*currentPixel == activeLabel)) { //check in which direction a line is necessary //a line is added if the neighbor of the current pixel has the value 0 //and if the pixel is located at the edge of the image //if vvvvv not the first line vvvvv if (y > yMin && *(currentPixel-line) != activeLabel) { //x direction - bottom edge of the pixel //add the 2 points vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); //add the line between both points lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last line vvvvv if (y < yMax && *(currentPixel+line) != activeLabel) { //x direction - top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the first pixel vvvvv if ( (x > xMin || y > yMin) && *(currentPixel-1) != activeLabel) { //y direction - left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last pixel vvvvv if ( (y < yMax || (x < xMax) ) && *(currentPixel+1) != activeLabel) { //y direction - right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } /* now consider pixels at the edge of the image */ //if vvvvv left edge of image vvvvv if (x == xMin) { //draw left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv right edge of image vvvvv if (x == xMax) { //draw right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv bottom edge of image vvvvv if (y == yMin) { //draw bottom edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv top edge of image vvvvv if (y == yMax) { //draw top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } }//end if currentpixel is set x++; if (x > xMax) { //reached end of line x = xMin; y++; } // Increase the pointer-position to the next pixel. // This is safe, as the while-loop and the x-reset logic above makes // sure we do not exceed the bounds of the image currentPixel++; }//end of while // Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New(); // Add the points to the dataset polyData->SetPoints(points); // Add the lines to the dataset polyData->SetLines(lines); return polyData; } void mitk::LabelSetImageVtkMapper2D::TransformActor(mitk::BaseRenderer* renderer) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //get the transformation matrix of the reslicer in order to render the slice as axial, coronal or saggital vtkSmartPointer trans = vtkSmartPointer::New(); vtkSmartPointer matrix = localStorage->m_Reslicer->GetResliceAxes(); trans->SetMatrix(matrix); //transform the plane/contour (the actual actor) to the corresponding view (axial, coronal or saggital) - localStorage->m_ReslicedImageActor->SetUserTransform(trans); + localStorage->m_Actor->SetUserTransform(trans); //transform the origin to center based coordinates, because MITK is center based. - localStorage->m_ReslicedImageActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); - localStorage->m_ActiveLabelContourActor->SetUserTransform(trans); - localStorage->m_ActiveLabelContourActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); -} - -bool mitk::LabelSetImageVtkMapper2D::RenderingGeometryIntersectsImage( const Geometry2D* renderingGeometry, SlicedGeometry3D* imageGeometry ) -{ - // if either one of the two geometries is NULL we return true - // for safety reasons - if ( renderingGeometry == NULL || imageGeometry == NULL ) - return true; - - // get the distance for the first cornerpoint - ScalarType initialDistance = renderingGeometry->SignedDistance( imageGeometry->GetCornerPoint( 0 ) ); - for( int i=1; i<8; i++ ) - { - mitk::Point3D cornerPoint = imageGeometry->GetCornerPoint( i ); - - // get the distance to the other cornerpoints - ScalarType distance = renderingGeometry->SignedDistance( cornerPoint ); - - // if it has not the same signing as the distance of the first point - if ( initialDistance * distance < 0 ) - { - // we have an intersection and return true - return true; - } - } - - // all distances have the same sign, no intersection and we return false - return false; -} - -mitk::LabelSetImageVtkMapper2D::LocalStorage::~LocalStorage() -{ -} - -mitk::LabelSetImageVtkMapper2D::LocalStorage::LocalStorage() -{ - - m_LevelWindowFilter = vtkSmartPointer::New(); - - //Do as much actions as possible in here to avoid double executions. - m_Plane = vtkSmartPointer::New(); - m_Texture = vtkSmartPointer::New().GetPointer(); - m_ReslicedImageMapper = vtkSmartPointer::New(); - m_ReslicedImageActor = vtkSmartPointer::New(); - m_ActiveLabelContourMapper = vtkSmartPointer::New(); - m_ActiveLabelContourActor = vtkSmartPointer::New(); - m_Actors = vtkSmartPointer::New(); - m_Reslicer = mitk::ExtractSliceFilter::New(); -// m_LabelOutline = vtkSmartPointer::New(); - m_ActiveLabelContour = vtkSmartPointer::New(); - m_ReslicedImage = vtkSmartPointer::New(); - m_EmptyPolyData = vtkSmartPointer::New(); -// m_ImageBlend = vtkSmartPointer::New(); - - //do not repeat the texture (the image) - m_Texture->RepeatOff(); - - //set corresponding mappers for the actors - m_ReslicedImageActor->SetMapper( m_ReslicedImageMapper ); - m_ActiveLabelContourActor->SetMapper( m_ActiveLabelContourMapper ); - - m_Actors->AddPart( m_ActiveLabelContourActor ); - m_Actors->AddPart( m_ReslicedImageActor ); + localStorage->m_Actor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); + localStorage->m_OutlineActor->SetUserTransform(trans); + localStorage->m_OutlineActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); } diff --git a/Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.h b/Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.h similarity index 79% rename from Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.h rename to Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.h index 5f77f1e156..094765684a 100644 --- a/Core/Code/Rendering/mitkLabelSetImageVtkMapper2D.h +++ b/Modules/Segmentation/Rendering/mitkLabelSetImageVtkMapper2D.h @@ -1,290 +1,255 @@ /*=================================================================== 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 __mitkLabelSetImageVtkMapper2D_H_ #define __mitkLabelSetImageVtkMapper2D_H_ //MITK -#include +#include "mitkCommon.h" +#include "SegmentationExports.h" //MITK Rendering #include "mitkBaseRenderer.h" -#include "mitkVtkMapper.h" +#include "mitkImageVtkMapper2D.h" #include "mitkLabelSetImage.h" #include "mitkExtractSliceFilter.h" //VTK #include class vtkActor; class vtkPolyDataMapper; class vtkPlaneSource; +class vtkTexture; class vtkImageData; class vtkLookupTable; class vtkImageReslice; class vtkPoints; class vtkMitkThickSlicesFilter; class vtkPolyData; class vtkMitkLevelWindowFilter; class vtkImageLabelOutline; class vtkImageBlend; class vtkPropAssembly; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D image. * * The following image gives a brief overview of the mapping and the involved parts. * * \image html imageVtkMapper2Darchitecture.png * * First, the image is resliced by means of vtkImageReslice. The volume image * serves as input to the mapper in addition to spatial placement of the slice and a few other * properties such as thick slices. This code was already present in the old version * (mitkImageMapperGL2D). * * Next, the obtained slice (m_ReslicedImage) is put into a vtkMitkLevelWindowFilter * and the scalar levelwindow, opacity levelwindow and optional clipping to * local image bounds are applied * * Next, the output of the vtkMitkLevelWindowFilter is used to create a texture * (m_Texture) and a plane onto which the texture is rendered (m_Plane). For * mapping purposes, a vtkPolyDataMapper (m_Mapper) is utilized. Orthographic * projection is applied to create the effect of a 2D image. The mapper and the * texture are assigned to the actor (m_Actor) which is passed to the VTK rendering * pipeline via the method GetVtkProp(). * * In order to transform the textured plane to the correct position in space, the * same transformation as used for reslicing is applied to both the camera and the * vtkActor. All important steps are explained in more detail below. The resulting * 2D image (by reslicing the underlying 3D input image appropriately) can either * be directly rendered in a 2D view or just be calculated to be used later by another * rendering entity, e.g. in texture mapping in a 3D view. * * Properties that can be set for images and influence the imageMapper2D are: * * - \b "opacity": (FloatProperty) Opacity of the image * - \b "color": (ColorProperty) Color of the image * - \b "LookupTable": (mitkLookupTableProperty) If this property is set, * the default lookuptable will be ignored and the "LookupTable" value * will be used instead. * - \b "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink * - \b "Image Rendering.Transfer Function": (mitkTransferFunctionProperty) If this * property is set, a color transferfunction will be used to color the image. * - \b "binary": (BoolProperty) is the image a binary image or not * - \b "outline binary": (BoolProperty) show outline of the image or not * - \b "texture interpolation": (BoolProperty) texture interpolation of the image * - \b "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image * - \b "in plane resample extent by geometry": (BoolProperty) Do it or not * - \b "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not * - \b "layer": (IntProperty) Layer of the image * - \b "volume annotation color": (ColorProperty) color of the volume annotation, TODO has to be reimplemented * - \b "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml or cm3, TODO has to be reimplemented * The default properties are: * - \b "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ) * - \b "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ) * - \b "binary", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ) * - \b "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ) * - \b "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ) * - \b "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ) * - \b "bounding box", mitk::BoolProperty::New( false ) ) * - \b "layer", mitk::IntProperty::New(10), renderer, overwrite) * - \b "Image Rendering.Transfer Function": Default color transfer function for CTs * - \b "LookupTable": Rainbow color. * If the modality-property is set for an image, the mapper uses modality-specific default properties, * e.g. color maps, if they are defined. * \ingroup Mapper */ -class MITK_CORE_EXPORT LabelSetImageVtkMapper2D : public VtkMapper +class Segmentation_EXPORT LabelSetImageVtkMapper2D : public ImageVtkMapper2D { public: /** Standard class typedefs. */ - mitkClassMacro( LabelSetImageVtkMapper2D,VtkMapper ); + mitkClassMacro( LabelSetImageVtkMapper2D,ImageVtkMapper2D ); /** Method for creation through the object factory. */ itkNewMacro(Self); /** \brief Get the Image to map */ - const mitk::LabelSetImage *GetInput(void); + //const mitk::LabelSetImage *GetInput(void); /** \brief Checks whether this mapper needs to update itself and generate * data. */ virtual void Update(mitk::BaseRenderer * renderer); //### methods of MITK-VTK rendering pipeline - virtual vtkProp* GetVtkProp(mitk::BaseRenderer* renderer); +// virtual vtkProp* GetVtkProp(mitk::BaseRenderer* renderer); //### end of methods of MITK-VTK rendering pipeline - - /** \brief Internal class holding the mapper, actor, etc. for each of the 3 2D render windows */ - /** - * To render transveral, coronal, and sagittal, the mapper is called three times. - * For performance reasons, the corresponding data for each view is saved in the - * internal helper class LocalStorage. This allows rendering n views with just - * 1 mitkMapper using n vtkMapper. - */ - class MITK_CORE_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage +/* + class Segmentation_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage { public: - /** \brief Actor of the resliced image plane. */ vtkSmartPointer m_ReslicedImageActor; - - /** \brief Actor for the outline of the active label. */ vtkSmartPointer m_ActiveLabelContourActor; - vtkSmartPointer m_Actors; - /** \brief Mapper of a 2D render window. */ vtkSmartPointer m_ReslicedImageMapper; vtkSmartPointer m_ActiveLabelContourMapper; - /** \brief Current slice of a 2D render window.*/ vtkSmartPointer m_ReslicedImage; - /** \brief Empty vtkPolyData that is set when rendering geometry does not - * intersect the image geometry. - * \warning This member variable is set to NULL, - * if no image geometry is inside the plane geometry - * of the respective render window. Any user of this - * slice has to check whether it is set to NULL! */ vtkSmartPointer m_EmptyPolyData; - /** \brief Plane on which the slice is rendered as texture. */ vtkSmartPointer m_Plane; - /** \brief The texture which is used to render the current slice. */ vtkSmartPointer m_Texture; - /** \brief The filter to blend all available layers. */ vtkSmartPointer m_ImageBlend; - /** \brief The actual reslicer (one per renderer) */ mitk::ExtractSliceFilter::Pointer m_Reslicer; - /** \brief The filter for generating label outlines */ vtkSmartPointer m_LabelOutline; - /** \brief PolyData object containg all lines/points needed for outlining the contour. - This container is used to save a computed contour for the next rendering execution. - For instance, if you zoom or pann, there is no need to recompute the contour. */ vtkSmartPointer m_ActiveLabelContour; - - /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastDataUpdateTime; - - /** \brief Timestamp of last update of a property. */ itk::TimeStamp m_LastPropertyUpdateTime; - - /** \brief mmPerPixel relation between pixel and mm. (World spacing).*/ mitk::ScalarType* m_mmPerPixel; - - /** \brief This filter is used to apply the level window to Grayvalue and RBG(A) images. */ vtkSmartPointer m_LevelWindowFilter; - /** \brief Default constructor of the local storage. */ LocalStorage(); - /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - +*/ /** \brief The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. */ - mitk::LocalStorageHandler m_LSH; + //mitk::LocalStorageHandler m_LSH; /** \brief Get the LocalStorage corresponding to the current renderer. */ - LocalStorage* GetLocalStorage(mitk::BaseRenderer* renderer); + //LocalStorage* GetLocalStorage(mitk::BaseRenderer* renderer); /** \brief Set the default properties for general image rendering. */ static void SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer = NULL, bool overwrite = false); protected: /** \brief Transforms the actor to the actual position in 3D. * \param renderer The current renderer corresponding to the render window. */ void TransformActor(mitk::BaseRenderer* renderer); /** \brief Generates a plane according to the size of the resliced image in milimeters. * * \image html texturedPlane.png * * In VTK a vtkPlaneSource is defined through three points. The origin and two * points defining the axes of the plane (see VTK documentation). The origin is * set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the * resliced image in space. Z is relevant for blending and the layer property. * The center of the plane (C) is also the center of the view plane (cf. the image above). * * \note For the standard MITK view with three 2D render windows showing three * different slices, three such planes are generated. All these planes are generated * in the XY-plane (even if they depict a YZ-slice of the volume). */ - void GeneratePlane(mitk::BaseRenderer* renderer, vtkFloatingPointType planeBounds[6]); +// void GeneratePlane(mitk::BaseRenderer* renderer, vtkFloatingPointType planeBounds[6]); /** \brief Generates a vtkPolyData object containing the outline of a given binary slice. \param renderer: Pointer to the renderer containing the needed information \note This code is based on code from the iil library. */ vtkSmartPointer CreateOutlinePolyData(mitk::BaseRenderer* renderer); /** Default constructor */ LabelSetImageVtkMapper2D(); /** Default deconstructor */ virtual ~LabelSetImageVtkMapper2D(); /** \brief Does the actual resampling, without rendering the image yet. * All the data is generated inside this method. The vtkProp (or Actor) * is filled with content (i.e. the resliced image). * * After generation, a 4x4 transformation matrix(t) of the current slice is obtained * from the vtkResliceImage object via GetReslicesAxis(). This matrix is * applied to each textured plane (actor->SetUserTransform(t)) to transform everything * to the actual 3D position (cf. the following image). * * \image html cameraPositioning3D.png * */ virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer); /** \brief This method uses the vtkCamera clipping range and the layer property * to calcualte the depth of the object (e.g. image or contour). The depth is used * to keep the correct order for the final VTK rendering. */ - float CalculateLayerDepth(mitk::BaseRenderer* renderer); +// float CalculateLayerDepth(mitk::BaseRenderer* renderer); /** \brief This method applies (or modifies) the lookuptable for all types of images. * \warning To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' * which uses the lookup table must be set. */ void ApplyLookuptable(mitk::BaseRenderer* renderer); /** \brief Set the opacity of the actor. */ void ApplyOpacity( mitk::BaseRenderer* renderer ); /** \brief Set the color of the actor. */ void ApplyColor( mitk::BaseRenderer* renderer ); /** * \brief Calculates whether the given rendering geometry intersects the * given SlicedGeometry3D. * * This method checks if the given Geometry2D intersects the given * SlicedGeometry3D. It calculates the distance of the Geometry2D to all * 8 cornerpoints of the SlicedGeometry3D. If all distances have the same * sign (all positive or all negative) there is no intersection. * If the distances have different sign, there is an intersection. **/ - bool RenderingGeometryIntersectsImage( const Geometry2D* renderingGeometry, SlicedGeometry3D* imageGeometry ); + //bool RenderingGeometryIntersectsImage( const Geometry2D* renderingGeometry, SlicedGeometry3D* imageGeometry ); }; } // namespace mitk -#endif /* MITKLabelSetImageVtkMapper2D_H_HEADER_INCLUDED_C10E906E */ +#endif // __mitkLabelSetImageVtkMapper2D_H_ diff --git a/Modules/Segmentation/files.cmake b/Modules/Segmentation/files.cmake index 9f7e63f01c..bc7f2b1f83 100644 --- a/Modules/Segmentation/files.cmake +++ b/Modules/Segmentation/files.cmake @@ -1,123 +1,127 @@ set(CPP_FILES Algorithms/mitkCalculateSegmentationVolume.cpp Algorithms/mitkContourModelSource.cpp Algorithms/mitkContourModelSubDivisionFilter.cpp Algorithms/mitkContourModelToPointSetFilter.cpp Algorithms/mitkContourModelToSurfaceFilter.cpp Algorithms/mitkContourSetToPointSetFilter.cpp Algorithms/mitkContourUtils.cpp Algorithms/mitkCorrectorAlgorithm.cpp Algorithms/mitkDiffImageApplier.cpp Algorithms/mitkDiffSliceOperation.cpp Algorithms/mitkDiffSliceOperationApplier.cpp Algorithms/mitkImageLiveWireContourModelFilter.cpp Algorithms/mitkImageToContourFilter.cpp Algorithms/mitkImageToContourModelFilter.cpp Algorithms/mitkImageToLiveWireContourFilter.cpp Algorithms/mitkManualSegmentationToSurfaceFilter.cpp Algorithms/mitkOtsuSegmentationFilter.cpp Algorithms/mitkOverwriteDirectedPlaneImageFilter.cpp Algorithms/mitkOverwriteSliceImageFilter.cpp Algorithms/mitkSegmentationObjectFactory.cpp Algorithms/mitkSegmentationSink.cpp Algorithms/mitkShapeBasedInterpolationAlgorithm.cpp Algorithms/mitkShowSegmentationAsSmoothedSurface.cpp Algorithms/mitkShowSegmentationAsSurface.cpp Algorithms/mitkVtkImageOverwrite.cpp Algorithms/mitkLabelSetImageToSurfaceFilter.cpp Algorithms/mitkLabelSetImageToSurfaceThreadedFilter.cpp Algorithms/mitkSurfaceStampImageFilter.cpp Controllers/mitkSegmentationInterpolationController.cpp Controllers/mitkToolManager.cpp Controllers/mitkSegmentationModuleActivator.cpp Controllers/mitkToolManagerProvider.cpp DataManagement/mitkContour.cpp DataManagement/mitkContourElement.cpp DataManagement/mitkContourModel.cpp DataManagement/mitkContourSet.cpp DataManagement/mitkExtrudedContour.cpp + DataManagement/mitkLabel.cpp + DataManagement/mitkLabelSet.cpp + DataManagement/mitkLabelSetImage.cpp Interactions/mitkAdaptiveRegionGrowingTool.cpp Interactions/mitkAddContourTool.cpp Interactions/mitkAutoCropTool.cpp Interactions/mitkAutoSegmentationTool.cpp Interactions/mitkBinaryThresholdTool.cpp Interactions/mitkBinaryThresholdULTool.cpp Interactions/mitkCalculateGrayValueStatisticsTool.cpp Interactions/mitkCalculateVolumetryTool.cpp Interactions/mitkContourInteractor.cpp Interactions/mitkContourModelInteractor.cpp Interactions/mitkContourModelLiveWireInteractor.cpp Interactions/mitkContourTool.cpp Interactions/mitkCorrectorTool2D.cpp Interactions/mitkCreateSurfaceTool.cpp Interactions/mitkDrawPaintbrushTool.cpp Interactions/mitkErasePaintbrushTool.cpp Interactions/mitkEraseRegionTool.cpp Interactions/mitkExtrudedContourInteractor.cpp Interactions/mitkFastMarchingTool.cpp Interactions/mitkFastMarchingTool3D.cpp Interactions/mitkMedianTool3D.cpp Interactions/mitkFeedbackContourTool.cpp Interactions/mitkFillRegionTool.cpp Interactions/mitkLiveWireTool2D.cpp Interactions/mitkOtsuTool3D.cpp Interactions/mitkPaintbrushTool.cpp Interactions/mitkPixelManipulationTool.cpp Interactions/mitkRegionGrow3DTool.cpp Interactions/mitkRegionGrowingTool.cpp Interactions/mitkSegmentationsProcessingTool.cpp Interactions/mitkSetRegionTool.cpp Interactions/mitkSegTool2D.cpp Interactions/mitkSegTool3D.cpp Interactions/mitkSubtractContourTool.cpp Interactions/mitkTool.cpp Interactions/mitkToolCommand.cpp Interactions/mitkWatershedTool.cpp IO/mitkContourModelIOFactory.cpp IO/mitkContourModelReader.cpp IO/mitkContourModelWriter.cpp IO/mitkContourModelWriterFactory.cpp IO/mitkNrrdLabelSetImageIOFactory.cpp IO/mitkNrrdLabelSetImageWriterFactory.cpp IO/mitkNrrdLabelSetImageReader.cpp IO/mitkNrrdLabelSetImageWriter.cpp IO/mitkLabelSetImageSource.cpp Rendering/mitkContourMapper2D.cpp Rendering/mitkContourModelGLMapper2D.cpp Rendering/mitkContourModelMapper2D.cpp Rendering/mitkContourModelMapper3D.cpp Rendering/mitkContourSetMapper2D.cpp Rendering/mitkContourSetVtkMapper3D.cpp Rendering/mitkContourVtkMapper3D.cpp + Rendering/mitkLabelSetImageVtkMapper2D.cpp SegmentationUtilities/BooleanOperations/mitkBooleanOperation.cpp SegmentationUtilities/MorphologicalOperations/mitkMorphologicalOperations.cpp ) set(RESOURCE_FILES Add_48x48.png Add_Cursor_32x32.png Correction_48x48.png Correction_Cursor_32x32.png Erase_48x48.png Erase_Cursor_32x32.png FastMarching_48x48.png FastMarching_Cursor_32x32.png Fill_48x48.png Fill_Cursor_32x32.png LiveWire_48x48.png LiveWire_Cursor_32x32.png Otsu_48x48.png Paint_48x48.png Paint_Cursor_32x32.png RegionGrowing_48x48.png RegionGrowing_Cursor_32x32.png Subtract_48x48.png Subtract_Cursor_32x32.png Threshold_48x48.png TwoThresholds_48x48.png Watershed_48x48.png Watershed_Cursor_32x32.png Wipe_48x48.png Wipe_Cursor_32x32.png MedianTool3D_48x48.png )