我在土木工程博士學位的學生,我最近開始在C++做一些編碼,基本上我感興趣的是得到兩個多邊形的重疊或交叉區域,其代表兩個土壤顆粒的投影。的boost ::幾何::交叉口C++
我做了很多的搜索,我發現,提升幾何形狀對我來說是最好的解決方案。我也做了很多搜索我面臨的具體問題,但我無法解決我的問題。
這是問題所在,我使用的軟件被稱爲PFC3D(顆粒流)。我必須使用microsoft visual studio 2010與此軟件交互並編譯DLL文件以在PFC中運行它。
我的代碼工作非常良好,沒有重疊區域。這裏是代碼:
// 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);
我得到的錯誤是在分配poly1和poly2座標。 希望你能在這方面提供幫助。謝謝!
什麼版本提升您使用的是? – mascoj
感謝您的回覆。我正在使用boost_1_65_0 –