To make connecting easier, we'll add forwarding connect and connect_only functions in the global namespace (where vtk classes live) specific to the vtk framework. The Dataflow library provides include file templates for this purpose.
Including <boost/dataflow/templates/binary_operation.hpp> with #defined
DATAFLOW_TEMPLATE_TAG
and DATAFLOW_TEMPLATE_BINARY_OPERATION
will define a forwarding function DATAFLOW_TEMPLATE_BINARY_OPERATION
in the current namespace.
Including <boost/dataflow/templates/operator.hpp> with #defined
DATAFLOW_TEMPLATE_TAG,
DATAFLOW_TEMPLATE_BINARY_OPERATION,
and DATAFLOW_TEMPLATE_OPERATOR
will define a forwarding operator in the current namespace.
// the include templates expect DATAFLOW_TEMPLATE_TAG to have // the mechanism type #define DATAFLOW_TEMPLATE_TAG boost::dataflow::vtk::tag #define DATAFLOW_TEMPLATE_MECHANISM boost::dataflow::default_mechanism // the binary_operation.hpp template expects DATAFLOW_TEMPLATE_BINARY_OPERATION # define DATAFLOW_TEMPLATE_BINARY_OPERATION connect # include <boost/dataflow/templates/binary_operation.hpp> // the operator.hpp template expects DATAFLOW_TEMPLATE_OPERATOR # define DATAFLOW_TEMPLATE_OPERATOR >>= # include <boost/dataflow/templates/operator.hpp> # undef DATAFLOW_TEMPLATE_OPERATOR # undef DATAFLOW_TEMPLATE_BINARY_OPERATION # define DATAFLOW_TEMPLATE_BINARY_OPERATION connect_only # include <boost/dataflow/templates/binary_operation.hpp> # define DATAFLOW_TEMPLATE_OPERATOR ^= # include <boost/dataflow/templates/operator.hpp> # undef DATAFLOW_TEMPLATE_OPERATOR # undef DATAFLOW_TEMPLATE_BINARY_OPERATION #undef DATAFLOW_TEMPLATE_MECHANISM #undef DATAFLOW_TEMPLATE_TAG // We now have connect and connect_only functions that each take a // vtk ProducerPort and vtk ConsumerPort as arguments, and try to connect them. // We also have operators >>= for the connect operation, // and ^= for the connect_only operation.
What we can do with what we have so far
using namespace boost::dataflow; // connect *cone to *coneMapper connect(*cone->GetOutputPort(), vtk::vtk_algorithm_consumer_adapter(*coneMapper)); // make *cone the only thing connected to *coneMapper connect(*cone->GetOutputPort(), vtk::vtk_algorithm_consumer_adapter(*coneMapper));