FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
GridSelector.hpp
1#ifndef __FIBER_GRIDSELECTOR_HPP
2#define __FIBER_GRIDSELECTOR_HPP
3
4#include "BundleAPI.h"
5#include "Bundle.hpp"
6
7namespace Fiber
8{
9
10class BundleProperty;
11class BUNDLE_API GridSelector;
12
13extern BUNDLE_API bool hasProperty(const GridSelector&, const BundleProperty&);
14
15
26{
27public:
34
37
39 const string&getGridname() const { return theGridname; }
40 const string&getGridName() const { return theGridname; }
41
43 GridSelector();
44
46 GridSelector(const string&gridname, const Fiber::BundlePtr&Source = Fiber::BundlePtr(NullPtr() ) )
47 : theSourceBundle(Source)
48 , theGridname(gridname)
49 {}
50
52 GridSelector(const Fiber::BundlePtr&Source, const string&gridname)
53 : theSourceBundle(Source)
54 , theGridname(gridname)
55 {}
56
58 GridSelector(const GridSelector&Source, const string&gridname)
59 : theSourceBundle(Source.theSourceBundle)
60 , theGridname(gridname)
61 {}
62
64 GridSelector(const string&gridname, const GridSelector&Source)
65 : theSourceBundle(Source.theSourceBundle)
66 , theGridname(gridname)
67 {}
68
71
84 GridSelector operator[](const string&gridname) const
85 {
86 return GridSelector(*this,gridname);
87 }
88
90 friend bool operator==(const GridSelector&L, const GridSelector&R)
91 {
92 return L.theSourceBundle == R.theSourceBundle &&
93 L.theGridname == R.theGridname;
94 }
95
97 friend bool operator!=(const GridSelector&L, const GridSelector&R)
98 {
99 return !(L==R);
100 }
101
103 const string&Gridname() const
104 {
105 return theGridname;
106 }
107
110 {
111 return theSourceBundle;
112 }
113
116 {
117 return theSourceBundle;
118 }
119
120
122 bool hasValidGrid() const
123 {
124 return theSourceBundle && theGridname.length()>0;
125 }
126
128 operator bool() const
129 {
130 return hasValidGrid();
131 }
132
134 bool selectGrid(const string&name)
135 {
136 theGridname = name;
137 return true;
138
139 /*
140 if (!theSpacetime)
141 return false;
142
143 theGridID = (*theSpacetime)[ name ];
144 return theGridID.valid();
145 */
146 }
147
154 {
155 if (!theSpacetime)
156 return Info<Grid>();
157
158 return theSpacetime->findMostRecentGrid(time, theGridname);
159 }
160
166 {
167 if (!theSpacetime)
168 {
169 if (!theSourceBundle)
170 return Info<Grid>();
171 else
172 return theSourceBundle->findMostRecentGrid(time, theGridname);
173 }
174
175 return theSpacetime->findMostRecentGrid(time, theGridname);
176 }
177
189 Info<Skeleton> getRefinementLevel(double time,
190 int Level, int IndexDepth,
191 const BundlePtr&SpaceTime = BundlePtr(NullPtr() ) );
192
197 {
198 if (!theSpacetime)
199 {
200 if (!theSourceBundle)
201 return Info<Grid>();
202 else
203 theSourceBundle->findPrev(time, theGridname);
204 }
205
206 return theSpacetime->findPrev(time, theGridname);
207 }
208
213 {
214 if (!theSpacetime)
215 {
216 if (!theSourceBundle)
217 return Info<Grid>();
218 else
219 theSourceBundle->findNext(time, theGridname);
220 }
221
222 return theSpacetime->findNext(time, theGridname);
223 }
224
225 Fiber::Grid&operator[](double time)
226 {
227 return theSourceBundle[time][ Gridname() ];
228 }
229
237 {
238 Fiber::Bundle::GridInfo_t G = findMostRecentGrid(time, theSpacetime);
239 return G.getGrid();
240 }
241
242 RefPtr<Fiber::Grid> operator()(double time, const GridSelector&GS)
243 {
244 Fiber::Bundle::GridInfo_t G = findMostRecentGrid(time, GS.theSourceBundle);
245 return G.getGrid();
246 }
247
252 {
253 return ::Fiber::hasProperty(*this, theProperty);
254 }
255
256
268 bool providesFieldTypes(const Fiber::TypeList_t&AcceptedFields) const;
269};
270
271
272} /* namespace Fiber */
273
274#endif /* __FIBER_GRIDSELECTOR_HPP */
275
Convenient abstract base class for inspecting and evaluating properties of Bundles.
Definition BundleProperty.hpp:21
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
friend bool operator!=(const GridSelector &L, const GridSelector &R)
Check if two Grid selectors differ.
Definition GridSelector.hpp:97
const string & Gridname() const
Return the name of the currently selected Grid.
Definition GridSelector.hpp:103
bool hasValidGrid() const
check for validity, bundle pointer must be valid and grid name.
Definition GridSelector.hpp:122
Info< Grid > findMostRecentGrid(const Fiber::BundlePtr &theSpacetime, double time) const
Return the time, slice and grid that is most recent to the given time for the selected grid.
Definition GridSelector.hpp:153
string theGridname
Name of the selected grid.
Definition GridSelector.hpp:36
GridSelector operator[](const string &gridname) const
Operator syntax for constructing a new GridSelector from an existing one and a new gridname.
Definition GridSelector.hpp:84
BundlePtr theSourceBundle
The bundle that was used to retrieve the grid name, meaning: the selected grid name is ensured to exi...
Definition GridSelector.hpp:33
Info< Grid > findMostRecentGrid(double time, const Fiber::BundlePtr &theSpacetime=Fiber::BundlePtr(NullPtr())) const
Find the Grid that is most recent for the given time.
Definition GridSelector.hpp:164
const Fiber::BundlePtr & getBundle() const
Provide the original bundle of from where the Grid was selected.
Definition GridSelector.hpp:115
const Fiber::BundlePtr & BundleSource() const
Provide the original bundle of from where the Grid was selected.
Definition GridSelector.hpp:109
Info< Grid > findNext(double time, const BundlePtr &theSpacetime=BundlePtr(NullPtr())) const
Return the Grid that is just next after the given time.
Definition GridSelector.hpp:212
friend bool operator==(const GridSelector &L, const GridSelector &R)
Compare two Grid selectors.
Definition GridSelector.hpp:90
bool selectGrid(const string &name)
Select a certain grid out of the given spacetime.
Definition GridSelector.hpp:134
GridSelector(const string &gridname, const Fiber::BundlePtr &Source=Fiber::BundlePtr(NullPtr()))
Construct from gridname and bundle.
Definition GridSelector.hpp:46
const string & getGridname() const
Name of the selected grid (member function)
Definition GridSelector.hpp:39
GridSelector(const string &gridname, const GridSelector &Source)
Construct from GridSelector and gridname.
Definition GridSelector.hpp:64
Info< Grid > findPrev(double time, const BundlePtr &theSpacetime=BundlePtr(NullPtr())) const
Return the Grid that is just previous to the given time.
Definition GridSelector.hpp:196
bool hasProperty(const BundleProperty &theProperty) const
Check this GridSelector for a certain property.
Definition GridSelector.hpp:251
GridSelector(const Fiber::BundlePtr &Source, const string &gridname)
Construct from bundle and gridname.
Definition GridSelector.hpp:52
RefPtr< Fiber::Grid > operator()(double time, const Fiber::BundlePtr &theSpacetime=Fiber::BundlePtr(NullPtr())) const
Convenience function to easily retrieve just the most recent Grid for a given time.
Definition GridSelector.hpp:235
GridSelector(const GridSelector &Source, const string &gridname)
Construct from GridSelector and gridname.
Definition GridSelector.hpp:58
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
T & operator[](index_t i) const
Access an element of the array, writeable.
Definition vector/Iterator.hpp:712
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr
The information as returned by a query for Grids.
Definition GridInfo.hpp:21
A set of types.
Definition FiberType.hpp:213