31 #ifndef OPENVDB_MATH_TRANSFORM_HAS_BEEN_INCLUDED
32 #define OPENVDB_MATH_TRANSFORM_HAS_BEEN_INCLUDED
35 #include <openvdb/Types.h>
68 typedef boost::shared_ptr<Transform>
Ptr;
69 typedef boost::shared_ptr<const Transform>
ConstPtr;
79 static Transform::Ptr createLinearTransform(
double voxelSize = 1.0);
83 double depth,
double voxelSize = 1.0);
96 void preRotate(
double radians,
const Axis axis =
X_AXIS);
102 void preTranslate(
const Vec3d&);
103 void preScale(
const Vec3d&);
104 void preScale(
double);
106 void preMult(
const Mat4d&);
107 void preMult(
const Mat3d&);
109 void postRotate(
double radians,
const Axis axis =
X_AXIS);
110 void postTranslate(
const Vec3d&);
111 void postScale(
const Vec3d&);
112 void postScale(
double);
114 void postMult(
const Mat4d&);
115 void postMult(
const Mat3d&);
133 Vec3d indexToWorld(
const Vec3d& xyz)
const {
return mMap->applyMap(xyz); }
148 template<
typename MapType>
typename MapType::Ptr map();
151 template<
typename MapType>
typename MapType::ConstPtr map()
const;
152 template<
typename MapType>
typename MapType::ConstPtr constMap()
const;
156 void read(std::istream&);
158 void write(std::ostream&)
const;
163 void print(std::ostream& os = std::cout,
const std::string& indent =
"")
const;
179 template<
typename MapType>
180 inline typename MapType::Ptr
183 if (
mMap->type() == MapType::mapType()) {
184 return boost::static_pointer_cast<MapType>(
mMap);
186 return typename MapType::Ptr();
190 template<
typename MapType>
191 inline typename MapType::ConstPtr
192 Transform::map()
const
194 return boost::const_pointer_cast<
const MapType>(
195 const_cast<Transform*
>(
this)->map<MapType>());
199 template<
typename MapType>
200 inline typename MapType::ConstPtr
201 Transform::constMap()
const
203 return map<MapType>();
211 template<
typename ResolvedMapType,
typename OpType>
215 ResolvedMapType& resolvedMap = *transform.
map<ResolvedMapType>();
217 op.operator()<ResolvedMapType>(resolvedMap);
219 op.template operator()<ResolvedMapType>(resolvedMap);
224 template<
typename ResolvedMapType,
typename OpType>
228 const ResolvedMapType& resolvedMap = *transform.
map<ResolvedMapType>();
230 op.operator()<ResolvedMapType>(resolvedMap);
232 op.template operator()<ResolvedMapType>(resolvedMap);
251 template<
typename TransformType,
typename OpType>
255 using namespace openvdb;
257 const Name mapType = transform.mapType();
258 if (mapType == UniformScaleMap::mapType()) {
259 doProcessTypedMap<UniformScaleMap, OpType>(transform, op);
261 }
else if (mapType == UniformScaleTranslateMap::mapType()) {
262 doProcessTypedMap<UniformScaleTranslateMap, OpType>(transform, op);
264 }
else if (mapType == ScaleMap::mapType()) {
265 doProcessTypedMap<ScaleMap, OpType>(transform, op);
267 }
else if (mapType == ScaleTranslateMap::mapType()) {
268 doProcessTypedMap<ScaleTranslateMap, OpType>(transform, op);
270 }
else if (mapType == UnitaryMap::mapType()) {
271 doProcessTypedMap<UnitaryMap, OpType>(transform, op);
273 }
else if (mapType == AffineMap::mapType()) {
274 doProcessTypedMap<AffineMap, OpType>(transform, op);
276 }
else if (mapType == TranslationMap::mapType()) {
277 doProcessTypedMap<TranslationMap, OpType>(transform, op);
279 }
else if (mapType == NonlinearFrustumMap::mapType()) {
280 doProcessTypedMap<NonlinearFrustumMap, OpType>(transform, op);
291 #endif // OPENVDB_MATH_TRANSFORM_HAS_BEEN_INCLUDED
boost::shared_ptr< const MapBase > ConstPtr
Definition: Maps.h:162
const MapT & mMap
Definition: GridOperators.h:260
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:684
Vec3d asVec3d() const
Definition: Coord.h:136
MatType shear(Axis axis0, Axis axis1, typename MatType::value_type shear)
Set the matrix to a shear along axis0 by a fraction of axis1.
Definition: Mat.h:669
bool isIdentity(const MatType &m)
Definition: Mat.h:834
std::ostream & operator<<(std::ostream &os, const BBox< Vec3T > &b)
Definition: BBox.h:410
bool processTypedMap(TransformType &transform, OpType &op)
Utility function that, given a generic map pointer, calls a functor on the fully-resoved map...
Definition: Transform.h:253
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:430
std::string Name
Definition: Name.h:44
#define OPENVDB_VERSION_NAME
Definition: version.h:45
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
Abstract base class for maps.
Definition: Maps.h:158
Vec3< double > Vec3d
Definition: Vec3.h:605
void doProcessTypedMap(Transform &transform, OpType &op)
Helper function used internally by processTypedMap()
Definition: Transform.h:213
OPENVDB_API void calculateBounds(const Transform &t, const Vec3d &minWS, const Vec3d &maxWS, Vec3d &minIS, Vec3d &maxIS)
Calculate an axis-aligned bounding box in index space from an axis-aligned bounding box in world spac...
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:56
Axis
Definition: Math.h:762
boost::shared_ptr< MapBase > Ptr
Definition: Maps.h:161