|
Geometry : |
Subject: [geometry] intersects (one geometry) possible issue
From: joan (joan.abadie_at_[hidden])
Date: 2013-11-06 09:58:46
Hello,
I have a geometry that self intersects when using intersects (one geometry)
by should not.
<http://boost-geometry.203548.n3.nabble.com/file/n4025738/selfintersectissue_boost.png>
This is the polygon that produce the self intersection :
polygon myBoostPolygon;
boost::geometry::read_wkt("POLYGON((137.14632454923444
200.61927877947369,50 224, 323 497,255 169,137.14632454923444
200.61927877947369))", myBoostPolygon);
//check if boundary segments doesn't intersect with the polygon
if (boost::geometry::intersects(myBoostPolygon))
{
cout << "Self intersects !" << endl;
}
Regards
Joan Abadie
Here is the full code to reproduce :
#include <deque>
#include <iostream>
#include <fstream>
#pragma warning(push)
#pragma warning(disable:4100)
#pragma warning(disable:4267)
#pragma warning(disable:4244)
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
#include <boost/geometry/multi/geometries/multi_point.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/foreach.hpp>
#pragma warning(pop)
#include <boost/geometry/io/svg/svg_mapper.hpp>
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type,
boost::geometry::cs::cartesian> point_type;
typedef boost::geometry::model::polygon<point_type> polygon;///
typedef boost::geometry::model::linestring<point_type> linestring;
typedef boost::geometry::model::multi_point<point_type> multipoint;
using namespace std;
template <typename Geometry1, typename Geometry2>
void create_svg(std::string const& filename, Geometry1 const& a, Geometry2
const& b)
{
typedef typename boost::geometry::point_type<Geometry1>::type point_type;
std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
mapper.add(a);
mapper.add(b);
mapper.map(a,
"fill-opacity:0.1;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:1");
mapper.map(b,
"fill-opacity:0.5;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:1");
}
int main()
{
// Declare/fill input
polygon myBoostPolygon;
boost::geometry::read_wkt("POLYGON((137.14632454923444
200.61927877947369,50 224, 323 497,255 169,137.14632454923444
200.61927877947369))", myBoostPolygon);
//check if boundary segments doesn't intersect with the polygon
if (boost::geometry::intersects(myBoostPolygon))
{
cout << "Self intersects !" << endl;
}
//export result to svg
multipoint mp;
for (auto ite = myBoostPolygon.outer().begin(); ite !=
myBoostPolygon.outer().end(); ite++)
boost::geometry::append(mp, *ite);
create_svg("output.svg", myBoostPolygon, mp);
return 0;
}
-- View this message in context: http://boost-geometry.203548.n3.nabble.com/intersects-one-geometry-possible-issue-tp4025738.html Sent from the Boost Geometry mailing list archive at Nabble.com.
Geometry list run by mateusz at loskot.net