FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
FragmentSkeleton.hpp
1#ifndef __FRAGMENT_SKELETON_HPP
2#define __FRAGMENT_SKELETON_HPP
3
4#include <grid/Grid.hpp>
5#include <grid/CartesianChart.hpp>
6#include <eagle/PhysicalSpace.hpp>
7#include <aerie/BoundingBox.hpp>
8
9#include "gridopDllApi.h"
10
11namespace Fiber
12{
13
20{
23
25 {
26 const char*what() const throw()
27 { return "FragmentSkeleton Exception"; }
28 };
29
31 {
32 const char*what() const throw()
33 { return "FragmentSkeleton: No Vertices in Grid object"; }
34 };
35
36static const char*MinFieldName();
37static const char*MaxFieldName();
38
39static SkeletonID ID(int VertexDims)
40 {
41 return SkeletonID(VertexDims, 2);
42 }
43
50static SkeletonID ID(const Grid&G)
51 {
52 RefPtr<Skeleton> Vertices = G.findVertices();
53 if (!Vertices)
54 throw NoVertices();
55
56 int VertexDims = Vertices->Dims();
57 return SkeletonID(VertexDims, 2);
58 }
59
60
61static RefPtr<Skeleton> getFragments(const Grid&G)
62 {
63 RefPtr<Skeleton> Vertices = G.findVertices();
64 if (!Vertices)
65 return NullPtr();
66
67 int VertexDims = Vertices->Dims();
68 return G( SkeletonID(VertexDims, 2) );
69 }
70
71static Skeleton& makeFragments(Grid&G)
72 {
73 return G[ ID(G) ];
74 }
75
76
77
78static RefPtr<Representation> getFragmentsAsVertices(const Grid&G)
79 {
80 RefPtr<Skeleton> Vertices = G.findVertices();
81 if (!Vertices) return NullPtr();
82
83 RefPtr<Skeleton> Fragments = getFragments(G);
84 if (!Fragments) return NullPtr();
85
86 return (*Fragments)( Vertices );
87 }
88
89static Representation&makeFragmentsAsVertices(Grid&G)
90 {
91 RefPtr<Skeleton> Vertices = G.findVertices();
92 if (!Vertices) throw NoVertices();
93
94 Skeleton& Fragments = makeFragments(G);
95
96 return Fragments[ Vertices ];
97 }
98
99static RefPtr<Field> makeFragmentNames(Grid&G)
100 {
101 return makeFragmentsAsVertices(G)[ FIBER_POSITIONS ];
102 }
103
104static Representation&makeFragmentCoordinates(Grid&G, const RefPtr<Chart>&C)
105 {
106 Skeleton& Fragments = makeFragments(G);
107 return Fragments[ C ];
108 }
109
110static RefPtr<Field> makeFragmentCoordinatesCenter(Grid&G, const RefPtr<Chart>&C)
111 {
112 return makeFragmentCoordinates(G, C)[ FIBER_POSITIONS ];
113 }
114
115static RefPtr<Field> makeFragmentCoordinatesMin(Grid&G, const RefPtr<Chart>&C)
116 {
117 return makeFragmentCoordinates(G, C)[ MaxFieldName() ];
118 }
119
120static RefPtr<Field> makeFragmentCoordinatesMax(Grid&G, const RefPtr<Chart>&C)
121 {
122 return makeFragmentCoordinates(G, C)[ MaxFieldName() ];
123 }
124
125 RefPtr<Grid> TheGrid;
126
127 FragmentSkeleton(const RefPtr<Grid>&g)
128 : TheGrid(g)
129 {}
130
131 Skeleton& makeFragments()
132 {
133 assert(TheGrid);
134 return makeFragments(*TheGrid);
135 }
136
137 RefPtr<Field> makeFragmentNames() const
138 {
139 assert(TheGrid);
140 return makeFragmentNames(*TheGrid);
141 }
142
143 std::string getFragmentName(index_t i) const
144 {
145 RefPtr<Field> F = makeFragmentNames();
146 assert(F);
147 RefPtr<FragmentNamesMemArray_t> A = F->getData();
148 assert(A);
149 return (*A)[ i ];
150 }
151};
152
153template <class Coordinates = Eagle::PhysicalSpace::point>
164
167
169{
171
174
176 : Base_t(g)
177 {}
178
179 bool buildFragmentCoordinates();
180
181 Representation&makeFragmentCoordinates()
182 {
183 RefPtr<Chart> myCartesian = TheGrid->makeChart( typeid(Fiber::CartesianChart3D) );
184 return Base_t::makeFragmentCoordinates(*TheGrid, myCartesian);
185 }
186
188 makeFragmentCoordinatesMinMax()
189 {
190 Representation&R = makeFragmentCoordinates();
191
193 R[ MinFieldName() ], R[ MaxFieldName() ]
194 );
195 }
196
198
199 RefPtr<FragmentID> getFragmentID(index_t I) const
200 {
201 assert( TheGrid );
202 RefPtr<Representation> CartesianRep = TheGrid->getCartesianRepresentation();
204 assert( CartesianRep->getPositions() );
205 return CartesianRep->getPositions()->getFragmentID( getFragmentName(I) );
206 }
207};
208
209} // namespace Fiber
210
211
212#endif // __FRAGMENT_SKELETON_HPP
213
214
basic_string< char > string
Chart object for cartesian coordinates.
Definition CartesianChart.hpp:15
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Identification information about a field's fragment.
Definition FragmentID.hpp:42
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
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
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
std::nullptr_t NullPtr
Definition FragmentSkeleton.hpp:169
Definition FragmentSkeleton.hpp:155
Definition FragmentSkeleton.hpp:31
Definition FragmentSkeleton.hpp:25
Fragment Skeleton: Each fragment of a field is assigned some value in the form of a field defined on ...
Definition FragmentSkeleton.hpp:20
static SkeletonID ID(const Grid &G)
Return the skeleton ID which is used to store fragment information.
Definition FragmentSkeleton.hpp:50