FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
LocalFromWorldPoint.hpp
1#ifndef __LOCALFROMWORLDPOINT_HPP
2#define __LOCALFROMWORLDPOINT_HPP
3
4#include <fish/fiber/field/DirectProductArray.hpp>
5#include <fish/fiber/vector/Interpolate.hpp>
6#include <fish/fiber/vector/LinearIpol.hpp>
7#include <fish/fiber/baseop/UniGridMapper.hpp>
8#include <fish/fiber/baseop/TreeCellMapper.hpp>
9#include <fish/fiber/baseop/ExpandBBox.hpp>
10
11#include <fish/fiber/field/Fragment.hpp>
12#include <fish/fiber/grid/Chart.hpp>
13
14#include <fish/fiber/baseop/BundleBaseSpaceFunctions.hpp>
15
16#include <eagle/PhysicalSpace.hpp>
17#include <aerie/KDTree.hpp>
18#include <eagle/FixedArray.hpp>
19
20#include <memcore/RefPtr.hpp>
21#include "FragmentSkeleton.hpp"
22#include "PointSearch.hpp"
23#include <fish/fiber/field/DirectProductArrayTypes.hpp>
24
25#include "gridopDllApi.h"
26
27#ifdef USE_OPENMP
28#include <omp.h>
29#endif
30
31namespace Fiber
32{
33
34using namespace Eagle;
35using namespace Eagle::PhysicalSpace;
36
37
39{
41const Eagle::PhysicalSpace::point world_point;
42RefPtr<FragmentID> frag_id;
43MultiIndex<1> cell; // required for hexahedral and pointcloud data, thus 1 dimensional
44tvector cell_size;
45
47 : local_point(0, 0, 0)
48 , world_point(0, 0, 0)
49 , frag_id(NullPtr())
50 , cell( MultiIndex<1>(0) )
51 , cell_size(0, 0, 0)
52 {}
53
55 : local_point(0, 0, 0)
56 , world_point( wp )
57 , frag_id(NullPtr())
58 , cell( MultiIndex<1>(0) )
59 , cell_size(0, 0, 0)
60 {}
61
62};
63
70class gridop_API LocalFromWorldPoint : public MemCore::ReferenceBase<LocalFromWorldPoint >
71{
72 // info retrieved from iterator, which is called once
73// bool curvi_coords;
74// bool fragmented_coords;
75
76// bool inited;
77
78// RefPtr<Slice> slice;
79 RefPtr<Field> coords;
80
81 CartesianFragments FragmentProperties;
82 PointSearch UniformPointSearch;
83
84public:
85 RefPtr<Grid>&grid() { return FragmentProperties.TheGrid; }
86private:
87
88 double TreeQueryFac;
89 RefPtr<KDTree<3, int> > MyTree;
90
96 static inline MultiIndex<3> getFragmentOffset(const RefPtr<FragmentID>&f)
97 {
98 MultiIndex<3> Offset;
101 {
102 Offset = *F3;
103 }
104 else
105 {
106 Offset = 0, 0, 0;
107 }
108
109 return Offset;
110 }
111
118
120
130
131 // Remember Fragment IDs and Bounding Boxes, and UniGRid object in class after initialization
132// RefPtr<FragmentIDs_t> MyFragIds;
133// RefPtr<FragmentBounds_t> MyFragBBs;
134 RefPtr<Field>&UniMapperField()
135 {
136 return UniformPointSearch.UniMapperField;
137 }
138
142 struct MyIterator : Field::Iterator
143 {
144 int c;
145
146 RefPtr<Field> FragmentBoxes;
147
148 RefPtr<Field> Coords;
150 double last_radius;
151
152 bool build_tree;
153
154// RefPtr<FragmentIDs_t> MyFragIds;
155// RefPtr<FragmentBounds_t> MyFragBBs;
156
157 MyIterator(const RefPtr<Field>&FragmentBoxesPositions,
159 const RefPtr<KDTree<3,int> >&TreeP,
160 const bool build_treeP)
161//, const RefPtr<FragmentIDs_t>&FragIdsP, const RefPtr<FragmentBounds_t>&FragBBsP )
162 :c(0)
163 , FragmentBoxes( FragmentBoxesPositions )
164 , Coords(CoordsP)
165 , Tree(TreeP)
166 , last_radius(0)
167 , build_tree(build_treeP)
168// , MyFragIds(FragIdsP)
169// , MyFragBBs(FragBBsP)
170 {}
171
173
174 } ;
175
176
177
182 class gridop_API BBSelectorBase
183 {
184 protected:
185
186
187 public:
188 BBSelectorBase() {}
189 virtual ~BBSelectorBase(){}
190
191 virtual unsigned int getNext() = 0;
192 virtual bool hasNext() = 0;
193 virtual void reset(const int _last, const point& pos) = 0;
194 };
195
196 public:
201 class gridop_API BBSelectorMemoryTree : public BBSelectorBase
202 {
203 int last, current, size;
204 point reset_pos;
207 double TreeQueryFac;
209 public:
211 : reset_pos(point(0,0,0))
212 , TreeQueryFac(TreeQueryFacP)
213 , Tree(TreeP)
214 {
215 m.clear();
216 last=0;
217 current=0;
218 size=0;
219 }
220
221 unsigned int getNext();
222 bool hasNext();
223 void reset( const int _last, const point& pos );
224 };
225
226
232 {
233// protected:
234// RefPtr<CoordsArray_t> CoordsArr;
235// RefPtr<VectorArray_t> VecsArr;
236// MultiIndex<3> iAx, iAy, iAz;
237 public:
238 FindCell()
239 {
240// iAx = 1, 0, 0;
241// iAy = 0, 1, 0;
242// iAz = 0, 0, 1;
243 }
244
245 virtual ~FindCell(){}
246
247// void setCoords(const RefPtr<CoordsArray_t> CA) { CoordsArr = CA; }
248// void setVecs (const RefPtr<VectorArray_t> VA) { VecsArr = VA; }
249
250// inline tvector cross(const tvector&t1, const tvector&t2)
251// {
252// tvector res;
253// res = t1[1]*t2[2] - t1[2]*t2[1],
254// -( t1[0]*t2[2] - t1[2]*t2[0] ),
255// t1[0]*t2[1] - t1[1]*t2[0];
256//
257// return res;
258// }
259
260 virtual int pointInCell( const point&P ) = 0;
261 virtual point localUVW () = 0;
262 };
263
264
269 {
271
272 point uvw;
273 int point_type;
274 double block_epsilon;
275
276 public:
278 {}
279
280 virtual ~HexaHedralCellNewton(){}
281
282 void setUniMap ( RefPtr<UniGridMapper> unimap ) { UniMap = unimap; }
283 int pointInCell( const point&P );
284 point localUVW ();
285
286 void setEpsilon(const double e) { block_epsilon = e; }
287 };
288
289 class ProjectiveCell// : public FindCell
290 {
291 RefPtr<TreeCellMapper> m_tree_map;
292
293 // use LocalPoint here?? Reference??
294 point uvw;
295 tvector cell_size;
296 int point_type;
297
298 public:
299 ProjectiveCell()//:FindCell()
300 {}
301
302 virtual ~ProjectiveCell(){}
303
304 void setTreeMap ( RefPtr<TreeCellMapper> tree_map ) { m_tree_map = tree_map; }
305 inline point localUVW() { return uvw; }
306 inline tvector cellSize() { return cell_size; }
307
308 inline int pointInCell( const point&P )
309 {
310 point_type = m_tree_map->localCoordinates( uvw, cell_size, P );
311 return point_type;
312 }
313
314
315 };
316
317 // to be removed later
318 double block_epsilon;
319
320 // parameters for unigrid building
321 double res_scale, prec_scale;
322
323
324
325public:
326 int MaxListSize;
327private:
328 tvector m_tree_query_scale;
329public:
339 const string&Gridname,
340 double res_scale = 1.0, double prec_scale = 0.1,
341 tvector tree_query_scale = tvector(1.,1.,1.) );
342
345
353// bool get(const point&position, pair<point, RefPtr<FragmentID> >&result );
354 bool get(const point&position, LocalPoint&result );
355
356 bool getViaTree( LocalPoint&result );
357
358 /* Set an epsilon value for widening the block boundary test. This is a hack solution and should be done internally via
359 * neighbourhood information avoiding espsilons. Some tests showed that a value of 0.05 seems to do pretty ok.
360 */
361 void setBlockBoundaryEpsilon(const double block_epsilonP) { block_epsilon = block_epsilonP; }
362
363
367 int numberOfBordersOfCell( const pair<point, string> localdata, int&hint1, int&hint2 );
368
369
375 bool getBorderIntersectionNormal( const point worldposition,
377 const tvector direction,
379};
380
381} // namespace
382
383#endif
constexpr const __tuple_element_t< __i, tuple< _Elements... > > && get(const tuple< _Elements... > &&__t) noexcept
valarray< size_t > size() const
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply(_Tp __func(_Tp)) const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Definition DirectProductArray.hpp:367
Base class for iterators over the fragments of a field.
Definition FragmentID.hpp:249
Select fragment candidates out of all the candidates by doing a query into the KDTree and provide a m...
Definition LocalFromWorldPoint.hpp:202
Base class for finding the cell containing the point in a fragment.
Definition LocalFromWorldPoint.hpp:232
Finds a cell containing a world point by using the UniGridMapper.
Definition LocalFromWorldPoint.hpp:269
Definition LocalFromWorldPoint.hpp:290
Use this class to compute a local cell index and fragment ID (if neccessary) of any coordinate field ...
Definition LocalFromWorldPoint.hpp:71
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr
Definition FragmentSkeleton.hpp:169
Definition LocalFromWorldPoint.hpp:39
Point Search Utility functions for finding points in a grid based on provided coordinate information.
Definition PointSearch.hpp:24