-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STYLE: Call SetNthOutput(i, MakeOutput(i))
in a for
loop
#4687
STYLE: Call SetNthOutput(i, MakeOutput(i))
in a for
loop
#4687
Conversation
Reduced duplicate code by replacing manual `SetNthOutput(i, MakeOutput(i)` calls for i = 0, 1, 2 with the corresponding `for` loops.
SetNthOutput(i, MakeOutput(i)
in a for
loopSetNthOutput(i, MakeOutput(i))
in a for
loop
@blowekamp Following our discussion at #4654 (comment) I'm still trying to get clear in which particular scenario's |
OK, so this could be a nice use case, being able to call |
Thanks for the continued investigation and the discussion. These filters have multiple outputs of different types. These different output types are not represented by the template parameters. Hence the Note: An incorrectly casted image type can work a surprising long time as the wrong type. |
It is also used here:
Which indirectly gets called when operations the "ReleaseDataFlagOn" or "DisconnectPipeline" are called and the output created in the constructor is created again. |
Interesting, thanks! Apparently |
// distance map, voronoi map, distance vectors | ||
for (unsigned int i{}; i < numberOfRequiredOutputs; ++i) | ||
{ | ||
ProcessObject::SetNthOutput(i, Self::MakeOutput(i)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can make this more generic, like:
ProcessObject::SetRequiredOutputs(*this, numberOfRequiredOutputs);
This new function, SetRequiredOutputs
would then set the numberOfRequiredOutputs and do the for
loop. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the constructors we are in a bit of a hard place where the methods called be the constructor should not be virtual. That is the virtual MakeOutput should not be called by base classes in the constructor.
This is more of a design issue, maybe the output should only be created on demand? or Maybe a separate "virtual Initialize" method is needed.
Then there is the idea of having a base class take multiple template parameters for inputs and outputs.... But for the few filters it's likely not worth the refactor.
|
Reduced duplicate code by replacing manual
SetNthOutput(i, MakeOutput(i))
calls for i = 0, 1, 2 with the correspondingfor
loops.