Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52077 - sandbox-branches/andreo/guigl/libs/guigl/example/autogeo
From: andreytorba_at_[hidden]
Date: 2009-03-31 12:02:04


Author: andreo
Date: 2009-03-31 12:02:03 EDT (Tue, 31 Mar 2009)
New Revision: 52077
URL: http://svn.boost.org/trac/boost/changeset/52077

Log:
autogeo
Text files modified:
   sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/functor.hpp | 52 +++++++++++++++++++++++++-----------
   sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/geometry.cpp | 56 ++++++++++++++++++++++++++-------------
   sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/graph.hpp | 14 +++++++--
   sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/visitors.hpp | 35 ++++++++++++++++++++----
   4 files changed, 112 insertions(+), 45 deletions(-)

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/functor.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/functor.hpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/functor.hpp 2009-03-31 12:02:03 EDT (Tue, 31 Mar 2009)
@@ -71,24 +71,44 @@
 typedef boost::guigl::segment_type line_type;
 typedef geometry::polygon<point_type> plane_type;
 
+typedef SmartResult<vector_type> const& SmartVector;
 typedef SmartResult<point_type> const& SmartPoint;
 typedef SmartResult<line_type> const& SmartLine;
 typedef SmartResult<plane_type> const& SmartPlane;
 
-typedef
-Functor<point_type, boost::tuple<>, point_type>
-source_point;
-
-typedef
-Functor<line_type, boost::tuple<SmartPoint, SmartPoint> >
-line_from_two_points;
-
-//typedef
-//Functor<line_type, boost::tuple<SmartPoint, SmartVector, SmartDistance> >
-//line_from_point_vector_distance;
-
-typedef
-Functor<plane_type, boost::tuple<SmartPoint, SmartPoint, SmartPoint> >
-plane_from_three_points;
-
+namespace functor {
+ //SmartVector
+ typedef
+ Functor<vector_type, boost::tuple<SmartLine> >
+ direction_of;
+
+ typedef
+ Functor<line_type, boost::tuple<SmartLine, SmartVector> >
+ translate_line;
+
+ typedef
+ Functor<vector_type, boost::tuple<SmartPlane> >
+ normal_of;
+
+ typedef
+ Functor<vector_type, boost::tuple<SmartVector, SmartVector> >
+ perpendicular_to;
+
+ //SmartPoint
+ typedef
+ Functor<point_type, boost::tuple<>, point_type>
+ source_point;
+
+ typedef
+ Functor<line_type, boost::tuple<SmartPoint, SmartPoint> >
+ line_from_two_points;
+
+ //typedef
+ //Functor<line_type, boost::tuple<SmartPoint, SmartVector, SmartDistance> >
+ //line_from_point_vector_distance;
+
+ typedef
+ Functor<plane_type, boost::tuple<SmartPoint, SmartPoint, SmartPoint> >
+ plane_from_three_points;
+ };
 #endif // BOOST_GUIGL_EXAMPLE_FUNCTORS_HPP

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/geometry.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/geometry.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/geometry.cpp 2009-03-31 12:02:03 EDT (Tue, 31 Mar 2009)
@@ -34,9 +34,10 @@
 
 using namespace boost::guigl;
 
-class Renderer : public IVisitor
+class Renderer
   {
   public:
+
     void operator()(SmartResult<point_type>& g) const
       {
       gl::color(blue(0.7f));
@@ -66,27 +67,43 @@
 class RecomputeVisitor : public IVisitor
   {
   public:
- void visit(source_point& o) const
+ void visit(functor::direction_of& x) const
       {
- o.result = o.data;
+ line_type const& line = x.args.get<0>().result;
+ x.result = vector_type(line.second.x - line.first.x, line.second.y - line.first.y);
+ }
+
+ void visit(functor::translate_line& x) const
+ {
+ line_type const& line = x.args.get<0>().result;
+ vector_type const& vector = x.args.get<1>().result;
 
- point_type const* p = &o.result;
+ x.result = line;
+ x.result.first.x += vector.x;
+ x.result.second.x += vector.x;
+ x.result.first.y += vector.y;
+ x.result.second.y += vector.y;
+ }
+
+ void visit(functor::source_point& o) const
+ {
+ o.result = o.data;
       };
 
- void visit(line_from_two_points& o) const
+ void visit(functor::line_from_two_points& o) const
       {
- o.result.first = arg<0>(o).result;
- o.result.second = arg<1>(o).result;
+ o.result.first = o.args.get<0>().result;
+ o.result.second = o.args.get<1>().result;
       };
 
- void visit(plane_from_three_points& o) const
+ void visit(functor::plane_from_three_points& o) const
       {
       using namespace boost::assign;
       o.result.outer().clear();
       o.result.outer() +=
- arg<1>(o).result,
- arg<2>(o).result,
- arg<3>(o).result;
+ o.args.get<0>().result,
+ o.args.get<1>().result,
+ o.args.get<2>().result;
       geometry::correct(o.result);
       };
   };
@@ -100,7 +117,7 @@
     }
 
   template<>
- void operator()<line_from_two_points>(line_from_two_points& g) const
+ void operator()<functor::line_from_two_points>(functor::line_from_two_points& g) const
     {
     geometry::linestring<point_type> s;
     geometry::append(s, g.result.first);
@@ -279,10 +296,10 @@
       g.objects.end(),
       accept_each(Visitor<Renderer>()));
 
- std::for_each(
- g.objects.begin(),
- g.objects.end(),
- accept_each(Visitor<PrintDescription>(PrintDescription(names, g))));
+ //std::for_each(
+ // g.objects.begin(),
+ // g.objects.end(),
+ // accept_each(Visitor<PrintDescription>(PrintDescription(names, g))));
     }
   };
 
@@ -313,8 +330,6 @@
   {
   using namespace boost::assign;
 
- boost::make_tuple(1).get<0>();
-
   SmartPoint
     pt_mnp = make_source_point(g, point_type(90, 90)),
     pt_fh = make_source_point(g, point_type(-90, -90)),
@@ -323,7 +338,10 @@
 
   SmartLine
     ax_mech = make_line(g, pt_mnp, pt_fh),
- ax_epi = make_line(g, pt_meepi, pt_laepi);
+ ax_epi = make_line(g, pt_meepi, pt_laepi),
+ ax = make_line(g, pt_fh, pt_laepi);
+
+ translate(g, ax, direction_of(g, ax_epi));
 
   SmartPlane
     pl_axial = make_plane(g, pt_mnp, pt_fh, pt_laepi);

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/graph.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/graph.hpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/graph.hpp 2009-03-31 12:02:03 EDT (Tue, 31 Mar 2009)
@@ -72,7 +72,7 @@
 
   SmartPoint make_source_point(DependencyGraph& g, point_type const& pt)
   {
- return g.add_functor<source_point>(boost::make_tuple(), pt);
+ return g.add_functor<functor::source_point>(boost::make_tuple(), pt);
   }
 
 #define FUNCTOR_IMPL_1(FunctionName, F, T1)\
@@ -100,9 +100,15 @@
     boost::make_tuple(boost::cref(arg1), boost::cref(arg2), boost::cref(arg3)));\
     }
 
-FUNCTOR_IMPL_2(make_line, line_from_two_points, point_type, point_type);
-//FUNCTOR_IMPL_3(make_line, line_from_point_vector_distance, point_type, vector_type, distance_type);
+FUNCTOR_IMPL_2(make_line, functor::line_from_two_points, point_type, point_type);
+//FUNCTOR_IMPL_3(make_line, functor::line_from_point_vector_distance, point_type, vector_type, distance_type);
+
+FUNCTOR_IMPL_3(make_plane, functor::plane_from_three_points, point_type, point_type, point_type);
+
+FUNCTOR_IMPL_2(perpendicular_to, functor::perpendicular_to, vector_type, vector_type);
+FUNCTOR_IMPL_1(normal_of, functor::normal_of, plane_type);
+FUNCTOR_IMPL_1(direction_of, functor::direction_of, line_type);
+FUNCTOR_IMPL_2(translate, functor::translate_line, line_type, vector_type);
 
-FUNCTOR_IMPL_3(make_plane, plane_from_three_points, point_type, point_type, point_type);
 
 #endif

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/visitors.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/visitors.hpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/autogeo/visitors.hpp 2009-03-31 12:02:03 EDT (Tue, 31 Mar 2009)
@@ -8,9 +8,20 @@
   public:
     virtual ~IVisitor(){}
 
- virtual void visit(source_point& g) const {}
- virtual void visit(line_from_two_points& g) const {};
- virtual void visit(plane_from_three_points& g) const {};
+ //Vector
+ virtual void visit(functor::perpendicular_to& g) const {}
+ virtual void visit(functor::normal_of& g) const {}
+ virtual void visit(functor::direction_of& g) const {}
+ virtual void visit(functor::translate_line& g) const {}
+
+ //Point
+ virtual void visit(functor::source_point& g) const {}
+
+ //Line
+ virtual void visit(functor::line_from_two_points& g) const {}
+
+ //Plane
+ virtual void visit(functor::plane_from_three_points& g) const {}
   };
 
 template<class StaticVisitor>
@@ -22,9 +33,21 @@
   public:
     Visitor(StaticVisitor const& static_visitor = StaticVisitor())
       : m_static_visitor(static_visitor) {}
- void visit(source_point& g) const {m_static_visitor(g);}
- void visit(line_from_two_points& g) const {m_static_visitor(g);};
- void visit(plane_from_three_points& g) const {m_static_visitor(g);};
+
+ //Vector
+ void visit(functor::perpendicular_to& g) const {m_static_visitor(g);}
+ void visit(functor::normal_of& g) const {m_static_visitor(g);}
+ void visit(functor::direction_of& g) const {m_static_visitor(g);}
+ void visit(functor::translate_line& g) const {m_static_visitor(g);}
+
+ //Point
+ void visit(functor::source_point& g) const {m_static_visitor(g);}
+
+ //Line
+ void visit(functor::line_from_two_points& g) const {m_static_visitor(g);}
+
+ //Plane
+ void visit(functor::plane_from_three_points& g) const {m_static_visitor(g);}
   };
 
 #endif


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