detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T > Struct Template Reference

`#include <MIPUtil.h>`

## Public Types

typedef Field_T::value_type | T

## Public Member Functions

| MIPSeparableThreadOp (const Field_T &src, Field_T &tgt, const size_t level, const V3i &add, const FilterOp_T &filterOp, const size_t dim, const std::vector< Box3i > &blocks, size_t &nextIdx, boost::mutex &mutex)
void | operator() ()

## Private Attributes

const V3i & | m_add
const std::vector< Box3i > & | m_blocks
const size_t | m_dim
const FilterOp_T & | m_filterOp
const size_t | m_level
boost::mutex & | m_mutex
size_t & | m_nextIdx
const size_t | m_numBlocks
const Field_T & | m_src
Field_T & | m_tgt

## Detailed Description

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>
struct detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >

Definition at line 187 of file MIPUtil.h.

## Member Typedef Documentation

## T

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

typedef Field_T::value_type detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::T

Definition at line 189 of file MIPUtil.h.

## Constructor & Destructor Documentation

## MIPSeparableThreadOp()

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::MIPSeparableThreadOp | ( | const Field_T & | src,
|  | Field_T & | tgt,
|  | const size_t | level,
|  | const V3i & | add,
|  | const FilterOp_T & | filterOp,
|  | const size_t | dim,
|  | const std::vector< Box3i > & | blocks,
|  | size_t & | nextIdx,
|  | boost::mutex & | mutex )

inline

Definition at line 191 of file MIPUtil.h.

: m_src(src),
m_tgt(tgt),
m_filterOp(filterOp),
m_level(level),
m_add(add),
m_dim(dim),
m_blocks(blocks),
m_nextIdx(nextIdx),
m_mutex(mutex),
m_numBlocks(blocks.size())
{
// Empty
}
detail::MIPSeparableThreadOp
Definition MIPUtil.h:188
detail::MIPSeparableThreadOp::m_numBlocks
const size_t m_numBlocks
Definition MIPUtil.h:346
detail::MIPSeparableThreadOp::m_blocks
const std::vector< Box3i > & m_blocks
Definition MIPUtil.h:343
detail::MIPSeparableThreadOp::m_filterOp
const FilterOp_T & m_filterOp
Definition MIPUtil.h:339
detail::MIPSeparableThreadOp::m_src
const Field_T & m_src
Definition MIPUtil.h:337
detail::MIPSeparableThreadOp::m_dim
const size_t m_dim
Definition MIPUtil.h:342
detail::MIPSeparableThreadOp::m_nextIdx
size_t & m_nextIdx
Definition MIPUtil.h:344
detail::MIPSeparableThreadOp::m_add
const V3i & m_add
Definition MIPUtil.h:341
detail::MIPSeparableThreadOp::m_level
const size_t m_level
Definition MIPUtil.h:340
detail::MIPSeparableThreadOp::m_tgt
Field_T & m_tgt
Definition MIPUtil.h:338
detail::MIPSeparableThreadOp::m_mutex
boost::mutex & m_mutex
Definition MIPUtil.h:345

References m_add, m_blocks, m_dim, m_filterOp, m_level, m_mutex, m_nextIdx, m_numBlocks, m_src, and m_tgt.

## Member Function Documentation

## operator()()

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

void detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::operator() | ( |  | ) |

inline

Definition at line 211 of file MIPUtil.h.

{
using namespace std;
// Defer to ComputationType to determine the processing data type
typedef typename Field_T::value_type Data_T;
typedef typename ComputationType<Data_T>::type Value_T;
// To ensure we don't sample outside source data
Box3i srcDw = m_src.dataWindow();
// Coordinate frame conversion constants
const float tgtToSrcMult = 2.0;
const float filterCoordMult = 1.0f / (tgtToSrcMult);
// Filter info, support size in target space
const float support = m_filterOp.support();
// Get next index to process
size_t idx;
{
boost::mutex::scoped_lock lock(m_mutex);
idx = m_nextIdx;
m_nextIdx++;
}
// Keep going while there is data to process
while (idx < m_numBlocks) {
// Grab the bounds
const Box3i box = m_blocks[idx];
// Early exit if input blocks are all empty
if (!detail::checkInputEmpty(m_src, m_tgt, box, support, m_dim)) {
// For each output voxel
for (int k = box.min.z; k <= box.max.z; ++k) {
for (int j = box.min.y; j <= box.max.y; ++j) {
for (int i = box.min.x; i <= box.max.x; ++i) {
Value_T accumValue(m_filterOp.initialValue());
if (IsAnalytic_T) {
// Transform from current point in target frame to source frame
const int curTgt = V3i(i, j, k)[m_dim];
const float curSrc = discToCont(curTgt) * tgtToSrcMult - m_add[m_dim];
// Find interval
int startSrc =
static_cast<int>(std::floor(curSrc - support * tgtToSrcMult));
int endSrc =
static_cast<int>(std::ceil(curSrc + support *
tgtToSrcMult)) - 1;
// Clamp coordinates
startSrc = std::max(startSrc, srcDw.min[m_dim]);
endSrc = std::min(endSrc, srcDw.max[m_dim]);
// Loop over source voxels
for (int s = startSrc; s <= endSrc; ++s) {
// Source index
const int xIdx = m_dim == 0 ? s : i;
const int yIdx = m_dim == 1 ? s : j;
const int zIdx = m_dim == 2 ? s : k;
// Source voxel in continuous coords
const float srcP = discToCont(s);
// Compute filter weight in source space (twice as wide)
const float weight = m_filterOp.eval(std::abs(srcP - curSrc) *
filterCoordMult);
// Value
const Value_T value = m_src.fastValue(xIdx, yIdx, zIdx);
// Update
if (weight > 0.0f) {
FilterOp_T::op(accumValue, value);
}
}
// Update final value
if (accumValue !=
static_cast<Value_T>(m_filterOp.initialValue())) {
m_tgt.fastLValue(i, j, k) = accumValue;
}
} else {
float accumWeight = 0.0f;
// Transform from current point in target frame to source frame
const int curTgt = V3i(i, j, k)[m_dim];
const float curSrc = discToCont(curTgt) * tgtToSrcMult - m_add[m_dim];
// Find interval
int startSrc =
static_cast<int>(std::floor(curSrc - support * tgtToSrcMult));
int endSrc =
static_cast<int>(std::ceil(curSrc + support *
tgtToSrcMult)) - 1;
// Clamp coordinates
startSrc = std::max(startSrc, srcDw.min[m_dim]);
endSrc = std::min(endSrc, srcDw.max[m_dim]);
// Loop over source voxels
for (int s = startSrc; s <= endSrc; ++s) {
// Source index
const int xIdx = m_dim == 0 ? s : i;
const int yIdx = m_dim == 1 ? s : j;
const int zIdx = m_dim == 2 ? s : k;
// Source voxel in continuous coords
const float srcP = discToCont(s);
// Compute filter weight in source space (twice as wide)
const float weight = m_filterOp.eval(std::abs(srcP - curSrc) *
filterCoordMult);
// Value
const Value_T value = m_src.fastValue(xIdx, yIdx, zIdx);
// Update
accumWeight += weight;
accumValue += value * weight;
}
// Update final value
if (accumWeight > 0.0f &&
accumValue != static_cast<Value_T>(0.0)) {
m_tgt.fastLValue(i, j, k) = accumValue / accumWeight;
}
} // if (IsAnalytic_T)
}
}
}
} // Empty input
// Get next index
{
boost::mutex::scoped_lock lock(m_mutex);
idx = m_nextIdx;
m_nextIdx++;
}
}
}
discToCont
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
Definition Field.h:1070
V3i
Imath::V3i V3i
Definition SpiMathLib.h:71

References detail::checkInputEmpty(), discToCont(), m_add, m_blocks, m_dim, m_filterOp, m_mutex, m_nextIdx, m_numBlocks, m_src, and m_tgt.

## Member Data Documentation

## m_src

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const Field_T& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_src

private

Definition at line 337 of file MIPUtil.h.

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

## m_tgt

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

Field_T& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_tgt

private

Definition at line 338 of file MIPUtil.h.

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

## m_filterOp

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const FilterOp_T& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_filterOp

private

Definition at line 339 of file MIPUtil.h.

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

## m_level

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const size_t detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_level

private

Definition at line 340 of file MIPUtil.h.

Referenced by MIPSeparableThreadOp().

## m_add

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const V3i& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_add

private

Definition at line 341 of file MIPUtil.h.

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

## m_dim

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const size_t detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_dim

private

Definition at line 342 of file MIPUtil.h.

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

## m_blocks

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const std::vector<Box3i>& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_blocks

private

Definition at line 343 of file MIPUtil.h.

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

## m_nextIdx

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

size_t& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_nextIdx

private

Definition at line 344 of file MIPUtil.h.

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

## m_mutex

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

boost::mutex& detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_mutex

private

Definition at line 345 of file MIPUtil.h.

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

## m_numBlocks

template<typename Field_T, typename FilterOp_T, bool IsAnalytic_T>

const size_t detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::m_numBlocks

private

Definition at line 346 of file MIPUtil.h.

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

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

- export/MIPUtil.h