Field3D
LinearMACFieldInterp Class Reference

#include <FieldInterp.h>

Inheritance diagram for LinearMACFieldInterp:
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

Member Typedef Documentation

Definition at line 318 of file FieldInterp.h.

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

Reimplemented from RefBase.

Definition at line 319 of file FieldInterp.h.

Convenience typedef for referring to base class.

Definition at line 354 of file FieldInterp.h.


Member Function Documentation

static const char* LinearMACFieldInterp::staticClassName ( ) [inline, static]

Definition at line 326 of file FieldInterp.h.

  {
    return "LinearMACFieldInterp";
  }
static const char* LinearMACFieldInterp::classType ( ) [inline, static]

classType for RTTI replacement

Reimplemented from RefBase.

Definition at line 332 of file FieldInterp.h.

References ms_classType, and TemplatedFieldType::name().

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

Definition at line 818 of file FieldInterp.h.

References MACField::u(), MACField::v(), and MACField::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;
}
double LinearMACFieldInterp::sample ( const MACField< Data_T > &  data,
const MACComponent comp,
const V3d vsP 
) const

Definition at line 941 of file FieldInterp.h.

References MACCompU, MACField::u(), MACCompV, MACField::v(), MACCompW, and MACField::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

Definition at line 349 of file FieldInterp.h.

Referenced by classType().


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