[f6d9b9]: / lib / ChainOfResponsibility.cpp

Download this file

62 lines (51 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "../includes/ChainOfResponsibility.h"
#include "../includes/Masking/Masking.h"
#include <iostream>
void Chain::addCommandByName(const std::string& name)
{
if (name == "masking")
{
std::cout << "Adding masking command." << std::endl;
std::shared_ptr<Command> maskingCommand = std::make_shared<Masking>(std::shared_ptr<Chain>(this));
commandList.push_back(maskingCommand);
}
else
{
std::cout << "Wrong command type" << std::endl;
}
}
bool Chain::execute()
{
if (commandList.size() == 0)
{
std::cout << "No command added yet. Exiting." << std::endl;
return false;
}
bool ok = true;
std::cout << "Starting execution." << std::endl;
for (std::shared_ptr<Command>& command : commandList)
{
ok = command->execute();
if (ok == false)
{
break;
}
}
return ok;
}
void Chain::setParameters(Parameters &params) { this->params = params; }
Parameters Chain::getParameters() const { return params; }
void Chain::setMask(sitk::Image &mask) { this->mask = mask; }
sitk::Image Chain::getMask() const { return mask; }
void Chain::setImage(sitk::Image &image) { this->image = image; }
sitk::Image Chain::getImage() const { return image; }
Parameters::Parameters()
{
params["maskingStrategy"] = "rayCasting";
params["regularMaskingRegionGrowingSeedType"] = "center";
params["regularMaskingRegionGrowingLowerThreshold"] = "0";
params["regularMaskingRegionGrowingUpperThreshold"] = "80";
}
void Parameters::setParameter(std::string key, std::string value) { params[key] = value; }
std::string Parameters::getValue(std::string key) { return params[key]; }
void Parameters::validateParameters() {}