2017-12-05 9 views
2

私のように定義されたRTREEでboost :: geometry :: rtreeをglm :: vec3とカスタムポイントタイプとして使用する方法は?

BOOST_GEOMETRY_REGISTER_POINT_3D(glm::vec3, float, boost::geometry::cs::cartesian, x, y, z); 

を使用しています:私はこれで最近傍クエリを実行しようとすると、それはコンパイルに失敗し

using IndexedPoint = std::pair<glm::vec3, uint32_t>; 
    using RTree = boost::geometry::index::rtree<IndexedPoint, boost::geometry::index::rstar<8>>; 

auto it = rtree.qbegin(boost::geometry::index::nearest(glm::vec3(), 3)) 

エラー:

error C2664: 'int boost::mpl::assertion_failed<false>(boost::mpl::assert<false>::type)': cannot convert argument 1 from 'boost::mpl::failed ************(__cdecl boost::geometry::strategy::distance::services::default_strategy<boost::geometry::point_tag,boost::geometry::box_tag,glm::vec<3,float,0>,boost::geometry::model::point<float,3,boost::geometry::cs::cartesian>,boost::geometry::cartesian_tag,boost::geometry::cartesian_tag,void>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION::* ***********)(boost::mpl::assert_::types<Point1,Point2,CsTag1,CsTag2>)' to 'boost::mpl::assert<false>::type' 
     with 
     [ 
      Point1=glm::vec<3,float,0>, 
      Point2=boost::geometry::model::point<float,3,boost::geometry::cs::cartesian>, 
      CsTag1=boost::geometry::cartesian_tag, 
      CsTag2=boost::geometry::cartesian_tag 
     ] 

comparable_distance_resultには、vec3とboost :: geometry :: model :: pointとboost :: geometry :: model :: boxのスペシャライゼーションがありません。手動で追加しようとしましたが、動作させることができませんでした。必要な距離タイプの特殊化を追加するにはどうすればよいですか?

空間的なクエリには同じ設定を使用できますが、基本的には音質が良いように見えます。

私はGCC /ブースト1.65.1で問題を再現することはできません

答えて

2

:Coliruはlibglm

を持っていない¹

Nearest: # 3 (3, 3 3) 

Live ¹ On Coliru

#include <boost/geometry.hpp> 
#include <boost/geometry/index/rtree.hpp> 
#include <boost/geometry/geometries/box.hpp> 
#include <boost/geometry/geometries/register/point.hpp> 

namespace bg = boost::geometry; 
namespace bgi = boost::geometry::index; 

#include <glm/vec3.hpp> 
BOOST_GEOMETRY_REGISTER_POINT_3D(glm::vec3, float, bg::cs::cartesian, x, y, z) 

#include <iostream> 
int main() { 

    using IndexedPoint = std::pair<glm::vec3, uint32_t>; 
    using RTree = boost::geometry::index::rtree<IndexedPoint, boost::geometry::index::rstar<8>>; 

    RTree rtree; 
    rtree.insert({glm::vec3(1,1,1), 1}); 
    rtree.insert({glm::vec3(2,2,2), 2}); 
    rtree.insert({glm::vec3(3,3,3), 3}); 
    rtree.insert({glm::vec3(4,4,4), 4}); 

    auto it = rtree.qbegin(bgi::nearest(glm::vec3(2.9, 2.9, 2.9), 99)); 

    auto p = it->first; 
    std::cout << "Nearest: # " << it->second << " (" << p.x << ", " << p.y << " " << p.z << ")\n"; 
} 

プリント

+0

ランダムに助けてくれましたか、MSVCで動作しないと結論づけられましたか? – sehe

+1

クイックレスポンスとテストプログラムをありがとうございました。問題は、geometry.hppは含まず、rtree、box、pointだけを含んでいたということでした。私は自分の依存関係を最小限に抑えようとしていて、明らかに遠すぎた。私は今、ちょっと愚かな気がする。 OTOH:このプログラムが機能するために最低限必要なヘッダーは何ですか? – BuschnicK

+0

あまりにも確かではありません - 私はそれを汗をかくわけではありません。なぜなら、オプティマイザがとにかくそれを書き留めているからです。そして、それらのブーストヘッダは、私のプロジェクトのほとんどでは "揮発性"としてカウントされません。 IWYUが提供したものは次のとおりです:http://paste.ubuntu.com/26118710/ - コンパイルされていないので完全には正確ではありません – sehe

関連する問題