[Insight-developers] Filter execution dispatch based on dimension.
Brad King
brad.king@kitware.com
Fri, 26 Jan 2001 17:39:34 -0500 (EST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---1463811583-366643265-980548774=:20114
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hello, all:
A general problem we've been having with this toolkit is how to setup
multiple implementations of each filter, each optimized for a particular
dimension. The attached file presents a clean solution to this problem
which has been tested on Visual C++, GCC, MIPSpro, and the Intel
compiler. See the file for a more detailed description of the problem.
After reading the solution, you will see that we can provide several
filter dispatch classes, each defining a different combination of rules
for dimension-based filter execute calls. Each filter will be able to
select which dispatch class to use, or define its own.
The use of these dispach classes is completely transparent to the user of
the filter, and requires little work by the implementer. If everyone
likes this approach, I will add the dispatch classes to Insight and check
them in.
Thoughts?
-Brad
---1463811583-366643265-980548774=:20114
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="filterDispatch.cxx"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.21.0101261739340.20114@darkstar.kitware.com>
Content-Description:
Content-Disposition: attachment; filename="filterDispatch.cxx"
LyoqDQogKiBEZW1vbnN0cmF0aW9uIG9mIGZpbHRlciBkaXNwYXRjaGluZy4g
IFRoZSBnZW5lcmFsIHByb2JsZW0gaXMgdG8gcHJvdmlkZQ0KICogZmlsdGVy
cyB3aXRoIHNwZWNpYWxpemVkIGltcGxlbWVudGF0aW9ucyBmb3IgZWFjaCBk
aW1lbnNpb24sIGJ1dCBpbg0KICogb25seSBvbmUgY2xhc3MsIGFuZCB3aXRo
b3V0IHBhcnRpYWwgc3BlY2lhbGl6YXRpb24uICBDb25zaWRlciBhIGZpbHRl
cg0KICogd2l0aCBtZXRob2RzIEV4ZWN1dGVOZCgpLCBFeGVjdXRlM2QoKSwg
YW5kIEV4ZWN1dGUyZCgpIHdoaWNoIHdlIHdvdWxkDQogKiBsaWtlIHRvIGRp
c3BhdGNoIGZ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