|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70725 - branches/release/boost/polygon
From: lucanus.j.simonson_at_[hidden]
Date: 2011-03-29 19:52:51
Author: ljsimons
Date: 2011-03-29 19:52:50 EDT (Tue, 29 Mar 2011)
New Revision: 70725
URL: http://svn.boost.org/trac/boost/changeset/70725
Log:
added simplify algorithm
Text files modified:
branches/release/boost/polygon/polygon_set_concept.hpp | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
Modified: branches/release/boost/polygon/polygon_set_concept.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_set_concept.hpp (original)
+++ branches/release/boost/polygon/polygon_set_concept.hpp 2011-03-29 19:52:50 EDT (Tue, 29 Mar 2011)
@@ -8,6 +8,7 @@
#ifndef BOOST_POLYGON_POLYGON_SET_CONCEPT_HPP
#define BOOST_POLYGON_POLYGON_SET_CONCEPT_HPP
#include "polygon_set_data.hpp"
+#include "detail/polygon_simplify.hpp"
namespace boost { namespace polygon{
template <typename T, typename T2>
@@ -148,16 +149,39 @@
return retval;
}
- // TODO: Dafna add ngon parameter passing
+ template <typename polygon_set_type>
+ typename enable_if< typename is_mutable_polygon_set_type<polygon_set_type>::type,
+ std::size_t>::type
+ simplify(polygon_set_type& polygon_set, typename coordinate_traits<
+ typename polygon_set_traits<polygon_set_type>::coordinate_type
+ >::coordinate_distance threshold) {
+ typedef typename polygon_set_traits<polygon_set_type>::coordinate_type Unit;
+ typedef polygon_with_holes_data<Unit> p_type;
+ std::vector<p_type> polys;
+ assign(polys, polygon_set);
+ std::size_t retval = 0;
+ for(std::size_t i = 0; i < polys.size(); ++i) {
+ retval += detail::simplify_detail::simplify(polys[i].self_.coords_,
+ polys[i].self_.coords_, threshold);
+ for(typename std::list<polygon_data<Unit> >::iterator itrh =
+ polys[i].holes_.begin(); itrh != (polys[i].holes_.end()); ++itrh) {
+ retval += detail::simplify_detail::simplify((*itrh).coords_,
+ (*itrh).coords_, threshold);
+ }
+ }
+ assign(polygon_set, polys);
+ return retval;
+ }
+
template <typename polygon_set_type, typename coord_type>
typename enable_if< typename is_mutable_polygon_set_type<polygon_set_type>::type,
polygon_set_type>::type &
- resize(polygon_set_type& polygon_set, coord_type resizing, bool corner_fill_arcs = false, int ngon=0) {
+ resize(polygon_set_type& polygon_set, coord_type resizing, bool corner_fill_arcs = false, int num_circle_segments = 0) {
typedef typename polygon_set_traits<polygon_set_type>::coordinate_type Unit;
clean(polygon_set);
polygon_set_data<Unit> ps;
assign(ps, polygon_set);
- ps.resize(resizing, corner_fill_arcs,ngon);
+ ps.resize(resizing, corner_fill_arcs,num_circle_segments);
assign(polygon_set, ps);
return polygon_set;
}
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