Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
SuperElastix
Commits
2733afe7
Commit
2733afe7
authored
Feb 02, 2016
by
Floris Berendsen
Browse files
ENH: added Test for ImageRegistrationMethodv4
parent
eb744278
Changes
7
Hide whitespace changes
Inline
Side-by-side
Modules/Components/ItkSmoothingRecursiveGaussianImageFilter/ModuleItkSmoothingRecursiveGaussianImageFilter.cmake
View file @
2733afe7
...
...
@@ -13,6 +13,11 @@ set( ${MODULE}_LIBRARIES
${
MODULE
}
)
# Export tests
set
(
${
MODULE
}
_TESTS
elxitkImageFilterTest.cxx
)
# Module source files
set
(
${
MODULE
}
_SOURCE_FILES
${${
MODULE
}
_SOURCE_DIR
}
/src/selxItkImageSource.cxx
...
...
Modules/Components/itkImageRegistrationMethodv4/ModuleItkImageRegistrationMethodv4.cmake
View file @
2733afe7
...
...
@@ -13,9 +13,17 @@ set( ${MODULE}_LIBRARIES
${
MODULE
}
)
# Export tests
set
(
${
MODULE
}
_TESTS
elxRegistrationItkv4Test.cxx
)
# Module source files
set
(
${
MODULE
}
_SOURCE_FILES
${${
MODULE
}
_SOURCE_DIR
}
/src/selxItkImageRegistrationMethodv4.cxx
)
${${
MODULE
}
_SOURCE_DIR
}
/src/selxItkImageRegistrationMethodv4.cxx
${${
MODULE
}
_SOURCE_DIR
}
/src/selxItkImageSourceFixed.cxx
${${
MODULE
}
_SOURCE_DIR
}
/src/selxItkImageSourceMoving.cxx
)
# Compile library
...
...
Modules/Components/itkImageRegistrationMethodv4/include/selxItkImageRegistrationMethodv4Component.h
View file @
2733afe7
...
...
@@ -12,7 +12,7 @@ namespace selx
template
<
int
Dimensionality
,
class
TPixel
>
class
ItkImageRegistrationMethodv4Component
:
public
Implements
<
Accepting
<
itkImageSourceInterface
<
Dimensionality
,
TPixel
>
>
,
Accepting
<
itkImageSource
Fixed
Interface
<
Dimensionality
,
TPixel
>
,
itkImageSourceMovingInterface
<
Dimensionality
,
TPixel
>
>
,
Providing
<
itkImageSourceInterface
<
Dimensionality
,
TPixel
>
>
>
{
...
...
@@ -40,7 +40,9 @@ namespace selx
typedef
itk
::
ResampleImageFilter
<
MovingImageType
,
ConnectionImageType
>
ResampleFilterType
;
virtual
int
Set
(
itkImageSourceInterface
<
Dimensionality
,
TPixel
>*
)
override
;
virtual
int
Set
(
itkImageSourceFixedInterface
<
Dimensionality
,
TPixel
>*
)
override
;
virtual
int
Set
(
itkImageSourceMovingInterface
<
Dimensionality
,
TPixel
>*
)
override
;
virtual
ItkImageSourcePointer
GetItkImageSource
()
override
;
virtual
bool
MeetsCriterion
(
const
CriterionType
&
criterion
)
override
;
...
...
Modules/Components/itkImageRegistrationMethodv4/include/selxItkImageRegistrationMethodv4Component.hxx
View file @
2733afe7
...
...
@@ -16,12 +16,21 @@ ItkImageRegistrationMethodv4Component< Dimensionality, TPixel>::~ItkImageRegistr
}
template
<
int
Dimensionality
,
class
TPixel
>
int
ItkImageRegistrationMethodv4Component
<
Dimensionality
,
TPixel
>::
Set
(
itkImageSourceInterface
<
Dimensionality
,
TPixel
>*
component
)
int
ItkImageRegistrationMethodv4Component
<
Dimensionality
,
TPixel
>::
Set
(
itkImageSource
Fixed
Interface
<
Dimensionality
,
TPixel
>*
component
)
{
auto
other
=
component
->
GetItkImageSource
();
auto
other
=
component
->
GetItkImageSourceFixed
();
// connect the itk pipeline
this
->
m_theItkFilter
->
SetFixedImage
(
other
->
GetOutput
());
return
1
;
}
template
<
int
Dimensionality
,
class
TPixel
>
int
ItkImageRegistrationMethodv4Component
<
Dimensionality
,
TPixel
>::
Set
(
itkImageSourceMovingInterface
<
Dimensionality
,
TPixel
>*
component
)
{
auto
other
=
component
->
GetItkImageSourceMoving
();
// connect the itk pipeline
this
->
m_theItkFilter
->
SetMovingImage
(
other
->
GetOutput
());
return
0
;
return
1
;
}
//ItkImageSourceType::Pointer
...
...
Modules/Core/ComponentInterface/include/InterfaceTraits.h
View file @
2733afe7
...
...
@@ -93,7 +93,22 @@ struct InterfaceName < itkImageSourceInterface <D, TPixel> >
}
};
template
<
int
D
,
class
TPixel
>
struct
InterfaceName
<
itkImageSourceFixedInterface
<
D
,
TPixel
>
>
{
static
const
char
*
Get
()
{
return
"itkImageSourceFixedInterface"
;
}
};
template
<
int
D
,
class
TPixel
>
struct
InterfaceName
<
itkImageSourceMovingInterface
<
D
,
TPixel
>
>
{
static
const
char
*
Get
()
{
return
"itkImageSourceMovingInterface"
;
}
};
template
<
>
struct
InterfaceName
<
SourceInterface
>
{
...
...
Modules/Core/ComponentInterface/src/Overlord.cxx
View file @
2733afe7
...
...
@@ -41,13 +41,21 @@ namespace selx
// The (failing) criteria can be printed as well.
if
(
numberOfComponents
==
0
)
{
itkExceptionMacro
(
"Too many criteria for component"
);
//TODO report about m_Criteria
std
::
stringstream
message
;
message
<<
"Too many criteria for component "
<<
this
->
m_ComponentSelectorContainer
[
*
componentIt
]
->
GetNameOfClass
();
// "There is no component in our database that fulfills your set of criteria
std
::
cout
<<
message
.
str
();
//TODO how does this work for strings?
itkExceptionMacro
(
"Too many criteria for component "
);
}
else
if
(
numberOfComponents
>
1
)
{
allUniqueComponents
=
false
;
}
std
::
cout
<<
"blueprint node "
<<
*
componentIt
<<
" has selected"
<<
numberOfComponents
<<
" components"
<<
std
::
endl
;
std
::
cout
<<
"blueprint node "
<<
*
componentIt
<<
" has selected
"
<<
numberOfComponents
<<
" components"
<<
std
::
endl
;
}
return
allUniqueComponents
;
...
...
@@ -169,7 +177,7 @@ namespace selx
//TODO GetComponent returns NULL if possible components !=1 we can check for that, but Overlord::UpdateSelectors() does something similar.
ComponentBase
::
Pointer
sourceComponent
=
this
->
m_ComponentSelectorContainer
[
ouputIt
->
m_source
]
->
GetComponent
();
ComponentBase
::
Pointer
targetComponent
=
this
->
m_ComponentSelectorContainer
[
ouputIt
->
m_target
]
->
GetComponent
();
targetComponent
->
ConnectFrom
(
sourceComponent
);
targetComponent
->
Accept
Connect
ion
From
(
sourceComponent
);
}
}
//TODO should we communicate by exceptions instead of returning booleans?
...
...
Testing/Unit/elxComponentInterfaceTest.cxx
View file @
2733afe7
...
...
@@ -69,26 +69,26 @@ TEST_F( InterfaceTest, DynamicCast )
TEST_F
(
InterfaceTest
,
ConnectByName
)
{
ComponentBase
::
interfaceStatus
IFstatus
;
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
ConnectFrom
(
"MetricValueInterface"
,
metric3p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
Accept
Connect
ion
From
(
"MetricValueInterface"
,
metric3p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
success
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
ConnectFrom
(
"MetricValueInterface"
,
metric4p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
Accept
Connect
ion
From
(
"MetricValueInterface"
,
metric4p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
success
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
ConnectFrom
(
"MetricValueInterface"
,
metric3p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
Accept
Connect
ion
From
(
"MetricValueInterface"
,
metric3p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
success
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
ConnectFrom
(
"MetricValueInterface"
,
metric4p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
Accept
Connect
ion
From
(
"MetricValueInterface"
,
metric4p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
success
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
ConnectFrom
(
"MetricDerivativeInterface"
,
metric3p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
Accept
Connect
ion
From
(
"MetricDerivativeInterface"
,
metric3p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
success
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
ConnectFrom
(
"MetricDerivativeInterface"
,
metric4p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer3p
->
Accept
Connect
ion
From
(
"MetricDerivativeInterface"
,
metric4p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
noprovider
);
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
ConnectFrom
(
"MetricDerivativeInterface"
,
metric3p
));
EXPECT_NO_THROW
(
IFstatus
=
optimizer4p
->
Accept
Connect
ion
From
(
"MetricDerivativeInterface"
,
metric3p
));
EXPECT_EQ
(
IFstatus
,
ComponentBase
::
interfaceStatus
::
noaccepter
);
}
...
...
@@ -98,7 +98,7 @@ TEST_F(InterfaceTest, ConnectAll)
int
connectionCount
=
0
;
int
returnval
;
OptimizerUpdateInterface
*
updateIF
;
EXPECT_NO_THROW
(
connectionCount
=
optimizer3p
->
ConnectFrom
(
metric3p
));
EXPECT_NO_THROW
(
connectionCount
=
optimizer3p
->
Accept
Connect
ion
From
(
metric3p
));
EXPECT_EQ
(
connectionCount
,
2
);
// both MetricValueInterface and MetricDerivativeInterface are connected
//optimizer3p should have a OptimizerUpdateInterface
...
...
@@ -106,27 +106,27 @@ TEST_F(InterfaceTest, ConnectAll)
ASSERT_NE
(
updateIF
,
nullptr
);
EXPECT_NO_THROW
(
returnval
=
updateIF
->
Update
());
// Update can only be called if metric and optimizer are connected
EXPECT_NO_THROW
(
connectionCount
=
optimizer3p
->
ConnectFrom
(
metric4p
));
EXPECT_NO_THROW
(
connectionCount
=
optimizer3p
->
Accept
Connect
ion
From
(
metric4p
));
EXPECT_EQ
(
connectionCount
,
1
);
// only MetricValueInterface is connected
//metric4p does not have MetricDerivativeInterface, so optimizer3p cannot run
EXPECT_NO_THROW
(
connectionCount
=
optimizer4p
->
ConnectFrom
(
metric3p
));
EXPECT_NO_THROW
(
connectionCount
=
optimizer4p
->
Accept
Connect
ion
From
(
metric3p
));
EXPECT_EQ
(
connectionCount
,
1
);
// only MetricValueInterface is connected
updateIF
=
dynamic_cast
<
OptimizerUpdateInterface
*>
(
optimizer4p
);
ASSERT_NE
(
updateIF
,
nullptr
);
EXPECT_NO_THROW
(
returnval
=
updateIF
->
Update
());
EXPECT_NO_THROW
(
connectionCount
=
optimizer4p
->
ConnectFrom
(
metric4p
));
EXPECT_NO_THROW
(
connectionCount
=
optimizer4p
->
Accept
Connect
ion
From
(
metric4p
));
EXPECT_EQ
(
connectionCount
,
1
);
// only MetricValueInterface is connected
updateIF
=
dynamic_cast
<
OptimizerUpdateInterface
*>
(
optimizer4p
);
ASSERT_NE
(
updateIF
,
nullptr
);
EXPECT_NO_THROW
(
returnval
=
updateIF
->
Update
());
EXPECT_NO_THROW
(
connectionCount
=
metric4p
->
ConnectFrom
(
optimizer4p
));
EXPECT_NO_THROW
(
connectionCount
=
metric4p
->
Accept
Connect
ion
From
(
optimizer4p
));
EXPECT_EQ
(
connectionCount
,
0
);
// cannot connect in this direction
ConflictinUpdateInterface
*
update2IF
=
dynamic_cast
<
ConflictinUpdateInterface
*>
(
optimizer4p
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment