FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
RegularTopology.hpp
1#ifndef __FIBER_GRID_REGULAR_TOPOLOGY_HPP
2#define __FIBER_GRID_REGULAR_TOPOLOGY_HPP
3
4#include "GridAPI.h"
5#include <vector/MultiIndex.hpp>
6
7
8namespace Fiber
9{
10
11// GRID_API BaseSpace : public MemCore::ReferenceBase<BaseSpace> , public MemCore::Intercube
12
16namespace RegularTopology
17{
18
23template <Dims_t Dims>
24inline index_t NumberOfEdges(const MultiIndex<Dims>&NumberOfVertices) throw()
25{
26index_t Edges = 0;
27 for(Dims_t i=0; i<Dims; i++)
28 {
29 Edges += ( NumberOfVertices - MultiIndex<Dims>::BitIndex(1<<i) ).size();
30 }
31
32 return Edges;
33}
34
45template <Dims_t Dims>
46inline int EdgeOrientation(index_t EdgeIndex, const MultiIndex<Dims>&NumberOfVertices)
47{
48 for(int Orientation=0; Orientation<Dims; Orientation++)
49 {
52 {
53 return Orientation;
54 }
56 }
57 throw -1;
58}
59
74template <Dims_t Dims>
76 index_t EdgeIndex, const MultiIndex<Dims>&NumberOfVertices)
77{
78// assert( EdgeIndex < NumberOfEdges( NumberOfVertices ) );
79
80 for(Orientation=0; Orientation<Dims; Orientation++)
81 {
85 {
87 return;
88 }
90 }
91 throw -1;
92}
93
105template <Dims_t Dims>
107{
108 return Vertex + MultiIndex<Dims>::BitIndex( 1 << Orientation );
109}
110
120template <Dims_t Dims>
123{
124// assert( EdgeIndex < NumberOfEdges( NumberOfVertices) );
125
127int Orientation;
129 EdgeIndex, NumberOfVertices);
130
133 );
134}
135
151template <Dims_t Dims>
153 const MultiIndex<Dims>&NumberOfVertices)
154{
155 assert( Vertex < NumberOfVertices );
156 assert( Orientation >= 0);
157
159 for(int O=0; O<Orientation+1; O++)
160 {
163
164/*
165 cout << " ComputeEdgeIDfromVertexAndOrientation("<<Vertex<<","<<Orientation<<","<<NumberOfVertices<<")"
166 << "Oriention Axis: " << MultiIndex<3>::Axis(O)
167 << " O="<<O<<" NumberOfOrientedEdges="<<NumberOfOrientedEdges<<" NumberOfOrientedEdgesCount="<<NumberOfOrientedEdgesCount
168 << " EdgeNumberBias="<<EdgeNumberBias<<endl;
169*/
170 if (O<Orientation)
171 {
173 }
174 else
175 {
176 return EdgeNumberBias + Vertex.linear(NumberOfOrientedEdges);
177 }
178 }
179 throw EdgeNumberBias;
180}
181
182} // namespace RegularTopology
183
184using namespace RegularTopology;
185
186} /* namespace Fiber */
187
188#endif /* __FIBER_GRID_REGULAR_TOPOLOGY_HPP */
valarray< size_t > size() const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Identify the edges on a skeleton within a Grid.
Definition Edges.hpp:35
index_t BitIndex() const
From this given multiindex which is supposed to have index values of either 0 or 1 in each direction,...
Definition MultiIndex.hpp:489
static MultiIndex Axis(unsigned int orientation) noexcept
Return a MultiIndex that points just in the given orientation.
Definition MultiIndex.hpp:469
std::pair< MultiIndex< Dims >, MultiIndex< Dims > > ComputeEdgeVertices(index_t EdgeIndex, const MultiIndex< Dims > &NumberOfVertices)
Compute the both vertices that correspond to a certain edge, where the edge is linearly numbered over...
Definition RegularTopology.hpp:122
void ComputeFirstEdgeVertex(MultiIndex< Dims > &FirstVertex, int &Orientation, index_t EdgeIndex, const MultiIndex< Dims > &NumberOfVertices)
Given a linear index of an edge (the edge ID) and the multidimensional number of vertices,...
Definition RegularTopology.hpp:75
index_t ComputeEdgeIDfromVertexAndOrientation(const MultiIndex< Dims > &Vertex, int Orientation, const MultiIndex< Dims > &NumberOfVertices)
Given a vertex and an orientation (i.e.
Definition RegularTopology.hpp:152
index_t NumberOfEdges(const MultiIndex< Dims > &NumberOfVertices)
Compute the number of edges on a regular grid that consists of the given number of vertices.
Definition RegularTopology.hpp:24
int EdgeOrientation(index_t EdgeIndex, const MultiIndex< Dims > &NumberOfVertices)
Compute the orientation of a given edge index in a regular grid, given the number of vertices in the ...
Definition RegularTopology.hpp:46
MultiIndex< Dims > ComputeSecondEdgeVertex(const MultiIndex< Dims > &Vertex, int Orientation)
Given the vertex of an edge and an orientation (0,1,2), return the second vertex of the given edge.
Definition RegularTopology.hpp:106
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
A helper class to be used for multilinear index construction.
Definition MultiIndex.hpp:54
Convenience class to provide an input slot for selection a coordinate orientation along the X,...
Definition XYZOrientation.hpp:17