Boost logo

Geometry :

From: qxc_at_[hidden]
Date: 2021-03-31 11:42:45


Hi,

I have a problem with the resize() function which is used in order to provide a bigger or smaller copy of the current polygon. The input polygon is shown in attached image shape.png, it is a rectangle with two other rectangles that form a hole. All rectangles are oriented clockwise, these are the coordinates:

-36486 26031 0
-8220 26031 1
-8220 4409 1
-36486 4409 1
-36486 26031 1
-32983 21078 0
-28031 21078 1
-28031 16730 1
-32983 16730 1
-32983 21078 1
-16555 10932 0
-11240 10932 1
-11240 7187 1
-16555 7187 1
-16555 10932 1

When I do a resize() with a positive value in parameter resizing, the result is as per clip_inner.png (the red filled area shows the resize-result), when a "resizing" is set to a negative value, the result is as in attached image clip_outer.png. In both cases the first hole is somehow overlapped.

My code (simplified to the minimum) to resize the polygon looks like this:

   boost::polygon::polygon_with_holes_data<int> data;
   boost::polygon::polygon_with_holes_data<int> opData;

   boost::polygon::polygon_data<int> hole;
   std::vector<boost::polygon::polygon_data<int>> holes;
   std::vector<std::vector<boost::polygon::point_data<int>>> outlines;

      std::vector<boost::polygon::point_data<int>> outline;

      // add the outline
      outlines.push_back(outline);
      for (i=0; i<planeNum; i++)
      {
         outlines[polyCnt].push_back(boost::polygon::point_data<int>((int)(plane[i].x*10000),(int)(plane[i].y*10000)));
      }

      outline.clear();

      // add the holes
      outlines.push_back(outline);
      if (i<planeNum-1) for (; i<planeNum; i++)
      {
         outlines[polyCnt].push_back(boost::polygon::point_data<int>((int)(plane[i].x*10000),(int)(plane[i].y*10000)));
         if ((plane[i].flags...)
         {
            // end of one hole, beginning of next one, switch data
            ...
         }
         outlines.push_back(outline);
      }
      data->set_holes(holes.begin(),holes.end());

      if (outlines[outlines.size()-1].empty()) outlines.pop_back();

      for (i=0; i<outlines.size(); i++)
      {
         if (i==maxPoly) data->set(outlines[i].begin(),outlines[i].end());
         else
         {
            hole.set(outlines[i].begin(),outlines[i].end());
            holes.push_back(hole);
         }
      }
      data->set_holes(holes.begin(),holes.end());

Then resizing is done e.g. this way:

   boost::polygon::polygon_set_data<int> result;

   opData=data;
   result=opData+data;
   clip->result=result.resize((int)(distance*10000.0,0));

Any idea what may go wrong here?

Thanks!



clip_inner.png
clip_outer.png
shape.png

Geometry list run by mateusz at loskot.net