transformation_3d.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_3D_H
00051 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_3D_H
00052
00053 #include "prim_common.h"
00054 #include "point_3d.h"
00055 #include "xyz.h"
00056 #include "impl/prim_allocator.h"
00057 #include "../io/xml_o_stream.h"
00058 #include "../num/num_traits.h"
00059 #include "../util/shared_ptr.h"
00060 #include "../util/thread.h"
00061
00062 namespace lass
00063 {
00064 namespace prim
00065 {
00066 namespace impl
00067 {
00068 template <typename T, typename Cascade>
00069 class Transformation3DStorage: public util::ArrayStorage<T, Cascade>
00070 {
00071 public:
00072 Transformation3DStorage(): util::ArrayStorage<T, Cascade>() {}
00073 Transformation3DStorage(T* p): util::ArrayStorage<T, Cascade>(p) {}
00074 protected:
00075 void dispose()
00076 {
00077 deallocateArray(this->pointer(), 16);
00078 }
00079 };
00080 }
00081
00082 template <typename T>
00083 class Transformation3D
00084 {
00085 public:
00086
00087 typedef Transformation3D<T> TSelf;
00088
00089 typedef Point3D<T> TPoint;
00090 typedef typename TPoint::TVector TVector;
00091 typedef typename util::CallTraits<T>::TValue TValue;
00092 typedef typename util::CallTraits<T>::TParam TParam;
00093 typedef typename util::CallTraits<T>::TReference TReference;
00094 typedef typename util::CallTraits<T>::TConstReference TConstReference;
00095 typedef num::NumTraits<T> TNumTraits;
00096 typedef size_t TSize;
00097
00098 enum { dimension = TPoint::dimension };
00099
00100 template <typename U> struct Rebind
00101 {
00102 typedef Transformation3D<U> Type;
00103 };
00104
00105 Transformation3D();
00106 Transformation3D(const TPoint& origin, const TVector& baseX, const TVector& baseY,
00107 const TVector& baseZ);
00108 template <typename InputIterator> Transformation3D(InputIterator first, InputIterator last);
00109
00110 const TSelf inverse() const;
00111
00112 const TValue* matrix() const;
00113 void swap(TSelf& other);
00114
00115 static const TSelf identity();
00116 static const TSelf translation(const Vector3D<T>& offset);
00117 static const TSelf scaler(const T& scale);
00118 static const TSelf scaler(const Vector3D<T>& scale);
00119 static const TSelf rotation(XYZ axis, TParam radians);
00120 static const TSelf rotation(const Vector3D<T>& axis, TParam radians);
00121
00122 private:
00123
00124 enum { matrixSize_ = 16 };
00125
00126 typedef util::SharedPtr<TValue, impl::Transformation3DStorage> TMatrix;
00127
00128 Transformation3D(const TMatrix& matrix, const TMatrix& inverseMatrix, bool dummy);
00129
00130 TMatrix matrix_;
00131 mutable TMatrix inverseMatrix_;
00132
00133 static T* allocate();
00134
00135 static util::Semaphore sync_;
00136 };
00137
00138 template <typename T> Transformation3D<T> concatenate(const Transformation3D<T>& first, const Transformation3D<T>& second);
00139
00140 template <typename T> Vector3D<T> transform(const Vector3D<T>& subject, const Transformation3D<T>& transformation);
00141 template <typename T> Point3D<T> transform(const Point3D<T>& subject, const Transformation3D<T>& transformation);
00142 template <typename T> Vector3D<T> normalTransform(const Vector3D<T>& subject, const Transformation3D<T>& transformation);
00143 template <typename T> std::pair<Vector3D<T>, T> normalTransform(const std::pair<Vector3D<T>, T>& subject, const Transformation3D<T>& transformation);
00144
00145 template<typename T, typename Char, typename Traits>
00146 std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& stream, const Transformation3D<T>& transformation);
00147
00148 template<typename T> io::XmlOStream& operator<<(io::XmlOStream& stream, const Transformation3D<T>& transformation);
00149
00150
00151
00152 template <typename T> util::Semaphore Transformation3D<T>::sync_;
00153
00154 }
00155
00156 }
00157
00158 #include "transformation_3d.inl"
00159
00160 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_TRANSFORMATION_3D
00161 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
00162 # include "pyobject_util.h"
00163 #endif
00164
00165 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_H
00166 # include "aabb_3d_transformation_3d.h"
00167 #endif
00168
00169 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_PLANE_3D_H
00170 # include "plane_3d_transformation_3d.h"
00171 #endif
00172
00173 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_H
00174 # include "ray_3d_transformation_3d.h"
00175 #endif
00176
00177 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_COLOR_RGBA_H
00178 # include "color_rgba_transformation_3d.h"
00179 #endif
00180
00181 #endif
00182
00183