Archicad C++ API
About Archicad add-on development using the C++ API.

Problem with Geometry::ResizePolygon2DDataContour ()

Anonymous
Not applicable
Problem with GSErr ResizePolygon2DDataContour ( const Polygon2DData& poly, long contourIdx, double offset, VAArray<Polygon2DData>* resultPolys )

This function work fine for different polygons but I found one problem for polygon with coordinates

0 – (0.000000, 0.000000)
1 – (10.000000, 0.000000)
2 – (10.000000, 10.000000)
3 – (0.256000, 10.000000)
4 – (0.256000, 9.850000)
5 – (0.150000, 9.744000)
6 – (0.000000, 9.744000)
0 – (0.000000, 0.000000)

And the offset is –0.300

Then the expected results are(which is auto cad is giveing)

0 – (0.300000, 0.300000)
0 – (9.700000, 0.300000)
0 – (9.700000, 9.700000)
0 – (0.5302641, 9.700000)
0 – (0.300000, 9.4697359)
0 – (0.300000, 0.300000)

But we got

0 – (0.300000, 0.300000)
1 – (9.700000, 0.300000)
2 – (9.700000, 9.700000)
3 – (0.556000, 9.700000)
4 – (0.556000, 9.725736)
5 – (0.274264, 9.444000)
6 – (0.300000, 9.444000)
0 – (0.300000, 0.300000)

is there any bug in this function?

Ranga
1 REPLY 1
Peter Csikvolgyi
Graphisoft
Graphisoft
This doesn’t seem to be the result of a bug in the function. The algorithm that we implemented to resize a polygon is a very simple one and very often it doesn’t provide the expected result, especially it can’t decide correctly when an edge should disappear from the polygon during the shrinking process. We might change the algorithm in the near future to a more sophisticated one as we will have to solve this problem for a totally different reason anyway. There might also be an issue of numeric inaccuracy in this case, as both Archicad’s and Autocad’s solutions are a bit inaccurate but to different directions which doubles the difference.