Commit 6b40b677 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: ExecutionOrder can be passed as setting to CompositeTransformComponent

parent db922017
......@@ -68,7 +68,7 @@ private:
typename std::vector<MultiStageTransformInterface< InternalComputationValueType, Dimensionality >*> m_registrationStages;
std::set< ReconnectTransformInterface * > m_ReconnectTransformInterfaces;
std::vector<std::string> m_ExecutionOrder;
protected:
// return the class name and the template arguments to uniquely identify this component.
......
......@@ -66,11 +66,43 @@ template< class InternalComputationValueType, int Dimensionality >
void
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >::RegistrationControllerStart()
{
for (auto & stage : this->m_registrationStages)
// Check if the names connected stages are compatible with the provided execution order
// TODO: should we handle such component sanity checks as separate overlord check instead of as execution stage?
std::vector<std::string> sortedExecutionNames(this->m_ExecutionOrder); // copy container
std::vector<std::string> sortedStageNames; // empty container
sortedStageNames.resize(sortedExecutionNames.size()); // allocate space
std::transform(this->m_registrationStages.begin(), this->m_registrationStages.end(), sortedStageNames.begin(),
[](MultiStageTransformInterface< InternalComputationValueType, Dimensionality >* stageIterator) { return stageIterator->GetComponentName(); });
sort(sortedExecutionNames.begin(), sortedExecutionNames.end());
sort(sortedStageNames.begin(), sortedStageNames.end());
std::vector<std::string> mismatchNames;
//mismatchNames.resize(sortedExecutionNames.size() + sortedStageNames.size()); // allocate space worst case, no overlap
std::set_symmetric_difference(sortedExecutionNames.begin(), sortedExecutionNames.end(), sortedStageNames.begin(), sortedStageNames.end(), mismatchNames.begin());
if (mismatchNames.size() > 0)
{
std::cout << "Non-fatal error: The names of ExecutionOrder and the connected Stages do not correspond for " << this->m_Name << ". Found mismatch is [ ";
for (auto const & name : mismatchNames)
{
std::cout <<""<< name << """ ";
}
std::cout << "]." << std::endl;
}
// Perform execution flow
for (auto const & stageName : this->m_ExecutionOrder)
{
stage->SetMovingInitialTransform(this->m_CompositeTransform);
stage->RunRegistration();
this->m_CompositeTransform->AppendTransform(stage->GetItkTransform());
auto && stageIterator = std::find_if(this->m_registrationStages.begin(),
this->m_registrationStages.end(),
[stageName](MultiStageTransformInterface< InternalComputationValueType, Dimensionality >* thisStage) { return thisStage->GetComponentName() == stageName; });
(*stageIterator)->SetMovingInitialTransform(this->m_CompositeTransform);
(*stageIterator)->RunRegistration();
this->m_CompositeTransform->AppendTransform((*stageIterator)->GetItkTransform());
}
for( auto && reconnectTransformInterface : this->m_ReconnectTransformInterfaces )
{
......@@ -85,7 +117,6 @@ ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
::MeetsCriterion( const ComponentBase::CriterionType & criterion )
{
bool hasUndefinedCriteria( false );
bool meetsCriteria( false );
auto status = CheckTemplateProperties( this->TemplateProperties(), criterion );
if( status == CriterionStatus::Satisfied )
......@@ -96,6 +127,13 @@ ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
{
return false;
} // else: CriterionStatus::Unknown
return meetsCriteria;
if (criterion.first == "ExecutionOrder") //Supports this?
{
// should we check on non-repeating names?
this->m_ExecutionOrder = criterion.second;
return true;
}
return hasUndefinedCriteria;
}
} //end namespace selx
......@@ -94,7 +94,7 @@ public:
virtual void SetFixedInitialTransform(typename CompositeTransformType::Pointer fixedInitialTransform) override;
virtual void SetMovingInitialTransform(typename CompositeTransformType::Pointer movingInitialTransform) override;
virtual typename std::string GetComponentName() override;
virtual const typename std::string GetComponentName() override;
//BaseClass methods
virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
......
......@@ -287,11 +287,11 @@ ItkImageRegistrationMethodv4Component< Dimensionality, TPixel, InternalComputati
}
template< int Dimensionality, class TPixel, class InternalComputationValueType >
typename std::string
const typename std::string
ItkImageRegistrationMethodv4Component< Dimensionality, TPixel, InternalComputationValueType >
::GetComponentName()
{
return "to be implemented";
return this->m_Name; //from ComponentBase
}
template< int Dimensionality, class TPixel, class InternalComputationValueType >
......
......@@ -644,7 +644,7 @@ TEST_F(RegistrationItkv4Test, CompositeTransform)
/** make example blueprint configuration */
blueprint = Blueprint::New();
blueprint->AddComponent("MultiStageTransformController", { { "NameOfClass", { "ItkCompositeTransformComponent" } } });
blueprint->AddComponent("MultiStageTransformController", { { "NameOfClass", { "ItkCompositeTransformComponent" } }, { "ExecutionOrder", { "RegistrationMethod1", "RegistrationMethod2" } } });
blueprint->AddComponent("FixedImageSource", { { "NameOfClass", { "ItkImageSourceFixedComponent" } } });
blueprint->AddComponent("MovingImageSource", { { "NameOfClass", { "ItkImageSourceMovingComponent" } } });
......
......@@ -70,7 +70,7 @@ public:
//virtual const std::map< std::string, std::string > TemplateProperties(); //TODO should be overridden
void Name(const std::string setName){ m_Name = setName; }; //Setter should be via constructor. We should get rid of itk factory design.
const std::string Name(){ return m_Name; };
//const std::string GetComponentName() { return m_Name; };
protected:
......
......@@ -319,7 +319,7 @@ public:
virtual void RunRegistration(void) = 0;
virtual void SetMovingInitialTransform(typename CompositeTransformType::Pointer) = 0;
virtual typename TransformBaseType::Pointer GetItkTransform() = 0;
virtual typename std::string GetComponentName() = 0;
virtual const typename std::string GetComponentName() = 0;
};
} // end namespace selx
......
......@@ -137,6 +137,8 @@ Overlord::ApplyNodeConfiguration()
{
std::cout << " Blueprint Node: " << name << std::endl;
ComponentSelectorPointer currentComponentSelector = ComponentSelector::New();
currentComponentSelector->ComponentName(name); // Todo via constructor
Blueprint::ParameterMapType currentProperty = this->m_Blueprint->GetComponent( name );
for( auto const & criterion : currentProperty )
{
......
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