FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
ArrayList.hpp
1
2//
3// $Id: ArrayList.hpp,v 1.2 2005/01/17 14:47:28 werner Exp $
4// $Log: ArrayList.hpp,v $
5// Revision 1.2 2005/01/17 14:47:28 werner
6// Improved documentation.
7//
8// Revision 1.1 2004/08/31 14:10:42 werner
9// On-demand loading array classes separated from Field class, and introduced
10// transparent multidimensional arrays with on-demand loaded slices.
11//
13
14#ifndef __FIELD_ARRAYLIST_HPP
15#define __FIELD_ARRAYLIST_HPP
16
17#include <vecal/ipol/CopyMultiArray.hpp>
18#include <vecal/ipol/ViewMultiArray.hpp>
19#include "MemArray.hpp"
20#include "CreativeArray.hpp"
21
22namespace Fiber
23{
24using namespace VecAl;
25
26
27template <class T, class S=T*>
65
66#if 0
67template <class SrcMemArrayType>
69{
71
72 enum { Dims = SrcMemArrayType::Dims };
73
74 const MultiIndex<Dims> &DstOffset;
75 const RefPtr<MemArray<Dims> > &Dst;
76 const MultiIndex<Dims> &SrcOffset;
77
78 CopyMemArraySourceTypeIterator(const RefPtr<MemArray<Dims> > &pDst,
79 const MultiIndex<Dims> &pDstOffset,
80 SrcMemArrayType&S,
81 const MultiIndex<Dims> &pSrcOffset)
82 : Src(S), Dst(pDst)
83 , DstOffset(pDstOffset), SrcOffset(pSrcOffset)
84 {}
85
86 template <typename T>
87 struct exec
88 {
89 template <typename Storage>
90 struct DstStorage
91 {
92 static bool CouldCopy(CopyMemArraySourceTypeIterator&It)
93 {
94 if (RefPtr<MemArrayStorage<Dims, T, Storage> > D = It.Dst)
95 {
96 Xerox<MultiArray<Dims, T, Storage>, SrcMemArrayType>::
97 Copy( D->myArray(), It.DstOffset, It.Src, It.SrcOffset);
98 return true; // copy done.
99 }
100 return false; // continue traversal
101 }
102 };
103
104 // return true if the traversal of the list
105 // should be stopped
106 static inline bool Break(CopyMemArraySourceTypeIterator&It)
107 {
108 if (DstStorage< T* >::CouldCopy(It) ) return true;
109 if (DstStorage<ViewPtr<T> >::CouldCopy(It) ) return true;
110 // if (DstStorage<vector <T> >::CouldCopy(It) ) return true;
111 if (DstStorage<vector <T*> >::CouldCopy(It) ) return true;
112
113
114 /*
115 if (RefPtr<MemArrayStorage<Dims, T, T*> > D = It.Dst)
116 {
117 Xerox<MultiArray<Dims, T, T*>, SrcMemArrayType, Dims>::
118 Copy( D->myArray(), It.DstOffset, It.Src, It.SrcOffset);
119 return true; // copy done.
120 }
121 */
122 return false; // continue traversal
123 }
124 };
125};
126
127
128
129template <int Dims>
130struct CopyMemArrayIterator
131{
132 const RefPtr<MemArray<Dims> > &Dst;
133 const MultiIndex<Dims> &DstOffset;
134 const RefPtr<MemArray<Dims> > &Src;
135 const MultiIndex<Dims> &SrcOffset;
136
137
138 CopyMemArrayIterator(const RefPtr<MemArray<Dims> >&pDst, const MultiIndex<Dims>&pDstOffset,
139 const RefPtr<MemArray<Dims> >&pSrc, const MultiIndex<Dims>&pSrcOffset)
140 : Dst(pDst), DstOffset(pDstOffset)
141 , Src(pSrc), SrcOffset(pSrcOffset)
142 {}
143
144 template <typename T>
145 struct exec
146 {
147 template <typename Storage>
148 struct SrcStorage
149 {
150 static bool CouldCopy(CopyMemArrayIterator&It)
151 {
152 if (RefPtr<MemArrayStorage<Dims, T, Storage> > Src = It.Src)
153 {
154 typedef MultiArray<Dims, T, Storage> SrcMultiArray_t;
155
156 CopyMemArraySourceTypeIterator<SrcMultiArray_t>
157 cm( It.Dst, It.DstOffset, Src->myArray(), It.SrcOffset );
158
159 bool ok = FOREACH<CopyMemArraySourceTypeIterator<SrcMultiArray_t>,
160 FloatTypeList>::exec( cm );
161
162 return ok;
163 }
164 return false;
165 }
166 };
167
168 // return true if the traversal of the list
169 // should be stopped
170 static inline bool Break(CopyMemArrayIterator&It)
171 {
172 if (SrcStorage<const T* >::CouldCopy(It) ) return true;
173 if (SrcStorage< T* >::CouldCopy(It) ) return true;
174 if (SrcStorage<ViewPtr<const T> >::CouldCopy(It) ) return true;
175 if (SrcStorage<ViewPtr< T> >::CouldCopy(It) ) return true;
176 if (SrcStorage<vector < T> >::CouldCopy(It) ) return true;
177 if (SrcStorage<vector < T*> >::CouldCopy(It) ) return true;
178
179
180
181/* The above code is identical to the explicit version as here,
182 but leaving the storage type open for iteration.
183
184 if (RefPtr<MemArrayStorage<Dims, T, T*> > Src = It.Src)
185 {
186 CopyMemArraySourceTypeIterator<MultiArray<Dims, T, T*> >
187 cm( It.Dst, It.DstOffset, Src->myArray(), It.SrcOffset );
188
189 bool ok = FOREACH<CopyMemArraySourceTypeIterator<MultiArray<Dims, T, T*> >,
190 FloatTypeList>::exec( cm );
191
192 return ok;
193 }
194*/
195 return false; // continue traversal
196 }
197 };
198};
199#endif
200
201} /* namespace VecAl */
202
203
204#endif // __FIELD_ARRAYLIST_HPP
Definition ArrayList.hpp:29
MultiArray< 1, T, S > M1D
A onedimensional array that is stored contiguously.
Definition ArrayList.hpp:32
MultiArray< 4, T, S > M4D
A fourdimensional array that is stored contiguously.
Definition ArrayList.hpp:53
MultiArray< 4, T, CreativeArray< 4, T, S, CreativeArray< 3, T, S, S > > > M4D_3D_2D
A fourdimensional array that is stored as contiguous 3D arrays that are build from 2D arrays created ...
Definition ArrayList.hpp:59
MultiArray< 3, T, CreativeArray< 3, T, S, CreativeArray< 2, T, S, S > > > M3D_2D_1D
A threedimensional array that is stored as contiguous 2D arrays that are build from 1D arrays created...
Definition ArrayList.hpp:49
MultiArray< 2, T, CreativeArray< 2, T, S, S > > M2D_1D
A twodimensional array that is stored as contiguous 1D arrays that are created on demand.
Definition ArrayList.hpp:39
MultiArray< 2, T, S > M2D
A twodimensional array that is stored contiguously.
Definition ArrayList.hpp:36
MultiArray< 4, T, CreativeArray< 4, T, S, CreativeArray< 3, T, S, CreativeArray< 2, T, S, S > > > > M4D_3D_2D_1D
A fourdimensional array that is stored as contiguous 3D arrays that are build from 1D arrays created ...
Definition ArrayList.hpp:62
MultiArray< 3, T, S > M3D
A threedimensional array that is stored contiguously.
Definition ArrayList.hpp:43
MultiArray< 4, T, CreativeArray< 4, T, S, S > > M4D_3D
A fourdimensional array that is stored as contiguous 3D arrays that are created on demand.
Definition ArrayList.hpp:56
MultiArray< 3, T, CreativeArray< 3, T, S, S > > M3D_2D
A threedimensional array that is stored as contiguous 2D arrays that are created on demand.
Definition ArrayList.hpp:46
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
LIST< float, LIST< double, LIST< long double > > > FloatTypeList
StrongPtr< Object, ObjectBase > RefPtr
Definition CopyMemArray.hpp:54