FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections Struct Reference

`#include <FieldGroup.h>`

## Public Member Functions

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

## Public Attributes

IntervalVec & | m_intervals
const Ray3d & | m_wsRay

## Detailed Description

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

Definition at line 1206 of file FieldGroup.h.

## Constructor & Destructor Documentation

## GetIntersections()

template<typename BaseTypeList_T, int Dims_T>

FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::GetIntersections | ( | const Ray3d & | wsRay,
|  | IntervalVec & | intervals )

inline

Ctor.

Definition at line 1209 of file FieldGroup.h.

: m_wsRay(wsRay), m_intervals(intervals)
{
}
FieldGroup::GetIntersections::m_intervals
IntervalVec & m_intervals
Definition FieldGroup.h:1321
FieldGroup::GetIntersections::m_wsRay
const Ray3d & m_wsRay
Definition FieldGroup.h:1320
FieldGroup
Definition FieldGroup.h:304

References m_intervals, and m_wsRay.

## Member Function Documentation

## intersectMatrixMapping()

template<typename BaseTypeList_T, int Dims_T>

void FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectMatrixMapping | ( | const Ray3d & | wsRay,
|  | const MatrixFieldMapping * | mtx,
|  | const float | worldScale ) const

inline

Intersect matrix mapping.

Definition at line 1215 of file FieldGroup.h.

{
using std::min;
const float time = 0.0f;
// Transform ray to local space for intersection test
Ray3d lsRay;
mtx->worldToLocal(wsRay.pos, lsRay.pos, time);
mtx->worldToLocalDir(wsRay.dir, lsRay.dir);
// Use unit bounding box to intersect against
Box3d lsBBox(V3d(0.0), V3d(1.0));
// Calculate intersection points
double t0, t1;
// Add the interval if the ray intersects the box
if (detail::intersect(lsRay, lsBBox, t0, t1)) {
const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
wsVoxelSize.z);
m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
}
}
V3d
Imath::V3d V3d
Definition SpiMathLib.h:74

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

Referenced by operator()().

## intersectFrustumMapping()

template<typename BaseTypeList_T, int Dims_T>

void FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectFrustumMapping | ( | const Ray3d & | wsRay,
|  | const FrustumFieldMapping * | mtx,
|  | const float | worldScale ) const

inline

Intersect frustum mapping.

Definition at line 1240 of file FieldGroup.h.

{
using std::min;
typedef std::vector<V3d> PointVec;
const float time = 0.0f;
// Get the eight corners of the local space bounding box
Box3d lsBounds(V3d(0.0), V3d(1.0));
PointVec lsCorners = detail::cornerPoints(lsBounds);
// Get the world space positions of the eight corners of the frustum
PointVec wsCorners(lsCorners.size());
for (PointVec::iterator lsP = lsCorners.begin(), wsP = wsCorners.begin(),
end = lsCorners.end(); lsP != end; ++lsP, ++wsP) {
mtx->localToWorld(*lsP, *wsP, time);
}
// Construct plane for each face of frustum
Plane3d planes[6];
planes[0] = Plane3d(wsCorners[4], wsCorners[0], wsCorners[6]);
planes[1] = Plane3d(wsCorners[1], wsCorners[5], wsCorners[3]);
planes[2] = Plane3d(wsCorners[4], wsCorners[5], wsCorners[0]);
planes[3] = Plane3d(wsCorners[2], wsCorners[3], wsCorners[6]);
planes[4] = Plane3d(wsCorners[0], wsCorners[1], wsCorners[2]);
planes[5] = Plane3d(wsCorners[5], wsCorners[4], wsCorners[7]);
// Intersect ray against planes
double t0 = -std::numeric_limits<double>::max();
double t1 = std::numeric_limits<double>::max();
for (int i = 0; i < 6; ++i) {
double t;
const Plane3d &p = planes[i];
if (p.intersectT(wsRay, t)) {
if (wsRay.dir.dot(p.normal) > 0.0) {
// Non-opposing plane
t1 = std::min(t1, t);
} else {
// Opposing plane
t0 = std::max(t0, t);
}
}
}
if (t0 < t1) {
t0 = std::max(t0, 0.0);
const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
wsVoxelSize.z);
m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
}
}
Plane3d
Imath::Plane3d Plane3d
Definition SpiMathLib.h:83
detail::cornerPoints
std::vector< V3d > cornerPoints(const Box3d &box)
Definition FieldGroup.h:211
FieldGroup::size
virtual size_t size() const
The number of fields in the group.
Definition FieldGroup.h:689

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

Referenced by operator()().

## operator()()

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 1295 of file FieldGroup.h.

{
// Intersect the ray against all the fields
for (size_t field = 0, end = vec.size(); field < end; ++field) {
// Check object space transform
Ray3d wsRay = m_wsRay;
if (vec[field].doOsToWs) {
vec[field].wsToOs.multVecMatrix(m_wsRay.pos, wsRay.pos);
vec[field].wsToOs.multDirMatrix(m_wsRay.dir, wsRay.dir);
}
// Pointer to mapping
const FieldMapping* m = vec[field].mapping;
// Check matrix mapping
if (const MatrixFieldMapping *mtx =
dynamic_cast<const MatrixFieldMapping*>(m)) {
intersectMatrixMapping(wsRay, mtx, vec[field].worldScale);
}
// Check frustum mapping
if (const FrustumFieldMapping *f =
dynamic_cast<const FrustumFieldMapping*>(m)) {
intersectFrustumMapping(wsRay, f, vec[field].worldScale);
}
}
}
FieldGroup::GetIntersections::intersectFrustumMapping
void intersectFrustumMapping(const Ray3d &wsRay, const FrustumFieldMapping *mtx, const float worldScale) const
Intersect frustum mapping.
Definition FieldGroup.h:1240
FieldGroup::GetIntersections::intersectMatrixMapping
void intersectMatrixMapping(const Ray3d &wsRay, const MatrixFieldMapping *mtx, const float worldScale) const
Intersect matrix mapping.
Definition FieldGroup.h:1215

References intersectFrustumMapping(), intersectMatrixMapping(), and m_wsRay.

## Member Data Documentation

## m_wsRay

template<typename BaseTypeList_T, int Dims_T>

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

Definition at line 1320 of file FieldGroup.h.

Referenced by GetIntersections(), and operator()().

## m_intervals

template<typename BaseTypeList_T, int Dims_T>

IntervalVec& FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::m_intervals

Definition at line 1321 of file FieldGroup.h.

Referenced by GetIntersections(), intersectFrustumMapping(), and intersectMatrixMapping().

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

- export/FieldGroup.h