I'm a PhD student in civil engineering and I recently started doing some coding in C++, basically I'm interested in getting the overlapping or intersection area of two polygons, which represent the projection of two soil particles.
I did a lot of search and I found that boost geometry is the best solution for me. I also did a lot of search for the specific problem I'm facing but I wasn't able to resolve my issue.
Here is the problem, the software I'm using is called PFC3D (particle flow code). I have to use microsoft visual studio 2010 to interact with this software and compile DLL files to run it in PFC.
My code work very well without the overlapping area. Here is the code:
// Includes for overlapping
#include <boost/geometry.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/register/point.hpp>enter code here
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
polygon poly1, poly2;
poly1 {{0.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.05, 0.0}};
poly2 {{0.5, -0.5}, {0.5, 0.5}, {1.5, 0.5}, {1.5, -0.5}, {0.5, -0.5}};
std::deque<polygon> output;
boost::geometry::intersection(poly1, poly2, output);
double area = boost::geometry::area(output);
The error I'm getting is in assigning the poly1 and poly2 coordinates. Hope you can help in this. Thanks!