mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
[buffer] documentation of 6 distance strategies
This commit is contained in:
parent
46068123b9
commit
c12701bb40
BIN
doc/html/img/strategies/buffer_distance_asymmetric.png
Normal file
BIN
doc/html/img/strategies/buffer_distance_asymmetric.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
doc/html/img/strategies/buffer_distance_symmetric.png
Normal file
BIN
doc/html/img/strategies/buffer_distance_symmetric.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
doc/html/img/strategies/buffer_end_flat.png
Normal file
BIN
doc/html/img/strategies/buffer_end_flat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
doc/html/img/strategies/buffer_end_round.png
Normal file
BIN
doc/html/img/strategies/buffer_end_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
doc/html/img/strategies/buffer_join_miter.png
Normal file
BIN
doc/html/img/strategies/buffer_join_miter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
doc/html/img/strategies/buffer_join_round.png
Normal file
BIN
doc/html/img/strategies/buffer_join_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -114,6 +114,12 @@
|
||||
[import src/examples/io/wkt.cpp]
|
||||
[import src/examples/io/read_wkt.cpp]
|
||||
|
||||
[import src/examples/strategies/buffer_join_round.cpp]
|
||||
[import src/examples/strategies/buffer_join_miter.cpp]
|
||||
[import src/examples/strategies/buffer_end_round.cpp]
|
||||
[import src/examples/strategies/buffer_end_flat.cpp]
|
||||
[import src/examples/strategies/buffer_distance_symmetric.cpp]
|
||||
[import src/examples/strategies/buffer_distance_asymmetric.cpp]
|
||||
[import src/examples/strategies/buffer_circle.cpp]
|
||||
[import src/examples/strategies/buffer_square.cpp]
|
||||
|
||||
|
@ -116,6 +116,9 @@ strategies = ["distance::pythagoras", "distance::pythagoras_box_box"
|
||||
, "within::winding", "within::franklin", "within::crossings_multiply"
|
||||
, "area::surveyor", "area::huiller"
|
||||
, "buffer::buffer_circle", "buffer::buffer_square"
|
||||
, "buffer::join_round", "buffer::join_miter"
|
||||
, "buffer::end_round", "buffer::end_flat"
|
||||
, "buffer::distance_symmetric", "buffer::distance_asymmetric"
|
||||
, "centroid::bashein_detmer", "centroid::average"
|
||||
, "convex_hull::graham_andrew"
|
||||
, "simplify::douglas_peucker"
|
||||
|
@ -300,6 +300,12 @@
|
||||
[include generated/distance_cross_track.qbk]
|
||||
[include generated/area_surveyor.qbk]
|
||||
[include generated/area_huiller.qbk]
|
||||
[include generated/buffer_join_round.qbk]
|
||||
[include generated/buffer_join_miter.qbk]
|
||||
[include generated/buffer_end_round.qbk]
|
||||
[include generated/buffer_end_flat.qbk]
|
||||
[include generated/buffer_distance_symmetric.qbk]
|
||||
[include generated/buffer_distance_asymmetric.qbk]
|
||||
[include generated/buffer_buffer_circle.qbk]
|
||||
[include generated/buffer_buffer_square.qbk]
|
||||
[include generated/centroid_average.qbk]
|
||||
|
@ -25,5 +25,11 @@
|
||||
[$img/algorithms/buffer_multi_polygon.png]
|
||||
|
||||
[heading Available Strategies]
|
||||
* JoinStrategy: [link geometry.reference.strategies.strategy_buffer_join_round Round (cartesian)]
|
||||
* JoinStrategy: [link geometry.reference.strategies.strategy_buffer_join_miter Miter (cartesian)]
|
||||
* EndStrategy: [link geometry.reference.strategies.strategy_buffer_end_round Round (cartesian)]
|
||||
* EndStrategy: [link geometry.reference.strategies.strategy_buffer_end_flat Flat (cartesian)]
|
||||
* DistanceStrategy: [link geometry.reference.strategies.strategy_buffer_distance_symmetric Symmetric]
|
||||
* DistanceStrategy: [link geometry.reference.strategies.strategy_buffer_distance_asymmetric Asymmetric]
|
||||
* PointStrategy: [link geometry.reference.strategies.strategy_buffer_buffer_circle Circle (cartesian)]
|
||||
* PointStrategy: [link geometry.reference.strategies.strategy_buffer_buffer_square Square (cartesian)]
|
||||
|
@ -29,10 +29,10 @@ void create_svg_buffer(std::string const& filename, Geometry1 const& original, G
|
||||
mapper.add(buffer);
|
||||
|
||||
// Draw buffer at bottom
|
||||
mapper.map(buffer, "fill-opacity:0.6;fill:rgb(255,255,64);stroke:rgb(255,128,0);stroke-width:5;stroke-dasharray:1,7;stroke-linecap:round");
|
||||
mapper.map(buffer, "fill-opacity:0.6;fill:rgb(255,255,64);stroke:rgb(255,128,0);stroke-width:3");
|
||||
|
||||
// Draw original on top
|
||||
mapper.map(original, "fill-opacity:0.6;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:3");
|
||||
mapper.map(original, "fill-opacity:0.6;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
|
||||
|
||||
#else
|
||||
boost::ignore_unused_variable_warning(filename);
|
||||
|
@ -13,3 +13,9 @@ project boost-geometry-doc-example-strategies
|
||||
|
||||
exe buffer_circle : buffer_circle.cpp ;
|
||||
exe buffer_square : buffer_square.cpp ;
|
||||
exe buffer_join_round : buffer_join_round.cpp ;
|
||||
exe buffer_join_miter : buffer_join_miter.cpp ;
|
||||
exe buffer_end_round : buffer_end_round.cpp ;
|
||||
exe buffer_end_flat : buffer_end_flat.cpp ;
|
||||
exe buffer_distance_symmetric : buffer_distance_symmetric.cpp ;
|
||||
exe buffer_distance_asymmetric : buffer_distance_asymmetric.cpp ;
|
||||
|
49
doc/src/examples/strategies/buffer_distance_asymmetric.cpp
Normal file
49
doc/src/examples/strategies/buffer_distance_asymmetric.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_distance_asymmetric
|
||||
//` Shows how the buffer_distance_asymmetric strategy can be used as a EndStrategy to create rounded ends
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the asymmetric distance strategy
|
||||
boost::geometry::strategy::buffer::distance_asymmetric<double> distance_strategy(1.0, 0.5);
|
||||
|
||||
// Declare other strategies
|
||||
const int points_per_circle = 36;
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(points_per_circle);
|
||||
|
||||
// Declare/fill a multi linestring
|
||||
boost::geometry::model::multi_linestring<linestring> ml;
|
||||
boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml);
|
||||
|
||||
// Create the buffered geometry with left/right a different distance
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(ml, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_distance_asymmetric.svg", ml, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
49
doc/src/examples/strategies/buffer_distance_symmetric.cpp
Normal file
49
doc/src/examples/strategies/buffer_distance_symmetric.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_distance_symmetric
|
||||
//` Shows how the buffer_distance_symmetric strategy can be used as a EndStrategy to create rounded ends
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the symmetric distance strategy
|
||||
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(0.5);
|
||||
|
||||
// Declare other strategies
|
||||
const int points_per_circle = 36;
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(points_per_circle);
|
||||
|
||||
// Declare/fill a multi linestring
|
||||
boost::geometry::model::multi_linestring<linestring> ml;
|
||||
boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml);
|
||||
|
||||
// Create the buffered geometry with left/right the same distance
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(ml, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_distance_symmetric.svg", ml, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
49
doc/src/examples/strategies/buffer_end_flat.cpp
Normal file
49
doc/src/examples/strategies/buffer_end_flat.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_end_flat
|
||||
//` Shows how the buffer_end_flat strategy can be used as a EndStrategy to create flat ends
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the flat-end strategy
|
||||
boost::geometry::strategy::buffer::end_flat end_strategy;
|
||||
|
||||
// Declare other strategies
|
||||
const int points_per_circle = 36;
|
||||
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(points_per_circle);
|
||||
|
||||
// Declare/fill a multi linestring
|
||||
boost::geometry::model::multi_linestring<linestring> ml;
|
||||
boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml);
|
||||
|
||||
// Create the buffered geometry with flat ends
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(ml, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_end_flat.svg", ml, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
49
doc/src/examples/strategies/buffer_end_round.cpp
Normal file
49
doc/src/examples/strategies/buffer_end_round.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_end_round
|
||||
//` Shows how the buffer_end_round strategy can be used as a EndStrategy to create rounded ends
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the round-end strategy
|
||||
const int points_per_circle = 36;
|
||||
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
|
||||
|
||||
// Declare other strategies
|
||||
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(points_per_circle);
|
||||
|
||||
// Declare/fill a multi linestring
|
||||
boost::geometry::model::multi_linestring<linestring> ml;
|
||||
boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml);
|
||||
|
||||
// Create the buffered geometry with rounded ends
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(ml, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_end_round.svg", ml, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
48
doc/src/examples/strategies/buffer_join_miter.cpp
Normal file
48
doc/src/examples/strategies/buffer_join_miter.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_join_miter
|
||||
//` Shows how the buffer_join_miter strategy can be used as a JoinStrategy to create sharp corners
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the join_miter strategy
|
||||
boost::geometry::strategy::buffer::join_miter join_strategy;
|
||||
|
||||
// Declare other strategies
|
||||
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(0.5);
|
||||
boost::geometry::strategy::buffer::end_flat end_strategy;
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(36);
|
||||
|
||||
// Declare/fill a multi polygon
|
||||
boost::geometry::model::multi_polygon<polygon> mp;
|
||||
boost::geometry::read_wkt("MULTIPOLYGON(((5 5,7 8,9 5,5 5)),((8 7,8 10,11 10,11 7,8 7)))", mp);
|
||||
|
||||
// Create the buffered geometry with sharp corners
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(mp, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_join_miter.svg", mp, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
49
doc/src/examples/strategies/buffer_join_round.cpp
Normal file
49
doc/src/examples/strategies/buffer_join_round.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[buffer_join_round
|
||||
//` Shows how the buffer_join_round strategy can be used as a JoinStrategy to create rounded corners
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::d2::point_xy<double> point;
|
||||
typedef boost::geometry::model::linestring<point> linestring;
|
||||
typedef boost::geometry::model::polygon<point> polygon;
|
||||
|
||||
// Declare the join_round strategy
|
||||
const int points_per_circle = 36;
|
||||
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
|
||||
|
||||
// Declare other strategies
|
||||
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
|
||||
boost::geometry::strategy::buffer::end_flat end_strategy;
|
||||
boost::geometry::strategy::buffer::buffer_side side_strategy;
|
||||
boost::geometry::strategy::buffer::buffer_circle point_strategy(points_per_circle);
|
||||
|
||||
// Declare/fill a multi polygon
|
||||
boost::geometry::model::multi_polygon<polygon> mp;
|
||||
boost::geometry::read_wkt("MULTIPOLYGON(((5 5,7 8,9 5,5 5)),((8 7,8 10,11 10,11 7,8 7)))", mp);
|
||||
|
||||
// Create the buffered geometry with rounded corners
|
||||
boost::geometry::model::multi_polygon<polygon> result;
|
||||
boost::geometry::buffer(mp, result,
|
||||
distance_strategy, side_strategy,
|
||||
join_strategy, end_strategy, point_strategy);
|
||||
/*<-*/ create_svg_buffer("buffer_join_round.svg", mp, result); /*->*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
@ -20,16 +20,35 @@ namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer for linestrings be asymmetric
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as DistanceStrategy for the buffer algorithm.
|
||||
It can be applied for (multi)linestrings. It uses a (potentially) different
|
||||
distances for left and for right. This means the (multi)linestrings are
|
||||
interpreted having a direction.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_distance_asymmetric]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_distance_asymmetric.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
template<typename CoordinateType>
|
||||
class distance_asymmetric
|
||||
{
|
||||
public :
|
||||
//! Constructs the strategy, two distances must be specified
|
||||
distance_asymmetric(CoordinateType const& left,
|
||||
CoordinateType const& right)
|
||||
: m_left(left)
|
||||
, m_right(right)
|
||||
{}
|
||||
|
||||
//! Returns the distance-value for the specified side
|
||||
template <typename Point>
|
||||
inline CoordinateType apply(Point const& , Point const& ,
|
||||
buffer_side_selector side) const
|
||||
@ -38,16 +57,19 @@ public :
|
||||
return negative() ? math::abs(result) : result;
|
||||
}
|
||||
|
||||
//! Returns 1 (used internally)
|
||||
inline int factor() const
|
||||
{
|
||||
return m_left < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
//! Returns true if both distances are negative
|
||||
inline bool negative() const
|
||||
{
|
||||
return m_left < 0 && m_right < 0;
|
||||
}
|
||||
|
||||
//! Returns the distance at which the input is simplified before the buffer process
|
||||
inline CoordinateType simplify_distance() const
|
||||
{
|
||||
CoordinateType const left = geometry::math::abs(m_left);
|
||||
|
@ -20,14 +20,33 @@ namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer algorithm create buffers with same distances
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as DistanceStrategy for the buffer algorithm.
|
||||
It can be applied for all geometries. It uses one distance for left and
|
||||
for right.
|
||||
The distance can also be negative: it creates a deflated polygon.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_distance_symmetric]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_distance_symmetric.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
template<typename CoordinateType>
|
||||
class distance_symmetric
|
||||
{
|
||||
public :
|
||||
inline distance_symmetric(CoordinateType const& distance)
|
||||
//! Constructs the strategy, a distance must be specified
|
||||
explicit inline distance_symmetric(CoordinateType const& distance)
|
||||
: m_distance(distance)
|
||||
{}
|
||||
|
||||
//! Returns the distance-value
|
||||
template <typename Point>
|
||||
inline CoordinateType apply(Point const& , Point const& ,
|
||||
buffer_side_selector ) const
|
||||
@ -35,16 +54,19 @@ public :
|
||||
return m_distance;
|
||||
}
|
||||
|
||||
//! Returns 1 (used internally)
|
||||
inline int factor() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//! Returns true if distance is negative
|
||||
inline bool negative() const
|
||||
{
|
||||
return m_distance < 0;
|
||||
}
|
||||
|
||||
//! Returns the distance at which the input is simplified before the buffer process
|
||||
inline CoordinateType simplify_distance() const
|
||||
{
|
||||
return geometry::math::abs(m_distance) / 1000.0;
|
||||
|
@ -27,11 +27,29 @@ namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer create flat ends
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as EndStrategy for the buffer algorithm.
|
||||
It creates a flat end for each linestring-end. It can be applied
|
||||
for (multi)linestrings. Also it is applicable for spikes in (multi)polygons.
|
||||
This strategy is only applicable for Cartesian coordinate systems.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_end_flat]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_end_flat.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
class end_flat
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
//! Fills output_range with a flat end
|
||||
template <typename Point, typename RangeOut, typename DistanceStrategy>
|
||||
inline void apply(Point const& penultimate_point,
|
||||
Point const& perp_left_point,
|
||||
@ -70,6 +88,7 @@ public :
|
||||
// In other cases it does no harm but is further useless
|
||||
}
|
||||
|
||||
//! Returns the piece_type (flat end)
|
||||
static inline piece_type get_piece_type()
|
||||
{
|
||||
return buffered_flat_end;
|
||||
|
@ -27,6 +27,23 @@ namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer create rounded ends
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as EndStrategy for the buffer algorithm.
|
||||
It creates a rounded end for each linestring-end. It can be applied
|
||||
for (multi)linestrings. Also it is applicable for spikes in (multi)polygons.
|
||||
This strategy is only applicable for Cartesian coordinate systems.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_end_round]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_end_round.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
class end_round
|
||||
{
|
||||
private :
|
||||
@ -74,10 +91,17 @@ private :
|
||||
}
|
||||
|
||||
public :
|
||||
inline end_round(int steps_per_circle = 100)
|
||||
//! Constructs the strategy with default number of points (100)
|
||||
inline end_round()
|
||||
: m_steps_per_circle(100)
|
||||
{}
|
||||
|
||||
//! Constructs the strategy specifying the nuber of points
|
||||
explicit inline end_round(int steps_per_circle)
|
||||
: m_steps_per_circle(steps_per_circle)
|
||||
{}
|
||||
|
||||
//! Fills output_range with a flat end
|
||||
template <typename Point, typename RangeOut, typename DistanceStrategy>
|
||||
inline void apply(Point const& penultimate_point,
|
||||
Point const& perp_left_point,
|
||||
@ -120,6 +144,7 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns the piece_type (flat end)
|
||||
static inline piece_type get_piece_type()
|
||||
{
|
||||
return buffered_round_end;
|
||||
|
@ -26,13 +26,35 @@ namespace strategy { namespace buffer
|
||||
|
||||
// TODO: condider merging/baseclassing join strategies to avoid duplicate code
|
||||
|
||||
struct join_miter
|
||||
{
|
||||
/*!
|
||||
\brief Let the buffer create sharp corners
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as JoinStrategy for the buffer algorithm.
|
||||
It creates a sharp corners around each convex vertex. It can be applied
|
||||
for (multi)linestrings and (multi)polygons.
|
||||
This strategy is only applicable for Cartesian coordinate systems.
|
||||
|
||||
// Constructor compatible with other join strategies:
|
||||
inline join_miter(int = 0)
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_join_miter]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_join_miter.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
class join_miter
|
||||
{
|
||||
public:
|
||||
//! Constructs the strategy
|
||||
inline join_miter()
|
||||
{}
|
||||
|
||||
//! Constructs the strategy with a (currently dummy) integer
|
||||
explicit inline join_miter(int)
|
||||
{}
|
||||
|
||||
//! Fills output_range with a sharp shape around a vertex
|
||||
template <typename Point, typename DistanceType, typename RangeOut>
|
||||
inline bool apply(Point const& ip, Point const& vertex,
|
||||
Point const& perp1, Point const& perp2,
|
||||
@ -83,7 +105,6 @@ struct join_miter
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
|
||||
|
@ -28,15 +28,40 @@ namespace boost { namespace geometry
|
||||
namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Let the buffer create rounded corners
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as JoinStrategy for the buffer algorithm.
|
||||
It creates a rounded corners around each convex vertex. It can be applied
|
||||
for (multi)linestrings and (multi)polygons.
|
||||
This strategy is only applicable for Cartesian coordinate systems.
|
||||
The specified number of points is for a full circle, which will in practice
|
||||
never be the case
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_join_round]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_join_round.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
}
|
||||
*/
|
||||
class join_round
|
||||
{
|
||||
public :
|
||||
|
||||
inline join_round(int steps_per_circle = 100)
|
||||
//! Constructs the strategy with default number of points (100)
|
||||
inline join_round()
|
||||
: m_steps_per_circle(100)
|
||||
{}
|
||||
|
||||
//! Constructs the strategy specifying the nuber of points
|
||||
explicit inline join_round(int steps_per_circle)
|
||||
: m_steps_per_circle(steps_per_circle)
|
||||
{}
|
||||
|
||||
private :
|
||||
template <typename Point, typename DistanceType, typename RangeOut>
|
||||
inline void generate_points(Point const& vertex,
|
||||
Point const& perp1, Point const& perp2,
|
||||
@ -99,6 +124,9 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
public :
|
||||
|
||||
//! Fills output_range with a rounded shape around a vertex
|
||||
template <typename Point, typename DistanceType, typename RangeOut>
|
||||
inline bool apply(Point const& ip, Point const& vertex,
|
||||
Point const& perp1, Point const& perp2,
|
||||
@ -139,11 +167,8 @@ private :
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user