OutputPortExtender - How to add a precondition
radone
New Altair Community Member
I have input port extender defined as folows:
How can I add a Metadata precodndition to the innerOut1 port?
This approach failed:
private OutputPortExtender innerOut1 = new OutputPortExtender(The code is generated from operator and therefore it is not possible to use any passthrough rule.
"Example Set", getSubprocess(0).getInnerSources());
How can I add a Metadata precodndition to the innerOut1 port?
This approach failed:
innerOut1.deliverMetaData(getMetadata());Thanks in advance for any help.
private List<MetaData> getMetadata() {
List<MetaData> metadata = new Vector<MetaData>();
metadata.add(new MetaData(ExampleSet.class));
return metadata;
}
0
Answers
-
Hi,
output ports don't have preconditions. For InputPortExtenders, you either pass it a desiredMetaData in the constuctor if your precondition is as simple as requiring an IOObject of a certain type, or you override makePrecondition.
The rules for the output ports are handeled just as those of any other port.
Best,
Simon0 -
Hi,
I can't figure out, how to add generation rule for OutputPortExtender.
This is defined only for OutputPort.Simon Fischer wrote:
The rules for the output ports are handeled just as those of any other port.getTransformer().addGenerationRule(port, IOObject.class);
How can I do same thing for OutputPortExtender?
Thanks for your answers.0 -
I made small work around by modifying OneToManyPassThroughRule class:
But I'm not sure if it is good solution of this problem. Is there better way to solve it?
public class ManyGenerationRule implements MDTransformationRule {
private final Collection<OutputPort> outputPorts;
MetaData metaData;
public ManyGenerationRule(OutputPorts outputPorts, MetaData metaData) {
this(outputPorts.getAllPorts(), metaData);
}
public ManyGenerationRule(Collection<OutputPort> outputPorts, MetaData metaData) {
this.outputPorts = outputPorts;
this.metaData = metaData;
}
@Override
public void transformMD() {
int i = 0;
for (OutputPort outputPort : outputPorts) {
if (metaData != null) {
metaData = metaData.clone();
metaData.addToHistory(outputPort);
outputPort.deliverMD(metaData);
} else {
outputPort.deliverMD(null);
}
i++;
}
}
}0 -
Hi,
Simon is out of office right now but I am sure he will come back to you later.
Cheers,
Ingo0 -
Hi StaryVena,
I think your solution is perfect. To be honest, I don't know why we don't have a ready-made class like the one you posted, but I also can't think of an operator that would use it - why would an operator produce several identical objects? May I ask what your application is, maybe I can make a better proposal then.
Best,
Simon0 -
It is inner output port of OperatorChain. Segmented image comes to outer input port and to inner operators is sent only one segment per one subprocess run. Segmented image and one segment have different IOObject class. It could be used Multiply operator and single output port, but almost always will be used several inner operators. Thats why I prefer output port extender instead of single port.Simon Fischer wrote:
..., but I also can't think of an operator that would use it - why would an operator produce several identical objects? May I ask what your application is, maybe I can make a better proposal then.
Thank you for your answer.
Ciao
StaryVena0 -
Hi,
then I think your solution is fine.
Best,
Simon0