Field3D
MinMaxUtil.h File Reference

Contains MIP-related utility functions. More...

#include <vector>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include "MIPUtil.h"
#include "ns.h"

Go to the source code of this file.

Functions

template<typename MIPField_T >
FIELD3D_NAMESPACE_OPEN std::pair< typename MIPField_T::Ptr, typename MIPField_T::Ptr > makeMinMax (const typename MIPField_T::NestedType &base, const float resMult, const size_t numThreads)
 Constructs a min/max MIP representation of the given field. More...
 
template<typename MIPField_T >
std::pair< typename MIPField_T::Ptr, typename MIPField_T::Ptr > makeMinMax (const typename MIPField_T::NestedType &base, const float resMult, const size_t numThreads)
 Constructs a min/max MIP representation of the given field. More...
 

Variables

const char * k_maxSuffix
 The standard 'max' suffix - "_max". More...
 
const char * k_minSuffix
 The standard 'min' suffix - "_min". More...
 

Detailed Description

Contains MIP-related utility functions.

Definition in file MinMaxUtil.h.

Function Documentation

◆ makeMinMax() [1/2]

template<typename MIPField_T >
FIELD3D_NAMESPACE_OPEN std::pair<typename MIPField_T::Ptr, typename MIPField_T::Ptr> makeMinMax ( const typename MIPField_T::NestedType &  base,
const float  resMult,
const size_t  numThreads 
)

Constructs a min/max MIP representation of the given field.

Definition at line 88 of file MinMaxUtil.h.

90 {
91  typedef typename MIPField_T::Ptr MipPtr;
92  typedef typename MIPField_T::NestedType Field;
93  typedef typename MIPField_T::NestedType::Ptr FieldPtr;
94 
95  // Storage for results
96  std::pair<MipPtr, MipPtr> result;
97 
98  // First, downsample the field into a min and max representation ---
99 
100  V3i srcRes = base.dataWindow().size() + Field3D::V3i(1);
101  V3i res = V3f(srcRes) * std::min(1.0f, resMult);
102 
103  // Corner case handling
104  res.x = std::max(res.x, 2);
105  res.y = std::max(res.y, 2);
106  res.z = std::max(res.z, 2);
107 
108  // Storage for min/max fields
109  FieldPtr minSrc(new Field);
110  FieldPtr maxSrc(new Field);
111 
112  // Resample
113  resample(base, *minSrc, res, MinFilter());
114  resample(base, *maxSrc, res, MaxFilter());
115 
116  // Second, generate MIP representations ---
117 
118  result.first = makeMIP<MIPField_T, MinFilter>(*minSrc, 2, numThreads);
119  result.second = makeMIP<MIPField_T, MaxFilter>(*maxSrc, 2, numThreads);
120 
121  return result;
122 }

References FieldRes::dataWindow(), detail::max(), detail::min(), and resample().

◆ makeMinMax() [2/2]

template<typename MIPField_T >
std::pair<typename MIPField_T::Ptr, typename MIPField_T::Ptr> makeMinMax ( const typename MIPField_T::NestedType &  base,
const float  resMult,
const size_t  numThreads 
)

Constructs a min/max MIP representation of the given field.

Definition at line 88 of file MinMaxUtil.h.

90 {
91  typedef typename MIPField_T::Ptr MipPtr;
92  typedef typename MIPField_T::NestedType Field;
93  typedef typename MIPField_T::NestedType::Ptr FieldPtr;
94 
95  // Storage for results
96  std::pair<MipPtr, MipPtr> result;
97 
98  // First, downsample the field into a min and max representation ---
99 
100  V3i srcRes = base.dataWindow().size() + Field3D::V3i(1);
101  V3i res = V3f(srcRes) * std::min(1.0f, resMult);
102 
103  // Corner case handling
104  res.x = std::max(res.x, 2);
105  res.y = std::max(res.y, 2);
106  res.z = std::max(res.z, 2);
107 
108  // Storage for min/max fields
109  FieldPtr minSrc(new Field);
110  FieldPtr maxSrc(new Field);
111 
112  // Resample
113  resample(base, *minSrc, res, MinFilter());
114  resample(base, *maxSrc, res, MaxFilter());
115 
116  // Second, generate MIP representations ---
117 
118  result.first = makeMIP<MIPField_T, MinFilter>(*minSrc, 2, numThreads);
119  result.second = makeMIP<MIPField_T, MaxFilter>(*maxSrc, 2, numThreads);
120 
121  return result;
122 }

References FieldRes::dataWindow(), detail::max(), detail::min(), and resample().

Variable Documentation

◆ k_minSuffix

const char* k_minSuffix

The standard 'min' suffix - "_min".

Definition at line 55 of file MinMaxUtil.cpp.

◆ k_maxSuffix

const char* k_maxSuffix

The standard 'max' suffix - "_max".

Definition at line 56 of file MinMaxUtil.cpp.

FieldRes::dataWindow
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:253
V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
resample
FIELD3D_NAMESPACE_OPEN bool resample(const Field_T &src, Field_T &tgt, const V3i &newRes, const FilterOp_T &filter)
Resamples the source field into the target field, such that the new data window is @dataWindow.
Definition: Resample.h:560
V3f
Imath::V3f V3f
Definition: SpiMathLib.h:73
MaxFilter
Definition: Resample.h:210
detail::max
T max(const T a, const T2 b)
Max operation on mixed types.
Definition: FieldSampler.h:32
Field
Definition: Field.h:390
detail::min
T min(const T a, const T2 b)
Min operation on mixed types.
Definition: FieldSampler.h:25
MinFilter
Definition: Resample.h:154