aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/gra/Camera.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/gra/Camera.h')
-rw-r--r--meowpp/gra/Camera.h261
1 files changed, 0 insertions, 261 deletions
diff --git a/meowpp/gra/Camera.h b/meowpp/gra/Camera.h
deleted file mode 100644
index 0cb2582..0000000
--- a/meowpp/gra/Camera.h
+++ /dev/null
@@ -1,261 +0,0 @@
-#ifndef gra_Camera_H__
-#define gra_Camera_H__
-
-#include "Photo.h"
-#include "IdentityPoints.h"
-#include "../Self.h"
-#include "../math/utility.h"
-#include "../math/LinearTransformations.h"
-#include "../math/methods.h"
-#include "../oo/ObjBase.h"
-
-namespace meow {
-
-/*!
- * @brief Camera
- *
- * 實際上就是一個 \c Photo 加上一個 \c Rotation3D.
- * 另外附有 fixedPoint, 可以用來定位時參考
- *
- * @author cat_leopard
- */
-template<class Pixel>
-class Camera: public ObjBase {
-public:
- typedef IdentityPoints<int, double, Vector2D<double> > FixedPoints2D;
-private:
- struct Myself {
- Photo<Pixel> photo_;
- Rotation3D<double> rot_;
- FixedPoints2D fixed2D_;
-
- Myself(): fixed2D_(2) {
- }
-
- Myself(Myself const& v):
- photo_(v.photo_), rot_(v.rot_), fixed2D_(v.fixed2D_) {
- }
-
- ~Myself() {
- }
- };
-
- Self<Myself> const self;
-public:
- /*!
- * @brief constructor
- */
- Camera(): self() {
- }
-
- /*!
- * @brief copy constructor
- */
- Camera(Camera const& b): self(b.self, Self<Myself>::COPY_FROM) {
- }
-
- /*!
- * @brief destructor
- */
- ~Camera() {
- }
-
- /*!
- * @brief 複製資料
- */
- Camera& copyFrom(Camera const& b) {
- self().copyFrom(b.self);
- return *this;
- }
-
- /*!
- * @brief 參照
- */
- Camera& referenceFrom(Camera const& b) {
- self().referenceFrom(b.self);
- return *this;
- }
-
- /*!
- * @brief 取得 photo
- */
- Photo<Pixel> photo() const {
- return self->photo_;
- }
-
- /*!
- * @brief 取得 photo (non-constant)
- */
- Photo<Pixel>& photoGet() {
- return self()->photo_;
- }
-
- /*!
- * @brief 設定 photo
- */
- Photo<Pixel> photo(Photo<Pixel> const& pho) {
- self()->photo_.copyFrom(pho);
- return photo();
- }
-
- /*!
- * @brief 取得rotation
- */
- Rotation3D<double> rotation() const {
- return self->rot_;
- }
-
- /*!
- * @brief 取得rotation (non-constant)
- */
- Rotation3D<double>& rotationGet() {
- return self()->rot_;
- }
-
- /*!
- * @brief 設定rotation
- */
- Rotation3D<double> rotation(Rotation3D<double> const& rot) {
- self()->rot_.copyFrom(rot);
- return rotation();
- }
-
- /*!
- * @brief 取得所有FixedPoint
- */
- FixedPoints2D fixedPoints2D() const {
- return self->fixed2D_;
- }
-
- /*!
- * @brief 取得所有FixedPoint(non-constant reference)
- */
- FixedPoints2D& fixedPoints2DGet() const {
- return self()->fixed2D_;
- }
-
- /*!
- * @brief 設定FixedPoint
- */
- FixedPoints2D fixedPoints2D(FixedPoints2D const& fps2d) const {
- if (fps2d.dimension() == 2) {
- self()->fixed2D_.copyFrom(fps2d);
- }
- return fixedPoints2D();
- }
-
- /*!
- * @brief 取得編號為i的fixed points 2d
- */
- Vector<double> fixedPoint2D(int i) {
- return self->fixed2D_.identityPoint(i);
- }
-
- /*!
- * @brief 詢問某點是否在底片範圍內
- */
- bool inside(Vector3D<double> const& p) const {
- return self->photo_.inside(
- Vector3D<double>(rotation().transformate(p.matrix())));
- }
-
- /*!
- * @brief 取得底片color
- */
- Pixel color(Vector3D<double> const& p) const {
- return self->photo_.color(
- Vector3D<double>(rotation().transformate(p.matrix())));
- }
-
- /*!
- * @brief same as \c copyFrom(b)
- */
- Camera& operator=(Camera const& b) {
- return copyFrom(b);
- }
-
- /*! @brief 將資料寫入檔案
- *
- * @note 未完成
- */
- bool write(FILE* f, bool bin, unsigned int fg) const {
- if (bin) {
- double tmp;
- for (size_t i = 0; i < 3; ++i) {
- if (fwrite(&(tmp = rotation().theta(i)), sizeof(tmp), 1, f) < 1)
- return false;
- }
- }
- else {
- for (size_t i = 0; i < 3; ++i) {
- if (fprintf(f, "%f ", rotation().theta(i)) < 1) return false;
- }
- fprintf(f, "\n");
- }
- return (fixedPoints2D().write(f, bin, fg) && photo().write(f, bin, fg));
- }
-
- /*! @brief 將資料讀入
- *
- * @note 未完成
- */
- bool read(FILE* f, bool bin, unsigned int fg) {
- if (bin) {
- double tmp;
- for (size_t i = 0; i < 3; ++i) {
- if (fread(&tmp, sizeof(tmp), 1, f) < 1) {
- return false;
- }
- rotationGet().theta(i, tmp);
- }
- }
- else {
- double a;
- for (size_t i = 0; i < 3; ++i) {
- if (fscanf(f, "%lf", &a) < 1) return false;
- rotationGet().theta(i, a);
- }
- }
- return (fixedPoints2DGet().read(f, bin, fg) && photoGet().read(f, bin, fg));
- }
-
- /*! @brief new一個自己
- *
- * @return 一個new出來的pointer
- */
- ObjBase* create() const {
- return new Camera();
- }
-
- /*! @brief 複製資料
- *
- * 輸入型別是 \c ObjBase \c const*
- * 事實上這個method就只是幫忙轉型然後呼叫原本的\c copyFrom
- *
- * @param [in] b 資料來源
- * @return this
- */
- ObjBase* copyFrom(ObjBase const* b) {
- return &(copyFrom(*(Camera const*)b));
- }
-
- /*! @brief 回傳class的type
- *
- * @return \c char \c const\c * 形式的typename
- */
- char const* ctype() const{
- return typeid(*this).name();
- }
-
- /*! @brief 回傳class的type
- *
- * @return \c std::string 形式的typename
- */
- std::string type() const {
- return std::string(ctype());
- }
-};
-
-} // meow
-
-#endif // gra_Camera_H__