1#ifndef __BASEOP_RESAMPLE_HPP
2#define __BASEOP_RESAMPLE_HPP
4#include <memcore/RefPtr.hpp>
5#include <memcore/Verbose.hpp>
7#include "gridopDllApi.h"
8#include <grid/Representation.hpp>
10#include <vector/LinearIpol.hpp>
11#include <vector/Interpolate.hpp>
12#include <vector/MultiCopy.hpp>
21template <Dims_t Dims,
typename DestType,
typename SrcType,
class Converter = PlainCopyConvert>
22MultiArray<Dims,DestType>&Resample(MultiArray<Dims,DestType>&DestData
23 ,
const MultiArray<Dims,SrcType>&SourceData
24 ,
const MultiIndex<Dims>&DestOffset = MultiIndex<Dims>()
25 ,
const MultiIndex<Dims>&SourceOffset = MultiIndex<Dims>()
26 ,
const Converter&C = Converter()
29const MultiIndex<Dims>&SrcDims = SourceData.Size();
30const MultiIndex<Dims>&DstDims = DestData.Size();
42FixedArray<double, Dims> IndexScale;
43 for(
int i=0; i<Dims; i++)
45 IndexScale[i] = SrcDims[i] / double(DstDims[i]);
48#pragma message "TODO: Check whether the index scale is an integer in all dimensions, and if so, use MultiCopy.hpp's Copy operation"
50FixedArray<double,Dims> SrcIndex;
51#pragma message "TODO: Pass Interpolation type - linear/cubic - as template argument"
52Interpolate<Dims, SrcType, LinearIpol<SrcType> > Ipol(SourceData, SrcIndex);
54 Verbose(30) <<
" Resampling over " << DstDims <<
" destination indices with scale " << IndexScale;
56 for(
auto DstIndex : DstDims)
58 for(
int i=0; i<Dims; i++)
59 SrcIndex[i] = DstIndex[i]*IndexScale[i];
61 C.copy( DestData[ DstIndex], Ipol.eval() );
70#include <field/RegularlyFragmentedField.hpp>
84 Field::CreationFailAlternative CreationMode = Field::CreationFailAlternative::Discardable;
101#pragma warning "reuse fragment ID collection!?"
106 Verbose(20) <<
"CreativeFieldResampler created empty field with regular fragmentation, using "
114 Verbose(20) <<
"CreativeFieldResampler created empty field with no predefined fragmentation";
123 InputField->iterate( *
this );
136template <
int Dims,
typename DestType,
typename SrcType = DestType,
class Converter = PlainCopyConvert>
143 Verbose(20) <<
"CreativeResampleFragmentIterator: Iterating over a source fragment of type "
144 <<
typeid(
SrcType) <<
" to be put into destination type " <<
typeid(
DestType);
149 for(
int i=0; i<Dims; i++)
155 Verbose(20) <<
"CreativeResampleFragmentIterator: Creating a destination fragment of size " <<
DestDims;
161 if (!this->OutputField->createCreator(
DestData, f,
this->CreationMode))
163 Verbose(0) <<
"CreativeResampleFragmentIterator: Could not create a Creator, which is not so good.";
169 Verbose(15) <<
"SourceData is " <<
SourceData;
171 Verbose(15) <<
"No acceptable input data type was found.";
190#include <grid/Grid.hpp>
197RefPtr<Field> ResampleRegularGrid3D(Grid&OutputGrid,
const Grid&InputGrid,
198 const string&Fieldname,
199 const FixedArray<double, 3>&IndexScale,
200 const std::string&ChartName = std::string() );
_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
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
Base class for iterators over the fragments of a field.
Definition FragmentID.hpp:249
void set(const T &Value)
Set all elements to the same value.
Definition vector/Iterator.hpp:724
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
Base class for resampling n-dimensional fields.
Definition Resample.hpp:82
Strategy: Iterate over the source grid, creating a fragments in the new Grid as specified by the resa...
Definition Resample.hpp:138
bool apply(const RefPtr< FragmentID > &f, const RefPtr< CreativeArrayBase > &SourceFragment) override
Iteration callback function.
Definition Resample.hpp:139