44#ifndef _INCLUDED_Field3D_MIPUtil_H_
45#define _INCLUDED_Field3D_MIPUtil_H_
51#include <boost/thread/thread.hpp>
52#include <boost/thread/mutex.hpp>
75template <
typename MIPField_T,
typename Filter_T>
76typename MIPField_T::Ptr
77makeMIP(
const typename MIPField_T::NestedType &base,
const int minSize,
81template <
typename MIPField_T,
typename Filter_T>
82typename MIPField_T::Ptr
83makeMIP(
const typename MIPField_T::NestedType &base,
const int minSize,
120 template <
typename Data_T>
127 template <
typename Data_T>
130 return f.blockSize();
135 template <
typename Data_T>
141 const int intSupport =
static_cast<int>(std::ceil(support * 0.5));
154 static boost::mutex
mutex;
155 boost::mutex::scoped_lock lock(
mutex);
161 if (
src.blockIsAllocated(
i,
j,
k) ||
162 src.getBlockEmptyValue(
i,
j,
k) !=
static_cast<Data_T
>(0)) {
176 template <
typename Field_T>
178 const Box3i &,
const float ,
186 template <
typename Field_T,
typename FilterOp_T,
bool IsAnalytic_T>
189 typedef typename Field_T::value_type
T;
195 const std::vector<Box3i> &blocks,
216 typedef typename Field_T::value_type Data_T;
232 boost::mutex::scoped_lock lock(
m_mutex);
243 for (
int k =
box.min.z;
k <=
box.max.z; ++
k) {
244 for (
int j =
box.min.y;
j <=
box.max.y; ++
j) {
245 for (
int i =
box.min.x;
i <=
box.max.x; ++
i) {
255 static_cast<int>(std::ceil(
curSrc + support *
292 static_cast<int>(std::ceil(
curSrc + support *
326 boost::mutex::scoped_lock lock(
m_mutex);
353 template <
typename Field_T,
typename FilterOp_T>
368 }
else if (
dim == 1) {
381 std::vector<Box3i> blocks;
382 for (
int k = 0;
k <
res.z;
k += blockSize) {
383 for (
int j = 0;
j <
res.y;
j += blockSize) {
384 for (
int i = 0;
i <
res.x;
i += blockSize) {
390 box.max.x = std::min(
box.max.x,
res.x - 1);
391 box.max.y = std::min(
box.max.y,
res.y - 1);
392 box.max.z = std::min(
box.max.z,
res.z - 1);
394 blocks.push_back(
box);
420 template <
typename Field_T,
typename FilterOp_T>
430 (
offset.y % 2 == 0) ? 0 : 1,
431 (
offset.z % 2 == 0) ? 0 : 1);
453 tgt.name = base.name;
454 tgt.attribute = base.attribute;
455 tgt.setMapping(base.mapping());
456 tgt.copyMetadata(base);
464 const Box3i &extents,
475template <
typename MIPField_T,
typename Filter_T>
476typename MIPField_T::Ptr
488template <
typename MIPField_T,
typename Filter_T>
489typename MIPField_T::Ptr
493 using namespace Field3D::detail;
495 typedef typename MIPField_T::value_type Data_T;
496 typedef typename MIPField_T::NestedType
Src_T;
497 typedef typename Src_T::Ptr
SrcPtr;
498 typedef typename MIPField_T::Ptr
MIPPtr;
499 typedef std::vector<typename Src_T::Ptr>
SrcVec;
501 if (base.extents() != base.dataWindow()) {
510 V3i res = base.extents().size() +
V3i(1);
526 for (
int i = 0;
i < 3; ++
i) {
538 mipField->attribute = base.attribute;
Box3i clipBounds(const Box3i &bbox, const Box3i &bounds)
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
MIPField_T::Ptr makeMIP(const typename MIPField_T::NestedType &base, const int minSize, const V3i &offset, const size_t numThreads)
Constructs a MIP representation of the given field, with optional offset vector. The offset vector in...
FIELD3D_NAMESPACE_OPEN V3i computeOffset(const FieldRes &f)
Computes the origin/offset of a field.
Contains functions for resampling fields.
Contains the SparseField class.
Box3i blockCoords(const Box3i &dvsBounds, const SparseField< Data_T > *f)
FIELD3D_NAMESPACE_OPENtypedef ::half half
Contains typedefs for the commonly used types in Field3D.
This subclass of Field stores data in a contiguous std::vector.
boost::intrusive_ptr< FieldMapping > Ptr
This Field subclass stores voxel data in block-allocated arrays.
const std::string k_mipOffsetStr
void mipSeparable(const Field_T &src, Field_T &tgt, const V3i &oldRes, const V3i &newRes, const size_t level, const V3i &add, const FilterOp_T &filterOp, const size_t dim, const size_t numThreads)
Threaded implementation of separable MIP filtering.
size_t threadingBlockSize(const DenseField< Data_T > &)
Constant size for all dense fields.
FIELD3D_API V3i mipResolution(const V3i &baseRes, const size_t level, const V3i &add)
void mipResample(const Field_T &base, const Field_T &src, Field_T &tgt, const size_t level, const V3i &offset, const FilterOp_T &filterOp, const size_t numThreads)
FIELD3D_API FieldMapping::Ptr adjustedMIPFieldMapping(const FieldRes *base, const V3i &baseRes, const Box3i &extents, const size_t level)
bool checkInputEmpty(const SparseField< Data_T > &src, const SparseField< Data_T > &, const Box3i &tgtBox, const float support, const size_t dim)
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Used to delegate the choice of bit depth to process at.
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)
const std::vector< Box3i > & m_blocks
const FilterOp_T & m_filterOp