Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centroid not working without main geometry header #792

Closed
Zilleplus opened this issue Jan 5, 2021 · 3 comments
Closed

centroid not working without main geometry header #792

Zilleplus opened this issue Jan 5, 2021 · 3 comments

Comments

@Zilleplus
Copy link

When I try to use the centroid or return_centroid function, by including the bare minimum (#include <boost/geometry/algorithms/centroid.hpp>) it doesn't seem to compile.("error: no type named 'state_type'")

If I add the "#include<boost/geometry.hpp>" header things work just fine. Is this by design? or a bug?

example code:

// #include<boost/geometry.hpp> // uncomment me to get stuff compiling.
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/linestring.hpp>

namespace bg = boost::geometry;

using point = bg::model::point<int, 2, bg::cs::cartesian>;
using linestring = bg::model::linestring<point>;

int main(){
    auto l = linestring{{0,0},{1,1}};
    auto p = bg::return_centroid<point>(l);
}

Or on compiler explorer: https://godbolt.org/z/Wdcb6f

@vissarion
Copy link
Member

You need to include the stategies for centroid.
Including the following should work
#include <boost/geometry/strategies/strategies.hpp>
However, AFAIU, this should not be needed to use the centroid algorithm.

@Zilleplus
Copy link
Author

@vissarion thanks !. With the "strategies" include it works, but the doc's don't say anything about it. I'l go trough the code and figure out why exactly the strategies header is required here.

drwells added a commit to drwells/dealii that referenced this issue Jan 4, 2022
 I bisected (fortunately Boost.Geometry a header-only library so adding the
 include directory sufficed) and
 boostorg/geometry@6eb9e23
 is where this problem starts for us. See also
 boostorg/geometry#792 - the easiest fix for all such
 issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit where grid_tools.cc fails to
compile, its because we were relying on some implicit includes. In particular,
we need the distance header to find the distance between points and boxes, but
that was previously included elsewhere.
drwells added a commit to drwells/dealii that referenced this issue Jan 4, 2022
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit where grid_tools.cc fails to
compile, its because we were relying on some implicit includes. In particular,
we need the distance header to find the distance between points and boxes, but
that was previously included elsewhere.
drwells added a commit to drwells/dealii that referenced this issue Jan 4, 2022
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit which causes grid_tools.cc
fails to compile, its because we were relying on some implicit includes. In
particular, we need the distance header to find the distance between points and
boxes, but that was previously included in another file.
drwells added a commit to drwells/dealii that referenced this issue Jan 4, 2022
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit which causes grid_tools.cc
fails to compile, its because we were relying on some implicit includes. In
particular, we need the distance header to find the distance between points and
boxes, but that was previously included in another file.
drwells added a commit to drwells/dealii that referenced this issue Jan 4, 2022
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit which causes grid_tools.cc
fails to compile, its because we were relying on some implicit includes. In
particular, we need the distance header to find the distance between points and
boxes, but that was previously included in another file.
drwells added a commit to drwells/dealii that referenced this issue Jan 6, 2022
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit which causes grid_tools.cc
fails to compile, its because we were relying on some implicit includes. In
particular, we need the distance header to find the distance between points and
boxes, but that was previously included in another file.
@vissarion
Copy link
Member

This is fixed in boost 1.77.0.

ivweber pushed a commit to ivweber/dealii that referenced this issue May 16, 2023
I bisected (fortunately Boost.Geometry a header-only library so adding the
include directory sufficed) and
boostorg/geometry@6eb9e23
is where this problem starts for us. See also
boostorg/geometry#792 - the easiest fix for all such
issues is to just include the project header `boost/geometry/geometry.hpp`.

In this particular case, if you look at the commit which causes grid_tools.cc
fails to compile, its because we were relying on some implicit includes. In
particular, we need the distance header to find the distance between points and
boxes, but that was previously included in another file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants