Commit cd286117 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: moved control from overlord to RegistrationControllerComponent

parent b106c745
......@@ -54,9 +54,9 @@ namespace selx
virtual bool MeetsCriterion(const ComponentBase::CriterionType &criterion) override;
static const char * GetDescription() { return "RegistrationController Component"; };
private:
RunRegistrationInterface* m_RunRegistrationInterface;
ReconnectTransformInterface* m_ReconnectTransformInterface;
AfterRegistrationInterface* m_AfterRegistrationInterface;
std::set<RunRegistrationInterface*> m_RunRegistrationInterfaces;
std::set<ReconnectTransformInterface*> m_ReconnectTransformInterfaces;
std::set<AfterRegistrationInterface*> m_AfterRegistrationInterfaces;
protected:
};
......
......@@ -22,8 +22,7 @@
namespace selx
{
template<bool dummy>
RegistrationControllerComponent< dummy>::RegistrationControllerComponent() :
m_RunRegistrationInterface(nullptr), m_ReconnectTransformInterface(nullptr), m_AfterRegistrationInterface(nullptr)
RegistrationControllerComponent< dummy>::RegistrationControllerComponent()
{
}
......@@ -35,30 +34,39 @@ namespace selx
template<bool dummy>
int RegistrationControllerComponent< dummy>::Set(RunRegistrationInterface* other)
{
this->m_RunRegistrationInterface = other;
this->m_RunRegistrationInterfaces.insert(other);
return 0;
}
template<bool dummy>
int RegistrationControllerComponent< dummy>::Set(ReconnectTransformInterface* other)
{
this->m_ReconnectTransformInterface = other;
this->m_ReconnectTransformInterfaces.insert(other);
return 0;
}
template<bool dummy>
int RegistrationControllerComponent< dummy>::Set(AfterRegistrationInterface* other)
{
this->m_AfterRegistrationInterface = other;
this->m_AfterRegistrationInterfaces.insert(other);
return 0;
}
template<bool dummy>
void RegistrationControllerComponent< dummy>::RegistrationControllerStart()
{
this->m_RunRegistrationInterface->RunRegistration();
this->m_ReconnectTransformInterface->ReconnectTransform();
this->m_AfterRegistrationInterface->AfterRegistration();
for (auto && runRegistrationInterface : this->m_RunRegistrationInterfaces)
{
runRegistrationInterface->RunRegistration();
}
for (auto && reconnectTransformInterface : this->m_ReconnectTransformInterfaces)
{
reconnectTransformInterface->ReconnectTransform();
}
for (auto && afterRegistrationInterface : this->m_AfterRegistrationInterfaces)
{
afterRegistrationInterface->AfterRegistration();
}
}
template<bool dummy>
......
......@@ -431,6 +431,8 @@ TEST_F(RegistrationItkv4Test, FullyConfigured3d)
blueprint->AddComponent("Transform", { { "NameOfClass", { "ItkGaussianExponentialDiffeomorphicTransformComponent" } },
{ "Dimensionality", { "3" } } });
blueprint->AddComponent("Controller", { { "NameOfClass", { "RegistrationControllerComponent"} } });
ParameterMapType connection1Parameters;
connection1Parameters["NameOfInterface"] = { "itkImageFixedInterface" };
blueprint->AddConnection("FixedImageSource", "RegistrationMethod", connection1Parameters);
......@@ -459,6 +461,12 @@ TEST_F(RegistrationItkv4Test, FullyConfigured3d)
blueprint->AddConnection("RegistrationMethod", "ResampleFilter", { {} });
blueprint->AddConnection("FixedImageSource", "ResampleFilter", { {} });
blueprint->AddConnection("MovingImageSource", "ResampleFilter", { {} });
blueprint->AddConnection("RegistrationMethod", "Controller", { {} }); //RunRegistrationInterface
blueprint->AddConnection("ResampleFilter", "Controller", { {} }); //ReconnectTransformInterface
blueprint->AddConnection("TransformDisplacementFilter", "Controller", { {} }); //ReconnectTransformInterface
blueprint->AddConnection("ResultImageSink", "Controller", { {} }); //AfterRegistrationInterface
blueprint->AddConnection("ResultDisplacementFieldSink", "Controller", { {} }); //AfterRegistrationInterface
// Instantiate SuperElastix
SuperElastixFilterType::Pointer superElastixFilter;
......
......@@ -33,6 +33,6 @@ namespace selx
const char * const HasAcceptingInterface = "HasAcceptingInterface"; // Checks component (base class) if the interface is present
const char * const SourceInterface = "SourceInterface"; // Special interface that connects to the outside of the SuperElastixFilter
const char * const SinkInterface = "SinkInterface"; // Special interface that connects to the outside of the SuperElastixFilter
const char * const RegistrationControllerStartInterface = "RegistrationControllerStartInterface"; //Special interface by which all algorithms are started
}
}
\ No newline at end of file
......@@ -53,6 +53,9 @@ namespace selx
typedef std::map <
std::string, SinkInterface* > SinkInterfaceMapType;
typedef std::map <
std::string, RegistrationControllerStartInterface* > RegistrationControllerStartInterfaceMapType;
Overlord();
~Overlord() {};
......@@ -126,6 +129,8 @@ namespace selx
typedef itk::VectorContainer <
unsigned int, ComponentBase::Pointer > ComponentsContainerType;
RegistrationControllerStartInterfaceMapType m_RegistrationControllerStartInterfaces;
ComponentsContainerType::Pointer m_RunRegistrationComponents;
ComponentsContainerType::Pointer m_AfterRegistrationComponents;
......
......@@ -326,8 +326,8 @@ namespace selx
{
// TODO make one "update button" for the overlord
this->FindRunRegistration();
this->FindAfterRegistration();
//this->FindRunRegistration();
//this->FindAfterRegistration();
// RunRegistrations is a simple execution model
// E.g.if the components are true itk Process Object, the don't need an 'Update' call.
......@@ -335,11 +335,28 @@ namespace selx
// If components need RunIterations() or RunResolution() we can explicitly 'Update' them here and control the flow.
// TODO: see if signals-and-slots paradigm is appropriate here.
this->RunRegistrations();
this->ReconnectTransforms();
this->AfterRegistrations();
//this->RunRegistrations();
//this->ReconnectTransforms();
//this->AfterRegistrations();
//update all writers...
/** Scans all Components to find those with RegistrationControllerStart capability and call them */
const CriterionType criterion = CriterionType(keys::HasProvidingInterface, { keys::RegistrationControllerStartInterface });
for (auto const & componentSelector : this->m_ComponentSelectorContainer)
{
ComponentBase::Pointer component = componentSelector.second->GetComponent();
if (component->MeetsCriterionBase(criterion))
{
RegistrationControllerStartInterface* providingInterface = dynamic_cast<RegistrationControllerStartInterface*> (component.GetPointer());
if (providingInterface == nullptr) // is actually a double-check for sanity: based on criterion cast should be successful
{
std::runtime_error::runtime_error("dynamic_cast<RegistrationControllerStartInterface*> fails, but based on component criterion it shouldn't");
}
providingInterface->RegistrationControllerStart();
}
}
}
AnyFileReader::Pointer Overlord::GetInputFileReader(const Overlord::ComponentNameType& inputName)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment