2012-12-12 60 views
2

過去,我使用庫GGL來編寫一些程序。例如,下面的代碼適用於GGL和舊版本的gcc。現在我將gcc更新到gcc4.7.1。我的程序在編譯期間出現錯誤。因此,我更新到boost 1.52.1的最新版本。仍然存在與point_2d,polygon_2d等相關的錯誤。我發現在最新的vesion boost中缺少一些像'cartesian2d.hpp','c_array_cartesian.hpp'這樣的文件。最新版本的升壓和升壓幾何庫(GGL)之間的衝突

有人可以幫我分析下面的代碼,並告訴我有什麼問題嗎?非常感謝。

#include <iostream> 

#include <boost/geometry.hpp> 
#include <boost/geometry/geometries/point_xy.hpp> 
#include <boost/geometry/geometries/polygon.hpp> 
#include <boost/geometry/algorithms/distance.hpp> 
#include <boost/geometry/geometry.hpp> 

#include <algorithm> // for reverse, unique 
#include <iostream> 
#include <string> 


typedef boost::geometry::model::d2::point_xy<double,   
boost::geometry::cs::cartesian> point_2d; 
typedef boost::geometry::model::polygon<point_2d> polygon_2d; 
using namespace boost::geometry; 

int main() { 
     std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! 
     model::d2::point_xy<int> p1(1.0, 1.0), p2(2.0, 2.0); 
     point_2d x(3.0,3.0); 
     std::cout << x.x(); 
     std::cout << "Distance p1-p2 is: " << distance(p1, p2) <<std::endl; 

     float width = 100; 
     float length = 100; 


     polygon_2d poly; 
     { 
      const float coor[][2] = { 
      {-350.0,-500.0}, {350,-500}, {350, 0}, {width/2.0, 0}, {width/2.0, length}, 
      {350, length}, {350, 1000}, {-350, 1000}, {-350, length}, {-1*width/2.0, length}, {-1*width/2.0,0}, 
      {-350, 0}, {-350.0,-500.0} // closing point is opening point 
      }; 
      assign(poly, coor); 
     } 
      correct(poly); 

     return 0; 
} 

的誤差如下:

c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/ 
../../../../include/boost/geometry/core/point_order.hpp:1 
57:12: required from 'const boost::geometry::order_selector 
boost::geometry::point_order<float [13][2]>::value' 
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64- 
mingw32/4.7.1/../../../../include/boost/geometry/algorithms/ 
assign.hpp:148:70: required from 'void 
boost::geometry::assign(Geometry1&, const Geometry2&) [with 
Geometry1 =boost::geometry::model::polygon<boost::geometry::model 
::d2::point_xy<double, boost::geometry::cs::cartesian> >; 
Geometry2 = float [13][2]]' 
..\src\test.cpp:47:44: required from here 
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/ 
../../../../include/boost/geometry/core/point_order.hpp:95:5: 
error: no matching function for call to 
'assertion_failed(mpl_::failed************ 
(boost::geometry::core_dispatch::point_order<void, float [13] 
[2]>::NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE::************) 
(mpl_::assert_::types<float [13][2], mpl_::na, mpl_::na, 
mpl_::na>))' 
+0

非常感謝你 – Jun

回答

3

兩個變化是必要的:

1)包括c_array.hpp,到2D浮子陣列(const的浮子內部使用適應[] [2])到Boost.Geometry Point概念:

#include <boost/geometry/geometries/adapted/c_array.hpp> 

2)使用assign_points而不是assign。

assign_points(poly, coor); 

然後編碼您的代碼。背景:您使用的是預發佈版本(當然是允許的),發佈版在界面中進行了小的更改。分配(帶範圍)現在稱爲assign_points。

+0

你可以看看我的問題在這裏?每當我編譯我的代碼時,它都會顯示check_underflow的錯誤,但我不知道是什麼問題。我使用boost 1.52.0。和gcc4.7.1。謝謝 – Jun

+0

謝謝,我明白了。問題是我使用#define re 1,但是在庫中有一個變種也是're'。 – Jun