summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac17
-rw-r--r--libdimensionxx/Makefile.am63
-rw-r--r--libdimensionxx/camera.cpp116
-rw-r--r--libdimensionxx/cameras.cpp59
-rw-r--r--libdimensionxx/canvas.cpp87
-rw-r--r--libdimensionxx/color.cpp27
-rw-r--r--libdimensionxx/cookie-fopencookie.cpp204
-rw-r--r--libdimensionxx/cookie-tmpfile.cpp157
-rw-r--r--libdimensionxx/dimensionxx.hpp45
-rw-r--r--libdimensionxx/dimensionxx/array.hpp351
-rw-r--r--libdimensionxx/dimensionxx/camera.hpp96
-rw-r--r--libdimensionxx/dimensionxx/cameras.hpp49
-rw-r--r--libdimensionxx/dimensionxx/canvas.hpp84
-rw-r--r--libdimensionxx/dimensionxx/color.hpp258
-rw-r--r--libdimensionxx/dimensionxx/cookie.hpp102
-rw-r--r--libdimensionxx/dimensionxx/cube.hpp30
-rw-r--r--libdimensionxx/dimensionxx/error.hpp54
-rw-r--r--libdimensionxx/dimensionxx/geometry.hpp322
-rw-r--r--libdimensionxx/dimensionxx/gl.hpp64
-rw-r--r--libdimensionxx/dimensionxx/object.hpp133
-rw-r--r--libdimensionxx/dimensionxx/objects.hpp61
-rw-r--r--libdimensionxx/dimensionxx/png.hpp71
-rw-r--r--libdimensionxx/dimensionxx/progress.hpp135
-rw-r--r--libdimensionxx/dimensionxx/raytrace.hpp51
-rw-r--r--libdimensionxx/dimensionxx/scene.hpp78
-rw-r--r--libdimensionxx/dimensionxx/texture.hpp115
-rw-r--r--libdimensionxx/dimensionxx/utility.hpp47
-rw-r--r--libdimensionxx/error.cpp44
-rw-r--r--libdimensionxx/gl.cpp75
-rw-r--r--libdimensionxx/object.cpp209
-rw-r--r--libdimensionxx/objects.cpp66
-rw-r--r--libdimensionxx/png.cpp180
-rw-r--r--libdimensionxx/progress.cpp133
-rw-r--r--libdimensionxx/raytrace.cpp69
-rw-r--r--libdimensionxx/scene.cpp124
-rw-r--r--libdimensionxx/texture.cpp106
-rw-r--r--tests/Makefile.am44
-rw-r--r--tests/error.cpp33
-rw-r--r--tests/gl.cpp79
-rw-r--r--tests/png.cpp65
-rw-r--r--tests/tests.cpp220
-rw-r--r--tests/tests.hpp61
-rw-r--r--tests/warning.cpp54
44 files changed, 2 insertions, 4440 deletions
diff --git a/Makefile.am b/Makefile.am
index 204ae5e..5e1e60f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,8 +19,6 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = doc \
- libdimension \
- libdimensionxx \
- tests
+ libdimension
EXTRA_DIST = autogen.sh
diff --git a/configure.ac b/configure.ac
index df85e2a..4a7c2c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,6 @@ AM_INIT_AUTOMAKE(dimension, 0.0.0)
dnl Programs
AC_PROG_CC
-AC_PROG_CXX
AM_PROG_CC_C_O
AM_PROG_AS
AC_PROG_INSTALL
@@ -29,23 +28,9 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
-dnl Determine if we can use the fopencookie() implementation of FILE_Cookie
-AC_MSG_CHECKING([for fopencookie()])
-AC_LINK_IFELSE(AC_LANG_PROGRAM(
- [[ #define _GNU_SOURCE
- #include <stdio.h> ]],
- [[ cookie_io_functions_t io_funcs;
- FILE* file = fopencookie(NULL, "r", io_funcs); ]]),
- [fopencookie=yes
- AC_MSG_RESULT([yes])],
- [AC_MSG_RESULT([no])])
-AM_CONDITIONAL([FOPENCOOKIE], [test "$fopencookie" = "yes"])
-
dnl Generate Makefiles
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_FILES([Makefile
doc/Makefile
- libdimension/Makefile
- libdimensionxx/Makefile
- tests/Makefile])
+ libdimension/Makefile])
AC_OUTPUT
diff --git a/libdimensionxx/Makefile.am b/libdimensionxx/Makefile.am
deleted file mode 100644
index 0f8d3a4..0000000
--- a/libdimensionxx/Makefile.am
+++ /dev/null
@@ -1,63 +0,0 @@
-###########################################################################
-## Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> ##
-## ##
-## This file is part of The Dimension Build Suite. ##
-## ##
-## The Dimension Build Suite is free software; you can redistribute it ##
-## and/or modify it under the terms of the GNU General Public License as ##
-## published by the Free Software Foundation; either version 3 of the ##
-## License, or (at your option) any later version. ##
-## ##
-## The Dimension Build Suite is distributed in the hope that it will be ##
-## useful, but WITHOUT ANY WARRANTY; without even the implied warranty ##
-## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
-## General Public License for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
-###########################################################################
-
-nobase_include_HEADERS = dimensionxx.hpp \
- dimensionxx/array.hpp \
- dimensionxx/canvas.hpp \
- dimensionxx/camera.hpp \
- dimensionxx/cameras.hpp \
- dimensionxx/color.hpp \
- dimensionxx/cookie.hpp \
- dimensionxx/geometry.hpp \
- dimensionxx/gl.hpp \
- dimensionxx/object.hpp \
- dimensionxx/objects.hpp \
- dimensionxx/png.hpp \
- dimensionxx/progress.hpp \
- dimensionxx/raytrace.hpp \
- dimensionxx/scene.hpp \
- dimensionxx/texture.hpp
-
-INCLUDES = -I../libdimension
-
-lib_LTLIBRARIES = libdimensionxx.la
-
-libdimensionxx_la_SOURCES = $(nobase_include_HEADERS) \
- canvas.cpp \
- camera.cpp \
- cameras.cpp \
- color.cpp \
- gl.cpp \
- error.cpp \
- object.cpp \
- objects.cpp \
- png.cpp \
- progress.cpp \
- raytrace.cpp \
- scene.cpp \
- texture.cpp
-
-if FOPENCOOKIE
- libdimensionxx_la_SOURCES += cookie-fopencookie.cpp
-else
- libdimensionxx_la_SOURCES += cookie-tmpfile.cpp
-endif
-
-libdimensionxx_la_LDFLAGS = -version-info 0:0:0
-libdimensionxx_la_LIBADD = ../libdimension/libdimension.la
diff --git a/libdimensionxx/camera.cpp b/libdimensionxx/camera.cpp
deleted file mode 100644
index d483ba3..0000000
--- a/libdimensionxx/camera.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Virtual destructor
- Camera::~Camera()
- {
- if (unique()) {
- dmnsn_delete_camera(dmnsn());
- }
- }
-
- // Return the result of the dmnsn_camera*'s ray callback
- Line
- Camera::ray(double x, double y)
- {
- return Line((*dmnsn()->ray_fn)(dmnsn(), x, y));
- }
-
- // Return the wrapped camera
- dmnsn_camera*
- Camera::dmnsn()
- {
- if (!m_camera) {
- throw Dimension_Error("Attempt to access NULL camera.");
- }
-
- return *m_camera;
- }
-
- // Return a const version of the wrapped canvas
- const dmnsn_camera*
- Camera::dmnsn() const
- {
- if (!m_camera) {
- throw Dimension_Error("Attempt to access NULL camera.");
- }
-
- return *m_camera;
- }
-
- // Protected default no-op constructor
- Camera::Camera()
- : m_camera()
- { }
-
- // Protected copy constructor
- Camera::Camera(const Camera& camera)
- : m_camera(camera.m_camera)
- { }
-
- // Protected manual constructor
- Camera::Camera(dmnsn_camera *camera)
- : m_camera(new dmnsn_camera*(camera))
- { }
-
- // Is m_camera unique?
- bool
- Camera::unique() const
- {
- return m_camera && m_camera.unique();
- }
-
- // Set the wrapped dmnsn_camera*
- void
- Camera::dmnsn(dmnsn_camera* camera)
- {
- m_camera.reset(new dmnsn_camera*(camera));
- }
-
- // Custom camera callbacks
- namespace {
- dmnsn_line
- ray_fn(const dmnsn_camera *camera, double x, double y)
- {
- Custom_Camera* ccamera = reinterpret_cast<Custom_Camera*>(camera->ptr);
- return ccamera->ray(x, y).dmnsn();
- }
- }
-
- // Initialize a new camera, using member functions as callbacks
- Custom_Camera::Custom_Camera()
- : Camera(dmnsn_new_camera())
- {
- dmnsn()->ptr = this;
- dmnsn()->ray_fn = &ray_fn;
- }
-
- // Delete the camera
- Custom_Camera::~Custom_Camera()
- {
- if (unique()) {
- dmnsn_delete_camera(dmnsn());
- }
- }
-}
diff --git a/libdimensionxx/cameras.cpp b/libdimensionxx/cameras.cpp
deleted file mode 100644
index 9c44fef..0000000
--- a/libdimensionxx/cameras.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Create a perspective camera
- Perspective_Camera::Perspective_Camera()
- : Camera(dmnsn_new_perspective_camera())
- {
- if (!dmnsn()) {
- throw Dimension_Error("Failed to allocate perspective camera.");
- }
- }
-
- // Get the transformation matrix
- Matrix
- Perspective_Camera::trans()
- {
- return Matrix(dmnsn_get_perspective_camera_trans(dmnsn()));
- }
-
- // Set the transformation matrix
- void
- Perspective_Camera::trans(const Matrix& trans)
- {
- dmnsn_set_perspective_camera_trans(dmnsn(), trans.dmnsn());
- }
-
- // Shallow-copy this camera
- Camera*
- Perspective_Camera::copy() const
- {
- return new Perspective_Camera(*this);
- }
-
- // Private copy-constructor, for copy() implementation
- Perspective_Camera::Perspective_Camera(const Perspective_Camera& camera)
- : Camera(camera)
- { }
-}
diff --git a/libdimensionxx/canvas.cpp b/libdimensionxx/canvas.cpp
deleted file mode 100644
index 10688da..0000000
--- a/libdimensionxx/canvas.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Allocate the canvas with dmnsn_new_canvas()
- Canvas::Canvas(unsigned int width, unsigned int height)
- : m_canvas(new dmnsn_canvas*(dmnsn_new_canvas(width, height)))
- {
- if (!dmnsn()) {
- throw Dimension_Error("Couldn't allocate canvas.");
- }
- }
-
- // Wrap an existing dmnsn_canvas*
- Canvas::Canvas(dmnsn_canvas* canvas)
- : m_canvas(new dmnsn_canvas*(canvas)) { }
-
- // Virtual destructor: delete the canvas with dmnsn_delete_canvas().
- Canvas::~Canvas()
- {
- if (m_canvas && m_canvas.unique()) {
- dmnsn_delete_canvas(dmnsn());
- }
- }
-
- // Get the width
- unsigned int
- Canvas::width() const
- {
- return dmnsn()->x;
- }
-
- // Get the height
- unsigned int
- Canvas::height() const
- {
- return dmnsn()->y;
- }
-
- // Get a particular pixel
- Color
- Canvas::pixel(unsigned int x, unsigned int y) const
- {
- return Color(dmnsn_get_pixel(dmnsn(), x, y));
- }
-
- // Set a particular pixel
- void
- Canvas::pixel(unsigned int x, unsigned int y, const Color& c)
- {
- dmnsn_set_pixel(dmnsn(), x, y, c.dmnsn());
- }
-
- // Return the wrapped canvas
- dmnsn_canvas*
- Canvas::dmnsn()
- {
- return *m_canvas;
- }
-
- // Return a const version of the wrapped canvas
- const dmnsn_canvas*
- Canvas::dmnsn() const
- {
- return *m_canvas;
- }
-}
diff --git a/libdimensionxx/color.cpp b/libdimensionxx/color.cpp
deleted file mode 100644
index 90cf2ea..0000000
--- a/libdimensionxx/color.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Definition of whitepoint
- const CIE_XYZ whitepoint(dmnsn_whitepoint);
-}
diff --git a/libdimensionxx/cookie-fopencookie.cpp b/libdimensionxx/cookie-fopencookie.cpp
deleted file mode 100644
index 843cc45..0000000
--- a/libdimensionxx/cookie-fopencookie.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-#ifndef _GNU_SOURCE
- // For fopencookie()
- #define _GNU_SOURCE
-#endif
-#include <stdio.h>
-
-// The conundrum: libdimension uses C I/O, with FILE*'s. We want to use C++ I/O
-// with std::i/ostreams. If present, we use the nonportable GNU stdio extension
-// fopencookie(), which creates a FILE* with custom read/write/seek functions.
-// BSD also has a similar function, funopen() which we should use too. Failing
-// in all that, fall back on a tmpfile() buffer (see cookie-tmpfile.cpp).
-
-namespace Dimension
-{
- // FILE_Cookie pure virtual destructor
- FILE_Cookie::~FILE_Cookie() {
- if (m_file) {
- // Bug if neither ~iFILE_Cookie nor ~oFILE_Cookie closed the FILE*
- dmnsn_error(DMNSN_SEVERITY_HIGH,
- "FILE* not closed by FILE_Cookie destructor");
- }
- }
-
- namespace
- {
- // Cookie read function
- ssize_t
- cookie_read(void* cookie, char* buf, size_t size)
- {
- FILE_Cookie* fcookie = reinterpret_cast<FILE_Cookie*>(cookie);
- iFILE_Cookie& ifcookie = dynamic_cast<iFILE_Cookie&>(*fcookie);
-
- // Do the unformatted read
- ifcookie.istr().read(buf, size);
-
- if (ifcookie.istr().eof() || ifcookie.istr().good()) {
- return ifcookie.istr().gcount(); // This returns 0 on an immediate EOF
- // for us.
- } else {
- // Some non-EOF error
- return -1;
- }
- }
-
- // Cookie write function
- ssize_t
- cookie_write(void* cookie, const char* buf, size_t size)
- {
- FILE_Cookie* fcookie = reinterpret_cast<FILE_Cookie*>(cookie);
- oFILE_Cookie& ofcookie = dynamic_cast<oFILE_Cookie&>(*fcookie);
-
- // Do the unformatted write
- ofcookie.ostr().write(buf, size);
-
- if (ofcookie.ostr().good()) {
- // Write operation succeeded, so we must've written size bytes
- return size;
- } else {
- // Write operation failed
- return -1;
- }
- }
-
- // Cookie seek function
- int
- cookie_seek(void* cookie, off64_t* offset, int whence)
- {
- FILE_Cookie* fcookie = reinterpret_cast<FILE_Cookie*>(cookie);
- iFILE_Cookie* ifcookie = dynamic_cast<iFILE_Cookie*>(fcookie);
- oFILE_Cookie* ofcookie = dynamic_cast<oFILE_Cookie*>(fcookie);
-
- if (ifcookie) {
- // If we have an input stream, seek it
- switch (whence) {
- case SEEK_SET:
- ifcookie->istr().seekg(*offset, std::ios::beg);
- break;
- case SEEK_CUR:
- ifcookie->istr().seekg(*offset, std::ios::cur);
- break;
- case SEEK_END:
- ifcookie->istr().seekg(*offset, std::ios::end);
- break;
- }
-
- if (!ifcookie->istr().good()) {
- // Seek failed
- return 1;
- }
- }
-
- if (ofcookie) {
- // If we have an output stream, seek it
- switch (whence) {
- case SEEK_SET:
- ofcookie->ostr().seekp(*offset, std::ios::beg);
- break;
- case SEEK_CUR:
- ofcookie->ostr().seekp(*offset, std::ios::cur);
- break;
- case SEEK_END:
- ofcookie->ostr().seekp(*offset, std::ios::end);
- }
-
- if (!ofcookie->ostr().good()) {
- // Seek failed
- return 1;
- }
- }
-
- // Seek succeeded
- return 0;
- }
- }
-
- // Make an input FILE_Cookie
- iFILE_Cookie::iFILE_Cookie(std::istream& istr)
- : m_istr(&istr)
- {
- cookie_io_functions_t io_funcs;
- io_funcs.read = &cookie_read;
- io_funcs.write = 0;
- io_funcs.seek = &cookie_seek;
- io_funcs.close = 0;
-
- // Set the FILE*
- file(fopencookie(reinterpret_cast<void*>(static_cast<FILE_Cookie*>(this)),
- "r", io_funcs));
- }
-
- // iFILE_Cookie destructor
- iFILE_Cookie::~iFILE_Cookie()
- {
- if (file()) {
- // If the FILE* is open, close it and set it to NULL
- fclose(file());
- file(0);
- }
- }
-
- // Make an output FILE_Cookie
- oFILE_Cookie::oFILE_Cookie(std::ostream& ostr)
- : m_ostr(&ostr)
- {
- cookie_io_functions_t io_funcs;
- io_funcs.read = 0;
- io_funcs.write = &cookie_write;
- io_funcs.seek = &cookie_seek;
- io_funcs.close = 0;
-
- // Set the FILE*
- file(fopencookie(reinterpret_cast<void*>(static_cast<FILE_Cookie*>(this)),
- "w", io_funcs));
- }
-
- // oFILE_Cookie destructor
- oFILE_Cookie::~oFILE_Cookie()
- {
- if (file()) {
- // If the FILE* is open, close it and set it to NULL
- fclose(file());
- file(0);
- }
- }
-
- // Make an I/O FILE_Cookie
- ioFILE_Cookie::ioFILE_Cookie(std::iostream& iostr)
- : iFILE_Cookie(iostr, 0), oFILE_Cookie(iostr, 0)
- {
- cookie_io_functions_t io_funcs;
- io_funcs.read = &cookie_read;
- io_funcs.write = &cookie_write;
- io_funcs.seek = &cookie_seek;
- io_funcs.close = 0;
-
- file(fopencookie(reinterpret_cast<void*>(static_cast<FILE_Cookie*>(this)),
- "r+", io_funcs));
- }
-
- // No-op ioFILE_Cookie destructor
- ioFILE_Cookie::~ioFILE_Cookie() { }
-}
diff --git a/libdimensionxx/cookie-tmpfile.cpp b/libdimensionxx/cookie-tmpfile.cpp
deleted file mode 100644
index 784e984..0000000
--- a/libdimensionxx/cookie-tmpfile.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-#include <stdio.h>
-
-// Use a tmpfile() as a buffer for a C++/C I/O interface.
-
-namespace Dimension
-{
- // FILE_Cookie pure virtual destructor
- FILE_Cookie::~FILE_Cookie() {
- fclose(file());
- }
-
- namespace
- {
- // Write an input stream completely to a FILE*; this works poorly for
- // console input, which may not have an EOF in the near future
- void
- write_cookie(FILE* file, std::istream& istr)
- {
- const unsigned int bs = 8192; // Bytes to read at once
- unsigned int count, pos;
- char buffer[bs];
-
- pos = istr.tellg(); // Get the stream's current position
- istr.seekg(0); // Seek to the beginning
- while (true) {
- // Read the whole stream into `file', `bs' bytes at a time
- istr.read(buffer, bs);
- count = istr.gcount();
-
- if (count != bs) {
- if (istr.eof()) {
- // We reached EOF; write the last count bytes
- fwrite(buffer, 1, count, file);
- break;
- } else {
- // Some other error
- throw Dimension_Error("Error reading from input stream.");
- }
- }
-
- // Write the next `bs' bytes
- fwrite(buffer, 1, bs, file);
- }
- fseek(file, pos, SEEK_SET); // Seek to the stream's initial position
- }
-
- // Read a C++ stream completely from a file
- void
- read_cookie(std::ostream& ostr, FILE* file)
- {
- const unsigned int bs = 8192; // Bytes to read at a time
- unsigned int count, pos;
- char buffer[bs];
-
- pos = ftell(file); // Get the initial position
- rewind(file); // Seek to the beginning
- while (true) {
- count = fread(buffer, 1, bs, file);
- if (count != bs) {
- if (feof(file)) {
- // Reached EOF, write the last `count' bytes
- ostr.write(buffer, count);
- break;
- } else {
- // Some other error
- throw Dimension_Error("Error reading from temporary file.");
- }
- }
-
- // Write the next `bs' bytes
- ostr.write(buffer, bs);
- }
- ostr.seekp(pos); // Seek to the initial position of `file'
- }
- }
-
- // Make an input FILE_Cookie
- iFILE_Cookie::iFILE_Cookie(std::istream& istr)
- : m_istr(&istr)
- {
- FILE* tmp = std::tmpfile();
- if (!tmp) {
- throw Dimension_Error("Error opening temporary file for C++/C I/O"
- " interface.");
- }
-
- // Write the input stream to the temporary file
- write_cookie(tmp, *m_istr);
-
- // Set the FILE*
- file(tmp);
- }
-
- // No-op iFILE_Cookie destructor
- iFILE_Cookie::~iFILE_Cookie() { }
-
- // Make an output FILE_Cookie
- oFILE_Cookie::oFILE_Cookie(std::ostream& ostr)
- : m_ostr(&ostr)
- {
- FILE* tmp = std::tmpfile();
- if (!tmp) {
- throw Dimension_Error("Error opening temporary file for C++/C I/O"
- " interface.");
- }
-
- // Set the FILE*
- file(tmp);
- }
-
- // Write the temporary file to the output stream
- oFILE_Cookie::~oFILE_Cookie()
- {
- read_cookie(ostr(), file());
- }
-
- // Make an I/O FILE_Cookie
- ioFILE_Cookie::ioFILE_Cookie(std::iostream& iostr)
- : iFILE_Cookie(iostr, 0), oFILE_Cookie(iostr, 0)
- {
- FILE* tmp = std::tmpfile();
- if (!tmp) {
- throw Dimension_Error("Error opening temporary file for C++/C I/O"
- " interface.");
- }
-
- // Write the input stream to the temporary file
- write_cookie(tmp, istr());
-
- // Set the FILE*
- file(tmp);
- }
-
- // No-op ioFILE_Cookie destructor
- ioFILE_Cookie::~ioFILE_Cookie() { }
-}
diff --git a/libdimensionxx/dimensionxx.hpp b/libdimensionxx/dimensionxx.hpp
deleted file mode 100644
index ba3f662..0000000
--- a/libdimensionxx/dimensionxx.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#ifndef DIMENSIONXX_HPP
-#define DIMENSIONXX_HPP
-
-// Internal helpers
-#include <dimensionxx/utility.hpp>
-#include <dimensionxx/cookie.hpp>
-
-// libdimension wrappers
-#include <dimensionxx/error.hpp>
-#include <dimensionxx/array.hpp>
-#include <dimensionxx/progress.hpp>
-#include <dimensionxx/geometry.hpp>
-#include <dimensionxx/color.hpp>
-#include <dimensionxx/canvas.hpp>
-#include <dimensionxx/gl.hpp>
-#include <dimensionxx/png.hpp>
-#include <dimensionxx/texture.hpp>
-#include <dimensionxx/object.hpp>
-#include <dimensionxx/objects.hpp>
-#include <dimensionxx/camera.hpp>
-#include <dimensionxx/cameras.hpp>
-#include <dimensionxx/scene.hpp>
-#include <dimensionxx/raytrace.hpp>
-
-#endif /* DIMENSIONXX_HPP */
diff --git a/libdimensionxx/dimensionxx/array.hpp b/libdimensionxx/dimensionxx/array.hpp
deleted file mode 100644
index b3b0496..0000000
--- a/libdimensionxx/dimensionxx/array.hpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_array* wrapper.
-
-#ifndef DIMENSIONXX_ARRAY_HPP
-#define DIMENSIONXX_ARRAY_HPP
-
-#include <tr1/memory> // For tr1::shared_ptr
-#include <cstdlib> // For size_t
-#include <vector>
-
-namespace Dimension
-{
- // Class to store POD types, and wrapped dmnsn_* types, including polymorphic
- // types. The non-specialized version will only handle POD types; specialize
- // it to allow storage of classes in Array's.
- template <typename T>
- class Array_Element
- {
- public:
- typedef T C_Type;
-
- inline Array_Element();
- inline Array_Element(T t);
-
- // Specializations should implement this constructor if C_Type differs from
- // T - but it should throw if T is a polymorphic type
- // Array_Element(C_Type c);
-
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
-
- C_Type dmnsn() const { return m_t; }
- T& object(C_Type& c) const { return c; }
-
- // Must the dmnsn_array* be rebuilt on every access?
- static const bool must_rebuild = false;
-
- private:
- T m_t;
- };
-
- // Array template class, wraps a dmnsn_array*. Copying is possible, but
- // copies refer to the same object, which is reference counted. T must be
- // a POD type.
- template <typename T>
- class Array
- {
- public:
- inline Array();
- explicit inline Array(dmnsn_array* array);
- // Array(const Array& a);
- ~Array()
- { if (m_array && m_array.unique()) { dmnsn_delete_array(dmnsn()); } }
-
- // Array& operator=(const Array& a);
-
- inline T& operator[](std::size_t i);
- inline const T& operator[](std::size_t i) const;
-
- std::size_t size() const { return dmnsn_array_size(dmnsn()); }
- inline void resize(std::size_t size);
-
- inline void push(T& object);
- inline void push(const T& object); // Not valid for polymorphic types
- inline void pop();
-
- // Access the wrapped C object.
- inline dmnsn_array* dmnsn();
- inline const dmnsn_array* dmnsn() const;
-
- // Release ownership of the dmnsn_array*, needed for returning a
- // dmnsn_array* from a function.
- inline dmnsn_array* release();
-
- private:
- typedef typename Array_Element<T>::C_Type C_Type;
-
- std::tr1::shared_ptr<dmnsn_array*> m_array;
- std::vector<Array_Element<T> > m_elements;
-
- inline void rebuild() const;
- };
-
- // Base class for non-polymorphic wrappers
- template <typename T, typename C>
- class By_Value_Array_Element
- {
- public:
- typedef C C_Type;
-
- By_Value_Array_Element() : m_object(new T()) { }
- By_Value_Array_Element(const T& object) : m_object(new T(object)) { }
- By_Value_Array_Element(C_Type c) : m_object(new T(c)) { }
- // By_Value_Array_Element(const By_Value_Array_Element& ae);
- // ~By_Value_Array_Element();
-
- // By_Value_Array_Element& operator=(const By_Value_Array_Element& ae);
-
- C_Type dmnsn() const { return m_object->dmnsn(); }
- T& object(C_Type& c) const { *m_object = T(c); return *m_object; }
-
- static const bool must_rebuild = true;
-
- private:
- std::tr1::shared_ptr<T> m_object;
- };
-
- // Base class for non-polymorphic wrappers
- template <typename T, typename C>
- class DMNSN_Array_Element
- {
- public:
- typedef C C_Type;
-
- DMNSN_Array_Element() {
- throw Dimension_Error("Couldn't default-construct an array element.");
- }
-
- DMNSN_Array_Element(const T& object) : m_object(new T(object)) { }
- DMNSN_Array_Element(C_Type c) : m_object(new T(c)) { }
- // DMNSN_Array_Element(const DMNSN_Array_Element& ae);
- // ~DMNSN_Array_Element();
-
- // DMNSN_Array_Element& operator=(const DMNSN_Array_Element& ae);
-
- C_Type dmnsn() const { return m_object->dmnsn(); }
- T& object(C_Type& c) const { return *m_object; }
-
- static const bool must_rebuild = false;
-
- private:
- std::tr1::shared_ptr<T> m_object;
- };
-
- // Base class for polymorphic wrappers
- template <typename T, typename C>
- class Polymorphic_Array_Element
- {
- public:
- typedef C C_Type;
-
- Polymorphic_Array_Element()
- {
- throw Dimension_Error("Cannot default-construct a polymorphic array"
- " object.");
- }
-
- Polymorphic_Array_Element(T& object) : m_object(object.copy()) { }
-
- Polymorphic_Array_Element(C_Type c)
- {
- throw Dimension_Error("Cannot wrap existing dmnsn_array* elements in"
- " polymorphic class.");
- }
-
- // Polymorphic_Array_Element(const Polymorphic_Array_Element& ae);
- // ~Polymorphic_Array_Element();
-
- // Polymorphic_Array_Element& operator=(const Polymorphic_Array_Element& e);
-
- C_Type dmnsn() const { return m_object->dmnsn(); }
- T& object(C_Type& c) const { return *m_object; }
-
- static const bool must_rebuild = false;
-
- private:
- std::tr1::shared_ptr<T> m_object;
- };
-
- // Array_Element
-
- template <typename T>
- inline
- Array_Element<T>::Array_Element()
- {
- void (*constraint)() = &POD_constraint<T>;
- static_cast<void>(constraint); // Silence unused variable warning
- }
-
- template <typename T>
- inline
- Array_Element<T>::Array_Element(T t)
- : m_t(t)
- {
- void (*constraint)() = &POD_constraint<T>;
- static_cast<void>(constraint); // Silence unused variable warning
- }
-
- // Array constructors
-
- template <typename T>
- inline
- Array<T>::Array()
- : m_array(new dmnsn_array*(dmnsn_new_array(sizeof(T)))) { }
-
- template <typename T>
- inline
- Array<T>::Array(dmnsn_array* array)
- : m_array(new dmnsn_array*(array))
- {
- m_elements.reserve(dmnsn_array_size(dmnsn()));
- for (std::size_t i = 0; i < dmnsn_array_size(dmnsn()); ++i) {
- C_Type* c = reinterpret_cast<C_Type*>(dmnsn_array_at(dmnsn(), i));
- m_elements.push_back(Array_Element<T>(*c));
- }
- }
-
- // Array element access
-
- template <typename T>
- inline T&
- Array<T>::operator[](std::size_t i)
- {
- if (i >= m_elements.size()) {
- m_elements.resize(i + 1);
- }
- C_Type* c = reinterpret_cast<C_Type*>(dmnsn_array_at(dmnsn(), i));
- return m_elements[i].object(c);
- }
-
- template <typename T>
- inline const T&
- Array<T>::operator[](std::size_t i) const
- {
- if (i >= m_elements.size()) {
- m_elements.resize(i + 1);
- }
- C_Type* c = reinterpret_cast<C_Type*>(dmnsn_array_at(dmnsn(), i));
- return m_elements[i].object(c);
- }
-
- template <typename T>
- inline void
- Array<T>::resize(std::size_t size)
- {
- m_elements.resize(size);
- dmnsn_array_resize(dmnsn(), size);
- }
-
- template <typename T>
- inline void
- Array<T>::push(T& object)
- {
- Array_Element<T> ae(object);
- m_elements.push_back(ae);
-
- C_Type c = ae.dmnsn();
- dmnsn_array_push(dmnsn(), &c);
- }
-
- template <typename T>
- inline void
- Array<T>::push(const T& object)
- {
- Array_Element<T> ae(object);
- m_elements.push_back(ae);
-
- C_Type c = ae.dmnsn();
- dmnsn_array_push(dmnsn(), &c);
- }
-
- template <typename T>
- inline void
- Array<T>::pop()
- {
- m_elements.pop();
- dmnsn_array_resize(dmnsn_array_size(dmnsn()) - 1);
- }
-
- // Access the underlying dmnsn_array*
-
- template <typename T>
- inline dmnsn_array*
- Array<T>::dmnsn()
- {
- if (!m_array) {
- throw Dimension_Error("Attempting to access released array.");
- }
-
- if (Array_Element<T>::must_rebuild) {
- rebuild();
- }
-
- return *m_array;
- }
-
- template <typename T>
- inline const dmnsn_array*
- Array<T>::dmnsn() const
- {
- if (!m_array) {
- throw Dimension_Error("Attempting to access released array.");
- }
-
- if (Array_Element<T>::must_rebuild) {
- rebuild();
- }
-
- return *m_array;
- }
-
- // Release the dmnsn_array*, if we are the only Array holding it
- template <typename T>
- inline dmnsn_array*
- Array<T>::release()
- {
- dmnsn_array* array = dmnsn();
-
- if (!m_array.unique()) {
- throw Dimension_Error("Attempting to release non-unique array.");
- } else {
- m_array.reset();
- return array;
- }
- }
-
- // Rebuild the dmnsn_array* from the C++ elements, needed if the C++ objects
- // wrap their C objects by value, not reference
- template <typename T>
- inline void
- Array<T>::rebuild() const
- {
- for (std::size_t i = 0; i < size(); ++i) {
- C_Type c = m_elements[i].dmnsn();
- dmnsn_array_set(*m_array, i, &c);
- }
- }
-}
-
-#endif /* DIMENSIONXX_ARRAY_HPP */
diff --git a/libdimensionxx/dimensionxx/camera.hpp b/libdimensionxx/dimensionxx/camera.hpp
deleted file mode 100644
index 81952d1..0000000
--- a/libdimensionxx/dimensionxx/camera.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_camera* wrapper.
-
-#ifndef DIMENSIONXX_CAMERA_HPP
-#define DIMENSIONXX_CAMERA_HPP
-
-namespace Dimension
-{
- // Abstract base camera class. Wraps a dmnsn_camera*.
- class Camera
- {
- public:
- // Delete the camera
- virtual ~Camera();
-
- // Camera callback
- virtual Line ray(double x, double y);
-
- // Shallow-copy a derived camera
- virtual Camera* copy() const = 0;
-
- // Access the wrapped C camera.
- dmnsn_camera* dmnsn();
- const dmnsn_camera* dmnsn() const;
-
- protected:
- // No-op
- Camera();
- // Shallow-copy
- Camera(const Camera& camera);
- // Wrap an existing camera
- explicit Camera(dmnsn_camera* camera);
-
- // Is m_camera unique?
- bool unique() const;
-
- // Set the wrapped C camera
- void dmnsn(dmnsn_camera* camera);
-
- private:
- // Copy-assignment prohibited
- Camera& operator=(const Camera&);
-
- std::tr1::shared_ptr<dmnsn_camera*> m_camera;
- };
-
- // A custom camera abstract base class, for creating your own camera types
- class Custom_Camera : public Camera
- {
- public:
- Custom_Camera();
- virtual ~Custom_Camera();
-
- virtual Line ray(double x, double y) = 0;
- };
-
- // Array_Element specialization
- template <>
- class Array_Element<Camera>
- : public Polymorphic_Array_Element<Camera, dmnsn_camera*>
- {
- public:
- typedef dmnsn_camera* C_Type;
-
- Array_Element() { }
- Array_Element(Camera& camera)
- : Polymorphic_Array_Element<Camera, dmnsn_camera*>(camera) { }
- Array_Element(C_Type c)
- : Polymorphic_Array_Element<Camera, dmnsn_camera*>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-}
-
-#endif /* DIMENSIONXX_CAMERA_HPP */
diff --git a/libdimensionxx/dimensionxx/cameras.hpp b/libdimensionxx/dimensionxx/cameras.hpp
deleted file mode 100644
index 648c3da..0000000
--- a/libdimensionxx/dimensionxx/cameras.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Camera wrappers.
-
-#ifndef DIMENSIONXX_CAMERAS_HPP
-#define DIMENSIONXX_CAMERAS_HPP
-
-namespace Dimension
-{
- // Perspective camera
- class Perspective_Camera : public Camera
- {
- public:
- Perspective_Camera();
- // ~Perspective_Camera();
-
- // Get/set the transformation matrix
- Matrix trans();
- void trans(const Matrix& trans);
-
- // Shallow-copy the camera
- Camera* copy() const;
-
- private:
- // Copying prohibited, but used internally
- Perspective_Camera(const Perspective_Camera& camera);
- Perspective_Camera& operator=(const Perspective_Camera&);
- };
-}
-
-#endif /* DIMENSIONXX_CAMERAS_HPP */
diff --git a/libdimensionxx/dimensionxx/canvas.hpp b/libdimensionxx/dimensionxx/canvas.hpp
deleted file mode 100644
index 321e1c7..0000000
--- a/libdimensionxx/dimensionxx/canvas.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_canvas* wrapper.
-
-#ifndef DIMENSIONXX_CANVAS_HPP
-#define DIMENSIONXX_CANVAS_HPP
-
-#include <tr1/memory>
-
-namespace Dimension
-{
- // Base canvas class. Wraps a dmnsn_canvas*.
- class Canvas
- {
- public:
- // Allocate a dmnsn_canvas of specified width and height
- Canvas(unsigned int width, unsigned int height);
-
- // Wrap an existing canvas
- explicit Canvas(dmnsn_canvas* canvas);
-
- // Canvas(const Canvas& canvas);
-
- // Delete the canvas
- ~Canvas();
-
- // Get the width and height
- unsigned int width() const;
- unsigned int height() const;
-
- // Get and set a pixel
- Color pixel(unsigned int x, unsigned int y) const;
- void pixel(unsigned int x, unsigned int y, const Color& c);
-
- // Access the wrapped C object.
- dmnsn_canvas* dmnsn();
- const dmnsn_canvas* dmnsn() const;
-
- private:
- // Copy-assignment prohibited
- Canvas& operator=(const Canvas&);
-
- std::tr1::shared_ptr<dmnsn_canvas*> m_canvas;
- };
-
- // Array_Element specialization
- template <>
- class Array_Element<Canvas>
- : public DMNSN_Array_Element<Canvas, dmnsn_canvas*>
- {
- public:
- typedef dmnsn_canvas* C_Type;
-
- Array_Element() { }
- Array_Element(Canvas& canvas)
- : DMNSN_Array_Element<Canvas, dmnsn_canvas*>(canvas) { }
- Array_Element(C_Type c)
- : DMNSN_Array_Element<Canvas, dmnsn_canvas*>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-}
-
-#endif /* DIMENSIONXX_CANVAS_HPP */
diff --git a/libdimensionxx/dimensionxx/color.hpp b/libdimensionxx/dimensionxx/color.hpp
deleted file mode 100644
index ad28c4d..0000000
--- a/libdimensionxx/dimensionxx/color.hpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Wrappers for libdimension colors.
-
-#ifndef DIMENSIONXX_COLOR_HPP
-#define DIMENSIONXX_COLOR_HPP
-
-namespace Dimension
-{
- // Forward declarations
- class CIE_XYZ;
- class CIE_xyY;
- class CIE_Lab;
- class CIE_Luv;
- class sRGB;
-
- // Default whitepoint (D50)
- extern const CIE_XYZ whitepoint;
-
- // Wrapper for dmnsn_color
- class Color
- {
- public:
- Color() { }
- inline Color(const CIE_XYZ& XYZ);
- inline Color(const CIE_xyY& xyY);
- inline Color(const CIE_Lab& Lab, const CIE_XYZ& white = whitepoint);
- inline Color(const CIE_Luv& Luv, const CIE_XYZ& white = whitepoint);
- inline Color(const sRGB& RGB);
- explicit Color(dmnsn_color c) : m_color(c) { }
- // Color(const Color& c);
- // ~Color();
-
- // Get and set filtered and unfiltered transparancy
- double filter() const { return m_color.filter; }
- double trans() const { return m_color.trans; }
-
- void filter(double f) { m_color.filter = f; }
- void trans(double t) { m_color.trans = t; }
-
- // Color& operator=(const Color& c);
-
- // Add a color to this one in a perceptually correct manner
- Color& operator+=(const Color& c)
- { m_color = dmnsn_color_add(m_color, c.m_color); return *this; }
-
- // Access the wrapped color
- dmnsn_color dmnsn() const { return m_color; }
-
- private:
- dmnsn_color m_color;
- };
-
- // Wrappers for all libdimension color types
-
- class CIE_XYZ
- {
- public:
- CIE_XYZ() { }
- CIE_XYZ(double X, double Y, double Z)
- { m_XYZ.X = X; m_XYZ.Y = Y; m_XYZ.Z = Z; }
- CIE_XYZ(const Color& c) : m_XYZ(dmnsn_XYZ_from_color(c.dmnsn())) { }
- explicit CIE_XYZ(dmnsn_CIE_XYZ XYZ) : m_XYZ(XYZ) { }
- // CIE_XYZ(const CIE_XYZ& XYZ);
- // ~CIE_XYZ();
-
- double X() const { return m_XYZ.X; }
- double Y() const { return m_XYZ.Y; }
- double Z() const { return m_XYZ.Z; }
-
- // CIE_XYZ& operator=(const CIE_XYZ& XYZ);
- CIE_XYZ& operator=(const Color& c)
- { m_XYZ = dmnsn_XYZ_from_color(c.dmnsn()); return *this; }
-
- dmnsn_CIE_XYZ dmnsn() const { return m_XYZ; }
-
- private:
- dmnsn_CIE_XYZ m_XYZ;
- };
-
- class CIE_xyY
- {
- public:
- CIE_xyY() { }
- CIE_xyY(double x, double y, double Y)
- { m_xyY.x = x; m_xyY.y = y; m_xyY.Y = Y; }
- CIE_xyY(const Color& c) : m_xyY(dmnsn_xyY_from_color(c.dmnsn())) { }
- explicit CIE_xyY(dmnsn_CIE_xyY xyY) : m_xyY(xyY) { }
- // CIE_xyY(const CIE_xyY& xyY);
- // ~CIE_xyY();
-
- double x() const { return m_xyY.x; }
- double y() const { return m_xyY.y; }
- double Y() const { return m_xyY.Y; }
-
- // CIE_xyY& operator=(const CIE_xyY& xyY);
- CIE_xyY& operator=(const Color& c)
- { m_xyY = dmnsn_xyY_from_color(c.dmnsn()); return *this; }
-
- dmnsn_CIE_xyY dmnsn() const { return m_xyY; }
-
- private:
- dmnsn_CIE_xyY m_xyY;
- };
-
- class CIE_Lab
- {
- public:
- CIE_Lab() { }
- CIE_Lab(double L, double a, double b)
- { m_Lab.L = L; m_Lab.a = a; m_Lab.b = b; }
- CIE_Lab(const Color& c, const CIE_XYZ& white = whitepoint)
- : m_Lab(dmnsn_Lab_from_color(c.dmnsn(), white.dmnsn())) { }
- explicit CIE_Lab(dmnsn_CIE_Lab Lab) : m_Lab(Lab) { }
- // CIE_Lab(const CIE_Lab& Lab);
- // ~CIE_Lab();
-
- double L() const { return m_Lab.L; }
- double a() const { return m_Lab.a; }
- double b() const { return m_Lab.b; }
-
- // CIE_Lab& operator=(const CIE_Lab& Lab);
- CIE_Lab& operator=(const Color& c)
- { m_Lab = dmnsn_Lab_from_color(c.dmnsn(), whitepoint.dmnsn());
- return *this; }
-
- dmnsn_CIE_Lab dmnsn() const { return m_Lab; }
-
- private:
- dmnsn_CIE_Lab m_Lab;
- };
-
- class CIE_Luv
- {
- public:
- CIE_Luv() { }
- CIE_Luv(double L, double u, double v)
- { m_Luv.L = L; m_Luv.u = u; m_Luv.v = v; }
- CIE_Luv(const Color& c, const CIE_XYZ& white = whitepoint)
- : m_Luv(dmnsn_Luv_from_color(c.dmnsn(), white.dmnsn())) { }
- explicit CIE_Luv(dmnsn_CIE_Luv Luv) : m_Luv(Luv) { }
- // CIE_Luv(const CIE_Luv& Luv);
- // ~CIE_Luv();
-
- double L() const { return m_Luv.L; }
- double u() const { return m_Luv.u; }
- double v() const { return m_Luv.v; }
-
- // CIE_Luv& operator=(const CIE_Luv& Luv);
- CIE_Luv& operator=(const Color& c)
- { m_Luv = dmnsn_Luv_from_color(c.dmnsn(), whitepoint.dmnsn());
- return *this; }
-
- dmnsn_CIE_Luv dmnsn() const { return m_Luv; }
-
- private:
- dmnsn_CIE_Luv m_Luv;
- };
-
- class sRGB
- {
- public:
- sRGB() { }
- sRGB(double R, double G, double B)
- { m_RGB.R = R; m_RGB.G = G; m_RGB.B = B; }
- sRGB(const Color& c) : m_RGB(dmnsn_sRGB_from_color(c.dmnsn())) { }
- explicit sRGB(dmnsn_sRGB RGB) : m_RGB(RGB) { }
- // sRGB(const sRGB& RGB);
- // ~sRGB();
-
- double R() const { return m_RGB.R; }
- double G() const { return m_RGB.G; }
- double B() const { return m_RGB.B; }
-
- // sRGB& operator=(const sRGB& RGB);
- sRGB& operator=(const Color& c)
- { m_RGB = dmnsn_sRGB_from_color(c.dmnsn()); return *this; }
-
- dmnsn_sRGB dmnsn() const { return m_RGB; }
-
- private:
- dmnsn_sRGB m_RGB;
- };
-
- // Array_Element specialization
- template <>
- class Array_Element<Color>
- : public By_Value_Array_Element<Color, dmnsn_color>
- {
- public:
- typedef dmnsn_color C_Type;
-
- Array_Element() { }
- Array_Element(Color& color)
- : By_Value_Array_Element<Color, dmnsn_color>(color) { }
- Array_Element(C_Type c)
- : By_Value_Array_Element<Color, dmnsn_color>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-
- // Color inline constructors
-
- inline Color::Color(const CIE_XYZ& XYZ)
- : m_color(dmnsn_color_from_XYZ(XYZ.dmnsn())) { }
-
- inline Color::Color(const CIE_xyY& xyY)
- : m_color(dmnsn_color_from_xyY(xyY.dmnsn())) { }
-
- inline Color::Color(const CIE_Lab& Lab, const CIE_XYZ& white)
- : m_color(dmnsn_color_from_Lab(Lab.dmnsn(), white.dmnsn())) { }
-
- inline Color::Color(const CIE_Luv& Luv, const CIE_XYZ& white)
- : m_color(dmnsn_color_from_Luv(Luv.dmnsn(), white.dmnsn())) { }
-
- inline Color::Color(const sRGB& RGB)
- : m_color(dmnsn_color_from_sRGB(RGB.dmnsn())) { }
-
- // Color operators
-
- // Perceptually correct color combination
- inline Color
- operator+(const Color& lhs, const Color& rhs)
- {
- Color temp = lhs;
- temp += rhs;
- return temp;
- }
-
- // Perceptual color difference
- inline double
- operator-(const Color& lhs, const Color& rhs)
- {
- return dmnsn_color_difference(lhs.dmnsn(), rhs.dmnsn());
- }
-}
-
-#endif /* DIMENSIONXX_COLOR_HPP */
diff --git a/libdimensionxx/dimensionxx/cookie.hpp b/libdimensionxx/dimensionxx/cookie.hpp
deleted file mode 100644
index 7df88c8..0000000
--- a/libdimensionxx/dimensionxx/cookie.hpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Some internal magic to use C FILE* I/O with C++ streams.
-
-#ifndef DIMENSIONXX_COOKIE_HPP
-#define DIMENSIONXX_COOKIE_HPP
-
-#include <istream>
-#include <ostream>
-#include <cstdio>
-
-namespace Dimension
-{
- // Simple RAII classes for FILE*'s which interface with a C++ stream.
-
- class FILE_Cookie
- {
- public:
- // Destructor made pure virtual
- virtual ~FILE_Cookie() = 0;
-
- // Get the magic FILE*
- FILE* file() { return m_file; }
- const FILE* file() const { return m_file; }
-
- protected:
- FILE_Cookie() { }
-
- // Set the underlying FILE*
- void file(FILE* file) { m_file = file; }
-
- private:
- std::FILE* m_file;
-
- // Copying prohibited
- FILE_Cookie(const FILE_Cookie& cookie);
- FILE_Cookie& operator=(const FILE_Cookie& cookie);
- };
-
- class iFILE_Cookie : public virtual FILE_Cookie
- {
- public:
- iFILE_Cookie(std::istream& istr);
- virtual ~iFILE_Cookie();
-
- // Get the C++ streams
- std::istream& istr() { return *m_istr; }
- const std::istream& istr() const { return *m_istr; }
-
- protected:
- // Just set the istream without initializing the FILE*
- iFILE_Cookie(std::istream& istr, int) : m_istr(&istr) { }
-
- private:
- std::istream* m_istr;
- };
-
- class oFILE_Cookie : public virtual FILE_Cookie
- {
- public:
- oFILE_Cookie(std::ostream& ostr);
- virtual ~oFILE_Cookie();
-
- // Get the C++ streams
- std::ostream& ostr() { return *m_ostr; }
- const std::ostream& ostr() const { return *m_ostr; }
-
- protected:
- // Just set the istream without initializing the FILE*
- oFILE_Cookie(std::ostream& ostr, int) : m_ostr(&ostr) { }
-
- private:
- std::ostream* m_ostr;
- };
-
- class ioFILE_Cookie : public iFILE_Cookie, public oFILE_Cookie
- {
- public:
- ioFILE_Cookie(std::iostream& iostr);
- virtual ~ioFILE_Cookie();
- };
-}
-
-#endif /* DIMENSIONXX_COOKIE_HPP */
diff --git a/libdimensionxx/dimensionxx/cube.hpp b/libdimensionxx/dimensionxx/cube.hpp
deleted file mode 100644
index 6ec95f0..0000000
--- a/libdimensionxx/dimensionxx/cube.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Cube wrapper
-
-#ifndef DIMENSIONXX_CUBE_HPP
-#define DIMENSIONXX_CUBE_HPP
-
-namespace Dimension
-{
-}
-
-#endif /* DIMENSIONXX_CUBE_HPP */
diff --git a/libdimensionxx/dimensionxx/error.hpp b/libdimensionxx/dimensionxx/error.hpp
deleted file mode 100644
index 17c2af4..0000000
--- a/libdimensionxx/dimensionxx/error.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Wrappers for libdimension error handling, and an exception class.
-// dmnsn_error is still used by libdimensionxx whenever an exception shouldn't
-// be thrown, like in destructors, and whenever libdimension uses it internally.
-// Exceptions are thrown otherwise to report errors.
-
-#ifndef DIMENSIONXX_ERROR_HPP
-#define DIMENSIONXX_ERROR_HPP
-
-#include <dimension.h>
-#include <stdexcept>
-#include <string>
-
-namespace Dimension
-{
- // Wrapper for dmnsn_severity
- enum Severity {
- SEVERITY_LOW = DMNSN_SEVERITY_LOW,
- SEVERITY_MEDIUM = DMNSN_SEVERITY_MEDIUM,
- SEVERITY_HIGH = DMNSN_SEVERITY_HIGH
- };
-
- // Get or set the resilience, thread-safely
- Severity resilience();
- void resilience(Severity resilience);
-
- // Generic exception class, derives from std::runtime_error
- class Dimension_Error : public std::runtime_error
- {
- public:
- Dimension_Error(const std::string& str);
- };
-}
-
-#endif /* DIMENSIONXX_ERROR_HPP */
diff --git a/libdimensionxx/dimensionxx/geometry.hpp b/libdimensionxx/dimensionxx/geometry.hpp
deleted file mode 100644
index 10cf452..0000000
--- a/libdimensionxx/dimensionxx/geometry.hpp
+++ /dev/null
@@ -1,322 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Wrappers for geometric types (Vectors, Matricies, Lines (rays)).
-
-#ifndef DIMENSIONXX_GEOMETRY_HPP
-#define DIMENSIONXX_GEOMETRY_HPP
-
-#include <dimension.h>
-
-namespace Dimension
-{
- class Vector;
-
- // Wrapper for dmnsn_matrix
- class Matrix
- {
- public:
- Matrix() { }
- Matrix(double a0, double a1, double a2, double a3,
- double b0, double b1, double b2, double b3,
- double c0, double c1, double c2, double c3,
- double d0, double d1, double d2, double d3)
- : m_matrix(dmnsn_matrix_construct(a0, a1, a2, a3,
- b0, b1, b2, b3,
- c0, c1, c2, c3,
- d0, d1, d2, d3)) { }
- explicit Matrix(dmnsn_matrix m) : m_matrix(m) { }
- // Matrix(const Matrix& m);
- // ~Matrix();
-
- // Element access
- double* operator[](unsigned int i) { return m_matrix.n[i]; }
-
- // Matrix arithmetic
-
- // Matrix& operator=(const Matrix& rhs);
- Matrix& operator*=(const Matrix& rhs)
- { m_matrix = dmnsn_matrix_mul(rhs.m_matrix, m_matrix); return *this; }
-
- // Get the wrapped matrix
- dmnsn_matrix dmnsn() const { return m_matrix; }
-
- // Special constructors
- static inline Matrix identity();
- static inline Matrix scale(const Vector& factor);
- static inline Matrix translation(const Vector& d);
- static inline Matrix rotation(const Vector& theta);
-
- private:
- dmnsn_matrix m_matrix;
- };
-
- // Wrapper for dmnsn_vector
- class Vector
- {
- public:
- Vector() { }
- Vector(double x, double y, double z)
- : m_vector(dmnsn_vector_construct(x, y, z)) { }
- explicit Vector(dmnsn_vector v) : m_vector(v) { }
- // Vector(const Vector& v);
- // ~Vector();
-
- // Get the x, y, and z components.
- double x() const { return m_vector.x; }
- double y() const { return m_vector.y; }
- double z() const { return m_vector.z; }
-
- // Vector arithmetic
-
- // Vector& operator=(const Vector& rhs);
- Vector& operator+=(const Vector& rhs)
- { m_vector = dmnsn_vector_add(m_vector, rhs.m_vector); return *this; }
- Vector& operator-=(const Vector& rhs)
- { m_vector = dmnsn_vector_sub(m_vector, rhs.m_vector); return *this; }
- Vector& operator*=(double rhs)
- { m_vector = dmnsn_vector_mul(rhs, m_vector); return *this; }
- Vector& operator*=(const Matrix& m)
- { m_vector = dmnsn_matrix_vector_mul(m.dmnsn(), m_vector); return *this; }
- Vector& operator/=(double rhs)
- { m_vector = dmnsn_vector_div(m_vector, rhs); return *this; }
-
- // Get the wrapped vector
- dmnsn_vector dmnsn() const { return m_vector; }
-
- private:
- dmnsn_vector m_vector;
- };
-
- // Wrapper for dmnsn_line
- class Line
- {
- public:
- Line() { }
- Line(const Vector& x0, const Vector& n)
- { m_line.x0 = x0.dmnsn(); m_line.n = n.dmnsn(); }
- explicit Line(dmnsn_line l) : m_line(l) { }
- // Line(const Line& l);
- // ~Line();
-
- Vector x0() const { return Vector(m_line.x0); }
- Vector n() const { return Vector(m_line.n); }
- double t(const Vector& v) { return dmnsn_line_index(m_line, v.dmnsn()); }
-
- // Line& operator=(const Line& l);
- Line& operator*=(const Matrix& m)
- { m_line = dmnsn_matrix_line_mul(m.dmnsn(), m_line); return *this; }
-
- // Get the point `t' on the line (x0 + t*n)
- Vector operator()(double t) { return Vector(dmnsn_line_point(m_line, t)); }
-
- // Get the wrapped line
- dmnsn_line dmnsn() const { return m_line; }
-
- private:
- dmnsn_line m_line;
- };
-
- // Array_Element specializations
-
- template <>
- class Array_Element<Matrix>
- : public By_Value_Array_Element<Matrix, dmnsn_matrix>
- {
- public:
- typedef dmnsn_matrix C_Type;
-
- Array_Element() { }
- Array_Element(Matrix& matrix)
- : By_Value_Array_Element<Matrix, dmnsn_matrix>(matrix) { }
- Array_Element(C_Type c)
- : By_Value_Array_Element<Matrix, dmnsn_matrix>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-
- template <>
- class Array_Element<Vector>
- : public By_Value_Array_Element<Vector, dmnsn_vector>
- {
- public:
- typedef dmnsn_vector C_Type;
-
- Array_Element() { }
- Array_Element(Vector& vector)
- : By_Value_Array_Element<Vector, dmnsn_vector>(vector) { }
- Array_Element(C_Type c)
- : By_Value_Array_Element<Vector, dmnsn_vector>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-
- template <>
- class Array_Element<Line>
- : public By_Value_Array_Element<Line, dmnsn_line>
- {
- public:
- typedef dmnsn_line C_Type;
-
- Array_Element() { }
- Array_Element(Line& line)
- : By_Value_Array_Element<Line, dmnsn_line>(line) { }
- Array_Element(C_Type c)
- : By_Value_Array_Element<Line, dmnsn_line>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-
- // Matrix operators
-
- inline Matrix
- operator*(const Matrix& lhs, const Matrix& rhs)
- {
- // This order is important!
- Matrix r = rhs;
- r *= lhs;
- return r;
- }
-
- inline Matrix
- inverse(const Matrix& M)
- {
- return Matrix(dmnsn_matrix_inverse(M.dmnsn()));
- }
-
- // Special Matrix constructors
-
- inline Matrix
- Matrix::identity()
- {
- return Matrix(dmnsn_identity_matrix());
- }
-
- inline Matrix
- Matrix::scale(const Vector& factor)
- {
- return Matrix(dmnsn_scale_matrix(factor.dmnsn()));
- }
-
- inline Matrix
- Matrix::translation(const Vector& d)
- {
- return Matrix(dmnsn_translation_matrix(d.dmnsn()));
- }
-
- inline Matrix
- Matrix::rotation(const Vector& theta)
- {
- return Matrix(dmnsn_rotation_matrix(theta.dmnsn()));
- }
-
- // Vector operators
-
- inline Vector
- operator+(const Vector& lhs, const Vector& rhs)
- {
- Vector r = lhs;
- r += rhs;
- return r;
- }
-
- inline Vector
- operator-(const Vector& lhs, const Vector& rhs)
- {
- Vector r = lhs;
- r -= rhs;
- return r;
- }
-
- inline Vector
- operator*(const Vector& lhs, double rhs)
- {
- Vector r = lhs;
- r *= rhs;
- return r;
- }
-
- inline Vector
- operator*(double lhs, const Vector& rhs)
- {
- Vector r = rhs;
- r *= lhs;
- return r;
- }
-
- inline Vector
- operator*(const Matrix& lhs, const Vector& rhs)
- {
- Vector r = rhs;
- r *= lhs;
- return r;
- }
-
- inline Vector
- operator/(const Vector& lhs, double rhs)
- {
- Vector r = lhs;
- r /= rhs;
- return r;
- }
-
- inline double
- norm(const Vector& v)
- {
- return dmnsn_vector_norm(v.dmnsn());
- }
-
- inline Vector
- normalize(const Vector& v)
- {
- return Vector(dmnsn_vector_normalize(v.dmnsn()));
- }
-
- // Dot product
- inline double
- dot(const Vector& lhs, const Vector& rhs)
- {
- return dmnsn_vector_dot(lhs.dmnsn(), rhs.dmnsn());
- }
-
- // Cross product
- inline Vector
- cross(const Vector& lhs, const Vector& rhs)
- {
- return Vector(dmnsn_vector_cross(lhs.dmnsn(), rhs.dmnsn()));
- }
-
- // Line transformation
- inline Line
- operator*(const Matrix& lhs, const Line& rhs)
- {
- Line r = rhs;
- r *= lhs;
- return r;
- }
-}
-
-#endif /* DIMENSIONXX_GEOMETRY_HPP */
diff --git a/libdimensionxx/dimensionxx/gl.hpp b/libdimensionxx/dimensionxx/gl.hpp
deleted file mode 100644
index dcf02f2..0000000
--- a/libdimensionxx/dimensionxx/gl.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// C++ wrapper for libdimension GL support
-
-#ifndef DIMENSIONXX_GL_HPP
-#define DIMENSIONXX_GL_HPP
-
-#include <istream>
-#include <ostream>
-
-namespace Dimension
-{
- class GL_Writer
- {
- public:
- GL_Writer(Canvas& canvas);
- ~GL_Writer();
-
- void write();
-
- private:
- // Copying prohibited
- GL_Writer(const GL_Writer&);
- GL_Writer& operator=(const GL_Writer&);
-
- Canvas* m_canvas;
- bool m_written;
- };
-
- class GL_Reader
- {
- public:
- GL_Reader();
- // ~GL_Reader();
-
- Canvas read(unsigned int x0, unsigned int y0,
- unsigned int width, unsigned int height);
-
- private:
- // Copying prohibited
- GL_Reader(const GL_Reader&);
- GL_Reader& operator=(const GL_Reader&);
- };
-}
-
-#endif /* DIMENSIONXX_GL_HPP */
diff --git a/libdimensionxx/dimensionxx/object.hpp b/libdimensionxx/dimensionxx/object.hpp
deleted file mode 100644
index 4c9dbff..0000000
--- a/libdimensionxx/dimensionxx/object.hpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_object* wrapper.
-
-#ifndef DIMENSIONXX_OBJECT_HPP
-#define DIMENSIONXX_OBJECT_HPP
-
-namespace Dimension
-{
- // Type to represent a ray-object intersection
- class Intersection
- {
- public:
- Intersection(const Line& ray, double t, const Texture& texture);
- explicit Intersection(dmnsn_intersection *intersection);
- // Intersection(const Intersection& intersection);
- ~Intersection();
-
- Line& ray() { return m_ray; }
- const Line& ray() const { return m_ray; }
-
- double t() const { return dmnsn()->t; }
- void t(double t) { dmnsn()->t = t; }
-
- const Texture& texture() const { return m_texture; }
-
- dmnsn_intersection* dmnsn();
- const dmnsn_intersection* dmnsn() const;
-
- dmnsn_intersection* release();
-
- private:
- // Copy-assignment prohibited
- Intersection& operator=(const Intersection& intersection);
-
- std::tr1::shared_ptr<dmnsn_intersection*> m_intersection;
- Line m_ray;
- const Texture m_texture;
- };
-
- // Base object class. Wraps a dmnsn_object*.
- class Object
- {
- public:
- // Wrap an existing object.
- explicit Object(dmnsn_object* object);
- // Delete the object
- virtual ~Object();
-
- // Get/set the transformation matrix
- Matrix trans();
- void trans(const Matrix& trans);
-
- // Object callbacks
- virtual Intersection intersection(const Line& l);
- virtual bool inside(const Vector& point);
-
- // Shallow-copy a derived object
- virtual Object* copy() const;
-
- // Access the wrapped C object
- dmnsn_object* dmnsn();
- const dmnsn_object* dmnsn() const;
-
- protected:
- // No-op
- Object();
- // Shallow copy
- Object(const Object& object);
-
- // Is m_object unique?
- bool unique() const;
-
- // Set the wrapped object
- void dmnsn(dmnsn_object* object);
-
- private:
- // Copy-assignment prohibited
- Object& operator=(const Object&);
-
- std::tr1::shared_ptr<dmnsn_object*> m_object;
- };
-
- // A custom object abstract base class, for creating your own object types
- class Custom_Object : public Object
- {
- public:
- Custom_Object();
- virtual ~Custom_Object();
-
- virtual Intersection intersection(const Line& l) = 0;
- virtual bool inside(const Vector& point) = 0;
- };
-
- // Array_Element specialization
- template <>
- class Array_Element<Object>
- : public Polymorphic_Array_Element<Object, dmnsn_object*>
- {
- public:
- typedef dmnsn_object* C_Type;
-
- Array_Element() { }
- Array_Element(Object& object)
- : Polymorphic_Array_Element<Object, dmnsn_object*>(object) { }
- Array_Element(C_Type c)
- : Polymorphic_Array_Element<Object, dmnsn_object*>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-}
-
-#endif /* DIMENSIONXX_OBJECT_HPP */
diff --git a/libdimensionxx/dimensionxx/objects.hpp b/libdimensionxx/dimensionxx/objects.hpp
deleted file mode 100644
index 6f7cce0..0000000
--- a/libdimensionxx/dimensionxx/objects.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Object wrappers.
-
-#ifndef DIMENSIONXX_OBJECTS_HPP
-#define DIMENSIONXX_OBJECTS_HPP
-
-namespace Dimension
-{
- // Sphere object
- class Sphere : public Object
- {
- public:
- Sphere();
- // ~Sphere();
-
- // Shallow-copy the sphere
- Object* copy() const;
-
- private:
- // Copying prohibited, but used internally
- Sphere(const Sphere& sphere);
- Sphere& operator=(const Sphere&);
- };
-
- // A cube
- class Cube : public Object
- {
- public:
- Cube();
- // ~Cube();
-
- // Shallow-copy the cube
- Object* copy() const;
-
- private:
- // Copying prohibited, but used internally
- Cube(const Cube& cube);
- Cube& operator=(const Cube&);
- };
-}
-
-#endif /* DIMENSIONXX_OBJECTS_HPP */
diff --git a/libdimensionxx/dimensionxx/png.hpp b/libdimensionxx/dimensionxx/png.hpp
deleted file mode 100644
index 28a5504..0000000
--- a/libdimensionxx/dimensionxx/png.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// C++ wrapper for libdimension PNG support
-
-#ifndef DIMENSIONXX_PNG_HPP
-#define DIMENSIONXX_PNG_HPP
-
-#include <istream>
-#include <ostream>
-
-namespace Dimension
-{
- class PNG_Writer
- {
- public:
- PNG_Writer(Canvas& canvas, std::ostream& ostr);
- ~PNG_Writer();
-
- void write();
- Progress write_async();
-
- private:
- // Copying prohibited
- PNG_Writer(const PNG_Writer&);
- PNG_Writer& operator=(const PNG_Writer&);
-
- Canvas* m_canvas;
- std::ostream* m_ostr;
- bool m_written;
- };
-
- class PNG_Reader
- {
- public:
- PNG_Reader(std::istream& istr);
- // ~PNG_Reader();
-
- Canvas read();
-
- Progress read_async();
- static Canvas finish(Progress& progress);
-
- private:
- // Copying prohibited
- PNG_Reader(const PNG_Reader&);
- PNG_Reader& operator=(const PNG_Reader&);
-
- std::istream* m_istr;
- bool m_read;
- };
-}
-
-#endif /* DIMENSIONXX_PNG_HPP */
diff --git a/libdimensionxx/dimensionxx/progress.hpp b/libdimensionxx/dimensionxx/progress.hpp
deleted file mode 100644
index 555c8c5..0000000
--- a/libdimensionxx/dimensionxx/progress.hpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_progress* wrapper.
-
-#ifndef DIMENSIONXX_PROGRESS_HPP
-#define DIMENSIONXX_PROGRESS_HPP
-
-#include <tr1/memory> // For tr1::shared_ptr
-#include <list>
-
-namespace Dimension
-{
- // Base class for persisting objects
- class Persist_Base
- {
- public:
- virtual ~Persist_Base() = 0;
-
- protected:
- Persist_Base() { }
-
- private:
- // Copying prohibited
- Persist_Base(const Persist_Base&);
- Persist_Base& operator=(const Persist_Base&);
- };
-
- // Class for persisting objects
- template <typename T>
- class Persist : public Persist_Base
- {
- public:
- Persist(T* t) : m_t(t) { }
- virtual ~Persist() { delete m_t; }
-
- T* persisted() const { return m_t; }
-
- private:
- T* m_t;
- };
-
- // Class for persisting many objects
- class Persister
- {
- public:
- // Persister();
- // Persister(const Persister& persister);
- // ~Persister();
-
- // Persister& operator=(const Persister& persister);
-
- template <typename T>
- void persist(T* t);
-
- // Access the first persisted element
- template <typename T>
- Persist<T>& first();
-
- private:
- // Copy-assignment prohibited
- Persister& operator=(const Persister&);
-
- std::list<std::tr1::shared_ptr<Persist_Base> > m_persists;
- };
-
- // dmnsn_progress* wrapper class to represent an asynchronous worker thread
- class Progress
- {
- public:
- explicit Progress(dmnsn_progress* progress);
- Progress(dmnsn_progress* progress, const Persister& persister);
- // Progress(const Progress& progress);
-
- // Finishes the job without throwing
- ~Progress();
-
- double progress() const;
- void wait(double progress) const;
-
- void new_element(unsigned int total);
- void increment();
- void done();
-
- // Wait for job to finish, throwing if the job failed
- void finish();
-
- // Access the set of persisted objects
- Persister& persister();
-
- // Access the wrapped C object.
- dmnsn_progress* dmnsn();
- const dmnsn_progress* dmnsn() const;
-
- private:
- // Copy assignment prohibited
- Progress& operator=(const Progress&);
-
- std::tr1::shared_ptr<dmnsn_progress*> m_progress;
- Persister m_persister;
- };
-
- template <typename T>
- void
- Persister::persist(T* t)
- {
- m_persists.push_back(std::tr1::shared_ptr<Persist_Base>(new Persist<T>(t)));
- }
-
- template <typename T>
- Persist<T>&
- Persister::first()
- {
- return dynamic_cast<Persist<T>&>(*m_persists.front());
- }
-}
-
-#endif /* DIMENSIONXX_PROGRESS_HPP */
diff --git a/libdimensionxx/dimensionxx/raytrace.hpp b/libdimensionxx/dimensionxx/raytrace.hpp
deleted file mode 100644
index 7f69008..0000000
--- a/libdimensionxx/dimensionxx/raytrace.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// C++ wrapper for libdimension raytracing
-
-#ifndef DIMENSIONXX_RAYTRACE_HPP
-#define DIMENSIONXX_RAYTRACE_HPP
-
-#include <istream>
-#include <ostream>
-
-namespace Dimension
-{
- class Raytracer
- {
- public:
- Raytracer(Scene& scene);
- ~Raytracer();
-
- // Render the scene
- void render();
- Progress render_async();
-
- private:
- // Copying prohibited
- Raytracer(const Raytracer&);
- Raytracer& operator=(const Raytracer&);
-
- Scene* m_scene;
- bool m_rendered;
- };
-}
-
-#endif /* DIMENSIONXX_RAYTRACE_HPP */
diff --git a/libdimensionxx/dimensionxx/scene.hpp b/libdimensionxx/dimensionxx/scene.hpp
deleted file mode 100644
index c79152f..0000000
--- a/libdimensionxx/dimensionxx/scene.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_scene* wrapper.
-
-#ifndef DIMENSIONXX_SCENE_HPP
-#define DIMENSIONXX_SCENE_HPP
-
-namespace Dimension
-{
- // Wrapper for dmnsn_quality
- enum Quality {
- RENDER_NONE = DMNSN_RENDER_NONE,
- RENDER_OBJECTS = DMNSN_RENDER_OBJECTS,
- RENDER_FULL = DMNSN_RENDER_FULL
- };
-
- // Base scene class. Wraps a dmnsn_scene*.
- class Scene
- {
- public:
- // Allocate a dmnsn_scene*
- Scene(Camera& camera, Canvas& canvas);
-
- // Scene(const Scene& scene);
-
- // Delete the scene
- ~Scene();
-
- // Element access
- Color background() const;
- void background(const Color& color);
-
- Camera& camera();
- const Camera& camera() const;
-
- Canvas& canvas();
- const Canvas& canvas() const;
-
- Array<Object>& objects();
- const Array<Object>& objects() const;
-
- Quality quality() const;
- void quality(Quality quality);
-
- // Access the wrapped C object.
- dmnsn_scene* dmnsn();
- const dmnsn_scene* dmnsn() const;
-
- private:
- // Copy-assignment prohibited
- Scene& operator=(const Scene&);
-
- std::tr1::shared_ptr<dmnsn_scene*> m_scene;
- std::tr1::shared_ptr<Camera> m_camera;
- std::tr1::shared_ptr<Canvas> m_canvas;
- Array<Object> m_objects;
- };
-}
-
-#endif /* DIMENSIONXX_SCENE_HPP */
diff --git a/libdimensionxx/dimensionxx/texture.hpp b/libdimensionxx/dimensionxx/texture.hpp
deleted file mode 100644
index 7f42206..0000000
--- a/libdimensionxx/dimensionxx/texture.hpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// dmnsn_texture* wrapper.
-
-#ifndef DIMENSIONXX_TEXTURE_HPP
-#define DIMENSIONXX_TEXTURE_HPP
-
-namespace Dimension
-{
- // Pigment base class. Wraps a dmnsn_pigment*.
- class Pigment
- {
- public:
- explicit Pigment(dmnsn_pigment* pigment);
- ~Pigment();
-
- Pigment* copy() const;
-
- dmnsn_pigment* dmnsn();
- const dmnsn_pigment* dmnsn() const;
-
- protected:
- // No-op
- Pigment();
- // Shallow copy
- Pigment(const Pigment& pigment);
-
- // Is m_pigment unique?
- bool unique() const;
-
- private:
- // Copy-assignment prohibited
- Pigment& operator=(const Pigment&);
-
- std::tr1::shared_ptr<dmnsn_pigment*> m_pigment;
- };
-
- // Texture class. Wraps a dmnsn_texture*.
- class Texture
- {
- public:
- Texture(const Pigment& pigment);
- explicit Texture(dmnsn_texture* texture);
- // Texture(const Texture& texture);
- ~Texture();
-
- dmnsn_texture* dmnsn();
- const dmnsn_texture* dmnsn() const;
-
- private:
- // Copy-assignment prohibited
- Texture& operator=(const Texture&);
-
- std::tr1::shared_ptr<dmnsn_texture*> m_texture;
- std::tr1::shared_ptr<Pigment> m_pigment;
- };
-
- // Array_Element specializations
-
- template <>
- class Array_Element<Pigment>
- : public Polymorphic_Array_Element<Pigment, dmnsn_pigment*>
- {
- public:
- typedef dmnsn_pigment* C_Type;
-
- Array_Element() { }
- Array_Element(Pigment& pigment)
- : Polymorphic_Array_Element<Pigment, dmnsn_pigment*>(pigment) { }
- Array_Element(C_Type c)
- : Polymorphic_Array_Element<Pigment, dmnsn_pigment*>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-
- template <>
- class Array_Element<Texture>
- : public DMNSN_Array_Element<Texture, dmnsn_texture*>
- {
- public:
- typedef dmnsn_texture* C_Type;
-
- Array_Element() { }
- Array_Element(Texture& texture)
- : DMNSN_Array_Element<Texture, dmnsn_texture*>(texture) { }
- Array_Element(C_Type c)
- : DMNSN_Array_Element<Texture, dmnsn_texture*>(c) { }
- // Array_Element(const Array_Element& ae);
- // ~Array_Element();
-
- // Array_Element& operator=(const Array_Element& ae);
- };
-}
-
-#endif /* DIMENSIONXX_TEXTURE_HPP */
diff --git a/libdimensionxx/dimensionxx/utility.hpp b/libdimensionxx/dimensionxx/utility.hpp
deleted file mode 100644
index 50c5e67..0000000
--- a/libdimensionxx/dimensionxx/utility.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-// Template utilities
-
-#ifndef DIMENSIONXX_UTILITY_HPP
-#define DIMENSIONXX_UTILITY_HPP
-
-namespace Dimension
-{
- // A constraint enforcing that T is a POD type by making it part of a union.
- // Taking the address of this function will cause a compile-time failure if
- // T is not a POD type.
- template <typename T>
- void POD_constraint();
-
- // POD constraint implementation
- template <typename T>
- void
- POD_constraint()
- {
- union
- {
- T t;
- } constraint;
- static_cast<void>(constraint); // Silence unused variable warning
- }
-}
-
-#endif // DIMENSIONXX_UTILITY_HPP
diff --git a/libdimensionxx/error.cpp b/libdimensionxx/error.cpp
deleted file mode 100644
index 665c5c9..0000000
--- a/libdimensionxx/error.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-#include <stdexcept>
-#include <string>
-
-namespace Dimension
-{
- // Get the resilience, thread-safely, with dmnsn_get_resilience().
- Severity
- resilience()
- {
- return static_cast<Severity>(dmnsn_get_resilience());
- }
-
- // Set the resilience, thread-safely, with dmnsn_set_resilience().
- void
- resilience(Severity resilience)
- {
- dmnsn_set_resilience(static_cast<dmnsn_severity>(resilience));
- }
-
- // Dimension_Error constructor
- Dimension_Error::Dimension_Error(const std::string& str)
- : std::runtime_error(str) { }
-}
diff --git a/libdimensionxx/gl.cpp b/libdimensionxx/gl.cpp
deleted file mode 100644
index 7d0c0a3..0000000
--- a/libdimensionxx/gl.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-#include <cstdio>
-
-namespace Dimension
-{
- GL_Writer::GL_Writer(Canvas& canvas)
- : m_canvas(&canvas), m_written(false)
- {
- // Optimize the canvas for GL writeing
- dmnsn_gl_optimize_canvas(m_canvas->dmnsn());
- }
-
- // Draw the canvas if it hasn't been writen yet
- GL_Writer::~GL_Writer()
- {
- if (!m_written) {
- try {
- write();
- } catch (...) {
- dmnsn_error(SEVERITY_MEDIUM,
- "Drawing canvas to GL failed in GL_Writer destructor.");
- }
- }
- }
-
- // Draw the canvas to the current openGL buffer
- void GL_Writer::write()
- {
- // Draw to the GL buffer
- if (dmnsn_gl_write_canvas(m_canvas->dmnsn()) != 0) {
- // The writeing operation failed
- throw Dimension_Error("Drawing canvas to GL failed.");
- }
-
- m_written = true; // Don't write again in destructor
- }
-
- // No-op
- GL_Reader::GL_Reader() { }
-
- // Read a canvas from a GL buffer
- Canvas
- GL_Reader::read(unsigned int x0, unsigned int y0,
- unsigned int width, unsigned int height)
- {
- // Read the canvas from the GL buffer
- dmnsn_canvas* canvas = dmnsn_gl_read_canvas(x0, y0, width, height);
- if (!canvas) {
- // The read operation failed
- throw Dimension_Error("Reading canvas from GL failed.");
- }
-
- return Canvas(canvas);
- }
-}
diff --git a/libdimensionxx/object.cpp b/libdimensionxx/object.cpp
deleted file mode 100644
index c36a37f..0000000
--- a/libdimensionxx/object.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Construct an intersection object
- Intersection::Intersection(const Line& ray, double t, const Texture& texture)
- : m_intersection(new dmnsn_intersection*(dmnsn_new_intersection())),
- m_ray(ray), m_texture(texture)
- {
- dmnsn()->t = t;
- }
-
- // Wrap an existing intersection - don't release() one of these
- Intersection::Intersection(dmnsn_intersection *intersection)
- : m_intersection(new dmnsn_intersection*(intersection)),
- m_ray(intersection->ray),
- m_texture(const_cast<dmnsn_texture*>(intersection->texture))
- { }
-
- // Delete an intersection
- Intersection::~Intersection() {
- if (m_intersection && m_intersection.unique()) {
- dmnsn_delete_intersection(dmnsn());
- }
- }
-
- dmnsn_intersection*
- Intersection::dmnsn()
- {
- if (!m_intersection) {
- throw Dimension_Error("Attempt to access released intersection.");
- }
- return *m_intersection;
- }
-
- const dmnsn_intersection*
- Intersection::dmnsn() const
- {
- if (!m_intersection) {
- throw Dimension_Error("Attempt to access released intersection.");
- }
- return *m_intersection;
- }
-
- dmnsn_intersection*
- Intersection::release()
- {
- if (!m_intersection) {
- throw Dimension_Error("Attempt to release previously released"
- " intersection.");
- }
-
- if (!m_intersection.unique()) {
- throw Dimension_Error("Attempt to release non-unique intersection.");
- }
-
- dmnsn_intersection* intersection = dmnsn();
- m_intersection.reset();
- return intersection;
- }
-
- // Manual constructor
- Object::Object(dmnsn_object* object)
- : m_object(new dmnsn_object*(object))
- { }
-
- // Virtual Object destructor
- Object::~Object()
- {
- if (unique()) {
- dmnsn_delete_object(dmnsn());
- }
- }
-
- // Get the transformation matrix
- Matrix
- Object::trans()
- {
- return Matrix(dmnsn()->trans);
- }
-
- // Set the transformation matrix
- void
- Object::trans(const Matrix& trans)
- {
- dmnsn()->trans = trans.dmnsn();
- }
-
- // Intersection list for the line l
- Intersection
- Object::intersection(const Line& l)
- {
- return Intersection((*dmnsn()->intersection_fn)(dmnsn(), l.dmnsn()));
- }
-
- // Whether the point `point' is inside the object
- bool
- Object::inside(const Vector& point)
- {
- return (*dmnsn()->inside_fn)(dmnsn(), point.dmnsn());
- }
-
- // Return the wrapped object
- dmnsn_object*
- Object::dmnsn()
- {
- if (!m_object) {
- throw Dimension_Error("Attempt to access NULL object.");
- }
-
- return *m_object;
- }
-
- Object*
- Object::copy() const
- {
- return new Object(*this);
- }
-
- // Return a const version of the wrapped canvas
- const dmnsn_object*
- Object::dmnsn() const
- {
- if (!m_object) {
- throw Dimension_Error("Attempt to access NULL object.");
- }
-
- return *m_object;
- }
-
- // Protected default no-op constructor
- Object::Object()
- : m_object()
- { }
-
- // Protected copy constructor
- Object::Object(const Object& object)
- : m_object(object.m_object)
- { }
-
- // Is m_object unique?
- bool
- Object::unique() const
- {
- return m_object && m_object.unique();
- }
-
- // Set the wrapped dmnsn_object*
- void
- Object::dmnsn(dmnsn_object* object)
- {
- m_object.reset(new dmnsn_object*(object));
- }
-
- // Custom object callbacks
- namespace
- {
- dmnsn_intersection *
- intersection_fn(const dmnsn_object *object, dmnsn_line line)
- {
- Custom_Object* cobject = reinterpret_cast<Custom_Object*>(object->ptr);
- return cobject->intersection(Line(line)).release();
- }
-
- int
- inside_fn(const dmnsn_object *object, dmnsn_vector point)
- {
- Custom_Object* cobject = reinterpret_cast<Custom_Object*>(object->ptr);
- return cobject->inside(Vector(point));
- }
- }
-
- // Initialize a new object, using member functions as callbacks
- Custom_Object::Custom_Object()
- : Object(dmnsn_new_object())
- {
- dmnsn()->ptr = this;
- dmnsn()->intersection_fn = &intersection_fn;
- dmnsn()->inside_fn = &inside_fn;
- }
-
- // Delete the object
- Custom_Object::~Custom_Object()
- {
- if (unique()) {
- dmnsn_delete_object(dmnsn());
- }
- }
-}
diff --git a/libdimensionxx/objects.cpp b/libdimensionxx/objects.cpp
deleted file mode 100644
index fffa3c4..0000000
--- a/libdimensionxx/objects.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Create a sphere
- Sphere::Sphere()
- : Object(dmnsn_new_sphere())
- {
- if (!dmnsn()) {
- throw Dimension_Error("Failed to allocate sphere.");
- }
- }
-
- // Shallow copy a sphere
- Object*
- Sphere::copy() const
- {
- return new Sphere(*this);
- }
-
- // Protected copy constructor
- Sphere::Sphere(const Sphere& sphere)
- : Object(sphere)
- { }
-
- // Create a cube
- Cube::Cube()
- : Object(dmnsn_new_cube())
- {
- if (!dmnsn()) {
- throw Dimension_Error("Failed to allocate cube.");
- }
- }
-
- // Shallow copy a cube
- Object*
- Cube::copy() const
- {
- return new Cube(*this);
- }
-
- // Protected copy constructor
- Cube::Cube(const Cube& cube)
- : Object(cube)
- { }
-}
diff --git a/libdimensionxx/png.cpp b/libdimensionxx/png.cpp
deleted file mode 100644
index 92bfc15..0000000
--- a/libdimensionxx/png.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-#include <cstdio>
-
-namespace Dimension
-{
- PNG_Writer::PNG_Writer(Canvas& canvas, std::ostream& ostr)
- : m_canvas(&canvas), m_ostr(&ostr), m_written(false)
- {
- // Optimize the canvas for PNG export
- dmnsn_png_optimize_canvas(m_canvas->dmnsn());
- }
-
- // PNG_Writer destructor. Call write() to write the PNG file if not already
- // written, but catch any exceptions and instead report the error with
- // dmnsn_error() to avoid throwing from a destructor.
- PNG_Writer::~PNG_Writer()
- {
- if (!m_written) {
- try {
- write();
- } catch (...) {
- dmnsn_error(SEVERITY_MEDIUM,
- "Writing canvas to PNG failed in PNG_Writer destructor.");
- }
- }
- }
-
- // Write the PNG file. Uses the FILE_Cookie() interface to make a FILE*
- // corresponding to an std::ostream (including std::ostringstream, etc).
- void PNG_Writer::write()
- {
- if (m_written) {
- // Does writing a PNG file twice make sense?
- throw Dimension_Error("Attempt to write canvas to PNG twice.");
- }
-
- // Make the C++/C I/O interface
- oFILE_Cookie cookie(*m_ostr);
-
- // Write the PNG file
- if (dmnsn_png_write_canvas(m_canvas->dmnsn(), cookie.file()) != 0) {
- // The actual write operation failed, for some reason
- throw Dimension_Error("Writing canvas to PNG failed.");
- }
-
- m_written = true; // We've written the file now, don't do it again
- }
-
- // Write a PNG file in the background
- Progress
- PNG_Writer::write_async()
- {
- if (m_written) {
- // Does writing a PNG file twice make sense?
- throw Dimension_Error("Attempt to write canvas to PNG twice.");
- }
-
- m_written = true; // We've written the file now, don't do it again
-
- // Object to persist local variables past function return
- Persister persister;
-
- // Make the C++/C I/O interface
- FILE_Cookie* cookie = new oFILE_Cookie(*m_ostr);
- persister.persist(cookie);
-
- // Start the asynchronous task
- dmnsn_progress *progress
- = dmnsn_png_write_canvas_async(m_canvas->dmnsn(), cookie->file());
- if (!progress) {
- throw Dimension_Error("Starting background PNG write failed.");
- }
-
- // Return the Progress object
- return Progress(progress, persister);
- }
-
- // Construct a PNG reader
- PNG_Reader::PNG_Reader(std::istream& istr)
- : m_istr(&istr), m_read(false) { }
-
- // Read a canvas from a PNG file. Uses the FILE_Cookie() interface to make a
- // FILE* corresponding to an std::istream
- Canvas
- PNG_Reader::read()
- {
- if (m_read) {
- // Does reading a PNG file twice make sense?
- throw Dimension_Error("Attempt to read canvas from PNG twice.");
- }
-
- // Make the C++/C I/O interface
- iFILE_Cookie cookie(*m_istr);
-
- // Read the canvas from a PNG file
- dmnsn_canvas* canvas = dmnsn_png_read_canvas(cookie.file());
- if (!canvas) {
- // The read operation failed
- throw Dimension_Error("Reading canvas from PNG failed.");
- }
-
- // Only set m_read if nothing threw an exception
- Canvas ret(canvas);
- m_read = true;
- return ret;
- }
-
- // Read a PNG file in the background
- Progress
- PNG_Reader::read_async()
- {
- if (m_read) {
- // Does reading a PNG file twice make sense?
- throw Dimension_Error("Attempt to read canvas from PNG twice.");
- }
-
- // Don't read again
- m_read = true;
-
- // Object to persist local variables past function return
- Persister persister;
-
- // Store a pointer to a dmnsn_canvas* in the persister to later construct
- // the PNG_Writer
- dmnsn_canvas** canvas = new dmnsn_canvas*;
- persister.persist(canvas);
-
- // Make the C++/C I/O interface
- iFILE_Cookie* cookie = new iFILE_Cookie(*m_istr);
- persister.persist(cookie);
-
- // Start the asynchronous task
- dmnsn_progress *progress
- = dmnsn_png_read_canvas_async(canvas, cookie->file());
- if (!progress) {
- throw Dimension_Error("Starting background PNG read failed.");
- }
-
- // Return the Progress object
- return Progress(progress, persister);
- }
-
- // Construct an input PNG_Writer from a background task
- Canvas
- PNG_Reader::finish(Progress& progress)
- {
- // Will throw if progress is not from a PNG_Writer::read_async call
- dmnsn_canvas** canvas
- = progress.persister().first<dmnsn_canvas*>().persisted();
-
- try {
- progress.finish();
- } catch (...) {
- dmnsn_delete_canvas(*canvas);
- throw;
- }
-
- return Canvas(*canvas);
- }
-}
diff --git a/libdimensionxx/progress.cpp b/libdimensionxx/progress.cpp
deleted file mode 100644
index 8132d8a..0000000
--- a/libdimensionxx/progress.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // No-op virtual destructor
- Persist_Base::~Persist_Base()
- { }
-
- // Construct a dmnsn_progress* wrapper
- Progress::Progress(dmnsn_progress* progress)
- : m_progress(new dmnsn_progress*(progress))
- { }
-
- // Construct a dmnsn_progress* wrapper, with a known persister
- Progress::Progress(dmnsn_progress* progress, const Persister& persister)
- : m_progress(new dmnsn_progress*(progress)), m_persister(persister)
- { }
-
- // Finish the progress if not yet finished and we are unique
- Progress::~Progress()
- {
- if (m_progress && m_progress.unique()) {
- try {
- finish();
- } catch (...) {
- dmnsn_error(SEVERITY_MEDIUM, "Finishing worker thread failed.");
- }
- }
- }
-
- // Get the current progress
- double
- Progress::progress() const
- {
- return dmnsn_get_progress(dmnsn());
- }
-
- // Wait until progress() >= progress
- void
- Progress::wait(double progress) const
- {
- dmnsn_wait_progress(dmnsn(), progress);
- }
-
- // Start a new level of loop nesting
- void
- Progress::new_element(unsigned int total)
- {
- dmnsn_new_progress_element(dmnsn(), total);
- }
-
- // Increment the progress
- void
- Progress::increment()
- {
- dmnsn_increment_progress(dmnsn());
- }
-
- // Immediately finish the progress
- void
- Progress::done()
- {
- dmnsn_done_progress(dmnsn());
- }
-
- // Wait for progress completion
- void
- Progress::finish()
- {
- if (!m_progress) {
- throw Dimension_Error("Attempt to finish Progress twice.");
- }
-
- if (!m_progress.unique()) {
- throw Dimension_Error("Attempt to finish non-unique Progress.");
- }
-
- if (dmnsn_finish_progress(dmnsn()) != 0) {
- throw Dimension_Error("Worker thread failed.");
- }
-
- m_progress.reset(); // Don't try again
- }
-
- // Access the set of persisted objects
- Persister&
- Progress::persister()
- {
- return m_persister;
- }
-
- // Access the underlying dmnsn_progress*
-
- dmnsn_progress*
- Progress::dmnsn()
- {
- if (!m_progress) {
- throw Dimension_Error("Attempting to access finished array.");
- }
-
- return *m_progress;
- }
-
- const dmnsn_progress*
- Progress::dmnsn() const
- {
- if (!m_progress) {
- throw Dimension_Error("Attempting to access finished array.");
- }
-
- return *m_progress;
- }
-}
diff --git a/libdimensionxx/raytrace.cpp b/libdimensionxx/raytrace.cpp
deleted file mode 100644
index 6a5463a..0000000
--- a/libdimensionxx/raytrace.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Construct a raytracer
- Raytracer::Raytracer(Scene& scene)
- : m_scene(&scene), m_rendered(false) { }
-
- // Call render() if we've never rendered the scene
- Raytracer::~Raytracer()
- {
- if (!m_rendered) {
- try {
- render();
- } catch (...) {
- dmnsn_error(SEVERITY_MEDIUM,
- "Rendering scene failed in Raytracer destructor.");
- }
- }
- }
-
- // Render the scene
- void Raytracer::render()
- {
- // Raytrace the scene
- if (dmnsn_raytrace_scene(m_scene->dmnsn()) != 0) {
- // The rendering operation failed
- throw Dimension_Error("Raytracing scene failed.");
- }
-
- m_rendered = true; // Don't render the scene again in the destructor
- }
-
- // Render a scene in the background
- Progress
- Raytracer::render_async()
- {
- m_rendered = true; // Don't render the scene again in the destructor
-
- // Start the asynchronous task
- dmnsn_progress *progress = dmnsn_raytrace_scene_async(m_scene->dmnsn());
- if (!progress) {
- throw Dimension_Error("Starting background raytrace failed.");
- }
-
- // Return the Progress object
- return Progress(progress);
- }
-}
diff --git a/libdimensionxx/scene.cpp b/libdimensionxx/scene.cpp
deleted file mode 100644
index 5695c1b..0000000
--- a/libdimensionxx/scene.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // Allocate a dmnsn_scene
- Scene::Scene(Camera& camera, Canvas& canvas)
- : m_scene(new dmnsn_scene*(dmnsn_new_scene())), m_camera(camera.copy()),
- m_canvas(new Canvas(canvas)), m_objects(dmnsn()->objects)
- {
- if (!dmnsn()) {
- throw Dimension_Error("Couldn't allocate scene.");
- }
-
- dmnsn()->background = Color(sRGB(0.0, 0.0, 0.0)).dmnsn();
- dmnsn()->camera = this->camera().dmnsn();
- dmnsn()->canvas = this->canvas().dmnsn();
- dmnsn()->quality = static_cast<dmnsn_quality>(RENDER_FULL);
- }
-
- // Delete the scene
- Scene::~Scene()
- {
- if (m_scene.unique()) {
- m_objects.release();
- dmnsn_delete_scene(dmnsn());
- }
- }
-
- // Element access
-
- Color
- Scene::background() const
- {
- return Color(dmnsn()->background);
- }
-
- void
- Scene::background(const Color& color)
- {
- dmnsn()->background = color.dmnsn();
- }
-
- Camera&
- Scene::camera()
- {
- return *m_camera;
- }
-
- const Camera&
- Scene::camera() const
- {
- return *m_camera;
- }
-
- Canvas&
- Scene::canvas()
- {
- return *m_canvas;
- }
-
- const Canvas&
- Scene::canvas() const
- {
- return *m_canvas;
- }
-
- Array<Object>&
- Scene::objects()
- {
- return m_objects;
- }
-
- const Array<Object>&
- Scene::objects() const
- {
- return m_objects;
- }
-
- Quality
- Scene::quality() const
- {
- return static_cast<Quality>(dmnsn()->quality);
- }
-
- void
- Scene::quality(Quality quality)
- {
- dmnsn()->quality = static_cast<dmnsn_quality>(quality);
- }
-
- // Access the wrapped C object.
-
- dmnsn_scene*
- Scene::dmnsn()
- {
- return *m_scene;
- }
-
- const dmnsn_scene*
- Scene::dmnsn() const
- {
- return *m_scene;
- }
-}
diff --git a/libdimensionxx/texture.cpp b/libdimensionxx/texture.cpp
deleted file mode 100644
index cd9c2a8..0000000
--- a/libdimensionxx/texture.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Library. *
- * *
- * The Dimension Library is free software; you can redistribute it and/ *
- * or modify it under the terms of the GNU Lesser General Public License *
- * as published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- Pigment::Pigment(dmnsn_pigment* pigment)
- : m_pigment(new dmnsn_pigment*(pigment))
- { }
-
- Pigment::~Pigment()
- {
- if (unique()) {
- dmnsn_delete_pigment(dmnsn());
- }
- }
-
- Pigment*
- Pigment::copy() const
- {
- return new Pigment(*this);
- }
-
- dmnsn_pigment*
- Pigment::dmnsn()
- {
- if (!m_pigment) {
- throw Dimension_Error("Attempt to access NULL pigment.");
- }
- return *m_pigment;
- }
-
- const dmnsn_pigment*
- Pigment::dmnsn() const
- {
- if (!m_pigment) {
- throw Dimension_Error("Attempt to access NULL pigment.");
- }
- return *m_pigment;
- }
-
- // Protected no-op constructor
- Pigment::Pigment() { }
-
- // Shallow copy
- Pigment::Pigment(const Pigment& pigment)
- : m_pigment(pigment.m_pigment)
- {
- }
-
- bool
- Pigment::unique() const
- {
- return m_pigment && m_pigment.unique();
- }
-
- Texture::Texture(const Pigment& pigment)
- : m_texture(new dmnsn_texture*(dmnsn_new_texture())),
- m_pigment(pigment.copy())
- {
- dmnsn()->pigment = m_pigment->dmnsn();
- }
-
- Texture::Texture(dmnsn_texture* texture)
- : m_texture(new dmnsn_texture*(texture)),
- m_pigment(new Pigment(texture->pigment))
- {
- }
-
- Texture::~Texture()
- {
- if (m_texture.unique()) {
- dmnsn_delete_texture(dmnsn());
- }
- }
-
- dmnsn_texture*
- Texture::dmnsn()
- {
- return *m_texture;
- }
-
- const dmnsn_texture*
- Texture::dmnsn() const
- {
- return *m_texture;
- }
-}
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index e26b181..0000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-###########################################################################
-## Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> ##
-## ##
-## This file is part of The Dimension Build Suite. ##
-## ##
-## The Dimension Build Suite is free software; you can redistribute it ##
-## and/or modify it under the terms of the GNU General Public License as ##
-## published by the Free Software Foundation; either version 3 of the ##
-## License, or (at your option) any later version. ##
-## ##
-## The Dimension Build Suite is distributed in the hope that it will be ##
-## useful, but WITHOUT ANY WARRANTY; without even the implied warranty ##
-## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
-## General Public License for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
-###########################################################################
-
-check_LTLIBRARIES = libdimension-tests.la
-check_PROGRAMS = warning-test \
- error-test \
- png-test \
- gl-test
-TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = error-test
-
-INCLUDES = -I../libdimension -I../libdimensionxx
-
-libdimension_tests_la_SOURCES = tests.hpp \
- tests.cpp
-libdimension_tests_la_LIBADD = ../libdimensionxx/libdimensionxx.la
-
-warning_test_SOURCES = warning.cpp
-warning_test_LDADD = ./libdimension-tests.la
-
-error_test_SOURCES = error.cpp
-error_test_LDADD = ./libdimension-tests.la
-
-png_test_SOURCES = png.cpp
-png_test_LDADD = ./libdimension-tests.la
-
-gl_test_SOURCES = gl.cpp
-gl_test_LDADD = ./libdimension-tests.la
diff --git a/tests/error.cpp b/tests/error.cpp
deleted file mode 100644
index 705e013..0000000
--- a/tests/error.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-/* Make sure that errors terminate us - this test should fail */
-
-#include "tests.hpp"
-
-int
-main()
-{
- using namespace Dimension;
-
- resilience(SEVERITY_LOW);
- dmnsn_error(SEVERITY_LOW, "This error is expected.");
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/gl.cpp b/tests/gl.cpp
deleted file mode 100644
index c01859b..0000000
--- a/tests/gl.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "tests.hpp"
-#include <fstream>
-#include <iostream>
-
-int
-main() {
- using namespace Dimension;
-
- // Set the resilience low for tests
- resilience(SEVERITY_LOW);
-
- // Create the default test scene
- Scene scene = Tests::default_scene();
-
- // Create a glX window
- Tests::Display display(scene.canvas());
-
- {
- Raytracer raytracer(scene);
- GL_Writer writer(scene.canvas());
-
- // Render the scene
- Progress progress = raytracer.render_async();
-
- std::cout << "Raytracing scene: ";
- Progress barprogress = Tests::progressbar_async(std::cout, progress);
-
- // Display the scene as it's rendered
- while (progress.progress() < 1.0) {
- writer.write();
- display.flush();
- }
-
- barprogress.finish();
- std::cout << std::endl;
-
- // Make sure we show the completed rendering
- progress.finish();
- writer.write();
- display.flush();
- }
-
- // Pause for a second
- sleep(1);
-
- // Read the canvas back from the GL buffer
- GL_Reader reader;
- Canvas canvas
- = reader.read(0, 0, scene.canvas().width(), scene.canvas().height());
-
- // And write it again
- GL_Writer writer(canvas);
- writer.write();
- display.flush();
-
- // Pause for a second
- sleep(1);
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/png.cpp b/tests/png.cpp
deleted file mode 100644
index 92a48d1..0000000
--- a/tests/png.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "tests.hpp"
-#include <fstream>
-#include <iostream>
-
-int
-main() {
- using namespace Dimension;
-
- // Set the resilience low for tests
- resilience(SEVERITY_LOW);
-
- // Perform the rendering
- {
- // Get the default test scene
- Scene scene = Tests::default_scene();
-
- std::ofstream ofile("pngxx1.png");
- PNG_Writer writer(scene.canvas(), ofile);
-
- // Render the scene
- Raytracer raytracer(scene);
- Progress rprogress = raytracer.render_async();
- std::cout << "Raytracing scene: " << rprogress << std::endl;
- rprogress.finish();
-
- // Write the canvas
- Progress oprogress = writer.write_async();
- std::cout << "Writing PNG file: " << oprogress << std::endl;
- }
-
- // Now test PNG import/export
- {
- std::ifstream ifile("pngxx1.png");
- PNG_Reader reader(ifile);
- Progress iprogress = reader.read_async();
- std::cout << "Reading PNG file: " << iprogress << std::endl;
-
- Canvas canvas = PNG_Reader::finish(iprogress);
- std::ofstream ofile("pngxx2.png");
- PNG_Writer writer(canvas, ofile);
- Progress oprogress = writer.write_async();
- std::cout << "Writing PNG file: " << oprogress << std::endl;
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/tests.cpp b/tests/tests.cpp
deleted file mode 100644
index 002adbb..0000000
--- a/tests/tests.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "tests.hpp"
-
-namespace Dimension
-{
- namespace Tests
- {
- Scene
- default_scene()
- {
- // Canvas
- Canvas canvas(768, 480);
-
- // Camera
- Perspective_Camera camera;
- camera.trans(
- Matrix::rotation(Vector(0.0, 1.0, 0.0))
- * Matrix::translation(Vector(0.0, 0.0, -4.0))
- * Matrix::scale(
- Vector(static_cast<double>(canvas.width())/canvas.height(),
- 1.0,
- 1.0)
- )
- );
-
- // Scene
- Scene scene(camera, canvas);
-
- // Objects in scene
-
- Sphere sphere;
- sphere.trans(inverse(Matrix::scale(Vector(1.25, 1.25, 1.25))));
- scene.objects().push(sphere);
-
- Cube cube;
- cube.trans(inverse(Matrix::rotation(Vector(0.75, 0.0, 0.0))));
- scene.objects().push(cube);
-
- // Background color
- Color background = sRGB(0.0, 0.1, 0.25);
- background.filter(0.1);
- scene.background(background);
-
- return scene;
- }
-
- namespace
- {
- /* XIfEvent callback */
- Bool
- WaitForNotify(::Display *d, XEvent *e, char *arg)
- {
- return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
- }
- }
-
- Display::Display(const Canvas& canvas)
- {
- int attributeList[] = {
- GLX_RGBA,
- GLX_DOUBLEBUFFER,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- None
- };
- XVisualInfo *vi;
- XSetWindowAttributes swa;
-
- /* Get an X connection */
- m_dpy = XOpenDisplay(0);
- if (!m_dpy) {
- throw Dimension_Error("Couldn't create display.");
- }
-
- /* Get an appropriate visual */
- vi = glXChooseVisual(m_dpy, DefaultScreen(m_dpy),
- attributeList);
- if (!vi) {
- XCloseDisplay(m_dpy);
- throw Dimension_Error("Couldn't create display.");
- }
-
- /* Create a GLX context */
- m_cx = glXCreateContext(m_dpy, vi, 0, GL_TRUE);
- if (!m_cx) {
- XCloseDisplay(m_dpy);
- throw Dimension_Error("Couldn't create display.");
- }
-
- /* Create a color map */
- m_cmap = XCreateColormap(m_dpy,
- RootWindow(m_dpy, vi->screen),
- vi->visual, AllocNone);
- if (!m_cmap) {
- glXDestroyContext(m_dpy, m_cx);
- XCloseDisplay(m_dpy);
- throw Dimension_Error("Couldn't create display.");
- }
-
- /* Create a window */
- swa.colormap = m_cmap;
- swa.border_pixel = 0;
- swa.event_mask = StructureNotifyMask;
- m_win = XCreateWindow(m_dpy,
- RootWindow(m_dpy, vi->screen),
- 0, 0, canvas.width(), canvas.height(),
- 0, vi->depth, InputOutput, vi->visual,
- CWBorderPixel|CWColormap|CWEventMask, &swa);
- if (!m_win) {
- XFreeColormap(m_dpy, m_cmap);
- glXDestroyContext(m_dpy, m_cx);
- XCloseDisplay(m_dpy);
- throw Dimension_Error("Couldn't create display.");
- }
-
- XStoreName(m_dpy, m_win, "glX");
-
- XMapWindow(m_dpy, m_win);
- XIfEvent(m_dpy, &m_event, &WaitForNotify, (char*)m_win);
-
- /* Connect the context to the window */
- glXMakeCurrent(m_dpy, m_win, m_cx);
- }
-
- Display::~Display()
- {
- XDestroyWindow(m_dpy, m_win);
- XFreeColormap(m_dpy, m_cmap);
- glXDestroyContext(m_dpy, m_cx);
- XCloseDisplay(m_dpy);
- }
-
- void
- Display::flush()
- {
- glFlush();
- glXSwapBuffers(m_dpy, m_win);
- }
-
- namespace
- {
- struct Progressbar_Payload
- {
- public:
- std::ostream* ostr;
- const Progress* progress;
- };
-
- void *
- progressbar_thread(void *ptr)
- {
- Progressbar_Payload* payload
- = reinterpret_cast<Progressbar_Payload*>(ptr);
-
- *payload->ostr << *payload->progress;
-
- int* ret = static_cast<int*>(std::malloc(sizeof(int)));
- if (ret) {
- *ret = 0;
- }
- return ret;
- }
- }
-
- Progress progressbar_async(std::ostream& ostr,
- const Dimension::Progress& progress)
- {
- dmnsn_progress* barprogress = dmnsn_new_progress();
- if (!barprogress) {
- throw Dimension_Error("Couldn't allocate progress object.");
- }
-
- Progressbar_Payload* payload = new Progressbar_Payload;
- payload->ostr = &ostr;
- payload->progress = &progress;
-
- /* Create the worker thread */
- if (pthread_create(&barprogress->thread, NULL, &progressbar_thread,
- reinterpret_cast<void*>(payload)) != 0)
- {
- throw Dimension_Error("Couldn't create background thread.");
- }
-
- return Progress(barprogress);
- }
- }
-
- // Print a progress bar of the progress of `progress'
- std::ostream&
- operator<<(std::ostream& ostr, const Dimension::Progress& progress)
- {
- const unsigned int increments = 32;
-
- ostr << "|" << std::flush;
- for (unsigned int i = 0; i < increments; ++i) {
- progress.wait(static_cast<double>(i + 1)/increments);
- ostr << "=" << std::flush;
- }
- return ostr << "|" << std::flush;
- }
-}
diff --git a/tests/tests.hpp b/tests/tests.hpp
deleted file mode 100644
index 437bd36..0000000
--- a/tests/tests.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#ifndef TESTSXX_HPP
-#define TESTSXX_HPP
-
-#include "../libdimensionxx/dimensionxx.hpp"
-#include <iostream>
-#include <GL/glx.h>
-#include <GL/gl.h>
-
-namespace Dimension
-{
- namespace Tests
- {
- // Helper to return a basic scene
- Scene default_scene();
-
- // Display abstraction
- class Display
- {
- public:
- Display(const Canvas& canvas);
- ~Display();
-
- void flush();
-
- private:
- ::Display *m_dpy;
- Window m_win;
- Colormap m_cmap;
- GLXContext m_cx;
- XEvent m_event;
- };
-
- Progress progressbar_async(std::ostream& ostr,
- const Dimension::Progress& progress);
- }
-
- // Print a progress bar of the progress of `progress'
- std::ostream& operator<<(std::ostream& ostr,
- const Dimension::Progress& progress);
-}
-
-#endif // TESTSXX_HPP
diff --git a/tests/warning.cpp b/tests/warning.cpp
deleted file mode 100644
index 9d74e9d..0000000
--- a/tests/warning.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Dimension Test Suite. *
- * *
- * The Dimension Test Suite is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * The Dimension Test Suite is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-/* Make sure warnings don't kill us - this test should pass */
-
-#include "tests.hpp"
-
-int
-main()
-{
- using namespace Dimension;
-
- if (resilience() != SEVERITY_MEDIUM) {
- return EXIT_FAILURE;
- }
-
- resilience(SEVERITY_LOW);
- if (resilience() != SEVERITY_LOW) {
- return EXIT_FAILURE;
- }
-
- resilience(SEVERITY_MEDIUM);
- if (resilience() != SEVERITY_MEDIUM) {
- return EXIT_FAILURE;
- }
-
- dmnsn_error(SEVERITY_LOW, "This warning is expected.");
-
- resilience(SEVERITY_HIGH);
- if (resilience() != SEVERITY_HIGH) {
- return EXIT_FAILURE;
- }
-
- dmnsn_error(SEVERITY_LOW, "This warning is expected.");
- dmnsn_error(SEVERITY_MEDIUM, "This warning is expected.");
-
- return EXIT_SUCCESS;
-}