Field3D
FieldGroup.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------//
2 
3 #ifndef __F3DUTIL_FIELDGROUP_H__
4 #define __F3DUTIL_FIELDGROUP_H__
5 
6 //------------------------------------------------------------------------------
7 
8 // Boost includes
9 #include <boost/foreach.hpp>
10 #include <boost/tokenizer.hpp>
11 #include <boost/thread/mutex.hpp>
12 #include <boost/mpl/vector.hpp>
13 #include <boost/mpl/for_each.hpp>
14 #include <boost/mpl/placeholders.hpp>
15 #include <boost/mpl/push_back.hpp>
16 #include <boost/mpl/transform.hpp>
17 #include <boost/fusion/mpl.hpp>
18 #include <boost/fusion/algorithm/iteration/for_each.hpp>
19 #include <boost/fusion/include/for_each.hpp>
20 #include <boost/fusion/include/as_vector.hpp>
21 
22 // Field3D includes
23 #include <lava/field3d15/DenseField.h>
24 #include <lava/field3d15/Field3DFile.h>
25 #include <lava/field3d15/FieldInterp.h>
26 #include <lava/field3d15/InitIO.h>
27 #include <lava/field3d15/MIPField.h>
28 #include <lava/field3d15/MIPUtil.h>
29 #include <lava/field3d15/SparseField.h>
30 
31 // Project includes
32 #include "FieldWrapper.h"
33 
34 //----------------------------------------------------------------------------//
35 
36 #include "ns.h"
37 
39 
40 //------------------------------------------------------------------------------
41 // MPL stuff
42 //------------------------------------------------------------------------------
43 
44 namespace mpl = boost::mpl;
45 namespace ph = mpl::placeholders;
46 namespace fusion = boost::fusion;
47 namespace fusion_ro = boost::fusion::result_of;
48 
49 typedef mpl::vector<Field3D::half, float, double> ScalarTypes;
50 typedef mpl::vector<Field3D::V3h, Field3D::V3f, Field3D::V3d> VectorTypes;
51 
52 //------------------------------------------------------------------------------
53 // MPL utilities
54 //------------------------------------------------------------------------------
55 
56 namespace detail {
57 
58 //------------------------------------------------------------------------------
59 
60 template <typename T>
61 struct MakeDense
62 {
63  typedef typename FieldWrapper<Field3D::DenseField<T> >::Vec type;
64 };
65 
66 //------------------------------------------------------------------------------
67 
68 template <typename T>
69 struct MakeSparse
70 {
71  typedef typename FieldWrapper<Field3D::SparseField<T> >::Vec type;
72 };
73 
74 //------------------------------------------------------------------------------
75 
76 template <typename T>
78 {
79  // typedef typename MIPFieldWrapper<Field3D::MIPDenseField<T> >::Vec type;
80  typedef typename
82 };
83 
84 //------------------------------------------------------------------------------
85 
86 template <typename T>
88 {
89  // typedef typename MIPFieldWrapper<Field3D::MIPSparseField<T> >::Vec type;
90  typedef typename
92 };
93 
94 //------------------------------------------------------------------------------
95 
96 template <int Dims_T>
97 struct LoadFields;
98 
99 template <>
100 struct LoadFields<1>
101 {
102  // Ctor
103  LoadFields(Field3D::Field3DInputFile &in, const std::string &name,
104  const std::string &attribute, Field3D::FieldRes::Vec &results)
105  : m_in(in), m_name(name), m_attribute(attribute), m_results(results)
106  { }
107  // Functor
108  template <typename T>
109  void operator()(T)
110  {
111  // Load all fields of type T
112  typename Field3D::Field<T>::Vec fields =
113  m_in.readScalarLayers<T>(m_name, m_attribute);
114  // Add the fields to the result
115  BOOST_FOREACH (const typename Field3D::Field<T>::Ptr &ptr, fields) {
116  m_results.push_back(ptr);
117  }
118  }
119  // Data members
120  Field3D::Field3DInputFile &m_in;
121  const std::string &m_name;
122  const std::string &m_attribute;
123  Field3D::FieldRes::Vec &m_results;
124 };
125 
126 template <>
127 struct LoadFields<3>
128 {
129  // Ctor
130  LoadFields(Field3D::Field3DInputFile &in, const std::string &name,
131  const std::string &attribute, Field3D::FieldRes::Vec &results)
132  : m_in(in), m_name(name), m_attribute(attribute), m_results(results)
133  { }
134  // Functor
135  template <typename Vec_T>
136  void operator()(Vec_T)
137  {
138  typedef typename Vec_T::BaseType T;
139 
140  // Load all fields of type T
141  typename Field3D::Field<Vec_T>::Vec fields =
142  m_in.readVectorLayers<T>(m_name, m_attribute);
143  // Add the fields to the result
144  BOOST_FOREACH (const typename Field3D::Field<Vec_T>::Ptr &ptr, fields) {
145  m_results.push_back(ptr);
146  }
147  }
148  // Data members
149  Field3D::Field3DInputFile &m_in;
150  const std::string &m_name;
151  const std::string &m_attribute;
152  Field3D::FieldRes::Vec &m_results;
153 };
154 
155 //----------------------------------------------------------------------------//
156 
157 inline std::vector<V3d>
158 cornerPoints(const Box3d &box)
159 {
160  std::vector<V3d> result;
161  result.push_back(V3d(box.min.x, box.min.y, box.min.z));
162  result.push_back(V3d(box.max.x, box.min.y, box.min.z));
163  result.push_back(V3d(box.min.x, box.max.y, box.min.z));
164  result.push_back(V3d(box.max.x, box.max.y, box.min.z));
165  result.push_back(V3d(box.min.x, box.min.y, box.max.z));
166  result.push_back(V3d(box.max.x, box.min.y, box.max.z));
167  result.push_back(V3d(box.min.x, box.max.y, box.max.z));
168  result.push_back(V3d(box.max.x, box.max.y, box.max.z));
169  return result;
170 }
171 
172 //------------------------------------------------------------------------------
173 
174 inline bool
175 intersect(const Ray3d &ray, const Box3d &box, double &outT0, double &outT1)
176 {
177  double tNear = -std::numeric_limits<double>::max();
178  double tFar = std::numeric_limits<double>::max();
179  const double epsilon = std::numeric_limits<double>::epsilon() * 10.0;
180 
181  for (size_t dim = 0; dim < 3; ++dim) {
182  double t0, t1;
183  if (std::abs(ray.dir[dim]) < epsilon) {
184  // Ray is parallel, check if inside slab
185  if (ray.pos[dim] < box.min[dim] || ray.pos[dim] > box.max[dim]) {
186  return false;
187  }
188  }
189  t0 = (box.min[dim] - ray.pos[dim]) / ray.dir[dim];
190  t1 = (box.max[dim] - ray.pos[dim]) / ray.dir[dim];
191  if (t0 > t1) {
192  std::swap(t0, t1);
193  }
194  tNear = std::max(tNear, t0);
195  tFar = std::min(tFar, t1);
196  if (tNear > tFar) {
197  return false;
198  }
199  if (tFar < 0.0) {
200  return false;
201  }
202  }
203  outT0 = tNear;
204  outT1 = tFar;
205  return true;
206 }
207 
208 //------------------------------------------------------------------------------
209 
210 } // namespace detail
211 
212 //------------------------------------------------------------------------------
213 // FieldGroup
214 //------------------------------------------------------------------------------
215 
223 template <typename BaseTypeList_T, int Dims_T>
225 {
226  // MPL Typedefs --------------------------------------------------------------
227 
228  // The list of basic types to support.
229  typedef BaseTypeList_T MPLBaseTypes;
230 
231  // Instantiate FieldWrapper<Field_T> for each family with each basic type
232  typedef typename mpl::transform<
233  MPLBaseTypes,
235  typedef typename mpl::transform<
236  MPLBaseTypes,
238  typedef typename mpl::transform<
239  MPLBaseTypes,
241  typedef typename mpl::transform<
242  MPLBaseTypes,
244 
245  // Map MPL types to boost fusion types
246  typedef typename fusion_ro::as_vector<MPLDenseTypes>::type DenseTypes;
247  typedef typename fusion_ro::as_vector<MPLSparseTypes>::type SparseTypes;
248  typedef typename fusion_ro::as_vector<MPLMIPDenseTypes>::type MIPDenseTypes;
249  typedef typename fusion_ro::as_vector<MPLMIPSparseTypes>::type MIPSparseTypes;
250 
251  // Constants -----------------------------------------------------------------
252 
254  static const int k_missingFile = -1;
255 
256  // Ctors ---------------------------------------------------------------------
257 
259  FieldGroup();
261  FieldGroup(const Field3D::FieldRes::Vec &fields);
262 
263  // Main methods --------------------------------------------------------------
264 
265  void setup(const Field3D::FieldRes::Vec &fields);
266 
270  int load(const std::string &filename, const std::string &attribute);
272  size_t size() const;
275  void sample(const V3d &vsP, float *result, bool isVs) const;
277  void sampleMIP(const V3d &vsP, const float wsSpotSize,
278  float *result, bool isVs) const;
280  bool getIntersections(const Ray3d &ray, IntervalVec &intervals) const;
282  void getMinMax(const Box3d &wsBounds, float *min, float *max) const;
284  long long int memSize() const;
286  const FieldRes::Vec& fields() const
287  { return m_allFields; }
288 
289 private:
290 
291  // Data members --------------------------------------------------------------
292 
293  DenseTypes m_dense;
294  SparseTypes m_sparse;
295  MIPDenseTypes m_mipDense;
296  MIPSparseTypes m_mipSparse;
297 
299 
300  // Functors ------------------------------------------------------------------
301 
302  struct GrabFields;
303  struct CountFields;
304  struct Sample;
305  struct SampleMIP;
306  struct GetIntersections;
307  struct GetMinMax;
308  struct GetMinMaxMIP;
309  struct MemSize;
310 
311 };
312 
313 //------------------------------------------------------------------------------
314 
317 
318 //------------------------------------------------------------------------------
319 // Template implementations
320 //------------------------------------------------------------------------------
321 
322 template <typename BaseTypeList_T, int Dims_T>
324 { }
325 
326 //------------------------------------------------------------------------------
327 
328 template <typename BaseTypeList_T, int Dims_T>
330 (const Field3D::FieldRes::Vec &fields)
331 {
332  setup(fields);
333 }
334 
335 //------------------------------------------------------------------------------
336 
337 template <typename BaseTypeList_T, int Dims_T>
338 void
339 FieldGroup<BaseTypeList_T, Dims_T>::setup(const Field3D::FieldRes::Vec &fields)
340 {
341  // Pick out only scalar fields
342  for (size_t i = 0, end = fields.size(); i < end; ++i) {
343  GrabFields op(fields[i]);
344  fusion::for_each(m_dense, op);
345  fusion::for_each(m_sparse, op);
346  fusion::for_each(m_mipDense, op);
347  fusion::for_each(m_mipSparse, op);
348  }
349 }
350 
351 //------------------------------------------------------------------------------
352 
353 template <typename BaseTypeList_T, int Dims_T>
354 int
356 (const std::string &filename, const std::string &attribute)
357 {
358  using namespace Field3D;
359 
360  FieldRes::Vec results;
361 
362  // Track number of fields in group before loading.
363  const size_t sizeBeforeLoading = size();
364 
365  // Open each file ---
366 
367  std::vector<std::string> filenames;
368  filenames.push_back(filename);
369 
370  BOOST_FOREACH (const std::string fn, filenames) {
371 
372  Field3DInputFile in;
373  if (!in.open(fn)) {
374  return k_missingFile;
375  }
376 
377  // Use partition names to determine if fields should be loaded
378  std::vector<std::string> names;
379  in.getPartitionNames(names);
380 
381  BOOST_FOREACH (const std::string &name, names) {
382  detail::LoadFields<Dims_T> op(in, name, attribute, results);
383  mpl::for_each<BaseTypeList_T>(op);
384  }
385 
386  }
387 
388  // Record all the loaded fields
389  m_allFields = results;
390 
391  // Set up from fields
392  setup(results);
393 
394  // Done. Return the number of fields that were loaded.
395  return size() - sizeBeforeLoading;
396 }
397 
398 //------------------------------------------------------------------------------
399 
400 template <typename BaseTypeList_T, int Dims_T>
401 size_t
403 {
404  CountFields op;
405  fusion::for_each(m_dense, op);
406  fusion::for_each(m_sparse, op);
407  fusion::for_each(m_mipDense, op);
408  fusion::for_each(m_mipSparse, op);
409  return op.count;
410 }
411 
412 //------------------------------------------------------------------------------
413 
414 template <typename BaseTypeList_T, int Dims_T>
415 void
417  float *result,
418  bool isVs) const
419 {
420  Sample op(vsP, result, isVs);
421  fusion::for_each(m_dense, op);
422  fusion::for_each(m_sparse, op);
423 }
424 
425 //------------------------------------------------------------------------------
426 
427 template <typename BaseTypeList_T, int Dims_T>
428 void
430  const float wsSpotSize,
431  float *result,
432  bool isVs) const
433 {
434  SampleMIP op(vsP, wsSpotSize, result, isVs);
435  fusion::for_each(m_mipDense, op);
436  fusion::for_each(m_mipSparse, op);
437 }
438 
439 //------------------------------------------------------------------------------
440 
441 template <typename BaseTypeList_T, int Dims_T>
442 bool
444 (const Ray3d &ray, IntervalVec &intervals) const
445 {
446  GetIntersections op(ray, intervals);
447  fusion::for_each(m_dense, op);
448  fusion::for_each(m_sparse, op);
449  fusion::for_each(m_mipDense, op);
450  fusion::for_each(m_mipSparse, op);
451  return intervals.size() > 0;
452 }
453 
454 //------------------------------------------------------------------------------
455 
456 template <typename BaseTypeList_T, int Dims_T>
457 void
459  float *min,
460  float *max) const
461 {
462  GetMinMax op(wsBounds, min, max);
463  fusion::for_each(m_dense, op);
464  fusion::for_each(m_sparse, op);
465  GetMinMaxMIP opMIP(wsBounds, min, max);
466  fusion::for_each(m_mipDense, opMIP);
467  fusion::for_each(m_mipSparse, opMIP);
468 }
469 
470 //------------------------------------------------------------------------------
471 
472 template <typename BaseTypeList_T, int Dims_T>
473 long long int
475 {
476  long long int result = 0;
477  MemSize op(result);
478  fusion::for_each(m_dense, op);
479  fusion::for_each(m_sparse, op);
480  fusion::for_each(m_mipDense, op);
481  fusion::for_each(m_mipSparse, op);
482  return result;
483 }
484 
485 //------------------------------------------------------------------------------
486 // Functor implementations
487 //------------------------------------------------------------------------------
488 
489 template <typename BaseTypeList_T, int Dims_T>
490 struct FieldGroup<BaseTypeList_T, Dims_T>::GrabFields
491 {
493  GrabFields(Field3D::FieldRes::Ptr f)
494  : m_field(f)
495  { }
497  template <typename WrapperVec_T>
498  void operator()(WrapperVec_T &vec) const
499  {
500  typedef typename WrapperVec_T::value_type Wrapper_T;
501  typedef typename Wrapper_T::field_type Field_T;
502  typedef typename Field_T::Ptr FieldPtr;
503  if (FieldPtr f =
504  Field3D::field_dynamic_cast<Field_T>(m_field)) {
505  vec.push_back(f);
506  }
507  }
509  Field3D::FieldRes::Ptr m_field;
510 };
511 
512 //------------------------------------------------------------------------------
513 
514 template <typename BaseTypeList_T, int Dims_T>
515 struct FieldGroup<BaseTypeList_T, Dims_T>::CountFields
516 {
519  : count(0)
520  { }
522  template <typename T>
523  void operator()(const T &vec) const
524  { count += vec.size(); }
525  // Data members
526  mutable int count;
527 };
528 
529 //------------------------------------------------------------------------------
530 
531 template <typename BaseTypeList_T, int Dims_T>
532 struct FieldGroup<BaseTypeList_T, Dims_T>::Sample
533 {
535  Sample(const V3d &p, float *result, bool isVs)
536  : m_p(p), m_result(result), m_isVs(isVs)
537  { }
539  template <typename T>
540  void operator()(const T &vec) const
541  { FieldSampler<T, Dims_T>::sample(vec, m_p, m_result, m_isVs); }
542  // Data members
543  const V3d &m_p;
544  float *m_result;
545  bool m_isVs;
546 };
547 
548 //------------------------------------------------------------------------------
549 
550 template <typename BaseTypeList_T, int Dims_T>
551 struct FieldGroup<BaseTypeList_T, Dims_T>::SampleMIP
552 {
554  SampleMIP(const V3d &p, const float wsSpotSize, float *result,
555  bool isVs)
556  : m_p(p), m_wsSpotSize(wsSpotSize), m_result(result), m_isVs(isVs)
557  { }
559  template <typename T>
560  void operator()(const T &vec) const
561  {
562  FieldSampler<T, Dims_T>::sampleMIP(vec, m_p, m_wsSpotSize, m_result,
563  m_isVs);
564  }
565  // Data members
566  const V3d &m_p;
567  const float m_wsSpotSize;
568  float *m_result;
569  bool m_isVs;
570 };
571 
572 //------------------------------------------------------------------------------
573 
574 template <typename BaseTypeList_T, int Dims_T>
575 struct FieldGroup<BaseTypeList_T, Dims_T>::GetIntersections
576 {
578  GetIntersections(const Ray3d &wsRay, IntervalVec &intervals)
579  : m_wsRay(wsRay), m_intervals(intervals)
580  { }
583  {
584  using std::min;
585 
586  const float time = 0.0f;
587 
588  // Transform ray to local space for intersection test
589  Ray3d lsRay;
590  mtx->worldToLocal(m_wsRay.pos, lsRay.pos, time);
591  mtx->worldToLocalDir(m_wsRay.dir, lsRay.dir);
592  // Use unit bounding box to intersect against
593  Box3d lsBBox(V3d(0.0), V3d(1.0));
594  // Calculate intersection points
595  double t0, t1;
596  // Add the interval if the ray intersects the box
597  if (detail::intersect(lsRay, lsBBox, t0, t1)) {
598  const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
599  const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
600  wsVoxelSize.z);
601  m_intervals.push_back(Interval(t0, t1, minLen));
602  }
603  }
606  {
607  using std::min;
608 
609  typedef std::vector<V3d> PointVec;
610 
611  const float time = 0.0f;
612 
613  // Get the eight corners of the local space bounding box
614  Box3d lsBounds(V3d(0.0), V3d(1.0));
615  PointVec lsCorners = detail::cornerPoints(lsBounds);
616  // Get the world space positions of the eight corners of the frustum
617  PointVec wsCorners(lsCorners.size());
618  for (PointVec::iterator lsP = lsCorners.begin(), wsP = wsCorners.begin(),
619  end = lsCorners.end(); lsP != end; ++lsP, ++wsP) {
620  mtx->localToWorld(*lsP, *wsP, time);
621  }
622 
623  // Construct plane for each face of frustum
624  Plane3d planes[6];
625  planes[0] = Plane3d(wsCorners[4], wsCorners[0], wsCorners[6]);
626  planes[1] = Plane3d(wsCorners[1], wsCorners[5], wsCorners[3]);
627  planes[2] = Plane3d(wsCorners[4], wsCorners[5], wsCorners[0]);
628  planes[3] = Plane3d(wsCorners[2], wsCorners[3], wsCorners[6]);
629  planes[4] = Plane3d(wsCorners[0], wsCorners[1], wsCorners[2]);
630  planes[5] = Plane3d(wsCorners[5], wsCorners[4], wsCorners[7]);
631 
632  // Intersect ray against planes
633  double t0 = -std::numeric_limits<double>::max();
634  double t1 = std::numeric_limits<double>::max();
635  for (int i = 0; i < 6; ++i) {
636  double t;
637  const Plane3d &p = planes[i];
638  if (p.intersectT(m_wsRay, t)) {
639  if (m_wsRay.dir.dot(p.normal) > 0.0) {
640  // Non-opposing plane
641  t1 = std::min(t1, t);
642  } else {
643  // Opposing plane
644  t0 = std::max(t0, t);
645  }
646  }
647  }
648  if (t0 < t1) {
649  t0 = std::max(t0, 0.0);
650  const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
651  const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
652  wsVoxelSize.z);
653  m_intervals.push_back(Interval(t0, t1, minLen));
654  }
655  }
657  template <typename T>
658  void operator()(const T &vec) const
659  {
660  // Intersect the ray against all the fields
661  for (size_t field = 0, end = vec.size(); field < end; ++field) {
662  // Pointer to mapping
663  const FieldMapping* m = vec[field].mapping;
664  // Check matrix mapping
665  if (const MatrixFieldMapping *mtx =
666  dynamic_cast<const MatrixFieldMapping*>(m)) {
667  intersectMatrixMapping(mtx);
668  }
669  // Check frustum mapping
670  if (const FrustumFieldMapping *f =
671  dynamic_cast<const FrustumFieldMapping*>(m)) {
672  intersectFrustumMapping(f);
673  }
674  }
675  }
676  // Data members
677  const Ray3d &m_wsRay;
679 };
680 
681 //------------------------------------------------------------------------------
682 
683 template <typename BaseTypeList_T, int Dims_T>
684 struct FieldGroup<BaseTypeList_T, Dims_T>::GetMinMax
685 {
687  GetMinMax(const Box3d &wsBounds, float *min, float *max)
688  : m_wsBounds(wsBounds), m_min(min), m_max(max)
689  { }
691  template <typename T>
692  void operator()(const T &vec) const
693  {
694  FieldSampler<T, Dims_T>::getMinMax(vec, m_wsBounds, m_min, m_max);
695  }
696  // Data members
698  float *m_min;
699  float *m_max;
700 };
701 
702 //------------------------------------------------------------------------------
703 
704 template <typename BaseTypeList_T, int Dims_T>
705 struct FieldGroup<BaseTypeList_T, Dims_T>::GetMinMaxMIP
706 {
708  GetMinMaxMIP(const Box3d &wsBounds, float *min, float *max)
709  : m_wsBounds(wsBounds), m_min(min), m_max(max)
710  { }
712  template <typename T>
713  void operator()(const T &vec) const
714  {
715  FieldSampler<T, Dims_T>::getMinMaxMIP(vec, m_wsBounds, m_min, m_max);
716  }
717  // Data members
719  float *m_min;
720  float *m_max;
721 };
722 
723 //------------------------------------------------------------------------------
724 
725 template <typename BaseTypeList_T, int Dims_T>
726 struct FieldGroup<BaseTypeList_T, Dims_T>::MemSize
727 {
729  MemSize(long long int &memSize)
730  : m_memSize(&memSize)
731  { }
733  template <typename T>
734  void operator()(const T &vec) const
735  {
736  for (size_t field = 0, end = vec.size(); field < end; ++field) {
737  *m_memSize += vec[field].field->memSize();
738  }
739  }
741  long long int result() const
742  { return m_memSize; }
743  // Data members
744  long long int *m_memSize;
745 };
746 
747 //----------------------------------------------------------------------------//
748 
750 
751 //------------------------------------------------------------------------------
752 
753 #endif // include guard
754 
755 //------------------------------------------------------------------------------
void intersectMatrixMapping(const MatrixFieldMapping *mtx) const
Intersect matrix mapping.
Definition: FieldGroup.h:582
MIPSparseTypes m_mipSparse
Definition: FieldGroup.h:296
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
FieldWrapper< Field3D::DenseField< T > >::Vec type
Definition: FieldGroup.h:63
fusion_ro::as_vector< MPLDenseTypes >::type DenseTypes
Definition: FieldGroup.h:246
void intersectFrustumMapping(const FrustumFieldMapping *mtx) const
Intersect frustum mapping.
Definition: FieldGroup.h:605
const std::string & m_attribute
Definition: FieldGroup.h:122
MemSize(long long int &memSize)
Ctor.
Definition: FieldGroup.h:729
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Definition: FieldMapping.h:419
SampleMIP(const V3d &p, const float wsSpotSize, float *result, bool isVs)
Ctor.
Definition: FieldGroup.h:554
MIPDenseTypes m_mipDense
Definition: FieldGroup.h:295
FieldGroup()
Default constructor, does nothing.
Definition: FieldGroup.h:323
std::vector< Ptr > Vec
Definition: Field.h:219
const V3d & m_p
Definition: FieldGroup.h:543
int load(const std::string &filename, const std::string &attribute)
Loads all fields from a given file and optional attribute pattern.
Definition: FieldGroup.h:356
SparseTypes m_sparse
Definition: FieldGroup.h:294
Sample(const V3d &p, float *result, bool isVs)
Ctor.
Definition: FieldGroup.h:535
GrabFields(Field3D::FieldRes::Ptr f)
Ctor.
Definition: FieldGroup.h:493
Field3D::FieldRes::Vec & m_results
Definition: FieldGroup.h:123
void getMinMax(const Box3d &wsBounds, float *min, float *max) const
Returns the min/max range within a given bounding box.
Definition: FieldGroup.h:458
fusion_ro::as_vector< MPLSparseTypes >::type SparseTypes
Definition: FieldGroup.h:247
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Definition: FieldMapping.h:467
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
GetMinMax(const Box3d &wsBounds, float *min, float *max)
Ctor.
Definition: FieldGroup.h:687
Base class for mapping between world-, local- and voxel coordinates.
Definition: FieldMapping.h:86
const std::string & m_name
Definition: FieldGroup.h:121
static void getMinMax(const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:692
Imath::Plane3d Plane3d
Definition: SpiMathLib.h:83
long long int memSize() const
Returns the memory use in bytes for the fields in the group.
Definition: FieldGroup.h:474
FieldWrapper< Field3D::SparseField< T > >::Vec type
Definition: FieldGroup.h:71
size_t size() const
The number of fields in the group.
Definition: FieldGroup.h:402
This class wraps up a single field to make its interpolator and its mapping easily accessible...
Definition: FieldWrapper.h:33
bool getIntersections(const Ray3d &ray, IntervalVec &intervals) const
Gets the intersection intervals between the ray and the fields.
Definition: FieldGroup.h:444
static void getMinMaxMIP(const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
long long int result() const
Result.
Definition: FieldGroup.h:741
GetMinMaxMIP(const Box3d &wsBounds, float *min, float *max)
Ctor.
Definition: FieldGroup.h:708
const Box3d & m_wsBounds
Definition: FieldGroup.h:697
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:540
mpl::transform< MPLBaseTypes, detail::MakeSparse< ph::_1 > >::type MPLSparseTypes
Definition: FieldGroup.h:237
Represents a single integration interval. The interval is assumed to be inclusive, i.e. [t0,t1].
Definition: Types.h:64
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
void operator()(WrapperVec_T &vec) const
Functor.
Definition: FieldGroup.h:498
void sample(const V3d &vsP, float *result, bool isVs) const
Samples the group of fields at the given point. This call will not include MIP fields, which require a spot size.
Definition: FieldGroup.h:416
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:713
const float m_wsSpotSize
Definition: FieldGroup.h:567
FieldRes::Vec m_allFields
Definition: FieldGroup.h:298
LoadFields(Field3D::Field3DInputFile &in, const std::string &name, const std::string &attribute, Field3D::FieldRes::Vec &results)
Definition: FieldGroup.h:103
MIPFieldWrapper< Field3D::MIPField< Field3D::DenseField< T > > >::Vec type
Definition: FieldGroup.h:81
MIPFieldWrapper< Field3D::MIPField< Field3D::SparseField< T > > >::Vec type
Definition: FieldGroup.h:91
DenseTypes m_dense
Definition: FieldGroup.h:293
Imath::V3d V3d
Definition: SpiMathLib.h:74
std::vector< Interval > IntervalVec
Definition: Types.h:86
void sampleMIP(const V3d &vsP, const float wsSpotSize, float *result, bool isVs) const
Samples all the MIP fields in the group.
Definition: FieldGroup.h:429
Provides reading of .f3d (internally, hdf5) files.Refer to using_files for examples of how to use thi...
Definition: Field3DFile.h:434
const FieldRes::Vec & fields() const
Returns a vector of FieldRes::Ptrs to the fields in the group.
Definition: FieldGroup.h:286
Field3D::FieldRes::Vec & m_results
Definition: FieldGroup.h:152
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:560
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:734
static void sample(const WrapperVec_T &f, const V3d &p, float *value, bool isVs)
mpl::transform< MPLBaseTypes, detail::MakeDense< ph::_1 > >::type MPLDenseTypes
Definition: FieldGroup.h:234
void getPartitionNames(std::vector< std::string > &names) const
Gets the names of all the partitions in the file.
void operator()(Vec_T)
Definition: FieldGroup.h:136
LoadFields(Field3D::Field3DInputFile &in, const std::string &name, const std::string &attribute, Field3D::FieldRes::Vec &results)
Definition: FieldGroup.h:130
long long int * m_memSize
Definition: FieldGroup.h:744
Field3D::FieldRes::Ptr m_field
The field to work on. Will be matched against the type of operator().
Definition: FieldGroup.h:509
This class wraps up a single MIP field to make its interpolator and its mapping easily accessible...
Definition: FieldWrapper.h:59
const Box3d & m_wsBounds
Definition: FieldGroup.h:718
const std::string & m_name
Definition: FieldGroup.h:150
mpl::transform< MPLBaseTypes, detail::MakeMIPDense< ph::_1 > >::type MPLMIPDenseTypes
Definition: FieldGroup.h:240
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:658
FIELD3D_NAMESPACE_OPEN typedef mpl::vector< Field3D::half, float, double > ScalarTypes
Definition: FieldGroup.h:49
virtual V3d wsVoxelSize(int i, int j, int k) const
Returns world-space size of a voxel at the specified coordinate.
FieldGroup< VectorTypes, 3 > VectorFieldGroup
Definition: FieldGroup.h:316
Represents the mapping of a field by a perspective transform.
Definition: FieldMapping.h:547
Field3D::Field3DInputFile & m_in
Definition: FieldGroup.h:149
void setup(const Field3D::FieldRes::Vec &fields)
Definition: FieldGroup.h:339
mpl::vector< Field3D::V3h, Field3D::V3f, Field3D::V3d > VectorTypes
Definition: FieldGroup.h:50
static void sampleMIP(const WrapperVec_T &f, const V3d &p, const float wsSpotSize, float *value, bool isVs)
bool intersect(const Ray3d &ray, const Box3d &box, double &outT0, double &outT1)
Definition: FieldGroup.h:175
Imath::Line3d Ray3d
Definition: StdMathLib.h:71
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
Definition: FieldMapping.h:453
std::vector< V3d > cornerPoints(const Box3d &box)
Definition: FieldGroup.h:158
void operator()(const T &vec) const
Functor.
Definition: FieldGroup.h:523
fusion_ro::as_vector< MPLMIPSparseTypes >::type MIPSparseTypes
Definition: FieldGroup.h:249
GetIntersections(const Ray3d &wsRay, IntervalVec &intervals)
Ctor.
Definition: FieldGroup.h:578
mpl::transform< MPLBaseTypes, detail::MakeMIPSparse< ph::_1 > >::type MPLMIPSparseTypes
Definition: FieldGroup.h:243
Represents the mapping of a field by a matrix transform.
Definition: FieldMapping.h:327
Field3D::Field3DInputFile & m_in
Definition: FieldGroup.h:120
fusion_ro::as_vector< MPLMIPDenseTypes >::type MIPDenseTypes
Definition: FieldGroup.h:248
bool open(const std::string &filename)
Opens the given file.
FieldGroup< ScalarTypes, 1 > ScalarFieldGroup
Definition: FieldGroup.h:315
const std::string & m_attribute
Definition: FieldGroup.h:151
BaseTypeList_T MPLBaseTypes
Definition: FieldGroup.h:229