2014-12-15 3 views
0

안녕하세요. 비슷한 문제가 발생한 사람이 있습니까?부스트가있는 포인트에서 보로 노이 셀까지의 거리 계산

보로 노이 다이어그램을 구성해도 문제가 발생하지 않았습니다. Voronoi 셀은 적어도 나를위한 다각형입니다. 또한 라이브러리는 한 지점에서 다각형까지의 거리를 찾을 수있게합니다. 그러나 라이브러리 함수는 셀을 사용하기를 원하지 않습니다. 컴파일러는 Elvish에서 무언가를 산출합니다. 농담. 즉, 컴파일러 출력은 나를 도울 수 없습니다. 셀에서 다각형을 만드는 방법이 있습니까?

voronoi 다이어그램은 vpoints에 생성됩니다. 프로그램은 qpoints 요소에서 해당 셀까지의 거리를 계산해야합니다.

#include <iostream> 
#include <vector> 

#include <boost/geometry.hpp> 
#include <boost/geometry/geometries/polygon.hpp> 
#include <boost/polygon/voronoi.hpp> 
namespace bg = boost::geometry; 

using boost::polygon::voronoi_diagram; 
typedef voronoi_diagram<double>::cell_type cell_type; 
typedef voronoi_diagram<double>::edge_type edge_type; 
typedef voronoi_diagram<double>::vertex_type vertex_type; 
typedef boost::polygon::point_data<double> point_type; 

using namespace std; 

int main() { 

    vector<point_type> vpoints; 
    vpoints.push_back(point_type(0.0, 0.0)); 
    vpoints.push_back(point_type(0.0, 4.0)); 
    vpoints.push_back(point_type(4.0, 4.0)); 
    vpoints.push_back(point_type(4.0, 0.0)); 
    vpoints.push_back(point_type(2.0, 2.0)); 

    vector<point_type> qpoints; 
    qpoints.push_back(point_type(0.0, 0.0)); 
    qpoints.push_back(point_type(0.0, 2.0)); 
    qpoints.push_back(point_type(3.0, 3.0)); 
    qpoints.push_back(point_type(5.0, 5.0)); 
    qpoints.push_back(point_type(5.0, 5.0)); 

    voronoi_diagram<double> vd; 
    construct_voronoi(vpoints.begin(), vpoints.end(), &vd); 

    for (int i = 0; i < qpoints.size(); i++) { 
    for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin(); 
     it != vd.cells().end(); ++it) { 
     if (i == it->source_index()) { 
     cout << "v[i]=(" << vpoints[i].x() << "," << vpoints[i].y() << ")\t"; 
     cout << "q[i]=(" << qpoints[i].x() << "," << qpoints[i].y() << ")\t"; 
     cout << "Distance="; 
     cout << bg::distance(qpoints[i], *it) << endl; 
     cout << endl; 
     break; 
     } 
    } 
    } 

    return 0; 
} 

답변

0

메시지가 NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE 어설입니다

boost_1_57_0/boost/geometry/core/geometry_id.hpp|37 col 5| error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::geometry::core_dispatch::geometry_id<void>::NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE::************)(mpl_::assert_::types<void, mpl_::na, mpl_::na, mpl_::na>))’ 

입니다 : 다음은 내 코드입니다. 그것은 reverse_dispatch에 대한 geometry_id을하는 일이 발생 :

/*! 
\brief Meta-function returning the id of a geometry type 
\details The meta-function geometry_id defines a numerical ID (based on 
    boost::mpl::int_<...>) for each geometry concept. A numerical ID is 
    sometimes useful, and within Boost.Geometry it is used for the 
    reverse_dispatch metafuntion. 
\note Used for e.g. reverse meta-function 
\ingroup core 
*/ 
template <typename Geometry> 
struct geometry_id : core_dispatch::geometry_id<typename tag<Geometry>::type> 
{}; 

같은 경고가 트리거 당신이

cout << distance(qpoints[i], qpoints[i]) << endl; 

을 수행 할 때 그래서 문제가 요점 타입이 reqistered 기하학되지 않는 것입니다.

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

를 포함하면 그 컴파일을 만들지 만 const boost::polygon::voronoi_cell<double>는 기하학을 높일 수있는 알려진 지오메트리 유형이 아니기 때문에 당연히

cout << distance(qpoints[i], *it) << endl; 

여전히,이 시간을 실패합니다.

내가 원하는 이유를 알지 못한다면 이 아니라이 라이브러리를 혼합하지 않는 것이 좋습니다.

voronoi 세포가 단지 하나의 것 (contains_segment()contains_point() 인 경우) 이상일 수 있습니다. 가능한 경우를 처리하기 위해 몇 가지 스위칭 로직을 작성해야하며, 프로세스에서 Boost Polygon의 euclidean_distance을 사용하십시오 (boost :: geometry :: distance`와 반대)

관련 문제