Field3D
LinearMACFieldInterp< Data_T > Class Template Reference

#include <FieldInterp.h>

Inheritance diagram for LinearMACFieldInterp< Data_T >:
RefBase

Public Types

typedef LinearMACFieldInterp class_type
 
typedef boost::intrusive_ptr< LinearMACFieldInterpPtr
 
typedef Data_T value_type
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

Public Member Functions

double sample (const MACField< Data_T > &data, const MACComponent &comp, const V3d &vsP) const
 
Data_T sample (const MACField< Data_T > &data, const V3d &vsP) const
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer.
 
size_t refcnt ()
 Used by boost::intrusive_pointer.
 
void unref () const
 Used by boost::intrusive_pointer.
 
WeakPtr weakPtr () const
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor.
 
RefBaseoperator= (const RefBase &)
 Assignment operator.
 
virtual ~RefBase ()
 Destructor.
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
 
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones.
 

Static Public Member Functions

static const charstaticClassName ()
 
static const charstaticClassType ()
 classType for RTTI replacement
 
- Static Public Member Functions inherited from RefBase
static const charstaticClassType ()
 

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

◆ value_type

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

Definition at line 318 of file FieldInterp.h.

◆ Ptr

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

Definition at line 319 of file FieldInterp.h.

◆ class_type

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

Definition at line 323 of file FieldInterp.h.

◆ base

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

◆ staticClassName()

template<class Data_T >
static const char * LinearMACFieldInterp< Data_T >::staticClassName ( )
inlinestatic

Definition at line 326 of file FieldInterp.h.

327 {
328 return "LinearMACFieldInterp";
329 }

◆ staticClassType()

template<class Data_T >
static const char * LinearMACFieldInterp< Data_T >::staticClassType ( )
inlinestatic

classType for RTTI replacement

Definition at line 332 of file FieldInterp.h.

333 {
334 return ms_classType.name();
335 }
static TemplatedFieldType< LinearMACFieldInterp< Data_T > > ms_classType
const char * name()
Definition Traits.h:284

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

◆ sample() [1/2]

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.

820{
821 // Pixel centers are at .5 coordinates
822 // NOTE: Don't use contToDisc for this, we're looking for sample
823 // point locations, not coordinate shifts.
824
825 const Box3i &dataWindow = data.dataWindow();
826
827 Data_T ret;
828
829 FIELD3D_VEC3_T<double> p(vsP.x , vsP.y - 0.5, vsP.z - 0.5);
830
831 // X component ---
832
833 // Lower left corner
834 V3i c1(static_cast<int>(floor(p.x)),
835 static_cast<int>(floor(p.y)),
836 static_cast<int>(floor(p.z)));
837
838 // Upper right corner
839 V3i c2(c1 + V3i(1));
840
841 // C1 fractions
843 // C2 fraction
845
846 // Clamp the coordinates
847 c1.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c1.x));
848 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
849 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
850 c2.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c2.x));
851 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
852 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
853
854 ret.x = (f1.x * (f1.y * (f1.z * data.u(c1.x, c1.y, c1.z) +
855 f2.z * data.u(c1.x, c1.y, c2.z)) +
856 f2.y * (f1.z * data.u(c1.x, c2.y, c1.z) +
857 f2.z * data.u(c1.x, c2.y, c2.z))) +
858 f2.x * (f1.y * (f1.z * data.u(c2.x, c1.y, c1.z) +
859 f2.z * data.u(c2.x, c1.y, c2.z)) +
860 f2.y * (f1.z * data.u(c2.x, c2.y, c1.z) +
861 f2.z * data.u(c2.x, c2.y, c2.z))));
862
863 // Y component ---
864
865 p.setValue(vsP.x - 0.5, vsP.y , vsP.z - 0.5);
866
867 // Lower left corner
868 c1.x = static_cast<int>(floor(p.x ));
869 c1.y = static_cast<int>(floor(p.y ));
870 c1.z = static_cast<int>(floor(p.z ));
871
872 // Upper right corner
873 c2.x = c1.x + 1;
874 c2.y = c1.y + 1;
875 c2.z = c1.z + 1;
876
877 // C1 fractions
878 f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
879 // C2 fraction
880 f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
881
882 // Clamp the coordinates
883 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
884 c1.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c1.y));
885 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
886 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
887 c2.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c2.y));
888 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
889
890 ret.y = (f1.x * (f1.y * (f1.z * data.v(c1.x, c1.y, c1.z) +
891 f2.z * data.v(c1.x, c1.y, c2.z)) +
892 f2.y * (f1.z * data.v(c1.x, c2.y, c1.z) +
893 f2.z * data.v(c1.x, c2.y, c2.z))) +
894 f2.x * (f1.y * (f1.z * data.v(c2.x, c1.y, c1.z) +
895 f2.z * data.v(c2.x, c1.y, c2.z)) +
896 f2.y * (f1.z * data.v(c2.x, c2.y, c1.z) +
897 f2.z * data.v(c2.x, c2.y, c2.z))));
898
899 // Z component ---
900
901 p.setValue(vsP.x - 0.5 , vsP.y - 0.5, vsP.z);
902
903 // Lower left corner
904 c1.x = static_cast<int>(floor(p.x ));
905 c1.y = static_cast<int>(floor(p.y ));
906 c1.z = static_cast<int>(floor(p.z ));
907
908 // Upper right corner
909 c2.x = c1.x + 1;
910 c2.y = c1.y + 1;
911 c2.z = c1.z + 1;
912
913 // C1 fractions
914 f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
915 // C2 fraction
916 f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
917
918 // Clamp the coordinates
919 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
920 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
921 c1.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c1.z));
922 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
923 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
924 c2.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c2.z));
925
926 ret.z = (f1.x * (f1.y * (f1.z * data.w(c1.x, c1.y, c1.z) +
927 f2.z * data.w(c1.x, c1.y, c2.z)) +
928 f2.y * (f1.z * data.w(c1.x, c2.y, c1.z) +
929 f2.z * data.w(c1.x, c2.y, c2.z))) +
930 f2.x * (f1.y * (f1.z * data.w(c2.x, c1.y, c1.z) +
931 f2.z * data.w(c2.x, c1.y, c2.z)) +
932 f2.y * (f1.z * data.w(c2.x, c2.y, c1.z) +
933 f2.z * data.w(c2.x, c2.y, c2.z))));
934
935 return ret;
936}
Imath::V3i V3i
Definition SpiMathLib.h:71
Imath::Box3i Box3i
Definition SpiMathLib.h:77
#define FIELD3D_MTX_T
Definition StdMathLib.h:99
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
const real_t & w(int i, int j, int k) const
Read access to value on w-facing wall.
Definition MACField.h:774
const real_t & u(int i, int j, int k) const
Read access to value on u-facing wall.
Definition MACField.h:698
const real_t & v(int i, int j, int k) const
Read access to value on v-facing wall.
Definition MACField.h:736
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition CoordSys.h:104

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

◆ sample() [2/2]

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.

944{
945 // Pixel centers are at .5 coordinates
946 // NOTE: Don't use contToDisc for this, we're looking for sample
947 // point locations, not coordinate shifts.
948
949 const Box3i &dataWindow = data.dataWindow();
950
951 double ret = 0.0;
953 V3i c1, c2;
956
957 switch(comp) {
958 // U component ---
959 case MACCompU:
960 {
961 p.setValue<>(vsP.x, vsP.y-0.5, vsP.z-0.5);
962
963 // Lower left corner
964 c1.x = static_cast<int>(floor(p.x));
965 c1.y = static_cast<int>(floor(p.y));
966 c1.z = static_cast<int>(floor(p.z));
967
968 // Upper right corner
969 c2.x = c1.x + 1;
970 c2.y = c1.y + 1;
971 c2.z = c1.z + 1;
972
973 // C1 fractions
974 f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
975 // C2 fraction
976 f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
977
978 // Clamp the coordinates
979 c1.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c1.x));
980 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
981 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
982 c2.x = std::min(dataWindow.max.x + 1, std::max(dataWindow.min.x, c2.x));
983 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
984 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
985
986 ret = (f1.x * (f1.y * (f1.z * data.u(c1.x, c1.y, c1.z) +
987 f2.z * data.u(c1.x, c1.y, c2.z)) +
988 f2.y * (f1.z * data.u(c1.x, c2.y, c1.z) +
989 f2.z * data.u(c1.x, c2.y, c2.z))) +
990 f2.x * (f1.y * (f1.z * data.u(c2.x, c1.y, c1.z) +
991 f2.z * data.u(c2.x, c1.y, c2.z)) +
992 f2.y * (f1.z * data.u(c2.x, c2.y, c1.z) +
993 f2.z * data.u(c2.x, c2.y, c2.z))));
994 break;
995 }
996 // Y component ---
997 case MACCompV:
998 {
999 p.setValue(vsP.x-0.5, vsP.y, vsP.z-0.5);
1000
1001 // Lower left corner
1002 c1.x = static_cast<int>(floor(p.x ));
1003 c1.y = static_cast<int>(floor(p.y ));
1004 c1.z = static_cast<int>(floor(p.z ));
1005
1006 // Upper right corner
1007 c2.x = c1.x + 1;
1008 c2.y = c1.y + 1;
1009 c2.z = c1.z + 1;
1010
1011 // C1 fractions
1012 f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
1013 // C2 fraction
1014 f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
1015
1016 // Clamp the coordinates
1017 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
1018 c1.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c1.y));
1019 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
1020 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
1021 c2.y = std::min(dataWindow.max.y + 1, std::max(dataWindow.min.y, c2.y));
1022 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
1023
1024 ret = (f1.x * (f1.y * (f1.z * data.v(c1.x, c1.y, c1.z) +
1025 f2.z * data.v(c1.x, c1.y, c2.z)) +
1026 f2.y * (f1.z * data.v(c1.x, c2.y, c1.z) +
1027 f2.z * data.v(c1.x, c2.y, c2.z))) +
1028 f2.x * (f1.y * (f1.z * data.v(c2.x, c1.y, c1.z) +
1029 f2.z * data.v(c2.x, c1.y, c2.z)) +
1030 f2.y * (f1.z * data.v(c2.x, c2.y, c1.z) +
1031 f2.z * data.v(c2.x, c2.y, c2.z))));
1032 break;
1033 }
1034 // W component ---
1035 case MACCompW:
1036 {
1037 p.setValue(vsP.x-0.5, vsP.y-0.5, vsP.z);
1038
1039 // Lower left corner
1040 c1.x = static_cast<int>(floor(p.x ));
1041 c1.y = static_cast<int>(floor(p.y ));
1042 c1.z = static_cast<int>(floor(p.z ));
1043
1044 // Upper right corner
1045 c2.x = c1.x + 1;
1046 c2.y = c1.y + 1;
1047 c2.z = c1.z + 1;
1048
1049 // C1 fractions
1050 f1.setValue(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
1051 // C2 fraction
1052 f2.setValue(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
1053
1054 // Clamp the coordinates
1055 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
1056 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
1057 c1.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c1.z));
1058 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
1059 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
1060 c2.z = std::min(dataWindow.max.z + 1, std::max(dataWindow.min.z, c2.z));
1061
1062 ret = (f1.x * (f1.y * (f1.z * data.w(c1.x, c1.y, c1.z) +
1063 f2.z * data.w(c1.x, c1.y, c2.z)) +
1064 f2.y * (f1.z * data.w(c1.x, c2.y, c1.z) +
1065 f2.z * data.w(c1.x, c2.y, c2.z))) +
1066 f2.x * (f1.y * (f1.z * data.w(c2.x, c1.y, c1.z) +
1067 f2.z * data.w(c2.x, c1.y, c2.z)) +
1068 f2.y * (f1.z * data.w(c2.x, c2.y, c1.z) +
1069 f2.z * data.w(c2.x, c2.y, c2.z))));
1070 break;
1071 }
1072 default:
1073 break;
1074 }
1075
1076 return ret;
1077}
@ MACCompV
Definition MACField.h:73
@ MACCompU
Definition MACField.h:72
@ MACCompW
Definition MACField.h:74

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

Member Data Documentation

◆ DEFINE_FIELD_RTTI_CONCRETE_CLASS

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

Definition at line 324 of file FieldInterp.h.

◆ ms_classType

template<class Data_T >
TemplatedFieldType<LinearMACFieldInterp<Data_T> > LinearMACFieldInterp< Data_T >::ms_classType
staticprivate

Definition at line 349 of file FieldInterp.h.

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


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