aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/gra/Eye.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/gra/Eye.h')
-rw-r--r--meowpp/gra/Eye.h174
1 files changed, 0 insertions, 174 deletions
diff --git a/meowpp/gra/Eye.h b/meowpp/gra/Eye.h
deleted file mode 100644
index cff5ccd..0000000
--- a/meowpp/gra/Eye.h
+++ /dev/null
@@ -1,174 +0,0 @@
-#ifndef Eye_H__
-#define Eye_H__
-
-#include "Camera.h"
-
-#include "../Self.h"
-#include "../oo/ObjBase.h"
-
-namespace meow {
-
-/*!
- * @brief 一個 \c Camera 加上一個offset transformation
- *
- * @author cat_leopard
- */
-template<class Pixel>
-class Eye: public ObjBase {
-private:
- struct Myself {
- Camera<Pixel> cam_;
- Vector3D<double> ofs_;
-
- Myself(): cam_(), ofs_(0.0, 0.0, 0.0) {
- }
-
- Myself(Camera<Pixel> const& c, Vector3D<double> const& o): cam_(c), ofs_(o){
- }
-
- Myself(Myself const& b): cam_(b.cam_), ofs_(b.ofs_) {
- }
-
- ~Myself() {
- }
- };
-
- Self<Myself> const self;
-public:
- Eye(): self() {
- }
-
- Eye(Eye const& b): self(b.self(), Self<Myself>::COPY_FROM) {
- }
-
- Eye(Camera<Pixel> const& c, Vector3D<double> const& o): self(Myself(c, o)) {
- }
-
- ~Eye() {
- }
-
- Eye& copyFrom(Eye const& e) {
- self().copyFrom(e.self);
- return *this;
- }
-
- Eye& referenceFrom(Eye const& e) {
- self().referenceFrom(e.self);
- return *this;
- }
-
- Camera<Pixel> camera() const {
- return self->cam_;
- }
-
- Camera<Pixel>& cameraGet() {
- return self()->cam_;
- }
-
- Camera<Pixel> camera(Camera<Pixel> const& c) {
- self()->cam_.copyFrom(c);
- return camera();
- }
-
- Vector3D<double> offset() const {
- return self->ofs_;
- }
-
- Vector3D<double>& offsetGet() {
- return self()->ofs_;
- }
-
- Vector3D<double> offset(Vector3D<double> const& ofs) {
- self()->ofs_ = ofs;
- return offset();
- }
-
- bool inside(Vector3D<double> const& v) const {
- return camera().inside(v - offset());
- }
-
- Eye& operator=(Eye const& e) {
- return copyFrom(e);
- }
-
- /*! @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 = offset()(i)), sizeof(tmp), 1, f) < 1)
- return false;
- }
- }
- else {
- for (size_t i = 0; i < 3; ++i) {
- if (fprintf(f, "%f ", offset()(i)) < 1) return false;
- }
- fprintf(f, "\n");
- }
- return camera().write(f, bin, fg);
- }
-
- /*! @brief 將資料讀入
- *
- * @note 未完成
- */
- bool read(FILE* f, bool bin, unsigned int fg) {
- if (bin) {
- double tmp[3];
- if (fread(tmp, sizeof(double), 3, f) < 3) return false;
- offsetGet().xyz(tmp[0], tmp[1], tmp[2]);
- }
- else {
- double a, b, c;
- if (fscanf(f, "%lf %lf %lf", &a, &b, &c) < 3) return false;
- offsetGet().x(a);
- offsetGet().y(b);
- offsetGet().z(c);
- }
- return cameraGet().read(f, bin, fg);
- }
-
- /*! @brief new一個自己
- *
- * @return 一個new出來的pointer
- */
- ObjBase* create() const {
- return new Eye();
- }
-
- /*! @brief 複製資料
- *
- * 輸入型別是 \c ObjBase \c const*
- * 事實上這個method就只是幫忙轉型然後呼叫原本的\c copyFrom
- *
- * @param [in] b 資料來源
- * @return this
- */
- ObjBase* copyFrom(ObjBase const* b) {
- return &(copyFrom(*(Eye 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 // Eye_H__