kallaballa / libnfporb

Implementation of a robust no-fit polygon generation in a C++ library using an orbiting approach
GNU General Public License v3.0
106 stars 31 forks source link

NFP of two identical squares incorrect #7

Closed martinhansdk closed 6 years ago

martinhansdk commented 6 years ago

Given the following polygon:

POLYGON((0 0,10 0,10 10,0 10,0 0))

If this polygon is given to generateNFP() both as pA and pB then the result is

POLYGON((10 -10))
POLYGON((0 0))

I think this may be incorrect. I would have expected to get these four points:

POLYGON((-10 -10))
POLYGON((0 -10))
POLYGON((10 10))
POLYGON((-10 0))

Here I am assuming that the first point (0 0) is the reference point.

kallaballa commented 6 years ago

Something is definitely going wrong there, because if i run the data you provided i get: POLYGON((10 -10,10 0,10 10,0 10,-10 10,-10 0,-10 -10,0 -10,10 -10))

Could you please provide info on the system, boost version, compiler version, etc. you are running?

martinhansdk commented 6 years ago

Linux debian 9 on x64: Linux kbnux-mrhn 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux

Compiler:

g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

I get the same result with clang:

clang version 3.8.1-24 (tags/RELEASE_381/final)

I also get the same result with Visual Studio 2017 on Windows 10, but making it compile there required a few changes that I still have to contribute back to you.

I am using boost v. 1.66.0.

martinhansdk commented 6 years ago

I just ran examples/nfp on this input with -DNFP_DEBUG set on the gcc command line. Here is the output:

POLYGON((0 0,10 0,10 10,0 10,0 0))
POLYGON((0 0,10 0,10 10,0 10,0 0))
0
touchers:1
0
collected vectors:2
{{{10,0},{10,10}} -> {0,10}} = vertex3
{{{10,0},{10,10}} -> {0,10}} = vertex4
next:{{{10,0},{10,10}} -> {0,10}} = vertex3
trimmed:{{{10,0},{10,0}} -> {0,0}} = vertex3
##### outer #####

And the generated files: output.zip

I hope this helps.

kallaballa commented 6 years ago

There is quite a hack in place to deal with floating point... maybe it breaks with your boost version. I'll try to reproduce your environment and see for myself.

martinhansdk commented 6 years ago

Yes, it looks like it is the boost version. Boost 1.65.0 works for me, 1.66.0 and 1.67.0 do not.

martinhansdk commented 6 years ago

I can just use boost 1.65.0 for now. I think it makes more sense for you to focus on the new library.