#ifndef __LSGRM_CONTROLLER_H #define __LSGRM_CONTROLLER_H #include "lsrmGetInternalMemory.h" #include "lsgrmSplitter.h" #include "lsgrmGraphOperations.h" #include "itkObject.h" #include "itkMacro.h" namespace lsgrm { template class ITK_EXPORT Controller : public itk::Object { public: /** Standard class typedef */ typedef Controller Self; typedef itk::LightObject Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Runtime information support. */ itkTypeMacro(Controller, itk::Object); /** Method for creation through the object factory. */ itkNewMacro(Self); /** Enum for tiling mode */ enum LSGRMTilingMode { LSGRM_TILING_NONE, LSGRM_TILING_USER, LSGRM_TILING_AUTO }; /* Some convenient typedefs */ using SegmenterType = TSegmenter; using ImageType = typename SegmenterType::ImageType; using LabelImageType = typename SegmenterType::LabelImageType; using SegmentationParameterType = typename SegmenterType::ParameterType; /* Default constructor and destructor. */ Controller(); ~Controller(); void RunSegmentation(); void SetSpecificParameters(const SegmentationParameterType& params); void SetInputImage(ImageType * inputImage); void SetInternalMemoryAvailable(long long unsigned int v); // expecting a value in Mbytes. /* Accessors */ void SetTilingModeNone(){m_TilingMode = LSGRM_TILING_NONE;}; void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER;}; void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO;}; typename LabelImageType::Pointer GetLabeledClusteredOutput(); itkGetMacro(Margin, unsigned int); itkGetMacro(TemporaryFilesList, std::vector); itkGetMacro(CleanTemporaryDirectory, bool); itkSetMacro(CleanTemporaryDirectory, bool); itkGetMacro(TemporaryDirectory, std::string); itkSetMacro(TemporaryDirectory, std::string); itkGetMacro(Threshold, float); itkSetMacro(Threshold, float); itkGetMacro(NumberOfIterations, unsigned int); itkSetMacro(NumberOfIterations, unsigned int); itkGetMacro(NbTilesX, unsigned int); itkSetMacro(NbTilesX, unsigned int); itkGetMacro(NbTilesY, unsigned int); itkSetMacro(NbTilesY, unsigned int); itkGetMacro(NumberOfFirstIterations, unsigned int); itkSetMacro(NumberOfFirstIterations, unsigned int); itkGetMacro(TileWidth, unsigned int); itkSetMacro(TileWidth, unsigned int); itkGetMacro(TileHeight, unsigned int); itkSetMacro(TileHeight, unsigned int); private: void GetAutomaticConfiguration(); long unsigned int GetMaximumNumberOfNodesInMemory(); /* Parameters given by the user */ std::string m_TemporaryDirectory; // Directory used to store intermediate files during the process. bool m_CleanTemporaryDirectory; // Clean the temporary directory. ImageType * m_InputImage; // Input image /* Segmentation parameters */ SegmentationParameterType m_SpecificParameters; // Specific parameters float m_Threshold; // Threshold unsigned int m_NumberOfIterations; // Number of iterations /* Parameters given by the user or computed automatically * depending of the chosen mode */ long long unsigned int m_Memory; // RAM available for the computation. unsigned int m_NbTilesX; unsigned int m_NbTilesY; unsigned int m_NumberOfFirstIterations; unsigned int m_TileWidth; unsigned int m_TileHeight; /* read-only variables */ unsigned int m_Margin; std::vector m_Tiles; std::vector m_TemporaryFilesList; LSGRMTilingMode m_TilingMode; typename LabelImageType::Pointer m_LabelImage; }; } // end of namespace lsgrm #include "lsgrmController.txx" #endif