FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
HyperslabParameters.hpp
1
2//
3// $Id: HyperslabParameters.hpp,v 1.3 2007/10/08 22:22:08 werner Exp $
4//
6#ifndef __vector_HyperslabParameters_HPP
7#define __vector_HyperslabParameters_HPP "Created 24.08.2006 11:48:12 by werner"
8
9#include "Index.hpp"
10#include <typeinfo>
11
12namespace Fiber
13{
14
34{
35protected:
38 index_t stride;
39 index_t offset;
40 index_t shift;
41 // how many elements at the end are not allowed to be iterable
42 index_t cropped;
43
44public:
47 : length(Length)
48 , stride(Stride)
49 , offset(Offset)
50 , shift(0)
51 , cropped(0)
52 {}
53
56 : length(H.length)
57 , stride(H.stride)
58 , offset(H.offset)
59 , shift(H.shift)
60 , cropped(H.cropped)
61 {}
62
66 : length(H.length)
67 , stride(H.stride)
68 , offset(H.offset)
69 , shift (H.shift+i)
70 , cropped(H.cropped)
71 {}
72
77 {
78 return length;
79 }
80
81 index_t getOffset() const throw()
82 {
83 return offset;
84 }
85
86 index_t getStride() const throw()
87 {
88 return stride;
89 }
90
91 index_t getShift() const throw()
92 {
93 return shift;
94 }
95
96 index_t getCropped() const throw()
97 {
98 return cropped;
99 }
100
109 {
110 return stride == 1;
111 }
112
117 {
118 if (stride==1)
119 {
120 assert(offset>0);
121 return length / offset;
122 }
123 else
124 return stride;
125 }
126
131 {
132 if (stride==1)
133 {
134 return offset - shift;
135 }
136 else
137 {
138 assert(stride>0);
139 return length / stride - shift;
140 }
141 }
142
148 {
149 return maxcount() - cropped;
150 }
151
156 void setCount(index_t size) throw()
157 {
158 if( maxcount() < size )
159 {
160 cropped = 0;
161 return;
162 }
163
164 cropped = maxcount() - size;
165 }
166
176 index_t getIndex(index_t i, int c) const throw()
177 {
178 return (shift + i)*stride + c*offset;
179 }
180
181
182 // MSVC GCC SGI C++
183#if defined(_IOSTREAM_) || defined(_GLIBCXX_OSTREAM) || defined(_CPP_IOSTREAM) || defined(__SGI_STL_IOSTREAM) || defined(__clang__)
184#define ITERATOR_OSTREAM
185 friend std::ostream&operator<<(std::ostream&os, const HyperslabParameters&It)
186 {
187 os << "{shift=" << It.shift << ", stride=" << It.stride << ", offset=" << It.offset
188 << ", length=" << It.length << ", cropped=" << It.cropped
189 << "} => count=" << It.count() << ", multiplicity=" << It.multiplicity() << "\n"
190 ;
191 return os;
192 }
193#endif
194
195 HyperslabParameters&getHyperslabParameters() throw()
196 {
197 return *this;
198 }
199
200 const HyperslabParameters&getHyperslabParameters() const throw()
201 {
202 return *this;
203 }
204};
205
206
207} /* namespace Fiber */
208
209#endif /* __vector_HyperslabParameters_HPP */
basic_ostream< char > ostream
valarray< size_t > stride() const
valarray< size_t > size() const
valarray< _Tp > shift(int __n) const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A set of integer values which describes how to iterate over a certain set of values.
Definition HyperslabParameters.hpp:34
index_t multiplicity() const
Return number of elements which form an entity.
Definition HyperslabParameters.hpp:116
index_t getIndex(index_t i, int c) const
Given a major and a minor index, compute the overall index in the dataset according to.
Definition HyperslabParameters.hpp:176
bool isSeparatedCompound() const
Tell if the iterator refers to a data set which is built from arrays of structure members,...
Definition HyperslabParameters.hpp:108
index_t getLength() const
Return the number of elements which can be accessed through this ElementIterator.
Definition HyperslabParameters.hpp:76
index_t length
The length (number of elements) of the data array.
Definition HyperslabParameters.hpp:37
HyperslabParameters(index_t Length, index_t Stride, index_t Offset)
Simple constructorm sets shift and cropped members to zero.
Definition HyperslabParameters.hpp:46
HyperslabParameters(index_t i, const HyperslabParameters &H)
Pointer addition constructor (sets the shift member).
Definition HyperslabParameters.hpp:65
void setCount(index_t size)
Set the maximally allowed count, i.e.
Definition HyperslabParameters.hpp:156
index_t count() const
Return the number of steps which can be traversed through this ElementIterator.
Definition HyperslabParameters.hpp:147
HyperslabParameters(const HyperslabParameters &H)
Copy constructor.
Definition HyperslabParameters.hpp:55
index_t maxcount() const
Return the number of steps which can be traversed through this ElementIterator.
Definition HyperslabParameters.hpp:130
Anemone_Context_t operator<<(Anemone &A, VRenderContext &VC)
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