FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
SkeletonMap.hpp
1#ifndef __FIBER_SKELETONMAP_HPP
2#define __FIBER_SKELETONMAP_HPP "Created 14.04.2014 16:37:27 by werner"
3
4#include "GridAPI.h"
5#include <fiber/field/Field.hpp>
6#include <memcore/TypeInfo.hpp>
7
8#include "FieldID.hpp"
9#include "FiberSpace.hpp"
10#include "Representation.hpp"
11#include "Skeleton.hpp"
12
13namespace Fiber
14{
15 using MemCore::WeakPtr;
16 using MemCore::NullPtr;
17 using std::set;
18 using std::list;
19
20
21
26{
27public:
28 virtual ~ConstSkeletonIterator();
29
30 virtual bool apply(const SkeletonID&id, const Skeleton&S) = 0;
31};
32
33
38{
39public:
40 virtual ~SkeletonIterator();
41
42 virtual bool apply(const SkeletonID&id, Skeleton&S) = 0;
43};
44
45
46//typedef std::pair<SkeletonID, RefPtr<Skeleton> > SkeletonInfo;
47
48
49struct SkeletonPtrHash : std::hash<Skeleton*>
50{
51 size_t operator()(const RefPtr<Skeleton>&S) const
52 {
53 return std::hash<Skeleton*>::operator()(S.rawptr());
54 }
55};
56
58{
59 bool operator()(const RefPtr<Skeleton>&A, const RefPtr<Skeleton>&B) const
60 {
61 if (A == B) return true;
62 if (!A) return false;
63 if (!B) return false;
64
65 return *A == *B;
66 }
67};
68
69
73class GRID_API SkeletonMap : public OwnerOf<BaseSpace>
74{
75// typedef std::unordered_set<RefPtr<Skeleton>, SkeletonPtrHash, SkeletonPtrEqual > Skeletons_t;
76// typedef std::map<SkeletonID, RefPtr<Skeleton> > Skeletons_t;
77
78public:
79
81 Skeletons_t Skeletons;
82
84
85protected:
88
89 void extremeUnction() override;
90
91public:
92
94 RefPtr<Skeleton> findVertices(int TotalRefinement = -1) const;
95
97 RefPtr<Skeleton> getVerticesInfo(int TotalRefinement = -1) const;
98
100 RefPtr<Skeleton> getEdgeInfo(int TotalRefinement = -1) const;
101
103 RefPtr<Skeleton> getFaceInfo(int TotalRefinement = -1) const;
104
117 double NumberOfHoles(int TotalRefinement = -1) const;
118
123 Skeleton& makeVertices(int dims);
124
125
127 Skeleton &operator[](const SkeletonID&Sid);
128
130 RefPtr<Skeleton> getSkeleton(const SkeletonID&Sid) const;
131
136 {
137 return getSkeleton(Sid);
138 }
139
140
141 RefPtr<Representation> CellsAsVertices(int dims) const;
142
157// RefPtr<Skeleton> getFragmentSkeleton(const SkeletonID&Sid) const;
158
168// [[deprecated("Use FragmentTopology::findHighestDimensionalRepresentation() instead")]]
169// RefPtr<Representation> getFragmentRepresentation(const SkeletonID&Sid) const;
170
179// RefPtr<Field> getFragmentTopology(const SkeletonID&Sid) const;
180
181
182 int MinLevel(int IndexDepth=0) const;
183
187 int MaxLevel(int IndexDepth=0) const;
188
196 RefPtr<Skeleton> findMaxHomogenousRefinement(int IndexDepth) const;
197
198 bool replaceSkeletonID( const SkeletonID&old_id, const SkeletonID&new_id );
199
208 RefPtr<Skeleton> findIsotropicRefinementFactor(int Factor, int IndexDepth) const;
209
214
218 int iterate(ConstSkeletonIterator&) const;
219
223 int iterate(SkeletonIterator&);
224
225
226 int iterate(std::function<bool(const SkeletonID&id, Skeleton&S)>) const;
227 int iterate_const(std::function<bool(const SkeletonID&id, const Skeleton&S)>) const;
228
229
240 template <class SkeletonFunctor>
241 int Iterate(const SkeletonFunctor&F) const
242 {
243 struct I : ConstSkeletonIterator
244 {
245 const SkeletonFunctor&F;
246 I(const SkeletonFunctor&pF)
247 : F(pF)
248 {}
249
250 bool apply(const SkeletonID&id, const Skeleton&S) override
251 {
252 return F(id, S);
253 }
254 }
255 myI(F);
256 return iterate(myI);
257 }
258
259 template <class Functor>
260 int iterate_all(const Functor&F) const
261 {
262 struct I : ConstSkeletonIterator
263 {
264 const Functor&F;
265 I(const Functor&pF)
266 : F(pF)
267 {}
268
269 bool apply(const SkeletonID&id, const Skeleton&S) override
270 {
271 S.iterate_all( [this, &S](const Representer&theRepresenter, const Representation&R,
272 const FieldID&theFieldID, const Field&theField,
274 {
275 F( S, theRepresenter, R,
276 theFieldID, theField,
277 CAB, fid );
278 }
279 );
280 return true;
281 }
282 }
283 myI(F);
284 return iterate(myI);
285 }
286
287
289 int nSkeletons() const;
290
291 int nSkeletons(int IndexDepth) const;
292
293
294
295#if 0 // method bodies not implemented
301 RefPtr<Field> getField(const RefPtr<ChartID>&theChartID,
302 const string&fieldname, const RefPtr<Skeleton>&theSkeleton) const;
307 RefPtr<Field> getVertexField(const RefPtr<ChartID>&theChartID,
308 const string&fieldname) const
309 {
310 return getField(theChartID, fieldname, findVertices() );
311 }
312
318 RefPtr<Field> getPositions(const RefPtr<ChartID>&theChartID,
319 const RefPtr<Skeleton>&theSkeleton) const;
320
321
327 RefPtr<Field> getVertexPositions(const RefPtr<ChartID>&theChartID) const;
328
329
335 RefPtr<Representation> getRepresentation(const RefPtr<ChartID>&theChartID,
336 const RefPtr<Skeleton>&theSkeleton) const;
337
345 RefPtr<Representation> getVertexRepresentation(const RefPtr<ChartID>&theChartID) const
346 {
347 return getRepresentation(theChartID, findVertices() );
348 }
349
350#endif
351
359 int getMemoryUsage(memsize_t&UsedMemory, memsize_t&WantedMemory) const;
360
361
365 void Speak(int indent=0, int maxindent=-1) const;
366
367
368 string xml() const;
369};
370
371
372} /* namespace Fiber */
373
374#endif /* __FIBER_SKELETONMAP_HPP */
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply(_Tp __func(_Tp)) const
Base class for constant iterators over a sequence of skeletons.
Definition SkeletonMap.hpp:26
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
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
T & operator[](index_t i) const
Access an element of the array, writeable.
Definition vector/Iterator.hpp:712
int iterate_all(const Functor &F) const
Definition Representation.hpp:672
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
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
int Iterate(const SkeletonFunctor &F) const
Definition SkeletonMap.hpp:241
RefPtr< Skeleton > operator()(const SkeletonID &Sid) const
Find a Skeleton.
Definition SkeletonMap.hpp:135
SkeletonIterator Iterator
Associated Iterator class.
Definition SkeletonMap.hpp:213
A Skeleton is a set of Representation object, each of them accessed by an Representer object.
Definition Skeleton.hpp:102
MemSizeConfig< sizeof(void *)>::memsize_t memsize_t
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
typename Ownable< OwnedObjectType, ContainerBase >::Container OwnerOf
Shortcut to find the owning type.
Definition Ownable.hpp:265
std::nullptr_t NullPtr
Definition SkeletonMap.hpp:58
Definition SkeletonMap.hpp:50