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
5d878eb6
Commit
5d878eb6
authored
Feb 02, 2017
by
Floris Berendsen
Browse files
BUG: forgot to handle Connection properties in ComposeWith
parent
1ce87383
Changes
2
Hide whitespace changes
Inline
Side-by-side
Modules/Core/Blueprints/src/selxBlueprintImpl.cxx
View file @
5d878eb6
...
...
@@ -226,6 +226,7 @@ Blueprint::BlueprintImpl
// Make a backup of the current blueprint status in case composition fails
GraphType
graph_backup
=
GraphType
(
this
->
m_Graph
);
// Copy-in all components (Nodes)
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
())
{
// Does other blueprint use component with a name that already exists?
...
...
@@ -280,6 +281,66 @@ Blueprint::BlueprintImpl
}
}
// Copy-in all connections (Edges)
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
())
{
for
(
auto
incomingName
:
other
->
GetInputNames
(
componentName
))
{
// Does other blueprint have a connection that already exists?
if
(
this
->
ConnectionExists
(
incomingName
,
componentName
))
{
// Connection exists, check if properties can be merged
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
auto
othersProperties
=
other
->
GetConnection
(
incomingName
,
componentName
);
for
(
auto
const
&
othersEntry
:
othersProperties
)
{
// Does other use a property key that already exists in this component?
if
(
ownProperties
.
count
(
othersEntry
.
first
))
{
auto
&&
ownValues
=
ownProperties
[
othersEntry
.
first
];
auto
&&
otherValues
=
othersEntry
.
second
;
// Are the property values equal?
if
(
ownValues
.
size
()
!=
otherValues
.
size
())
{
// No, based on the number of values we see that it is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
return
false
;
}
else
{
ParameterValueType
::
const_iterator
ownValue
;
ParameterValueType
::
const_iterator
otherValue
;
for
(
ownValue
=
ownValues
.
begin
(),
otherValue
=
otherValues
.
begin
();
ownValue
!=
ownValues
.
end
();
++
ownValue
,
++
otherValue
)
{
if
(
*
otherValue
!=
*
ownValue
)
{
// No, at least one value is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
return
false
;
}
}
}
}
else
{
// Property key doesn't exist yet, add entry to this component
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
ownProperties
[
othersEntry
.
first
]
=
othersEntry
.
second
;
this
->
SetConnection
(
incomingName
,
componentName
,
ownProperties
);
}
}
}
else
{
// Create Component copying properties of other
this
->
SetConnection
(
incomingName
,
componentName
,
other
->
GetConnection
(
incomingName
,
componentName
));
}
}
}
return
true
;
}
...
...
Modules/Core/ComponentInterface/include/selxNetworkBuilder.hxx
View file @
5d878eb6
...
...
@@ -25,7 +25,7 @@ namespace selx
{
template
<
typename
ComponentList
>
NetworkBuilder
<
ComponentList
>::
NetworkBuilder
()
:
m_isConfigured
(
false
)
NetworkBuilder
<
ComponentList
>::
NetworkBuilder
()
:
m_isConfigured
(
false
)
,
m_Blueprint
(
new
Blueprint
)
{
}
...
...
@@ -33,7 +33,7 @@ template< typename ComponentList >
bool
NetworkBuilder
<
ComponentList
>::
AddBlueprint
(
const
std
::
unique_ptr
<
Blueprint
>
&
blueprint
)
{
m_Blueprint
->
ComposeWith
(
blueprint
);
this
->
m_Blueprint
->
ComposeWith
(
blueprint
);
//m_Blueprint = std::make_shared< Blueprint >(*blueprint);
return
true
;
}
...
...
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