Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix polygon connector #843

Merged
merged 20 commits into from
Oct 25, 2018
Merged

Fix polygon connector #843

merged 20 commits into from
Oct 25, 2018

Conversation

BagelOrb
Copy link
Contributor

@BagelOrb BagelOrb commented Sep 9, 2018

I've fixed some problems with the PolygonConnector and improved performance.

The performance improvement should mostly come from the fact that we now use a sparse grid to efficiently lookup where polygons are close enough to each other to be connected.

I haven't done any performance tests to see whether performance is actually increased, but the tests below certainly show that some bugs are fixed and that the code is improved a lot!

Before:
(line dist 0.76)
random connection: (happened on roughly 2% of the layers)
image

image

no connection: (happened on roughly 50% of the layers, now on roughly 5%)
image

After:
image

image

image

Project:
lil_L_x2__cross_3d.curaproject.3mf.remove_extension.zip

@Ghostkeeper
Copy link
Collaborator

Developers, see issue CURA-5705.

@BagelOrb
Copy link
Contributor Author

BagelOrb commented Sep 10, 2018

I need to retract some claims.

I've done some tests and it turns out the new code is quite a bit slower.

Export stage processing time:
master: 5.07s, PR: 5.93s

Total fraction of polygons connected:
master: 62.5%, PR: 82.3%
Average fraction of polygons connected:
master: 65.0%, PR: 85.5%

So the core functionality of the PolygonConnector class is only enhanced marginally, at the cost of quite some computation time.

Still the PR solves the problem of random connections which can even introduce infill lines outside of the object.

I don't know yet which of my commits fixed that bug, but if you think the accuracy increase of 15% isn't worth the extra processing time of 10% then I can see if I can isolate the bug fix.

Project file for testing: (Nobody thinks that boaty-mac-bench-face is a good benchmark, right?)
Debailey_x20.curaproject.3mf.remove_extension.zip

Project files seem to be broken on master?!
In order to test it I do:

  • choose default TPU for UM3 profile
  • set the Extra Infill Wall Count to 1
  • set the line distance to 2.51

@BagelOrb
Copy link
Contributor Author

BagelOrb commented Sep 10, 2018

I am getting the same results in terms of accuracy when I test the lil L project file shared above:

master: 65%, PR: 85%

@BagelOrb
Copy link
Contributor Author

Okay I decided I need to really fix the implementation, because these fail rates are just too damn high!

Now I am satisfied with the fail rates:
master: 35%, PR: 0.5% !!!

@alekseisasin
Copy link
Contributor

Can you fix the branch conflicts?

@BagelOrb
Copy link
Contributor Author

The conflicts were auto-resolved.

@BagelOrb
Copy link
Contributor Author

Why is Jenkins crying?

@alekseisasin
Copy link
Contributor

[ 81%] Building CXX object CMakeFiles/ArcusCommunicationTest.dir/tests/arcus/MockSocket.cpp.obj

In file included from C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.cpp:4:0:

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:23:10: error: 'void cura::MockSocket::connect(const string&, int)' marked 'override', but does not override

 void connect(const std::string& address, int port) override;

      ^

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:24:10: error: 'void cura::MockSocket::listen(const string&, int)' marked 'override', but does not override

 void listen(const std::string& address, int port) override;

      ^

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:25:10: error: 'void cura::MockSocket::close()' marked 'override', but does not override

 void close() override;

      ^

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:26:10: error: 'void cura::MockSocket::reset()' marked 'override', but does not override

 void reset() override;

      ^

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:29:10: error: 'void cura::MockSocket::sendMessage(Arcus::MessagePtr)' marked 'override', but does not override

 void sendMessage(Arcus::MessagePtr message) override;

      ^

C:....\ngine_fix_polygon_connector-3V6HUP43CQSHTUOXHZEOXJ7DNWOI4QXO74SGWJXTH7SMVB3F7WOA\tests\arcus\MockSocket.h:30:23: error: 'Arcus::MessagePtr cura::MockSocket::takeNextMessage()' marked 'override', but does not override

 Arcus::MessagePtr takeNextMessage() override;

                   ^

CMakeFiles\ArcusCommunicationTest.dir\build.make:87: recipe for target 'CMakeFiles/ArcusCommunicationTest.dir/tests/arcus/MockSocket.cpp.obj' failed

mingw32-make[2]: *** [CMakeFiles/ArcusCommunicationTest.dir/tests/arcus/MockSocket.cpp.obj] Error 1

CMakeFiles\Makefile2:331: recipe for target 'CMakeFiles/ArcusCommunicationTest.dir/all' failed

mingw32-make[1]: *** [CMakeFiles/ArcusCommunicationTest.dir/all] Error 2

Makefile:161: recipe for target 'all' failed

mingw32-make: *** [all] Error 2

script returned exit code 2

@BagelOrb
Copy link
Contributor Author

BagelOrb commented Sep 27, 2018 via email

@alekseisasin
Copy link
Contributor

Right, we need to update the libarcus on the server.

…re reliably when the polygons involved have complex shapes
… line pairs if a good candidate has been found

It used to first put all candidate connecting pairs of line segments in a set first
and then process all items in the set until a good one is found.

Now it puts them in the set within the same loop as it processes the items.
Contributes to issue CURA-5826.
src/utils/PolygonConnector.cpp Show resolved Hide resolved
src/utils/PolygonConnector.cpp Outdated Show resolved Hide resolved
src/utils/PolygonConnector.h Outdated Show resolved Hide resolved
src/utils/SparseGrid.h Outdated Show resolved Hide resolved
@Ghostkeeper
Copy link
Collaborator

I don't see a definite improvement in how often the cross infill polygons can be connected. It still seems to fail to connect quite often. This is a screenshot of one of the worst layers:

screenshot from 2018-10-25 15-15-01

But since that was already the case, I think we'll have to accept that as a limitation of our current algorithm. What does appear to be fixed is the much more pressing issue of polygons connecting across the infill randomly. I am not able to reproduce those any more. Good job.

@Ghostkeeper Ghostkeeper merged commit b3f200e into master Oct 25, 2018
@Ghostkeeper Ghostkeeper deleted the fix_polygon_connector branch October 25, 2018 13:19
@BagelOrb
Copy link
Contributor Author

BagelOrb commented Oct 25, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants