Boost logo

Boost :

From: KL (deco33000_at_[hidden])
Date: 2022-01-10 06:37:59


   Hi,

   Boost Geometry 1.78, linux

   Ã‚

   I was getting bad results with my calculations so I decided to narrow
   down the implementation up to the point I got the following problematic
   code:

   Ã‚

   typedef boost::geometry::model::point <double, 2,
   boost::geometry::cs::cartesian> Vector2d;
   Ã‚

   int main (){
   Ã‚
   Ã‚       multi_polygon <polygon <Vector2d> > mp;
   Ã‚
   Ã‚       /*{
   Ã‚               polygon <Vector2d> poly;
   Ã‚
   Ã‚               poly.outer().push_back( {0, 0} );
   Ã‚               poly.outer().push_back( {0, 4} );
   Ã‚               poly.outer().push_back( {4, 4} );
   Ã‚               poly.outer().push_back( {4, 0} );
   Ã‚
   Ã‚               correct( poly );
   Ã‚
   Ã‚               mp.push_back(poly);
   Ã‚       }*/
   Ã‚       {
   Ã‚               polygon <Vector2d> poly;
   Ã‚
   Ã‚               poly.outer().push_back( {10, -1} );
   Ã‚               poly.outer().push_back( {14, -1} );
   Ã‚               poly.outer().push_back( {10, -2} );
   Ã‚               poly.outer().push_back( {14, -2} );
   Ã‚
   Ã‚               correct( poly );
   Ã‚
   Ã‚               mp.push_back(poly);
   Ã‚       }
   Ã‚
   Ã‚
   Ã‚       boost::geometry::strategy::buffer::join_miter
   join_strategy;
   Ã‚       boost::geometry::strategy::buffer::end_flat
   end_strategy;
   Ã‚       boost::geometry::strategy::buffer::side_straight
   side_strategy;
   Ã‚       boost::geometry::strategy::buffer::point_square
   point_strategy;
   Ã‚
   Ã‚       boost::geometry::strategy::buffer::distance_symmetric
   <double> distance_strategy( 2 );
   Ã‚       boost::geometry::model::multi_polygon <polygon
   <Vector2d> > result;
   Ã‚
   Ã‚       boost::geometry::buffer( mp, result, distance_strategy,
   side_strategy, join_strategy, end_strategy, point_strategy );
   Ã‚
   Ã‚       cout << dsv( result ) << endl;
   Ã‚
   Ã‚       return 0;
   Ã‚
   }
   Ã‚
   and the result I get is:
   ((((13.7169, -3.13232), (13.5149, -3.94029), (12, -3.56155), (10.4851,
   -3.94029), (10.2831, -3.13232), (9.51493, -2.94029), (0.0749244,
   0.221833), (10, 1), (14, 1), (23.9251, 0.221833), (14.4851, -2.94029),
   (13.7169, -3.13232))))
   Ã‚
   Notice the two points:
   (0.0749244, 0.221833) and (23.9251, 0.221833)
   Ã‚
   I have multiple complex (concave) shapes which behave worse than that
   simple rectangle. But it is a starting point here.
   Ã‚
   Did I do something wrong?
   I need to get my job done, any alternative or helping code massaging ?
   Ã‚

   Thanks

   --Â

   MKL

   Ã‚


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk