mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 15:14:02 +00:00
feat: add remaining examples to cmake
This commit is contained in:
parent
38adce676e
commit
310498b4b4
@ -1,22 +0,0 @@
|
||||
[/============================================================================
|
||||
Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
Copyright (c) 2011-2012 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)
|
||||
=============================================================================/]
|
||||
|
||||
[include reference/algorithms/difference_behavior.qbk]
|
||||
|
||||
[include reference/algorithms/geometry_rules.qbk]
|
||||
|
||||
[heading Example]
|
||||
[difference_inserter] [difference_inserter_output]
|
||||
|
||||
[heading See also]
|
||||
* [link geometry.reference.algorithms.sym_difference.sym_difference_inserter_3 sym_difference_inserter (symmetric difference)]
|
||||
* [link geometry.reference.algorithms.intersection.intersection_inserter_3 intersection_inserter]
|
||||
* [link geometry.reference.algorithms.union.union_inserter_3 union_inserter]
|
||||
|
@ -33,6 +33,7 @@ foreach(item IN ITEMS
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(algorithms)
|
||||
add_subdirectory(arithmetic)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(geometries)
|
||||
add_subdirectory(io)
|
||||
|
@ -65,9 +65,28 @@ foreach(item IN ITEMS
|
||||
union
|
||||
unique
|
||||
within
|
||||
|
||||
# Entries not present in Jamfile
|
||||
# Some of them are used in the documentation, but not all of them.
|
||||
assign_box_corners # uses detail, not used in documentation
|
||||
assign_point_from_index # uses detail, not used in documentation
|
||||
assign_point_to_index # uses detail, not used in documentation
|
||||
azimuth
|
||||
azimuth_strategy
|
||||
covered_by
|
||||
crosses
|
||||
disjoint
|
||||
intersection_poly_poly
|
||||
intersects_segment
|
||||
is_empty
|
||||
make_with_range # uses detail, not used in documentation
|
||||
overlaps
|
||||
perimeter
|
||||
simplify_insert # uses detail, not used in documentation
|
||||
touches_one_geometry
|
||||
touches_two_geometries
|
||||
)
|
||||
|
||||
boost_geometry_add_example("algorithms" ${item})
|
||||
|
||||
endforeach()
|
||||
|
||||
|
@ -28,7 +28,7 @@ int main()
|
||||
polygon poly;
|
||||
|
||||
// Append a range
|
||||
append(poly, vector{{0.0, 0.0}, {0.0, 10.0}, {11.0, 11.0}, {10.0, 0.0}}); /*< vector models a range and can therefore be used in boost::geometry::append >*/
|
||||
append(poly, vector{{0, 0}, {0, 10}, {11, 11}, {10, 0}}); /*< vector models a range and can therefore be used in boost::geometry::append >*/
|
||||
// Append a point (in this case the closing point)
|
||||
append(poly, boost::make_tuple(0, 0));
|
||||
|
||||
|
@ -27,7 +27,7 @@ int main()
|
||||
assign_values(b, 2, 2, 5, 5);
|
||||
|
||||
point ll, lr, ul, ur;
|
||||
assign_box_corners(b, ll, lr, ul, ur);
|
||||
detail::assign_box_corners(b, ll, lr, ul, ur);
|
||||
|
||||
std::cout << "box: " << dsv(b) << std::endl << std::endl;
|
||||
|
||||
|
@ -27,8 +27,8 @@ int main()
|
||||
assign_values(s, 1, 1, 2, 2);
|
||||
|
||||
point first, second;
|
||||
assign_point_from_index<0>(s, first);
|
||||
assign_point_from_index<1>(s, second);
|
||||
detail::assign_point_from_index<0>(s, first);
|
||||
detail::assign_point_from_index<1>(s, second);
|
||||
std::cout
|
||||
<< "segment: " << dsv(s) << std::endl
|
||||
<< "first: " << dsv(first) << std::endl
|
||||
|
@ -26,8 +26,8 @@ int main()
|
||||
point lower_left(0, 0), upper_right(2, 2);
|
||||
|
||||
box b;
|
||||
assign_point_to_index<0>(lower_left, b);
|
||||
assign_point_to_index<1>(upper_right, b);
|
||||
detail::assign_point_to_index<0>(lower_left, b);
|
||||
detail::assign_point_to_index<1>(upper_right, b);
|
||||
std::cout << "box: " << dsv(b) << std::endl;
|
||||
|
||||
return 0;
|
||||
|
@ -1,86 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011-2024 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)
|
||||
|
||||
//[difference_inserter
|
||||
//` Shows how the difference_inserter function can be used
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
|
||||
/*<-*/ #include "create_svg_overlay.hpp" /*->*/
|
||||
|
||||
int main()
|
||||
{
|
||||
using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>;
|
||||
|
||||
polygon green, blue;
|
||||
|
||||
boost::geometry::read_wkt(
|
||||
"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
|
||||
"(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green);
|
||||
|
||||
boost::geometry::read_wkt(
|
||||
"POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);
|
||||
|
||||
std::vector<polygon> output;
|
||||
|
||||
// Note that this sample simulates the symmetric difference,
|
||||
// which is also available as a separate algorithm.
|
||||
// It chains the output iterator returned by the function to the second instance.
|
||||
boost::geometry::difference_inserter<polygon>
|
||||
(
|
||||
green, blue,
|
||||
boost::geometry::difference_inserter<polygon>
|
||||
(
|
||||
blue, green,
|
||||
std::back_inserter(output)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
int i = 0;
|
||||
std::cout << "(blue \ green) u (green \ blue):" << std::endl;
|
||||
for (polygon const& p : output)
|
||||
{
|
||||
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
|
||||
}
|
||||
|
||||
/*<-*/ create_svg("difference_inserter.svg", green, blue, output); /*->*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[difference_inserter_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
(blue \\ green) u (green \\ blue):
|
||||
0: 0.525154
|
||||
1: 0.015
|
||||
2: 0.181136
|
||||
3: 0.128798
|
||||
4: 0.340083
|
||||
5: 0.307778
|
||||
6: 0.02375
|
||||
7: 0.542951
|
||||
8: 0.0149697
|
||||
9: 0.226855
|
||||
10: 0.839424
|
||||
|
||||
[$img/algorithms/sym_difference.png]
|
||||
|
||||
]
|
||||
*/
|
||||
//]
|
@ -33,7 +33,7 @@ int main()
|
||||
boost::geometry::for_each_segment(polyline,
|
||||
[&](auto const& s)
|
||||
{
|
||||
const auto length = boost::geometry::length(s);
|
||||
const auto length = static_cast<double>(boost::geometry::length(s));
|
||||
min_length = std::min(min_length, length);
|
||||
max_length = std::max(max_length, length);
|
||||
});
|
||||
|
@ -20,14 +20,14 @@ int main()
|
||||
{
|
||||
// Calculate the intersects of a cartesian polygon
|
||||
using P = boost::geometry::model::d2::point_xy<double>;
|
||||
bg::model::linestring<P> line1, line2;
|
||||
boost::geometry::model::linestring<P> 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);
|
||||
bool intersects = boost::geometry::intersects(line1, line2);
|
||||
|
||||
std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl;
|
||||
std::cout << "Intersects: " << (intersects ? "YES" : "NO") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::geometry::model::multi_linestring
|
||||
|
@ -18,18 +18,12 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
using P = boost::geometry::model::d2::point_xy<double>;
|
||||
using L = boost::geometry::model::linestring<P>;
|
||||
|
||||
L line;
|
||||
line.push_back(P(1.1, 1.1));
|
||||
line.push_back(P(2.5, 2.1));
|
||||
line.push_back(P(3.1, 3.1));
|
||||
line.push_back(P(4.9, 1.1));
|
||||
line.push_back(P(3.1, 1.9));
|
||||
using L = boost::geometry::model::linestring<boost::geometry::model::d2::point_xy<double>>;
|
||||
|
||||
L const line{{1.1, 1.1}, {2.5, 2.1}, {3.1, 3.1}, {4.9, 1.1}, {3.1, 1.9}};
|
||||
L simplified;
|
||||
boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5);
|
||||
|
||||
boost::geometry::detail::simplify::simplify_insert(line, std::back_inserter(simplified), 0.5);
|
||||
|
||||
std::cout
|
||||
<< " original: " << boost::geometry::dsv(line) << std::endl
|
||||
|
@ -1,71 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011-2024 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)
|
||||
|
||||
//[simplify_inserter
|
||||
//` Simplify a linestring using an output iterator
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using P = boost::geometry::model::d2::point_xy<double>;
|
||||
using L = boost::geometry::model::linestring<P>;
|
||||
|
||||
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);
|
||||
|
||||
using DS = boost::geometry::strategy::distance::projected_point<P, P>;
|
||||
using simplification = boost::geometry::strategy::simplify::douglas_peucker<P, DS>;
|
||||
|
||||
L simplified;
|
||||
boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5, simplification()); //std::ostream_iterator<P>(std::cout, "\n"), 0.5);//);
|
||||
//std::cout << simplified[0];
|
||||
//boost::geometry::simplify_inserter(line, std::ostream_iterator<P>(std::cout, "\n"), 0.5);//, simplification());
|
||||
|
||||
std::ostream_iterator<P> 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))
|
||||
*/
|
15
doc/src/examples/arithmetic/CMakeLists.txt
Normal file
15
doc/src/examples/arithmetic/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
foreach(item IN ITEMS
|
||||
cross_product
|
||||
dot_product
|
||||
)
|
||||
|
||||
boost_geometry_add_example("arithmetic" ${item})
|
||||
|
||||
endforeach()
|
||||
|
@ -22,3 +22,5 @@ foreach(item IN ITEMS
|
||||
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(adapted)
|
||||
add_subdirectory(register)
|
||||
|
20
doc/src/examples/geometries/adapted/CMakeLists.txt
Normal file
20
doc/src/examples/geometries/adapted/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
foreach(item IN ITEMS
|
||||
boost_array
|
||||
boost_fusion
|
||||
boost_tuple
|
||||
c_array
|
||||
std_array
|
||||
)
|
||||
|
||||
boost_geometry_add_example("geometries_adapted" ${item})
|
||||
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(boost_range)
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
foreach(item IN ITEMS
|
||||
filtered
|
||||
reversed
|
||||
sliced
|
||||
strided
|
||||
# uniqued Fails to compile, also commented in Jamfile
|
||||
)
|
||||
|
||||
boost_geometry_add_example("geometries_adapted_range" ${item})
|
||||
|
||||
endforeach()
|
||||
|
@ -19,15 +19,8 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
using xy = boost::geometry::model::d2::point_xy<int>;
|
||||
boost::geometry::model::linestring<xy> line;
|
||||
line += xy(0, 0);
|
||||
line += xy(1, 1);
|
||||
line += xy(2, 2);
|
||||
line += xy(3, 3);
|
||||
line += xy(4, 4);
|
||||
boost::geometry::model::linestring<xy> line = {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}};
|
||||
|
||||
std::cout
|
||||
<< boost::geometry::dsv(line | boost::adaptors::sliced(1, 3)) << std::endl;
|
||||
|
@ -19,17 +19,10 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using boost::adaptors::strided;
|
||||
|
||||
using xy = boost::geometry::model::d2::point_xy<int>;
|
||||
boost::geometry::model::ring<xy> ring;
|
||||
ring += xy(0, 0);
|
||||
ring += xy(0, 1);
|
||||
ring += xy(0, 2);
|
||||
ring += xy(1, 2);
|
||||
ring += xy(2, 2);
|
||||
ring += xy(2, 0);
|
||||
boost::geometry::model::ring<xy> ring {{0, 0}, {0, 1}, {0, 2}, {1, 2}, {2, 2}, {2, 0}};
|
||||
|
||||
boost::geometry::correct(ring);
|
||||
|
||||
|
@ -25,22 +25,11 @@ inline bool operator==(xy const& left, xy const& right)
|
||||
return eq(left, right);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using boost::adaptors::uniqued;
|
||||
|
||||
boost::geometry::model::ring<xy> ring;
|
||||
ring += xy(0, 0);
|
||||
ring += xy(0, 1);
|
||||
ring += xy(0, 2);
|
||||
ring += xy(1, 2);
|
||||
ring += xy(2, 2);
|
||||
ring += xy(2, 2);
|
||||
ring += xy(2, 2);
|
||||
ring += xy(2, 0);
|
||||
ring += xy(0, 0);
|
||||
const boost::geometry::model::ring<xy> ring = {{0, 0}, {0, 1}, {0, 2}, {1, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 0}, {0, 0}};
|
||||
|
||||
std::cout
|
||||
<< "Normal: " << boost::geometry::dsv(ring) << std::endl
|
||||
|
24
doc/src/examples/geometries/register/CMakeLists.txt
Normal file
24
doc/src/examples/geometries/register/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
foreach(item IN ITEMS
|
||||
box
|
||||
box_templated
|
||||
box_2d_4values
|
||||
point
|
||||
linestring
|
||||
linestring_templated
|
||||
ring
|
||||
ring_templated
|
||||
multi_point
|
||||
multi_point_templated
|
||||
multi_linestring
|
||||
multi_polygon
|
||||
)
|
||||
|
||||
boost_geometry_add_example("geometries_register" ${item})
|
||||
|
||||
endforeach()
|
Loading…
x
Reference in New Issue
Block a user