FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
SliceExtractor.hpp
1#ifndef __FIBEROPERATIONS_SLICEEXTRACTOR_HPP
2#define __FIBEROPERATIONS_SLICEEXTRACTOR_HPP
3
4#include "gridopDllApi.h"
5#include "RegularCoordinateSlice.hpp"
6
7#include <field/OnDemandCreator.hpp>
8
9namespace Fiber
10{
11
15template <class Converter>
17{
18 RefPtr<CreativeArrayBase> myFullDomainDataCreator;
19 index_t mySliceIndex;
20 MultiIndex<3> mySliceDims;
21 const Converter myConverter;
22
29 , myFullDomainDataCreator(theFullDomainDataCreator)
30 , mySliceIndex(theSliceIndex)
31 , mySliceDims(theSliceDims)
32 , myConverter( theConverter )
33 {}
34
35 bool canExtract() const
36 {
37 if (RefPtr<SizeInterface> SourceSize = getSize(myFullDomainDataCreator) )
38 {
40 if (SourceSize->get(SrcDims))
41 {
42 const MultiIndex<3>&DstDims = mySliceDims;
43
44 // if the source is large than the destination, we can't perform slicing
45 if (SrcDims[X] > DstDims[X] )
46 {
47 Assertion( SrcDims[X] <= DstDims[X], "if the source is large than the destination, we can't perform slicing in X" );
48 return false;
49 }
50 if (SrcDims[Y] > DstDims[Y] )
51 {
52 Assertion( SrcDims[Y] <= DstDims[Y], "if the source is large than the destination, we can't perform slicing in Y" );
53 return false;
54 }
55 }
56 }
57 return true;
58 }
59
60};
61
62
143template <class Converter, class InputType = typename Converter::input_type>
144 struct SliceExtractor;
145
146
150template <class Converter>
152{
154
155 typedef typename Converter::output_type output_type;
156
158 RefPtr<ResultArray_t> result_storage;
159
161 {}
162
163 RefPtr<ResultArray_t> result() const
164 {
165 return result_storage;
166 }
167};
168
169
173template <class Converter, class InputType>
174struct SliceExtractor : SliceExtractor<Converter, META::NIL>
175{
176 typedef typename SliceExtractor<Converter, META::NIL>::Constructor_t Constructor_t;
177
178 typedef typename Converter::output_type output_type;
179 typedef InputType input_type;
180
181 SliceExtractor(Constructor_t&Params, const WeakPtr<CreativeArrayBase>&CAB)
183 {
184 /*
185 Extract 2D data from 3D.
186 */
188 D = Params.myFullDomainDataCreator->create() )
189 {
190 const MultiArray<3, input_type>&Src = *D;
191
194
195#ifdef VERBOSE
196 puts("Performing actual Data slicing 3D --> 2D"); fflush(stdout);
197#endif
198
199 if (Params.extractDataToOriented3D(Dst, 0, Src, Params.mySliceIndex, Params.myConverter) )
200 this->result_storage = OutputArray;
201 }
202 else
203 {
204 Verbose(0) << "Unsupported data type for data extraction." << typeid(input_type).name()
205 << " --> " << typeid(output_type).name();
206 }
207 }
208};
209
210
214template <class Converter, class InputType, class NextType>
215struct SliceExtractor<Converter, META::LIST<InputType, NextType> > : SliceExtractor<Converter, NextType>
216{
217 typedef typename SliceExtractor<Converter, META::NIL>::Constructor_t Constructor_t;
218
219 typedef typename Converter::output_type output_type;
220 typedef InputType input_type;
221
222 SliceExtractor(Constructor_t&Params, const WeakPtr<CreativeArrayBase>&CAB)
224 {
225 assert( Params.myFullDomainDataCreator );
226 if (!Params.myFullDomainDataCreator ) return;
227
228 /*
229 Extract 2D data from 3D.
230 */
232 S = Params.myFullDomainDataCreator->create() )
233 {
234 const MultiArray<3, input_type>&Src = *S;
237
238#ifdef VERBOSE
239 printf("SliceExtractor: 3D --> 2D src (%dx%dx%d) ==> dst (%dx%dx%d) \n",
240 int(Src.Size()[0]), int(Src.Size()[1]), int(Src.Size()[2]),
241 int(Dst.Size()[0]), int(Dst.Size()[1]), int(Dst.Size()[2]) );
242 fflush(stdout);
243#endif
244 if (Params.extractDataToOriented3D(Dst, 0, Src, Params.mySliceIndex, Params.myConverter) )
245 {
246 this->result_storage = OutputArray;
247 }
248 }
249 }
250};
251
252
253
254} // namespace Fiber
255
256#endif // __FIBEROPERATIONS_SLICEEXTRACTOR_HPP
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Helper class to select a slice from a regular grid.
Definition RegularCoordinateSlice.hpp:26
Helper class for slice constructors.
Definition SliceExtractor.hpp:17
Template class to construct an OnDemandCreator to extract a 2D slice from a 3D data array with abitra...
Definition SliceExtractor.hpp:175