Boost logo

Geometry :

Subject: Re: [geometry] Interesection points
From: Barend Gehrels (barend_at_[hidden])
Date: 2013-08-20 14:07:40


Hi Tanaka,

(the policy of this list is to avoid top-postings)

On 20-8-2013 16:30, Tanaka Simon wrote:
> - assume we have an intersection point C of a polygon with a
> segment/linestring. C lies on the segment defined by the pair of
> points A and B, which are stored in the polygon. is it possible to
> return A and B, not only C?
Yes, internally the get_turns method has a lot more information, a.o. a
segment_identifier which indicate exactly the segment on the polygon (so
indirectly also A/B). It is a method in namespace detail::, so not
documented and it might ever change, but basically it is usable.
But intersection does not return this information indeed.

> - is it possible to have a polygon made of segment, something like
> boost::geometry::model::polygon< segment > ?
No

>
> questions not directly related to the thread's question, but related
> to the attached code (should i start a new topic?):
> - i use a custom point class myPoint. how to register the getter and
> setter template methods (e.g. get<0>)?

Specify just get<0> indeed. Works for me (using clang).
If this does not work, for some reason or compiler, you can use
boost::geometry::traits to register your point-type. You are not using a
macro then, writing some more lines code, but you get much more
flexibility then. See e.g. example c05_custom_point_pointer_example.cpp
where this is done.

> - can i register std::shared_ptr<myPoint> instead of myPoint?

That is (basically) not necessary, because all access to points is
equivalent between values, references and pointers. However, that is
enabled for pointers, but not (yet) for shared points. I did not try it,
but probably won't work. We use boost::is_pointer to check if it is a
pointer - that returns probably false for shared_ptr (though I'm not
sure). It should be possible to enable this for Boost.Geometry too in
the future.

> - why is boost::geometry::model::polygon< std::shared_ptr<point> > not
> working?

Because of the same reason. You can use polygon<point_pointer>, see the
same c05 exampe.

Regards, Barend



Geometry list run by mateusz at loskot.net