|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51975 - in sandbox-branches/andreo/guigl: . boost/guigl libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-03-25 18:52:41
Author: andreo
Date: 2009-03-25 18:52:40 EDT (Wed, 25 Mar 2009)
New Revision: 51975
URL: http://svn.boost.org/trac/boost/changeset/51975
Log:
GGL
Text files modified:
sandbox-branches/andreo/guigl/Jamroot | 1
sandbox-branches/andreo/guigl/boost/guigl/color.hpp | 6
sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp | 650 ++++++++++++++++++++--------------------
sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp | 293 +++++++++++++----
4 files changed, 546 insertions(+), 404 deletions(-)
Modified: sandbox-branches/andreo/guigl/Jamroot
==============================================================================
--- sandbox-branches/andreo/guigl/Jamroot (original)
+++ sandbox-branches/andreo/guigl/Jamroot 2009-03-25 18:52:40 EDT (Wed, 25 Mar 2009)
@@ -33,6 +33,5 @@
: requirements
<include>.
<include>$(BOOST_ROOT)
- <include>$(GGL)
<include>$(GGL)/boost/ggl
;
\ No newline at end of file
Modified: sandbox-branches/andreo/guigl/boost/guigl/color.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/color.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/color.hpp 2009-03-25 18:52:40 EDT (Wed, 25 Mar 2009)
@@ -91,11 +91,7 @@
inline void color(color_type const& clr)
{
// TODO: use gil concepts to access channels
- color(
- static_cast<float>(clr[0]),
- static_cast<float>(clr[1]),
- static_cast<float>(clr[2]),
- static_cast<float>(clr[3]));
+ color<float>(clr[0], clr[1], clr[2], clr[3]);
}
}}}
Modified: sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/ggl.hpp 2009-03-25 18:52:40 EDT (Wed, 25 Mar 2009)
@@ -12,24 +12,24 @@
#include <boost/guigl/gl.hpp>
#include <boost/guigl/types.hpp>
-#include <boost/ggl/geometry/geometries/point.hpp>
-#include <boost/ggl/geometry/geometries/box.hpp>
-#include <boost/ggl/geometry/geometries/segment.hpp>
-#include <boost/ggl/geometry/geometries/linestring.hpp>
-#include <boost/ggl/geometry/geometries/linear_ring.hpp>
-#include <boost/ggl/geometry/geometries/polygon.hpp>
-#include <boost/ggl/geometry/geometries/nsphere.hpp>
-
-#include <boost/ggl/geometry/core/concepts/point_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/segment_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/box_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/linestring_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/ring_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/polygon_concept.hpp>
-#include <boost/ggl/geometry/core/concepts/nsphere_concept.hpp>
+#include <geometry/geometries/point.hpp>
+#include <geometry/geometries/box.hpp>
+#include <geometry/geometries/segment.hpp>
+#include <geometry/geometries/linestring.hpp>
+#include <geometry/geometries/linear_ring.hpp>
+#include <geometry/geometries/polygon.hpp>
+#include <geometry/geometries/nsphere.hpp>
+
+#include <geometry/core/concepts/point_concept.hpp>
+#include <geometry/core/concepts/segment_concept.hpp>
+#include <geometry/core/concepts/box_concept.hpp>
+#include <geometry/core/concepts/linestring_concept.hpp>
+#include <geometry/core/concepts/ring_concept.hpp>
+#include <geometry/core/concepts/polygon_concept.hpp>
+#include <geometry/core/concepts/nsphere_concept.hpp>
-#include <boost/ggl/geometry/core/cs.hpp>
-#include <boost/ggl/geometry/geometries/register/register_point.hpp>
+#include <geometry/core/cs.hpp>
+#include <geometry/geometries/register/register_point.hpp>
#include <boost/static_assert.hpp>
// GEOMETRY_REGISTER_POINT_2D needs type without '::'
@@ -39,350 +39,350 @@
// GGL doesn't have a GEOMETRY_REGISTER_SEGMENT_2D macro
namespace geometry { namespace traits {
- // tag trait
- template<>
- struct tag<boost::guigl::segment_type>
+ // tag trait
+ template<>
+ struct tag<boost::guigl::segment_type>
{
- typedef
- geometry::segment_tag
- type;
+ typedef
+ geometry::segment_tag
+ type;
};
- // point_type trait
- template<>
- struct point_type<boost::guigl::segment_type>
+ // point_type trait
+ template<>
+ struct point_type<boost::guigl::segment_type>
{
- typedef
- boost::guigl::segment_type::first_type
- type;
+ typedef
+ boost::guigl::segment_type::first_type
+ type;
};
- // indexed_access trait
- template<int I, int D>
- struct indexed_access<boost::guigl::segment_type,I,D>
+ // indexed_access trait
+ template<int I, int D>
+ struct indexed_access<boost::guigl::segment_type,I,D>
{
- BOOST_STATIC_ASSERT( (0 == I) || (1 == I) );
+ BOOST_STATIC_ASSERT( (0 == I) || (1 == I) );
- typedef
- geometry::traits::point_type<boost::guigl::segment_type>::type
- point_type;
-
- typedef
- geometry::traits::coordinate_type<point_type>::type
- coordinate_type;
-
- static inline coordinate_type get(boost::guigl::segment_type const& segment)
- {
- return (I == 0)
- ? geometry::get<D>(segment.first)
- : geometry::get<D>(segment.second);
- }
-
- static inline void set(boost::guigl::segment_type const& segment, coordinate_type const& x)
- {
- return (I == 0)
- ? geometry::set<D>(segment.first, x)
- : geometry::set<D>(segment.second, x);
- }
+ typedef
+ geometry::traits::point_type<boost::guigl::segment_type>::type
+ point_type;
+
+ typedef
+ geometry::traits::coordinate_type<point_type>::type
+ coordinate_type;
+
+ static inline coordinate_type get(boost::guigl::segment_type const& segment)
+ {
+ return (I == 0)
+ ? geometry::get<D>(segment.first)
+ : geometry::get<D>(segment.second);
+ }
+
+ static inline void set(boost::guigl::segment_type const& segment, coordinate_type const& x)
+ {
+ return (I == 0)
+ ? geometry::set<D>(segment.first, x)
+ : geometry::set<D>(segment.second, x);
+ }
};
- }}
+}}
namespace boost{ namespace guigl { namespace ggl {
- namespace dispatch
+ namespace dispatch
{
- template <typename Tag, typename G>
- struct object_tag
- {
- //static inline void vertex(G const& ) {}
- //static inline void draw(G const& g) {}
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // Point
- template<typename G>
- struct object_tag<geometry::point_tag, G>
- {
- private:
- template<int D>
- static inline void vertex_(G const& g);
-
- template<>
- static inline void vertex_<2>(G const& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0>(g),
- geometry::get<1>(g));
- }
-
- template<>
- static inline void vertex_<3>(G const& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0>(g),
- geometry::get<1>(g),
- geometry::get<2>(g));
- }
- template<>
- static inline void vertex_<4>(G const& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0>(g),
- geometry::get<1>(g),
- geometry::get<2>(g),
- geometry::get<3>(g));
- }
-
- public:
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstPoint<G>)),
- (void))
- vertex(G const& g)
- {
- vertex_<geometry::traits::dimension<G>::value>(g);
- }
-
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstPoint<G>)),
- (void))
- draw(G const& g)
- {
- glBegin(GL_POINTS);
- vertex(g);
- glEnd();
- }
- };
+ template <typename Tag, typename G>
+ struct object_tag
+ {
+ //static inline void vertex(G const& ) {}
+ //static inline void draw(G const& g) {}
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Point
+ template<typename G>
+ struct object_tag<geometry::point_tag, G>
+ {
+ private:
+ template<int D>
+ static inline void vertex_(G const& g);
+
+ template<>
+ static inline void vertex_<2>(G const& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0>(g),
+ geometry::get<1>(g));
+ }
+
+ template<>
+ static inline void vertex_<3>(G const& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0>(g),
+ geometry::get<1>(g),
+ geometry::get<2>(g));
+ }
+ template<>
+ static inline void vertex_<4>(G const& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0>(g),
+ geometry::get<1>(g),
+ geometry::get<2>(g),
+ geometry::get<3>(g));
+ }
+
+ public:
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstPoint<G>)),
+ (void))
+ vertex(G const& g)
+ {
+ vertex_<geometry::traits::dimension<G>::value>(g);
+ }
+
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstPoint<G>)),
+ (void))
+ draw(G const& g)
+ {
+ glBegin(GL_POINTS);
+ vertex(g);
+ glEnd();
+ }
+ };
}
- template<class Tag, class G>
- void vertex(G const& g)
+ template<class Tag, class G>
+ void vertex(G const& g)
{
- dispatch::object_tag<Tag, G>::vertex(g);
+ dispatch::object_tag<Tag, G>::vertex(g);
}
- template<class G>
- void vertex(G const& g)
+ template<class G>
+ void vertex(G const& g)
{
- vertex<typename geometry::traits::tag<G>::type>(g);
+ vertex<typename geometry::traits::tag<G>::type>(g);
}
- struct vertex_drawer {
- template<class G>
- void operator()(G const& g) const {vertex(g);}
+ struct vertex_drawer {
+ template<class G>
+ void operator()(G const& g) const {vertex(g);}
};
- namespace dispatch
+ namespace dispatch
{
- ////////////////////////////////////////////////////////////////////////////////
- // Segment
- template<typename G>
- struct object_tag<geometry::segment_tag, G>
- {
- private:
- template<int D>
- static inline void vertex_(const G& g);
-
- template<>
- static inline void vertex_<2>(const G& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0, 0>(g),
- geometry::get<0, 1>(g));
- boost::guigl::gl::vertex(
- geometry::get<1, 0>(g),
- geometry::get<1, 1>(g));
- }
-
- template<>
- static inline void vertex_<3>(const G& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0, 0>(g),
- geometry::get<0, 1>(g),
- geometry::get<0, 2>(g));
- boost::guigl::gl::vertex(
- geometry::get<1, 0>(g),
- geometry::get<1, 1>(g),
- geometry::get<1, 2>(g));
- }
-
- template<>
- static inline void vertex_<4>(const G& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<0, 0>(g),
- geometry::get<0, 1>(g),
- geometry::get<0, 2>(g),
- geometry::get<0, 3>(g));
- boost::guigl::gl::vertex(
- geometry::get<1, 0>(g),
- geometry::get<1, 1>(g),
- geometry::get<1, 2>(g),
- geometry::get<1, 3>(g));
- }
-
- public:
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstSegment<G>)),
- (void))
- vertex(G const& g)
- {
- typedef typename geometry::traits::point_type<G>::type point_type;
- vertex_<geometry::traits::dimension<point_type>::value>(g);
- }
-
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstSegment<G>)),
- (void))
- draw(G const& g)
- {
- glBegin(GL_LINES);
- vertex(g);
- glEnd();
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // Box
- template<typename G>
- struct object_tag<geometry::box_tag, G>
- {
- private:
- template<int D>
- static inline void vertex_(const G& g);
-
- template<>
- static inline void vertex_<2>(const G& g)
- {
- boost::guigl::gl::vertex(
- geometry::get<geometry::min_corner, 0>(g),
- geometry::get<geometry::min_corner, 1>(g));
- boost::guigl::gl::vertex(
- geometry::get<geometry::min_corner, 0>(g),
- geometry::get<geometry::max_corner, 1>(g));
- boost::guigl::gl::vertex(
- geometry::get<geometry::max_corner, 0>(g),
- geometry::get<geometry::max_corner, 1>(g));
- boost::guigl::gl::vertex(
- geometry::get<geometry::max_corner, 0>(g),
- geometry::get<geometry::min_corner, 1>(g));
- }
-
- // support for 3d
-
- public:
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstBox<G>)),
- (void))
- vertex(G const& g)
- {
- typedef typename geometry::traits::point_type<G>::type point_type;
- vertex_<geometry::traits::dimension<point_type>::value>(g);
- }
-
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstBox<G>)),
- (void))
- draw(G const& g)
- {
- glBegin(GL_LINE_LOOP);
- vertex(g);
- glEnd();
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // Point Set
- template<typename G, int GLMode, template<typename T> class Concept>
- struct point_set
- {
- public:
- static inline
- BOOST_CONCEPT_REQUIRES(((Concept<G>)),
- (void))
- vertex(G const& g)
- {
- std::for_each(
- boost::begin(g), boost::end(g),
- vertex_drawer());
- }
-
- static inline
- BOOST_CONCEPT_REQUIRES(((Concept<G>)),
- (void))
- draw(G const& g)
- {
- glBegin(GLMode);
- vertex(g);
- glEnd();
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // Linestring
- template<typename G>
- struct object_tag<geometry::linestring_tag, G>
- : public point_set<G, GL_LINE_STRIP, geometry::ConstLinestring>
- {
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // Ring
- template<typename G>
- struct object_tag<geometry::ring_tag, G>
- : public point_set<G, GL_LINE_LOOP, geometry::ConstRing>
- {
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // polygon_tag
- // polygon is not implemented yet
- template<typename G>
- struct object_tag<geometry::polygon_tag, G>
- {
- public:
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstPolygon<G>)),
- (void))
- vertex(G const& g)
- {
- ggl::vertex(geometry::exterior_ring(g));
-
- std::for_each(
- boost::begin(geometry::interior_rings(g)),
- boost::end(geometry::interior_rings(g)),
- vertex_drawer());
- }
-
- static inline
- BOOST_CONCEPT_REQUIRES(((geometry::ConstPolygon<G>)),
- (void))
- draw(G const& g)
- {
- }
- };
+ ////////////////////////////////////////////////////////////////////////////////
+ // Segment
+ template<typename G>
+ struct object_tag<geometry::segment_tag, G>
+ {
+ private:
+ template<int D>
+ static inline void vertex_(const G& g);
+
+ template<>
+ static inline void vertex_<2>(const G& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0, 0>(g),
+ geometry::get<0, 1>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<1, 0>(g),
+ geometry::get<1, 1>(g));
+ }
+
+ template<>
+ static inline void vertex_<3>(const G& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0, 0>(g),
+ geometry::get<0, 1>(g),
+ geometry::get<0, 2>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<1, 0>(g),
+ geometry::get<1, 1>(g),
+ geometry::get<1, 2>(g));
+ }
+
+ template<>
+ static inline void vertex_<4>(const G& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<0, 0>(g),
+ geometry::get<0, 1>(g),
+ geometry::get<0, 2>(g),
+ geometry::get<0, 3>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<1, 0>(g),
+ geometry::get<1, 1>(g),
+ geometry::get<1, 2>(g),
+ geometry::get<1, 3>(g));
+ }
+
+ public:
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstSegment<G>)),
+ (void))
+ vertex(G const& g)
+ {
+ typedef typename geometry::traits::point_type<G>::type point_type;
+ vertex_<geometry::traits::dimension<point_type>::value>(g);
+ }
+
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstSegment<G>)),
+ (void))
+ draw(G const& g)
+ {
+ glBegin(GL_LINES);
+ vertex(g);
+ glEnd();
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Box
+ template<typename G>
+ struct object_tag<geometry::box_tag, G>
+ {
+ private:
+ template<int D>
+ static inline void vertex_(const G& g);
+
+ template<>
+ static inline void vertex_<2>(const G& g)
+ {
+ boost::guigl::gl::vertex(
+ geometry::get<geometry::min_corner, 0>(g),
+ geometry::get<geometry::min_corner, 1>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<geometry::min_corner, 0>(g),
+ geometry::get<geometry::max_corner, 1>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<geometry::max_corner, 0>(g),
+ geometry::get<geometry::max_corner, 1>(g));
+ boost::guigl::gl::vertex(
+ geometry::get<geometry::max_corner, 0>(g),
+ geometry::get<geometry::min_corner, 1>(g));
+ }
+
+ // support for 3d
+
+ public:
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstBox<G>)),
+ (void))
+ vertex(G const& g)
+ {
+ typedef typename geometry::traits::point_type<G>::type point_type;
+ vertex_<geometry::traits::dimension<point_type>::value>(g);
+ }
+
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstBox<G>)),
+ (void))
+ draw(G const& g)
+ {
+ glBegin(GL_LINE_LOOP);
+ vertex(g);
+ glEnd();
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Point Set
+ template<typename G, int GLMode, template<typename T> class Concept>
+ struct point_set
+ {
+ public:
+ static inline
+ BOOST_CONCEPT_REQUIRES(((Concept<G>)),
+ (void))
+ vertex(G const& g)
+ {
+ std::for_each(
+ boost::begin(g), boost::end(g),
+ vertex_drawer());
+ }
+
+ static inline
+ BOOST_CONCEPT_REQUIRES(((Concept<G>)),
+ (void))
+ draw(G const& g)
+ {
+ glBegin(GLMode);
+ vertex(g);
+ glEnd();
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Linestring
+ template<typename G>
+ struct object_tag<geometry::linestring_tag, G>
+ : public point_set<G, GL_LINE_STRIP, geometry::ConstLinestring>
+ {
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Ring
+ template<typename G>
+ struct object_tag<geometry::ring_tag, G>
+ : public point_set<G, GL_LINE_LOOP, geometry::ConstRing>
+ {
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // polygon_tag
+ // polygon is not implemented yet
+ template<typename G>
+ struct object_tag<geometry::polygon_tag, G>
+ {
+ public:
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstPolygon<G>)),
+ (void))
+ vertex(G const& g)
+ {
+ ggl::vertex(geometry::exterior_ring(g));
+
+ std::for_each(
+ boost::begin(geometry::interior_rings(g)),
+ boost::end(geometry::interior_rings(g)),
+ vertex_drawer());
+ }
+
+ static inline
+ BOOST_CONCEPT_REQUIRES(((geometry::ConstPolygon<G>)),
+ (void))
+ draw(G const& g)
+ {
+ }
+ };
}
- template<class Tag, class G>
- void draw(G const& g)
+ template<class Tag, class G>
+ void draw(G const& g)
{
- dispatch::object_tag<Tag, G>::draw(g);
+ dispatch::object_tag<Tag, G>::draw(g);
}
- template<class G>
- void draw(G const& g)
+ template<class G>
+ void draw(G const& g)
{
- draw<typename geometry::traits::tag<G>::type>(g);
+ draw<typename geometry::traits::tag<G>::type>(g);
}
- struct drawer {
- template<class G>
- void operator()(G const& g) const {draw(g);}
+ struct drawer {
+ template<class G>
+ void operator()(G const& g) const {draw(g);}
};
- }}}
+}}}
#endif BOOST__GUIGL__GGL_HPP
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp 2009-03-25 18:52:40 EDT (Wed, 25 Mar 2009)
@@ -14,99 +14,246 @@
#include <boost/guigl/ggl.hpp>
#include <boost/guigl/gl.hpp>
+#include <boost/foreach.hpp>
+
#include <boost/assign/std.hpp>
#include <geometry/geometries/geometries.hpp>
+#include <geometry/algorithms/correct.hpp>
namespace geometry { namespace traits{
- template<class T>
- struct point_type<std::vector<T> >
+ template<class T>
+ struct point_type<std::vector<T> >
{
- typedef T type;
+ typedef T type;
};
- }}
+}}
using namespace boost::guigl;
+void CALLBACK tess_begin_cb(GLenum which) { glBegin(which); }
+void CALLBACK tess_end_cb() { glEnd(); }
+void CALLBACK tess_vertex_cb(const GLvoid *data) { glVertex3dv((const GLdouble*)data); }
+void CALLBACK tess_error_cb(GLenum errorCode)
+{
+ const GLubyte *errorStr;
+ errorStr = gluErrorString(errorCode);
+ std::cerr << "[ERROR]: " << errorStr << std::endl;
+}
+
+class tess : boost::noncopyable {
+public:
+ GLUtesselator *m_tess;
+
+public:
+ tess() {
+ m_tess = gluNewTess(); // create a tessellator
+ if(!m_tess) throw std::runtime_error("failed to create tessellation object");
+ }
+ ~tess() { gluDeleteTess(m_tess); }
+
+ class polygon : boost::noncopyable {
+ public:
+ tess const& m_tess;
+ public:
+ polygon(tess const& t)
+ : m_tess(t)
+ { gluTessBeginPolygon(m_tess.m_tess, 0); }
+ ~polygon(){ gluTessEndPolygon(m_tess.m_tess); }
+
+ class contour : boost::noncopyable {
+ public:
+ tess const& m_tess;
+
+ public:
+ contour(tess const& t)
+ : m_tess(t)
+ { gluTessBeginContour(m_tess.m_tess); }
+ ~contour(){ gluTessEndContour(m_tess.m_tess); }
+
+ inline void operator()(double coord[3], void *data) const {
+ gluTessVertex(m_tess.m_tess, coord, data);
+ }
+
+ inline void operator()(double coord[3]) const {
+ (*this)(coord, coord);
+ }
+
+ inline void operator()(position_type const& pos) const {
+ double coord[3] = {pos[0], pos[1], 0.0};
+ (*this)(coord);
+ }
+
+ };
+ };
+};
+
+GLuint tessellate1()
+{
+ glColor3f(1,1,0);
+
+ tess tt;
+ GLUtesselator* t = tt.m_tess;
+ GLdouble quad1[4][3] = { {-10,30,0}, {0,0,0}, {10,30,0}, {0,20,0} };
+
+ // register callback functions
+ gluTessCallback(t, GLU_TESS_BEGIN, (void (CALLBACK *)())tess_begin_cb);
+ gluTessCallback(t, GLU_TESS_END, (void (CALLBACK *)())tess_end_cb);
+ gluTessCallback(t, GLU_TESS_ERROR, (void (CALLBACK *)())tess_error_cb);
+ gluTessCallback(t, GLU_TESS_VERTEX, (void (CALLBACK *)())tess_vertex_cb);
+
+// glNewList(id, GL_COMPILE);
+ {
+ tess::polygon p(tt);
+ tess::polygon::contour c(tt);
+ c(quad1[0]);
+ c(quad1[1]);
+ c(quad1[2]);
+ c(quad1[3]);
+ }
+
+ return 0;//id; // return handle ID of a display list
+}
+
typedef view::positioned<> my_widget_base_type;
class my_widget : public my_widget_base_type
- {
- public:
+{
+public:
typedef my_widget_base_type base_type;
template<typename ArgumentPack>
my_widget(const ArgumentPack &args)
- : base_type(args)
- {}
+ : base_type(args)
+ {}
void draw_prologue()
- {
- base_type::draw_prologue();
- using namespace boost::assign;
-
- geometry::linear_ring<position_type> r;
- r.push_back(point<LT>());
- r.push_back(point<RB>());
- r.push_back(point<RT>());
- r.push_back(point<LB>());
-
- // linear_ring
- gl::color(yellow());
- glLineWidth(7);
- ggl::draw(r);
-
- // box
- gl::color(blue());
- glLineWidth(1);
- geometry::box<position_type> b(
- point<LT>(),
- point<RB>());
- ggl::draw(b);
-
- // segment
- gl::color(green(0.5));
- glLineWidth(2);
- ggl::draw(segment<HC>());
- ggl::draw(segment<VC>());
-
- gl::color(red(0.2));
- glLineWidth(5);
- ggl::draw(segment<D1>());
- ggl::draw(segment<D2>());
-
- // std::vector as a ring
- gl::color(black());
- std::vector<position_type> v;
- v +=
- point<LC>(),
- point<CT>(),
- point<RC>(),
- point<CB>();
- ggl::draw<geometry::ring_tag>(v);
-
- // std::vector as a linestring
- glLineWidth(0.5);
- gl::color(white());
- ggl::draw<geometry::linestring_tag>(v);
+ {
+ base_type::draw_prologue();
+ using namespace boost::assign;
- }
+ geometry::linear_ring<position_type> r;
+ r.push_back(point<LT>());
+ r.push_back(point<RB>());
+ r.push_back(point<RT>());
+ r.push_back(point<LB>());
+
+ // linear_ring
+ gl::color(yellow());
+ glLineWidth(7);
+ ggl::draw(r);
+
+ // box
+ gl::color(blue());
+ glLineWidth(1);
+ geometry::box<position_type> b(
+ point<LT>(),
+ point<RB>());
+ ggl::draw(b);
+
+ // segment
+ gl::color(green(0.5f));
+ glLineWidth(2);
+ ggl::draw(segment<HC>());
+ ggl::draw(segment<VC>());
+
+ gl::color(red(0.2f));
+ glLineWidth(5);
+ ggl::draw(segment<D1>());
+ ggl::draw(segment<D2>());
+
+ // std::vector as a ring
+ gl::color(black());
+ std::vector<position_type> v;
+ v +=
+ point<LC>(),
+ point<CT>(),
+ point<RC>(),
+ point<CB>();
+ ggl::draw<geometry::ring_tag>(v);
+
+ // std::vector as a linestring
+ glLineWidth(0.5);
+ gl::color(white());
+ ggl::draw<geometry::linestring_tag>(v);
+
+ // polygon
+ geometry::polygon<position_type> pg;
+ pg.outer() +=
+ point<LT>(),
+ point<RT>(),
+ point<RB>(),
+ point<LB>();
+ pg.inners().resize(1);
+ std::copy(v.begin(), v.end(), std::back_inserter(pg.inners().back()));
+ geometry::correct(pg);
+
+ //glPointSize(10);
+ //gl::color(red());
+ //glBegin(GL_POINTS);
+ //ggl::vertex(pg);
+ //glEnd();
+
+ //GLuint id = glGenLists(1); // create a display list
+ gl::color(red(0.5));
+ //{
+ // GLUtesselator *t = gluNewTess(); // create a tessellator
+ // //tess t;
+ // // register callback functions
+ // gluTessCallback(t, GLU_TESS_BEGIN, (void (__stdcall*)(void))tess_begin_cb);
+ // gluTessCallback(t, GLU_TESS_END, (void (__stdcall*)(void))tess_end_cb);
+ // gluTessCallback(t, GLU_TESS_ERROR, (void (__stdcall*)(void))tess_error_cb);
+ // gluTessCallback(t, GLU_TESS_VERTEX, (void (__stdcall*)())tess_vertex_cb);
+
+ // glNewList(id, GL_COMPILE);
+ // gluTessBeginPolygon(t, 0);
+ // //tess::polygon p(t);
+ // {
+ // {
+ // gluTessBeginContour(t);
+ // //tess::polygon::contour c(t);
+ // BOOST_FOREACH(position_type const& pos, pg.outer())
+ // {
+ // double coord[3] = {pos[0], pos[1], 0.0};
+ // gluTessVertex(t, coord, coord);
+ // //c(pos);
+ // }
+ // gluTessEndContour(t);
+ // }
+
+ // //BOOST_FOREACH(
+ // // geometry::linear_ring<position_type> const& ring,
+ // // pg.inners())
+ // //{
+ // // tess::polygon::contour c(t);
+ // // BOOST_FOREACH(position_type const& pos, ring)
+ // // { c(pos); }
+ // //}
+ // }
+ // gluTessEndPolygon(t);
+ // glEndList();
+ // gluDeleteTess(t);
+ //}
+
+ tessellate1();
+// glCallList(tessellate1());
+ }
BOOST_GUIGL_WIDGET_DRAW_IMPL(my_widget);
- };
+};
int main()
- {
- window wnd((
- _label = "GGL example",
- _size = size_type(500, 500),
- _background = white()
- ));
-
- wnd << new my_widget((
- _size = size_type(300, 300),
- _position = position_type(100, 100)
- ));
-
- application::run();
- return 0;
- }
+{
+ window wnd((
+ _label = "GGL example",
+ _size = size_type(500, 500),
+ _background = white()
+ ));
+
+ wnd << new my_widget((
+ _size = size_type(300, 300),
+ _position = position_type(100, 100)
+ ));
+
+ application::run();
+ return 0;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk