Intersection acceleration does not work

I have a big problem with the intersection of the intersection. I would like to cross a triangle with a quad, but I get a clip:

i46.tinypic.com/2nvuo01.png

Can someone help me?

I tried to change the orientation of the geometry, nothing happened. intersection work with other triangles, but not with this.

typedef model::polygon<model::d2::point_xy<double> > polygon std::deque<polygon> tmp; bool ok = intersection(quad, triangle, tmp) 

Triangle:

 -213.57 -2.13163e-14 0 -350 37.5 0 -350 -2.84217e-14 0 

Box:

 BoundingBox(-300, -165, 2, 170, -0.1, 0.1) 

UPDATE:

Here is my code. I am using gcc 4.7.2 with boost 1.53.0 on Ubuntu 12.10

 #include <deque> #include <fstream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/io/wkt/wkt.hpp> #include <boost/geometry/extensions/io/svg/svg_mapper.hpp> using namespace boost::geometry; int main() { typedef model::polygon<model::d2::point_xy<double> > polygon; typedef typename model::d2::point_xy<double> point_type; polygon quad, triangle; read_wkt("POLYGON((-213.57 -2.131 , -350.0 37.5 , -350.0 -2.842 , -213.57 -2.131))", triangle); read_wkt("POLYGON((-300.0 2 , -300 170 , -165 170 , -165 2 , -300 2))", quad); std::deque<polygon> output; intersection(quad, triangle, output); std::string filename = "intersectiontest.svg"; std::ofstream svg(filename.c_str()); svg_mapper<point_type> mapper(svg, 600, 600); mapper.add(output[0]); mapper.map(output[0], "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(255,0,0);stroke-width:5"); } 
+6
source share
1 answer

My best guess is that this involves specifying the points in counterclockwise order, when by default the polygon expects the points to be clockwise. Therefore, you will need to change it as follows:

 read_wkt("POLYGON((-213.57 -2.131 , -350.0 -2.842 , -350.0 37.5 , -213.57 -2.131))", triangle); 

You can read more about this problem here.

+7
source

All Articles