2014-01-23 77 views
3

這段代碼工作正常2D版,但3D版本不編譯:的boost ::幾何3D多邊形交集編譯錯誤

namespace bg = boost::geometry; 

typedef bg::model::point<double, 3, bg::cs::cartesian> Point3D; 
typedef bg::model::polygon<Point3D>     Poly3D; 

Poly3D   p0, p1; 
vector<Poly3D> result; 

bg::read_wkt("POLYGON((0 0 0, 0 1 1, 1 0 0, 0 0 0))", p0); 
bg::read_wkt("POLYGON((0 0 0.5, 0 11 0.5, 11 0 0.5, 0 0 0.5))", p1); 

bg::intersection(p0, p1, result); 

與此模板錯誤:

1>C:\boost_1_54_0\boost/geometry/core/coordinate_dimension.hpp(89): error C2338: (boost::mpl::equal_to < geometry::dimension<Geometry>, boost::mpl::int_<Dimensions> >::type::value) 
... 

燦有人告訴我intersection有什麼問題嗎?我的應用程序是查找平面多邊形的交集。我可以看到,一般情況下Poly3D不必是平面的,所以它可能是此錯誤的來源。有沒有辦法定義平面三維多邊形類型?

回答

1

呃。編譯器告訴你,所調用的算法對於三維無效...程序員明確地表明瞭這一點(area.hpp):

BOOST_CONCEPT_ASSERT((geometry::concept::AreaStrategy<Strategy>)); 
    assert_dimension<Ring, 2>(); 

所以,是啊。不能使用intersection跨越兩個平面多邊形。我很確定你有一些數學方法可以做兩個投影,這將導致兩個交叉點一起給你提供你之後的信息。

+6

'程序員明確地表明瞭這一點 - 在templatese中明確清楚,這是一個相當混亂的符號本身;-) –