Giter Club home page Giter Club logo

notalfredo / curaengine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thomasrahm/curaengine

0.0 0.0 0.0 63.11 MB

CuraEngine is a powerful, fast and robust engine for processing 3D models into 3D printing instruction for Ultimaker and other GCode based 3D printers. It is part of the larger open source project called "Cura".

Home Page: https://ultimaker.com/en/products/cura-software

License: GNU Affero General Public License v3.0

C++ 98.78% Python 0.85% CMake 0.36%

curaengine's Introduction

Tree Support V2 Mod

I reimplemented the tree support, as the current implementation does not meet my expectations.

How the new tree support looks:

New tree support

How to use:

Download the official UltiMaker Cura. It already contains this Tree Support (Recommended)

If you want my release from before the ultimaker xmas alpha:
Download with error messages
Download without error messages (If the error messages annoy you)

There are two versions available to download:
One will behave like regular Cura would, the other one will display a message if an issue is detected (at most 2 messages per slice, one for performance issues and one for logic issues). I would prefer if you would use this one, so you can easier see when an issue occurs. Slicing is paused while the message is displayed.

It is based on Cura 5.2.1, only the tree support code was replaced. Just run the Ultimaker-Cura.exe after extracting the folder. You may need to import your profile (Just export the one you want to use and import it into this one).

When to report something as a bug

These are the things I consider bugs and would like to get a bug-report of it when encountered:

  • The progress bar disappears (back to 0%) or becomes stuck.
  • It takes longer with the new implementation than with the old one (Assuming that the used feature in fact is implemented in the old tree support e.g. per mesh settings are not)
  • The result violates given settings.
  • An error message occurs if you use the version that displays error messages. This happens when the implementation detects that something went wrong. The effect of an error may not be visible in the result, but it still should be fixed.

How to report a bug

Open an issue here.
Please send me the Profile and Model and a description of the bug. Just zip both and upload it to the github issue by dragging it into the text-field (Only works up to 25 mb). Only upload the model if you are sure that this does not cause any issues with copyright! If the model is available to download somewhere else (e.g. thingiverse) I prefer a link to this for the model. You will see the option to select bug-report when you open an issue, and all information I would like to have will be listed there.
The error-message alone is not really helpful, as often the detection of an error happens after it actually occurred.

My goal is a universal set and forget solution, so if you have any feedback, e.g. encounter a situation where regular support or the current tree support produce a superior result compared to my tree support implementation, I am happy to hear it.

Currently known issues:

  • Slicing with cross support and 0% support density causes the slice progress to hang. This is not an issue of my implementation and to my understanding also occurs in the official version. Bug report of this issue.
  • There are issues when Minimum Support X/Y Distance is larger than Support X/Y Distance. This can trigger an error message if the version displaying them is used. I will not fix this one, except by maybe disallowing it in the UI, as I think the assumption that a minimum is not larger than the expected one is reasonable.

Settings:

Recommended settings

To see the tree support specific settings set the Setting Visibility to all.

I recommend enabling roofs and setting a reasonable Minimum Support Roof Area (I use 10 mm²). My implementation will make sure to correctly support the lines generated by the support roof. If no roof is possible the branches will try to avoid moving for as many layer as the roof is thick. They will generate as regular tree support branches, as i have serious doubts about the stability of roofs in branches.
Do not use concentric floor. It will generate as intended (by my understanding at least), but I suspect it will not print (it will be obvious when you see it) when support infill is low.
Set Minimum support area to 0, higher values may cause very pointy overhangs to not be supported (as intended by my current understanding of this feature)

New Tree Support Settings

Tree Support Preferred Branch Angle vs Tree Support Maximum Branch Angle

Tree Support Maximum Branch Angle is ONLY used when Tree Support Preferred Branch Angle is not enough to avoid the model. This causes branches to only move with Tree Support Preferred Branch Angle to merge with other branches.

Idea behind this is that Tree Support Preferred Branch Angle is a very stable angle, but if some parts could not be supported with the smaller angle the larger angle can be used to reach these parts.

Slow vs Fast branch angle

Tree Support Diameter Increase To Model

Branches that can reach the buildplate and branches that cannot are able to merge. This setting limits how much the diameter of the branch connecting with the model can be increased by such merges.

This setting is intended to specify how important it is that connections with the model are avoided (the lower this setting, the less contact area with the model).

Small Diameter Increase To Model:
Small Diameter increase to model

Large Diameter Increase To Model:
Large Diameter increase to model

Tree Support Minimum Height To Model

If only a few layers space are left between the position where the branch begins and where it ends, removing the support is impossible. This setting removes all branches that have a height lower than Tree Support Minimum Height To Model to prevent this. Only branches that rest on the model are removed.

Small Minimum Height To Model:
Small Diameter increase to model

Large Minimum Height To Model:
Large Diameter increase to model

Tree Support Initial Layer Diameter

Branches try to ensure to reach this diameter at layer 0.

Small Initial Layer Diameter:
Initial Layer Diameter

Large Initial Layer Diameter:
Initial Layer Diameter

Tree Support Branch Density

A percentage of space that has to be filled by the top most layer of a branch aka the layer that supports the overhang. When a roof is supported the overhang is the line of the roof. When no support roof is used it behaves similarly to the supporting (top most) layer when using regular support. High values (depends on your other settings) of >35% can cause the resulting support areas to overlap. This causes cura to merge them to a single area, as cura assumes every support area is supported by support areas below. If a low support infill is used this assumption is wrong. There is nothing reasonable I can do to prevent this, so in this case adjust your support infill accordingly.

Simulated regular support pattern:
Simulate regular support pattern

Tree Support Tip Diameter

Defines the diameter of the top most support area of a branch. Using a large diameter without having a reasonable large support density would obviously not print well.

Can replace tips with roof!

Happens automatically when Minimum Support Roof Area is smaller than a circle with diameter Tree Support Tip Diameter and roofs are enabled.

Large Tip Diameter with minimum roof area being small:
Tip radius large interface

Large Tip Diameter with minimum roof area being large:
Tip Radius large2

Small Tip Diameter:
Small Tip Diameter

Large Tip Diameter:
Large Tip Diameter

Support Interface Priority

This setting defines how support roof and regular support (e.g. from other branches) interact.

Support preferred(Support Area Overwrites Interface Area):
Support Area Overwrites Interface Area

Interface preferred(Interface Area Overwrites Support Area):
Interface Area Overwrites Support Area

Support lines preferred(Support Lines Overwrite Interface Area):
Support Lines Overwrite Interface Area

Interface Lines preferred(Interface Lines Overwrite Support Area. This one will not be what you want when Support Wall Count > 0):
Interface Lines Overwrite Support Area

Both Overlap (This causes filament be extruded twice at the same location (Once the support and once the roof). This may cause issues when printing. Use with care!):
Both Overlap

Tree Support Limit Branch Reach and Tree Support Optimal Branch Range

Limit how far each branch should travel from the point it supports. This can make the support more sturdy, but will increase the amount of branches. Branches can violate this value to reach their destination.

Tree Support Limit Branch Reach Disabled:
Tree Support Limit Branch Reach Disabled Tree Support Limit Branch Reach Enabled with a small distance:
Tree Support Limit Branch Reach Enabled with a small distance

Tree Support Rest Preference

The preferred placement of the support structures. Note that the buildplate is assumed to be also a flat surface (If not i think you have bigger issues than this setting)!
Only visible when the support can rest on the model.

Buildplate:
Buildplate On any flat surface:
On any flat surface

Tree Support Branch Diameter and Tree Support Branch Diameter Angle behave like in the current tree support implementation, but Tree Support Branch Diameter Angle is ignored when a diameter increase would invalidate a branch, as a small branch has a higher chance of supporting the model than no branch at all.

What does it do better:

Uses significant less filament.

Also makes the branches of my implementation much easier to remove from the model.

Current tree support:
Current tree support

My tree support:
New tree support

Comparison of material usage:
Comparison

Disclaimer: This is only the material used for support structures, not the whole model. The measuring unit is mm of 1.75mm diameter filament, as displayed in Cura. Measurement was done in the 4.7.1 version, and exact numbers could differ slightly.

Can handle large branch angles.

Current tree support:
Current tree support

My tree support:
New tree support

Supports Roofs more consistently.

The images show the bottom-most roof layer and a few layers of the branches below. In the current tree support some lines of the roof have a large distance from one point where support is below it to the next. My implementation ensures consistent spacing.

Current tree support:
Current tree support

My tree support:
New tree support

Branches avoid support blocker.

Branches avoid support blocker

Setting applicable now on a per-mesh basis. All tree support related settings are now settable per mesh and support related settings are correctly used by the tree support. This may increase slicing time drastically for settings that are not only relevant on the top most support layers.

So to avoid slicing times being longer by factor 10 try not to slice 10 different models with different branch radii (Slicing 2 models with different settings should not take much longer than slicing 2 times).

Trees with settings that are incompatible with each other can not merge and will avoid each other.

Few settings differences allow merges:
Different interface settings can merge

More settings of the regular support are now supported by the tree support

The newly supported settings are: Support Distance Priority, Support Horizontal Expansion, Support Interface Horizontal Expansion, Minimum Support Roof Area (Some of these were enabled in the UI, but did not do anything if I understand the code correctly) and Minimum Support Area (though I would recommend leaving this setting at 0).

Slices faster on multicore cpus.

Measured was the time it takes to generate the tree support for the test model (hobgoblin).

Slice performance graph

Settings used for benchmarking:
Profile for current tree support
Profile for my tree support implementation

Benchmarking was done in the 4.10 Version.

Further attributes this implementation has:

If a model is sliced twice on the same machine, the same trees will result. If this is somehow not the case something went very wrong. (Trees generated on systems with a different amount of threads could theoretically differ).
Every point that can be supported with the given Branch Angle limitations, will be supported when the support can only rest on the build plate. This means some other settings may be paused to ensure such behavior. For example: Tree Support Branch Diameter Angle will be paused if a radius increase would cause a branch to become invalid.

How the algorithm generating the trees works

This explains the idea behind the algorithm. As such it is simplified a fair bit to avoid explaining fixes for some edge cases.

0. The model

The model

1. Calculate avoidance An avoidance is an area that has to be avoided to achieve certain given results. For example an area in which a branch would be unable to reach the buildplate has to be avoided, if the support is not allowed to rest on the model. This idea is identical to the current tree support. My implementation just uses a lot more avoidances(slow, fast, slow to model, fast to model, fast without holes, fast without holes to model), and precalculates them in parallel. Avoidances are calculated from the bottom up.

Avoidance

2. Generate influence areas An influence area is an area,in which every point of the represented current branch, can reach all support points it has to support. Is is similar to an avoidance, but other that the avoidance, it represents possible center point areas, rather than excluding impossible ones. If two influence areas intersect, only the intersection will be used going forward. This causes branches to merge. Influence areas are calculated from the top downwards, as they grow from the overhang downwards.

Influence areas

Influence areas 2

3. Generate tree path Using the influence areas, the center points of the circles that build the branches are set. This happens from the bottom up.

Tree path

4. Draw Tree The circles, which center-point was calculated in 3. are drawn. Here also happens a fair bit of post processing to avoid edge-cases by the fact that the drawn radius in the tip of a branch is always increased (for stability reasons), even if a normal circle would not fit.

Resulting tree

Hints for compiling (Deprecated. Will not be updated)

The code for the modified tree support can be found in the tree_support_2 branch. The code in the master branch is old, and should be ignored. If you want to compile the version with error messages enabled, the code can be found in tree_support_2_error_detection. The code for the error messages is Windows only.

To compile it yourself mostly follow the official cura-build-environment. This part is not designed to be user-friendly, it is to provide hints to the very few of you who want to compile it themselves for some reason. Most modifications are to either ensure that the version contains a unique identifier ("~TreeSupport2") to avoid issues with cached definitions (found in AppData\Local\cura). I never compiled this under Linux, so you are even more on your own there, but I suspect just changing the cura-engine cmake to point the the modified code and contain the unique identifier, setting the correct version and replacing the fdmprinter.def.json could be enough.

Set Version to 5.x~TreeSupport2

I replaced the line (line 59 for me) in the CMakeList.txt of cura-build-environment that sets the Cura version so that ~TreeSupport2 is appended to the string. It looks like this:

set(_default_cura_version "${CURA_VERSION_MAJOR}.${CURA_VERSION_MINOR}.${CURA_VERSION_PATCH}~TreeSupport2")

Also you should ensure all other projects are fetched in the correct version. I did this by changing all default versions(main or master) to the version i am currently building. If unsure check the corresponding repositories for matching branch names. The files i changed the default versions in are located in the projects folder of the cura-build-environment files.

Modifying CuraEngine Cmake to compile the local code instead of the official one

cura-build would by default load the cura-engine code from their github repository, so I changed the cura-build-environment\projects\CuraEngine.cmake in the following ways: I replaced the ExternalProject_Add section with:

ExternalProject_Add(CuraEngine
    DOWNLOAD_COMMAND ""
    SOURCE_DIR "C:\\Users\\Thomas\\Documents\\Cura\\CuraEngineGit\\CuraEngine"
    BUILD_ALWAYS 1
        CMAKE_GENERATOR ${CMAKE_GENERATOR}
        CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
                   -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
                   -DCURA_ENGINE_VERSION=${CURA_ENGINE_VERSION})
)

Ensure to change the path in such a way that it points to the source-code of CuraEngine (the one with my new tree support in this repository) and to escape all backslashes with another backslash.

Replacing fdmprinter.def.json

AFTER building the result will be in the package folder. You will then need to replace the share\cura\resources\definitions\fdmprinter.def.json with this one.

Fix for 3MFReader plugin showing an error when launching Cura

If you run into the issue that the 3MFReader plugin is broken, just take the CuraEngine.exe and the Ultimaker-Cura.exe that was just compiled, copy the official installation and drop these two in there. Remember to replace the fdmprinter.def.json again if you do this.

Possible future improvements:

Automatically increase branch height when the angle is large.

Further Information

I did not make the mini hobgoblin I used to test. I used it because it cloak makes it very hard to slice in a way that the cloak is supported while not having a connection of the branch to the model.
All screen-shots of the current tree support were made using version 4.7.1.
Thank you to DerGenaue for providing the images explaining the algorithm and creating the graphs out of the performance data.

curaengine's People

Contributors

bagelorb avatar ghostkeeper avatar rburema avatar smartavionics avatar jellespijker avatar daid avatar lipufei avatar nallath avatar konskarm avatar casperlamboo avatar jackha avatar diegopradogesto avatar alekseisasin avatar thomasrahm avatar bjude avatar awhiemstra avatar vgribinchuk avatar joeydelarago avatar 14bitvoid avatar thopiekar avatar skeen avatar fxtentacle avatar grimmy avatar ninovanhooff avatar piezoid avatar devjohan avatar sshirokov avatar ianpaschal avatar totalretribution avatar fieldofview avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.