FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Grid.hpp
1#ifndef __FIBER_GRID_HPP
2#define __FIBER_GRID_HPP "Created 27.02.2001 21:42:27 by werner"
3
4#include "GridAPI.h"
5#include <fiber/field/Field.hpp>
6#include <memcore/TypeInfo.hpp>
7
8#include <unordered_set>
9
10#include "FieldID.hpp"
11#include "FiberSpace.hpp"
12#include "Transformation.hpp"
13#include "Representation.hpp"
14#include "Chart.hpp"
15#include "Skeleton.hpp"
16#include "GridContainer.hpp"
17#include "SkeletonMap.hpp"
18
19namespace Fiber
20{
21 using MemCore::WeakPtr;
22 using MemCore::NullPtr;
23 using std::set;
24 using std::list;
25
26
33class GRID_API Timestep : public Interface<Timestep>
34{
35public:
37};
38
39
41
42
57 , public Ownable<Grid>
58 , public Intercube
59 , public SaveableAttributes
60{
61 WeakPtr<GridContainer> myContainer;
62 RefPtr<Atlas> myAtlas;
63
65 Grid(const Grid&) = delete;
66
68 void operator=(const Grid&) = delete;
69
70 Grid() = delete;
71
72public:
74
75
84
86
88 ~Grid();
89
91 const RefPtr<Atlas>&MyAtlas() const
92 {
93 return myAtlas;
94 }
95
106 const Atlas::Atlas_t&getCharts() const;
107
111 Atlas::Atlas_t getCharts(const type_info&ChartType) const;
112
117 Atlas::Atlas_t getCartesianCharts3D() const;
118
123 const RefPtr<Chart> getUniqueCartesianChart3D() const;
124
125 string getUniqueCartesianChart3DName() const;
126
127static string getChartName(const type_info&ChartType, const string&name);
128
130 RefPtr<Chart> findChart(const RefPtr<ChartID>&id) const;
131
135 RefPtr<Chart> findChart(const type_info&ChartType, const string&name = string()) const;
136
142 RefPtr<Chart> makeChart(const type_info&ChartType, const string&name = {}, uint16_t epsg_code = 0);
143
145 RefPtr<Chart> findChart(uint16_t epsg_code) const;
146 RefPtr<ChartID> findChartID(uint16_t epsg_code) const;
147
149 bool insertSharedChart(const RefPtr<Chart>&ExistingChart)
150 {
151 Assert( myAtlas );
152 return myAtlas->insertSharedChart(ExistingChart);
153 }
154
162 RefPtr<Chart> makeCartesianChart(const string&name = {}, uint16_t epsg_code = 0);
163
165 RefPtr<Chart> findCartesianChart(const string&name = {}) const;
166
169 RefPtr<Representation> getCartesianRepresentation(const Skeleton&Skel, const string&ChartName = {} ) const;
170
173 RefPtr<Representation> getCartesianRepresentation(const string&ChartName = {} ) const;
174
179 {
180 return getCartesianRepresentation();
181 }
182
183
186 RefPtr<Representation> getTimePolar2DRepresentation(const Skeleton&Skel) const;
187
188 RefPtr<Representation> getTimePolar2DRepresentation() const
189 {
190 RefPtr<Skeleton> S = findVertices();
191 if (!S)
192 {
193 puts("Grid::getTimePolar2DRepresentation(): no Vertex Skeleton found!");fflush(stdout);
194 return NullPtr();
195 }
196 return getTimePolar2DRepresentation(*S);
197 }
198
199
204 Representation&makeCartesianRepresentation(int Dims, const string&name = {}, uint16_t epsg_code = 0);
205
213 {
214 return makeCartesianRepresentation(Dims);
215 }
216
222 RefPtr<Field> operator()(const string&fieldname, const string&ChartName = string() ) const;
223 RefPtr<Field> operator()(const string&fieldname, const RefPtr<Chart>&theChart) const;
224
231 FieldProxy operator[](const string&fieldname);
232
237 RefPtr<Field> CartesianPositions() const;
238
239 RefPtr<Field> TimePolar2DPositions() const;
240
247 {
248 return CartesianPositions();
249 }
250
253 const string&ChartName = {}, uint16_t epsg_code = 0)
254 {
255 if (!Coordinates) return;
256 auto D = Coordinates->getSize();
257 Representation&R = makeCartesianRepresentation(D.dimensionality(), ChartName, epsg_code);
259 }
260
262 Representation&
264 const string&ChartName = {}, uint16_t epsg_code = 0)
265 {
266 auto D = Coordinates.getSize();
267 Representation&R = makeCartesianRepresentation(D.dimensionality(), ChartName, epsg_code);
268 R.setPositions(Coordinates.self() );
269 return R;
270 }
271
272 using SkeletonMap::operator[];
273 using SkeletonMap::operator();
274
279
290 template <class SkeletonFunctor>
292 {
293 return this->SkeletonMap::iterate(F);
294 }
296
311 using SkeletonMap::iterate_all;
312
319 const string&fieldname, const RefPtr<Skeleton>&theSkeleton) const;
320
321 RefPtr<Field> getField(const RefPtr<Chart>&theChart,
322 const string&fieldname, const RefPtr<Skeleton>&theSkeleton) const
323 {
324 if (!theChart) return nullptr;
325 return getField(theChart->ID(), fieldname, theSkeleton);
326 }
327
333 const string&fieldname) const
334 {
335 return getField(theChartID, fieldname, findVertices() );
336 }
337
338 RefPtr<Field> getField(const RefPtr<Chart>&theChart,
339 const string&fieldname) const
340 {
341 if (!theChart) return nullptr;
342 return getField(theChart->ID(), fieldname, findVertices() );
343 }
344
350 RefPtr<Field> getPositions(const RefPtr<ChartID>&theChartID,
351 const RefPtr<Skeleton>&theSkeleton) const;
352
353
354 RefPtr<Field> getPositions(const string&ChartName = {} ) const
355 {
356 RefPtr<Representation> R = getCartesianRepresentation(ChartName);
357 if (R)
358 return R->getPositions();
359
360 return nullptr;
361 }
362
368 RefPtr<Field> getVertexPositions(const RefPtr<ChartID>&theChartID) const;
369
370
376 RefPtr<Representation> getRepresentation(const RefPtr<ChartID>&theChartID,
377 const RefPtr<Skeleton>&theSkeleton) const;
378
379
384static RefPtr<Representation> getRepresentation(const RefPtr<Chart>&theChart,
385 const RefPtr<Skeleton>&theSkeleton);
386
391 RefPtr<Representation> getRepresentation(const RefPtr<Chart>&theChart,
392 const SkeletonID&theSkeletonID) const;
393
394 RefPtr<Representation> getRepresentation(const RefPtr<ChartID>&theChartID,
395 const SkeletonID&theSkeletonID) const;
396
405 {
406 return getRepresentation(theChartID, findVertices() );
407 }
408
410
418 RefPtr<Skeleton> findHighestHomogenousRefinement(int MaxLevel, int IndexDepth, int Dimensionality) const;
419
426 RefPtr<Skeleton> findHighestHomogenousVertexRefinement(int MaxLevel) const;
427
428
435 template <is_field_identifier... FieldIdentifiers>
436 std::array<RefPtr<Field>, sizeof...(FieldIdentifiers)>
437 getVertexFields(const RefPtr<Chart> &chart,
439 {
440 if (!chart) return {};
441
442 if (RefPtr<Skeleton> S = findVertices() )
443 return S->getFields( chart, theFieldIdentifiers...);
444
445 return {};
446 }
447
449 template <is_field_identifier... FieldIdentifiers>
450 auto getVertexFields(uint16_t epsg_code,
451 FieldIdentifiers... theFieldIdentifiers) const
452 {
453 RefPtr<Chart> chart = findChart(epsg_code);
454 return getVertexfields( chart, theFieldIdentifiers...);
455 }
456
458 template <is_field_identifier... FieldIdentifiers>
459 auto getVertexFields(const type_info&ChartType, const string&ChartName,
460 FieldIdentifiers... theFieldIdentifiers) const
461 {
462 RefPtr<Chart> chart = findChart(ChartType, ChartName);
463 return getVertexFields( chart, theFieldIdentifiers...);
464 }
465
467 template <is_field_identifier... FieldIdentifiers>
468 auto getCartesianVertexFields(const string&ChartName,
469 FieldIdentifiers... theFieldIdentifiers) const
470 {
471 RefPtr<Chart> chart = findCartesianChart(ChartName);
472 return getVertexFields( chart, theFieldIdentifiers...);
473 }
474
475
476
477
479 template <is_field_identifier... FieldIdentifiers>
480 auto getVertexFieldCreators(const RefPtr<FragmentID>&fID, const RefPtr<Chart> &chart,
481 FieldIdentifiers... theFieldIdentifiers) const
482 {
483 const auto&F = getVertexFields(chart, theFieldIdentifiers...);
484 return getCreators(F, fID);
485 }
486
487
489 template <is_field_identifier... FieldIdentifiers>
490 auto getVertexFieldCreators(const RefPtr<FragmentID>&fID, uint16_t epsg_code,
491 FieldIdentifiers... theFieldIdentifiers) const
492 {
493 const auto&F = getVertexFields(epsg_code, theFieldIdentifiers...);
494 return getCreators(F, fID);
495 }
496
498 template <is_field_identifier... FieldIdentifiers>
499 auto getVertexFieldCreators(const RefPtr<FragmentID>&fID, const type_info&ChartType, const string&ChartName,
500 FieldIdentifiers... theFieldIdentifiers) const
501 {
502 const auto&F = getVertexFields(ChartType, ChartName, theFieldIdentifiers...);
503 return getCreators(F, fID);
504 }
505
507 template <is_field_identifier... FieldIdentifiers>
508 auto getCartesianVertexFieldCreators(const RefPtr<FragmentID>&fID, const string&ChartName,
509 FieldIdentifiers... theFieldIdentifiers) const
510 {
511 const auto&F = getCartesianVertexFields(ChartName, theFieldIdentifiers...);
512 return getCreators(F, fID);
513 }
514
515
516
517
518
519
520
521#if 0
527 RefPtr<Chart> getGlobalChart(const type_info&t, const string&id) const;
528
534 RefPtr<Chart> getGlobalChart(const vector<char*>&component_names,
535 const type_info&element_type,
536 const string&id) const;
537
538#endif
539
540 string xml() const;
541
547 [[deprecated("Avoid using this slow function.")]]
548 RefPtr<Skeleton> findSkeleton(const RefPtr<FragmentID>&fID);
549
550
551
562 template <class index_type>
564
570 using metafilter = FragmentMetaIndirector::MetaInfoProvider_t;
571
575 template <class index_type>
577 {
578 filter<index_type> dataFilter = {};
579 metafilter metaFilter = {};
580 };
581
582
588 template <class index_type>
589 using SkeletonFilter = std::function<FragmentFilter<index_type>(Skeleton&SourceVertices, const Representer&theRepresenter, const Representation&R)>;
590
596
601 void establishVertexFilter(const Grid&SourceGrid, SkeletonFilter<uint32_t> SF);
602};
603
604
605template <>
607{
608};
609
610template <>
612{
613};
614
615
616} /* namespace Fiber */
617
618#endif /* __FIBER_GRID_HPP */
constexpr complex< _Tp > & operator=(const _Tp &)
Base class for multidimensional arrays that employ deferred storage, i.e.
Definition CreativeArrayBase.hpp:75
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
const RefPtr< Atlas > & MyAtlas() const
Return the Atlas of this Grid.
Definition Grid.hpp:91
int iterate_skeletons(const SkeletonFunctor &F) const
Definition Grid.hpp:291
Representation & operator[](int Dims)
Shortcut operator function: Create a vertex representation of this Grid with the given dimensionality...
Definition Grid.hpp:212
FragmentMetaIndirector::MetaInfoProvider_t metafilter
A callback function that will be called once a source fragment has been processed such that meta-data...
Definition Grid.hpp:570
SkeletonIterator Iterator
Associated Iterator class.
Definition Grid.hpp:278
RefPtr< Representation > getVertexRepresentation(const RefPtr< ChartID > &theChartID) const
Get the representation of this Grid's vertices in the specified Chart.
Definition Grid.hpp:404
RefPtr< Field > getField(const RefPtr< ChartID > &theChartID, const string &fieldname) const
Get a field of the Grid's vertices in the given Chart.
Definition Grid.hpp:332
Representation & setCartesianPositions(const MemBase &Coordinates, const string &ChartName={}, uint16_t epsg_code=0)
Convenience function to create a cartesian representation directly from a set of coordinates.
Definition Grid.hpp:263
void setCartesianPositions(const MemCore::RefPtr< MemBase > &Coordinates, const string &ChartName={}, uint16_t epsg_code=0)
Convenience function to easily set cartesian coordinates directly from data as unfragmented field.
Definition Grid.hpp:252
std::function< FragmentFilter< index_type >(Skeleton &SourceVertices, const Representer &theRepresenter, const Representation &R)> SkeletonFilter
A function invoked per skeleton to provide a filter function, given a certain Representation and Repr...
Definition Grid.hpp:589
RefPtr< Field > getCartesianPositions() const
Shortcut function: get the coordinates of the vertices in the default cartesian chart.
Definition Grid.hpp:246
std::function< bool(Chunk< index_type > &indirection, const RefPtr< FragmentID > &fid, CreativeArrayBase &CAB)> filter
A filter function provided by a SkeletonFilter that fills the given indirection array based for the g...
Definition Grid.hpp:563
RefPtr< Representation > operator()() const
Shortcut for getCartesianRepresentation().
Definition Grid.hpp:178
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
T & operator[](index_t i) const
Access an element of the array, writeable.
Definition vector/Iterator.hpp:712
Base class for multidimensional arrays with MemCore memory management.
Definition MemBase.hpp:70
Domain-specific class of objects that can be owned.
Definition Ownable.hpp:81
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
bool setPositions(const RefPtr< Field > &P)
Set the positional component of this Representation object.
Definition Representation.cpp:519
Attributes with an age that allows to keep track when the attributes had been saved last.
Definition CreativeArrayBase.hpp:32
Identifier for Skeletons within a Grid.
Definition SkeletonID.hpp:24
Base class for iterators over a sequence of skeletons.
Definition SkeletonMap.hpp:38
A Skeleton Map is a unique map from SkeletonID's to Skeletons.
Definition SkeletonMap.hpp:74
RefPtr< Skeleton > findMaxHomogenousRefinement(int IndexDepth) const
Find the skeleton with the maximal homogenous refinement level.
Definition SkeletonMap.cpp:142
int iterate(ConstSkeletonIterator &) const
Iterate over all skeletons of this Grid.
Definition SkeletonMap.cpp:48
A Skeleton is a set of Representation object, each of them accessed by an Representer object.
Definition Skeleton.hpp:102
Interface class that allows optionally storing integer numbers with a grid as a consecutive timestep ...
Definition Grid.hpp:34
long timestep
The integer timestep number for consecutive grids.
Definition Grid.hpp:36
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr
A proxy object that looks like a RefPtr<Field> but equips fields with a FieldCreator and a FragmentID...
Definition Representation.hpp:37
Filter callback functions per fragment.
Definition Grid.hpp:577