FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
FragmentCreator.hpp
1#ifndef __FIBER_FIELD_FRAGMENTCREATOR_HPP
2#define __FIBER_FIELD_FRAGMENTCREATOR_HPP
3
4#include "OnDemandCreator.hpp"
5#include "Field.hpp"
6
7
8namespace Fiber
9{
10
11
12template <class FragmentOperator>
13struct SingleFragmentCompute : FragmentOperator
14{
15 enum { DataDims = FragmentOperator::DataDims };
16
19
20
22
23 struct MyConstructor : FragmentOperator
24 {
25 RefPtr<CreativeArrayBase> myInputDataCreator;
26
27 MyConstructor(FragmentOperator&Op,
30 : FragmentOperator(Op)
31 , myInputDataCreator( theInputDataCreator )
32 {
33 Op.setupFragment(fid);
34 }
35 };
36
37
39
40 RefPtr<ResultArray_t> result_storage;
41
43 {
44 RefPtr<MemArray<DataDims, InputType> > InputData = C.myInputDataCreator->create();
45
47 result = new ResultArray_t(InputData->Size() );
48
49 if (C.compute(*result, *InputData))
50 result_storage = result;
51 }
52
53 RefPtr<ResultArray_t> result() const
54 {
55 return result_storage;
56 }
57};
58
59
60
61template <class FragmentOperator>
62void SetupNewFragmentCreators(const RefPtr<Field>&Output, const RefPtr<Field>&Input, FragmentOperator&Op)
63{
64 struct It : Field::Iterator, FragmentOperator
65 {
66 RefPtr<Field> Output;
67
68 typedef SingleFragmentCompute<FragmentOperator> MyCompute;
69
70 It(FragmentOperator&Op)
71 :FragmentOperator(Op)
72 {}
73
74 bool apply(const RefPtr<FragmentID>&fid, const RefPtr<CreativeArrayBase>&CAB) override
75 {
76 RefPtr<CreativeArrayBase>
77 NewFragment = new OnDemandCreator<MyCompute>( typename MyCompute::MyConstructor(*this,fid,CAB), MemCore::Cache::MemCache() );
78
79 Output->setCreator(NewFragment, fid);
80 return true;
81 }
82
83 }
84 Fit (Op);
85
86 Fit.Output = Output;
87 Input->iterate(Fit);
88
89}
90
91
92} // namespace
93
94
95#endif
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply(_Tp __func(_Tp)) const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
static RefPtr< Cache, CacheBase > & MemCache()
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Definition FragmentCreator.hpp:24
Definition FragmentCreator.hpp:14