1

I recently found out that boost polygon is integer-only: What is the utility of Boost Polygon?

I'm working around this by multiply my floating point values by a large exponent and then renormalizing the output from the library, but by default the internal representation seems to be 32 bit and doesn't work when my input goes over the max int at 2 billion or so.

is there a way to make the library work with 64 bit integers?

eg: http://www.boost.org/doc/libs/1_62_0/libs/polygon/doc/tutorial/minkowski.cpp

with my naive modifications:

typedef boost::polygon::point_data<long long int> point;
typedef boost::polygon::polygon_set_data<long long int> polygon_set;
typedef boost::polygon::polygon_with_holes_data<long long int> polygon;

...

int main(int argc, char **argv) {
  polygon_set a, b, c;
  a += boost::polygon::rectangle_data<long long int>(0, 0, 10000000000, 10000000000);
  std::vector<polygon> polys;

  b += boost::polygon::rectangle_data<long long int>(0, 0, 10000000000, 10000000000);

  polys.clear();
  convolve_two_polygon_sets(c, a, b);
  c.get(polys);

  for(int i = 0; i < polys.size(); ++i ){
    std::cout << polys[i] << std::endl;
  }

  return 0;
}

this outputs a polygon, but only for rectangles smaller than max int. The input data are long longs but I assume internally it's still 32 bit. I understand I have to define a new Point struct and use that but not sure how specifically.

Community
  • 1
  • 1
Jack000
  • 157
  • 1
  • 10
  • 1
    In general [Boost.Polygon seems to be able to deal with any integral type you like](http://www.boost.org/doc/libs/1_62_0/libs/polygon/doc/gtl_coordinate_concept.htm). E.g., in [this example](http://www.boost.org/doc/libs/1_62_0/libs/polygon/doc/gtl_custom_polygon.htm) you could easily replace the `int`s with `int64_t` or similar. Do you have some example code that illustrates your problem? – mindriot Nov 24 '16 at 08:49
  • I'm just working my way through the tutorials for now, specifically the minowski sum one where it uses the default boost::polygon::polygon_with_holes_data polygon; I guess the correct way to do this is with a custom polygon? I thought there might be an easier way without having to define your own point, polygon and polygonset etc. – Jack000 Nov 24 '16 at 09:35
  • 1
    Yes. There is a way. So. Unless you have a SSCCE you're stuck with the question is too broad. – sehe Nov 24 '16 at 09:54
  • So, have you tried using, say, `polygon_with_holes_data`? – mindriot Nov 24 '16 at 10:05
  • just updated the question. I hope that's enough for an SSCCE? – Jack000 Nov 24 '16 at 10:23

0 Answers0