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
986f8d59
Commit
986f8d59
authored
Sep 01, 2016
by
Floris Berendsen
Browse files
ENH: added Plain old datatype to string
parent
c5d94b6f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Modules/Components/itkImageRegistrationMethodv4/include/selxItkGradientDescentOptimizerv4.h
View file @
986f8d59
...
...
@@ -25,6 +25,8 @@
#include
"itkGradientDescentOptimizerv4.h"
#include
<string.h>
#include
"selxMacro.h"
namespace
selx
{
template
<
class
InternalComputationValueType
>
...
...
Modules/Components/itkImageRegistrationMethodv4/include/selxItkGradientDescentOptimizerv4.hxx
View file @
986f8d59
...
...
@@ -19,6 +19,7 @@
#include
"selxItkGradientDescentOptimizerv4.h"
#include
<boost/lexical_cast.hpp>
#include
"selxPodString.h"
namespace
selx
{
...
...
@@ -55,12 +56,12 @@ ItkGradientDescentOptimizerv4Component< InternalComputationValueType >
{
bool
hasUndefinedCriteria
(
false
);
bool
meetsCriteria
(
false
);
if
(
criterion
.
first
==
"
ComponentProperty
"
)
if
(
criterion
.
first
==
"
InternalComputationValueType
"
)
{
meetsCriteria
=
true
;
for
(
auto
const
&
criterionValue
:
criterion
.
second
)
// auto&& preferred?
{
if
(
criterionValue
!=
"SomeProperty"
)
// e.g. "GradientDescent", "SupportsSparseSamples
if
(
criterionValue
!=
PodString
<
InternalComputationValueType
>::
Get
()
)
// e.g. "GradientDescent", "SupportsSparseSamples
{
meetsCriteria
=
false
;
}
...
...
Modules/Core/Common/include/selxPodString.h
0 → 100644
View file @
986f8d59
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxPodString_h
#define selxPodString_h
#include
"selxStaticErrorMessageRevealT.h"
namespace
selx
{
template
<
typename
T
>
struct
PodString
{
static_assert
(
StaticErrorMessageRevealT
<
T
>::
False
,
"Please Implement PodString<T> for this T"
);
};
template
<
>
struct
PodString
<
unsigned
int
>
{
static
const
char
*
Get
()
{
return
"unsigned int"
;
}
};
template
<
>
struct
PodString
<
int
>
{
static
const
char
*
Get
()
{
return
"int"
;
}
};
template
<
>
struct
PodString
<
float
>
{
static
const
char
*
Get
()
{
return
"float"
;
}
};
template
<
>
struct
PodString
<
double
>
{
static
const
char
*
Get
()
{
return
"double"
;
}
};
}
#endif //selxPodString_h
\ No newline at end of file
Modules/Core/Common/include/selxStaticErrorMessageRevealT.h
0 → 100644
View file @
986f8d59
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxStaticErrorMessageRevealT_h
#define selxStaticErrorMessageRevealT_h
namespace
selx
{
// helper to display type name in static assert error message (required, at least for VC++ 2013)
template
<
typename
T
>
struct
StaticErrorMessageRevealT
{
enum
{
False
=
false
};
};
}
#endif // selxStaticErrorMessageRevealT_h
\ No newline at end of file
Modules/Core/ComponentInterface/include/selxInterfaceTraits.h
View file @
986f8d59
...
...
@@ -23,15 +23,12 @@
//TODO: note, maybe this functionality shouldn't be called a Trait, since we use a method ::Get(). Is Policy a better name?
#include
"selxInterfaces.h"
#include
"selxStaticErrorMessageRevealT.h"
#include
"selxPodString.h"
//#include <type_traits>
namespace
selx
{
// helper to display type name in static assert error message (required, at least for VC++ 2013)
template
<
typename
T
>
struct
StaticErrorMessageRevealT
{
enum
{
False
=
false
};
};
// Traits to get printable interface name
// In our toolbox for each InterfaceType it is required to implement InterfaceName<InterfaceType>::Get()
...
...
@@ -280,16 +277,17 @@ struct Properties< itkImageFixedInterface< D, TPixel >>
{
static
const
std
::
map
<
std
::
string
,
std
::
string
>
Get
()
{
return
{
{
"NameOfInterface"
,
InterfaceName
<
itkImageFixedInterface
<
D
,
TPixel
>
>::
Get
()
},
{
"Dimensionality"
,
"3"
},
{
"PixelType"
,
"float"
}
};
return
{
{
"NameOfInterface"
,
"
itkImageFixedInterface
"
},
{
"Dimensionality"
,
std
::
to_string
(
D
)
},
{
"PixelType"
,
PodString
<
TPixel
>::
Get
()
}
};
}
};
template
<
>
struct
Properties
<
MetricValueInterface
>
template
<
class
C
>
struct
Properties
<
itkOptimizerv4Interface
<
C
>
>
{
static
const
std
::
map
<
std
::
string
,
std
::
string
>
Get
()
{
return
{
{
"NameOfInterface"
,
"
MetricValueInterface"
}
};
return
{
{
"NameOfInterface"
,
"
itkOptimizerv4Interface"
},
{
"InternalComputationValueType"
,
PodString
<
C
>::
Get
()
}
};
}
};
}
// end namespace selx
...
...
Modules/Core/ComponentInterface/src/selxOverlord.cxx
View file @
986f8d59
...
...
@@ -58,6 +58,7 @@ Overlord::Configure()
while
(
anySelectionNarrowed
){
anySelectionNarrowed
=
false
;
nonUniqueComponentNames
=
this
->
GetNonUniqueComponentNames
();
for
(
auto
const
&
name
:
nonUniqueComponentNames
)
{
// check all components that accept from component "name"
...
...
@@ -99,7 +100,7 @@ Overlord::Configure()
//TODO:
//1: this lambda function converts the blueprint properties: map<string,vector<string>> to interfacecriteria: map<string,string>, consider redesign.
//2: connection blueprint->addConnection("myfirstnode","mysecondnode",{{}}) creates connectionProperties {"",[]} which is not an empty map.
std
::
for_each
(
connectionProperties
.
begin
(),
connectionProperties
.
end
(),
[
interfaceCriteria
](
Blueprint
::
ParameterMapType
::
value_type
kv
)
mutable
{
if
(
kv
.
second
.
size
()
>
0
)
interfaceCriteria
[
kv
.
first
]
=
kv
.
second
[
0
];
});
std
::
for_each
(
connectionProperties
.
begin
(),
connectionProperties
.
end
(),
[
&
interfaceCriteria
](
Blueprint
::
ParameterMapType
::
value_type
kv
)
mutable
{
if
(
kv
.
second
.
size
()
>
0
)
interfaceCriteria
[
kv
.
first
]
=
kv
.
second
[
0
];
});
auto
incomingComponent
=
this
->
m_ComponentSelectorContainer
[
incomingName
]
->
GetComponent
();
...
...
@@ -224,13 +225,13 @@ Overlord::ApplyConnectionConfiguration()
{
for
(
auto
const
&
outgoingName
:
this
->
m_Blueprint
->
GetOutputNames
(
name
)
)
{
Blueprint
::
ParameterMapType
connectionProperties
=
this
->
m_Blueprint
->
GetConnection
(
name
,
outgoingName
);
Blueprint
::
ParameterMapType
connectionProperties
=
this
->
m_Blueprint
->
GetConnection
(
name
,
outgoingName
);
//TODO:
//1: this lambda function converts the blueprint properties: map<string,vector<string>> to interfacecriteria: map<string,string>, consider redesign.
//2: connection blueprint->addConnection("myfirstnode","mysecondnode",{{}}) creates connectionProperties {"",[]} which is not an empty map.
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
;
std
::
for_each
(
connectionProperties
.
begin
(),
connectionProperties
.
end
(),
[
interfaceCriteria
](
Blueprint
::
ParameterMapType
::
value_type
kv
)
mutable
{
if
(
kv
.
second
.
size
()
>
0
)
interfaceCriteria
[
kv
.
first
]
=
kv
.
second
[
0
];
});
std
::
for_each
(
connectionProperties
.
begin
(),
connectionProperties
.
end
(),
[
&
interfaceCriteria
](
Blueprint
::
ParameterMapType
::
value_type
kv
)
mutable
{
if
(
kv
.
second
.
size
()
>
0
)
interfaceCriteria
[
kv
.
first
]
=
kv
.
second
[
0
];
});
this
->
m_ComponentSelectorContainer
[
name
]
->
AddProvidingInterfaceCriteria
(
interfaceCriteria
);
this
->
m_ComponentSelectorContainer
[
outgoingName
]
->
AddAcceptingInterfaceCriteria
(
interfaceCriteria
);
...
...
Modules/Core/ComponentInterface/test/selxOverlordTest.cxx
View file @
986f8d59
...
...
@@ -151,10 +151,10 @@ TEST_F(OverlordTest, DeduceComponentsFromConnections)
{
"Dimensionality"
,
{
"3"
}
},
{
"PixelType"
,
{
"float"
}
}
});
ParameterMapType
component2Parameters
;
component2Parameters
[
"NameOfClass"
]
=
{
"ItkImageSourceMovingComponent"
};
component2Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the inputs
blueprint
->
AddComponent
(
"MovingImageSource"
,
component2Parameters
);
blueprint
->
AddComponent
(
"MovingImageSource"
,
{
{
"NameOfClass"
,
{
"ItkImageSourceMovingComponent"
}
},
{
"Dimensionality"
,
{
"3"
}
},
{
"PixelType"
,
{
"float"
}
}
});
ParameterMapType
component3Parameters
;
component3Parameters
[
"NameOfClass"
]
=
{
"ItkImageSinkComponent"
};
...
...
@@ -217,7 +217,7 @@ TEST_F(OverlordTest, DeduceComponentsFromConnections)
blueprint
->
AddConnection
(
"FixedImageSource"
,
"TransformResolutionAdaptor"
,
{
{}
});
blueprint
->
AddConnection
(
"TransformResolutionAdaptor"
,
"RegistrationMethod"
,
{
{}
});
blueprint
->
AddConnection
(
"Optimizer"
,
"RegistrationMethod"
,
{
{}
});
blueprint
->
AddConnection
(
"Optimizer"
,
"RegistrationMethod"
,
{
{
"InternalComputationValueType"
,
{
"double"
}
}
});
blueprint
->
AddConnection
(
"RegistrationMethod"
,
"TransformDisplacementFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"FixedImageSource"
,
"TransformDisplacementFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"RegistrationMethod"
,
"ResampleFilter"
,
{
{}
});
...
...
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