Field3D
LinearMACFieldInterp< Data_T > Class Template Reference

#include <FieldInterp.h>

Inheritance diagram for LinearMACFieldInterp< Data_T >:
RefBase

List of all members.

Public Types

typedef LinearMACFieldInterp class_type
typedef boost::intrusive_ptr
< LinearMACFieldInterp
Ptr
typedef Data_T value_type

Public Member Functions

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

Static Public Member Functions

static const char * classType ()
 classType for RTTI replacement
static const char * staticClassName ()

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS

Private Types

typedef RefBase base
 Convenience typedef for referring to base class.

Static Private Attributes

static TemplatedFieldType
< LinearMACFieldInterp< Data_T > > 
ms_classType

Detailed Description

template<class Data_T>
class LinearMACFieldInterp< Data_T >

Definition at line 312 of file FieldInterp.h.


Member Typedef Documentation

template<class Data_T >
typedef Data_T LinearMACFieldInterp< Data_T >::value_type

Definition at line 318 of file FieldInterp.h.

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

Reimplemented from RefBase.

Definition at line 319 of file FieldInterp.h.

template<class Data_T >
typedef LinearMACFieldInterp LinearMACFieldInterp< Data_T >::class_type

Definition at line 323 of file FieldInterp.h.

template<class Data_T >
typedef RefBase LinearMACFieldInterp< Data_T >::base [private]

Convenience typedef for referring to base class.

Definition at line 354 of file FieldInterp.h.


Member Function Documentation

template<class Data_T >
static const char* LinearMACFieldInterp< Data_T >::staticClassName ( ) [inline, static]

Definition at line 326 of file FieldInterp.h.

  {
    return "LinearMACFieldInterp";
  }
template<class Data_T >
static const char* LinearMACFieldInterp< Data_T >::classType ( ) [inline, static]

classType for RTTI replacement

Reimplemented from RefBase.

Definition at line 332 of file FieldInterp.h.

References LinearMACFieldInterp< Data_T >::ms_classType, and TemplatedFieldType< Field_T >::name().

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

Definition at line 818 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 >
double LinearMACFieldInterp< Data_T >::sample ( const MACField< Data_T > &  data,
const MACComponent comp,
const V3d vsP 
) const

Definition at line 941 of file FieldInterp.h.

References FieldRes::dataWindow(), MACCompU, MACCompV, MACCompW, 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();

  double ret = 0.0;
  FIELD3D_VEC3_T<double> p;
  V3i c1, c2;
  FIELD3D_VEC3_T<double> f1;
  FIELD3D_VEC3_T<double> f2;

  switch(comp) {
    // U component ---
    case MACCompU:
    {
      p.setValue<>(vsP.x, vsP.y-0.5, 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 + 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 = (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))));
      break;
    }
    // Y component ---
    case MACCompV:
    {
      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 = (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))));
      break;
    }
    // W component ---
    case MACCompW:
    {  
      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 = (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))));
      break;
    }
    default:
      break;
  }

  return ret;
}

Member Data Documentation

template<class Data_T >
LinearMACFieldInterp< Data_T >::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 324 of file FieldInterp.h.

template<class Data_T >
TemplatedFieldType<LinearMACFieldInterp<Data_T> > LinearMACFieldInterp< Data_T >::ms_classType [static, private]

Definition at line 349 of file FieldInterp.h.

Referenced by LinearMACFieldInterp< Data_T >::classType().


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