Field3D
FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections Struct Reference

#include <FieldGroup.h>

Public Member Functions

 GetIntersections (const Ray3d &wsRay, IntervalVec &intervals)
 Ctor. More...
 
void intersectFrustumMapping (const FrustumFieldMapping *mtx) const
 Intersect frustum mapping. More...
 
void intersectMatrixMapping (const MatrixFieldMapping *mtx) const
 Intersect matrix mapping. More...
 
template<typename T >
void operator() (const T &vec) const
 Functor. More...
 

Public Attributes

IntervalVecm_intervals
 
const Ray3dm_wsRay
 

Detailed Description

template<typename BaseTypeList_T, int Dims_T>
struct FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections

Definition at line 575 of file FieldGroup.h.

Constructor & Destructor Documentation

template<typename BaseTypeList_T , int Dims_T>
FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::GetIntersections ( const Ray3d wsRay,
IntervalVec intervals 
)
inline

Ctor.

Definition at line 578 of file FieldGroup.h.

579  : m_wsRay(wsRay), m_intervals(intervals)
580  { }

Member Function Documentation

template<typename BaseTypeList_T , int Dims_T>
void FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectMatrixMapping ( const MatrixFieldMapping mtx) const
inline

Intersect matrix mapping.

Definition at line 582 of file FieldGroup.h.

References detail::intersect(), MatrixFieldMapping::worldToLocal(), MatrixFieldMapping::worldToLocalDir(), and MatrixFieldMapping::wsVoxelSize().

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  }
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Definition: FieldMapping.h:419
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Definition: FieldMapping.h:467
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
Imath::V3d V3d
Definition: SpiMathLib.h:74
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
template<typename BaseTypeList_T , int Dims_T>
void FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectFrustumMapping ( const FrustumFieldMapping mtx) const
inline

Intersect frustum mapping.

Definition at line 605 of file FieldGroup.h.

References detail::cornerPoints(), FrustumFieldMapping::localToWorld(), and FrustumFieldMapping::wsVoxelSize().

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  }
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Imath::Plane3d Plane3d
Definition: SpiMathLib.h:83
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
Imath::V3d V3d
Definition: SpiMathLib.h:74
virtual V3d wsVoxelSize(int i, int j, int k) const
Returns world-space size of a voxel at the specified coordinate.
std::vector< V3d > cornerPoints(const Box3d &box)
Definition: FieldGroup.h:158
template<typename BaseTypeList_T , int Dims_T>
template<typename T >
void FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::operator() ( const T &  vec) const
inline

Functor.

Definition at line 658 of file FieldGroup.h.

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)) {
668  }
669  // Check frustum mapping
670  if (const FrustumFieldMapping *f =
671  dynamic_cast<const FrustumFieldMapping*>(m)) {
673  }
674  }
675  }
void intersectMatrixMapping(const MatrixFieldMapping *mtx) const
Intersect matrix mapping.
Definition: FieldGroup.h:582
void intersectFrustumMapping(const FrustumFieldMapping *mtx) const
Intersect frustum mapping.
Definition: FieldGroup.h:605
Base class for mapping between world-, local- and voxel coordinates.
Definition: FieldMapping.h:86
Represents the mapping of a field by a perspective transform.
Definition: FieldMapping.h:547
Represents the mapping of a field by a matrix transform.
Definition: FieldMapping.h:327

Member Data Documentation

template<typename BaseTypeList_T , int Dims_T>
const Ray3d& FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::m_wsRay

Definition at line 677 of file FieldGroup.h.

template<typename BaseTypeList_T , int Dims_T>
IntervalVec& FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::m_intervals

Definition at line 678 of file FieldGroup.h.


The documentation for this struct was generated from the following file: