SourceXtractorPlusPlus  0.10
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoreThresholdPartitionConfig.cpp
Go to the documentation of this file.
1 
17 /*
18  * CoreThresholdPartitionConfig.cpp
19  *
20  * Created on: May 28, 2019
21  * Author: mkuemmel@usm.lmu.de
22  */
23 
25 
27 
31 
32 
33 namespace po = boost::program_options;
34 using namespace Euclid::Configuration;
35 
36 namespace SourceXtractor {
37 
38 static const std::string CORE_THRESHOLD {"core-threshold-value" };
39 static const std::string CORE_MINAREA {"core-minimum-area" };
40 static const std::string CORE_THRESH_USE {"partition-corethreshold" };
41 
42 CoreThresholdPartitionConfig::CoreThresholdPartitionConfig(long manager_id)
43  : Configuration(manager_id), m_core_threshold(0.), m_core_minarea(0) {
44  declareDependency<PartitionStepConfig>();
45 
46  ConfigManager::getInstance(manager_id).registerDependency<CoreThresholdPartitionConfig, MultiThresholdPartitionConfig>();
47 }
48 
50  return {{"Core threshold partitioning", {
51  {CORE_THRESHOLD.c_str(), po::value<double>()->default_value(0.0), "The core threshold level"},
52  {CORE_MINAREA.c_str(), po::value<int>()->default_value(0), "The minimum pixel area for partitioning"},
53  {CORE_THRESH_USE.c_str(), po::bool_switch(), "Activate core threshold partitioning"}
54  }}};
55 }
56 
57 void CoreThresholdPartitionConfig::initialize(const UserValues &args) {
58  m_core_threshold = args.find(CORE_THRESHOLD)->second.as<double>();
59  m_core_minarea = args.find(CORE_MINAREA)->second.as<int>();
60 
61  if (m_core_threshold < 0.) {
62  throw Elements::Exception() << "Invalid " << CORE_THRESHOLD << " value: " << m_core_threshold;
63  }
64  if (m_core_minarea < 0) {
65  throw Elements::Exception() << "Invalid " << CORE_MINAREA << " value: " << m_core_minarea;
66  }
67 
68  if (m_core_minarea > 0.0 && m_core_minarea > 0 && args.at(CORE_THRESH_USE).as<bool>()){
69 
70  double core_threshold = m_core_threshold;
71  int core_minarea = m_core_minarea;
72  getDependency<PartitionStepConfig>().addPartitionStepCreator([core_threshold, core_minarea](std::shared_ptr<SourceFactory>)
73  { return std::make_shared<CoreThresholdPartitionStep>(core_threshold, core_minarea); } );
74  }
75 }
76 
78  return m_core_threshold;
79 }
80 
82  return m_core_minarea;
83 }
84 
85 } // end SExtractor
std::map< std::string, OptionDescriptionList > getProgramOptions() override
STL class.
STL class.
static const std::string CORE_MINAREA
static const std::string CORE_THRESHOLD
T c_str(T...args)
static const std::string CORE_THRESH_USE