Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added touches documentation
  • Loading branch information
digu-007 committed Feb 10, 2020
commit 47789f4e3a4ca74e024e44c9591a60f28d86395d
56 changes: 56 additions & 0 deletions doc/src/examples/algorithms/touches_one_geometry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example

// Copyright (c) 2020-2021 Digvijay Janartha, Hamirpur, India.

// 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)

//[touches
//` Checks if a geometry has at least one touching point (self-tangency)

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>

namespace bg = boost::geometry; /*< Convenient namespace alias >*/

int main()
{
// Checks if the geometry has self-tangency.
bg::model::polygon<bg::model::d2::point_xy<double> > poly1;
bg::read_wkt("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", poly1);
bool check_touches = bg::touches(poly1);
if (check_touches) {
std::cout << "Touches: Yes" << std::endl;
} else {
std::cout << "Touches: No" << std::endl;
}

bg::model::polygon<bg::model::d2::point_xy<double> > poly2;
bg::read_wkt("POLYGON((0 0,0 4,4 4,4 0,2 3,0 0))", poly2);
check_touches = bg::touches(poly2);
if (check_touches) {
std::cout << "Touches: Yes" << std::endl;
} else {
std::cout << "Touches: No" << std::endl;
}

return 0;
}

//]


//[touches_output
/*`
Output:
[pre
Touches: Yes
Touches: No
]
*/
//]
58 changes: 58 additions & 0 deletions doc/src/examples/algorithms/touches_two_geometries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example

// Copyright (c) 2020-2021 Digvijay Janartha, Hamirpur, India.

// 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)

//[touches
//` Checks if two geometries have at least one touching point (tangent - non overlapping)

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>

namespace bg = boost::geometry; /*< Convenient namespace alias >*/

int main()
{
// Checks if the two geometries overlaps or not.
bg::model::polygon<bg::model::d2::point_xy<double> > poly1;
bg::read_wkt("POLYGON((0 0,0 4,4 4,4 0,0 0))", poly1);
bg::model::polygon<bg::model::d2::point_xy<double> > poly2;
bg::read_wkt("POLYGON((0 0,0 -4,-4 -4,-4 0,0 0))", poly2);
bool check_touches = bg::touches(poly1, poly2);
if (check_touches) {
std::cout << "Touches: Yes" << std::endl;
} else {
std::cout << "Touches: No" << std::endl;
}

bg::model::polygon<bg::model::d2::point_xy<double> > poly3;
bg::read_wkt("POLYGON((1 1,0 -4,-4 -4,-4 0,1 1))", poly3);
check_touches = bg::touches(poly1, poly3);
if (check_touches) {
std::cout << "Touches: Yes" << std::endl;
} else {
std::cout << "Touches: No" << std::endl;
}

return 0;
}

//]


//[touches_output
/*`
Output:
[pre
Touches: Yes
Touches: No
]
*/
//]