Boost logo

Geometry :

Subject: Re: [geometry] Querying index using intersection with custom geometry
From: Michael Nett (netto.mihyaeru_at_[hidden])
Date: 2014-03-28 09:34:25


Hi,

thanks for you answer. I won't have time to check it out today, but I'll
take a look tomorrow. The current implementation of the intersect-method
just returns true (trying to get things to work in a very minimal way
first).

- Michael

On Fri, Mar 28, 2014 at 10:00 PM, Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]
> wrote:

> Hi Michael,
>
> Michael Nett wrote:
>
> Hello,
>
> We're considering using Boost.Geometry in one of our projects, but we
> require the ability to query an index using a super set of the geometric
> shapes provided by the library (frustum, conical frustums and complex
> geometry).
>
> We have tried implementing template specializations as discussed in this
> thread (
> http://stackoverflow.com/questions/19490435/boost-geometry-spatial-query-shapes
> ).
>
> namespace boost { namespace geometry {
> template <typename Box> inline
> bool intersects(Box const& b, MyFrustum const& f)
> {
> // your implementation
> }
> }}
>
> However, compiling this provides the following error.
>
> /usr/include/boost/geometry/core/point_type.hpp:45:5: error: no matching
> function for call to 'assertion_failed(mpl_::failed************
> (boost::geometry::traits::point_type<MyGeometry>::NOT_IMPLEMENTED_FOR_THIS_POIN‌
> ​T_TYPE::************)(mpl_::assert_::types<MyGeometry, mpl_::na, mpl_::na,
> mpl_::na>))'
>
> I tried digging into the source files, but my understanding of the
> geometry library is too limited to figure out what's going on.
>
> Can anyone advise on how to approach the problem?
>
>
> This assertion fails if you try to get a point_type for the type which is
> not adapted to any of the Boost.Geometry concepts. So you must call
> something like geometry::point_type<MyGeometry>::type or pass an object of
> MyGeometry to one of the existing functions of Boost.Geometry which tries
> to use is as a properly adapted Geometry.
>
> Did you check if your implementation of intersects() work without the
> rtree?
>
> Btw, what's the Value type stored in the rtree?
>
> Below is the fully working (for me) example, maybe it will help you to
> find the cause:
>
> #include <boost/geometry/index/rtree.hpp>
>
> struct MyFrustum
> {
> MyFrustum(int d) : dummy(d) {}
> int dummy;
> };
>
> namespace boost { namespace geometry {
>
> // This will be called for Nodes Bounds and Indexables!
>
> template <typename Box> inline
> bool intersects(Box const& b, MyFrustum const& f)
> {
> std::cout << "checking the intersection with " << f.dummy << std::endl;
> return true; // always intersects
> }
>
> }}
>
> int main()
> {
> namespace bg = boost::geometry;
> namespace bgi = bg::index;
> namespace bgm = bg::model;
> typedef bgm::point<float, 2, bg::cs::cartesian> pt;
> typedef bgm::box<pt> box;
>
> // check your implementation
> bool ok = bg::intersects(box(pt(0, 0), pt(1, 1)), MyFrustum(5));
>
> std::cout << "-------------------" << std::endl;
>
> // now use the rtree
> bgi::rtree<box, bgi::rstar<8> > rt;
> // insert some values
> rt.insert(box(pt(0, 0), pt(1, 1)));
> rt.insert(box(pt(2, 2), pt(3, 3)));
>
> // performa a query
> std::vector<box> vec;
> rt.query(bgi::intersects(MyFrustum(10)), std::back_inserter(vec));
>
> std::cout << vec.size() << std::endl;
> }
>
> The above should print:
>
> checking the intersection with 5
> -------------------
> checking the intersection with 10
> checking the intersection with 10
> 2
>
> Let me know if it helps.
>
> Regards,
> Adam
>
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry
>
>



Geometry list run by mateusz at loskot.net