FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
CopyMemArray.hpp
1// $Id: CopyMemArray.hpp,v 1.4 2006/05/09 12:30:28 werner Exp $
2// $Log: CopyMemArray.hpp,v $
3// Revision 1.4 2006/05/09 12:30:28 werner
4// Adjustments and fixes for MSYS/MINGW32
5//
6// Revision 1.3 2004/09/30 11:18:40 werner
7// Bugfixes and increased functionality for generic field reading.
8//
9// Revision 1.2 2004/08/12 15:50:54 werner
10// Improvements.
11//
12// Revision 1.1 2004/07/12 13:30:44 werner
13// Outsourcing of the MemCore/VecAl interface into the Field library.
14//
15// Revision 1.4 2004/07/09 20:15:27 werner
16// Added local alignment capability when interpolating vector fields and
17// option to compute the interpolated derivative.
18//
19// Revision 1.3 2004/07/06 17:13:59 werner
20// Adjustments for GCC 3.4.0
21//
22// Revision 1.2 2004/07/06 11:56:04 werner
23// The Xerox copier is functioning now for all types and all targets.
24//
25// Revision 1.1 2004/07/04 17:24:57 werner
26// Interfacing MemCore library from VecAl and
27// template reduction to runtime interface. Uses the META library.
28//
29
30#include "MemArray.hpp"
31#include <vecal/ipol/CopyMultiArray.hpp>
32#include <vecal/ipol/ViewMultiArray.hpp>
33#include <vecal/ipol/STLMultiArray.hpp>
34
35#include <meta/LIST.hpp>
36#include <meta/NativeTypeList.hpp>
37
38
39
40#ifndef NDEBUG
41#define FAST_COMPILATION
42#endif
43
44namespace Fiber
45{
46using namespace VecAl;
47
48using namespace MemCore;
49using namespace META;
50
51
52template <class SrcMemArrayType>
54{
56
57 enum { Dims = SrcMemArrayType::Dims };
58
59 const MultiIndex<Dims> &DstOffset;
60 const RefPtr<MemArray<Dims> > &Dst;
61 const MultiIndex<Dims> &SrcOffset;
62
67 : Src(S), Dst(pDst)
68 , DstOffset(pDstOffset), SrcOffset(pSrcOffset)
69 {}
70
71 template <typename T>
72 struct exec
73 {
74 template <typename Storage>
76 {
77 static bool CouldCopy(CopyMemArraySourceTypeIterator&It)
78 {
80 {
82 Copy( D->myArray(), It.DstOffset, It.Src, It.SrcOffset);
83 return true; // copy done.
84 }
85 return false; // continue traversal
86 }
87 };
88
89 // return true if the traversal of the list
90 // should be stopped
91 static inline bool Break(CopyMemArraySourceTypeIterator&It)
92 {
93 if (DstStorage< T* >::CouldCopy(It) ) return true;
94 if (DstStorage<ViewPtr<T> >::CouldCopy(It) ) return true;
95 // if (DstStorage<vector <T> >::CouldCopy(It) ) return true;
96 if (DstStorage<vector <T*> >::CouldCopy(It) ) return true;
97
98
99 /*
100 if (RefPtr<MemArrayStorage<Dims, T, T*> > D = It.Dst)
101 {
102 Xerox<MultiArray<Dims, T, T*>, SrcMemArrayType, Dims>::
103 Copy( D->myArray(), It.DstOffset, It.Src, It.SrcOffset);
104 return true; // copy done.
105 }
106 */
107 return false; // continue traversal
108 }
109 };
110};
111
112
113
114template <int Dims>
116{
117 const RefPtr<MemArray<Dims> > &Dst;
118 const MultiIndex<Dims> &DstOffset;
119 const RefPtr<MemArray<Dims> > &Src;
120 const MultiIndex<Dims> &SrcOffset;
121
122
125 : Dst(pDst), DstOffset(pDstOffset)
126 , Src(pSrc), SrcOffset(pSrcOffset)
127 {}
128
129 template <typename T>
130 struct exec
131 {
132 template <typename Storage>
134 {
135 static bool CouldCopy(CopyMemArrayIterator&It)
136 {
137 if (RefPtr<MemArrayStorage<Dims, T, Storage> > Src = It.Src)
138 {
140
142 cm( It.Dst, It.DstOffset, Src->myArray(), It.SrcOffset );
143
145 FloatTypeList>::exec( cm );
146
147 return ok;
148 }
149 return false;
150 }
151 };
152
153 // return true if the traversal of the list
154 // should be stopped
155 static inline bool Break(CopyMemArrayIterator&It)
156 {
157 if (SrcStorage<const T* >::CouldCopy(It) ) return true;
158 if (SrcStorage< T* >::CouldCopy(It) ) return true;
159 if (SrcStorage<ViewPtr<const T> >::CouldCopy(It) ) return true;
160 if (SrcStorage<ViewPtr< T> >::CouldCopy(It) ) return true;
161 if (SrcStorage<vector < T> >::CouldCopy(It) ) return true;
162 if (SrcStorage<vector < T*> >::CouldCopy(It) ) return true;
163
164
165
166/* The above code is identical to the explicit version as here,
167 but leaving the storage type open for iteration.
168
169 if (RefPtr<MemArrayStorage<Dims, T, T*> > Src = It.Src)
170 {
171 CopyMemArraySourceTypeIterator<MultiArray<Dims, T, T*> >
172 cm( It.Dst, It.DstOffset, Src->myArray(), It.SrcOffset );
173
174 bool ok = FOREACH<CopyMemArraySourceTypeIterator<MultiArray<Dims, T, T*> >,
175 FloatTypeList>::exec( cm );
176
177 return ok;
178 }
179*/
180 return false; // continue traversal
181 }
182 };
183};
184
185
186} /* namespace VecAl */
187
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
void Copy(MultiArray< N, Dest > &DestArray, const MultiArray< N, Source > &SrcArray, const Converter &C)
Copy data from the source array to the destination array, whereby the destination array must be large...
Definition MultiCopy.hpp:46
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Definition CopyMemArray.hpp:134
Definition CopyMemArray.hpp:131
Definition CopyMemArray.hpp:116
Definition CopyMemArray.hpp:73
Definition CopyMemArray.hpp:54