Field3D
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

IntervalVecm_intervals
 
const Ray3dm_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.

1210 : m_wsRay(wsRay), m_intervals(intervals)
1211 {
1212
1213 }

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.

1218 {
1219 using std::min;
1220
1221 const float time = 0.0f;
1222
1223 // Transform ray to local space for intersection test
1224 Ray3d lsRay;
1225 mtx->worldToLocal(wsRay.pos, lsRay.pos, time);
1226 mtx->worldToLocalDir(wsRay.dir, lsRay.dir);
1227 // Use unit bounding box to intersect against
1228 Box3d lsBBox(V3d(0.0), V3d(1.0));
1229 // Calculate intersection points
1230 double t0, t1;
1231 // Add the interval if the ray intersects the box
1232 if (detail::intersect(lsRay, lsBBox, t0, t1)) {
1233 const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
1234 const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
1235 wsVoxelSize.z);
1236 m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
1237 }
1238 }
Imath::Box3d Box3d
Definition SpiMathLib.h:79
Imath::V3d V3d
Definition SpiMathLib.h:74
Imath::Line3d Ray3d
Definition StdMathLib.h:94
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
bool intersect(const Ray3d &ray, const Box3d &box, double &outT0, double &outT1)
Definition FieldGroup.h:245
T min(const T a, const T2 b)
Min operation on mixed types.
Represents a single integration interval. The interval is assumed to be inclusive,...
Definition Types.h:66

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

◆ 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.

1243 {
1244 using std::min;
1245
1246 typedef std::vector<V3d> PointVec;
1247
1248 const float time = 0.0f;
1249
1250 // Get the eight corners of the local space bounding box
1251 Box3d lsBounds(V3d(0.0), V3d(1.0));
1252 PointVec lsCorners = detail::cornerPoints(lsBounds);
1253 // Get the world space positions of the eight corners of the frustum
1254 PointVec wsCorners(lsCorners.size());
1255 for (PointVec::iterator lsP = lsCorners.begin(), wsP = wsCorners.begin(),
1256 end = lsCorners.end(); lsP != end; ++lsP, ++wsP) {
1257 mtx->localToWorld(*lsP, *wsP, time);
1258 }
1259
1260 // Construct plane for each face of frustum
1261 Plane3d planes[6];
1262 planes[0] = Plane3d(wsCorners[4], wsCorners[0], wsCorners[6]);
1263 planes[1] = Plane3d(wsCorners[1], wsCorners[5], wsCorners[3]);
1264 planes[2] = Plane3d(wsCorners[4], wsCorners[5], wsCorners[0]);
1265 planes[3] = Plane3d(wsCorners[2], wsCorners[3], wsCorners[6]);
1266 planes[4] = Plane3d(wsCorners[0], wsCorners[1], wsCorners[2]);
1267 planes[5] = Plane3d(wsCorners[5], wsCorners[4], wsCorners[7]);
1268
1269 // Intersect ray against planes
1270 double t0 = -std::numeric_limits<double>::max();
1271 double t1 = std::numeric_limits<double>::max();
1272 for (int i = 0; i < 6; ++i) {
1273 double t;
1274 const Plane3d &p = planes[i];
1275 if (p.intersectT(wsRay, t)) {
1276 if (wsRay.dir.dot(p.normal) > 0.0) {
1277 // Non-opposing plane
1278 t1 = std::min(t1, t);
1279 } else {
1280 // Opposing plane
1281 t0 = std::max(t0, t);
1282 }
1283 }
1284 }
1285 if (t0 < t1) {
1286 t0 = std::max(t0, 0.0);
1287 const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
1288 const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
1289 wsVoxelSize.z);
1290 m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
1291 }
1292 }
Imath::Plane3d Plane3d
Definition SpiMathLib.h:83
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
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:211

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

◆ 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.

1296 {
1297 // Intersect the ray against all the fields
1298 for (size_t field = 0, end = vec.size(); field < end; ++field) {
1299 // Check object space transform
1300 Ray3d wsRay = m_wsRay;
1301 if (vec[field].doOsToWs) {
1302 vec[field].wsToOs.multVecMatrix(m_wsRay.pos, wsRay.pos);
1303 vec[field].wsToOs.multDirMatrix(m_wsRay.dir, wsRay.dir);
1304 }
1305 // Pointer to mapping
1306 const FieldMapping* m = vec[field].mapping;
1307 // Check matrix mapping
1308 if (const MatrixFieldMapping *mtx =
1309 dynamic_cast<const MatrixFieldMapping*>(m)) {
1310 intersectMatrixMapping(wsRay, mtx, vec[field].worldScale);
1311 }
1312 // Check frustum mapping
1313 if (const FrustumFieldMapping *f =
1314 dynamic_cast<const FrustumFieldMapping*>(m)) {
1315 intersectFrustumMapping(wsRay, f, vec[field].worldScale);
1316 }
1317 }
1318 }
Base class for mapping between world-, local- and voxel coordinates.
Represents the mapping of a field by a perspective transform.
Represents the mapping of a field by a matrix transform.
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.

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.

◆ 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.


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