[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog configure.ac libgeometry/Makefi...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog configure.ac libgeometry/Makefi... |
Date: |
Fri, 01 Dec 2006 15:38:19 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/12/01 15:38:19
Modified files:
. : ChangeLog configure.ac
libgeometry : Makefile.am
testsuite : Makefile.am
testsuite/server: Makefile.am
Added files:
libgeometry : Range2d.h
testsuite/libgeometry: Makefile.am Range2dTest.cpp
Log message:
* configure.ac, libgeometry/Makefile.am, libgeometry/Range2d.h,
testsuite/Makefile.am, testsuite/libgeometry/Makefile.am,
testsuite/libgeometry/Range2dTest.cpp,
testsuite/server/Makefile.am:
New Range2d template class and associated unit test.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1839&r2=1.1840
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.222&r2=1.223
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Makefile.am?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Range2d.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/Makefile.am?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libgeometry/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libgeometry/Range2dTest.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/Makefile.am?cvsroot=gnash&r1=1.15&r2=1.16
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1839
retrieving revision 1.1840
diff -u -b -r1.1839 -r1.1840
--- ChangeLog 1 Dec 2006 12:33:18 -0000 1.1839
+++ ChangeLog 1 Dec 2006 15:38:18 -0000 1.1840
@@ -1,5 +1,12 @@
2006-12-01 Sandro Santilli <address@hidden>
+ * configure.ac, libgeometry/Makefile.am, libgeometry/Range2d.h,
+ testsuite/Makefile.am, testsuite/libgeometry/Makefile.am,
+ testsuite/libgeometry/Range2dTest.cpp, testsuite/server/Makefile.am:
+ New Range2d template class and associated unit test.
+
+2006-12-01 Sandro Santilli <address@hidden>
+
* configure.ac: make missing BOOST_LIBS
a nogo (we need threads now).
Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -b -r1.222 -r1.223
--- configure.ac 1 Dec 2006 12:33:18 -0000 1.222
+++ configure.ac 1 Dec 2006 15:38:18 -0000 1.223
@@ -15,7 +15,7 @@
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
dnl
-dnl $Id: configure.ac,v 1.222 2006/12/01 12:33:18 strk Exp $
+dnl $Id: configure.ac,v 1.223 2006/12/01 15:38:18 strk Exp $
AC_PREREQ(2.50)
AC_INIT(gnash, cvs)
@@ -830,6 +830,7 @@
doc/Doxyfile
testsuite/Makefile
testsuite/libbase/Makefile
+testsuite/libgeometry/Makefile
testsuite/actionscript.all/Makefile
testsuite/samples/Makefile
testsuite/misc-ming.all/Makefile
Index: libgeometry/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- libgeometry/Makefile.am 28 Nov 2006 12:10:26 -0000 1.23
+++ libgeometry/Makefile.am 1 Dec 2006 15:38:18 -0000 1.24
@@ -18,7 +18,7 @@
#
#
-# $Id: Makefile.am,v 1.23 2006/11/28 12:10:26 strk Exp $
+# $Id: Makefile.am,v 1.24 2006/12/01 15:38:18 strk Exp $
AUTOMAKE_OPTIONS =
@@ -54,6 +54,7 @@
tqt.cpp
noinst_HEADERS = \
+ Range2d.h \
axial_box.h \
bsp.h \
collision.h \
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- testsuite/Makefile.am 29 Nov 2006 00:32:27 -0000 1.23
+++ testsuite/Makefile.am 1 Dec 2006 15:38:18 -0000 1.24
@@ -4,6 +4,7 @@
SUBDIRS = \
. \
libbase \
+ libgeometry \
server \
samples \
misc-ming.all \
Index: testsuite/server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- testsuite/server/Makefile.am 24 Nov 2006 22:33:01 -0000 1.15
+++ testsuite/server/Makefile.am 1 Dec 2006 15:38:19 -0000 1.16
@@ -63,6 +63,9 @@
$(NULL)
TEST_DRIVERS = server.exp
+TEST_CASES = \
+ $(check_PROGRAMS) \
+ $(NULL)
check-DEJAGNU: site-update $(check_PROGRAMS)
@runtest=$(RUNTEST); \
Index: libgeometry/Range2d.h
===================================================================
RCS file: libgeometry/Range2d.h
diff -N libgeometry/Range2d.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libgeometry/Range2d.h 1 Dec 2006 15:38:18 -0000 1.1
@@ -0,0 +1,551 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+// Original author: Sandro Santilli <address@hidden>
+//
+
+
+/* $Id: Range2d.h,v 1.1 2006/12/01 15:38:18 strk Exp $ */
+
+#ifndef GNASH_RANGE2D_H
+#define GNASH_RANGE2D_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ostream>
+#include <limits>
+#include <algorithm>
+#include <cassert> // for inlines
+
+namespace gnash {
+
+namespace geometry {
+
+/// Kinds of a range
+enum RangeKind {
+ /// Valid range, using finite values
+ finiteRange,
+
+ /// A NULL range is a range enclosing NO points.
+ nullRange,
+
+ /// \brief
+ /// A WORLD range2d is a range including
+ /// all points on the plane.
+ //
+ /// Note that scaling, shifting and unioning
+ /// will NOT change a WORLD range.
+ ///
+ worldRange
+};
+
+/// 2d Range template class
+//
+/// The class stores 4 values of the type specified
+/// as template argument, representing the set of points
+/// enclosed by the given min and max values for the 2 dimensions,
+/// and provides methods for manipulating them.
+/// The parameter type must be a numeric type.
+///
+/// The two dimensions are called X and Y.
+///
+/// Note that the range is "open", which means that the points
+/// on its boundary are considered internal to the range.
+///
+///
+template <typename T>
+class Range2d
+{
+private:
+
+ T _xmin, _xmax, _ymin, _ymax;
+
+public:
+
+ /// Ouput operator
+ template <typename U>
+ friend std::ostream& operator<< (std::ostream& os, const Range2d<U>&
rect);
+
+ /// Equality operator
+ //
+ /// This is needed to take NULL kind into account
+ /// since we don't explicitly set all members when constructing
+ /// NULL ranges
+ ///
+ template <typename U>
+ friend bool operator== (const Range2d<U>& r1, const Range2d<U>& r2);
+
+ /// Inequality operator
+ //
+ /// This is needed to take NULL kind into account
+ /// since we don't explicitly set all members when constructing
+ /// NULL ranges
+ ///
+ template <typename U>
+ friend bool operator!= (const Range2d<U>& r1, const Range2d<U>& r2);
+
+ /// Return a rectangle being the intersetion of the two rectangles
+ //
+ /// Any NULL operand will make the result also NULL.
+ ///
+ template <typename U> friend Range2d<U>
+ Intersection(const Range2d<U>& r1, const Range2d<U>& r2);
+
+ /// Return a rectangle being the union of the two rectangles
+ template <typename U> friend Range2d<U>
+ Union(const Range2d<U>& r1, const Range2d<U>& r2);
+
+ /// Construct a Range2d of the given kind.
+ //
+ /// The default is building a nullRange.
+ /// If finiteRange is given the range will be set to
+ /// enclose the origin.
+ ///
+ /// See RangeKind
+ ///
+ Range2d(RangeKind kind=nullRange)
+ :
+ _xmin(T()),
+ _xmax(T()),
+ _ymin(T()),
+ _ymax(T())
+ {
+ switch ( kind )
+ {
+ case worldRange:
+ setWorld();
+ break;
+ case nullRange:
+ setNull();
+ break;
+ default:
+ case finiteRange:
+ break;
+ }
+ }
+
+ /// Construct a finite Range2d with the given values
+ //
+ /// Make sure that the min <= max, or an assertion
+ /// would fail. We could as well swap the values
+ /// in this case, but it is probably better to
+ /// force caller to deal with this, as a similar
+ /// case might as well expose a bug in the code.
+ ///
+ Range2d(T xmin, T ymin, T xmax, T ymax)
+ :
+ _xmin(xmin),
+ _xmax(xmax),
+ _ymin(ymin),
+ _ymax(ymax)
+ {
+ // use the default ctor to make a NULL Range2d
+ assert(_xmin <= _xmax);
+ assert(_ymin <= _ymax);
+ // .. or should we raise an exception .. ?
+ }
+
+ /// Returns true if this is the NULL Range2d
+ bool isNull() const
+ {
+ return _xmax < _xmin;
+ }
+
+ /// Set the Range2d to the NULL value
+ void setNull()
+ {
+ _xmin = std::numeric_limits<T>::max();
+ _xmax = std::numeric_limits<T>::min();
+ }
+
+ /// Returns true if this is the WORLD Range2d
+ bool isWorld() const
+ {
+ return _xmax == std::numeric_limits<T>::max()
+ && _xmin == std::numeric_limits<T>::min();
+ }
+
+ /// Returns true if this is a finite Range2d
+ //
+ /// See RangeKind::finiteRange
+ ///
+ bool isFinite() const
+ {
+ return ( ! isNull() && ! isWorld() );
+ }
+
+ /// Set the Range2d to the WORLD value
+ //
+ /// This is implemented using the minimun and maximun
+ /// values of the parameter type.
+ ///
+ /// See RangeType::worldRange
+ ///
+ void setWorld()
+ {
+ _xmin = std::numeric_limits<T>::min();
+ _xmax = std::numeric_limits<T>::max();
+ }
+
+ /// \brief
+ /// Return true if this rectangle contains the point with
+ /// given coordinates (boundaries are inclusive).
+ //
+ /// Note that WORLD rectangles contain every point
+ /// and NULL rectangles contain no point.
+ ///
+ bool contains(T x, T y) const
+ {
+ if ( isNull() ) return false;
+ if ( isWorld() ) return true;
+ if (x < _xmin || x > _xmax || y < _ymin || y > _ymax)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /// \brief
+ /// Return true if this rectangle intersects the point with
+ /// given coordinates (boundaries are inclusive).
+ //
+ /// Note that NULL rectangles don't intersect anything
+ /// and WORLD rectangles intersects everything except a NULL rectangle.
+ ///
+ bool intersects(const Range2d<T>& other) const
+ {
+ if ( isNull() || other.isNull() ) return false;
+ if ( isWorld() || other.isWorld() ) return true;
+
+ if ( _xmin > other._xmax ) return false;
+ if ( _xmax < other._xmin ) return false;
+ if ( _ymin > other._ymax ) return false;
+ if ( _ymax < other._ymin ) return false;
+ return true;
+ }
+
+ /// Expand this Range2d to enclose the given point.
+ void expandTo(T x, T y)
+ {
+ // A WORLD range already enclose every point
+ if ( isWorld() ) return;
+
+ if ( isNull() )
+ {
+ setTo(x,y);
+ }
+ else
+ {
+ _xmin = std::min(_xmin, x);
+ _ymin = std::min(_ymin, y);
+ _xmax = std::max(_xmax, x);
+ _ymax = std::max(_ymax, y);
+ }
+ }
+
+ /// Set ourself to bound the given point
+ void setTo(T x, T y)
+ {
+ _xmin = _xmax = x;
+ _ymin = _ymax = y;
+ }
+
+ /// Set coordinates to given values
+ //
+ /// Make sure that the min <= max, or an assertion
+ /// would fail. We could as well swap the values
+ /// in this case, but it is probably better to
+ /// force caller to deal with this, as a similar
+ /// case might as well expose a bug in the code.
+ //
+ void setTo(T xmin, T ymin, T xmax, T ymax)
+ {
+ _xmin = xmin;
+ _xmax = xmax;
+ _ymin = ymin;
+ _ymax = ymax;
+
+ // use the default ctor to make a NULL Range2d
+ assert(_xmin <= _xmax);
+ assert(_ymin <= _ymax);
+ }
+
+ /// Return width this Range2d
+ //
+ /// Don't call this function on a WORLD rectangle!
+ ///
+ T width() const
+ {
+ assert ( ! isWorld() );
+ if ( isNull() ) return 0;
+ return _xmax-_xmin;
+ }
+
+ /// Return height this Range2dangle
+ //
+ /// Don't call this function on a WORLD rectangle!
+ ///
+ T height() const
+ {
+ assert ( ! isWorld() );
+ if ( isNull() ) return 0;
+ return _ymax-_ymin;
+ }
+
+ /// Shift this Range2dangle horizontally
+ //
+ /// A positive offset will shift to the right,
+ /// A negative offset will shift to the left.
+ ///
+ /// WORLD or NULL ranges will be unchanged
+ ///
+ void shiftX(T offset)
+ {
+ if ( isNull() || isWorld() ) return;
+ _xmin += offset;
+ _xmax += offset;
+ }
+
+ /// Shift this Range2dangle vertically
+ //
+ /// A positive offset will increment y values.
+ /// A negative offset will decrement y values.
+ ///
+ /// WORLD or NULL ranges will be unchanged
+ ///
+ void shiftY(T offset)
+ {
+ if ( isNull() || isWorld() ) return;
+ _ymin += offset;
+ _ymax += offset;
+ }
+
+ /// Scale this Range2d horizontally
+ //
+ /// A positive factor will make the Range2dangle wider.
+ /// A negative factor will make the Range2dangle narrower.
+ /// A factor of 1 will leave it unchanged.
+ /// Control point is the origin (0,0).
+ ///
+ /// WORLD or NULL ranges will be unchanged
+ ///
+ /// If the range so scaled will hit the numerical limit
+ /// of the range an assertion will fail
+ /// (TODO: throw an exception instead!).
+ ///
+ void scaleX(T factor)
+ {
+ if ( isNull() || isWorld() ) return;
+ _xmin *= factor;
+ _xmax *= factor;
+ assert(_xmin < _xmax); // in case of overflow...
+ }
+
+ /// Scale this Range2dangle vertically
+ //
+ /// A positive factor will make the Range2dangle taller.
+ /// A negative factor will make the Range2dangle shorter.
+ /// A factor of 1 will leave it unchanged.
+ /// Control point is the origin (0,0).
+ ///
+ /// If the range so scaled will hit the numerical limit
+ /// of the range an assertion will fail
+ /// (TODO: throw an exception instead!).
+ ///
+ void scaleY(T factor)
+ {
+ if ( isNull() ) return;
+ _ymin *= factor;
+ _ymax *= factor;
+ assert(_ymin < _ymax); // in case of overflow...
+ }
+
+ /// Get min X ordinate.
+ //
+ /// Don't call this against a NULL or WORLD Range2
+ ///
+ T getMinX() const
+ {
+ assert ( isFinite() );
+ return _xmin;
+ }
+
+ /// Get max X ordinate.
+ //
+ /// Don't call this against a NULL or WORLD Range2d
+ ///
+ T getMaxX() const
+ {
+ assert ( isFinite() );
+ return _xmax;
+ }
+
+ /// Get min Y ordinate.
+ //
+ /// Don't call this against a NULL or WORLD Range2d
+ ///
+ T getMinY() const
+ {
+ assert ( isFinite() );
+ return _ymin;
+ }
+
+ /// Get max Y ordinate.
+ //
+ /// Don't call this against a NULL or WORLD Range2d
+ ///
+ T getMaxY() const
+ {
+ assert ( isFinite() );
+ return _ymax;
+ }
+
+ /// Expand this range to include the given Range2d
+ //
+ /// WORLD ranges force result to be the WORLD range.
+ /// A NULL range will have no effect on the result.
+ ///
+ void expandTo(const Range2d<T>& r)
+ {
+ if ( r.isNull() )
+ {
+ // the given range will add nothing
+ return;
+ }
+
+ if ( isNull() )
+ {
+ // being null ourself, we'll equal the given range
+ *this = r;
+ return;
+ }
+
+ if ( isWorld() || r.isWorld() )
+ {
+ // union with world is always world...
+ setWorld();
+ return;
+ }
+
+ _xmin = std::min(_xmin, r._xmin);
+ _xmax = std::max(_xmax, r._xmax);
+ _ymin = std::min(_ymin, r._ymin);
+ _ymax = std::max(_ymax, r._ymax);
+
+ }
+
+
+};
+
+template <typename T> inline std::ostream&
+operator<< (std::ostream& os, const Range2d<T>& rect)
+{
+ if ( rect.isNull() ) return os << "Null range";
+ if ( rect.isWorld() ) return os << "World range";
+
+ return os << "Finite range (" << rect._xmin << "," << rect._ymin
+ << " " << rect._xmax << "," << rect._ymax << ")";
+}
+
+template <typename T> inline bool
+operator== (const Range2d<T>& r1, const Range2d<T>& r2)
+{
+ // These checks are needed becase
+ // we don't initialize *all* memebers
+ // when setting to Null or World
+
+ if ( r1.isNull() ) return r2.isNull();
+ if ( r2.isNull() ) return r1.isNull();
+ if ( r1.isWorld() ) return r2.isWorld();
+ if ( r2.isWorld() ) return r1.isWorld();
+
+ return r1._xmin == r2._xmin && r1._ymin == r2._ymin &&
+ r1._xmax == r2._xmax && r1._ymax == r2._ymax;
+}
+
+template <typename T> inline bool
+operator!= (const Range2d<T>& r1, const Range2d<T>& r2)
+{
+ return ! ( r1 == r2 );
+}
+
+/// Return true of the two ranges intersect (boundaries included)
+template <typename T> inline bool
+Intersect(const Range2d<T>& r1, const Range2d<T>& r2)
+{
+ return r1.intersects(r2);Range2d<T> ret = r1;
+}
+
+/// Return a rectangle being the union of the two rectangles
+template <typename T> inline Range2d<T>
+Union(const Range2d<T>& r1, const Range2d<T>& r2)
+{
+ Range2d<T> ret = r1;
+ ret.expandTo(r2);
+ return ret;
+}
+
+/// Return a rectangle being the intersetion of the two rectangles
+//
+/// Any NULL operand will make the result also NULL.
+///
+template <typename T> inline Range2d<T>
+Intersection(const Range2d<T>& r1, const Range2d<T>& r2)
+{
+ if ( r1.isNull() || r2.isNull() ) {
+ // NULL ranges intersect nothing
+ return Range2d<T>(nullRange);
+ }
+
+ if ( r1.isWorld() ) {
+ // WORLD range intersect everything
+ return r2;
+ }
+
+ if ( r2.isWorld() ) {
+ // WORLD range intersect everything
+ return r1;
+ }
+
+ if ( ! r1.intersects(r2) ) {
+ // No intersection results in a NULL range
+ return Range2d<T>(nullRange);
+ }
+
+ return Range2d<T> (
+ std::max(r1._xmin, r2._xmin), // xmin
+ std::max(r1._ymin, r2._ymin), // ymin
+ std::min(r1._xmax, r2._xmax), // xmax
+ std::min(r1._ymax, r2._ymax) // ymax
+ );
+
+}
+
+
+
+} // namespace gnash::geometry
+} // namespace gnash
+
+#endif // GNASH_RANGE2D_H
+
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: testsuite/libgeometry/Makefile.am
===================================================================
RCS file: testsuite/libgeometry/Makefile.am
diff -N testsuite/libgeometry/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libgeometry/Makefile.am 1 Dec 2006 15:38:18 -0000 1.1
@@ -0,0 +1,73 @@
+## Process this fill with automake to generate Makefile.in
+#
+# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+#
+
+AUTOMAKE_OPTIONS = dejagnu
+
+AM_LDFLAGS = \
+ $(top_builddir)/libgeometry/libgnashgeo.la \
+ $(NULL)
+
+# AM_CPPFLAGS isn't right here since per-program *_CPPFLAGS override global
+# AM_CPPFLAGS
+INCLUDES = -I.. \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libgeometry \
+ -I$(top_srcdir)/testsuite \
+ $(NULL)
+
+abs_builddir=`(cd $(top_builddir)/testsuite/libbase; pwd)`
+
+check_PROGRAMS = \
+ Range2dTest \
+ $(NULL)
+
+CLEANFILES = \
+ testrun.sum \
+ testrun.log \
+ gnash-dbg.log \
+ site.exp.bak \
+ Range2dTest \
+ $(NULL)
+
+Range2dTest_SOURCES = Range2dTest.cpp
+
+TEST_DRIVERS = ../simple.exp
+TEST_CASES = \
+ $(check_PROGRAMS) \
+ $(NULL)
+
+check-DEJAGNU: site-update $(TEST_CASES)
+ @runtest=$(RUNTEST); \
+ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ $$runtest $(RUNTESTFLAGS) $(TEST_DRIVERS); \
+ else \
+ echo "WARNING: could not find \`runtest'" 1>&2; \
+ for i in "$(TEST_CASES)"; do \
+ $(SHELL) $$i; \
+ done; \
+ fi
+
+site-update: site.exp
+ @rm -fr site.exp.bak
+ @cp site.exp site.exp.bak
+ @sed -e '/testcases/d' site.exp.bak > site.exp
+ @echo "# This is a list of the pre-compiled testcases" >> site.exp
+ @echo "set testcases \"$(TEST_CASES)\"" >> site.exp
Index: testsuite/libgeometry/Range2dTest.cpp
===================================================================
RCS file: testsuite/libgeometry/Range2dTest.cpp
diff -N testsuite/libgeometry/Range2dTest.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libgeometry/Range2dTest.cpp 1 Dec 2006 15:38:18 -0000
1.1
@@ -0,0 +1,193 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "check.h"
+#include "Range2d.h"
+#include <iostream>
+#include <sstream>
+#include <cassert>
+
+using namespace std;
+using namespace gnash;
+using namespace gnash::geometry;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+
+ //
+ // Test NULL range construction
+ //
+
+ Range2d<int> nullIntRange1;
+ check( nullIntRange1.isNull() );
+ check( ! nullIntRange1.isWorld() );
+ check( ! nullIntRange1.isFinite() );
+
+ Range2d<int> nullIntRange2(nullRange);
+ check_equals( nullIntRange1, nullIntRange2 );
+ check( nullIntRange1 == nullIntRange2 );
+
+ //
+ // Test WORLD range construction
+ //
+
+ Range2d<int> worldIntRange1(worldRange);
+ check( ! worldIntRange1.isNull() );
+ check( worldIntRange1.isWorld() );
+ check( ! worldIntRange1.isFinite() );
+ check( nullIntRange1 != worldIntRange1 );
+
+ //
+ // Test FINITE range construction
+ //
+
+ Range2d<int> fIntRange1(0, 0, 10, 10);
+
+ check( ! fIntRange1.isNull() );
+ check( ! fIntRange1.isWorld() );
+ check( fIntRange1.isFinite() );
+ check( fIntRange1 != worldIntRange1 );
+ check( fIntRange1 != nullIntRange1 );
+
+ //
+ // Test range Union
+ //
+
+ Range2d<int> uIntNW1 = Union(nullIntRange1, worldIntRange1);
+ Range2d<int> uIntNW2 = Union(worldIntRange1, nullIntRange1);
+
+ // union is transitive
+ check_equals( uIntNW1, uIntNW2 );
+
+ // union of anything with world is world
+ check_equals( uIntNW1, worldIntRange1 );
+
+ Range2d<int> uIntNF1 = Union(nullIntRange1, fIntRange1);
+ Range2d<int> uIntNF2 = Union(fIntRange1, nullIntRange1);
+
+ // union is transitive
+ check_equals( uIntNF1, uIntNF2 );
+
+ // union of anything with null is no-op
+ check_equals( uIntNF1, fIntRange1 );
+
+ Range2d<int> uIntWF1 = Union(worldIntRange1, fIntRange1);
+ Range2d<int> uIntWF2 = Union(fIntRange1, worldIntRange1);
+
+ // union is transitive
+ check_equals( uIntWF1, uIntWF2 );
+
+ // union of anything with world is world
+ check_equals( uIntWF1, worldIntRange1 );
+
+ check_equals(
+ Union( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, -5, -5)),
+ Range2d<int>(-10, -10, 10, 10)
+ );
+
+ // disjoint
+ check_equals(
+ Union( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, 5, 5)),
+ Range2d<int>(-10, -10, 10, 10)
+ );
+
+ // overlapping
+ check_equals(
+ Union( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, 5, 5)),
+ Range2d<int>(-10, -10, 10, 10)
+ );
+ check_equals(
+ Union( Range2d<float>(-0.2, -0.3, 0.7, 0.8),
+ Range2d<float>(-0.1, -0.1, 0.8, 0.9)),
+ Range2d<float>(-0.2, -0.3, 0.8, 0.9)
+ );
+
+ // inscribed
+ check_equals(
+ Union( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(2, 2, 5, 5)),
+ Range2d<int>(0, 0, 10, 10)
+ );
+ check_equals(
+ Union( Range2d<unsigned short>(2, 2, 8, 9),
+ Range2d<unsigned short>(0, 1, 9, 10)),
+ Range2d<unsigned short>(0, 1, 9, 10)
+ );
+
+ //
+ // Test Intersection / Intersects
+ //
+
+ Range2d<int> iIntNW1 = Intersection(nullIntRange1, worldIntRange1);
+ Range2d<int> iIntNW2 = Intersection(worldIntRange1, nullIntRange1);
+
+ // intersection is transitive
+ check_equals( iIntNW1, iIntNW2 );
+
+ // intersection of anything with null is null
+ check_equals( iIntNW1, nullIntRange1 );
+ check_equals( Intersect(nullIntRange1, worldIntRange1), false );
+
+ // disjoint ranges
+ check_equals(
+ Intersection( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, -2, -3)),
+ Range2d<int>() // NULL range !
+ );
+ check_equals(
+ Intersection( Range2d<double>(-100.4, 50.5, -60.4, 60),
+ Range2d<double>(-80, -10, -70, -9)),
+ Range2d<double>() // NULL range !
+ );
+ check_equals(
+ Intersect( Range2d<double>(-100.4, 50.5, -60.4, 60),
+ Range2d<double>(-80, -10, -70, -9)),
+ false
+ );
+
+ // overlapping ranges
+ check_equals(
+ Intersection( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, 5, 5) ),
+ Range2d<int>(0, 0, 5, 5)
+ );
+ check_equals(
+ Intersect( Range2d<int>(0, 0, 10, 10),
+ Range2d<int>(-10, -10, 5, 5)),
+ true
+ );
+
+ // incribed ranges
+ check_equals(
+ Intersection( Range2d<unsigned short>(0, 0, 10, 10),
+ Range2d<unsigned short>(2, 2, 5, 5)),
+ Range2d<unsigned short>(2, 2, 5, 5)
+ );
+ check_equals(
+ Intersect( Range2d<unsigned short>(0, 0, 10, 10),
+ Range2d<unsigned short>(2, 2, 5, 5)),
+ true
+ );
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog configure.ac libgeometry/Makefi...,
Sandro Santilli <=