FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
UniGridMapper.hpp
1#ifndef __UNIGRIDMAPPER_HPP
2#define __UNIGRIDMAPPER_HPP
3
4#include <aerie/BoundingBox.hpp>
5#include <eagle/PhysicalSpace.hpp>
6#include <eagle/QuadraticMatrix.hpp>
7
8#include <field/UniformCartesianArray.hpp>
9
10#include <fish/fiber/vector/Interpolate.hpp>
11#include <fish/fiber/vector/LinearIpol.hpp>
12
13#include <memcore/RefPtr.hpp>
14
15#include "gridopDllApi.h"
16
17using namespace Fiber;
18using namespace Eagle;
19using namespace std;
20
21using namespace Eagle::PhysicalSpace;
22
23
30class gridop_API UniGridMapper : public ReferenceBase<UniGridMapper>
31{
36
37// typedef LinearDirectProductMemArray<Eagle::point3> ProcArray_t;
38
39 RefPtr<IndexListArray_t> CurviIndexList;
41 RefPtr<CoordsArray_t> CurviCoords;
42
44
45 double prec;
46 tvector cell_len;
47 MultiIndex<3> res, ix, iy, iz;
48
49 int MaxListSize;
50
51 // used for the correction of 'bad' points by EpsilonPreventer
52 struct DistPoint_t
53 {
54 double dist;
55 point uvw;
56 MultiIndex<3> self;
57 };
58
59public:
66 UniGridMapper(const RefPtr<CoordsArray_t>&_CurviCoords, const double res_scale = 1.0, const double prec_scale = 1.0);
67
68 int MaximalCurvicellPerUnicell() const
69 {
70 return MaxListSize;
71 }
72
73
74static inline double avg(const double a, const double b)
75 {
76 return (a+b)/2;
77 }
78
79static inline void clampRange(point&p, const double min, const double max)
80 {
81 for(unsigned i = 0; i < 3; i++)
82 {
83 p[i] = ( p[i] < min) ? min : p[i];
84 p[i] = ( p[i] > max) ? max : p[i];
85 }
86 }
87
88static inline bool uvwInRange2( point& u, const MultiIndex<3>&it, const MultiIndex<3>&max, const double prec)
89 {
90 if( u[0] >= it[0] && u[0] <= it[0]+1 &&
91 u[1] >= it[1] && u[1] <= it[1]+1 &&
92 u[2] >= it[2] && u[2] <= it[2]+1 )
93 {
94 return true;
95 }
96 else
97 {
98 return false;
99 }
100 }
101
102static inline bool localPointToIndex(const point&p, MultiIndex<3>&cc)
103 {
104 if(p[0] >= 0.0 && p[1] >= 0.0 && p[2] >= 0.0)
105 {
106 cc[0] = unsigned(floor(p[0]));
107 cc[1] = unsigned(floor(p[1]));
108 cc[2] = unsigned(floor(p[2]));
109 return true;
110 }
111 return false;
112 }
113
114
116 MultiIndex<3> Size() const { return CurviIndexList->Size();}
117
119 point operator[](const MultiIndex<3>&m) const { return (*UniGridCoords)[m]; }
120
122 IndexList_t& operator()(const MultiIndex<3>&m) const { return (*CurviIndexList)[m]; }
123 RefPtr<CoordsArray_t> getCurviCoords() const { return CurviCoords; }
124 RefPtr<UniformCartesianArray> getUniCoords() const { return UniGridCoords; }
125
127 point getMin() { return BBox->mincoord(); }
128
130 point getMax() { return BBox->maxcoord(); }
131
132
134 bool add( MultiIndex<3>& curvi_i );
135
139 bool inUniCell(const point&p, MultiIndex<3>&index );
140
144 bool curviCells(const point&p, IndexList_t&list);
145
154 unsigned localCellCoordinatesFromCurviGrid(const point&p, point&uvw, double grid_epsilon = 0.0);
155
163 bool localCellCoordinatesFromCell(point&uvw, const point&P, MultiIndex<3>&it,const CoordsArray_t&Data, const MultiIndex<3>&max,const double prec);
164
165 // do it projectively instead of iteratively
166 unsigned localCellCoordinatesFromCurviGridProjective(const point&p, point&uvw, const double& grid_epsilon );
167
168};
169
170
171
172#endif // __UNIGRIDMAPPER_HPP
constexpr __enable_if_is_duration< _ToDur > floor(const duration< _Rep, _Period > &__d)
_Tp min() const
_Tp max() const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArray.hpp:34
The UniGridMapper Maps a cell in a uniform grid to curvilinear cells, which are contained or intersec...
Definition UniGridMapper.hpp:31
point getMax()
Get the maximum coord of the bounding box of the UniGridMapper.
Definition UniGridMapper.hpp:130
IndexList_t & operator()(const MultiIndex< 3 > &m) const
return list of curvi-cell indices at a given uni-grid index
Definition UniGridMapper.hpp:122
point operator[](const MultiIndex< 3 > &m) const
return point at a given uni-grid index
Definition UniGridMapper.hpp:119
point getMin()
Get the minimum coord of the bounding box of the UniGridMapper.
Definition UniGridMapper.hpp:127
MultiIndex< 3 > Size() const
return the size of the curvi linear index list (Thats not a helpful comment, is it?...
Definition UniGridMapper.hpp:116
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
STL namespace.