Field3D
FieldMapping.h File Reference

Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses. More...

#include <vector>
#include <algorithm>
#include "Curve.h"
#include "Exception.h"
#include "RefCount.h"
#include "Types.h"
#include "ns.h"

Go to the source code of this file.

Classes

class  FieldMapping
 Base class for mapping between world-, local- and voxel coordinates. More...
 
class  FrustumFieldMapping
 Represents the mapping of a field by a perspective transform. More...
 
class  MatrixFieldMapping
 Represents the mapping of a field by a matrix transform. More...
 
class  NullFieldMapping
 Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0..1] in all axes. More...
 

Functions

void transformBounds (const M44d &mtx, const Box3d &fromBounds, Box3d &toBounds)
 Transforms a bounding box by a 4x4 matrix This is done by transforming each corner vertex from world to voxel space and bounding the result.
 
void worldToVoxel (const Field3D::FieldMapping *mapping, const Box3d &wsBounds, Box3d &vsBounds)
 Computes a voxel space bounds given a bounding box in world space. This is done by transforming each corner vertex from world to voxel space and bounding the result.
 

Detailed Description

Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses.

Definition in file FieldMapping.h.

Function Documentation

◆ worldToVoxel()

void worldToVoxel ( const Field3D::FieldMapping * mapping,
const Box3d & wsBounds,
Box3d & vsBounds )

Computes a voxel space bounds given a bounding box in world space. This is done by transforming each corner vertex from world to voxel space and bounding the result.

Todo
Make this integrate over time

Definition at line 173 of file FieldMapping.cpp.

176{
177 V3d test1, test2;
178 mapping->worldToVoxel(test1, test2);
180 V3d wsVerts[] = {
181 V3d(wsBounds.min.x, wsBounds.min.y, wsBounds.min.z),
182 V3d(wsBounds.max.x, wsBounds.min.y, wsBounds.min.z),
183 V3d(wsBounds.min.x, wsBounds.max.y, wsBounds.min.z),
184 V3d(wsBounds.max.x, wsBounds.max.y, wsBounds.min.z),
185 V3d(wsBounds.min.x, wsBounds.min.y, wsBounds.max.z),
186 V3d(wsBounds.max.x, wsBounds.min.y, wsBounds.max.z),
187 V3d(wsBounds.min.x, wsBounds.max.y, wsBounds.max.z),
188 V3d(wsBounds.max.x, wsBounds.max.y, wsBounds.max.z)
189 };
190 vsBounds.makeEmpty();
191 V3d vsP;
192 for (int i = 0; i < 8; i++) {
193 mapping->worldToVoxel(wsVerts[i], vsP);
194 vsBounds.extendBy(vsP);
195 }
196}
Imath::V3d V3d
Definition SpiMathLib.h:74
#define FIELD3D_MTX_T
Definition StdMathLib.h:99

References FIELD3D_MTX_T.

Referenced by FieldSampler< WrapperVec_T, Dims_T >::getMinMax(), FieldSampler< WrapperVec_T, Dims_T >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, Dims_T >::getMinMaxPrefilt().

◆ transformBounds()

void transformBounds ( const M44d & mtx,
const Box3d & fromBounds,
Box3d & toBounds )

Transforms a bounding box by a 4x4 matrix This is done by transforming each corner vertex from world to voxel space and bounding the result.

Definition at line 200 of file FieldMapping.cpp.

203{
204 V3d verts[] = {
205 V3d(fromBounds.min.x, fromBounds.min.y, fromBounds.min.z),
206 V3d(fromBounds.max.x, fromBounds.min.y, fromBounds.min.z),
207 V3d(fromBounds.min.x, fromBounds.max.y, fromBounds.min.z),
208 V3d(fromBounds.max.x, fromBounds.max.y, fromBounds.min.z),
209 V3d(fromBounds.min.x, fromBounds.min.y, fromBounds.max.z),
210 V3d(fromBounds.max.x, fromBounds.min.y, fromBounds.max.z),
211 V3d(fromBounds.min.x, fromBounds.max.y, fromBounds.max.z),
212 V3d(fromBounds.max.x, fromBounds.max.y, fromBounds.max.z)
213 };
214 toBounds.makeEmpty();
215 V3d toP;
216 for (int i = 0; i < 8; i++) {
217 mtx.multVecMatrix(verts[i], toP);
218 toBounds.extendBy(toP);
219 }
220}

References FIELD3D_MTX_T.

Referenced by FieldSampler< WrapperVec_T, Dims_T >::getMinMax(), FieldSampler< WrapperVec_T, Dims_T >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, Dims_T >::getMinMaxPrefilt().