diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index aab3e65047..682d1358b0 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,62 +1,63 @@ set(LIBPOSTFIX "Ext") # Modules must be listed according to their dependencies set(module_dirs SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport MitkExt SceneSerialization GraphAlgorithms + SurfaceInterpolation Segmentation PlanarFigureSegmentation Qmitk QmitkExt Properties DiffusionImaging GPGPU IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US ClippingTools USUI DicomUI Simulation Remeshing Python ) set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/Segmentation/CMakeLists.txt b/Modules/Segmentation/CMakeLists.txt index f156909325..a31cd06725 100644 --- a/Modules/Segmentation/CMakeLists.txt +++ b/Modules/Segmentation/CMakeLists.txt @@ -1,10 +1,10 @@ #configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in $#{PROJECT_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) #configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in $#{PROJECT_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) #configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in $#{PROJECT_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) MITK_CREATE_MODULE( Segmentation INCLUDE_DIRS Algorithms Controllers DataManagement Interactions IO Rendering - DEPENDS Mitk ipSegmentation mitkIpFunc MitkExt MitkGraphAlgorithms + DEPENDS Mitk ipSegmentation mitkIpFunc SurfaceInterpolation MitkExt MitkGraphAlgorithms ) add_subdirectory(Testing) \ No newline at end of file diff --git a/Modules/Segmentation/files.cmake b/Modules/Segmentation/files.cmake index 47bd8f2216..e31a5d7629 100644 --- a/Modules/Segmentation/files.cmake +++ b/Modules/Segmentation/files.cmake @@ -1,75 +1,71 @@ set(CPP_FILES Algorithms/mitkCalculateSegmentationVolume.cpp -Algorithms/mitkComputeContourSetNormalsFilter.cpp Algorithms/mitkContourSetToPointSetFilter.cpp Algorithms/mitkContourUtils.cpp Algorithms/mitkCorrectorAlgorithm.cpp -Algorithms/mitkCreateDistanceImageFromSurfaceFilter.cpp Algorithms/mitkDiffImageApplier.cpp Algorithms/mitkImageToContourFilter.cpp Algorithms/mitkManualSegmentationToSurfaceFilter.cpp Algorithms/mitkOverwriteDirectedPlaneImageFilter.cpp Algorithms/mitkOverwriteSliceImageFilter.cpp -Algorithms/mitkReduceContourSetFilter.cpp Algorithms/mitkSegmentationObjectFactory.cpp Algorithms/mitkSegmentationSink.cpp Algorithms/mitkShapeBasedInterpolationAlgorithm.cpp Algorithms/mitkShowSegmentationAsSmoothedSurface.cpp Algorithms/mitkShowSegmentationAsSurface.cpp Algorithms/mitkVtkImageOverwrite.cpp Algorithms/mitkDiffSliceOperation.cpp Algorithms/mitkDiffSliceOperationApplier.cpp Algorithms/mitkContourModelSource.cpp Algorithms/mitkContourModelToPointSetFilter.cpp Algorithms/mitkContourModelToSurfaceFilter.cpp Algorithms/mitkContourModelSubDivisionFilter.cpp Algorithms/mitkImageToContourModelFilter.cpp Algorithms/mitkImageToLiveWireContourFilter.cpp Algorithms/mitkImageLiveWireContourModelFilter.cpp Controllers/mitkSegmentationInterpolationController.cpp -Controllers/mitkSurfaceInterpolationController.cpp # DataManagement/mitkApplyDiffImageOperation.cpp DataManagement/mitkContour.cpp DataManagement/mitkContourSet.cpp DataManagement/mitkExtrudedContour.cpp DataManagement/mitkContourModel.cpp DataManagement/mitkContourElement.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/mitkContourTool.cpp Interactions/mitkCorrectorTool2D.cpp Interactions/mitkCreateSurfaceTool.cpp Interactions/mitkDrawPaintbrushTool.cpp Interactions/mitkErasePaintbrushTool.cpp Interactions/mitkEraseRegionTool.cpp Interactions/mitkExtrudedContourInteractor.cpp Interactions/mitkFeedbackContourTool.cpp Interactions/mitkFillRegionTool.cpp Interactions/mitkPaintbrushTool.cpp Interactions/mitkRegionGrow3DTool.cpp Interactions/mitkRegionGrowingTool.cpp Interactions/mitkSegmentationsProcessingTool.cpp Interactions/mitkSetRegionTool.cpp Interactions/mitkSegTool2D.cpp Interactions/mitkSubtractContourTool.cpp Interactions/mitkContourModelInteractor.cpp Interactions/mitkContourModelLiveWireInteractor.cpp Interactions/mitkLiveWireTool2D.cpp IO/mitkContourModelIOFactory.cpp IO/mitkContourModelReader.cpp IO/mitkContourModelWriter.cpp IO/mitkContourModelWriterFactory.cpp Rendering/mitkContourMapper2D.cpp Rendering/mitkContourSetMapper2D.cpp Rendering/mitkContourSetVtkMapper3D.cpp Rendering/mitkContourVtkMapper3D.cpp Rendering/mitkContourModelMapper2D.cpp Rendering/mitkContourModelMapper3D.cpp Rendering/mitkContourModelGLMapper2D.cpp ) diff --git a/Modules/SurfaceInterpolation/CMakeLists.txt b/Modules/SurfaceInterpolation/CMakeLists.txt new file mode 100644 index 0000000000..981ad60a47 --- /dev/null +++ b/Modules/SurfaceInterpolation/CMakeLists.txt @@ -0,0 +1,3 @@ +MITK_CREATE_MODULE( SurfaceInterpolation + DEPENDS Mitk ImageExtraction +) \ No newline at end of file diff --git a/Modules/SurfaceInterpolation/files.cmake b/Modules/SurfaceInterpolation/files.cmake new file mode 100644 index 0000000000..0dd9c14810 --- /dev/null +++ b/Modules/SurfaceInterpolation/files.cmake @@ -0,0 +1,6 @@ +set(CPP_FILES + mitkComputeContourSetNormalsFilter.cpp + mitkCreateDistanceImageFromSurfaceFilter.cpp + mitkReduceContourSetFilter.cpp + mitkSurfaceInterpolationController.cpp +) \ No newline at end of file diff --git a/Modules/Segmentation/Algorithms/mitkComputeContourSetNormalsFilter.cpp b/Modules/SurfaceInterpolation/mitkComputeContourSetNormalsFilter.cpp similarity index 100% rename from Modules/Segmentation/Algorithms/mitkComputeContourSetNormalsFilter.cpp rename to Modules/SurfaceInterpolation/mitkComputeContourSetNormalsFilter.cpp diff --git a/Modules/Segmentation/Algorithms/mitkComputeContourSetNormalsFilter.h b/Modules/SurfaceInterpolation/mitkComputeContourSetNormalsFilter.h similarity index 95% rename from Modules/Segmentation/Algorithms/mitkComputeContourSetNormalsFilter.h rename to Modules/SurfaceInterpolation/mitkComputeContourSetNormalsFilter.h index a0c454bc4d..42daf6e5a1 100644 --- a/Modules/Segmentation/Algorithms/mitkComputeContourSetNormalsFilter.h +++ b/Modules/SurfaceInterpolation/mitkComputeContourSetNormalsFilter.h @@ -1,108 +1,108 @@ /*=================================================================== 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 mitkComputeContourSetNormalsFilter_h_Included #define mitkComputeContourSetNormalsFilter_h_Included -#include "SegmentationExports.h" +#include "SurfaceInterpolationExports.h" #include "mitkSurfaceToSurfaceFilter.h" #include "mitkProgressBar.h" #include "mitkSurface.h" #include "vtkCellArray.h" #include "vtkPolyData.h" #include "vtkSmartPointer.h" #include "vtkDoubleArray.h" #include "vtkMath.h" #include "vtkCellData.h" #include "vtkLine.h" #include "mitkImage.h" namespace mitk { /** \brief Filter to compute the normales for contours based on vtkPolygons This filter takes a number of extracted contours and computes the normals for each contour edge point. The normals can be accessed by calling: filter->GetOutput(i)->GetVtkPolyData()->GetCellData()->GetNormals(); See also the method GetNormalsAsSurface() Note: If a segmentation binary image is provided this filter assures that the computed normals do not point into the segmentation image $Author: fetzer$ */ -class Segmentation_EXPORT ComputeContourSetNormalsFilter : public SurfaceToSurfaceFilter +class SurfaceInterpolation_EXPORT ComputeContourSetNormalsFilter : public SurfaceToSurfaceFilter { public: mitkClassMacro(ComputeContourSetNormalsFilter,SurfaceToSurfaceFilter); itkNewMacro(Self); itkSetMacro(SegmentationBinaryImage, mitk::Image::Pointer); /* \brief Returns the computed normals as a surface */ mitk::Surface::Pointer GetNormalsAsSurface(); //Resets the filter, i.e. removes all inputs and outputs void Reset(); void SetMaxSpacing(double); /** \brief Set whether the mitkProgressBar should be used \a Parameter true for using the progress bar, false otherwise */ void SetUseProgressBar(bool); /** \brief Set the stepsize which the progress bar should proceed \a Parameter The stepsize for progressing */ void SetProgressStepSize(unsigned int stepSize); protected: ComputeContourSetNormalsFilter(); virtual ~ComputeContourSetNormalsFilter(); virtual void GenerateData(); virtual void GenerateOutputInformation(); private: //The segmentation out of which the contours were extracted. Can be used to determine the direction of the normals mitk::Image::Pointer m_SegmentationBinaryImage; double m_MaxSpacing; unsigned int m_NegativeNormalCounter; unsigned int m_PositiveNormalCounter; bool m_UseProgressBar; unsigned int m_ProgressStepSize; };//class }//namespace #endif diff --git a/Modules/Segmentation/Algorithms/mitkCreateDistanceImageFromSurfaceFilter.cpp b/Modules/SurfaceInterpolation/mitkCreateDistanceImageFromSurfaceFilter.cpp similarity index 100% rename from Modules/Segmentation/Algorithms/mitkCreateDistanceImageFromSurfaceFilter.cpp rename to Modules/SurfaceInterpolation/mitkCreateDistanceImageFromSurfaceFilter.cpp diff --git a/Modules/Segmentation/Algorithms/mitkCreateDistanceImageFromSurfaceFilter.h b/Modules/SurfaceInterpolation/mitkCreateDistanceImageFromSurfaceFilter.h similarity index 97% rename from Modules/Segmentation/Algorithms/mitkCreateDistanceImageFromSurfaceFilter.h rename to Modules/SurfaceInterpolation/mitkCreateDistanceImageFromSurfaceFilter.h index 4784f91a07..fffb7fc097 100644 --- a/Modules/Segmentation/Algorithms/mitkCreateDistanceImageFromSurfaceFilter.h +++ b/Modules/SurfaceInterpolation/mitkCreateDistanceImageFromSurfaceFilter.h @@ -1,194 +1,194 @@ /*=================================================================== 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 mitkCreateDistanceImageFromSurfaceFilter_h_Included #define mitkCreateDistanceImageFromSurfaceFilter_h_Included -#include "SegmentationExports.h" +#include "SurfaceInterpolationExports.h" #include "mitkImageSource.h" #include "mitkSurface.h" #include "mitkProgressBar.h" #include "vtkSmartPointer.h" #include "vtkDoubleArray.h" #include "vtkCellArray.h" #include "vtkCellData.h" #include "vtkPolyData.h" #include "vnl/vnl_matrix.h" #include "vnl/vnl_vector.h" #include "vnl/vnl_vector_fixed.h" #include "vnl/algo/vnl_qr.h" #include "itkImageBase.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkNeighborhoodIterator.h" #include namespace mitk { /** \brief This filter interpolates the 3D surface for a segmented area. The basis for the interpolation are the edge-points of contours that are drawn into an image. The interpolation itself is performed via Radial Basis Function Interpolation. ATTENTION: This filter needs beside the edge points of the delineated contours additionally the normals for each edge point. \sa mitkSurfaceInterpolationController Based on the contour edge points and their normal this filter calculates a distance function with the following properties: - Putting a point into the distance function that lies inside the considered surface gives a negativ scalar value - Putting a point into the distance function that lies outside the considered surface gives a positive scalar value - Putting a point into the distance function that lies exactly on the considered surface gives the value zero With this interpolated distance function a distance image will be created. The desired surface can then be extract e.g. with the marching cubes algorithm. (Within the distance image the surface goes exactly where the pixelvalues are zero) Note that the obtained distance image has always an isotropig spacing. The size (in this case volume) of the image can be adjusted by calling SetDistanceImageVolume(unsigned int volume) which specifies the number ob pixels enclosed by the image. \ingroup Process $Author: fetzer$ */ - class Segmentation_EXPORT CreateDistanceImageFromSurfaceFilter : public ImageSource + class SurfaceInterpolation_EXPORT CreateDistanceImageFromSurfaceFilter : public ImageSource { public: typedef vnl_vector_fixed PointType; typedef itk::Image DistanceImageType; typedef DistanceImageType::IndexType IndexType; typedef itk::ImageRegionIteratorWithIndex ImageIterator; typedef itk::NeighborhoodIterator NeighborhoodImageIterator; typedef std::vector< PointType > NormalList; typedef std::vector< PointType > CenterList; typedef vnl_matrix SolutionMatrix; typedef vnl_vector FunctionValues; typedef vnl_vector InterpolationWeights; typedef std::vector SurfaceList; mitkClassMacro(CreateDistanceImageFromSurfaceFilter,ImageSource); itkNewMacro(Self); //Methods copied from mitkSurfaceToSurfaceFilter virtual void SetInput( const mitk::Surface* surface ); virtual void SetInput( unsigned int idx, const mitk::Surface* surface ); virtual const mitk::Surface* GetInput(); virtual const mitk::Surface* GetInput( unsigned int idx ); virtual void RemoveInputs(mitk::Surface* input); /** \brief Set the size of the output distance image. The size is specified by the image's volume (i.e. in this case how many pixels are enclosed by the image) If non is set, the volume will be 500000 pixels. */ itkSetMacro(DistanceImageVolume, unsigned int); void PrintEquationSystem(); //Resets the filter, i.e. removes all inputs and outputs void Reset(); /** \brief Set whether the mitkProgressBar should be used \a Parameter true for using the progress bar, false otherwise */ void SetUseProgressBar(bool); /** \brief Set the stepsize which the progress bar should proceed \a Parameter The stepsize for progressing */ void SetProgressStepSize(unsigned int stepSize); void SetReferenceImage( itk::ImageBase<3>::Pointer referenceImage ); protected: CreateDistanceImageFromSurfaceFilter(); virtual ~CreateDistanceImageFromSurfaceFilter(); virtual void GenerateData(); virtual void GenerateOutputInformation(); private: void CreateSolutionMatrixAndFunctionValues(); double CalculateDistanceValue(PointType p); void CreateDistanceImage (); /** * \brief This method fills the given variables with the minimum and * maximum coordinates that contain all input-points in index- and * world-coordinates. * * This method iterates over all input-points and transforms them from * world-coordinates to index-coordinates using the transform of the * reference-Image. * Next, the minimal and maximal index-coordinates are determined that * span an area that contains all given input-points. * These index-coordinates are then transformed back to world-coordinates. * * These minimal and maximal points are then set to the given variables. */ void DetermineBounds( DistanceImageType::PointType &minPointInWorldCoordinates, DistanceImageType::PointType &maxPointInWorldCoordinates, DistanceImageType::IndexType &minPointInIndexCoordinates, DistanceImageType::IndexType &maxPointInIndexCoordinates ); void FillImageRegion(DistanceImageType::RegionType reqRegion, DistanceImageType::PixelType pixelValue, DistanceImageType::Pointer image); //Datastructures for the interpolation CenterList m_Centers; NormalList m_Normals; FunctionValues m_FunctionValues; InterpolationWeights m_Weights; SolutionMatrix m_SolutionMatrix; double m_DistanceImageSpacing; itk::ImageBase<3>::Pointer m_ReferenceImage; unsigned int m_DistanceImageVolume; bool m_UseProgressBar; unsigned int m_ProgressStepSize; }; }//namespace #endif diff --git a/Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.cpp b/Modules/SurfaceInterpolation/mitkReduceContourSetFilter.cpp similarity index 100% rename from Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.cpp rename to Modules/SurfaceInterpolation/mitkReduceContourSetFilter.cpp diff --git a/Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.h b/Modules/SurfaceInterpolation/mitkReduceContourSetFilter.h similarity index 96% rename from Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.h rename to Modules/SurfaceInterpolation/mitkReduceContourSetFilter.h index 2f187823a6..8ad1b224c6 100644 --- a/Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.h +++ b/Modules/SurfaceInterpolation/mitkReduceContourSetFilter.h @@ -1,128 +1,128 @@ /*=================================================================== 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 mitkReduceContourSetFilter_h_Included #define mitkReduceContourSetFilter_h_Included -#include "SegmentationExports.h" +#include "SurfaceInterpolationExports.h" #include "mitkSurfaceToSurfaceFilter.h" #include "mitkSurface.h" #include "mitkProgressBar.h" #include "vtkSmartPointer.h" #include "vtkPolyData.h" #include "vtkPolygon.h" #include "vtkPoints.h" #include "vtkCellArray.h" #include "vtkMath.h" #include namespace mitk { /** \brief A filter that reduces the number of points of contours represented by a mitk::Surface The type of the reduction can be set via SetReductionType. The two ways provided by this filter is the \li NTH_POINT Algorithm which reduces the contours according to a certain stepsize \li DOUGLAS_PEUCKER Algorithm which incorpates an error tolerance into the reduction. Stepsize and error tolerance can be set via SetStepSize and SetTolerance. Additional if more than one input contour is provided this filter tries detect contours which occur just because of an intersection. These intersection contours are eliminated. In oder to ensure a correct elimination the min and max spacing of the original image must be provided. The output is a mitk::Surface. $Author: fetzer$ */ - class Segmentation_EXPORT ReduceContourSetFilter : public SurfaceToSurfaceFilter + class SurfaceInterpolation_EXPORT ReduceContourSetFilter : public SurfaceToSurfaceFilter { public: enum Reduction_Type { NTH_POINT, DOUGLAS_PEUCKER }; struct LineSegment { unsigned int StartIndex; unsigned int EndIndex; }; mitkClassMacro(ReduceContourSetFilter,SurfaceToSurfaceFilter); itkNewMacro(Self); itkSetMacro(MinSpacing, double); itkSetMacro(MaxSpacing, double); itkSetMacro(ReductionType, Reduction_Type); itkSetMacro(StepSize, unsigned int); itkSetMacro(Tolerance, double); itkGetMacro(NumberOfPointsAfterReduction, unsigned int); //Resets the filter, i.e. removes all inputs and outputs void Reset(); /** \brief Set whether the mitkProgressBar should be used \a Parameter true for using the progress bar, false otherwise */ void SetUseProgressBar(bool); /** \brief Set the stepsize which the progress bar should proceed \a Parameter The stepsize for progressing */ void SetProgressStepSize(unsigned int stepSize); protected: ReduceContourSetFilter(); virtual ~ReduceContourSetFilter(); virtual void GenerateData(); virtual void GenerateOutputInformation(); private: void ReduceNumberOfPointsByNthPoint (vtkIdType cellSize, vtkIdType* cell, vtkPoints* points, vtkPolygon* reducedPolygon, vtkPoints* reducedPoints); void ReduceNumberOfPointsByDouglasPeucker (vtkIdType cellSize, vtkIdType* cell, vtkPoints* points, vtkPolygon* reducedPolygon, vtkPoints* reducedPoints); bool CheckForIntersection (vtkIdType* currentCell, vtkIdType currentCellSize, vtkPoints* currentPoints, /*vtkIdType numberOfIntersections, vtkIdType* intersectionPoints,*/ unsigned int currentInputIndex); double m_MinSpacing; double m_MaxSpacing; Reduction_Type m_ReductionType; unsigned int m_StepSize; double m_Tolerance; unsigned int m_MaxSegmentLenght; bool m_UseProgressBar; unsigned int m_ProgressStepSize; unsigned int m_NumberOfPointsAfterReduction; };//class }//namespace #endif diff --git a/Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.cpp b/Modules/SurfaceInterpolation/mitkSurfaceInterpolationController.cpp similarity index 100% rename from Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.cpp rename to Modules/SurfaceInterpolation/mitkSurfaceInterpolationController.cpp diff --git a/Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.h b/Modules/SurfaceInterpolation/mitkSurfaceInterpolationController.h similarity index 97% rename from Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.h rename to Modules/SurfaceInterpolation/mitkSurfaceInterpolationController.h index e25c85333e..2d0d3100df 100644 --- a/Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.h +++ b/Modules/SurfaceInterpolation/mitkSurfaceInterpolationController.h @@ -1,173 +1,173 @@ /*=================================================================== 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 mitkSurfaceInterpolationController_h_Included #define mitkSurfaceInterpolationController_h_Included #include "mitkCommon.h" -#include "SegmentationExports.h" +#include "SurfaceInterpolationExports.h" #include "mitkRestorePlanePositionOperation.h" #include "mitkSurface.h" #include "mitkInteractionConst.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkCreateDistanceImageFromSurfaceFilter.h" #include "mitkReduceContourSetFilter.h" #include "mitkComputeContourSetNormalsFilter.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkWeakPointer.h" #include "vtkPolygon.h" #include "vtkPoints.h" #include "vtkCellArray.h" #include "vtkPolyData.h" #include "vtkSmartPointer.h" #include "vtkAppendPolyData.h" #include "vtkMarchingCubes.h" #include "vtkImageData.h" #include "mitkVtkRepresentationProperty.h" #include "vtkProperty.h" #include "mitkProgressBar.h" namespace mitk { - class Segmentation_EXPORT SurfaceInterpolationController : public itk::Object + class SurfaceInterpolation_EXPORT SurfaceInterpolationController : public itk::Object { public: mitkClassMacro(SurfaceInterpolationController, itk::Object) itkNewMacro(Self) static SurfaceInterpolationController* GetInstance(); /** * Adds a new extracted contour to the list */ void AddNewContour(Surface::Pointer newContour, RestorePlanePositionOperation *op); /** * Interpolates the 3D surface from the given extracted contours */ void Interpolate (); mitk::Surface::Pointer GetInterpolationResult(); /** * Sets the minimum spacing of the current selected segmentation * This is needed since the contour points we reduced before they are used to interpolate the surface */ void SetMinSpacing(double minSpacing); /** * Sets the minimum spacing of the current selected segmentation * This is needed since the contour points we reduced before they are used to interpolate the surface */ void SetMaxSpacing(double maxSpacing); /** * Sets the volume i.e. the number of pixels that the distance image should have * By evaluation we found out that 50.000 pixel delivers a good result */ void SetDistanceImageVolume(unsigned int distImageVolume); /** * Sets the current segmentation which is used by the interpolation * This is needed because the calculation of the normals needs to now wheather a normal points inside a segmentation or not */ void SetSegmentationImage(Image* workingImage); Surface* GetContoursAsSurface(); void SetDataStorage(DataStorage::Pointer ds); /** * Sets the current list of contourpoints which is used for the surface interpolation * @param segmentation The current selected segmentation */ void SetCurrentSegmentationInterpolationList(mitk::Image* segmentation); /** * Removes the segmentation and all its contours from the list * @param segmentation The segmentation to be removed */ void RemoveSegmentationFromContourList(mitk::Image* segmentation); mitk::Image* GetImage(); /** * Estimates the memory which is needed to build up the equationsystem for the interpolation. * \returns The percentage of the real memory which will be used by the interpolation */ double EstimatePortionOfNeededMemory(); protected: SurfaceInterpolationController(); ~SurfaceInterpolationController(); template void GetImageBase(itk::Image* input, itk::ImageBase<3>::Pointer& result); private: void OnSegmentationDeleted(const itk::Object *caller, const itk::EventObject &event); struct ContourPositionPair { Surface::Pointer contour; RestorePlanePositionOperation* position; }; typedef std::vector ContourPositionPairList; typedef std::map ContourListMap; ContourPositionPairList::iterator m_Iterator; ReduceContourSetFilter::Pointer m_ReduceFilter; ComputeContourSetNormalsFilter::Pointer m_NormalsFilter; CreateDistanceImageFromSurfaceFilter::Pointer m_InterpolateSurfaceFilter; double m_MinSpacing; double m_MaxSpacing; const Image* m_WorkingImage; Surface::Pointer m_Contours; vtkSmartPointer m_PolyData; unsigned int m_DistImageVolume; mitk::DataStorage::Pointer m_DataStorage; ContourListMap m_MapOfContourLists; mitk::Surface::Pointer m_InterpolationResult; unsigned int m_CurrentNumberOfReducedContours; mitk::Image* m_SelectedSegmentation; std::map m_SegmentationObserverTags; }; } #endif