FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Skeleton.hpp
1#ifndef __FIBER_GRID_SKELETON_HPP
2#define __FIBER_GRID_SKELETON_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#include <unordered_set>
8
9#include "FieldID.hpp"
10#include <fiber/field/BaseSpace.hpp>
11#include "FiberSpace.hpp"
12#include "Representation.hpp"
13#include "Chart.hpp"
14#include "Atlas.hpp"
15#include "SkeletonID.hpp"
16
17namespace Fiber
18{
19 using MemCore::WeakPtr;
20
21class GRID_API FieldRef;
22class GRID_API SkeletonMap;
23
31struct FragmentMetaIndirector : Interface<FragmentMetaIndirector>
32{
33 using MetaInfoProvider_t = std::function<bool(CreativeArrayBase&targetCAB,
37 const string&FieldName,
38 const Representer&WantRep)>;
39
40 MetaInfoProvider_t provideMetaInfo = {};
41
42 FragmentMetaIndirector(MetaInfoProvider_t theMetaInfo)
43 : provideMetaInfo( std::move( theMetaInfo) )
44 {}
45};
46
47template <size_t NumberOfFields>
48inline auto getCreators(const std::array<RefPtr<Field>, NumberOfFields>&Fields, const RefPtr<FragmentID>&fID)
49{
51
52 for(size_t fieldNo = 0; fieldNo < NumberOfFields; fieldNo++)
53 {
54 if (auto F = Fields[fieldNo])
55 Creators[ fieldNo ] = F -> getCreator(fID);
56 }
57
58 return Creators;
59}
60
61
62
100 , public Fiber::SkeletonID
101 , public SaveableAttributes
102{
104 Skeleton (const SkeletonID&SID);
105
106 friend class SkeletonMap;
107
108protected:
110
112 ~Skeleton();
113
114 RefPtr<Field> getFieldRecursion(const Representer&R, const string&FieldName
115 , const RefPtr<Atlas>&myAtlas
117
118
119
120template <is_field_identifier firstFieldIdentifier_t, is_field_identifier... FieldIdentifiers>
121 void getFieldsRecursion(const Representer&R,
125 {
126 *Rit = getField(R, firstFieldIdentifier);
127
128 if constexpr (sizeof...(FieldIdentifiers) > 0)
129 {
130 Rit++;
131 this->getFieldsRecursion(R, Rit, theFieldIdentifiers...);
132 }
133 }
134
135
136public:
137
139 Skeleton() = delete;
140
142 Skeleton(const Skeleton&) = delete;
143
145 void operator=(const Skeleton&) = delete;
146
147 void clear();
148
149 void extremeUnction() override;
150
151 using RepresentationMap::operator();
155
157
158 using FieldIterator_t = Representation::const_iterator_t;
159
161 RefPtr<Representation> makeRepresentation(const Representer&D);
162
164 {
165 const Representer&R = D.self();
166 return (*this)[R];
167 }
168
169
173 int Dims() const override;
174
179 RefPtr<Field> createIndirectedField(const Representer&WantRep, const RefPtr<Field>&RelativeIndices,
180 const string&FieldName, const RefPtr<Field>&SourceField,
181 const RefPtr<Field>&SourcePositions);
182
193 RefPtr<Field> getField(const Representer&R, const RefPtr<FieldID>&Fid
194 , const RefPtr<Atlas>&myAtlas = nullptr
195 , const RepresenterList_t&SkipRepresenters = {} );
196
210 RefPtr<Field> getField(const Representer&R, const std::string&FieldName
211 , const RefPtr<Atlas>&myAtlas = nullptr
212 , const RepresenterList_t&SkipRepresenters = {});
213
219 {
220 return getField(R, FIBER_POSITIONS);
221 }
222
223 std::string xml() const override;
224
225 friend std::string to_string(const Skeleton&);
226
227 std::string Name() const override
228 {
229 return SkeletonID::Name();
230 }
231
238
239 unsigned iterate_fields(const FieldIterator_t&F, SkeletonExcluder&SE) const;
240
246 unsigned iterate_fields(const FieldIterator_t&F) const
247 {
249 return iterate_fields(F, SE);
250 }
251
252
253 using RepresentationFieldIterator_t = std::function<bool(const Representer&theRepresenter, const Representation&R, const FieldID&, const Field&)>;
254
255 unsigned iterate_fields(const RepresentationFieldIterator_t&F, SkeletonExcluder&SE) const;
256
261 unsigned iterate_fields(const RepresentationFieldIterator_t&F) const
262 {
264 return iterate_fields(F, SE);
265 }
266
267
279 template <is_field_identifier... FieldIdentifiers>
280 auto getFields(const Representer&R,
282 {
283 std::array<RefPtr<Field>, sizeof...(FieldIdentifiers)> ResultFields;
284 getFieldsRecursion(R, ResultFields.begin(), theFieldIdentifiers...);
285 return ResultFields;
286 }
287
288
302 template <is_field_identifier... FieldIdentifiers>
305 {
306 const auto&F = getFields( R, theFieldIdentifiers...);
307 return getCreators(F, fID);
308 }
309};
310
311using Topology = Skeleton;
312
315
318
319
325{
326 RefPtr<Skeleton> SkelPtr;
328 RefPtr<Atlas> myGridAtlas;
329 string fieldname;
330
331public:
333 : SkelPtr(S), Id(fid), myGridAtlas(GA)
334 {}
335
336 FieldRef(const RefPtr<Skeleton>&S, const string&fname, const RefPtr<Atlas>&GA)
337 : SkelPtr(S), myGridAtlas(GA), fieldname(fname)
338 {}
339
340 ~FieldRef();
341
342/*
343 template <class CoordinateSystem, class TensorType>
344 void operator=(const Tensor<CoordinateSystem, TensorType>&Value)
345 {
346 typedef Tensor<CoordinateSystem, TensorType> value_type;
347 typedef MemArrayStorage<1, value_type, vector<value_type> > array_type;
348
349 array_type*Data = new array_type(1);
350 Data->myArray()[0] = Value;
351
352 RefPtr<Field> myField = new Field();
353 myField->setCreator( new MemCreativeArray(Data) );
354
355// RefPtr<Chart> C = CreateChart<CoordinateSystem>::global( (*myGridAtlas) );
356// Representation&Rep = (*SkelPtr)[C];
357
358 Representation&Rep = SkeletonRepresentation<CoordinateSystem>::makeDefaultRepresentation(SkelPtr, myGridAtlas);
359 if (!Id)
360 {
361 FieldID&Fid = Rep[fieldname];
362 Id = &Fid;
363 }
364
365 Rep[ Id ] = myField;
366 }
367*/
368
369#if 0
376 bool operator=(const double&Value)
377 {
378 typedef double value_type;
380
381 array_type*Data = new array_type( MIndex(1) );
382 Data->myArray()[0] = Value;
383
384 RefPtr<Representation> Rep = SkelPtr->DefaultRepresentation();
385 if (!Rep)
386 return false;
387
388 RefPtr<Field> myField = new Field();
389 myField->setCreator( new MemCreativeArray(Data) );
390
391 if (!Id)
392 {
393 FieldID&Fid = (*Rep)[fieldname];
394 Id = &Fid;
395 }
396
397 (*Rep)[ Id ] = myField;
398
399 return true;
400 }
401#endif
402
403
404/*
405 template <class CoordinateSystem, class real>
406 void operator=(const Point<CoordinateSystem, real>&Vertex)
407 {
408 typedef Point<CoordinateSystem, real> value_type;
409 typedef MemArrayStorage<1, value_type, vector<value_type> > array_type;
410
411// RefPtr<Chart> C = CreateChart<CoordinateSystem>::global( (*myGridAtlas) );
412
413// printf("Got chart named '%s' for storing points as %s (of %s)...\n", C->ID().c_str(), typeid(real).name(), typeid(Vertex).name() );
414
415// Representation&Rep = (*SkelPtr)[C];
416
417 Representation&Rep = SkeletonRepresentation<CoordinateSystem>::makeDefaultRepresentation(SkelPtr, myGridAtlas);
418
419 array_type*Data = new array_type( MIndex(1) );
420 Data->myArray()[0] = Vertex;
421
422 RefPtr<Field> myField = new Field();
423 myField->setCreator( new MemCreativeArray(Data) );
424
425 if (!Id)
426 {
427 FieldID&Fid = Rep[fieldname];
428 Id = &Fid;
429 }
430
431 Rep[ Id ] = myField;
432 }
433*/
434};
435
436
437template <>
438class Iterator<Representation> : public Skeleton::RepresentationMap::Iterator
439{
440};
441
442
443} /* namespace Fiber */
444
445#endif /* __FIBER_GRID_SKELETON_HPP */
constexpr complex< _Tp > & operator=(const _Tp &)
constexpr _OI move(_II __first, _II __last, _OI __result)
basic_string< char > string
Base class for spaces that may be used for mapping domains to fiber spaces.
Definition BaseSpace.hpp:38
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
Identifier for Fields within a Grid.
Definition FieldID.hpp:53
Context information for creating a field and inserting data.
Definition Skeleton.hpp:325
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
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
Mutable Iterator base class to inspect all representations in a given RepresentationMap.
Definition RepresentationMap.hpp:137
A map that associates Representer objects with Representation instances.
Definition RepresentationMap.hpp:41
int iterate(ConstIterator &) const
Inspect all elements of this map.
Definition RepresentationMap.cpp:185
RefPtr< FragmentIDCollection > getFragmentIDCollection() const override
Get the FragmentIDCollection that is responsible for all fields of this Representation.
Definition RepresentationMap.cpp:304
int size() const
Return the number of representations available here.
Definition RepresentationMap.cpp:68
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
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
std::string Name() const
Create a textual representation of the inherent parameters of the Skeleton ID.
Definition SkeletonID.cpp:138
A Skeleton Map is a unique map from SkeletonID's to Skeletons.
Definition SkeletonMap.hpp:74
A Skeleton is a set of Representation object, each of them accessed by an Representer object.
Definition Skeleton.hpp:102
unsigned iterate_fields(const FieldIterator_t &F) const
Iterate over all fields on all Representations of this Skeleton.
Definition Skeleton.hpp:246
Skeleton()=delete
prevent default construction
void operator=(const Skeleton &)=delete
prevent copy assignment
RefPtr< Field > getPositions(const Representer &R)
Get the positions field in the given representation.
Definition Skeleton.hpp:218
auto getFieldFragmentCreators(const Representer &R, const RefPtr< FragmentID > &fID, FieldIdentifiers... theFieldIdentifiers)
Get a set of array creators at once from a Skeleton and a Representer such as a chart object,...
Definition Skeleton.hpp:303
Skeleton(const Skeleton &)=delete
prevent copy construction
auto getFields(const Representer &R, FieldIdentifiers... theFieldIdentifiers)
Get a number of fields at once from a Skeleton and a Representer such as a chart object:
Definition Skeleton.hpp:280
WeakPtr< Skeleton > wSkeleton
Shortcut for a weak pointer to a Skeleton object.
Definition Skeleton.hpp:317
unsigned iterate_fields(const RepresentationFieldIterator_t &F) const
Iterate over all fields on all Representations of this Skeleton, also providing information on the Re...
Definition Skeleton.hpp:261
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
WeakPtr< BaseSpace > Representer
The type used to reference other objects, which is the anchor of representations of a Skeleton.
Definition RepresentationMap.hpp:28
std::string to_string(const span< char > &s)
An interface on creators for fragments in relative representations, used within function Skeleton::cr...
Definition Skeleton.hpp:32