diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index b3d675a07..50443bd76 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -15,8 +15,8 @@ ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = YES INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES -STRIP_FROM_PATH = c:/_svn/boost/sandbox/geometry \ - c:/_svn/boost/sandbox/geometry/libs/geometry/doc/doxygen_input/pages +STRIP_FROM_PATH = c:/_svn/boost/trunk/boost/geometry \ + c:/_svn/boost/trunk/libs/geometry/doc/doxygen_input/pages STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO @@ -65,6 +65,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ tparam_out{1}="A valid output iterator type, accepting geometries of \1 Concept" \ tparam_point="Any type fulfilling a Point Concept" \ tparam_point="point type" \ + tparam_range_point="Any type fulfilling a Range Concept where it range_value type fulfills the Point Concept" \ tparam_second_point="second point type" \ tparam_segment_point="segment point type" \ tparam_strategy{1}="Any type fulfilling a \1 Strategy Concept" \ @@ -79,6 +80,10 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ param_macro_coorsystem="Coordinate system (e.g. cs::cartesian)" \ param_macro_member{1}="Member containing \1 coordinate" \ param_macro_getset{2}="Method to \1 the \2 coordinate" \ + param_range_point="A range containg points fulfilling range and point concepts" \ + param_x="First coordinate (usually x-coordinate)" \ + param_y="Second coordinate (usually y-coordinate)" \ + param_z="Third coordinate (usually z-coordinate)" \ constructor_default{1}="Default constructor, creating an empty \1" \ constructor_begin_end{1}="Constructor with begin and end, filling the \1" \ details_calc{2}="The free function \1 calculates the \2 of a geometry" \ @@ -94,6 +99,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ details_make{1}="This version with the make_ prefix returns the \1, and a template parameter must therefore be specified in the call." \ details_inserter{1}="This version with the _inserter suffix outputs the \1 to an output iterator, and a template parameter must therefore be specified in the call." \ details_get_set="The free functions [*get] and [*set] are two of the most important functions of Boost.Geometry, both within the library, as also for the library user. With these two functions you normally get and set coordinate values from and for a point, box, segment or sphere." \ + details_make="Boost.Geometry uses concepts for all its geometries. It does not rely on constructors. The "make" functions are object generators creating geometries. There are overloads, currently with two or three coordinate values or ranges, to construct geometry instances" \ return_calc{1}="The calculated \1" \ return_check{1}="Returns true if the geometry \1" \ return_check2{1}="Returns true if two geometries \1" \ diff --git a/doc/geometry.qbk b/doc/geometry.qbk index d817c6fd4..946d7b8cc 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -71,11 +71,19 @@ Simplify algorithm [link geometry.reference.algorithms.simplify.simplify_3 here] [import src/examples/quick_start.cpp] [import src/examples/algorithms/area.cpp] [import src/examples/algorithms/area_with_strategy.cpp] +[import src/examples/algorithms/assign_2d_point.cpp] +[import src/examples/algorithms/assign_3d_point.cpp] +[import src/examples/algorithms/assign_inverse.cpp] +[import src/examples/algorithms/assign_with_range.cpp] [import src/examples/algorithms/for_each_point.cpp] [import src/examples/algorithms/for_each_point_const.cpp] [import src/examples/algorithms/for_each_segment_const.cpp] [import src/examples/algorithms/length.cpp] [import src/examples/algorithms/length_with_strategy.cpp] +[import src/examples/algorithms/make_2d_point.cpp] +[import src/examples/algorithms/make_3d_point.cpp] +[import src/examples/algorithms/make_inverse.cpp] +[import src/examples/algorithms/make_with_range.cpp] [import src/examples/algorithms/intersection_ls_ls_point.cpp] [import src/examples/algorithms/intersection_segment.cpp] [import src/examples/algorithms/intersects_linestring.cpp] diff --git a/doc/reference/assign.qbk b/doc/reference/assign.qbk index af2fe728e..9a641814e 100644 --- a/doc/reference/assign.qbk +++ b/doc/reference/assign.qbk @@ -13,9 +13,9 @@ [/ Generated by doxygen_xml2qbk, don't change, will be overwritten automatically] [/ Generated from doxy/doxygen_output/xml/group__assign.xml] -[section:assign_2 assign] +[section:assign_2_with_a_range assign (with a range)] -assign a range of points to a linestring, ring or polygon +Assign a range of points to a linestring, ring or polygon. [heading Synopsis] ``template @@ -25,8 +25,8 @@ void assign(Geometry & geometry, Range const & range)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] []] -[[Range const &] [] [range] []] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Range const &] [Any type fulfilling a Range Concept where it range_value type fulfills the Point Concept ] [range] [A range containg points fulfilling range and point concepts]] ] @@ -39,12 +39,18 @@ Or `#include ` +[heading Example] +[assign_with_range] [assign_with_range_output] + +[heading See also] +* [link geometry.reference.algorithms.make.make_1_with_a_range make] + [endsect] -[section:assign_5 assign] +[section:assign_5_4_coordinate_values assign (4 coordinate values)] -assign center + radius to a sphere [for extension] +Assign four values to a geometry (usually a box or segment). [heading Synopsis] ``template @@ -54,11 +60,11 @@ void assign(Geometry & geometry, Type const & c1, Type const & c2, Type const & [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] []] -[[Type const &] [] [c1] []] -[[Type const &] [] [c2] []] -[[Type const &] [] [c3] []] -[[Type const &] [] [c4] []] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c1] [First coordinate (usually x1) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c2] [Second coordinate (usually y1) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c3] [Third coordinate (usually x2) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c4] [Fourth coordinate (usually y2)]] ] @@ -74,9 +80,9 @@ Or [endsect] -[section:assign_4 assign] +[section:assign_4_3_coordinate_values assign (3 coordinate values)] -assign three values to a 3D point [or the center + radius to a circle] +Assign three values to a geometry (usually a 3D point). [heading Synopsis] ``template @@ -86,10 +92,10 @@ void assign(Geometry & geometry, Type const & c1, Type const & c2, Type const & [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] []] -[[Type const &] [] [c1] []] -[[Type const &] [] [c2] []] -[[Type const &] [] [c3] []] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c1] [First coordinate (usually x-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c2] [Second coordinate (usually y-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c3] [Third coordinate (usually z-coordinate)]] ] @@ -102,12 +108,18 @@ Or `#include ` +[heading Example] +[assign_3d_point] [assign_3d_point_output] + +[heading See also] +* [link geometry.reference.algorithms.make.make_3_3_coordinate_values make] + [endsect] -[section:assign_3 assign] +[section:assign_3_2_coordinate_values assign (2 coordinate values)] -assign two values to a 2D point +Assign two coordinates to a geometry (usually a 2D point). [heading Synopsis] ``template @@ -117,9 +129,9 @@ void assign(Geometry & geometry, Type const & c1, Type const & c2)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] []] -[[Type const &] [] [c1] []] -[[Type const &] [] [c2] []] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c1] [First coordinate (usually x-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c2] [Second coordinate (usually y-coordinate)]] ] @@ -132,6 +144,12 @@ Or `#include ` +[heading Example] +[assign_2d_point] [assign_2d_point_output] + +[heading See also] +* [link geometry.reference.algorithms.make.make_2_2_coordinate_values make] + [endsect] @@ -147,7 +165,7 @@ void assign_box_corners(Box const & box, Point & lower_left, Point & lower_right [table [[Type] [Concept] [Name] [Description] ] -[[Box const &] [] [box] []] +[[Box const &] [Any type fulfilling a Box Concept ] [box] []] [[Point &] [] [lower_left] []] [[Point &] [] [lower_right] []] [[Point &] [] [upper_left] []] @@ -172,7 +190,7 @@ Or assign to a box inverse infinite [heading Description] -The assign_inverse function initialize a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small. This is a convenient starting point to collect the minimum bounding box of a geometry. +The assign_inverse function initialize a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small. This is a convenient starting point to collect the minimum bounding box of a geometry. [heading Synopsis] ``template @@ -182,7 +200,7 @@ void assign_inverse(Geometry & geometry)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] []] +[[Geometry &] [Any type fulfilling a Geometry Concept] [geometry] []] ] @@ -195,6 +213,12 @@ Or `#include ` +[heading Example] +[assign_inverse] [assign_inverse_output] + +[heading See also] +* [link geometry.reference.algorithms.make.make_inverse make] + [endsect] @@ -211,7 +235,7 @@ void assign_point_from_index(Geometry const & geometry, Point & point)`` [table [[Type] [Concept] [Name] [Description] ] [[Index] [indicates which box-corner, min_corner (0) or max_corner (1) or which point of segment (0/1) ] [ - ] [Must be specified]] -[[Geometry const &] [] [geometry] []] +[[Geometry const &] [Any type fulfilling a Box Concept or a Segment Concept ] [geometry] []] [[Point &] [] [point] []] ] @@ -242,7 +266,7 @@ void assign_point_to_index(Point const & point, Geometry & geometry)`` [[Type] [Concept] [Name] [Description] ] [[Index] [indicates which box-corner, min_corner (0) or max_corner (1) or which point of segment (0/1) ] [ - ] [Must be specified]] [[Point const &] [] [point] []] -[[Geometry &] [] [geometry] []] +[[Geometry &] [Any type fulfilling a Box Concept or a Segment Concept ] [geometry] []] ] @@ -273,7 +297,7 @@ void assign_zero(Geometry & geometry)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [the geometry type ] [geometry] []] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] []] ] diff --git a/doc/reference/make.qbk b/doc/reference/make.qbk index 24212e261..c4d9d4887 100644 --- a/doc/reference/make.qbk +++ b/doc/reference/make.qbk @@ -13,27 +13,25 @@ [/ Generated by doxygen_xml2qbk, don't change, will be overwritten automatically] [/ Generated from doxy/doxygen_output/xml/group__make.xml] -[section:make_3 make] +[section:make_1_with_a_range make (with a range)] -Make a geometry. +Construct a geometry. [heading Synopsis] -``template -Geometry make(T const & c1, T const & c2, T const & c3)`` +``template +Geometry make(Range const & range)`` [heading Parameters] [table [[Type] [Concept] [Name] [Description] ] -[[Geometry] [] [ - ] [Must be specified]] -[[T const &] [] [c1] []] -[[T const &] [] [c2] []] -[[T const &] [] [c3] []] +[[Geometry] [Any type fulfilling a Geometry Concept ] [ - ] [Must be specified]] +[[Range const &] [Any type fulfilling a Range Concept where it range_value type fulfills the Point Concept ] [range] [A range containg points fulfilling range and point concepts ]] ] [heading Returns] -a 3D point +The constructed geometry, here: a linestring or a linear ring [heading Header] Either @@ -44,33 +42,36 @@ Or `#include ` +[heading Example] +[make_with_range] [make_with_range_output] + +[heading See also] +* [link geometry.reference.algorithms.assign.assign_2_with_a_range assign] + [endsect] -[section:make_2 make] +[section:make_3_3_coordinate_values make (3 coordinate values)] -Make a geometry. - -[heading Description] -the Generic Geometry Library uses concepts for all its geometries. Therefore it does not rely on constructors. The "make" functions are object generators creating geometries. There are overloads with two, three, four or six values, which are implemented depending on the geometry specified. +Construct a geometry. [heading Synopsis] -``template -Geometry make(T const & c1, T const & c2)`` +``template +Geometry make(Type const & c1, Type const & c2, Type const & c3)`` [heading Parameters] [table [[Type] [Concept] [Name] [Description] ] -[[Geometry] [] [ - ] [Must be specified]] -[[G] [the geometry type ] [ - ] [Must be specified]] -[[T const &] [the coordinate type ] [c1] []] -[[T const &] [the coordinate type ] [c2] []] +[[Geometry] [Any type fulfilling a Geometry Concept ] [ - ] [Must be specified]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c1] [First coordinate (usually x-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c2] [Second coordinate (usually y-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c3] [Third coordinate (usually z-coordinate) ]] ] [heading Returns] -the geometry +The constructed geometry, here: a 3D point [heading Header] Either @@ -81,15 +82,60 @@ Or `#include ` +[heading Example] +[make_3d_point] [make_3d_point_output] + +[heading See also] +* [link geometry.reference.algorithms.assign.assign_4_3_coordinate_values assign] + + +[endsect] + +[section:make_2_2_coordinate_values make (2 coordinate values)] + +Construct a geometry. + +[heading Synopsis] +``template +Geometry make(Type const & c1, Type const & c2)`` + +[heading Parameters] + +[table +[[Type] [Concept] [Name] [Description] ] +[[Geometry] [Any type fulfilling a Geometry Concept ] [ - ] [Must be specified]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c1] [First coordinate (usually x-coordinate) ]] +[[Type const &] [numerical type (int, double, ttmath, ...) to specify the coordinates ] [c2] [Second coordinate (usually y-coordinate) ]] +] + + +[heading Returns] +The constructed geometry, here: a 2D point + +[heading Header] +Either + +`#include ` + +Or + +`#include ` + +[heading Example] +[make_2d_point] [make_2d_point_output] + +[heading See also] +* [link geometry.reference.algorithms.assign.assign_3_2_coordinate_values assign] + [endsect] [section:make_inverse make_inverse] -Create a box with inverse infinite coordinates. +Construct a box with inverse infinite coordinates. [heading Description] -The make_inverse function initialize a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small +The make_inverse function initializes a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small. This is useful e.g. in combination with the combine function, to determine the bounding box of a series of geometries. [heading Synopsis] ``template @@ -99,12 +145,12 @@ Geometry make_inverse`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry] [the geometry type ] [ - ] [Must be specified]] +[[Geometry] [Any type fulfilling a Geometry Concept ] [ - ] [Must be specified]] ] [heading Returns] -the box +The constructed geometry, here: a box [heading Header] Either @@ -115,12 +161,18 @@ Or `#include ` +[heading Example] +[make_inverse] [make_inverse_output] + +[heading See also] +* [link geometry.reference.algorithms.assign.assign_inverse assign] + [endsect] [section:make_zero make_zero] -Create a geometry with "zero" coordinates. +Construct a geometry with its coordinates initialized to zero. [heading Description] The make_zero function initializes a 2D or 3D point or box with coordinates of zero @@ -133,12 +185,12 @@ Geometry make_zero`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry] [the geometry type ] [ - ] [Must be specified]] +[[Geometry] [Any type fulfilling a Geometry Concept ] [ - ] [Must be specified]] ] [heading Returns] -the geometry +The constructed and zero-initialized geometry [heading Header] Either diff --git a/doc/src/examples/algorithms/Jamfile.v2 b/doc/src/examples/algorithms/Jamfile.v2 index 1f933eba2..6449ea6eb 100644 --- a/doc/src/examples/algorithms/Jamfile.v2 +++ b/doc/src/examples/algorithms/Jamfile.v2 @@ -14,6 +14,11 @@ project boost-geometry-doc-example-algorithms exe area : area.cpp ; exe area_with_strategy : area_with_strategy.cpp ; +exe assign_2d_point : assign_2d_point.cpp ; +exe assign_3d_point : assign_3d_point.cpp ; +exe assign_inverse : assign_inverse.cpp ; +exe assign_with_range : assign_with_range.cpp ; + exe for_each_point : for_each_point.cpp ; exe for_each_point_const : for_each_point_const.cpp ; exe for_each_segment_const : for_each_segment_const.cpp ; @@ -23,6 +28,11 @@ exe intersection_segment : intersection_segment.cpp ; exe intersects_linestring : intersects_linestring.cpp ; +exe make_2d_point : make_2d_point.cpp ; +exe make_3d_point : make_3d_point.cpp ; +exe make_inverse : make_inverse.cpp ; +exe make_with_range : make_with_range.cpp ; + exe num_geometries : num_geometries.cpp ; exe num_interior_rings : num_interior_rings.cpp ; exe num_points : num_points.cpp ; diff --git a/doc/src/examples/algorithms/assign_2d_point.cpp b/doc/src/examples/algorithms/assign_2d_point.cpp new file mode 100644 index 000000000..1d73e469c --- /dev/null +++ b/doc/src/examples/algorithms/assign_2d_point.cpp @@ -0,0 +1,54 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[assign_2d_point +//` Shows the usage of assign to set point coordinates, and, besides that, shows how you can initialize ttmath points with high precision + +#include +#include + +#include +#include +#include + + +int main() +{ + using boost::geometry::assign; + + + boost::geometry::model::d2::point_xy p1; + assign(p1, 1.2345, 2.3456); + + boost::geometry::model::d2::point_xy > p2; + assign(p2, "1.2345", "2.3456"); /*< It is possible to assign coordinates with other types than the coordinate type. + For ttmath, you can e.g. conveniently use strings. The advantage is that it then has higher precision, because + if doubles are used for assignments the double-precision is used. + >*/ + + std::cout + << std::setprecision(20) + << boost::geometry::dsv(p1) << std::endl + << boost::geometry::dsv(p2) << std::endl; + + return 0; +} + +//] + + +//[assign_2d_point_output +/*` +Output: +[pre +(1.2344999999999999, 2.3456000000000001) +(1.2345, 2.3456) +] +*/ +//] diff --git a/doc/src/examples/algorithms/assign_3d_point.cpp b/doc/src/examples/algorithms/assign_3d_point.cpp new file mode 100644 index 000000000..3f117b32a --- /dev/null +++ b/doc/src/examples/algorithms/assign_3d_point.cpp @@ -0,0 +1,39 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[assign_3d_point +//` Use assign to set three coordinates of a 3D point + +#include +#include + +#include +#include + +int main() +{ + boost::geometry::model::point p; + boost::geometry::assign(p, 1.2345, 2.3456, 3.4567); + + std::cout << boost::geometry::dsv(p) << std::endl; + + return 0; +} + +//] + + +//[assign_3d_point_output +/*` +Output: +[pre +(1.2345, 2.3456, 3.4567) +] +*/ +//] diff --git a/doc/src/examples/algorithms/assign_inverse.cpp b/doc/src/examples/algorithms/assign_inverse.cpp new file mode 100644 index 000000000..3dd128fe3 --- /dev/null +++ b/doc/src/examples/algorithms/assign_inverse.cpp @@ -0,0 +1,45 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[assign_inverse +//` Usage of assign_inverse and combine to conveniently determine bounding 3D box of two points + +#include + +#include +#include + +using namespace boost::geometry; + +int main() +{ + typedef model::point point; + typedef model::box box; + + box all; + assign_inverse(all); + std::cout << dsv(all) << std::endl; + combine(all, point(0, 0, 0)); + combine(all, point(1, 2, 3)); + std::cout << dsv(all) << std::endl; + + return 0; +} + +//] + + +//[assign_inverse_output +/*` +Output: +[pre +((3.40282e+038, 3.40282e+038, 3.40282e+038), (-3.40282e+038, -3.40282e+038, -3.40282e+038)) +((0, 0, 0), (1, 2, 3))] +*/ +//] diff --git a/doc/src/examples/algorithms/assign_with_range.cpp b/doc/src/examples/algorithms/assign_with_range.cpp new file mode 100644 index 000000000..ee6338f17 --- /dev/null +++ b/doc/src/examples/algorithms/assign_with_range.cpp @@ -0,0 +1,71 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[assign_with_range +//` Shows usage of Boost.Geometry's assign, Boost.Assign, and Boost.Range to assign ranges of a linestring + +#include + +#include +#include +#include + +#include +#include + +template +struct x_between +{ + x_between(T a, T b) + : fa(a), fb(b) + {} + + template + bool operator()(P const& p) const + { + return boost::geometry::get<0>(p) >= fa + && boost::geometry::get<0>(p) <= fb; + } +private : + T fa, fb; +}; + + +int main() +{ + using namespace boost::assign; + + typedef boost::geometry::model::linestring > ls; + + ls line1, line2, line3; + + line1 = tuple_list_of(0, 0)(2, 3)(4, 0)(6, 3)(8, 0)(10, 3)(12, 0); /*< tuple_list_of is part of Boost.Assign and can be used for Boost.Geometry if points are tuples >*/ + boost::geometry::assign(line2, tuple_list_of(0, 0)(2, 2)(4, 0)(6, 2)(8, 0)); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::assign >*/ + boost::geometry::assign(line3, line1 | boost::adaptors::filtered(x_between(4, 8))); /*< Boost.Range adaptors can also be used in boost::geometry::assign >*/ + + std::cout << "line 1: " << boost::geometry::dsv(line1) << std::endl; + std::cout << "line 2: " << boost::geometry::dsv(line2) << std::endl; + std::cout << "line 3: " << boost::geometry::dsv(line3) << std::endl; + + return 0; +} + +//] + + +//[assign_with_range_output +/*` +Output: +[pre +line 1: ((0, 0), (2, 3), (4, 0), (6, 3), (8, 0), (10, 3), (12, 0)) +line 2: ((0, 0), (2, 2), (4, 0), (6, 2), (8, 0)) +line 3: ((4, 0), (6, 3), (8, 0)) +] +*/ +//] diff --git a/doc/src/examples/algorithms/intersects_segment.cpp b/doc/src/examples/algorithms/intersects_segment.cpp new file mode 100644 index 000000000..c8e09045c --- /dev/null +++ b/doc/src/examples/algorithms/intersects_segment.cpp @@ -0,0 +1,44 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[intersects +//` Check if two linestrings intersect each other + +#include + +#include +#include + +int main() +{ + // Calculate the intersects of a cartesian polygon + typedef boost::geometry::model::d2::point_xy P; + bg::model::linestring

line1, line2; + + boost::geometry::read_wkt("linestring(1 1,2 2)", line1); + boost::geometry::read_wkt("linestring(2 1,1 2)", line2); + + bool b = boost::geometry::intersects(line1, line2); + + std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl; + + return 0; +} + +//] + + +//[intersects_output +/*` +Output: +[pre +Intersects: YES +] +*/ +//] diff --git a/doc/src/examples/algorithms/make_2d_point.cpp b/doc/src/examples/algorithms/make_2d_point.cpp new file mode 100644 index 000000000..14798d564 --- /dev/null +++ b/doc/src/examples/algorithms/make_2d_point.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[make_2d_point +//` Shows the usage of make as a generic constructor for different point types + +#include + +#include +#include +#include +#include +#include + +struct mypoint { float _x, _y; }; + +BOOST_GEOMETRY_REGISTER_POINT_2D(mypoint, float, cs::cartesian, _x, _y) + +template +void construct_and_display() +{ + using boost::geometry::make; + using boost::geometry::get; + + Point p = make(1, 2); + + std::cout << "x=" << get<0>(p) << " y=" << get<1>(p) + << " (" << typeid(Point).name() << ")" + << std::endl; +} + +int main() +{ + construct_and_display >(); + construct_and_display >(); + construct_and_display >(); + construct_and_display >(); + construct_and_display(); + return 0; +} + +//] + +//[make_2d_point_output +/*` +Output (compiled using gcc): +[pre +x=1 y=2 (N5boost8geometry5model2d28point_xyIdNS0_2cs9cartesianEEE) +x=1 y=2 (N5boost8geometry5model2d28point_xyIiNS0_2cs9cartesianEEE) +x=1 y=2 (N5boost6tuples5tupleIddNS0_9null_typeES2_S2_S2_S2_S2_S2_S2_EE) +x=1 y=2 (N5boost7polygon10point_dataIiEE) +x=1 y=2 (7mypoint) +] +*/ +//] diff --git a/doc/src/examples/algorithms/make_3d_point.cpp b/doc/src/examples/algorithms/make_3d_point.cpp new file mode 100644 index 000000000..983a6ecbb --- /dev/null +++ b/doc/src/examples/algorithms/make_3d_point.cpp @@ -0,0 +1,36 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[make_3d_point +//` Using make to construct a three dimensional point + +#include + +#include +#include + +int main() +{ + typedef boost::geometry::model::point point_type; + point_type p = boost::geometry::make(1, 2, 3); + std::cout << boost::geometry::dsv(p) << std::endl; + return 0; +} + +//] + + +//[make_3d_point_output +/*` +Output: +[pre +(1, 2, 3) +] +*/ +//] diff --git a/doc/src/examples/algorithms/make_inverse.cpp b/doc/src/examples/algorithms/make_inverse.cpp new file mode 100644 index 000000000..81373f169 --- /dev/null +++ b/doc/src/examples/algorithms/make_inverse.cpp @@ -0,0 +1,46 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[make_inverse +//` Usage of make_inverse and combine to conveniently determine bounding box of several objects + +#include + +#include +#include + +using namespace boost::geometry; + +int main() +{ + + typedef model::d2::point_xy point; + typedef model::box box; + + box all = make_inverse(); + std::cout << dsv(all) << std::endl; + combine(all, make(0, 0, 3, 4)); + combine(all, make(2, 2, 5, 6)); + std::cout << dsv(all) << std::endl; + + return 0; +} + +//] + + +//[make_inverse_output +/*` +Output: +[pre +((1.79769e+308, 1.79769e+308), (-1.79769e+308, -1.79769e+308)) +((0, 0), (5, 6)) +] +*/ +//] diff --git a/doc/src/examples/algorithms/make_with_range.cpp b/doc/src/examples/algorithms/make_with_range.cpp new file mode 100644 index 000000000..3efb664bd --- /dev/null +++ b/doc/src/examples/algorithms/make_with_range.cpp @@ -0,0 +1,48 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[make_with_range +//` Using make to construct a linestring with two different range types + +#include + +#include +#include +#include /*< Necessary to register a C array like {1,2} as a point >*/ + + +int main() +{ + using boost::geometry::make; + + typedef boost::geometry::model::d2::point_xy point; + typedef boost::geometry::model::linestring linestring; + + double coordinates[][2] = {{1,2}, {3,4}, {5, 6}}; /*< Initialize with C array points >*/ + linestring ls = make(coordinates); + std::cout << boost::geometry::dsv(ls) << std::endl; + + point points[3] = { make(9,8), make(7,6), make(5,4) }; /*< Construct array with points, using make which should work for any point type >*/ + std::cout << boost::geometry::dsv(make(points)) << std::endl; /*< Construct linestring with point-array and output it as Delimiter Separated Values >*/ + + return 0; +} + +//] + + +//[make_with_range_output +/*` +Output: +[pre +((1, 2), (3, 4), (5, 6)) +((9, 8), (7, 6), (5, 4)) +] +*/ +//] diff --git a/doc/src/examples/algorithms/simplify_inserter_with_strategy.cpp b/doc/src/examples/algorithms/simplify_inserter_with_strategy.cpp new file mode 100644 index 000000000..97e44aa88 --- /dev/null +++ b/doc/src/examples/algorithms/simplify_inserter_with_strategy.cpp @@ -0,0 +1,72 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, 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) +// +// Quickbook Example + +//[simplify_inserter +//` Simplify a linestring using an output iterator + +#include +#include +#include +#include + + + +int main() +{ + typedef boost::geometry::model::d2::point_xy P; + typedef boost::geometry::model::linestring

L; + + L line; + boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line); + + typedef boost::geometry::strategy::distance::projected_point DS; + typedef boost::geometry::strategy::simplify::douglas_peucker simplification; + + L simplified; + boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5, simplification()); //std::ostream_iterator

(std::cout, "\n"), 0.5);//); + //std::cout << simplified[0]; + //boost::geometry::simplify_inserter(line, std::ostream_iterator

(std::cout, "\n"), 0.5);//, simplification()); + + std::ostream_iterator

out(std::cout, "\n"); + std::copy(simplified.begin(), simplified.end(), out); + + std::cout + << " original: " << boost::geometry::dsv(line) << std::endl + << "simplified: " << boost::geometry::dsv(simplified) << std::endl; + + return 0; +} + +//] + + +//[simplify_inserter_output +/*` +Output: +[pre +simplify_inserter: 16 +simplify_inserter: 0.339837 +] +*/ +//] +/* +OUTPUT +POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +*/ +/* +OUTPUT +POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +*/ +/* +OUTPUT +POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +*/