Field3D
LinearMACFieldInterp< Data_T > Class Template Reference

#include <FieldInterp.h>

Inheritance diagram for LinearMACFieldInterp< Data_T >:
RefBase RefBase

List of all members.

Public Types

typedef boost::intrusive_ptr
< LinearMACFieldInterp
Ptr
typedef boost::intrusive_ptr
< LinearMACFieldInterp
Ptr

Public Member Functions

Data_T sample (const MACField< Data_T > &data, const V3d &vsP) const
Data_T sample (const MACField< Data_T > &data, const V3d &vsP) const

Detailed Description

template<class Data_T>
class LinearMACFieldInterp< Data_T >

Definition at line 149 of file FieldInterp.h.


Member Typedef Documentation

template<class Data_T >
typedef boost::intrusive_ptr<LinearMACFieldInterp> LinearMACFieldInterp< Data_T >::Ptr

Reimplemented from RefBase.

Definition at line 153 of file FieldInterp.h.

template<class Data_T >
typedef boost::intrusive_ptr<LinearMACFieldInterp> LinearMACFieldInterp< Data_T >::Ptr

Reimplemented from RefBase.

Definition at line 153 of file FieldInterp.h.


Member Function Documentation

template<class Data_T >
Data_T LinearMACFieldInterp< Data_T >::sample ( const MACField< Data_T > &  data,
const V3d vsP 
) const

Definition at line 495 of file FieldInterp.h.

References FieldRes::dataWindow(), MACField< Data_T >::u(), MACField< Data_T >::v(), and MACField< Data_T >::w().

{
  // Pixel centers are at .5 coordinates
  // NOTE: Don't use contToDisc for this, we're looking for sample
  // point locations, not coordinate shifts.

  const Box3i &dataWindow = data.dataWindow();      

  Data_T ret;

  FIELD3D_VEC3_T<double> p(vsP.x , vsP.y - 0.5, vsP.z - 0.5);

  // X component ---

  // Lower left corner
  V3i c1(static_cast<int>(floor(p.x)), 
         static_cast<int>(floor(p.y)), 
         static_cast<int>(floor(p.z)));
    
  // Upper right corner
  V3i c2(c1 + V3i(1));

  // C1 fractions
  FIELD3D_VEC3_T<double> f1(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
  // C2 fraction
  FIELD3D_VEC3_T<double> f2(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);

  // Clamp the coordinates
  c1.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c1.x));
  c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
  c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
  c2.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c2.x));
  c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
  c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));

  ret.x = (f1.x * (f1.y * (f1.z * data.u(c1.x, c1.y, c1.z) +
                           f2.z * data.u(c1.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.u(c1.x, c2.y, c1.z) + 
                           f2.z * data.u(c1.x, c2.y, c2.z))) +
           f2.x * (f1.y * (f1.z * data.u(c2.x, c1.y, c1.z) + 
                           f2.z * data.u(c2.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.u(c2.x, c2.y, c1.z) + 
                           f2.z * data.u(c2.x, c2.y, c2.z))));

  // Y component ---

  p.setValue(vsP.x - 0.5, vsP.y , vsP.z - 0.5);

  // Lower left corner
  c1.x = static_cast<int>(floor(p.x ));
  c1.y = static_cast<int>(floor(p.y )); 
  c1.z = static_cast<int>(floor(p.z ));
    
  // Upper right corner
  c2.x = c1.x + 1;
  c2.y = c1.y + 1;
  c2.z = c1.z + 1;

  // C1 fractions
  f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
  // C2 fraction
  f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);

  // Clamp the coordinates
  c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
  c1.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c1.y));
  c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
  c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
  c2.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c2.y));
  c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));

  ret.y = (f1.x * (f1.y * (f1.z * data.v(c1.x, c1.y, c1.z) +
                           f2.z * data.v(c1.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.v(c1.x, c2.y, c1.z) + 
                           f2.z * data.v(c1.x, c2.y, c2.z))) +
           f2.x * (f1.y * (f1.z * data.v(c2.x, c1.y, c1.z) + 
                           f2.z * data.v(c2.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.v(c2.x, c2.y, c1.z) + 
                           f2.z * data.v(c2.x, c2.y, c2.z))));

  // Z component ---

  p.setValue(vsP.x - 0.5 , vsP.y - 0.5, vsP.z);

  // Lower left corner
  c1.x = static_cast<int>(floor(p.x ));
  c1.y = static_cast<int>(floor(p.y )); 
  c1.z = static_cast<int>(floor(p.z ));
    
  // Upper right corner
  c2.x = c1.x + 1;
  c2.y = c1.y + 1;
  c2.z = c1.z + 1;

  // C1 fractions
  f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
  // C2 fraction
  f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);

  // Clamp the coordinates
  c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
  c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
  c1.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c1.z));
  c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
  c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
  c2.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c2.z));

  ret.z = (f1.x * (f1.y * (f1.z * data.w(c1.x, c1.y, c1.z) +
                           f2.z * data.w(c1.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.w(c1.x, c2.y, c1.z) + 
                           f2.z * data.w(c1.x, c2.y, c2.z))) +
           f2.x * (f1.y * (f1.z * data.w(c2.x, c1.y, c1.z) + 
                           f2.z * data.w(c2.x, c1.y, c2.z)) +
                   f2.y * (f1.z * data.w(c2.x, c2.y, c1.z) + 
                           f2.z * data.w(c2.x, c2.y, c2.z))));

  return ret;
}
template<class Data_T >
Data_T LinearMACFieldInterp< Data_T >::sample ( const MACField< Data_T > &  data,
const V3d vsP 
) const

The documentation for this class was generated from the following files: