46#ifndef _INCLUDED_Field3D_FieldInterp_H_
47#define _INCLUDED_Field3D_FieldInterp_H_
71template <
class Data_T>
79 typedef boost::intrusive_ptr<FieldInterp>
Ptr;
135template <
class Data_T>
143 typedef boost::intrusive_ptr<LinearFieldInterp>
Ptr;
152 return "LinearFieldInterp";
194template <
class Data_T>
202 typedef boost::intrusive_ptr<CubicFieldInterp>
Ptr;
211 return "CubicFieldInterp";
252template <
class Field_T>
260 typedef boost::intrusive_ptr<LinearGenericFieldInterp>
Ptr;
269 return "LinearGenericFieldInterp";
311template <
class Data_T>
319 typedef boost::intrusive_ptr<LinearMACFieldInterp>
Ptr;
328 return "LinearMACFieldInterp";
374template <
class Field_T>
382 typedef boost::intrusive_ptr<CubicGenericFieldInterp>
Ptr;
391 return "CubicGenericFieldInterp";
433template <
class Data_T>
441 typedef boost::intrusive_ptr<CubicMACFieldInterp>
Ptr;
450 return "CubicMACFieldInterp";
492template <
class Data_T>
500 typedef boost::intrusive_ptr<ProceduralFieldLookup>
Ptr;
509 return "ProceduralFieldLookup";
545template <
class Data_T>
551 f->mapping()->worldToVoxel(
wsP,
vsP);
574template <
class S,
class T>
585template <
class Data_T>
587 const Data_T &
f3,
const Data_T &
f4,
596template <
class Data_T>
598 const Data_T &
f3,
const Data_T &
f4,
605template <
class Data_T>
615 V3i c1(
static_cast<int>(floor(
p.x)),
616 static_cast<int>(floor(
p.y)),
617 static_cast<int>(floor(
p.z)));
628 c1.x = std::max(dataWindow.min.x, std::min(
c1.x, dataWindow.max.x));
629 c2.x = std::max(dataWindow.min.x, std::min(
c2.x, dataWindow.max.x));
630 c1.y = std::max(dataWindow.min.y, std::min(
c1.y, dataWindow.max.y));
631 c2.y = std::max(dataWindow.min.y, std::min(
c2.y, dataWindow.max.y));
632 c1.z = std::max(dataWindow.min.z, std::min(
c1.z, dataWindow.max.z));
633 c2.z = std::max(dataWindow.min.z, std::min(
c2.z, dataWindow.max.z));
636 return static_cast<Data_T
>
650template <
class Data_T>
658 std::max(0.5,
vsP.y),
659 std::max(0.5,
vsP.z));
663 V3i c(
static_cast<int>(floor(
p.x)),
664 static_cast<int>(floor(
p.y)),
665 static_cast<int>(floor(
p.z)));
674 im = std::max(dataWindow.min.x, std::min(
c.x, dataWindow.max.x));
675 jm = std::max(dataWindow.min.y, std::min(
c.y, dataWindow.max.y));
676 km = std::max(dataWindow.min.z, std::min(
c.z, dataWindow.max.z));
678 im_1 = std::max(dataWindow.min.x, std::min(
im - 1, dataWindow.max.x));
679 jm_1 = std::max(dataWindow.min.y, std::min(
jm - 1, dataWindow.max.y));
680 km_1 = std::max(dataWindow.min.z, std::min(
km - 1, dataWindow.max.z));
682 im1 = std::max(dataWindow.min.x, std::min(
im + 1, dataWindow.max.x));
683 jm1 = std::max(dataWindow.min.y, std::min(
jm + 1, dataWindow.max.y));
684 km1 = std::max(dataWindow.min.z, std::min(
km + 1, dataWindow.max.z));
686 im2 = std::max(dataWindow.min.x, std::min(
im + 2, dataWindow.max.x));
687 jm2 = std::max(dataWindow.min.y, std::min(
jm + 2, dataWindow.max.y));
688 km2 = std::max(dataWindow.min.z, std::min(
km + 2, dataWindow.max.z));
771template <
class Field_T>
772typename Field_T::value_type
776 typedef typename Field_T::value_type Data_T;
784 V3i c1(
static_cast<int>(floor(
p.x)),
785 static_cast<int>(floor(
p.y)),
786 static_cast<int>(floor(
p.z)));
794 const Box3i &dataWindow = data.dataWindow();
797 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x,
c1.x));
798 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y,
c1.y));
799 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z,
c1.z));
800 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x,
c2.x));
801 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y,
c2.y));
802 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z,
c2.z));
804 return static_cast<Data_T
>
805 (
f1.x * (
f1.y * (
f1.z * data.fastValue(
c1.x,
c1.y,
c1.z) +
806 f2.z * data.fastValue(
c1.x,
c1.y,
c2.z)) +
807 f2.y * (
f1.z * data.fastValue(
c1.x,
c2.y,
c1.z) +
808 f2.z * data.fastValue(
c1.x,
c2.y,
c2.z))) +
809 f2.x * (
f1.y * (
f1.z * data.fastValue(
c2.x,
c1.y,
c1.z) +
810 f2.z * data.fastValue(
c2.x,
c1.y,
c2.z)) +
811 f2.y * (
f1.z * data.fastValue(
c2.x,
c2.y,
c1.z) +
812 f2.z * data.fastValue(
c2.x,
c2.y,
c2.z))));
817template <
class Data_T>
834 V3i c1(
static_cast<int>(floor(
p.x)),
835 static_cast<int>(floor(
p.y)),
836 static_cast<int>(floor(
p.z)));
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));
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 ));
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));
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 ));
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));
940template <
class Data_T>
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));
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));
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 ));
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));
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 ));
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));
1081template <
class Field_T>
1082typename Field_T::value_type
1086 typedef typename Field_T::value_type Data_T;
1092 std::max(0.5,
vsP.y),
1093 std::max(0.5,
vsP.z));
1096 const Box3i &dataWindow = data.dataWindow();
1099 V3i c(
static_cast<int>(floor(
p.x)),
1100 static_cast<int>(floor(
p.y)),
1101 static_cast<int>(floor(
p.z)));
1108 im = std::max(dataWindow.min.x, std::min(
c.x, dataWindow.max.x));
1109 jm = std::max(dataWindow.min.y, std::min(
c.y, dataWindow.max.y));
1110 km = std::max(dataWindow.min.z, std::min(
c.z, dataWindow.max.z));
1112 im_1 = std::max(dataWindow.min.x, std::min(
im - 1, dataWindow.max.x));
1113 jm_1 = std::max(dataWindow.min.y, std::min(
jm - 1, dataWindow.max.y));
1114 km_1 = std::max(dataWindow.min.z, std::min(
km - 1, dataWindow.max.z));
1116 im1 = std::max(dataWindow.min.x, std::min(
im + 1, dataWindow.max.x));
1117 jm1 = std::max(dataWindow.min.y, std::min(
jm + 1, dataWindow.max.y));
1118 km1 = std::max(dataWindow.min.z, std::min(
km + 1, dataWindow.max.z));
1120 im2 = std::max(dataWindow.min.x, std::min(
im + 2, dataWindow.max.x));
1121 jm2 = std::max(dataWindow.min.y, std::min(
jm + 2, dataWindow.max.y));
1122 km2 = std::max(dataWindow.min.z, std::min(
km + 2, dataWindow.max.z));
1146 data.fastValue(
im,
jm,
km),
1204template <
class Data_T>
1208 typedef typename Data_T::BaseType T;
1221 std::max(0.5,
vsP.y),
1222 std::max(0.5,
vsP.z));
1228 V3i c(
static_cast<int>(floor(
p.x)),
1229 static_cast<int>(floor(
p.y)),
1230 static_cast<int>(floor(
p.z)));
1237 im = std::max(dataWindow.min.x, std::min(
c.x, dataWindow.max.x + 1));
1238 jm = std::max(dataWindow.min.y, std::min(
c.y, dataWindow.max.y));
1239 km = std::max(dataWindow.min.z, std::min(
c.z, dataWindow.max.z));
1241 im_1 = std::max(dataWindow.min.x, std::min(
im - 1, dataWindow.max.x + 1));
1242 jm_1 = std::max(dataWindow.min.y, std::min(
jm - 1, dataWindow.max.y));
1243 km_1 = std::max(dataWindow.min.z, std::min(
km - 1, dataWindow.max.z));
1245 im1 = std::max(dataWindow.min.x, std::min(
im + 1, dataWindow.max.x + 1));
1246 jm1 = std::max(dataWindow.min.y, std::min(
jm + 1, dataWindow.max.y));
1247 km1 = std::max(dataWindow.min.z, std::min(
km + 1, dataWindow.max.z));
1249 im2 = std::max(dataWindow.min.x, std::min(
im + 2, dataWindow.max.x + 1));
1250 jm2 = std::max(dataWindow.min.y, std::min(
jm + 2, dataWindow.max.y));
1251 km2 = std::max(dataWindow.min.z, std::min(
km + 2, dataWindow.max.z));
1335 c.x =
static_cast<int>(floor(
p.x));
1336 c.y =
static_cast<int>(floor(
p.y));
1337 c.z =
static_cast<int>(floor(
p.z));
1343 im = std::max(dataWindow.min.x, std::min(
c.x, dataWindow.max.x));
1344 jm = std::max(dataWindow.min.y, std::min(
c.y, dataWindow.max.y + 1));
1345 km = std::max(dataWindow.min.z, std::min(
c.z, dataWindow.max.z));
1347 im_1 = std::max(dataWindow.min.x, std::min(
im - 1, dataWindow.max.x));
1348 jm_1 = std::max(dataWindow.min.y, std::min(
jm - 1, dataWindow.max.y + 1));
1349 km_1 = std::max(dataWindow.min.z, std::min(
km - 1, dataWindow.max.z));
1351 im1 = std::max(dataWindow.min.x, std::min(
im + 1, dataWindow.max.x));
1352 jm1 = std::max(dataWindow.min.y, std::min(
jm + 1, dataWindow.max.y + 1));
1353 km1 = std::max(dataWindow.min.z, std::min(
km + 1, dataWindow.max.z));
1355 im2 = std::max(dataWindow.min.x, std::min(
im + 2, dataWindow.max.x));
1356 jm2 = std::max(dataWindow.min.y, std::min(
jm + 2, dataWindow.max.y + 1));
1357 km2 = std::max(dataWindow.min.z, std::min(
km + 2, dataWindow.max.z));
1440 c.x =
static_cast<int>(floor(
p.x));
1441 c.y =
static_cast<int>(floor(
p.y));
1442 c.z =
static_cast<int>(floor(
p.z));
1448 im = std::max(dataWindow.min.x, std::min(
c.x, dataWindow.max.x));
1449 jm = std::max(dataWindow.min.y, std::min(
c.y, dataWindow.max.y));
1450 km = std::max(dataWindow.min.z, std::min(
c.z, dataWindow.max.z + 1));
1452 im_1 = std::max(dataWindow.min.x, std::min(
im - 1, dataWindow.max.x));
1453 jm_1 = std::max(dataWindow.min.y, std::min(
jm - 1, dataWindow.max.y));
1454 km_1 = std::max(dataWindow.min.z, std::min(
km - 1, dataWindow.max.z + 1));
1456 im1 = std::max(dataWindow.min.x, std::min(
im + 1, dataWindow.max.x));
1457 jm1 = std::max(dataWindow.min.y, std::min(
jm + 1, dataWindow.max.y));
1458 km1 = std::max(dataWindow.min.z, std::min(
km + 1, dataWindow.max.z + 1));
1460 im2 = std::max(dataWindow.min.x, std::min(
im + 2, dataWindow.max.x));
1461 jm2 = std::max(dataWindow.min.y, std::min(
jm + 2, dataWindow.max.y));
1462 km2 = std::max(dataWindow.min.z, std::min(
km + 2, dataWindow.max.z + 1));
1545template <
class Data_T>
1557template <
class S,
class T>
1573 if (
delta_k ==
static_cast<T
>(0)) {
1574 d_k =
static_cast<T
>(0);
1575 d_k1 =
static_cast<T
>(0);
1596template <
class Data_T>
1598 const Data_T &
f3,
const Data_T &
f4,
1601 typedef typename Data_T::BaseType T;
1603 Data_T
d_k = T(.5) * (
f3 -
f1);
1607 for (
int i = 0;
i < 3;
i++) {
1608 if (
delta_k[
i] ==
static_cast<T
>(0)) {
1609 d_k[
i] =
static_cast<T
>(0);
1610 d_k1[
i]=
static_cast<T
>(0);
Contains the DenseField class.
V3h monotonicCubicInterpolant< V3h >(const V3h &f1, const V3h &f2, const V3h &f3, const V3h &f4, double t)
V3f monotonicCubicInterpolant< V3f >(const V3f &f1, const V3f &f2, const V3f &f3, const V3f &f4, double t)
bool isPointInField(const FieldRes::Ptr f, const V3d &wsP)
Checks whether the point is within the given field.
Data_T wsSample(const typename Field< Data_T >::Ptr f, const FieldInterp< Data_T > &interp, const V3d &wsP)
Helper function for interpolating in world space.
FIELD3D_VEC3_T< T > operator*(S s, const FIELD3D_VEC3_T< T > vec)
Scalar times Vec3 multiplication. Makes the interpolation calls cleaner.
Data_T monotonicCubicInterpolant(const Data_T &f1, const Data_T &f2, const Data_T &f3, const Data_T &f4, double t)
Monotonic cubic interpolation References: http://en.wikipedia.org/wiki/Monotone_cubic_interpolation h...
V3d monotonicCubicInterpolant< V3d >(const V3d &f1, const V3d &f2, const V3d &f3, const V3d &f4, double t)
Data_T monotonicCubicInterpolantVec(const Data_T &f1, const Data_T &f2, const Data_T &f3, const Data_T &f4, double t)
Monotonic cubic interpolation on 3 - vectors References: http://en.wikipedia.org/wiki/Monotone_cubic_...
bool isLegalVoxelCoord(const V3d &vsP, const Box3d &vsDataWindow)
Checks whether the floating - point voxel coordinate is within the given (floating point) data window...
Contains Field, WritableField and ResizableField classes.
#define FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(field)
Contains the MACField class.
Contains the ProceduralField class.
Contains base class for reference counting with Mutex.
static TemplatedFieldType< CubicFieldInterp< Data_T > > ms_classType
DEFINE_FIELD_RTTI_CONCRETE_CLASS
FieldInterp< Data_T > base
Convenience typedef for referring to base class.
static const char * staticClassName()
boost::intrusive_ptr< CubicFieldInterp > Ptr
virtual Data_T sample(const Field< Data_T > &data, const V3d &vsP) const
CubicFieldInterp class_type
static const char * staticClassType()
static const char * staticClassName()
static const char * staticClassType()
DEFINE_FIELD_RTTI_CONCRETE_CLASS
CubicGenericFieldInterp class_type
boost::intrusive_ptr< CubicGenericFieldInterp > Ptr
Field_T::value_type value_type
RefBase base
Convenience typedef for referring to base class.
static TemplatedFieldType< CubicGenericFieldInterp< Field_T > > ms_classType
value_type sample(const Field_T &data, const V3d &vsP) const
RefBase base
Convenience typedef for referring to base class.
static const char * staticClassName()
CubicMACFieldInterp class_type
boost::intrusive_ptr< CubicMACFieldInterp > Ptr
static const char * staticClassType()
Data_T sample(const MACField< Data_T > &data, const V3d &vsP) const
DEFINE_FIELD_RTTI_CONCRETE_CLASS
static TemplatedFieldType< CubicMACFieldInterp< Data_T > > ms_classType
Base class for interpolators.
static TemplatedFieldType< FieldInterp< Data_T > > ms_classType
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
RefBase base
Convenience typedef for referring to base class.
static const char * staticClassName()
boost::intrusive_ptr< FieldInterp > Ptr
static const char * staticClassType()
virtual Data_T sample(const Field< Data_T > &data, const V3d &vsP) const =0
V3i const dataResolution() const
boost::intrusive_ptr< FieldRes > Ptr
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
boost::intrusive_ptr< Field > Ptr
virtual Data_T value(int i, int j, int k) const =0
Read access to a voxel. The coordinates are in integer voxel space .
FieldInterp< Data_T > base
Convenience typedef for referring to base class.
virtual Data_T sample(const Field< Data_T > &data, const V3d &vsP) const
static TemplatedFieldType< LinearFieldInterp< Data_T > > ms_classType
DEFINE_FIELD_RTTI_CONCRETE_CLASS
static const char * staticClassType()
LinearFieldInterp class_type
static const char * staticClassName()
boost::intrusive_ptr< LinearFieldInterp > Ptr
DEFINE_FIELD_RTTI_CONCRETE_CLASS
static TemplatedFieldType< LinearGenericFieldInterp< Field_T > > ms_classType
boost::intrusive_ptr< LinearGenericFieldInterp > Ptr
value_type sample(const Field_T &data, const V3d &vsP) const
Field_T::value_type value_type
static const char * staticClassType()
LinearGenericFieldInterp class_type
RefBase base
Convenience typedef for referring to base class.
static const char * staticClassName()
Data_T sample(const MACField< Data_T > &data, const V3d &vsP) const
RefBase base
Convenience typedef for referring to base class.
LinearMACFieldInterp class_type
static const char * staticClassType()
classType for RTTI replacement
static TemplatedFieldType< LinearMACFieldInterp< Data_T > > ms_classType
static const char * staticClassName()
DEFINE_FIELD_RTTI_CONCRETE_CLASS
boost::intrusive_ptr< LinearMACFieldInterp > Ptr
This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book...
const real_t & w(int i, int j, int k) const
Read access to value on w-facing wall.
const real_t & u(int i, int j, int k) const
Read access to value on u-facing wall.
const real_t & v(int i, int j, int k) const
Read access to value on v-facing wall.
static const char * staticClassType()
static const char * staticClassName()
DEFINE_FIELD_RTTI_CONCRETE_CLASS
RefBase base
Convenience typedef for referring to base class.
ProceduralFieldLookup class_type
boost::intrusive_ptr< ProceduralFieldLookup > Ptr
static TemplatedFieldType< ProceduralFieldLookup< Data_T > > ms_classType
Data_T sample(const ProceduralField< Data_T > &data, const V3d &vsP) const
virtual Data_T lsSample(const V3d &lsP) const =0
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Used to return a string for the name of a templated field.