Comparar commits

...

252 Commits

Autor SHA1 Mensagem Data
Arjen Hiemstra 8b82ec4c95 Only include OpenMP headers if we are actually compiling with OpenMP
Fixes building on OSX with Clang
2017-02-16 11:13:20 +01:00
Tim Kuipers bdb788e3c4 don't generate towers when support_use_towers is disabled (CURA-3288) 2017-02-15 12:48:46 +01:00
Tim Kuipers 5b00c21a5f Merge branch 'feature_omp_settings' 2017-02-15 12:19:21 +01:00
Tim Kuipers b546f66bbe Merge branch 'feature_omp_skin_infill' 2017-02-15 12:16:37 +01:00
Tim Kuipers 2af8320cc9 Merge branch 'feature_omp_slicing' 2017-02-15 12:16:11 +01:00
Tim Kuipers 5fa5c89935 fix: const correctness of getSetting functions (CURA-3372) 2017-02-15 12:05:14 +01:00
Tim Kuipers 5c40f74c68 feat: small optimization in setting value retrieval (CURA-3372) 2017-02-15 12:03:11 +01:00
Tim Kuipers 60cebc86eb fix: error on unknown unset setting, rather than warn (CURA-3372)
this als oremoves a const_cast :)
2017-02-15 12:02:36 +01:00
Tim Kuipers 1bb4e03b36 fix: remove superfluous const_cast (CURA-3372) 2017-02-15 11:46:01 +01:00
Tim Kuipers 677857a186 fix: lil (CURA-3331) 2017-02-09 21:13:26 +01:00
Tim Kuipers 156674e452 fix: bs include (CURA-3331) 2017-02-09 17:44:23 +01:00
Tim Kuipers 903b31d381 Merge branch 'feature_omp_skin_infill' of github.com:Ultimaker/CuraEngine into feature_omp_skin_infill 2017-02-09 17:41:49 +01:00
Tim Kuipers 734978230f lil (CURA-3330) 2017-02-09 17:41:45 +01:00
Tim Kuipers fa02006a5d fix: logging of OpenMP threads in main (CURA-3330) 2017-02-09 15:30:45 +01:00
Ghostkeeper 6861020c6b Remove irrelevant documentation of different function
This documentation of processInsets reports on one of the generateInsets functions. Probably a copy-paste mistake.

Contributes to issue CURA-3330.
2017-02-08 16:43:13 +01:00
Ghostkeeper 2d9a3c83ef Code style: Space after for keyword
Contributes to issue CURA-3330.
2017-02-08 16:29:02 +01:00
Ghostkeeper ab7e035f6e Don't continue with compiling when function has error
This would give an exception which breaks the script and makes a very unclear chained error message.

Contributes to issue CURA-2572.
2017-02-03 17:05:28 +01:00
Ghostkeeper d0a149cf26 Fix error handling when setting has a parse error
The code was an integer. It needs to be converted to a string in order to be added to other strings.

Contributes to issue CURA-2572.
2017-02-03 17:05:28 +01:00
Tim Kuipers 4d35735aa8 Merge pull request #451 from smartavionics/mb-spiralize-bug
Fix spiralize args bug - untested but this just looked wrong to me.
2017-02-02 13:12:49 +01:00
Mark Burton 5e831f99e9 Fix spiralize args bug - untested but this just looked wrong to me. 2017-02-02 08:08:50 +00:00
Tim Kuipers 04766f663b Add OpenMP parallel execution createLayerParts (CURA-3331) 2017-02-01 13:26:51 +01:00
Tim Kuipers 42684e6368 feat: Add OpenMP parallel execution of slice make polygons (CURA-3331) 2017-01-31 11:41:34 +01:00
Ghostkeeper aa14682087 Remove 'l' formatting character and simplify+speed-up int2mm formatting
The 'l' formatting character in combination with 'd' was not allowed with MinGW on Windows. Simply formatting with 'd' is sufficient since our coordinates are allowed to be cast to integers at this stage: We won't need to square them any more or anything.

Contributes to issue CURA-3274.
2017-01-31 10:35:28 +01:00
Tim Kuipers 4c5a959c4e fix: handle multithreaded progress messages (CURA-781) 2017-01-30 17:41:33 +01:00
Johan Kristensen 21746022c4 Add OpenMP parallel execution of processInsets
CURA-541
2017-01-30 17:36:12 +01:00
Johan Kristensen d6bf9be54e Add OpenMP parallel execution of processSkinsAndInfill
CURA-541
2017-01-30 17:35:59 +01:00
Johan K fff1164042 Add cmake option to enable OpenMP
CURA-541
2017-01-30 17:30:44 +01:00
Ghostkeeper c7e621eeb5 Merge branch '2.4' 2017-01-25 17:46:07 +01:00
Ghostkeeper 9c3170b277 Print debug message upon sending layer data
This should help a bit with debugging the slice loop. I hope.

Contributes to issue CURA-3274.
2017-01-25 17:45:34 +01:00
Ghostkeeper e2f89778e2 Remove p1 after inserting point next to it
Because this insertion requires dereferencing p1. If it has been removed from the list, dereferencing it would remove it from memory so that would be an invalid pointer reference.

Contributes to debugging issue CURA-3274.
2017-01-25 14:40:11 +01:00
Ghostkeeper 8f74952aca Replace last long in gcodeExport with int64_t
Previously we had a crash only on windows because the long was not long enough. Perhaps this fixes something with the slicing loop.

Contributes to issue CURA-3274.
2017-01-25 13:36:14 +01:00
Ghostkeeper 5b6f1db59d Merge branch 'mb-min-infill-area' of https://github.com/smartavionics/CuraEngine into smartavionics-mb-min-infill-area 2017-01-24 11:40:03 +01:00
Tim Kuipers 17463e1139 quick fix: accidental const (CURA-3309) 2017-01-23 17:37:17 +01:00
Tim Kuipers 8df26ae916 fix: equalize flow still equalizes after halving the line width for perimeter gaps (CURA-3309) 2017-01-23 17:36:24 +01:00
Tim Kuipers 9ac9d1dd59 Merge branch '2.4' 2017-01-23 14:54:16 +01:00
Tim Kuipers c2aa1d59bc fix: add perimeter_gaps config with line width of half the inner wall line width (CURA-3309)
also the perimeter gaps of the skin walls now have to be generated separately
2017-01-23 14:53:57 +01:00
Tim Kuipers 3d476f114b Merge branch '2.4' 2017-01-23 10:22:54 +01:00
Tim Kuipers 152f6e89a8 fix: more safety against empty layers (CURA-3290) 2017-01-20 16:56:01 +01:00
Tim Kuipers 113202cd34 fix: types in CubicSubdiv were wrong (CURA-3196)
the sphere_slice_radius2 was a long rather than a coord_t (long long)
2017-01-20 15:23:34 +01:00
Tim Kuipers 4bc706d618 fix: perimeter gaps were introduced for the overlap between infill and skin (CURA-3179)
this caused extra overextrusion where infill and skin meet
2017-01-20 15:01:51 +01:00
Tim Kuipers 5766e2db11 fix: don't fill gaps for outer wall when spiralize is enabled (CURA-3152) 2017-01-20 14:21:14 +01:00
Tim Kuipers 671ebccdbb fix: indentation only (CURA-3271) 2017-01-20 14:08:56 +01:00
Tim Kuipers 2516165c86 fix: there were no support bottoms on top of the first model in support of the second model (CURA-3271)
All support areas are now generated before generating the interface. They are stored in supportLayer.supportAreas right after generation of the areas.
generateSupportInterface then operates on the merged supportAreas.

Note that this has a performace impact: while evaluating support interface, the support of all models is considered, rather than only the support it introduced itself.
2017-01-20 14:08:29 +01:00
Tim Kuipers 0315aaf404 fix: support top distance was one layer too high (CURA-3269) 2017-01-20 13:26:39 +01:00
Mark Burton b43e4df3aa Remove areas of infill smaller than min_infill_area.
When you have a small feature above an outer layer (e.g. raised text), the
area under the feature will be infill rather than skin and so the skin is
composed of multiple segments around the feature. Better surface quality is
obtained if the area under the raised feature is treated as skin thus allowing
more of the outer layer to be printed as a single segment. This setting
specifies the minimum area (in mm^2) of a filled region. Areas smaller than
this will be filled with skin rather than infill.
2017-01-19 11:44:22 +00:00
Ghostkeeper 405c49133b Merge branch 'first-layer-skin-pattern' of https://github.com/14bitVoid/CuraEngine into 14bitVoid-first-layer-skin-pattern 2017-01-03 10:42:31 +01:00
Tim Kuipers 49f09ed204 fix: (anti) support meshes could f*ck up the printZ of each layer (CURA-3198)
those meshes didn't call createLayerParts and so their printZ was never set.
To determine the print height of a layer an arbitrary mesh was used to see the printZ.
2017-01-02 23:03:40 +01:00
14bitVoid e717404055 Use different skin pattern on first layer 2017-01-02 22:30:41 +01:00
Ghostkeeper 3e7d623c86 Make total bounding box use head coordinates
Instead of nozzle coordinates.
2016-12-20 15:49:37 +01:00
Ghostkeeper d694bff227 Remove superfluous comment
A bit witty, perhaps, but unnecessary.

Contributes to issue CURA-3137.
2016-12-15 12:03:28 +01:00
Ghostkeeper 05be030c45 Document range check for pre-computed cubes
Contributes to issue CURA-3137.
2016-12-14 15:15:20 +01:00
Ghostkeeper 3c5e745f83 Reintroduce assert for coordinates exceeding maximum int
Because we might still test with models of 2km size.

Contributes to issue CURA-3137.
2016-12-14 14:09:16 +01:00
Ghostkeeper 2e6cd36f20 Make unused parameters unnamed
This way they cannot be used any more.

Shuts the compiler up for issue CURA-3137.
2016-12-14 12:02:00 +01:00
Ghostkeeper 9fc4a427cd Removed checks of unsigned ints being >= 0
Because that's always true. Even the compiler says that.

Contributes sorta to issue CURA-3137.
2016-12-14 12:00:39 +01:00
Ghostkeeper 5729908023 Remove unused path parameter
According to the compiler, the path parameter of handleChildren was not unused, but that was only because it went recursively to subcalls to handleChildren, so it was actually also unused.

Contributes to issue CURA-3137.
2016-12-14 11:55:40 +01:00
Ghostkeeper c5b90b0ad9 Put check for empty extruder trains before size check
Could save a miniscule amount of time.

Contributes to issue CURA-3137.
2016-12-14 11:50:45 +01:00
Ghostkeeper 382343e558 Make recursion depth unsigned
It can't be negative anyway. And it helps with the signed-unsigned comparison checks.

Contributes to issue CURA-3137.
2016-12-14 11:48:46 +01:00
Ghostkeeper 68b293b880 Make subdivided cubic infill robust to 0% infill
Otherwise it would crash or loop forever.

Contributes to issue CURA-3137.
2016-12-14 11:44:34 +01:00
Ghostkeeper f867c0f53a Prevent crashing when given no extruder trains
Instead we return -1. A bit more robust.

Contributes to issue CURA-3137.
2016-12-14 11:05:05 +01:00
Ghostkeeper ee7e83d138 Merge branch 'mb-layer-height-comment' of https://github.com/smartavionics/CuraEngine into smartavionics-mb-layer-height-comment 2016-12-14 09:29:53 +01:00
Ghostkeeper 50df40c6c6 Revert "Re-use extruder train variable"
This reverts commit c9217d4738.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper 4d924fd33d Revert "Add park distance information to retraction config"
This reverts commit 23ef513cce.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper c953a726cb Revert "Add function to move filament to park position"
This reverts commit ae00cbe497.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper 7c8c0b2417 Revert "Correct speed of retraction"
This reverts commit 6925f39426.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper a834754d64 Revert "Remove some annoying compile warnings"
This reverts commit d75882a707.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper 9957a0c733 Revert "Fix updating current E value"
This reverts commit 80f8760f68.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper f6ce0b4141 Revert "Put filament in parking position when we never use it any more"
This reverts commit 3cb3e5de45.

Contributes to issue CURA-2795.
2016-12-13 15:35:47 +01:00
Ghostkeeper 120a9c440c Revert "Park filament even if printer doesn't support retraction"
This reverts commit 837f992f69.

Contributes to issue CURA-2795.
2016-12-13 15:35:46 +01:00
Ghostkeeper 59f72bdd98 Revert "Expand documentation of writePark"
This reverts commit 4f3b4f429d.

Contributes to issue CURA-2795.
2016-12-13 15:35:46 +01:00
Ghostkeeper abc43302ac Revert "Correct retraction speed"
This reverts commit 36eb3471df.

Contributes to issue CURA-2795.
2016-12-13 15:35:46 +01:00
Mark Burton c2725bdf83 Move layer_height out of the GCodeExport class - it doesn't need to be a member. 2016-12-13 13:47:39 +00:00
Tim Kuipers fb761dfd9d fix: don't generate perimeter_gaps between inner wall and infill/skin when there is no infill (CURA-3108) 2016-12-13 13:53:05 +01:00
Mark Burton 90727a0578 Merge branch 'master' into mb-layer-height-comment 2016-12-13 08:05:31 +00:00
Mark Burton fd7d1a4bd4 Add comment that reports layer height in RepRap flavour gcode. 2016-12-12 16:54:13 +00:00
Ghostkeeper 2b1266c647 Move implementation to CPP file
Contributes to issue CURA-3006.
2016-12-12 14:04:32 +01:00
Ghostkeeper 901bf47610 Move implementation to CPP file
Contributes to issue CURA-3006.
2016-12-12 13:55:47 +01:00
Ghostkeeper 80a6115537 Move implementation to CPP file
Contributes to issue CURA-3006.
2016-12-12 13:44:23 +01:00
Ghostkeeper f94ca645bd Make writeRetraction accept const ref instead of const pointer
This change was already made for CURA-2795, and upon this change was built by other commits for other issues. I had to revert CURA-2795, so that would undo the changes that the other commits depend on. Instead though, I un-reverted the change because it's nice and doesn't have anything inherently to do with CURA-2795.

Contributes to issue CURA-2795.
2016-12-12 13:11:03 +01:00
Ghostkeeper 2067644d30 Revert "Update prime speed corresponding to park retraction"
This reverts commit 6c986e6cfe.

Contributes to issue CURA-2795.
2016-12-12 12:57:15 +01:00
Ghostkeeper 0285e2f025 Revert "Add additional safety check for extruder switching off in later layers"
This reverts commit bc82fd98c9.

Contributes to issue CURA-2795.
2016-12-12 12:57:15 +01:00
Ghostkeeper 38a1ee4270 Revert "Allow going to stand-by temperature if nozzle is later used"
This reverts commit 3c0d3f1b2d.

Contributes to issue CURA-2795.
2016-12-12 12:57:15 +01:00
Ghostkeeper 63459d5cd4 Revert "Correct documentation on why the temperature is switched off later"
This reverts commit 6972101d7e.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 138691436e Revert "Correct technicality in documentation"
This reverts commit ab2c2eed4b.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper b9c5b4593b Revert "Remove unused parameter"
This reverts commit b7e9f72023.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper a0a3a24dc1 Revert "Restore park distance exception for BFB g-code"
This reverts commit b6355b69e7.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 5959b41132 Revert "Use filament park distance setting instead of direct heat & cool zones"
This reverts commit b0487fa4c7.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 3d7229c9f2 Revert "Turn extruder temperature off only if it parked the filament"
This reverts commit 84d3381be6.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper e1cfc3d93b Revert "Break retraction in two"
This reverts commit a0625aa735.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 5834540bec Revert "Rename writeRetractionMove to writeMoveFilament"
This reverts commit 7c39b6b26a.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper f191d23e17 Revert "Pass retraction configs by reference instead of pointer"
This reverts commit 7a8be50b8f.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 5114ab4218 Revert "Use writeMoveFilament to retract to parking distance"
This reverts commit cb7b7bf22a.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 9f5645ecac Revert "Protect writeMoveFilament"
This reverts commit 52220ccab8.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper 66befe5827 Revert "Correct documentation of extruder_switch parameter"
This reverts commit 4263801d16.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper c9de64f946 Revert "Use optional to denote uninitiated previous extruder temperature"
This reverts commit 460c52ea6c.

Contributes to issue CURA-2795.
2016-12-12 12:57:14 +01:00
Ghostkeeper dbfa3a0f4b Revert "Move park distance data to ExtruderTrainAttributes"
This reverts commit 7777668b86.

Contributes to issue CURA-2795.
2016-12-12 12:54:56 +01:00
Ghostkeeper 02268eb7e8 Revert "Park via E-moves instead of via a retraction"
This reverts commit 6350f47cd6.

Contributes to issue CURA-2795.
2016-12-12 12:54:56 +01:00
Tim Kuipers d2b8c8bf17 Merge pull request #417 from smartavionics/mb-fix-total-filament-report
Reinstate filament used comment for RepRap flavour gcode.
2016-12-12 11:32:58 +01:00
Tim Kuipers d00f5efa77 lil fix: assert used unset extruder_count 2016-12-11 23:12:20 +01:00
Tim Kuipers b8d7162daf lil cast warning fix 2016-12-11 11:56:51 +01:00
Tim Kuipers b0293e2d6a refactor: processSkin ==> processSkinAndPerimeterGaps (CURA-3108) 2016-12-11 11:50:07 +01:00
Tim Kuipers e998eb8899 fix: perform perimeter gaps rounding safety offset only from one side (CURA-3108)
saves computation time
2016-12-11 11:24:01 +01:00
Tim Kuipers 731a69ff86 fix: perimeter gaps offset wasn't used (CURA-3108) 2016-12-11 11:04:49 +01:00
Tim Kuipers d2d34f89d5 lil doc pf planPrime (CURA-3006) 2016-12-10 14:40:58 +01:00
Tim Kuipers 0ad7bd747c fix: extruder was switched without pre-switch code (CURA-3006) 2016-12-10 14:36:13 +01:00
Tim Kuipers 3ad4dbd62e fix: plan a prime at a specified location (CURA-3006) 2016-12-10 14:26:30 +01:00
Tim Kuipers b5c8f95713 safety: assert in Meshgroup::getExtruderTrain (URA-3006) 2016-12-10 13:57:51 +01:00
Tim Kuipers 1590c18041 refactor: make explicit why only GRIFFIN needs to have priming on the initial layer (CURA-3006) 2016-12-10 13:54:25 +01:00
Tim Kuipers 405e8bdd0e fix: properly determine the starting extruder everywhere (CURA-3006) 2016-12-10 13:14:51 +01:00
Tim Kuipers 06c74c3151 lil refactor: initialize FffGcodeWriter members in initializer list (CURA-3006) 2016-12-10 12:40:24 +01:00
Tim Kuipers 28304d1aa9 refactor: compute starting extruder outside of processStartingCode (CURA-3006) 2016-12-10 12:28:27 +01:00
Tim Kuipers a18d61ccb3 refactor: reduced code duplication in Preheat (CURA-3006) 2016-12-10 12:12:51 +01:00
Ghostkeeper 6350f47cd6 Park via E-moves instead of via a retraction
While parking the filament is essentially a retraction, it should not be called this way and therefore we should make an exception for park moves that they do not allow the printer to decide for itself how far to retract the filament.

Contributes to issue CURA-2795.
2016-12-09 16:04:01 +01:00
Ghostkeeper e25a0d1305 Rename near to nearby
Because 'near' is a built-in keyword in the MSVC compiler. You can't use that as a variable name.

Contributes to issue CURA-1112.
2016-12-09 14:06:37 +01:00
Ghostkeeper 31179cab5c Revert "Use std::next instead of incrementing .begin()"
This reverts commit c85146457e.

Contributes to issue CURA-1112.
2016-12-09 14:03:19 +01:00
Ghostkeeper c85146457e Use std::next instead of incrementing .begin()
Hopefully that is allowed by MSVC. Let's see.

Contributes to issue CURA-1112.
2016-12-09 13:41:27 +01:00
Tim Kuipers f1442ba7a5 fix: also add perimeter gaps between the innermost wall and infill/skin (CURA-3108) 2016-12-08 20:24:33 +01:00
Tim Kuipers 33e50f7b05 fix: also do preheating for layers with unretracted moves only (CURA-3006) 2016-12-08 19:35:59 +01:00
Tim Kuipers 865aacbfb1 fix: always prime nozzles on the first layer (CURA-3006) 2016-12-08 19:35:14 +01:00
Tim Kuipers 2bc7ee5df0 feat: prime all nozzles at the end of the first layer (CURA-3006) 2016-12-08 19:34:50 +01:00
Ghostkeeper 7777668b86 Move park distance data to ExtruderTrainAttributes
It was deemed to be more logical there.

Contributes to issue CURA-2795.
2016-12-08 15:35:00 +01:00
Tim Kuipers 96e8c7a73d lil fix: forward declaration of ExtruderPlan for TimeMaterialEstimates (CURA-3006) 2016-12-08 15:30:19 +01:00
Tim Kuipers 89446b8e32 refactor: factor out GCodePath into its own header file (CURA-3006) 2016-12-08 15:27:07 +01:00
Tim Kuipers b2fa8d3be1 refactor: factor out TimeMaterialEstimates into its own .h and .cpp files (CURA-3006) 2016-12-08 15:21:59 +01:00
Tim Kuipers d8e0e84fcc refactor: factor out NozzleTempInsert into its own header file (CURA-3006) 2016-12-08 15:15:30 +01:00
Tim Kuipers 443c630997 Merge branch 'feature_mesh_order' 2016-12-08 15:06:54 +01:00
Tim Kuipers 9831ef3580 lil fix: allow negative bed temperatures (CURA-2781) 2016-12-08 15:05:07 +01:00
Ghostkeeper 460c52ea6c Use optional to denote uninitiated previous extruder temperature
NaN is also a very common pattern, but std::optional is more explicit.

Contributes to issue CURA-2795.
2016-12-08 14:55:15 +01:00
Tim Kuipers 3d1e79c670 lil comment (CURA-2907) 2016-12-08 11:56:21 +01:00
Ghostkeeper 879b86cab9 Also enforce z-distance from the top
This entails a bit slower slicing. How much slower will be determined by a performance test.

Contributes to issue CURA-2907.
2016-12-08 10:17:37 +01:00
Mark Burton 941b1ff1ac Reinstate filament used comment for RepRap flavour gcode. 2016-12-07 14:55:54 +00:00
Ghostkeeper 4263801d16 Correct documentation of extruder_switch parameter
This parameter is only used for firmware-retracting printers.

Contributes to issue CURA-2795.
2016-12-07 15:44:11 +01:00
Ghostkeeper 52220ccab8 Protect writeMoveFilament
It should be used as a helper function only.

Contributes to issue CURA-2795.
2016-12-07 15:41:53 +01:00
Ghostkeeper cb7b7bf22a Use writeMoveFilament to retract to parking distance
This re-uses a bit of code.

Contributes to issue CURA-2795.
2016-12-07 15:40:03 +01:00
Ghostkeeper 7a8be50b8f Pass retraction configs by reference instead of pointer
This makes things a bit safer. It's a const reference, so it should be very easy.

Contributes to issue CURA-2795.
2016-12-07 15:36:52 +01:00
Ghostkeeper 7c39b6b26a Rename writeRetractionMove to writeMoveFilament
I think that is more indicative of what it can do, since it doesn't only concern retractions.

Contributes to issue CURA-2795.
2016-12-07 15:31:40 +01:00
Ghostkeeper a0625aa735 Break retraction in two
One starting point for normal retractions and one to directly move the filament to a certain position.

Contributes to issue CURA-2795.
2016-12-07 15:29:28 +01:00
Ghostkeeper 84d3381be6 Turn extruder temperature off only if it parked the filament
The two had slightly different conditions if the stand-by temperature was zero.

Contributes to issue CURA-2795.
2016-12-07 12:50:49 +01:00
Ghostkeeper 8b01098dd1 Cache prime tower outside polygon
Saves a few polygon unions, since this is the same for each layer anyway.

Contributes to issue CURA-2684.
2016-12-07 11:54:12 +01:00
Ghostkeeper 1bfe4e74d2 Correct height of prime tower to subtract from support
The prime tower has one additional layer on top of the last extruder switch.

Contributes to issue CURA-2684.
2016-12-07 11:49:11 +01:00
Tim Kuipers bcde7f50ee Revert "fix: don't output print temperature in starting code if set to zero (CURA-3101)"
This reverts commit 5db20ee68d.
2016-12-06 16:39:33 +01:00
Tim Kuipers c7cadc132b Revert "fix: don't output print temperature in starting code if set to zero (CURA-3101)"
This reverts commit abfb41006b.
2016-12-06 16:39:12 +01:00
Tim Kuipers abfb41006b fix: don't output print temperature in starting code if set to zero (CURA-3101) 2016-12-06 16:37:35 +01:00
Tim Kuipers 5db20ee68d fix: don't output print temperature in starting code if set to zero (CURA-3101) 2016-12-06 16:36:32 +01:00
Ghostkeeper b0487fa4c7 Use filament park distance setting instead of direct heat & cool zones
The sum of the heat and cool zone lengths is now computed via inheritance in the front-end.

Contributes to issue CURA-2795.
2016-12-06 15:57:39 +01:00
Ghostkeeper b6355b69e7 Restore park distance exception for BFB g-code
Turns out that BFB flavour doesn't have an e-axis, but it still doesn't count as a firmware retract.

Contributes to issue CURA-2795.
2016-12-06 14:58:26 +01:00
Tim Kuipers 9597ee5645 fix: concentric infill always acted as if alternate_extra_perimeter was enabled (CURA-2772) 2016-12-06 14:09:28 +01:00
Tim Kuipers 5ba1cb674e fix: first walls of concentrid 3D infill didn't get added 2016-12-06 13:55:37 +01:00
Tim Kuipers f336d5ffc0 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-12-06 13:03:19 +01:00
Tim Kuipers 1d0ac8528b fix: only ensure unprimed extruders are primed (CURA-3006) 2016-12-06 13:02:35 +01:00
Tim Kuipers 5c06c48c87 small fix: only perform anti-overhang when there is anti-overhang (CURA-3006, CURA-2077) 2016-12-06 13:01:26 +01:00
Tim Kuipers 837d4e7fba feat: tracking of extruder_prime_is_planned (CURA-3006) 2016-12-06 12:59:50 +01:00
Ghostkeeper 7ded01a110 Remove unused prev_extruder parameter
It doesn't need to know which extruder it came from. Just with which extruder to draw the lines. The new_extruder parameter was renamed because there is no need to disambiguate any more.

Contributes to issue CURA-2684.
2016-12-06 11:20:51 +01:00
Ghostkeeper 3f3b526ebd Remove unused storage parameter
It doesn't need to know any settings and the documentation was outdated.

Contributes to issue CURA-2684.
2016-12-06 11:17:28 +01:00
Ghostkeeper b29607b8a9 Remove unused gcode parameter
The results are stored in the gcodeLayer parameter. Has been this way for a while. This was generating compiler warnings. The documentation was already updated, it seems.

Contributes to issue CURA-2684.
2016-12-06 11:15:30 +01:00
Ghostkeeper e641a25aab Subtract prime tower from support after determining prime tower height
There is a circular dependency between prime tower height and support areas. Prime tower height is determined by the highest extruder switch. The highest extruder switch is dependent on the height of support if support is printed with a different exturder. The height of support is dependent on the support areas and the support areas are dependent on the prime tower height. Previously we resolved this by printing no support in the prime tower area and no prime tower, possibly violating the support horizontal expansion in an edge case. Now it is resolved by printing a prime tower there even if there are no extruder switches.

Contributes to issue CURA-2684.
2016-12-06 11:07:10 +01:00
Ghostkeeper b7e9f72023 Remove unused parameter
One of the many. Seems to me that the documentation is outdated if an essential parameter like this one is unused.

Contributes to issue CURA-2795.
2016-12-06 09:44:18 +01:00
Ghostkeeper ab2c2eed4b Correct technicality in documentation
Contributes to issue CURA-2795.
2016-12-06 09:41:40 +01:00
Ghostkeeper 6972101d7e Correct documentation on why the temperature is switched off later
This old code needs to be after the switch, but it was not clear to me why. I tried to make it clear and failed.

Contributes to issue CURA-2795.
2016-12-06 09:40:02 +01:00
Ghostkeeper 3c0d3f1b2d Allow going to stand-by temperature if nozzle is later used
Contributes to issue CURA-2795.
2016-12-06 09:38:08 +01:00
Ghostkeeper bc82fd98c9 Add additional safety check for extruder switching off in later layers
This is never used, but it can't hurt.

Contributes to issue CURA-2795.
2016-12-06 09:32:34 +01:00
Ghostkeeper 6c986e6cfe Update prime speed corresponding to park retraction
We have some double data here, which could lead to asynchronicity. As is evident in my mistake.

Contributes to issue CURA-2795.
2016-12-06 09:30:57 +01:00
Ghostkeeper 36eb3471df Correct retraction speed
Contributes to issue CURA-2795.
2016-12-06 09:24:33 +01:00
Ghostkeeper 4f3b4f429d Expand documentation of writePark
It wasn't clear what retraction limit this function was not adhering to. It is not adhering to the only limit on retraction we currently have: The number of retractions.

Contributes to issue CURA-2795.
2016-12-06 09:10:34 +01:00
Ghostkeeper 837f992f69 Park filament even if printer doesn't support retraction
Let's hope they do support non-increasing E values.

Contributes to issue CURA-2795.
2016-12-06 09:04:07 +01:00
Tim Kuipers ad76736d26 fix: specify starting extruder when adhesion_type==none (CURA-3006, CURA-759) 2016-12-05 17:01:21 +01:00
Tim Kuipers 3fe5a000f2 fix: set extruder back after priming in the first raft layer (CURA-3006) 2016-12-05 17:00:25 +01:00
Ghostkeeper d5a7e2f62e Add documentation of why this union is necessary
Contributes to issue CURA-3017.
2016-12-05 14:23:41 +01:00
Ghostkeeper 6e5315f754 Revert "Also union layer polygons before combing"
This reverts commit 4aff5a1488.
2016-12-05 14:17:22 +01:00
Ghostkeeper 3cb3e5de45 Put filament in parking position when we never use it any more
It should retract before the nozzle switch, of course, so it can't be retracting at the same time as when it's setting the extruder temperature to 0.

Contributes to issue CURA-2795.
2016-12-05 12:04:12 +01:00
Ghostkeeper 80f8760f68 Fix updating current E value
It should be updated before we use it to write the retraction. Also we should subtract the retraction because it is the amount to retract, not the amount to prime.

Contributes to issue CURA-2795.
2016-12-05 12:02:33 +01:00
Ghostkeeper d75882a707 Remove some annoying compile warnings
They are by far not all, but these remove some of the 'unused variable' warnings.

Contributes to issue CURA-2795.
2016-12-05 11:54:51 +01:00
Ghostkeeper 6925f39426 Correct speed of retraction
It should be in millimetres per minute, not millimetres per second. Also, always use the retraction speed.

Contributes to issue CURA-2795.
2016-12-05 11:34:59 +01:00
Tim Kuipers d6cdfefb58 fix: use start_layers_at_same_position to see with which mesh to start a layer (CURA-1112) 2016-12-03 12:43:43 +01:00
Tim Kuipers dfa23feb31 lil optimization vector.reserve (CURA-1112) 2016-12-03 12:26:12 +01:00
Tim Kuipers b0888e4424 refactor: compute mesh order globally (CURA-1112) 2016-12-03 12:25:53 +01:00
Tim Kuipers fd06e10646 fix: calculateMeshOrder now uses a smart path (CURA-1112)
but doesn't yet use the Z seam setting and starts at an arbitrary point in the smart cycle
2016-12-03 12:14:55 +01:00
Tim Kuipers 6e051e0bdc refactor: let OrderOptimizer contain objects of arbitrary type rather than always pointers (CURA-1112) 2016-12-03 12:11:19 +01:00
Ghostkeeper ae00cbe497 Add function to move filament to park position
If the g-code has no control over the retraction distances via G1, it performs a normal retraction instead.

Contributes to issue CURA-2795.
2016-12-02 16:58:13 +01:00
Ghostkeeper 23ef513cce Add park distance information to retraction config
This is the location of the filament when the extruder is parked.

Contributes to issue CURA-2795.
2016-12-02 16:34:19 +01:00
Tim Kuipers 3aa29d898f feat: orderOptimizer (CURA-1112) 2016-12-02 15:22:31 +01:00
Ghostkeeper c9217d4738 Re-use extruder train variable
I moved the definition of the 'train' variable a bit earlier so it can be re-used a bit more often.

Contributes to issue CURA-2795.
2016-12-02 15:05:51 +01:00
Ghostkeeper 16d4ab923f Make support attach directly to prime tower
No X/Y offset is happening. This makes both support and prime tower sturdier, and prevents having to do an offset of the prime tower so it would make the support a bit faster in theory (but the difference is not noticable).

Contributes to issue CURA-2684.
2016-12-02 12:39:05 +01:00
Ghostkeeper 60d4a3108d Don't print support inside hollow prime towers
It only takes the outside of the prime tower ground polygon.

Contributes to issue CURA-2684.
2016-12-02 12:34:59 +01:00
Tim Kuipers 7ad5eee176 indent change only (CURA-1112) 2016-12-02 11:58:38 +01:00
Tim Kuipers 209e9fa50f refactor: separate out FffGcodeWriter::addMeshPartToGCode (CURA-1112) 2016-12-02 11:58:11 +01:00
Ghostkeeper 4aff5a1488 Also union layer polygons before combing
If two polygons overlap, clipperlib can interpret them as one being the inside polygon with the even odd rule. If they overlap exactly, it produces no output. However if you union the polygons it will properly avoid all objects regardless of whether they overlap with other objects.

Contributes to issue CURA-3017.
2016-12-02 11:21:16 +01:00
Ghostkeeper 4f786d5533 Subtract prime tower area from support
At this point we don't know for certain if there will be a prime tower, but that is impossible since there is a circular dependency between prime tower and support then.

Contributes to issue CURA-2684.
2016-12-01 13:10:49 +01:00
Ghostkeeper b4fd72f92f Re-use layer outlines variable
We already had it stored in a variable and the polygons don't change in between, so we can safely re-use this.

Contributes to issue CURA-2684.
2016-12-01 13:10:49 +01:00
Ghostkeeper df892030c5 Only include prime tower if it is enabled
We always generate a ground polygon now, so we can't rely on the ground polygon being empty if it is disabled due to there being no layer switches.

Contributes to issue CURA-2684.
2016-12-01 13:10:49 +01:00
Tim Kuipers e31a516205 fix: ooze/draft shield now processed again (CURA-3077) 2016-12-01 11:57:13 +01:00
Ghostkeeper c77afe06e2 Generate prime tower polygon at construction
This way we can always request the prime tower ground polygon throughout the entire process. The polygon will be empty if prime tower is disabled.

Contributes to issue CURA-2684.
2016-11-30 17:41:41 +01:00
Ghostkeeper 921ffbe659 Merge branch 'feature_z_seam_location' 2016-11-30 16:34:31 +01:00
Ghostkeeper 96ac0758b9 Don't use sqrt in a constexpr
sqrt doesn't return a constexpr. GCC allows it, but Clang doesn't. Instead we just use a preprocessor definition.

Contributes to issue CURA-2602.
2016-11-30 10:44:19 +01:00
Ghostkeeper dd8639b1f5 Use std::abs instead of abs
The clang compiler doesn't define abs outside of the std library.
2016-11-30 10:27:30 +01:00
Ghostkeeper 2572349938 Remove debug prints
These should never have been committed.

Contributes to issue CURA-3017.
2016-11-30 10:09:09 +01:00
Tim Kuipers ac9a053f5b Revert "lil fix: don't compute overhang on first layer"
This reverts commit bec51eb0bd.
2016-11-29 17:19:15 +01:00
Tim Kuipers bec51eb0bd lil fix: don't compute overhang on first layer 2016-11-29 17:17:35 +01:00
Jaime van Kessel 12ccb3512f Merge branch 'feature_recursive_infill_code_review' of github.com:Ultimaker/CuraEngine 2016-11-29 15:42:02 +01:00
Tim Kuipers 87a3a30bc5 fix: open polylines bug
turned back a mistake which was made in a refactor: fa203bd976
2016-11-29 14:32:01 +01:00
Tim Kuipers 6ae41a5e86 fix: max feedrate is in mm/s in both frontend and firmware (CURA-2955)
I've verified that M203 Sxx is interpreted as mm/s in Marlin, Sprinter and Repetier-Firmware.
Other firmware types we support, like MakerBot, BFB and MACH weren't checked.
2016-11-29 13:15:22 +01:00
Ghostkeeper 8ce016064f Fix typo in documentation
The variable name is _dest_point, it seems.

Contributes to issue CURA-2229.
2016-11-28 17:05:51 +01:00
Ghostkeeper 4e16b4313f Fix typo in assert message
Contributes to issue CURA-3008.
2016-11-28 16:55:24 +01:00
Ghostkeeper 5b493c17dc Union first layer polygons for brim too
For skirt it does this union by taking the convex hull. For brim it did no such thing, so when polygons overlapped it would get complex polygons which didn't work out well.

Contributes to issue CURA-3017.
2016-11-28 16:37:28 +01:00
Tim Kuipers 4b45726ada Revert "feat: PolygonPointer as distinct from PolygonRef (CURA-2602)"
This reverts commit a2a8604c72.
2016-11-28 14:42:18 +01:00
Tim Kuipers 6653f5a557 Merge branch 'master' into feature_recursive_infill_code_review 2016-11-28 14:39:53 +01:00
Tim Kuipers 866e911739 fix: make z_seam_pos settable per mesh (CURA-1461) 2016-11-25 16:43:31 +01:00
Tim Kuipers 83a1a09772 fix: merge fix for PathOrderOptimizer in FffGcodeWriter::processSkin (CURA-1461) 2016-11-21 18:48:10 +01:00
Tim Kuipers 2c425421ec Merge branch 'master' into feature_z_seam_location 2016-11-21 18:45:10 +01:00
Tim Kuipers baf6410a1e fix: PolygonUtils::findClosest failed when only the first polygon was empty (CURA-2602) 2016-11-18 16:33:28 +01:00
Tim Kuipers 4634338c7d fix: use PolygonPointer in ClosestPolygonPoint (CURA-2602)
sometimes functions cannot return a ClosestPolygonPoint, or we start with an empty one untill we find any point
2016-11-18 16:32:56 +01:00
Tim Kuipers a2a8604c72 feat: PolygonPointer as distinct from PolygonRef (CURA-2602)
It was a bad idea to change PolygonRef into PolygonPointer, because then we'd have to check whether it is a nullptr all over the engine...
2016-11-18 16:30:34 +01:00
Tim Kuipers 40a6075022 Merge branch 'master' into feature_recursive_infill_code_review 2016-11-18 13:55:06 +01:00
Tim Kuipers c57ab7d090 fix: getSettingInMicrons should return coord_t, rather than int! (CURA-2602) 2016-11-16 15:25:12 +01:00
Tim Kuipers bd5a82dd86 refactor: split up SubDivCube::generateSubdivisionLines into two functions (CURA-2602)
one public base class function, one private recursive function.
Instead of using a heap-allocated array of pointers to Polygons, just use a stack-allocated array of Polygons
2016-11-16 15:14:16 +01:00
Tim Kuipers 942d409d72 lil refactor: moved constant expression inside function where it's used (CURA-2602) 2016-11-16 14:56:48 +01:00
Tim Kuipers a17d3017b5 lil simplification and reduction of rounding errors (CURA-2602) 2016-11-16 14:35:35 +01:00
Tim Kuipers b79f605ce2 fix: made Polygons::remove be O(1) (CURA-2602)
The order of polygons is never important, except in PolygonsPart where the first polygon is the outer one, but there it should be impossible to remove the first element anyway.
2016-11-16 14:22:45 +01:00
Tim Kuipers ea1c9b80e9 refactor: make private function of SubDivCube::addLineAndCombine (CURA-2602) 2016-11-16 14:21:10 +01:00
Tim Kuipers 1d86f54a8b lil refactor 2016-11-16 13:59:14 +01:00
Tim Kuipers fc909ff3ad fix: subdivcube: max_side_length based on machine dimensions (CURA-2602) 2016-11-16 13:56:41 +01:00
Tim Kuipers 7f54037246 refactor: merged cube properties into one vector of ew struct (CURA-2602) 2016-11-16 13:36:08 +01:00
Tim Kuipers ec7164004e refactor: factored addLine into Polygons class (CURA-2602) 2016-11-16 13:22:28 +01:00
Tim Kuipers a6314a9f80 lil improvements (CURA-2602) 2016-11-16 12:57:09 +01:00
Tim Kuipers 1207291950 rename: src/infill/subDivCube.cpp ==> src/infill/SubDivCube.cpp (CURA-2602) 2016-11-16 12:47:47 +01:00
Tim Kuipers 384071aaeb feat: z seam position (CURA-1461) 2016-11-11 12:02:46 +01:00
mboerwinkle 4b6f672e56 Merge pull request #2 from Ultimaker/feature_recursive_infill_BagelOrb
Some small optimizations and cleanup
2016-11-06 18:23:13 -06:00
Tim Kuipers 6760f38663 fix: properly clean up SubDivCube 2016-10-31 18:51:24 +01:00
Tim Kuipers b1cc8e5abf small optimization: squared distance rather than absolute distance 2016-10-31 18:31:35 +01:00
Tim Kuipers 89d274dfc0 --amend 2016-10-31 18:18:36 +01:00
Tim Kuipers dde776bde7 removed code duplication in SubDivCube constructor 2016-10-31 16:24:12 +01:00
Tim Kuipers edd2c796e1 introduced 3d matrix for 3d rotation 2016-10-31 16:23:19 +01:00
Tim Kuipers 07c64b9361 simplified some math 2016-10-31 16:22:36 +01:00
Tim Kuipers 48b479b675 fix of merge conflict 2016-10-27 23:19:33 +02:00
Tim Kuipers d39a82d13f Merge remote-tracking branch 'mboerwinkle/master' into feature_recursive_infill_BagelOrb 2016-10-27 23:18:39 +02:00
Tim Kuipers 08844ff8d3 Merge branch 'feature_recursive_infill' into feature_recursive_infill_BagelOrb 2016-10-27 23:16:47 +02:00
Tim Kuipers 5f0a844df3 refactor: better naming 2016-10-27 23:14:08 +02:00
Tim Kuipers 2ea58fe795 cleanup: code conventions etc; no more extern SubDivCube 2016-10-27 23:13:12 +02:00
mboerwinkle ed5a0c03c8 Merge pull request #1 from Ultimaker/feature_recursive_infill_BagelOrb
My proposed changes to your PR
2016-10-24 13:48:54 -05:00
Tim Kuipers a954d88d77 feat: cubic subdivision settings 2016-10-21 14:12:57 +02:00
Tim Kuipers d301a8f535 fix: no more memory leak for base_subdiv_cube
destroy it when instantiated and mesh slice data is deleted
2016-10-21 13:56:54 +02:00
Tim Kuipers 8ac14dc725 fix: no more memory leak for base_subdiv_cube
destroy it when instantiated and mesh slice data is deleted
2016-10-21 13:24:50 +02:00
Tim Kuipers 7d4ac28bd2 fix: generate SubDivCube per mesh
There used to be one global SubDivCube which would get reset for each mesh on the build plate.

Also resetting without deleting the object leads to memory loss.
2016-10-21 13:19:17 +02:00
Tim Kuipers f8ea0150fc Merge branch 'master' of https://github.com/mboerwinkle/CuraEngine into feature_recursive_infill 2016-10-21 12:41:33 +02:00
mboerwinkle 06c3729d51 cleaned up a few more things 2016-10-14 14:48:06 +00:00
mboerwinkle 6af4faef1f fixed my editing of CPackConfig.cmake 2016-10-14 04:16:01 +00:00
mboerwinkle 593f3ae353 Merge branch 'master' of git://github.com/Ultimaker/CuraEngine 2016-10-14 04:05:03 +00:00
mboerwinkle 3e0811fdb7 Cleaned up everything best I could! 2016-10-14 03:51:05 +00:00
mboerwinkle 7f31e39ee3 cleaned up the code 2016-10-14 03:37:00 +00:00
mboerwinkle ed5ed001b9 utils/polygon.h looks good. infill.h and .cpp look good. infill/subDivCube.h looks good. Only infill/subDivCube.cpp left to fix. 2016-10-14 02:00:44 +00:00
mboerwinkle f8f14f3968 did some work on bringing my code style up to standards 2016-10-14 01:18:52 +00:00
Tim Kuipers dc41117078 Merge branch 'master' into feature_recursive_infill 2016-10-11 13:30:24 +02:00
mboerwinkle c339dbc8ae added subdivcube infill 2016-10-10 17:13:29 +00:00
57 arquivos alterados com 1867 adições e 643 exclusões
+14
Ver Arquivo
@@ -42,6 +42,16 @@ if(NOT APPLE AND NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
endif()
option (ENABLE_OPENMP
"Use OpenMP for parallel code" ON)
if (ENABLE_OPENMP)
FIND_PACKAGE( OpenMP )
if( OPENMP_FOUND )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
endif()
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR} libs)
add_library(clipper STATIC libs/clipper/clipper.cpp)
@@ -85,9 +95,13 @@ set(engine_SRCS # Except main.cpp.
src/infill/ZigzagConnectorProcessorDisconnectedEndPieces.cpp
src/infill/ZigzagConnectorProcessorEndPieces.cpp
src/infill/ZigzagConnectorProcessorNoEndPieces.cpp
src/infill/SubDivCube.cpp
src/pathPlanning/Comb.cpp
src/pathPlanning/GCodePath.cpp
src/pathPlanning/LinePolygonsCrossings.cpp
src/pathPlanning/NozzleTempInsert.cpp
src/pathPlanning/TimeMaterialEstimates.cpp
src/progress/Progress.cpp
src/progress/ProgressStageEstimator.cpp
+1 -1
Ver Arquivo
@@ -44,7 +44,7 @@
//#define use_xyz
//use_lines: Enables line clipping. Adds a very minor cost to performance.
//#define use_lines
#define use_lines
//use_deprecated: Enables temporary support for the obsolete functions
//#define use_deprecated
+267 -114
Ver Arquivo
@@ -6,6 +6,7 @@
#include "FffProcessor.h"
#include "progress/Progress.h"
#include "wallOverlap.h"
#include "utils/orderOptimizer.h"
namespace cura
{
@@ -18,13 +19,13 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
if (FffProcessor::getInstance()->getMeshgroupNr() == 0)
{ // first meshgroup
gcode.resetTotalPrintTimeAndFilament();
gcode.setInitialTemps(*storage.meshgroup);
gcode.setInitialTemps(*storage.meshgroup, getStartExtruder(storage));
}
// set the initial extruder of this meshgroup
if (FffProcessor::getInstance()->getMeshgroupNr() == 0)
{ // first meshgroup
current_extruder_planned = getSettingAsIndex("adhesion_extruder_nr");
current_extruder_planned = getStartExtruder(storage);
}
else
{
@@ -54,7 +55,8 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
if (FffProcessor::getInstance()->getMeshgroupNr() == 0)
{
processStartingCode(storage);
unsigned int start_extruder_nr = getStartExtruder(storage);
processStartingCode(storage, start_extruder_nr);
}
else
{
@@ -80,6 +82,15 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
}
}
{ // calculate the mesh order for each extruder
int extruder_count = storage.meshgroup->getExtruderCount();
mesh_order_per_extruder.reserve(extruder_count);
for (int extruder_nr = 0; extruder_nr < extruder_count; extruder_nr++)
{
mesh_order_per_extruder.push_back(calculateMeshOrder(storage, extruder_nr));
}
}
for(unsigned int layer_nr=0; layer_nr<total_layers; layer_nr++)
{
processLayer(storage, layer_nr, total_layers);
@@ -93,7 +104,7 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
layer_plan_buffer.flush();
constexpr bool force = true;
gcode.writeRetraction(&storage.retraction_config_per_extruder[gcode.getExtruderNr()], force); // retract after finishing each meshgroup
gcode.writeRetraction(storage.retraction_config_per_extruder[gcode.getExtruderNr()], force); // retract after finishing each meshgroup
}
void FffGcodeWriter::setConfigFanSpeedLayerTime(SliceDataStorage& storage)
@@ -183,7 +194,17 @@ void FffGcodeWriter::initConfigs(SliceDataStorage& storage)
mesh.inset0_config.init(mesh.getSettingInMillimetersPerSecond("speed_wall_0"), mesh.getSettingInMillimetersPerSecond("acceleration_wall_0"), mesh.getSettingInMillimetersPerSecond("jerk_wall_0"), mesh.getSettingInMicrons("wall_line_width_0"), mesh.getSettingInPercentage("material_flow"));
mesh.insetX_config.init(mesh.getSettingInMillimetersPerSecond("speed_wall_x"), mesh.getSettingInMillimetersPerSecond("acceleration_wall_x"), mesh.getSettingInMillimetersPerSecond("jerk_wall_x"), mesh.getSettingInMicrons("wall_line_width_x"), mesh.getSettingInPercentage("material_flow"));
mesh.skin_config.init(mesh.getSettingInMillimetersPerSecond("speed_topbottom"), mesh.getSettingInMillimetersPerSecond("acceleration_topbottom"), mesh.getSettingInMillimetersPerSecond("jerk_topbottom"), mesh.getSettingInMicrons("skin_line_width"), mesh.getSettingInPercentage("material_flow"));
// The perimeter gap config follows the skin config, but has a different line width:
// wall_line_width_x divided by two because the gaps are between 0 and 1 times the wall line width
const int perimeter_gaps_line_width = mesh.getSettingInMicrons("wall_line_width_x") / 2;
double perimeter_gaps_speed = mesh.getSettingInMillimetersPerSecond("speed_topbottom");
if (mesh.getSettingBoolean("speed_equalize_flow_enabled"))
{
perimeter_gaps_speed = perimeter_gaps_speed * mesh.getSettingInMicrons("skin_line_width") / perimeter_gaps_line_width;
}
mesh.perimeter_gap_config.init(perimeter_gaps_speed, mesh.getSettingInMillimetersPerSecond("acceleration_topbottom"), mesh.getSettingInMillimetersPerSecond("jerk_topbottom"), perimeter_gaps_line_width, mesh.getSettingInPercentage("material_flow"));
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
{
mesh.infill_config[idx].init(mesh.getSettingInMillimetersPerSecond("speed_infill"), mesh.getSettingInMillimetersPerSecond("acceleration_infill"), mesh.getSettingInMillimetersPerSecond("jerk_infill"), mesh.getSettingInMicrons("infill_line_width") * (idx + 1), mesh.getSettingInPercentage("material_flow"));
@@ -193,7 +214,26 @@ void FffGcodeWriter::initConfigs(SliceDataStorage& storage)
storage.primeTower.initConfigs(storage.meshgroup);
}
void FffGcodeWriter::processStartingCode(SliceDataStorage& storage)
unsigned int FffGcodeWriter::getStartExtruder(SliceDataStorage& storage)
{
int start_extruder_nr = getSettingAsIndex("adhesion_extruder_nr");
if (getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::NONE)
{
std::vector<bool> extruder_is_used = storage.getExtrudersUsed();
for (unsigned int extruder_nr = 0; extruder_nr < extruder_is_used.size(); extruder_nr++)
{
start_extruder_nr = extruder_nr;
if (extruder_is_used[extruder_nr])
{
break;
}
}
}
assert(start_extruder_nr >= 0 && start_extruder_nr < storage.meshgroup->getExtruderCount() && "start_extruder_nr must be a valid extruder");
return start_extruder_nr;
}
void FffGcodeWriter::processStartingCode(SliceDataStorage& storage, const unsigned int start_extruder_nr)
{
if (!CommandSocket::isInstantiated())
{
@@ -201,15 +241,13 @@ void FffGcodeWriter::processStartingCode(SliceDataStorage& storage)
gcode.writeCode(prefix.c_str());
}
int start_extruder_nr = getSettingAsIndex("adhesion_extruder_nr");
gcode.writeComment("Generated with Cura_SteamEngine " VERSION);
if (gcode.getFlavor() != EGCodeFlavor::ULTIGCODE && gcode.getFlavor() != EGCodeFlavor::GRIFFIN)
{
if (getSettingBoolean("material_bed_temp_prepend"))
{
if (getSettingBoolean("machine_heated_bed") && getSettingInDegreeCelsius("material_bed_temperature_layer_0") > 0)
if (getSettingBoolean("machine_heated_bed") && getSettingInDegreeCelsius("material_bed_temperature_layer_0") != 0)
{
gcode.writeBedTemperatureCommand(getSettingInDegreeCelsius("material_bed_temperature_layer_0"), getSettingBoolean("material_bed_temp_wait"));
}
@@ -257,8 +295,9 @@ void FffGcodeWriter::processStartingCode(SliceDataStorage& storage)
double print_temp_here = (print_temp_0 != 0)? print_temp_0 : train.getSettingInDegreeCelsius("material_print_temperature");
gcode.writeTemperatureCommand(start_extruder_nr, print_temp_here, wait);
gcode.writePrimeTrain(train.getSettingInMillimetersPerSecond("speed_travel"));
extruder_prime_is_planned[start_extruder_nr] = true;
RetractionConfig& retraction_config = storage.retraction_config_per_extruder[start_extruder_nr];
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
}
}
@@ -315,10 +354,8 @@ void FffGcodeWriter::processRaft(SliceDataStorage& storage, unsigned int total_l
GCodePlanner& gcode_layer = layer_plan_buffer.emplace_back(storage, layer_nr, z, layer_height, last_position_planned, current_extruder_planned, is_inside_mesh_layer_part, fan_speed_layer_time_settings_per_extruder, combing_mode, comb_offset, train->getSettingBoolean("travel_avoid_other_parts"), train->getSettingInMicrons("travel_avoid_distance"));
gcode_layer.setIsInside(true);
if (getSettingAsIndex("adhesion_extruder_nr") > 0)
{
gcode_layer.setExtruder(extruder_nr);
}
gcode_layer.setExtruder(extruder_nr);
if (CommandSocket::isInstantiated())
{
CommandSocket::getInstance()->sendOptimizedLayerInfo(layer_nr, z, layer_height);
@@ -333,12 +370,15 @@ void FffGcodeWriter::processRaft(SliceDataStorage& storage, unsigned int total_l
infill_comp.generate(raft_polygons, raftLines);
gcode_layer.addLinesByOptimizer(raftLines, &storage.raft_base_config, SpaceFillType::Lines);
if (getExtrudersNeedPrimeDuringFirstLayer())
{
ensureAllExtrudersArePrimed(storage, gcode_layer, layer_nr);
}
last_position_planned = gcode_layer.getLastPosition();
current_extruder_planned = gcode_layer.getExtruder();
is_inside_mesh_layer_part = gcode_layer.getIsInsideMesh();
ensureAllExtrudersArePrimed(storage, gcode_layer, layer_nr);
gcode_layer.processFanSpeedAndMinimalLayerTime();
gcode_layer.overrideFanSpeeds(train->getSettingInPercentage("raft_base_fan_speed"));
}
@@ -351,11 +391,13 @@ void FffGcodeWriter::processRaft(SliceDataStorage& storage, unsigned int total_l
GCodePlanner& gcode_layer = layer_plan_buffer.emplace_back(storage, layer_nr, z, layer_height, last_position_planned, current_extruder_planned, is_inside_mesh_layer_part, fan_speed_layer_time_settings_per_extruder, combing_mode, comb_offset, train->getSettingBoolean("travel_avoid_other_parts"), train->getSettingInMicrons("travel_avoid_distance"));
gcode_layer.setIsInside(true);
gcode_layer.setExtruder(extruder_nr); // reset to extruder number, because we might have primed in the last layer
if (CommandSocket::isInstantiated())
{
CommandSocket::getInstance()->sendOptimizedLayerInfo(layer_nr, z, layer_height);
}
Polygons raftLines;
int offset_from_poly_outline = 0;
double fill_angle = train->getSettingAsCount("raft_surface_layers") > 0 ? 45 : 90;
@@ -438,7 +480,7 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
}
bool avoid_other_parts = false;
int avoid_distance = 0; // minimal avoid distance is zero
coord_t avoid_distance = 0; // minimal avoid distance is zero
for (int extr_nr = 0; extr_nr < storage.meshgroup->getExtruderCount(); extr_nr++)
{
if (gcode.getExtruderIsUsed(extr_nr))
@@ -453,7 +495,7 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
}
}
int max_inner_wall_width = 0;
coord_t max_inner_wall_width = 0;
for (SettingsBaseVirtual& mesh_settings : storage.meshes)
{
max_inner_wall_width = std::max(max_inner_wall_width, mesh_settings.getSettingInMicrons((mesh_settings.getSettingAsCount("wall_line_count") > 1) ? "wall_line_width_x" : "wall_line_width_0"));
@@ -466,18 +508,22 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
if (include_helper_parts && layer_nr == 0)
{ // process the skirt or the brim of the starting extruder.
int extruder_nr = getSettingAsIndex("adhesion_extruder_nr");
int extruder_nr = gcode_layer.getExtruder();
if (storage.skirt_brim[extruder_nr].size() > 0)
{
gcode_layer.setExtruder(extruder_nr);
processSkirtBrim(storage, gcode_layer, extruder_nr);
}
}
if (include_helper_parts)
{ // handle shield(s) first in a layer so that chances are higher that the other nozzle is wiped (for the ooze shield)
processOozeShield(storage, gcode_layer, std::max(0, layer_nr));
processDraftShield(storage, gcode_layer, std::max(0, layer_nr));
}
int support_skin_extruder_nr = getSettingAsIndex("support_interface_extruder_nr");
int support_infill_extruder_nr = (layer_nr <= 0)? getSettingAsIndex("support_extruder_nr_layer_0") : getSettingAsIndex("support_infill_extruder_nr");
//Figure out in which order to print the meshes, do this by looking at the current extruder and preferer the meshes that use that extruder.
std::vector<int> extruder_order = calculateExtruderOrder(storage, gcode_layer.getExtruder());
for (int extruder_nr : extruder_order)
{
@@ -489,9 +535,36 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
if (layer_nr >= 0)
{
std::vector<unsigned int> mesh_order = calculateMeshOrder(storage, extruder_nr);
for (unsigned int mesh_idx : mesh_order)
std::vector<unsigned int>& mesh_order = mesh_order_per_extruder[extruder_nr];
unsigned int mesh_order_idx_starting_mesh = 0;
{ // calculate mesh_order_idx_starting_mesh
Point layer_start_position = last_position_planned;
if (storage.getSettingBoolean("start_layers_at_same_position"))
{
layer_start_position = Point(storage.getSettingInMicrons("layer_start_x"), storage.getSettingInMicrons("layer_start_y"));
}
coord_t best_dist2 = std::numeric_limits<coord_t>::max();
for (unsigned int mesh_order_idx = 0; mesh_order_idx < mesh_order.size(); mesh_order_idx++)
{
unsigned int mesh_idx = mesh_order[mesh_order_idx];
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
for (SliceLayerPart& part : mesh.layers[layer_nr].parts)
{
Point middle = (part.boundaryBox.min + part.boundaryBox.max) / 2;
coord_t dist2 = vSize2(middle - layer_start_position);
if (dist2 < best_dist2)
{
best_dist2 = dist2;
mesh_order_idx_starting_mesh = mesh_order_idx;
}
}
}
}
for (unsigned int mesh_iterator_idx = 0; mesh_iterator_idx < mesh_order.size(); mesh_iterator_idx++)
{
unsigned int mesh_order_idx = (mesh_iterator_idx + mesh_order_idx_starting_mesh) % mesh_order.size();
unsigned int mesh_idx = mesh_order[mesh_order_idx];
SliceMeshStorage* mesh = &storage.meshes[mesh_idx];
if (mesh->getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE)
{
@@ -505,7 +578,7 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
}
}
if (include_helper_parts && layer_nr == 0)
if (layer_nr == 0 && getExtrudersNeedPrimeDuringFirstLayer())
{
ensureAllExtrudersArePrimed(storage, gcode_layer, layer_nr);
}
@@ -524,13 +597,26 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
gcode_layer.processFanSpeedAndMinimalLayerTime();
}
bool FffGcodeWriter::getExtrudersNeedPrimeDuringFirstLayer()
{
switch(gcode.getFlavor())
{
case EGCodeFlavor::GRIFFIN:
return true;
default:
return false; // TODO: change this once priming for other firmware types is implemented
}
}
void FffGcodeWriter::ensureAllExtrudersArePrimed(SliceDataStorage& storage, GCodePlanner& gcode_layer, const int layer_nr)
{
//Add skirt for all extruders which haven't primed the skirt or brim yet.
// Add prime for all extruders which haven't primed yet.
std::vector<bool> extruder_is_used = storage.getExtrudersUsed();
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); extruder_nr++)
{
if (gcode.getExtruderIsUsed(extruder_nr) && !skirt_brim_is_processed[extruder_nr])
{
if (extruder_is_used[extruder_nr] && !extruder_prime_is_planned[extruder_nr])
{ // prime before the current gcode layer plan is written to gcode
setExtruder_addPrime(storage, gcode_layer, layer_nr, extruder_nr);
}
}
@@ -613,15 +699,26 @@ std::vector<int> FffGcodeWriter::calculateExtruderOrder(SliceDataStorage& storag
std::vector<unsigned int> FffGcodeWriter::calculateMeshOrder(SliceDataStorage& storage, int extruder_nr)
{
std::vector<unsigned int> ret;
OrderOptimizer<unsigned int> mesh_idx_order_optimizer;
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
if (mesh.getSettingAsIndex("extruder_nr") == extruder_nr)
{
ret.push_back(mesh_idx);
Mesh& mesh_data = storage.meshgroup->meshes[mesh_idx];
Point3 middle = (mesh_data.getAABB().min + mesh_data.getAABB().max) / 2;
mesh_idx_order_optimizer.addItem(Point(middle.x, middle.y), mesh_idx);
}
}
std::list<unsigned int> mesh_indices_order = mesh_idx_order_optimizer.optimize();
std::vector<unsigned int> ret;
ret.reserve(mesh_indices_order.size());
for (unsigned int mesh_order_idx : mesh_indices_order)
{
const unsigned int mesh_idx = mesh_idx_order_optimizer.items[mesh_order_idx].second;
ret.push_back(mesh_idx);
}
return ret;
}
@@ -651,7 +748,8 @@ void FffGcodeWriter::addMeshLayerToGCode_meshSurfaceMode(SliceDataStorage& stora
}
EZSeamType z_seam_type = mesh->getSettingAsZSeamType("z_seam_type");
gcode_layer.addPolygonsByOptimizer(polygons, &mesh->inset0_config, nullptr, z_seam_type, mesh->getSettingInMicrons("wall_0_wipe_dist"), mesh->getSettingBoolean("magic_spiralize"));
Point z_seam_pos(mesh->getSettingInMicrons("z_seam_x"), mesh->getSettingInMicrons("z_seam_y"));
gcode_layer.addPolygonsByOptimizer(polygons, &mesh->inset0_config, nullptr, z_seam_type, z_seam_pos, mesh->getSettingInMicrons("wall_0_wipe_dist"), mesh->getSettingBoolean("magic_spiralize"));
addMeshOpenPolyLinesToGCode(storage, mesh, gcode_layer, layer_nr);
}
@@ -716,73 +814,23 @@ void FffGcodeWriter::addMeshLayerToGCode(SliceDataStorage& storage, SliceMeshSto
setExtruder_addPrime(storage, gcode_layer, layer_nr, mesh->getSettingAsIndex("extruder_nr"));
EZSeamType z_seam_type = mesh->getSettingAsZSeamType("z_seam_type");
Point z_seam_pos(mesh->getSettingInMicrons("z_seam_x"), mesh->getSettingInMicrons("z_seam_y"));
Point layer_start_position = last_position_planned;
if (storage.getSettingBoolean("start_layers_at_same_position"))
{
layer_start_position = Point(storage.getSettingInMicrons("layer_start_x"), storage.getSettingInMicrons("layer_start_y"));
}
PathOrderOptimizer part_order_optimizer(layer_start_position, z_seam_type);
PathOrderOptimizer part_order_optimizer(layer_start_position, z_seam_pos, z_seam_type);
for(unsigned int partNr=0; partNr<layer->parts.size(); partNr++)
{
part_order_optimizer.addPolygon(layer->parts[partNr].insets[0][0]);
}
part_order_optimizer.optimize();
bool skin_alternate_rotation = mesh->getSettingBoolean("skin_alternate_rotation") && ( mesh->getSettingAsCount("top_layers") >= 4 || mesh->getSettingAsCount("bottom_layers") >= 4 );
for(int order_idx : part_order_optimizer.polyOrder)
for (int part_idx : part_order_optimizer.polyOrder)
{
SliceLayerPart& part = layer->parts[order_idx];
EFillMethod infill_pattern = mesh->getSettingAsFillMethod("infill_pattern");
int infill_angle = 45;
if ((infill_pattern == EFillMethod::LINES || infill_pattern == EFillMethod::ZIG_ZAG))
{
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh->getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), 1)));
if ((layer_nr / combined_infill_layers) & 1)
{ // switch every [combined_infill_layers] layers
infill_angle += 90;
}
}
int infill_line_distance = mesh->getSettingInMicrons("infill_line_distance");
int infill_overlap = mesh->getSettingInMicrons("infill_overlap_mm");
gcode_layer.setIsInside(true); // going to print inside stuff below
if (mesh->getSettingBoolean("infill_before_walls"))
{
processMultiLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
processSingleLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
}
processInsets(gcode_layer, mesh, part, layer_nr, z_seam_type);
if (!mesh->getSettingBoolean("infill_before_walls"))
{
processMultiLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
processSingleLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
}
EFillMethod skin_pattern = mesh->getSettingAsFillMethod("top_bottom_pattern");
int skin_angle = 45;
if ((skin_pattern == EFillMethod::LINES || skin_pattern == EFillMethod::ZIG_ZAG) && layer_nr & 1)
{
skin_angle += 90; // should coincide with infill_angle (if both skin and infill are lines) so that the first top layer is orthogonal to the last infill layer
}
if (skin_alternate_rotation && ( layer_nr / 2 ) & 1)
skin_angle -= 45;
int64_t skin_overlap = mesh->getSettingInMicrons("skin_overlap_mm");
processSkin(gcode_layer, mesh, part, layer_nr, skin_overlap, skin_angle);
//After a layer part, make sure the nozzle is inside the comb boundary, so we do not retract on the perimeter.
if (!mesh->getSettingBoolean("magic_spiralize") || static_cast<int>(layer_nr) < mesh->getSettingAsCount("bottom_layers"))
{
gcode_layer.moveInsideCombBoundary(mesh->getSettingInMicrons((mesh->getSettingAsCount("wall_line_count") > 1) ? "wall_line_width_x" : "wall_line_width_0") * 1);
}
gcode_layer.setIsInside(false);
SliceLayerPart& part = layer->parts[part_idx];
addMeshPartToGCode(storage, mesh, part, gcode_layer, layer_nr);
}
if (mesh->getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
{
@@ -790,6 +838,64 @@ void FffGcodeWriter::addMeshLayerToGCode(SliceDataStorage& storage, SliceMeshSto
}
}
void FffGcodeWriter::addMeshPartToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, SliceLayerPart& part, GCodePlanner& gcode_layer, int layer_nr)
{
bool skin_alternate_rotation = mesh->getSettingBoolean("skin_alternate_rotation") && ( mesh->getSettingAsCount("top_layers") >= 4 || mesh->getSettingAsCount("bottom_layers") >= 4 );
EFillMethod infill_pattern = mesh->getSettingAsFillMethod("infill_pattern");
int infill_angle = 45;
if ((infill_pattern == EFillMethod::LINES || infill_pattern == EFillMethod::ZIG_ZAG))
{
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh->getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), (coord_t)1)));
if ((layer_nr / combined_infill_layers) & 1)
{ // switch every [combined_infill_layers] layers
infill_angle += 90;
}
}
int infill_line_distance = mesh->getSettingInMicrons("infill_line_distance");
int infill_overlap = mesh->getSettingInMicrons("infill_overlap_mm");
gcode_layer.setIsInside(true); // going to print inside stuff below
if (mesh->getSettingBoolean("infill_before_walls"))
{
processMultiLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
processSingleLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
}
EZSeamType z_seam_type = mesh->getSettingAsZSeamType("z_seam_type");
Point z_seam_pos(mesh->getSettingInMicrons("z_seam_x"), mesh->getSettingInMicrons("z_seam_y"));
processInsets(gcode_layer, mesh, part, layer_nr, z_seam_type, z_seam_pos);
if (!mesh->getSettingBoolean("infill_before_walls"))
{
processMultiLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
processSingleLayerInfill(gcode_layer, mesh, part, layer_nr, infill_line_distance, infill_overlap, infill_angle);
}
EFillMethod skin_pattern = (layer_nr == 0)?
mesh->getSettingAsFillMethod("top_bottom_pattern_0") :
mesh->getSettingAsFillMethod("top_bottom_pattern");
int skin_angle = 45;
if ((skin_pattern == EFillMethod::LINES || skin_pattern == EFillMethod::ZIG_ZAG) && layer_nr & 1)
{
skin_angle += 90; // should coincide with infill_angle (if both skin and infill are lines) so that the first top layer is orthogonal to the last infill layer
}
if (skin_alternate_rotation && ( layer_nr / 2 ) & 1)
skin_angle -= 45;
int64_t skin_overlap = mesh->getSettingInMicrons("skin_overlap_mm");
processSkinAndPerimeterGaps(gcode_layer, mesh, part, layer_nr, skin_overlap, skin_angle);
//After a layer part, make sure the nozzle is inside the comb boundary, so we do not retract on the perimeter.
if (!mesh->getSettingBoolean("magic_spiralize") || static_cast<int>(layer_nr) < mesh->getSettingAsCount("bottom_layers"))
{
gcode_layer.moveInsideCombBoundary(mesh->getSettingInMicrons((mesh->getSettingAsCount("wall_line_count") > 1) ? "wall_line_width_x" : "wall_line_width_0") * 1);
}
gcode_layer.setIsInside(false);
}
@@ -817,7 +923,7 @@ void FffGcodeWriter::processMultiLayerInfill(GCodePlanner& gcode_layer, SliceMes
}
Infill infill_comp(infill_pattern, part.infill_area_per_combine_per_density[density_idx][combine_idx], 0, infill_line_width, infill_line_distance_here, infill_overlap, infill_angle, z, infill_shift);
infill_comp.generate(infill_polygons, infill_lines);
infill_comp.generate(infill_polygons, infill_lines, mesh);
}
gcode_layer.addPolygonsByOptimizer(infill_polygons, &mesh->infill_config[combine_idx]);
gcode_layer.addLinesByOptimizer(infill_lines, &mesh->infill_config[combine_idx], (infill_pattern == EFillMethod::ZIG_ZAG)? SpaceFillType::PolyLines : SpaceFillType::Lines);
@@ -873,7 +979,7 @@ void FffGcodeWriter::processSingleLayerInfill(GCodePlanner& gcode_layer, SliceMe
infill_line_distance_here /= 2;
}
Infill infill_comp(pattern, part.infill_area_per_combine_per_density[density_idx][0], 0, infill_line_width, infill_line_distance_here, infill_overlap, infill_angle, z, infill_shift);
infill_comp.generate(infill_polygons, infill_lines);
infill_comp.generate(infill_polygons, infill_lines, mesh);
}
gcode_layer.addPolygonsByOptimizer(infill_polygons, &mesh->infill_config[0]);
if (pattern == EFillMethod::GRID || pattern == EFillMethod::LINES || pattern == EFillMethod::TRIANGLES)
@@ -886,7 +992,7 @@ void FffGcodeWriter::processSingleLayerInfill(GCodePlanner& gcode_layer, SliceMe
}
}
void FffGcodeWriter::processInsets(GCodePlanner& gcode_layer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type)
void FffGcodeWriter::processInsets(GCodePlanner& gcode_layer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type, Point z_seam_pos)
{
bool compensate_overlap_0 = mesh->getSettingBoolean("travel_compensate_overlapping_walls_0_enabled");
bool compensate_overlap_x = mesh->getSettingBoolean("travel_compensate_overlapping_walls_x_enabled");
@@ -901,7 +1007,9 @@ void FffGcodeWriter::processInsets(GCodePlanner& gcode_layer, SliceMeshStorage*
}
if (static_cast<int>(layer_nr) == mesh->getSettingAsCount("bottom_layers") && part.insets.size() > 0)
{ // on the last normal layer first make the outer wall normally and then start a second outer wall from the same hight, but gradually moving upward
gcode_layer.addPolygonsByOptimizer(part.insets[0], &mesh->insetX_config, nullptr, EZSeamType::SHORTEST, mesh->getSettingInMicrons("wall_0_wipe_dist"), false);
WallOverlapComputation* wall_overlap_computation(nullptr);
int wall_0_wipe_dist(0);
gcode_layer.addPolygonsByOptimizer(part.insets[0], &mesh->insetX_config, wall_overlap_computation, EZSeamType::SHORTEST, z_seam_pos, wall_0_wipe_dist, spiralize);
}
}
int processed_inset_number = -1;
@@ -916,13 +1024,14 @@ void FffGcodeWriter::processInsets(GCodePlanner& gcode_layer, SliceMeshStorage*
{
if (!compensate_overlap_0)
{
gcode_layer.addPolygonsByOptimizer(part.insets[0], &mesh->inset0_config, nullptr, z_seam_type, mesh->getSettingInMicrons("wall_0_wipe_dist"), spiralize);
WallOverlapComputation* wall_overlap_computation(nullptr);
gcode_layer.addPolygonsByOptimizer(part.insets[0], &mesh->inset0_config, wall_overlap_computation, z_seam_type, z_seam_pos, mesh->getSettingInMicrons("wall_0_wipe_dist"), spiralize);
}
else
{
Polygons& outer_wall = part.insets[0];
WallOverlapComputation wall_overlap_computation(outer_wall, mesh->getSettingInMicrons("wall_line_width_0"));
gcode_layer.addPolygonsByOptimizer(outer_wall, &mesh->inset0_config, &wall_overlap_computation, z_seam_type, mesh->getSettingInMicrons("wall_0_wipe_dist"), spiralize);
gcode_layer.addPolygonsByOptimizer(outer_wall, &mesh->inset0_config, &wall_overlap_computation, z_seam_type, z_seam_pos, mesh->getSettingInMicrons("wall_0_wipe_dist"), spiralize);
}
}
else
@@ -943,15 +1052,18 @@ void FffGcodeWriter::processInsets(GCodePlanner& gcode_layer, SliceMeshStorage*
}
void FffGcodeWriter::processSkin(GCodePlanner& gcode_layer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int skin_angle)
void FffGcodeWriter::processSkinAndPerimeterGaps(GCodePlanner& gcode_layer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int skin_angle)
{
int64_t z = layer_nr * getSettingInMicrons("layer_height");
const unsigned int skin_line_width = mesh->skin_config.getLineWidth();
const unsigned int perimeter_gaps_line_width = mesh->perimeter_gap_config.getLineWidth();
constexpr int perimeter_gaps_extra_offset = 15; // extra offset so that the perimeter gaps aren't created everywhere due to rounding errors
bool fill_perimeter_gaps = mesh->getSettingAsFillPerimeterGapMode("fill_perimeter_gaps") != FillPerimeterGapMode::NOWHERE;
bool fill_perimeter_gaps = mesh->getSettingAsFillPerimeterGapMode("fill_perimeter_gaps") != FillPerimeterGapMode::NOWHERE
&& !mesh->getSettingBoolean("magic_spiralize");
PathOrderOptimizer part_order_optimizer(gcode_layer.getLastPosition(), EZSeamType::SHORTEST);
Point z_seam_pos(0, 0); // not used
PathOrderOptimizer part_order_optimizer(gcode_layer.getLastPosition(), z_seam_pos, EZSeamType::SHORTEST);
for (unsigned int skin_part_idx = 0; skin_part_idx < part.skin_parts.size(); skin_part_idx++)
{
PolygonsPart& outline = part.skin_parts[skin_part_idx].outline;
@@ -966,7 +1078,9 @@ void FffGcodeWriter::processSkin(GCodePlanner& gcode_layer, SliceMeshStorage* me
Polygons skin_polygons;
Polygons skin_lines;
EFillMethod pattern = mesh->getSettingAsFillMethod("top_bottom_pattern");
EFillMethod pattern = (layer_nr == 0)?
mesh->getSettingAsFillMethod("top_bottom_pattern_0") :
mesh->getSettingAsFillMethod("top_bottom_pattern");
int bridge = -1;
if (layer_nr > 0)
bridge = bridgeAngle(skin_part.outline, &mesh->layers[layer_nr-1]);
@@ -995,13 +1109,13 @@ void FffGcodeWriter::processSkin(GCodePlanner& gcode_layer, SliceMeshStorage* me
{
// add perimeter gaps between the outer skin inset and the innermost wall
const Polygons outer = skin_part.outline;
const Polygons inner = skin_part.insets[0].offset(mesh->insetX_config.getLineWidth() / 2 + perimeter_gaps_extra_offset * 2);
const Polygons inner = skin_part.insets[0].offset(mesh->insetX_config.getLineWidth() / 2 + perimeter_gaps_extra_offset);
perimeter_gaps.add(outer.difference(inner));
for (unsigned int inset_idx = 1; inset_idx < skin_part.insets.size(); inset_idx++)
{ // add perimeter gaps between consecutive skin walls
const Polygons outer = skin_part.insets[inset_idx - 1].offset(-1 * mesh->insetX_config.getLineWidth() / 2 - perimeter_gaps_extra_offset);
const Polygons inner = skin_part.insets[inset_idx].offset(mesh->insetX_config.getLineWidth() / 2 + perimeter_gaps_extra_offset);
const Polygons inner = skin_part.insets[inset_idx].offset(mesh->insetX_config.getLineWidth() / 2);
perimeter_gaps.add(outer.difference(inner));
}
}
@@ -1018,13 +1132,6 @@ void FffGcodeWriter::processSkin(GCodePlanner& gcode_layer, SliceMeshStorage* me
Infill infill_comp(pattern, *inner_skin_outline, offset_from_inner_skin_outline, skin_line_width, skin_line_width, skin_overlap, skin_angle, z, extra_infill_shift, perimeter_gaps_output);
infill_comp.generate(skin_polygons, skin_lines);
if (fill_perimeter_gaps)
{ // handle perimeter_gaps of skin insets
int offset = 0;
Infill infill_comp(EFillMethod::LINES, perimeter_gaps, offset, skin_line_width, skin_line_width, skin_overlap, skin_angle, z, extra_infill_shift);
infill_comp.generate(skin_polygons, skin_lines);
}
gcode_layer.addPolygonsByOptimizer(skin_polygons, &mesh->skin_config);
if (pattern == EFillMethod::GRID || pattern == EFillMethod::LINES || pattern == EFillMethod::TRIANGLES)
@@ -1035,28 +1142,56 @@ void FffGcodeWriter::processSkin(GCodePlanner& gcode_layer, SliceMeshStorage* me
{
gcode_layer.addLinesByOptimizer(skin_lines, &mesh->skin_config, (pattern == EFillMethod::ZIG_ZAG)? SpaceFillType::PolyLines : SpaceFillType::Lines);
}
if (fill_perimeter_gaps)
{ // handle perimeter_gaps of skin insets
Polygons gap_polygons; // will remain empty
Polygons gap_lines;
int offset = 0;
Infill infill_comp(EFillMethod::LINES, perimeter_gaps, offset, perimeter_gaps_line_width, perimeter_gaps_line_width, skin_overlap, skin_angle, z, extra_infill_shift);
infill_comp.generate(gap_polygons, gap_lines);
gcode_layer.addLinesByOptimizer(gap_lines, &mesh->perimeter_gap_config, SpaceFillType::Lines);
}
}
if (fill_perimeter_gaps)
{ // handle perimeter gaps of normal insets
Polygons perimeter_gaps;
int line_width = mesh->inset0_config.getLineWidth();
for (unsigned int inset_idx = 1; inset_idx < part.insets.size(); inset_idx++)
for (unsigned int inset_idx = 0; inset_idx < part.insets.size() - 1; inset_idx++)
{
const Polygons outer = part.insets[inset_idx - 1].offset(-1 * line_width / 2 - perimeter_gaps_extra_offset);
const Polygons outer = part.insets[inset_idx].offset(-1 * line_width / 2 - perimeter_gaps_extra_offset);
line_width = mesh->insetX_config.getLineWidth();
const Polygons inner = part.insets[inset_idx].offset(line_width / 2 + perimeter_gaps_extra_offset);
Polygons inner = part.insets[inset_idx + 1].offset(line_width / 2);
perimeter_gaps.add(outer.difference(inner));
}
{ // gap between inner wall and skin/infill
if (mesh->getSettingInMicrons("infill_line_distance") > 0
&& !mesh->getSettingBoolean("infill_hollow")
&& mesh->getSettingInMicrons("infill_overlap_mm") >= 0
)
{
const Polygons outer = part.insets.back().offset(-1 * line_width / 2 - perimeter_gaps_extra_offset);
Polygons skin_polygons; // unused
Polygons skin_lines; // soon to be generated gap filler lines
Polygons inner = part.infill_area;
for (SkinPart& skin_part : part.skin_parts)
{
inner.add(skin_part.outline);
}
inner = inner.unionPolygons();
perimeter_gaps.add(outer.difference(inner));
}
}
Polygons gap_polygons; // unused
Polygons gap_lines; // soon to be generated gap filler lines
int offset = 0;
int extra_infill_shift = 0;
Infill infill_comp(EFillMethod::LINES, perimeter_gaps, offset, skin_line_width, skin_line_width, skin_overlap, skin_angle, z, extra_infill_shift);
infill_comp.generate(skin_polygons, skin_lines);
Infill infill_comp(EFillMethod::LINES, perimeter_gaps, offset, perimeter_gaps_line_width, perimeter_gaps_line_width, skin_overlap, skin_angle, z, extra_infill_shift);
infill_comp.generate(gap_polygons, gap_lines);
gcode_layer.addLinesByOptimizer(skin_lines, &mesh->skin_config, SpaceFillType::Lines);
gcode_layer.addLinesByOptimizer(gap_lines, &mesh->perimeter_gap_config, SpaceFillType::Lines);
}
}
@@ -1234,11 +1369,29 @@ void FffGcodeWriter::setExtruder_addPrime(SliceDataStorage& storage, GCodePlanne
if (extruder_changed)
{
if (!extruder_prime_is_planned[extruder_nr])
{
ExtruderTrain* train = storage.meshgroup->getExtruderTrain(extruder_nr);
// move to prime position
bool prime_pos_is_abs = train->getSettingBoolean("extruder_prime_pos_abs");
Point prime_pos = Point(train->getSettingInMicrons("extruder_prime_pos_x"), train->getSettingInMicrons("extruder_prime_pos_y"));
gcode_layer.addTravel(prime_pos_is_abs? prime_pos : gcode_layer.getLastPosition() + prime_pos);
gcode_layer.planPrime();
extruder_prime_is_planned[extruder_nr] = true;
}
assert(extruder_prime_is_planned[extruder_nr] && "extruders should be primed before they are used!");
if (layer_nr == 0 && !skirt_brim_is_processed[extruder_nr])
{
processSkirtBrim(storage, gcode_layer, extruder_nr);
}
addPrimeTower(storage, gcode_layer, layer_nr, previous_extruder);
if (layer_nr >= -Raft::getFillerLayerCount(storage))
{
addPrimeTower(storage, gcode_layer, layer_nr, previous_extruder);
}
}
}
+54 -11
Ver Arquivo
@@ -65,6 +65,13 @@ private:
*/
bool skirt_brim_is_processed[MAX_EXTRUDERS];
std::vector<std::vector<unsigned int>> mesh_order_per_extruder; //!< For each extruder, the cyclic order of the meshes (the first element is not the starting element per se)
/*!
* For each extruder whether priming has already been planned
*/
bool extruder_prime_is_planned[MAX_EXTRUDERS];
std::vector<FanSpeedLayerTimeSettings> fan_speed_layer_time_settings_per_extruder; //!< The settings used relating to minimal layer time and fan speeds. Configured for each extruder.
Point last_position_planned; //!< The position of the head before planning the next layer
@@ -73,12 +80,13 @@ private:
public:
FffGcodeWriter(SettingsBase* settings_)
: SettingsMessenger(settings_)
, max_object_height(0)
, layer_plan_buffer(this, gcode)
, extruder_prime_is_planned {} // initialize all values in array with [false]
, last_position_planned(no_point)
, current_extruder_planned(0) // changed somewhere early in FffGcodeWriter::writeGCode
, is_inside_mesh_layer_part(false)
{
max_object_height = 0;
}
/*!
@@ -175,15 +183,26 @@ private:
* \param[out] storage The data storage to which to save the configurations.
*/
void initConfigs(SliceDataStorage& storage);
/*!
* Get the extruder with which to start the print.
*
* Generally this is the adhesion_extruder_nr, but in case the platform adhesion type is none,
* the extruder with lowest number which is used on the first layer is used as initial extruder.
*
* \param[in] storage where to get settings from.
*/
unsigned int getStartExtruder(SliceDataStorage& storage);
/*!
* Set temperatures and perform initial priming.
*
* Write a stub header if CuraEngine is in command line tool mode. (Cause writing the header afterwards would entail moving all gcode down.)
*
* \param[in] storage where the slice data is stored.
* \param[in] start_extruder_nr The extruder with which to start the print.
*/
void processStartingCode(SliceDataStorage& storage);
void processStartingCode(SliceDataStorage& storage, const unsigned int start_extruder_nr);
/*!
* Move up and over the already printed meshgroups to print the next meshgroup.
@@ -212,6 +231,13 @@ private:
*/
void processLayer(SliceDataStorage& storage, int layer_nr, unsigned int total_layers);
/*!
* Whether the extruders need to be primed separately just before they are used.
*
* \return whether the extruders need to be primed separately just before they are used
*/
bool getExtrudersNeedPrimeDuringFirstLayer();
/*!
* Plan priming of all used extruders which haven't been primed yet
* \param[in] storage where the slice data is stored.
@@ -289,15 +315,27 @@ private:
void addMeshOpenPolyLinesToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcode_layer, int layer_nr);
/*!
* Add a single layer from a single mesh-volume to the layer plan \p gcodeLayer.
* Add a single layer from a single mesh-volume to the layer plan \p gcode_layer.
*
* \param[in] storage where the slice data is stored.
* \param mesh The mesh to add to the layer plan \p gcodeLayer.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param mesh The mesh to add to the layer plan \p gcode_layer.
* \param gcode_layer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*
*/
void addMeshLayerToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcodeLayer, int layer_nr);
void addMeshLayerToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcode_layer, int layer_nr);
/*!
* Add a single part from a given layer of a mesh-volume to the layer plan \p gcode_layer.
*
* \param[in] storage where the slice data is stored.
* \param mesh The mesh to add to the layer plan \p gcode_layer.
* \param part The part to add
* \param gcode_layer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*
*/
void addMeshPartToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, SliceLayerPart& part, GCodePlanner& gcode_layer, int layer_nr);
/*!
* Add thicker (multiple layers) sparse infill for a given part in a layer plan.
@@ -331,20 +369,25 @@ private:
* \param part The part for which to create gcode
* \param layer_nr The current layer number.
* \param z_seam_type dir3ective for where to start the outer paerimeter of a part
* \param z_seam_pos The location near where to start the outer inset in case \p z_seam_type is 'back'
*/
void processInsets(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type);
void processInsets(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type, Point z_seam_pos);
/*!
* Add the gcode of the top/bottom skin of the given part.
* Add the gcode of the top/bottom skin of the given part and of the perimeter gaps.
*
* Perimter gaps are generated for skin outlines and printed while the skin fill of the skin part is printed.
* Perimeter gaps between the walls are added to the gcode afterwards.
*
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param part The part for which to create gcode
* \param layer_nr The current layer number.
* \param skin_overlap The distance by which the skin overlaps with the wall insets.
* \param skin_overlap The distance by which the skin overlaps with the wall insets and the distance by which the perimeter gaps overlap with adjacent print features.
* \param fillAngle The angle in the XY plane at which the infill is generated.
*/
void processSkin(cura::GCodePlanner& gcode_layer, cura::SliceMeshStorage* mesh, cura::SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int infill_angle);
void processSkinAndPerimeterGaps(cura::GCodePlanner& gcode_layer, cura::SliceMeshStorage* mesh, cura::SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int infill_angle);
/*!
* Add the support to the layer plan \p gcodeLayer of the current layer for all support parts with the given \p extruder_nr.
+86 -14
Ver Arquivo
@@ -3,6 +3,10 @@
#include <algorithm>
#include <map> // multimap (ordered map allowing duplicate keys)
#ifdef _OPENMP
#include <omp.h>"
#endif
#include "utils/math.h"
#include "utils/algorithm.h"
#include "slicer.h"
@@ -53,7 +57,7 @@ unsigned int FffPolygonGenerator::getDraftShieldLayerCount(const unsigned int to
case DraftShieldHeightLimitation::FULL:
return total_layers;
case DraftShieldHeightLimitation::LIMITED:
return std::max(0, (getSettingInMicrons("draft_shield_height") - getSettingInMicrons("layer_height_0")) / getSettingInMicrons("layer_height") + 1);
return std::max((coord_t)0, (getSettingInMicrons("draft_shield_height") - getSettingInMicrons("layer_height_0")) / getSettingInMicrons("layer_height") + 1);
}
}
@@ -151,6 +155,10 @@ bool FffPolygonGenerator::sliceModel(MeshGroup* meshgroup, TimeKeeper& timeKeepe
SupportLayer& support_layer = storage.support.supportLayers[layer_nr];
SlicerLayer& slicer_layer = slicer->layers[layer_nr];
support_layer.anti_overhang = support_layer.anti_overhang.unionPolygons(slicer_layer.polygons);
meshStorage.layers[layer_nr].printZ =
slicer_layer.z
+ getSettingInMicrons("layer_height_0")
- initial_slice_z;
}
continue;
}
@@ -161,6 +169,10 @@ bool FffPolygonGenerator::sliceModel(MeshGroup* meshgroup, TimeKeeper& timeKeepe
SupportLayer& support_layer = storage.support.supportLayers[layer_nr];
SlicerLayer& slicer_layer = slicer->layers[layer_nr];
support_layer.support_mesh.add(slicer_layer.polygons);
meshStorage.layers[layer_nr].printZ =
slicer_layer.z
+ getSettingInMicrons("layer_height_0")
- initial_slice_z;
}
continue;
}
@@ -297,6 +309,7 @@ void FffPolygonGenerator::slices2polygons(SliceDataStorage& storage, TimeKeeper&
// handle helpers
storage.primeTower.generatePaths(storage);
storage.primeTower.subtractFromSupport(storage);
logDebug("Processing ooze shield\n");
processOozeShield(storage);
@@ -336,12 +349,24 @@ void FffPolygonGenerator::processBasicWallsSkinInfill(SliceDataStorage& storage,
// walls
unsigned int processed_layer_count = 0;
#pragma omp parallel for default(none) shared(mesh_layer_count, mesh, inset_skin_progress_estimate, processed_layer_count) schedule(dynamic)
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
{
logDebug("Processing insets for layer %i of %i\n", layer_number, mesh_layer_count);
processInsets(mesh, layer_number);
double progress = inset_skin_progress_estimate.progress(layer_number);
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
#ifdef _OPENMP
if (omp_get_thread_num() == 0)
#endif
{ // progress estimation is done only in one thread so that no two threads message progress at the same time
int _processed_layer_count;
#pragma omp atomic read
_processed_layer_count = processed_layer_count;
double progress = inset_skin_progress_estimate.progress(_processed_layer_count);
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
}
#pragma omp atomic
processed_layer_count++;
}
ProgressEstimatorLinear* skin_estimator = new ProgressEstimatorLinear(mesh_layer_count);
@@ -372,16 +397,33 @@ void FffPolygonGenerator::processBasicWallsSkinInfill(SliceDataStorage& storage,
{
mesh_max_bottom_layer_count = std::max(mesh_max_bottom_layer_count, mesh.getSettingAsCount("bottom_layers"));
}
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
processed_layer_count = 0;
#pragma omp parallel default(none) shared(mesh_layer_count, mesh, mesh_max_bottom_layer_count, process_infill, inset_skin_progress_estimate, processed_layer_count)
{
logDebug("Processing skins and infill layer %i of %i\n", layer_number, mesh_layer_count);
if (!mesh.getSettingBoolean("magic_spiralize") || static_cast<int>(layer_number) < mesh_max_bottom_layer_count) //Only generate up/downskin and infill for the first X layers when spiralize is choosen.
#pragma omp for schedule(dynamic)
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
{
processSkinsAndInfill(mesh, layer_number, process_infill);
logDebug("Processing skins and infill layer %i of %i\n", layer_number, mesh_layer_count);
if (!mesh.getSettingBoolean("magic_spiralize") || static_cast<int>(layer_number) < mesh_max_bottom_layer_count) //Only generate up/downskin and infill for the first X layers when spiralize is choosen.
{
processSkinsAndInfill(mesh, layer_number, process_infill);
}
#ifdef _OPENMP
if (omp_get_thread_num() == 0)
#endif
{ // progress estimation is done only in one thread so that no two threads message progress at the same time
int _processed_layer_count;
#pragma omp atomic read
_processed_layer_count = processed_layer_count;
double progress = inset_skin_progress_estimate.progress(_processed_layer_count);
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
}
#pragma omp atomic
processed_layer_count++;
}
}
double progress = inset_skin_progress_estimate.progress(layer_number);
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
}
}
void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order)
@@ -460,8 +502,14 @@ void FffPolygonGenerator::processDerivedWallsSkinInfill(SliceMeshStorage& mesh)
// create gradual infill areas
SkinInfillAreaComputation::generateGradualInfill(mesh, mesh.getSettingInMicrons("gradual_infill_step_height"), mesh.getSettingAsCount("gradual_infill_steps"));
//SubDivCube Pre-compute Octree
if (mesh.getSettingAsFillMethod("infill_pattern") == EFillMethod::CUBICSUBDIV)
{
SubDivCube::precomputeOctree(mesh);
}
// combine infill
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh.getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), 1))); //How many infill layers to combine to obtain the requested sparse thickness.
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh.getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), (coord_t)1))); //How many infill layers to combine to obtain the requested sparse thickness.
combineInfillLayers(mesh,combined_infill_layers);
// fuzzy skin
@@ -471,6 +519,12 @@ void FffPolygonGenerator::processDerivedWallsSkinInfill(SliceMeshStorage& mesh)
}
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* processInsets only reads and writes data for the current layer
*/
void FffPolygonGenerator::processInsets(SliceMeshStorage& mesh, unsigned int layer_nr)
{
SliceLayer* layer = &mesh.layers[layer_nr];
@@ -509,11 +563,19 @@ void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, cons
for (SliceMeshStorage& mesh : storage.meshes)
{
SliceLayer& layer = mesh.layers[layer_idx];
if (layer.parts.size() > 0 || (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL && layer.openPolyLines.size() > 0) )
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL && layer.openPolyLines.size() > 0)
{
layer_is_empty = false;
break;
}
for (const SliceLayerPart& part : layer.parts)
{
if (part.print_outline.size() > 0)
{
layer_is_empty = false;
break;
}
}
}
if (layer_is_empty)
@@ -544,8 +606,18 @@ void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, cons
support_layers.erase(support_layers.begin(), support_layers.begin() + n_empty_first_layers);
}
}
void FffPolygonGenerator::processSkinsAndInfill(SliceMeshStorage& mesh, unsigned int layer_nr, bool process_infill)
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateSkins read (depend on) data from mesh.layers[*].parts[*].insets and write mesh.layers[n].parts[*].skin_parts
* generateInfill read mesh.layers[n].parts[*].{insets,skin_parts,boundingBox} and write mesh.layers[n].parts[*].infill_area
*
* processSkinsAndInfill read (depend on) mesh.layers[*].parts[*].{insets,boundingBox}.
* write mesh.layers[n].parts[*].{skin_parts,infill_area}.
*/
void FffPolygonGenerator::processSkinsAndInfill(SliceMeshStorage& mesh, unsigned int layer_nr, bool process_infill)
{
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE)
{
+2 -4
Ver Arquivo
@@ -251,7 +251,7 @@ void LayerPlanBuffer::insertFinalPrintTempCommand(std::vector<ExtruderPlan*>& ex
time_window += prev_extruder_plan_time;
heated_pre_travel_time = prev_extruder_plan.heated_pre_travel_time;
if (prev_extruder_plan.estimates.getTotalUnretractedTime() > 0 && prev_extruder_plan.estimates.getMaterial() > 0)
if (prev_extruder_plan.estimates.getTotalUnretractedTime() > 0)
{ // handle temp statistics
assert(prev_extruder_plan.printing_temperature != -1 && "Previous extruder plan should already have a temperature planned");
weighted_average_print_temp += prev_extruder_plan.printing_temperature * prev_extruder_plan_time;
@@ -349,9 +349,7 @@ void LayerPlanBuffer::insertTempCommands()
ExtruderPlan& extruder_plan = layer_plan.extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
double time = extruder_plan.estimates.getTotalUnretractedTime();
if (time <= 0.0
|| extruder_plan.estimates.getMaterial() == 0.0 // extruder plan only consists of moves (when an extruder switch occurs at the beginning of a layer)
)
if (time <= 0.0)
{
continue;
}
+1
Ver Arquivo
@@ -58,6 +58,7 @@ int MeshGroup::getExtruderCount() const
ExtruderTrain* MeshGroup::createExtruderTrain(unsigned int extruder_nr)
{
assert((int)extruder_nr >= 0 && (int)extruder_nr < getSettingAsCount("machine_extruder_count") && "only valid extruder trains may be requested!");
if (!extruders[extruder_nr])
{
extruders[extruder_nr] = new ExtruderTrain(this, extruder_nr);
+13 -24
Ver Arquivo
@@ -82,12 +82,6 @@ Preheat::WarmUpResult Preheat::getWarmUpPointAfterCoolDown(double time_window, u
result.heating_time = extra_heatup_time;
limited_time_window = time_window - extra_heatup_time;
outer_temp = temp_start;
if (limited_time_window < 0.0)
{
result.heating_time = 0.0;
result.lowest_temperature = temp_start;
return result;
}
}
else
{
@@ -95,13 +89,14 @@ Preheat::WarmUpResult Preheat::getWarmUpPointAfterCoolDown(double time_window, u
result.heating_time = 0;
limited_time_window = time_window - extra_cooldown_time;
outer_temp = temp_end;
if (limited_time_window < 0.0)
{
result.heating_time = 0.0;
result.lowest_temperature = temp_end;
return result;
}
}
if (limited_time_window < 0.0)
{
result.heating_time = 0.0;
result.lowest_temperature = std::min(temp_start, temp_end);
return result;
}
double time_ratio_cooldown_heatup = time_to_cooldown_1_degree / time_to_heatup_1_degree;
double time_to_heat_from_standby_to_print_temp = getTimeToGoFromTempToTemp(extruder, temp_mid, outer_temp, during_printing);
double time_needed_to_reach_standby_temp = time_to_heat_from_standby_to_print_temp * (1.0 + time_ratio_cooldown_heatup);
@@ -150,12 +145,6 @@ Preheat::CoolDownResult Preheat::getCoolDownPointAfterWarmUp(double time_window,
result.cooling_time = 0;
limited_time_window = time_window - extra_heatup_time;
outer_temp = temp_end;
if (limited_time_window < 0.0)
{
result.cooling_time = 0.0;
result.highest_temperature = temp_end;
return result;
}
}
else
{
@@ -163,12 +152,12 @@ Preheat::CoolDownResult Preheat::getCoolDownPointAfterWarmUp(double time_window,
result.cooling_time = extra_cooldown_time;
limited_time_window = time_window - extra_cooldown_time;
outer_temp = temp_start;
if (limited_time_window < 0.0)
{
result.cooling_time = 0.0;
result.highest_temperature = temp_start;
return result;
}
}
if (limited_time_window < 0.0)
{
result.cooling_time = 0.0;
result.highest_temperature = std::max(temp_start, temp_end);
return result;
}
double time_ratio_cooldown_heatup = time_to_cooldown_1_degree / time_to_heatup_1_degree;
double cool_down_time = getTimeToGoFromTempToTemp(extruder, temp_mid, outer_temp, during_printing);
-1
Ver Arquivo
@@ -117,7 +117,6 @@ public:
{
return config_per_extruder[extruder_nr].flow_dependent_temperature;
}
public:
/*!
* Get the optimal temperature corresponding to a given average flow,
* or the initial layer temperature.
+23 -12
Ver Arquivo
@@ -12,7 +12,7 @@
namespace cura
{
PrimeTower::PrimeTower()
PrimeTower::PrimeTower(const SliceDataStorage& storage)
: is_hollow(false)
, wipe_from_middle(false)
, current_pre_wipe_location_idx(0)
@@ -21,6 +21,13 @@ PrimeTower::PrimeTower()
{
last_prime_tower_poly_printed[extruder_nr] = -1;
}
enabled = storage.getSettingBoolean("prime_tower_enable")
&& storage.getSettingInMicrons("prime_tower_wall_thickness") > 10
&& storage.getSettingInMicrons("prime_tower_size") > 10;
if (enabled)
{
generateGroundpoly(storage);
}
}
@@ -83,10 +90,7 @@ void PrimeTower::generateGroundpoly(const SliceDataStorage& storage)
void PrimeTower::generatePaths(const SliceDataStorage& storage)
{
enabled = storage.max_print_height_second_to_last_extruder >= 0
&& storage.getSettingBoolean("prime_tower_enable")
&& storage.getSettingInMicrons("prime_tower_wall_thickness") > 10
&& storage.getSettingInMicrons("prime_tower_size") > 10;
enabled &= storage.max_print_height_second_to_last_extruder >= 0; //Maybe it turns out that we don't need a prime tower after all because there are no layer switches.
if (enabled)
{
generatePaths_denseInfill(storage);
@@ -100,8 +104,6 @@ void PrimeTower::generatePaths_denseInfill(const SliceDataStorage& storage)
int infill_overlap = 60; // so that it can't be zero; EDIT: wtf?
int extra_infill_shift = 0;
generateGroundpoly(storage);
int64_t z = 0; // (TODO) because the prime tower stores the paths for each extruder for once instead of generating each layer, we don't know the z position
for (int extruder = 0; extruder < extruder_count; extruder++)
@@ -160,7 +162,7 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode
preWipe(storage, gcodeLayer, new_extruder);
}
addToGcode_denseInfill(storage, gcodeLayer, gcode, layer_nr, prev_extruder, new_extruder);
addToGcode_denseInfill(gcodeLayer, layer_nr, new_extruder);
// post-wipe:
if (post_wipe)
@@ -169,16 +171,16 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode
}
}
void PrimeTower::addToGcode_denseInfill(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder)
void PrimeTower::addToGcode_denseInfill(GCodePlanner& gcodeLayer, const int layer_nr, const int extruder)
{
ExtrusionMoves& pattern = patterns_per_extruder[new_extruder][((layer_nr % 2) + 2) % 2]; // +2) %2 to handle negative layer numbers
ExtrusionMoves& pattern = patterns_per_extruder[extruder][((layer_nr % 2) + 2) % 2]; // +2) %2 to handle negative layer numbers
GCodePathConfig& config = config_per_extruder[new_extruder];
GCodePathConfig& config = config_per_extruder[extruder];
gcodeLayer.addPolygonsByOptimizer(pattern.polygons, &config);
gcodeLayer.addLinesByOptimizer(pattern.lines, &config, SpaceFillType::Lines);
last_prime_tower_poly_printed[new_extruder] = layer_nr;
last_prime_tower_poly_printed[extruder] = layer_nr;
}
Point PrimeTower::getLocationBeforePrimeTower(const SliceDataStorage& storage)
@@ -295,5 +297,14 @@ void PrimeTower::preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_la
gcode_layer.addExtrusionMove(end, &config_per_extruder[extruder_nr], SpaceFillType::None, flow);
}
void PrimeTower::subtractFromSupport(SliceDataStorage& storage)
{
const Polygons outside_polygon = ground_poly.getOutsidePolygons();
for(size_t layer = 0; layer <= (size_t)storage.max_print_height_second_to_last_extruder + 1 && layer < storage.support.supportLayers.size(); layer++)
{
storage.support.supportLayers[layer].supportAreas = storage.support.supportLayers[layer].supportAreas.difference(outside_polygon);
}
}
}//namespace cura
+26 -10
Ver Arquivo
@@ -1,3 +1,6 @@
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef PRIME_TOWER_H
#define PRIME_TOWER_H
@@ -30,8 +33,6 @@ private:
Polygons polygons;
Polygons lines;
};
bool enabled; //!< Whether the prime tower is enabled
int extruder_count; //!< number of extruders
std::vector<GCodePathConfig> config_per_extruder; //!< Path config for prime tower for each extruder
@@ -49,10 +50,19 @@ private:
int current_pre_wipe_location_idx; //!< Index into \ref PrimeTower::wipe_locations of where to pre-wipe the nozzle
public:
bool enabled; //!< Whether the prime tower is enabled.
Polygons ground_poly; //!< The outline of the prime tower to be used for each layer
std::vector<std::vector<ExtrusionMoves>> patterns_per_extruder; //!< for each extruder a vector of patterns to alternate between, over the layers
/*!
* \brief Creates a prime tower instance that will determine where and how
* the prime tower gets printed.
*
* \param storage A storage where it retrieves the prime tower settings.
*/
PrimeTower(const SliceDataStorage& storage);
/*!
* Initialize \ref PrimeTower::config_per_extruder with speed and line width settings.
*
@@ -85,8 +95,6 @@ public:
*/
void generatePaths(const SliceDataStorage& storage);
PrimeTower(); //!< basic constructor
/*!
* Add path plans for the prime tower to the \p gcode_layer
*
@@ -97,6 +105,15 @@ public:
* \param new_extruder The switched to extruder with which the prime tower paths should be generated.
*/
void addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder);
/*!
* \brief Subtract the prime tower from the support areas in storage.
*
* \param storage The storage where to find the support from which to
* subtract a prime tower.
*/
void subtractFromSupport(SliceDataStorage& storage);
private:
/*!
* Layer number of the last layer in which a prime tower has been printed per extruder train.
@@ -134,16 +151,15 @@ private:
/*!
* \see PrimeTower::addToGcode
*
*
* Add path plans for the prime tower to the \p gcode_layer
*
* \param storage where to get settings from; where to get the maximum height of the prime tower from
*
* \param[in,out] gcode_layer Where to get the current extruder from; where to store the generated layer paths
* \param layer_nr The layer for which to generate the prime tower paths
* \param prev_extruder The previous extruder with which paths were planned; from which extruder a switch was made
* \param new_extruder The switched to extruder with which the prime tower paths should be generated.
* \param extruder The extruder we just switched to, with which the prime
* tower paths should be drawn.
*/
void addToGcode_denseInfill(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder);
void addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder);
/*!
* Plan the moves for wiping the current nozzles oozed material before starting to print the prime tower.
+13 -2
Ver Arquivo
@@ -1,4 +1,7 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
//Copyright (C) 2013 David Braam
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "SkirtBrim.h"
#include "support.h"
@@ -19,6 +22,7 @@ void SkirtBrim::getFirstLayerOutline(SliceDataStorage& storage, const unsigned i
{ // add brim underneath support by removing support where there's brim around the model
const bool include_helper_parts = false; // include manually below
first_layer_outline = storage.getLayerOutlines(layer_nr, include_helper_parts, external_only);
first_layer_outline = first_layer_outline.unionPolygons(); //To guard against overlapping outlines, which would produce holes according to the even-odd rule.
Polygons first_layer_empty_holes;
if (outside_only)
{
@@ -44,13 +48,20 @@ void SkirtBrim::getFirstLayerOutline(SliceDataStorage& storage, const unsigned i
first_layer_outline.add(support_layer.supportAreas);
first_layer_outline.add(support_layer.skin);
}
first_layer_outline.add(storage.primeTower.ground_poly); // don't remove parts of the prime tower, but make a brim for it
if (storage.primeTower.enabled)
{
first_layer_outline.add(storage.primeTower.ground_poly); // don't remove parts of the prime tower, but make a brim for it
}
}
constexpr int join_distance = 20;
first_layer_outline = first_layer_outline.offset(join_distance).offset(-join_distance); // merge adjacent models into single polygon
constexpr int smallest_line_length = 200;
constexpr int largest_error_of_removed_point = 50;
first_layer_outline.simplify(smallest_line_length, largest_error_of_removed_point); // simplify for faster processing of the brim lines
if (first_layer_outline.size() == 0)
{
logError("Couldn't generate skirt / brim! No polygons on first layer.");
}
}
int SkirtBrim::generatePrimarySkirtBrimLines(SliceDataStorage& storage, int start_distance, unsigned int primary_line_count, const int primary_extruder_skirt_brim_line_width, const int64_t primary_extruder_minimal_length, const Polygons& first_layer_outline, Polygons& skirt_brim_primary_extruder)
+12
Ver Arquivo
@@ -12,6 +12,12 @@ WallsComputation::WallsComputation(int wall_0_inset, int line_width_0, int line_
{
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateInsets only reads and writes data for the current layer
*/
void WallsComputation::generateInsets(SliceLayerPart* part)
{
if (insetCount == 0)
@@ -58,6 +64,12 @@ void WallsComputation::generateInsets(SliceLayerPart* part)
}
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateInsets only reads and writes data for the current layer
*/
void WallsComputation::generateInsets(SliceLayer* layer)
{
for(unsigned int partNr = 0; partNr < layer->parts.size(); partNr++)
+10 -9
Ver Arquivo
@@ -18,8 +18,9 @@ void Wireframe2gcode::writeGCode()
{
gcode.preSetup(wireFrame.meshgroup);
gcode.setInitialTemps(*wireFrame.meshgroup);
const unsigned int start_extruder_nr = getSettingAsIndex("adhesion_extruder_nr"); // TODO: figure out how Wireframe works with dual extrusion
gcode.setInitialTemps(*wireFrame.meshgroup, start_extruder_nr);
if (CommandSocket::getInstance())
CommandSocket::getInstance()->beginGCode();
@@ -159,7 +160,7 @@ void Wireframe2gcode::writeGCode()
gcode.setZ(maxObjectHeight);
gcode.writeRetraction(&standard_retraction_config);
gcode.writeRetraction(standard_retraction_config);
gcode.updateTotalPrintTime();
@@ -259,7 +260,7 @@ void Wireframe2gcode::strategy_retract(WeaveLayer& layer, WeaveConnectionPart& p
Point3 lowering = vec * retract_hop_dist / 2 / vec.vSize();
Point3 lower = to - lowering;
gcode.writeMove(lower, speedUp, extrusion_mm3_per_mm_connection);
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
gcode.writeMove(to + lowering, speedUp, 0);
gcode.writeDelay(top_retract_pause);
if (after_retract_hop)
@@ -268,7 +269,7 @@ void Wireframe2gcode::strategy_retract(WeaveLayer& layer, WeaveConnectionPart& p
} else
{
gcode.writeMove(to, speedUp, extrusion_mm3_per_mm_connection);
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
gcode.writeMove(to + Point3(0, 0, retract_hop_dist), speedFlat, 0);
gcode.writeDelay(top_retract_pause);
if (after_retract_hop)
@@ -467,14 +468,14 @@ void Wireframe2gcode::writeFill(std::vector<WeaveRoofPart>& infill_insets, Polyg
void Wireframe2gcode::writeMoveWithRetract(Point3 to)
{
if ((gcode.getPosition() - to).vSize2() >= nozzle_top_diameter * nozzle_top_diameter * 2 * 2)
gcode.writeRetraction(&standard_retraction_config);
gcode.writeRetraction(standard_retraction_config);
gcode.writeMove(to, moveSpeed, 0);
}
void Wireframe2gcode::writeMoveWithRetract(Point to)
{
if (vSize2(gcode.getPositionXY() - to) >= nozzle_top_diameter * nozzle_top_diameter * 2 * 2)
gcode.writeRetraction(&standard_retraction_config);
gcode.writeRetraction(standard_retraction_config);
gcode.writeMove(to, moveSpeed, 0);
}
@@ -562,7 +563,7 @@ void Wireframe2gcode::processStartingCode()
{
if (getSettingBoolean("material_bed_temp_prepend"))
{
if (getSettingBoolean("machine_heated_bed") && getSettingInDegreeCelsius("material_bed_temperature") > 0)
if (getSettingBoolean("machine_heated_bed") && getSettingInDegreeCelsius("material_bed_temperature") != 0)
{
gcode.writeBedTemperatureCommand(getSettingInDegreeCelsius("material_bed_temperature"), getSettingBoolean("material_bed_temp_wait"));
}
@@ -603,7 +604,7 @@ void Wireframe2gcode::processStartingCode()
constexpr bool wait = true;
gcode.writeTemperatureCommand(start_extruder_nr, getSettingInDegreeCelsius("material_print_temperature"), wait);
gcode.writePrimeTrain(getSettingInMillimetersPerSecond("speed_travel"));
gcode.writeRetraction(&standard_retraction_config);
gcode.writeRetraction(standard_retraction_config);
}
}
+2
Ver Arquivo
@@ -642,6 +642,7 @@ void CommandSocket::sendLayerData()
{
for (std::pair<const int, std::shared_ptr<cura::proto::Layer>> entry : data.slice_data) //Note: This is in no particular order!
{
logDebug("Sending layer data for layer %i of %i.\n", entry.first, data.slice_data.size());
private_data->socket->sendMessage(entry.second); //Send the actual layers.
}
data.sliced_objects = 0;
@@ -667,6 +668,7 @@ void CommandSocket::sendOptimizedLayerData()
{
for (std::pair<const int, std::shared_ptr<cura::proto::LayerOptimized>> entry : data.slice_data) //Note: This is in no particular order!
{
logDebug("Sending layer data for layer %i of %i.\n", entry.first, data.slice_data.size());
private_data->socket->sendMessage(entry.second); //Send the actual layers.
}
data.sliced_objects = 0;
+26 -23
Ver Arquivo
@@ -11,6 +11,8 @@
namespace cura {
double layer_height; //!< report basic layer height in RepRap gcode file.
GCodeExport::GCodeExport()
: output_stream(&std::cout)
, currentPosition(0,0,MM2INT(20))
@@ -97,6 +99,8 @@ void GCodeExport::preSetup(const MeshGroup* meshgroup)
machine_name = meshgroup->getSettingString("machine_name");
layer_height = meshgroup->getSettingInMillimeters("layer_height");
if (flavor == EGCodeFlavor::BFB)
{
new_line = "\r\n";
@@ -109,20 +113,15 @@ void GCodeExport::preSetup(const MeshGroup* meshgroup)
estimateCalculator.setFirmwareDefaults(meshgroup);
}
void GCodeExport::setInitialTemps(const MeshGroup& settings)
void GCodeExport::setInitialTemps(const MeshGroup& settings, const unsigned int start_extruder_nr)
{
int start_extruder_nr = 0;
if (settings.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::NONE)
{
start_extruder_nr = settings.getSettingAsIndex("adhesion_extruder_nr");
}
for (unsigned int extr_nr = 0; extr_nr < extruder_count; extr_nr++)
{
const ExtruderTrain& train = *settings.getExtruderTrain(extr_nr);
double print_temp_0 = train.getSettingInDegreeCelsius("material_print_temperature_layer_0");
double print_temp_here = (print_temp_0 != 0)? print_temp_0 : train.getSettingInDegreeCelsius("material_print_temperature");
double temp = ((int)extr_nr == start_extruder_nr)? print_temp_here : train.getSettingInDegreeCelsius("material_standby_temperature");
double temp = (extr_nr == start_extruder_nr)? print_temp_here : train.getSettingInDegreeCelsius("material_standby_temperature");
setInitialTemp(extr_nr, temp);
}
@@ -196,6 +195,11 @@ std::string GCodeExport::getFileHeader(const double* print_time, const std::vect
prefix << ";NOZZLE_DIAMETER:" << float(INT2MM(getNozzleSize(0))) << new_line;
// TODO: the second nozzle size isn't always initiated! ";NOZZLE_DIAMETER2:"
}
else if (flavor == EGCodeFlavor::REPRAP)
{
prefix << ";Filament used: " << ((filament_used.size() >= 1)? filament_used[0] / (1000 * extruder_attr[0].filament_area) : 0) << "m" << new_line;
prefix << ";Layer height: " << layer_height << new_line;
}
return prefix.str();
}
}
@@ -552,8 +556,6 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
assert((Point3(x,y,z) - currentPosition).vSize() < MM2INT(300)); // no crazy positions (this code should not be compiled for release)
#endif //ASSERT_INSANE_OUTPUT
total_bounding_box.include(Point3(x, y, z));
if (extrusion_mm3_per_mm < 0)
logWarning("Warning! Negative extrusion move!");
@@ -566,6 +568,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
double extrusion_per_mm = mm3ToE(extrusion_mm3_per_mm);
Point gcode_pos = getGcodePos(x,y, current_extruder);
total_bounding_box.include(Point3(gcode_pos.X, gcode_pos.Y, z));
if (extrusion_mm3_per_mm > 0.000001)
{
@@ -639,7 +642,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), speed);
}
void GCodeExport::writeRetraction(RetractionConfig* config, bool force, bool extruder_switch)
void GCodeExport::writeRetraction(const RetractionConfig& config, bool force, bool extruder_switch)
{
ExtruderTrainAttributes& extr_attr = extruder_attr[current_extruder];
@@ -656,7 +659,7 @@ void GCodeExport::writeRetraction(RetractionConfig* config, bool force, bool ext
}
double old_retraction_e_amount = extr_attr.retraction_e_amount_current;
double new_retraction_e_amount = mmToE(config->distance);
double new_retraction_e_amount = mmToE(config.distance);
double retraction_diff_e_amount = old_retraction_e_amount - new_retraction_e_amount;
if (std::abs(retraction_diff_e_amount) < 0.000001)
{
@@ -666,23 +669,23 @@ void GCodeExport::writeRetraction(RetractionConfig* config, bool force, bool ext
{ // handle retraction limitation
double current_extruded_volume = getCurrentExtrudedVolume();
std::deque<double>& extruded_volume_at_previous_n_retractions = extr_attr.extruded_volume_at_previous_n_retractions;
while (int(extruded_volume_at_previous_n_retractions.size()) > config->retraction_count_max && !extruded_volume_at_previous_n_retractions.empty())
while (int(extruded_volume_at_previous_n_retractions.size()) > config.retraction_count_max && !extruded_volume_at_previous_n_retractions.empty())
{
// extruder switch could have introduced data which falls outside the retraction window
// also the retraction_count_max could have changed between the last retraction and this
extruded_volume_at_previous_n_retractions.pop_back();
}
if (!force && config->retraction_count_max <= 0)
if (!force && config.retraction_count_max <= 0)
{
return;
}
if (!force && int(extruded_volume_at_previous_n_retractions.size()) == config->retraction_count_max
&& current_extruded_volume < extruded_volume_at_previous_n_retractions.back() + config->retraction_extrusion_window * extr_attr.filament_area)
if (!force && int(extruded_volume_at_previous_n_retractions.size()) == config.retraction_count_max
&& current_extruded_volume < extruded_volume_at_previous_n_retractions.back() + config.retraction_extrusion_window * extr_attr.filament_area)
{
return;
}
extruded_volume_at_previous_n_retractions.push_front(current_extruded_volume);
if (int(extruded_volume_at_previous_n_retractions.size()) == config->retraction_count_max + 1)
if (int(extruded_volume_at_previous_n_retractions.size()) == config.retraction_count_max + 1)
{
extruded_volume_at_previous_n_retractions.pop_back();
}
@@ -705,17 +708,17 @@ void GCodeExport::writeRetraction(RetractionConfig* config, bool force, bool ext
}
else
{
double speed = ((retraction_diff_e_amount < 0.0)? config->speed : extr_attr.last_retraction_prime_speed) * 60;
double speed = ((retraction_diff_e_amount < 0.0)? config.speed : extr_attr.last_retraction_prime_speed) * 60;
current_e_value += retraction_diff_e_amount;
*output_stream << "G1 F" << PrecisionedDouble{1, speed} << " "
<< extr_attr.extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
extr_attr.last_retraction_prime_speed = config->primeSpeed;
extr_attr.last_retraction_prime_speed = config.primeSpeed;
}
extr_attr.retraction_e_amount_current = new_retraction_e_amount; // suppose that for UM2 the retraction amount in the firmware is equal to the provided amount
extr_attr.prime_volume += config->prime_volume;
extr_attr.prime_volume += config.prime_volume;
}
@@ -725,7 +728,7 @@ void GCodeExport::writeZhopStart(int hop_height)
{
isZHopped = hop_height;
*output_stream << "G1 Z" << MMtoStream{currentPosition.z + isZHopped} << new_line;
total_bounding_box.include(currentPosition + Point3(0, 0, isZHopped));
total_bounding_box.includeZ(currentPosition.z + isZHopped);
}
}
@@ -772,7 +775,7 @@ void GCodeExport::switchExtruder(int new_extruder, const RetractionConfig& retra
bool force = true;
bool extruder_switch = true;
writeRetraction(&const_cast<RetractionConfig&>(retraction_config_old_extruder), force, extruder_switch);
writeRetraction(const_cast<RetractionConfig&>(retraction_config_old_extruder), force, extruder_switch);
resetExtrusionValue(); // zero the E value on the old extruder, so that the current_e_value is registered on the old extruder
@@ -904,7 +907,7 @@ void GCodeExport::writeMaxZFeedrate(double max_z_feedrate)
{
if (current_max_z_feedrate != max_z_feedrate)
{
*output_stream << "M203 Z" << int(max_z_feedrate * 60) << new_line;
*output_stream << "M203 Z" << PrecisionedDouble{2, max_z_feedrate} << new_line;
current_max_z_feedrate = max_z_feedrate;
estimateCalculator.setMaxZFeedrate(max_z_feedrate);
}
@@ -919,7 +922,7 @@ void GCodeExport::finalize(const char* endCode)
{
writeFanCommand(0);
writeCode(endCode);
long print_time = getTotalPrintTime();
int64_t print_time = getTotalPrintTime();
int mat_0 = getTotalFilamentUsed(0);
log("Print time: %d\n", print_time);
log("Print time (readable): %dh %dm %ds\n", print_time / 60 / 60, (print_time / 60) % 60, print_time % 60);
+6 -2
Ver Arquivo
@@ -261,7 +261,7 @@ private:
*/
void writeMoveBFB(int x, int y, int z, double speed, double extrusion_mm3_per_mm);
public:
void writeRetraction(RetractionConfig* config, bool force = false, bool extruder_switch = false);
void writeRetraction(const RetractionConfig& config, bool force = false, bool extruder_switch = false);
/*!
* Start a z hop with the given \p hop_height
@@ -349,13 +349,17 @@ public:
* See FffGcodeWriter::processStartingCode
*
* \param settings The meshgroup to get the global bed temp from and to get the extruder trains from which to get the nozzle temperatures
* \param start_extruder_nr The extruder with which to start this print
*/
void setInitialTemps(const MeshGroup& settings);
void setInitialTemps(const MeshGroup& settings, const unsigned int start_extruder_nr);
/*!
* Override or set an initial nozzle temperature as written by GCodeExport::setInitialTemps
* This is used primarily during better specification of temperatures in LayerPlanBuffer::insertPreheatCommand
*
* \warning This function must be called before any of the layers in the meshgroup are written to file!
* That's because it sets the current temperature in the gcode!
*
* \param extruder_nr The extruder number for which to better specify the temp
* \param temp The temp at which the nozzle should be at startup
*/
+24 -19
Ver Arquivo
@@ -9,19 +9,6 @@
namespace cura {
TimeMaterialEstimates TimeMaterialEstimates::operator-(const TimeMaterialEstimates& other)
{
return TimeMaterialEstimates(extrude_time - other.extrude_time,unretracted_travel_time - other.unretracted_travel_time,retracted_travel_time - other.retracted_travel_time,material - other.material);
}
TimeMaterialEstimates& TimeMaterialEstimates::operator-=(const TimeMaterialEstimates& other)
{
extrude_time -= other.extrude_time;
unretracted_travel_time -= other.unretracted_travel_time;
retracted_travel_time -= other.retracted_travel_time;
material -= other.material;
return *this;
}
ExtruderPlan::ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config)
: extruder(extruder)
@@ -77,6 +64,7 @@ GCodePath* GCodePlanner::getLatestPathWithConfig(GCodePathConfig* config, SpaceF
paths.emplace_back();
GCodePath* ret = &paths.back();
ret->retract = false;
ret->perform_prime = false;
ret->perform_z_hop = false;
ret->config = config;
ret->done = false;
@@ -352,6 +340,14 @@ GCodePath& GCodePlanner::addTravel_simple(Point p, GCodePath* path)
return *path;
}
void GCodePlanner::planPrime()
{
forceNewPathStart();
GCodePath& prime_travel = addTravel_simple(lastPosition + Point(0, 100));
prime_travel.retract = false;
prime_travel.perform_prime = true;
forceNewPathStart();
}
void GCodePlanner::addExtrusionMove(Point p, GCodePathConfig* config, SpaceFillType space_fill_type, float flow, bool spiralize)
{
@@ -407,13 +403,13 @@ void GCodePlanner::addPolygon(PolygonRef polygon, int start_idx, GCodePathConfig
}
}
void GCodePlanner::addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, EZSeamType z_seam_type, coord_t wall_0_wipe_dist, bool spiralize)
void GCodePlanner::addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, EZSeamType z_seam_type, Point z_seam_pos, coord_t wall_0_wipe_dist, bool spiralize)
{
if (polygons.size() == 0)
{
return;
}
PathOrderOptimizer orderOptimizer(lastPosition, z_seam_type);
PathOrderOptimizer orderOptimizer(lastPosition, z_seam_pos, z_seam_type);
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
orderOptimizer.addPolygon(polygons[poly_idx]);
@@ -687,7 +683,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
// prime extruder if it hadn't been used yet
gcode.writePrimeTrain(storage.meshgroup->getExtruderTrain(extruder)->getSettingInMillimetersPerSecond("speed_travel"));
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
if (extruder_plan.prev_extruder_standby_temp)
{ // turn off previous extruder
@@ -703,7 +699,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
}
else if (extruder_plan_idx == 0 && layer_nr != 0 && storage.meshgroup->getExtruderTrain(extruder)->getSettingBoolean("retract_at_layer_change"))
{
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
}
gcode.writeFanCommand(extruder_plan.getFanSpeed());
std::vector<GCodePath>& paths = extruder_plan.paths;
@@ -727,6 +723,12 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
GCodePath& path = paths[path_idx];
if (path.perform_prime)
{
gcode.writePrimeTrain(train->getSettingInMillimetersPerSecond("speed_travel"));
gcode.writeRetraction(retraction_config);
}
if (acceleration_enabled)
{
gcode.writeAcceleration(path.config->getAcceleration());
@@ -738,7 +740,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
if (path.retract)
{
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
if (path.perform_z_hop)
{
gcode.writeZhopStart(retraction_config.zHop);
@@ -857,7 +859,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
{
gcode.writeComment("Small layer, adding delay");
RetractionConfig& retraction_config = storage.retraction_config_per_extruder[gcode.getExtruderNr()];
gcode.writeRetraction(&retraction_config);
gcode.writeRetraction(retraction_config);
if (extruder_plan_idx == extruder_plans.size() - 1 || !train->getSettingBoolean("machine_extruder_end_pos_abs"))
{ // only move the head if it's the last extruder plan; otherwise it's already at the switching bay area
// or do it anyway when we switch extruder in-place
@@ -895,6 +897,7 @@ void GCodePlanner::completeConfigs()
mesh.insetX_config.setLayerHeight(layer_thickness);
mesh.skin_config.setLayerHeight(layer_thickness);
mesh.perimeter_gap_config.setLayerHeight(layer_thickness);
for(unsigned int idx=0; idx<MAX_INFILL_COMBINE; idx++)
{
mesh.infill_config[idx].setLayerHeight(layer_thickness);
@@ -953,6 +956,7 @@ void GCodePlanner::processInitialLayersSpeedup()
//Skin speed (per mesh).
mesh.skin_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
mesh.perimeter_gap_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
{
@@ -974,6 +978,7 @@ void GCodePlanner::processInitialLayersSpeedup()
mesh.inset0_config.setSpeedIconic();
mesh.insetX_config.setSpeedIconic();
mesh.skin_config.setSpeedIconic();
mesh.perimeter_gap_config.setSpeedIconic();
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
{
mesh.infill_config[idx].setSpeedIconic();
+19 -247
Ver Arquivo
@@ -6,6 +6,9 @@
#include "gcodeExport.h"
#include "pathPlanning/Comb.h"
#include "pathPlanning/GCodePath.h"
#include "pathPlanning/NozzleTempInsert.h"
#include "pathPlanning/TimeMaterialEstimates.h"
#include "utils/polygon.h"
#include "utils/logoutput.h"
#include "wallOverlap.h"
@@ -21,251 +24,6 @@ namespace cura
class SliceDataStorage;
/*!
* A gcode command to insert before a specific path.
*
* Currently only used for preheat commands
*/
struct NozzleTempInsert
{
const unsigned int path_idx; //!< The path before which to insert this command
double time_after_path_start; //!< The time after the start of the path, before which to insert the command // TODO: use this to insert command in between moves in a path!
int extruder; //!< The extruder for which to set the temp
double temperature; //!< The temperature of the temperature command to insert
bool wait; //!< Whether to wait for the temperature to be reached
NozzleTempInsert(unsigned int path_idx, int extruder, double temperature, bool wait, double time_after_path_start = 0.0)
: path_idx(path_idx)
, time_after_path_start(time_after_path_start)
, extruder(extruder)
, temperature(temperature)
, wait(wait)
{
assert(temperature != 0 && temperature != -1 && "Temperature command must be set!");
}
/*!
* Write the temperature command at the current position in the gcode.
* \param gcode The actual gcode writer
*/
void write(GCodeExport& gcode)
{
gcode.writeTemperatureCommand(extruder, temperature, wait);
}
};
class ExtruderPlan; // forward declaration so that TimeMaterialEstimates can be a friend
/*!
* Time and material estimates for a portion of paths, e.g. layer, extruder plan, path.
*/
class TimeMaterialEstimates
{
friend class ExtruderPlan; // cause there the naive estimates are calculated
private:
double extrude_time; //!< Time in seconds occupied by extrusion
double unretracted_travel_time; //!< Time in seconds occupied by non-retracted travel (non-extrusion)
double retracted_travel_time; //!< Time in seconds occupied by retracted travel (non-extrusion)
double material; //!< Material used (in mm^3)
public:
/*!
* Basic contructor
*
* \param extrude_time Time in seconds occupied by extrusion
* \param unretracted_travel_time Time in seconds occupied by non-retracted travel (non-extrusion)
* \param retracted_travel_time Time in seconds occupied by retracted travel (non-extrusion)
* \param material Material used (in mm^3)
*/
TimeMaterialEstimates(double extrude_time, double unretracted_travel_time, double retracted_travel_time, double material)
: extrude_time(extrude_time)
, unretracted_travel_time(unretracted_travel_time)
, retracted_travel_time(retracted_travel_time)
, material(material)
{
}
/*!
* Basic constructor initializing all estimates to zero.
*/
TimeMaterialEstimates()
: extrude_time(0.0)
, unretracted_travel_time(0.0)
, retracted_travel_time(0.0)
, material(0.0)
{
}
/*!
* Set all estimates to zero.
*/
void reset()
{
extrude_time = 0.0;
unretracted_travel_time = 0.0;
retracted_travel_time = 0.0;
material = 0.0;
}
/*!
* Pointwise addition of estimate stats
*
* \param other The estimates to add to these estimates.
* \return The resulting estimates
*/
TimeMaterialEstimates operator+(const TimeMaterialEstimates& other)
{
return TimeMaterialEstimates(extrude_time+other.extrude_time, unretracted_travel_time+other.unretracted_travel_time, retracted_travel_time+other.retracted_travel_time, material+other.material);
}
/*!
* In place pointwise addition of estimate stats
*
* \param other The estimates to add to these estimates.
* \return These estimates
*/
TimeMaterialEstimates& operator+=(const TimeMaterialEstimates& other)
{
extrude_time += other.extrude_time;
unretracted_travel_time += other.unretracted_travel_time;
retracted_travel_time += other.retracted_travel_time;
material += other.material;
return *this;
}
/*!
* \brief Subtracts the specified estimates from these estimates and returns
* the result.
*
* Each of the estimates in this class are individually subtracted.
*
* \param other The estimates to subtract from these estimates.
* \return These estimates with the specified estimates subtracted.
*/
TimeMaterialEstimates operator-(const TimeMaterialEstimates& other);
/*!
* \brief Subtracts the specified elements from these estimates.
*
* This causes the estimates in this instance to change. Each of the
* estimates in this class are individually subtracted.
*
* \param other The estimates to subtract from these estimates.
* \return A reference to this instance.
*/
TimeMaterialEstimates& operator-=(const TimeMaterialEstimates& other);
/*!
* Get total time estimate. The different time estimate member values added together.
*
* \return the total of all different time estimate values
*/
double getTotalTime() const
{
return extrude_time + unretracted_travel_time + retracted_travel_time;
}
/*!
* Get the total time during which the head is not retracted.
*
* This includes extrusion time and non-retracted travel time
*
* \return the total time during which the head is not retracted.
*/
double getTotalUnretractedTime() const
{
return extrude_time + unretracted_travel_time;
}
/*!
* Get the total travel time.
*
* This includes the retracted travel time as well as the unretracted travel time.
*
* \return the total travel time.
*/
double getTravelTime() const
{
return retracted_travel_time + unretracted_travel_time;
}
/*!
* Get the extrusion time.
*
* \return extrusion time.
*/
double getExtrudeTime() const
{
return extrude_time;
}
/*!
* Get the amount of material used in mm^3.
*
* \return amount of material
*/
double getMaterial() const
{
return material;
}
};
/*!
* A class for representing a planned path.
*
* A path consists of several segments of the same type of movement: retracted travel, infill extrusion, etc.
*
* This is a compact premature representation in which are line segments have the same config, i.e. the config of this path.
*
* In the final representation (gcode) each line segment may have different properties,
* which are added when the generated GCodePaths are processed.
*/
class GCodePath
{
public:
GCodePathConfig* config; //!< The configuration settings of the path.
SpaceFillType space_fill_type; //!< The type of space filling of which this path is a part
float flow; //!< A type-independent flow configuration (used for wall overlap compensation)
bool retract; //!< Whether the path is a move path preceded by a retraction move; whether the path is a retracted move path.
bool perform_z_hop; //!< Whether to perform a z_hop in this path, which is assumed to be a travel path.
std::vector<Point> points; //!< The points constituting this path.
bool done;//!< Path is finished, no more moves should be added, and a new path should be started instead of any appending done to this one.
bool spiralize; //!< Whether to gradually increment the z position during the printing of this path. A sequence of spiralized paths should start at the given layer height and end in one layer higher.
TimeMaterialEstimates estimates; //!< Naive time and material estimates
/*!
* Whether this config is the config of a travel path.
*
* \return Whether this config is the config of a travel path.
*/
bool isTravelPath()
{
return config->isTravelPath();
}
/*!
* Get the material flow in mm^3 per mm traversed.
*
* \warning Can only be called after the layer height has been set (which is done while writing the gcode!)
*
* \return The flow
*/
double getExtrusionMM3perMM()
{
return flow * config->getExtrusionMM3perMM();
}
/*!
* Get the actual line width (modulated by the flow)
* \return the actual line width as shown in layer view
*/
int getLineWidth()
{
return flow * config->getLineWidth() * config->getFlowPercentage() / 100.0;
}
};
class GCodePlanner; // forward declaration so that ExtruderPlan can be a friend
class LayerPlanBuffer; // forward declaration so that ExtruderPlan can be a friend
@@ -566,7 +324,13 @@ public:
* Features like prime tower and support are considered outside.
*/
void setIsInside(bool going_to_comb);
/*!
* Plan a switch to a new extruder
*
* \param extruder The extruder number to which to switch
* \return whether the extruder has changed
*/
bool setExtruder(int extruder);
/*!
@@ -597,6 +361,13 @@ public:
*/
GCodePath& addTravel_simple(Point p, GCodePath* path = nullptr);
/*!
* Plan a prime poop at the current location.
*
* \warning A nonretracted move is introduced so that the LayerPlanBuffer classifies this move as an extrusion move.
*/
void planPrime();
/*!
* Add an extrusion move to a certain point, optionally with a different flow than the one in the \p config.
*
@@ -632,10 +403,11 @@ public:
* \param config The config with which to print the polygon lines
* \param wall_overlap_computation The wall overlap compensation calculator for each given segment (optionally nullptr)
* \param z_seam_type The seam type / poly start optimizer
* \param z_seam_pos The location near where to start each part in case \p z_seam_type is 'back'
* \param wall_0_wipe_dist The distance to travel along each polygon after it has been laid down, in order to wipe the start and end of the wall together
* \param spiralize Whether to gradually increase the z height from the normal layer height to the height of the next layer over each polygon printed
*/
void addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, EZSeamType z_seam_type = EZSeamType::SHORTEST, coord_t wall_0_wipe_dist = 0, bool spiralize = false);
void addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, EZSeamType z_seam_type = EZSeamType::SHORTEST, Point z_seam_pos = Point(0, 0), coord_t wall_0_wipe_dist = 0, bool spiralize = false);
/*!
* Add lines to the gcode with optimized order.
+30 -11
Ver Arquivo
@@ -17,7 +17,7 @@ int Infill::computeScanSegmentIdx(int x, int line_width)
return x / line_width;
}
void Infill::generate(Polygons& result_polygons, Polygons& result_lines)
void Infill::generate(Polygons& result_polygons, Polygons& result_lines, SliceMeshStorage* mesh)
{
if (in_outline.size() == 0) return;
if (line_distance == 0) return;
@@ -48,6 +48,14 @@ void Infill::generate(Polygons& result_polygons, Polygons& result_lines)
case EFillMethod::ZIG_ZAG:
generateZigZagInfill(result_lines, line_distance, fill_angle, connected_zigzags, use_endpieces);
break;
case EFillMethod::CUBICSUBDIV:
if (!mesh)
{
logError("Cannot generate Cubic Subdivision infill without a mesh!\n");
break;
}
generateCubicSubDivInfill(result_lines, *mesh);
break;
default:
logError("Fill pattern has unknown value.\n");
break;
@@ -58,7 +66,6 @@ void Infill::generateConcentricInfill(Polygons& result, int inset_value)
{
Polygons first_concentric_wall = in_outline.offset(outline_offset - line_distance + infill_line_width / 2); // - infill_line_width / 2 cause generateConcentricInfill expects [outline] to be the outer most polygon instead of the outer outline
result.add(first_concentric_wall);
if (perimeter_gaps)
{
const Polygons inner = first_concentric_wall.offset(infill_line_width / 2 + perimeter_gaps_extra_offset);
@@ -70,6 +77,7 @@ void Infill::generateConcentricInfill(Polygons& result, int inset_value)
void Infill::generateConcentricInfill(Polygons& first_concentric_wall, Polygons& result, int inset_value)
{
result.add(first_concentric_wall);
Polygons* prev_inset = &first_concentric_wall;
Polygons next_inset;
while (prev_inset->size() > 0)
@@ -79,7 +87,7 @@ void Infill::generateConcentricInfill(Polygons& first_concentric_wall, Polygons&
if (perimeter_gaps)
{
const Polygons outer = prev_inset->offset(-infill_line_width / 2 - perimeter_gaps_extra_offset);
const Polygons inner = next_inset.offset(infill_line_width / 2 + perimeter_gaps_extra_offset);
const Polygons inner = next_inset.offset(infill_line_width / 2);
const Polygons gaps_here = outer.difference(inner);
perimeter_gaps->add(gaps_here);
}
@@ -136,15 +144,26 @@ void Infill::generateTriangleInfill(Polygons& result)
generateLineInfill(result, line_distance, fill_angle + 120, 0);
}
void Infill::generateCubicSubDivInfill(Polygons& result, SliceMeshStorage& mesh)
{
Polygons uncropped;
mesh.base_subdiv_cube->generateSubdivisionLines(z, uncropped);
addLineSegmentsInfill(result, uncropped);
}
void Infill::addLineSegmentsInfill(Polygons& result, Polygons& input)
{
ClipperLib::PolyTree interior_segments_tree = in_outline.lineSegmentIntersection(input);
ClipperLib::Paths interior_segments;
ClipperLib::OpenPathsFromPolyTree(interior_segments_tree, interior_segments);
for (uint64_t idx = 0; idx < interior_segments.size(); idx++)
{
result.addLine(interior_segments[idx][0], interior_segments[idx][1]);
}
}
void Infill::addLineInfill(Polygons& result, const PointMatrix& rotation_matrix, const int scanline_min_idx, const int line_distance, const AABB boundary, std::vector<std::vector<int64_t>>& cut_list, int64_t shift)
{
auto addLine = [&](Point from, Point to)
{
PolygonRef p = result.newPoly();
p.add(rotation_matrix.unapply(from));
p.add(rotation_matrix.unapply(to));
};
auto compare_int64_t = [](const void* a, const void* b)
{
int64_t n = (*(int64_t*)a) - (*(int64_t*)b);
@@ -170,7 +189,7 @@ void Infill::addLineInfill(Polygons& result, const PointMatrix& rotation_matrix,
{ // segment is too short to create infill
continue;
}
addLine(Point(x, crossings[crossing_idx]), Point(x, crossings[crossing_idx + 1]));
result.addLine(rotation_matrix.unapply(Point(x, crossings[crossing_idx])), rotation_matrix.unapply(Point(x, crossings[crossing_idx + 1])));
}
scanline_idx += 1;
}
+17 -1
Ver Arquivo
@@ -12,6 +12,7 @@
#include "infill/ZigzagConnectorProcessorEndPieces.h"
#include "infill/ZigzagConnectorProcessorConnectedEndPieces.h"
#include "infill/ZigzagConnectorProcessorDisconnectedEndPieces.h"
#include "infill/SubDivCube.h"
#include "utils/intpoint.h"
#include "utils/AABB.h"
@@ -77,8 +78,9 @@ public:
*
* \param result_polygons (output) The resulting polygons (from concentric infill)
* \param result_lines (output) The resulting line segments (from linear infill types)
* \param mesh The mesh for which to geenrate infill (should only be used for non-helper objects)
*/
void generate(Polygons& result_polygons, Polygons& result_lines);
void generate(Polygons& result_polygons, Polygons& result_lines, SliceMeshStorage* mesh = nullptr);
private:
/*!
@@ -140,6 +142,13 @@ private:
* \param result (output) The resulting lines
*/
void generateTriangleInfill(Polygons& result);
/*!
* Generate a 3d pattern of subdivided cubes on their points
* \param[out] result The resulting lines
* \param[in] mesh Where the Cubic Subdivision Infill precomputation is stored
*/
void generateCubicSubDivInfill(Polygons& result, SliceMeshStorage& mesh);
/*!
* Convert a mapping from scanline to line_segment-scanline-intersections (\p cut_list) into line segments, using the even-odd rule
@@ -153,6 +162,13 @@ private:
*/
void addLineInfill(Polygons& result, const PointMatrix& rotation_matrix, const int scanline_min_idx, const int line_distance, const AABB boundary, std::vector<std::vector<int64_t>>& cut_list, int64_t total_shift);
/*!
* Crop line segments by the infill polygon using Clipper
* \param result (output) The resulting lines
* \param input The line segments to be cropped
*/
void addLineSegmentsInfill(Polygons& result, Polygons& input);
/*!
* generate lines within the area of \p in_outline, at regular intervals of \p line_distance
*
+282
Ver Arquivo
@@ -0,0 +1,282 @@
#include "SubDivCube.h"
#include <functional>
#include "../utils/polygonUtils.h"
#include "../sliceDataStorage.h"
#include "../utils/math.h"
#define ONE_OVER_SQRT_2 0.7071067811865475244008443621048490392848359376884740 //1 / sqrt(2)
#define ONE_OVER_SQRT_3 0.577350269189625764509148780501957455647601751270126876018 //1 / sqrt(3)
#define ONE_OVER_SQRT_6 0.408248290463863016366214012450981898660991246776111688072 //1 / sqrt(6)
#define SQRT_TWO_THIRD 0.816496580927726032732428024901963797321982493552223376144 //sqrt(2 / 3)
namespace cura
{
std::vector<SubDivCube::CubeProperties> SubDivCube::cube_properties_per_recursion_step;
double SubDivCube::radius_multiplier = 1;
int32_t SubDivCube::radius_addition = 0;
Point3Matrix SubDivCube::rotation_matrix;
PointMatrix SubDivCube::infill_rotation_matrix;
SubDivCube::~SubDivCube()
{
for (int child_idx = 0; child_idx < 8; child_idx++)
{
if (children[child_idx])
{
delete children[child_idx];
}
}
}
void SubDivCube::precomputeOctree(SliceMeshStorage& mesh)
{
radius_multiplier = mesh.getSettingAsRatio("sub_div_rad_mult");
radius_addition = mesh.getSettingInMicrons("sub_div_rad_add");
double infill_angle = M_PI / 4.0;
coord_t furthest_dist_from_origin = std::sqrt(square(mesh.getSettingInMicrons("machine_height")) + square(mesh.getSettingInMicrons("machine_depth") / 2) + square(mesh.getSettingInMicrons("machine_width") / 2));
coord_t max_side_length = furthest_dist_from_origin * 2;
int curr_recursion_depth = 0;
const int64_t infill_line_distance = mesh.getSettingInMicrons("infill_line_distance");
if (infill_line_distance > 0)
{
for (int64_t curr_side_length = infill_line_distance * 2; curr_side_length < max_side_length * 2; curr_side_length *= 2)
{
cube_properties_per_recursion_step.emplace_back();
CubeProperties& cube_properties_here = cube_properties_per_recursion_step.back();
cube_properties_here.side_length = curr_side_length;
cube_properties_here.height = sqrt(3) * curr_side_length;
cube_properties_here.square_height = sqrt(2) * curr_side_length;
cube_properties_here.max_draw_z_diff = ONE_OVER_SQRT_3 * curr_side_length;
cube_properties_here.max_line_offset = ONE_OVER_SQRT_6 * curr_side_length;
curr_recursion_depth++;
}
}
Point3 center(0, 0, 0);
Point3Matrix tilt; // rotation matrix to get from axis aligned cubes to cubes standing on their tip
// The Z axis is transformed to go in positive Y direction
//
// cross section in a horizontal plane horizontal plane showing
// looking down at the origin O positive X and positive Y
// Z .
// /:\ Y .
// / : \ ^ .
// / : \ | .
// / .O. \ | .
// /.~' '~.\ O---->X .
// X """"""""""" Y .
tilt.matrix[0] = -ONE_OVER_SQRT_2; tilt.matrix[1] = ONE_OVER_SQRT_2; tilt.matrix[2] = 0;
tilt.matrix[3] = -ONE_OVER_SQRT_6; tilt.matrix[4] = -ONE_OVER_SQRT_6; tilt.matrix[5] = SQRT_TWO_THIRD ;
tilt.matrix[6] = ONE_OVER_SQRT_3; tilt.matrix[7] = ONE_OVER_SQRT_3; tilt.matrix[8] = ONE_OVER_SQRT_3;
infill_rotation_matrix = PointMatrix(infill_angle);
Point3Matrix infill_angle_mat(infill_rotation_matrix);
rotation_matrix = infill_angle_mat.compose(tilt);
mesh.base_subdiv_cube = new SubDivCube(mesh, center, curr_recursion_depth - 1);
}
void SubDivCube::generateSubdivisionLines(int64_t z, Polygons& result)
{
if (cube_properties_per_recursion_step.empty()) //Infill is set to 0%.
{
return;
}
Polygons directional_line_groups[3];
generateSubdivisionLines(z, result, directional_line_groups);
for (int dir_idx = 0; dir_idx < 3; dir_idx++)
{
Polygons& line_group = directional_line_groups[dir_idx];
for (unsigned int line_idx = 0; line_idx < line_group.size(); line_idx++)
{
result.addLine(line_group[line_idx][0], line_group[line_idx][1]);
}
}
}
void SubDivCube::generateSubdivisionLines(int64_t z, Polygons& result, Polygons (&directional_line_groups)[3])
{
CubeProperties cube_properties = cube_properties_per_recursion_step[depth];
int32_t z_diff = std::abs(z - center.z); //!< the difference between the cube center and the target layer.
if (z_diff > cube_properties.height / 2) //!< this cube does not touch the target layer. Early exit.
{
return;
}
if (z_diff < cube_properties.max_draw_z_diff) //!< this cube has lines that need to be drawn.
{
Point relative_a, relative_b; //!< relative coordinates of line endpoints around cube center
Point a, b; //!< absolute coordinates of line endpoints
relative_a.X = (cube_properties.square_height / 2) * (cube_properties.max_draw_z_diff - z_diff) / cube_properties.max_draw_z_diff;
relative_b.X = -relative_a.X;
relative_a.Y = cube_properties.max_line_offset - ((z - (center.z - cube_properties.max_draw_z_diff)) * ONE_OVER_SQRT_2);
relative_b.Y = relative_a.Y;
rotatePointInitial(relative_a);
rotatePointInitial(relative_b);
for (int dir_idx = 0; dir_idx < 3; dir_idx++)//!< draw the line, then rotate 120 degrees.
{
a.X = center.x + relative_a.X;
a.Y = center.y + relative_a.Y;
b.X = center.x + relative_b.X;
b.Y = center.y + relative_b.Y;
addLineAndCombine(directional_line_groups[dir_idx], a, b);
if (dir_idx < 2)
{
rotatePoint120(relative_a);
rotatePoint120(relative_b);
}
}
}
for (int idx = 0; idx < 8; idx++) //!< draws the eight children
{
if (children[idx] != nullptr)
{
children[idx]->generateSubdivisionLines(z, result, directional_line_groups);
}
}
}
SubDivCube::SubDivCube(SliceMeshStorage& mesh, Point3& center, unsigned int depth)
{
this->depth = depth;
this->center = center;
if (depth == 0) // lowest layer, no need for subdivision, exit.
{
return;
}
if (depth >= cube_properties_per_recursion_step.size()) //Depth is out of bounds of what we pre-computed.
{
return;
}
CubeProperties cube_properties = cube_properties_per_recursion_step[depth];
Point3 child_center;
coord_t radius = double(radius_multiplier * double(cube_properties.height)) / 4.0 + radius_addition;
int child_nr = 0;
std::vector<Point3> rel_child_centers;
rel_child_centers.emplace_back(1, 1, 1); // top
rel_child_centers.emplace_back(-1, 1, 1); // top three
rel_child_centers.emplace_back(1, -1, 1);
rel_child_centers.emplace_back(1, 1, -1);
rel_child_centers.emplace_back(-1, -1, -1); // bottom
rel_child_centers.emplace_back(1, -1, -1); // bottom three
rel_child_centers.emplace_back(-1, 1, -1);
rel_child_centers.emplace_back(-1, -1, 1);
for (Point3 rel_child_center : rel_child_centers)
{
child_center = center + rotation_matrix.apply(rel_child_center * int32_t(cube_properties.side_length / 4));
if (isValidSubdivision(mesh, child_center, radius))
{
children[child_nr] = new SubDivCube(mesh, child_center, depth - 1);
child_nr++;
}
}
}
bool SubDivCube::isValidSubdivision(SliceMeshStorage& mesh, Point3& center, int64_t radius)
{
int64_t distance2;
coord_t sphere_slice_radius2;//!< squared radius of bounding sphere slice on target layer
bool inside_somewhere = false;
bool outside_somewhere = false;
int inside;
double part_dist;//what percentage of the radius the target layer is away from the center along the z axis. 0 - 1
const coord_t layer_height = mesh.getSettingInMicrons("layer_height");
int bottom_layer = (center.z - radius) / layer_height;
int top_layer = (center.z + radius) / layer_height;
for (int test_layer = bottom_layer; test_layer <= top_layer; test_layer += 3) // steps of three. Low-hanging speed gain.
{
part_dist = (double)(test_layer * layer_height - center.z) / radius;
sphere_slice_radius2 = radius * radius * (1.0 - (part_dist * part_dist));
Point loc(center.x, center.y);
inside = distanceFromPointToMesh(mesh, test_layer, loc, &distance2);
if (inside == 1)
{
inside_somewhere = true;
}
else
{
outside_somewhere = true;
}
if (outside_somewhere && inside_somewhere)
{
return true;
}
if ((inside != 2) && distance2 < sphere_slice_radius2)
{
return true;
}
}
return false;
}
int SubDivCube::distanceFromPointToMesh(SliceMeshStorage& mesh, int layer_nr, Point& location, int64_t* distance2)
{
if (layer_nr < 0 || (unsigned int)layer_nr >= mesh.layers.size()) //!< this layer is outside of valid range
{
return 2;
}
Polygons collide;
mesh.layers[layer_nr].getSecondOrInnermostWalls(collide);
Point centerpoint = location;
bool inside = collide.inside(centerpoint);
ClosestPolygonPoint border_point = PolygonUtils::moveInside2(collide, centerpoint);
Point diff = border_point.location - location;
*distance2 = vSize2(diff);
if (inside)
{
return 1;
}
return 0;
}
void SubDivCube::rotatePointInitial(Point& target)
{
target = infill_rotation_matrix.apply(target);
}
void SubDivCube::rotatePoint120(Point& target)
{
constexpr double sqrt_three_fourths = 0.8660254037844386467637231707529361834714026269051903; //!< sqrt(3.0 / 4.0) = sqrt(3) / 2
int64_t x;
x = (-0.5) * target.X - sqrt_three_fourths * target.Y;
target.Y = (-0.5)*target.Y + sqrt_three_fourths * target.X;
target.X = x;
}
void SubDivCube::addLineAndCombine(Polygons& group, Point from, Point to)
{
int epsilon = 10; // the smallest distance of two points which are viewed as coincident (dist > 0 due to rounding errors)
for (unsigned int idx = 0; idx < group.size(); idx++)
{
if (std::abs(from.X - group[idx][1].X) < epsilon && std::abs(from.Y - group[idx][1].Y) < epsilon)
{
from = group[idx][0];
group.remove(idx);
idx--;
continue;
}
if (std::abs(to.X - group[idx][0].X) < epsilon && std::abs(to.Y - group[idx][0].Y) < epsilon)
{
to = group[idx][1];
group.remove(idx);
idx--;
continue;
}
}
group.addLine(from, to);
}
}//namespace cura
+98
Ver Arquivo
@@ -0,0 +1,98 @@
#ifndef INFILL_SUBDIVCUBE_H
#define INFILL_SUBDIVCUBE_H
#include "../sliceDataStorage.h"
namespace cura
{
class Infill;
class SubDivCube
{
public:
/*!
* Constructor for SubDivCube. Recursively calls itself eight times to flesh out the octree.
* \param mesh contains infill layer data and settings
* \param my_center the center of the cube
* \param depth the recursion depth of the cube (0 is most recursed)
*/
SubDivCube(SliceMeshStorage& mesh, Point3& center, unsigned int depth);
~SubDivCube(); //!< destructor (also destroys children
/*!
* Precompute the octree of subdivided cubes
* \param mesh contains infill layer data and settings
*/
static void precomputeOctree(SliceMeshStorage& mesh);
/*!
* Generates the lines of subdivision of the specific cube at the specific layer. It recursively calls itself, so it ends up drawing all the subdivision lines of sub-cubes too.
* \param z the specified layer height
* \param result (output) The resulting lines
*/
void generateSubdivisionLines(int64_t z, Polygons& result);
private:
/*!
* Generates the lines of subdivision of the specific cube at the specific layer. It recursively calls itself, so it ends up drawing all the subdivision lines of sub-cubes too.
* \param z the specified layer height
* \param result (output) The resulting lines
* \param directional_line_groups Array of 3 times a polylines. Used to keep track of line segments that are all pointing the same direction for line segment combining
*/
void generateSubdivisionLines(int64_t z, Polygons& result, Polygons (&directional_line_groups)[3]);
struct CubeProperties
{
int64_t side_length; //!< side length of cubes
int64_t height; //!< height of cubes based. This is the distance from one point of a cube to its 3d opposite.
int64_t square_height; //!< square cut across lengths. This is the diagonal distance across a face of the cube.
int64_t max_draw_z_diff; //!< maximum draw z differences. This is the maximum difference in z at which lines need to be drawn.
int64_t max_line_offset; //!< maximum line offsets. This is the maximum distance at which subdivision lines should be drawn from the 2d cube center.
};
/*!
* Rotates a point 120 degrees about the origin.
* \param target the point to rotate.
*/
static void rotatePoint120(Point& target);
/*!
* Rotates a point to align it with the orientation of the infill.
* \param target the point to rotate.
*/
static void rotatePointInitial(Point& target);
/*!
* Determines if a described theoretical cube should be subdivided based on if a sphere that encloses the cube touches the infill mesh.
* \param mesh contains infill layer data and settings
* \param center the center of the described cube
* \param radius the radius of the enclosing sphere
* \return the described cube should be subdivided
*/
static bool isValidSubdivision(SliceMeshStorage& mesh, Point3& center, int64_t radius);
/*!
* Finds the distance to the infill border at the specified layer from the specified point.
* \param mesh contains infill layer data and settings
* \param layer_nr the number of the specified layer
* \param location the location of the specified point
* \param[out] distance2 the squared distance to the infill border
* \return Code 0: outside, 1: inside, 2: boundary does not exist at specified layer
*/
static int distanceFromPointToMesh(SliceMeshStorage& mesh, int layer_nr, Point& location, int64_t* distance2);
/*!
* Adds the defined line to the specified polygons. It assumes that the specified polygons are all parallel lines. Combines line segments with touching ends closer than epsilon.
* \param[out] group the polygons to add the line to
* \param from the first endpoint of the line
* \param to the second endpoint of the line
*/
void addLineAndCombine(Polygons& group, Point from, Point to);
unsigned int depth; //!< the recursion depth of the cube (0 is most recursed)
Point3 center; //!< center location of the cube in absolute coordinates
SubDivCube* children[8] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; //!< pointers to this cube's eight octree children
static std::vector<CubeProperties> cube_properties_per_recursion_step; //!< precomputed array of basic properties of cubes based on recursion depth.
static double radius_multiplier; //!< multiplier for the bounding radius when determining if a cube should be subdivided
static Point3Matrix rotation_matrix; //!< The rotation matrix to get from axis aligned cubes to cubes standing on a corner point aligned with the infill_angle
static PointMatrix infill_rotation_matrix; //!< Horizontal rotation applied to infill
static int32_t radius_addition; //!< addition to the bounding radius when determining if a cube should be subdivided
};
}
#endif //INFILL_SUBDIVCUBE_H
+1 -3
Ver Arquivo
@@ -109,9 +109,7 @@ protected:
*/
void addLine(Point from, Point to)
{
PolygonRef line_poly = result.newPoly();
line_poly.add(rotation_matrix.unapply(from));
line_poly.add(rotation_matrix.unapply(to));
result.addLine(rotation_matrix.unapply(from), rotation_matrix.unapply(to));
}
/*!
+4 -1
Ver Arquivo
@@ -44,7 +44,10 @@ void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, bool uni
}
void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer, bool union_layers, bool union_all_remove_holes)
{
for(unsigned int layer_nr = 0; layer_nr < slicer->layers.size(); layer_nr++)
const auto total_layers = slicer->layers.size();
assert(mesh.layers.size() == total_layers);
#pragma omp parallel for default(none) shared(mesh,slicer) firstprivate(union_layers,union_all_remove_holes) schedule(dynamic)
for(unsigned int layer_nr = 0; layer_nr < total_layers; layer_nr++)
{
mesh.layers[layer_nr].sliceZ = slicer->layers[layer_nr].z;
mesh.layers[layer_nr].printZ = slicer->layers[layer_nr].z;
+18 -2
Ver Arquivo
@@ -20,6 +20,10 @@
#include "settings/SettingsToGV.h"
#ifdef _OPENMP
#include <omp.h> // omp_get_num_threads
#endif
namespace cura
{
@@ -328,7 +332,19 @@ int main(int argc, char **argv)
print_usage();
exit(1);
}
#pragma omp parallel
{
#pragma omp master
{
#ifdef _OPENMP
log("OpenMP multithreading enabled, likely number of threads to be used: %u\n", omp_get_num_threads());
#else
log("OpenMP multithreading disabled\n");
#endif
}
}
if (stringcasecompare(argv[1], "connect") == 0)
{
connect(argc, argv);
@@ -423,4 +439,4 @@ int main(int argc, char **argv)
}
return 0;
}
}
+1 -19
Ver Arquivo
@@ -92,7 +92,7 @@ int PathOrderOptimizer::getPolyStart(Point prev_point, int poly_idx)
{
switch (type)
{
case EZSeamType::BACK: return getFarthestPointInPolygon(poly_idx);
case EZSeamType::BACK: return getClosestPointInPolygon(z_seam_pos, poly_idx);
case EZSeamType::RANDOM: return getRandomPointInPolygon(poly_idx);
case EZSeamType::SHORTEST: return getClosestPointInPolygon(prev_point, poly_idx);
default: return getClosestPointInPolygon(prev_point, poly_idx);
@@ -129,24 +129,6 @@ int PathOrderOptimizer::getRandomPointInPolygon(int poly_idx)
return rand() % polygons[poly_idx].size();
}
int PathOrderOptimizer::getFarthestPointInPolygon(int poly_idx)
{
PolygonRef poly = polygons[poly_idx];
int best_point_idx = -1;
float best_y = std::numeric_limits<float>::min();
for(unsigned int point_idx=0 ; point_idx<poly.size() ; point_idx++)
{
if (poly[point_idx].Y > best_y)
{
best_point_idx = point_idx;
best_y = poly[point_idx].Y;
}
}
return best_point_idx;
}
/**
*
*/
+10 -2
Ver Arquivo
@@ -19,13 +19,15 @@ class PathOrderOptimizer
public:
EZSeamType type;
Point startPoint; //!< A location near the prefered start location
Point z_seam_pos; //!< The position near where to create the z_seam (if \ref PathOrderOptimizer::type == 'back')
std::vector<PolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
std::vector<int> polyStart; //!< polygons[i][polyStart[i]] = point of polygon i which is to be the starting point in printing the polygon
std::vector<int> polyOrder; //!< the optimized order as indices in #polygons
PathOrderOptimizer(Point startPoint, EZSeamType type = EZSeamType::SHORTEST)
PathOrderOptimizer(Point startPoint, Point z_seam_pos = Point(0, 0), EZSeamType type = EZSeamType::SHORTEST)
: type(type)
, startPoint(startPoint)
, z_seam_pos(z_seam_pos)
{
}
@@ -43,9 +45,15 @@ public:
void optimize(); //!< sets #polyStart and #polyOrder
private:
/*!
* Get the starting vertex of a polygon, depending on the \ref PathOrderOptimizer::type
* \param prev_point The previous planned location
* \param poly_idx The index of the polygon in \ref PathOrderOptimizer::polygons
* \return the index of the starting vertex in \ref PathOrderOptimizer::polygons[\p poly_idx]
*/
int getPolyStart(Point prev_point, int poly_idx);
int getClosestPointInPolygon(Point prev, int i_polygon); //!< returns the index of the closest point
int getFarthestPointInPolygon(int poly_idx); //!< return the index to the point farthest from the front (highest y)
int getRandomPointInPolygon(int poly_idx);
+1 -1
Ver Arquivo
@@ -245,7 +245,7 @@ void Comb::Crossing::findCrossingInOrMid(const PartsView& partsView_inside, cons
dest_part = partsView_inside.assemblePart(dest_part_idx);
ClosestPolygonPoint boundary_crossing_point;
{ // set [result] to a point on the destination part closest to close_to (but also a bit close to fest_point)
{ // set [result] to a point on the destination part closest to close_to (but also a bit close to _dest_point)
std::unordered_set<unsigned int> dest_part_poly_indices;
for (unsigned int poly_idx : partsView_inside[dest_part_idx])
{
+24
Ver Arquivo
@@ -0,0 +1,24 @@
//Copyright (C) 2016 Ultimaker
//Released under terms of the AGPLv3 License
#include "GCodePath.h"
namespace cura
{
bool GCodePath::isTravelPath()
{
return config->isTravelPath();
}
double GCodePath::getExtrusionMM3perMM()
{
return flow * config->getExtrusionMM3perMM();
}
int GCodePath::getLineWidth()
{
return flow * config->getLineWidth() * config->getFlowPercentage() / 100.0;
}
}
+64
Ver Arquivo
@@ -0,0 +1,64 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_G_CODE_PATH_H
#define PATH_PLANNING_G_CODE_PATH_H
#include "../SpaceFillType.h"
#include "../GCodePathConfig.h"
#include "TimeMaterialEstimates.h"
namespace cura
{
/*!
* A class for representing a planned path.
*
* A path consists of several segments of the same type of movement: retracted travel, infill extrusion, etc.
*
* This is a compact premature representation in which are line segments have the same config, i.e. the config of this path.
*
* In the final representation (gcode) each line segment may have different properties,
* which are added when the generated GCodePaths are processed.
*/
class GCodePath
{
public:
GCodePathConfig* config; //!< The configuration settings of the path.
SpaceFillType space_fill_type; //!< The type of space filling of which this path is a part
float flow; //!< A type-independent flow configuration (used for wall overlap compensation)
bool retract; //!< Whether the path is a move path preceded by a retraction move; whether the path is a retracted move path.
bool perform_z_hop; //!< Whether to perform a z_hop in this path, which is assumed to be a travel path.
bool perform_prime; //!< Whether this path is preceded by a prime (poop)
std::vector<Point> points; //!< The points constituting this path.
bool done;//!< Path is finished, no more moves should be added, and a new path should be started instead of any appending done to this one.
bool spiralize; //!< Whether to gradually increment the z position during the printing of this path. A sequence of spiralized paths should start at the given layer height and end in one layer higher.
TimeMaterialEstimates estimates; //!< Naive time and material estimates
/*!
* Whether this config is the config of a travel path.
*
* \return Whether this config is the config of a travel path.
*/
bool isTravelPath();
/*!
* Get the material flow in mm^3 per mm traversed.
*
* \warning Can only be called after the layer height has been set (which is done while writing the gcode!)
*
* \return The flow
*/
double getExtrusionMM3perMM();
/*!
* Get the actual line width (modulated by the flow)
* \return the actual line width as shown in layer view
*/
int getLineWidth();
};
}//namespace cura
#endif//PATH_PLANNING_G_CODE_PATH_H
+24
Ver Arquivo
@@ -0,0 +1,24 @@
//Copyright (C) 2016 Ultimaker
//Released under terms of the AGPLv3 License
#include "NozzleTempInsert.h"
namespace cura
{
NozzleTempInsert::NozzleTempInsert(unsigned int path_idx, int extruder, double temperature, bool wait, double time_after_path_start)
: path_idx(path_idx)
, time_after_path_start(time_after_path_start)
, extruder(extruder)
, temperature(temperature)
, wait(wait)
{
assert(temperature != 0 && temperature != -1 && "Temperature command must be set!");
}
void NozzleTempInsert::write(GCodeExport& gcode)
{
gcode.writeTemperatureCommand(extruder, temperature, wait);
}
}
+32
Ver Arquivo
@@ -0,0 +1,32 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_NOZZLE_TEMP_INSERT_H
#define PATH_PLANNING_NOZZLE_TEMP_INSERT_H
#include "../gcodeExport.h"
namespace cura
{
/*!
* A gcode command to insert before a specific path.
*
* Currently only used for preheat commands
*/
struct NozzleTempInsert
{
const unsigned int path_idx; //!< The path before which to insert this command
double time_after_path_start; //!< The time after the start of the path, before which to insert the command // TODO: use this to insert command in between moves in a path!
int extruder; //!< The extruder for which to set the temp
double temperature; //!< The temperature of the temperature command to insert
bool wait; //!< Whether to wait for the temperature to be reached
NozzleTempInsert(unsigned int path_idx, int extruder, double temperature, bool wait, double time_after_path_start = 0.0);
/*!
* Write the temperature command at the current position in the gcode.
* \param gcode The actual gcode writer
*/
void write(GCodeExport& gcode);
};
}//namespace cura
#endif//PATH_PLANNING_NOZZLE_TEMP_INSERT_H
+84
Ver Arquivo
@@ -0,0 +1,84 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "TimeMaterialEstimates.h"
namespace cura
{
TimeMaterialEstimates::TimeMaterialEstimates(double extrude_time, double unretracted_travel_time, double retracted_travel_time, double material)
: extrude_time(extrude_time)
, unretracted_travel_time(unretracted_travel_time)
, retracted_travel_time(retracted_travel_time)
, material(material)
{
}
TimeMaterialEstimates::TimeMaterialEstimates()
: extrude_time(0.0)
, unretracted_travel_time(0.0)
, retracted_travel_time(0.0)
, material(0.0)
{
}
TimeMaterialEstimates TimeMaterialEstimates::operator-(const TimeMaterialEstimates& other)
{
return TimeMaterialEstimates(extrude_time - other.extrude_time,unretracted_travel_time - other.unretracted_travel_time,retracted_travel_time - other.retracted_travel_time,material - other.material);
}
TimeMaterialEstimates& TimeMaterialEstimates::operator-=(const TimeMaterialEstimates& other)
{
extrude_time -= other.extrude_time;
unretracted_travel_time -= other.unretracted_travel_time;
retracted_travel_time -= other.retracted_travel_time;
material -= other.material;
return *this;
}
TimeMaterialEstimates TimeMaterialEstimates::operator+(const TimeMaterialEstimates& other)
{
return TimeMaterialEstimates(extrude_time+other.extrude_time, unretracted_travel_time+other.unretracted_travel_time, retracted_travel_time+other.retracted_travel_time, material+other.material);
}
TimeMaterialEstimates& TimeMaterialEstimates::operator+=(const TimeMaterialEstimates& other)
{
extrude_time += other.extrude_time;
unretracted_travel_time += other.unretracted_travel_time;
retracted_travel_time += other.retracted_travel_time;
material += other.material;
return *this;
}
double TimeMaterialEstimates::getExtrudeTime() const
{
return extrude_time;
}
double TimeMaterialEstimates::getMaterial() const
{
return material;
}
double TimeMaterialEstimates::getTotalTime() const
{
return extrude_time + unretracted_travel_time + retracted_travel_time;
}
double TimeMaterialEstimates::getTotalUnretractedTime() const
{
return extrude_time + unretracted_travel_time;
}
double TimeMaterialEstimates::getTravelTime() const
{
return retracted_travel_time + unretracted_travel_time;
}
void TimeMaterialEstimates::reset()
{
extrude_time = 0.0;
unretracted_travel_time = 0.0;
retracted_travel_time = 0.0;
material = 0.0;
}
}//namespace cura
+124
Ver Arquivo
@@ -0,0 +1,124 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_TIME_MATERIAL_ESTIMATES_H
#define PATH_PLANNING_TIME_MATERIAL_ESTIMATES_H
#include "../gcodeExport.h"
namespace cura
{
class ExtruderPlan; // forward declaration so that TimeMaterialEstimates can be a friend
/*!
* Time and material estimates for a portion of paths, e.g. layer, extruder plan, path.
*/
class TimeMaterialEstimates
{
friend class ExtruderPlan; // cause there the naive estimates are calculated
private:
double extrude_time; //!< Time in seconds occupied by extrusion
double unretracted_travel_time; //!< Time in seconds occupied by non-retracted travel (non-extrusion)
double retracted_travel_time; //!< Time in seconds occupied by retracted travel (non-extrusion)
double material; //!< Material used (in mm^3)
public:
/*!
* Basic contructor
*
* \param extrude_time Time in seconds occupied by extrusion
* \param unretracted_travel_time Time in seconds occupied by non-retracted travel (non-extrusion)
* \param retracted_travel_time Time in seconds occupied by retracted travel (non-extrusion)
* \param material Material used (in mm^3)
*/
TimeMaterialEstimates(double extrude_time, double unretracted_travel_time, double retracted_travel_time, double material);
/*!
* Basic constructor initializing all estimates to zero.
*/
TimeMaterialEstimates();
/*!
* Set all estimates to zero.
*/
void reset();
/*!
* Pointwise addition of estimate stats
*
* \param other The estimates to add to these estimates.
* \return The resulting estimates
*/
TimeMaterialEstimates operator+(const TimeMaterialEstimates& other);
/*!
* In place pointwise addition of estimate stats
*
* \param other The estimates to add to these estimates.
* \return These estimates
*/
TimeMaterialEstimates& operator+=(const TimeMaterialEstimates& other);
/*!
* \brief Subtracts the specified estimates from these estimates and returns
* the result.
*
* Each of the estimates in this class are individually subtracted.
*
* \param other The estimates to subtract from these estimates.
* \return These estimates with the specified estimates subtracted.
*/
TimeMaterialEstimates operator-(const TimeMaterialEstimates& other);
/*!
* \brief Subtracts the specified elements from these estimates.
*
* This causes the estimates in this instance to change. Each of the
* estimates in this class are individually subtracted.
*
* \param other The estimates to subtract from these estimates.
* \return A reference to this instance.
*/
TimeMaterialEstimates& operator-=(const TimeMaterialEstimates& other);
/*!
* Get total time estimate. The different time estimate member values added together.
*
* \return the total of all different time estimate values
*/
double getTotalTime() const;
/*!
* Get the total time during which the head is not retracted.
*
* This includes extrusion time and non-retracted travel time
*
* \return the total time during which the head is not retracted.
*/
double getTotalUnretractedTime() const;
/*!
* Get the total travel time.
*
* This includes the retracted travel time as well as the unretracted travel time.
*
* \return the total travel time.
*/
double getTravelTime() const;
/*!
* Get the extrusion time.
*
* \return extrusion time.
*/
double getExtrudeTime() const;
/*!
* Get the amount of material used in mm^3.
*
* \return amount of material
*/
double getMaterial() const;
};
}//namespace cura
#endif//PATH_PLANNING_TIME_MATERIAL_ESTIMATES_H
+1 -1
Ver Arquivo
@@ -43,7 +43,7 @@ int Raft::getZdiffBetweenRaftAndLayer1(const SliceDataStorage& storage)
{
return 0;
}
const int64_t airgap = std::max(0, train.getSettingInMicrons("raft_airgap"));
const int64_t airgap = std::max((coord_t)0, train.getSettingInMicrons("raft_airgap"));
const int64_t layer_0_overlap = storage.getSettingInMicrons("layer_0_z_overlap");
const int64_t layer_height_0 = storage.getSettingInMicrons("layer_height_0");
+10 -8
Ver Arquivo
@@ -125,6 +125,11 @@ bool SettingRegistry::getDefinitionFile(const std::string machine_id, std::strin
int SettingRegistry::loadExtruderJSONsettings(unsigned int extruder_nr, SettingsBase* settings_base)
{
if (extruder_train_ids.empty())
{
logError("Couldn't find any extruder trains!\n");
return -1;
}
if (extruder_nr >= extruder_train_ids.size())
{
logWarning("Couldn't load extruder.def.json file for extruder %i. Index out of bounds.\n Loading first extruder definition instead.\n", extruder_nr);
@@ -220,8 +225,7 @@ int SettingRegistry::loadJSONsettingsFromDoc(rapidjson::Document& json_document,
if (json_document.HasMember("settings"))
{
std::list<std::string> path;
handleChildren(json_document["settings"], path, settings_base, warn_duplicates);
handleChildren(json_document["settings"], settings_base, warn_duplicates);
}
if (json_document.HasMember("overrides"))
@@ -243,7 +247,7 @@ int SettingRegistry::loadJSONsettingsFromDoc(rapidjson::Document& json_document,
return 0;
}
void SettingRegistry::handleChildren(const rapidjson::Value& settings_list, std::list<std::string>& path, SettingsBase* settings_base, bool warn_duplicates)
void SettingRegistry::handleChildren(const rapidjson::Value& settings_list, SettingsBase* settings_base, bool warn_duplicates)
{
if (!settings_list.IsObject())
{
@@ -252,12 +256,10 @@ void SettingRegistry::handleChildren(const rapidjson::Value& settings_list, std:
}
for (rapidjson::Value::ConstMemberIterator setting_iterator = settings_list.MemberBegin(); setting_iterator != settings_list.MemberEnd(); ++setting_iterator)
{
handleSetting(setting_iterator, path, settings_base, warn_duplicates);
handleSetting(setting_iterator, settings_base, warn_duplicates);
if (setting_iterator->value.HasMember("children"))
{
std::list<std::string> path_here = path;
path_here.push_back(setting_iterator->name.GetString());
handleChildren(setting_iterator->value["children"], path_here, settings_base, warn_duplicates);
handleChildren(setting_iterator->value["children"], settings_base, warn_duplicates);
}
}
}
@@ -275,7 +277,7 @@ bool SettingRegistry::settingIsUsedByEngine(const rapidjson::Value& setting)
}
void SettingRegistry::handleSetting(const rapidjson::Value::ConstMemberIterator& json_setting_it, std::list<std::string>& path, SettingsBase* settings_base, bool warn_duplicates)
void SettingRegistry::handleSetting(const rapidjson::Value::ConstMemberIterator& json_setting_it, SettingsBase* settings_base, bool warn_duplicates)
{
const rapidjson::Value& json_setting = json_setting_it->value;
if (!json_setting.IsObject())
+2 -3
Ver Arquivo
@@ -174,17 +174,16 @@ private:
* \param settings_base The settings base where to store the default values.
* \param warn_duplicates whether to warn for duplicate setting definitions
*/
void handleChildren(const rapidjson::Value& settings_list, std::list<std::string>& path, SettingsBase* settings_base, bool warn_duplicates);
void handleChildren(const rapidjson::Value& settings_list, SettingsBase* settings_base, bool warn_duplicates);
/*!
* Handle a json object for a setting.
*
* \param json_setting_it Iterator for the setting which contains the key (setting name) and attributes info
* \param path The path of (internal) setting names traversed to get to this object
* \param settings_base The settings base where to store the default values.
* \param warn_duplicates whether to warn for duplicate setting definitions
*/
void handleSetting(const rapidjson::Value::ConstMemberIterator& json_setting_it, std::list<std::string>& path, SettingsBase* settings_base, bool warn_duplicates);
void handleSetting(const rapidjson::Value::ConstMemberIterator& json_setting_it, SettingsBase* settings_base, bool warn_duplicates);
};
}//namespace cura
+19 -9
Ver Arquivo
@@ -93,21 +93,23 @@ void SettingsBase::setSettingInheritBase(std::string key, const SettingsBaseVirt
std::string SettingsBase::getSettingString(std::string key) const
{
if (setting_values.find(key) != setting_values.end())
auto value_it = setting_values.find(key);
if (value_it != setting_values.end())
{
return setting_values.at(key);
return value_it->second;
}
if (setting_inherit_base.find(key) != setting_inherit_base.end())
auto inherit_override_it = setting_inherit_base.find(key);
if (inherit_override_it != setting_inherit_base.end())
{
return setting_inherit_base.at(key)->getSettingString(key);
return inherit_override_it->second->getSettingString(key);
}
if (parent)
{
return parent->getSettingString(key);
}
const_cast<SettingsBase&>(*this).setting_values[key] = "";
cura::logWarning("Unregistered setting %s\n", key.c_str());
cura::logError("Trying to retrieve unregistered setting with no value given: '%s'\n", key.c_str());
std::exit(-1);
return "";
}
@@ -156,7 +158,7 @@ double SettingsBaseVirtual::getSettingInMillimeters(std::string key) const
return atof(value.c_str());
}
int SettingsBaseVirtual::getSettingInMicrons(std::string key) const
coord_t SettingsBaseVirtual::getSettingInMicrons(std::string key) const
{
return getSettingInMillimeters(key) * 1000.0;
}
@@ -210,6 +212,12 @@ double SettingsBaseVirtual::getSettingInPercentage(std::string key) const
return std::max(0.0, atof(value.c_str()));
}
double SettingsBaseVirtual::getSettingAsRatio(std::string key) const
{
std::string value = getSettingString(key);
return atof(value.c_str()) / 100.0;
}
double SettingsBaseVirtual::getSettingInSeconds(std::string key) const
{
std::string value = getSettingString(key);
@@ -345,6 +353,8 @@ EFillMethod SettingsBaseVirtual::getSettingAsFillMethod(std::string key) const
return EFillMethod::GRID;
if (value == "cubic")
return EFillMethod::CUBIC;
if (value == "cubicsubdiv")
return EFillMethod::CUBICSUBDIV;
if (value == "tetrahedral")
return EFillMethod::TETRAHEDRAL;
if (value == "triangles")
@@ -418,7 +428,7 @@ FillPerimeterGapMode SettingsBaseVirtual::getSettingAsFillPerimeterGapMode(std::
return FillPerimeterGapMode::NOWHERE;
}
CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key)
CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key) const
{
std::string value = getSettingString(key);
if (value == "off")
@@ -436,7 +446,7 @@ CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key)
return CombingMode::ALL;
}
SupportDistPriority SettingsBaseVirtual::getSettingAsSupportDistPriority(std::string key)
SupportDistPriority SettingsBaseVirtual::getSettingAsSupportDistPriority(std::string key) const
{
std::string value = getSettingString(key);
if (value == "xy_overrides_z")
+5 -3
Ver Arquivo
@@ -105,6 +105,7 @@ enum class EFillMethod
LINES,
GRID,
CUBIC,
CUBICSUBDIV,
TETRAHEDRAL,
TRIANGLES,
CONCENTRIC,
@@ -230,12 +231,13 @@ public:
double getSettingInAngleDegrees(std::string key) const;
double getSettingInAngleRadians(std::string key) const;
double getSettingInMillimeters(std::string key) const;
int getSettingInMicrons(std::string key) const;
coord_t getSettingInMicrons(std::string key) const;
bool getSettingBoolean(std::string key) const;
double getSettingInDegreeCelsius(std::string key) const;
double getSettingInMillimetersPerSecond(std::string key) const;
double getSettingInCubicMillimeters(std::string key) const;
double getSettingInPercentage(std::string key) const;
double getSettingAsRatio(std::string key) const; //!< For settings which are provided in percentage
double getSettingInSeconds(std::string key) const;
FlowTempGraph getSettingAsFlowTempGraph(std::string key) const;
@@ -249,8 +251,8 @@ public:
EZSeamType getSettingAsZSeamType(std::string key) const;
ESurfaceMode getSettingAsSurfaceMode(std::string key) const;
FillPerimeterGapMode getSettingAsFillPerimeterGapMode(std::string key) const;
CombingMode getSettingAsCombingMode(std::string key);
SupportDistPriority getSettingAsSupportDistPriority(std::string key);
CombingMode getSettingAsCombingMode(std::string key) const;
SupportDistPriority getSettingAsSupportDistPriority(std::string key) const;
};
class SettingRegistry;
+50 -5
Ver Arquivo
@@ -10,7 +10,16 @@
namespace cura
{
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateSkinAreas reads data from mesh.layers.parts[*].insets and writes to mesh.layers[n].parts[*].skin_parts
* generateSkinInsets only read/writes the skin_parts from the current layer.
*
* generateSkins therefore reads (depends on) data from mesh.layers[*].parts[*].insets and writes mesh.layers[n].parts[*].skin_parts
*/
void generateSkins(int layerNr, SliceMeshStorage& mesh, int downSkinCount, int upSkinCount, int wall_line_count, int innermost_wall_line_width, int insetCount, bool no_small_gaps_heuristic)
{
generateSkinAreas(layerNr, mesh, innermost_wall_line_width, downSkinCount, upSkinCount, wall_line_count, no_small_gaps_heuristic);
@@ -23,6 +32,12 @@ void generateSkins(int layerNr, SliceMeshStorage& mesh, int downSkinCount, int u
}
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateSkinAreas reads data from mesh.layers[*].parts[*].insets and writes to mesh.layers[n].parts[*].skin_parts
*/
void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost_wall_line_width, int downSkinCount, int upSkinCount, int wall_line_count, bool no_small_gaps_heuristic)
{
SliceLayer& layer = mesh.layers[layer_nr];
@@ -31,7 +46,7 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
{
return;
}
int min_infill_area = mesh.getSettingInMillimeters("min_infill_area");
for(unsigned int partNr = 0; partNr < layer.parts.size(); partNr++)
{
SliceLayerPart& part = layer.parts[partNr];
@@ -63,12 +78,22 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
{
if (static_cast<int>(layer_nr - downSkinCount) >= 0)
{
downskin = downskin.difference(getInsidePolygons(mesh.layers[layer_nr - downSkinCount])); // skin overlaps with the walls
Polygons not_air = getInsidePolygons(mesh.layers[layer_nr - downSkinCount]);
if (min_infill_area > 0)
{
not_air.removeSmallAreas(min_infill_area);
}
downskin = downskin.difference(not_air); // skin overlaps with the walls
}
if (static_cast<int>(layer_nr + upSkinCount) < static_cast<int>(mesh.layers.size()))
{
upskin = upskin.difference(getInsidePolygons(mesh.layers[layer_nr + upSkinCount])); // skin overlaps with the walls
Polygons not_air = getInsidePolygons(mesh.layers[layer_nr + upSkinCount]);
if (min_infill_area > 0)
{
not_air.removeSmallAreas(min_infill_area);
}
upskin = upskin.difference(not_air); // skin overlaps with the walls
}
}
else
@@ -80,6 +105,10 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
{
not_air = not_air.intersection(getInsidePolygons(mesh.layers[downskin_layer_nr]));
}
if (min_infill_area > 0)
{
not_air.removeSmallAreas(min_infill_area);
}
downskin = downskin.difference(not_air); // skin overlaps with the walls
}
@@ -90,6 +119,10 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
{
not_air = not_air.intersection(getInsidePolygons(mesh.layers[upskin_layer_nr]));
}
if (min_infill_area > 0)
{
not_air.removeSmallAreas(min_infill_area);
}
upskin = upskin.difference(not_air); // skin overlaps with the walls
}
}
@@ -106,7 +139,12 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
}
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateSkinInsets only read/writes the skin_parts from the current layer.
*/
void generateSkinInsets(SliceLayerPart* part, const int wall_line_width, int insetCount)
{
if (insetCount == 0)
@@ -139,6 +177,12 @@ void generateSkinInsets(SliceLayerPart* part, const int wall_line_width, int ins
}
}
/*
* This function is executed in a parallel region based on layer_nr.
* When modifying make sure any changes does not introduce data races.
*
* generateInfill read mesh.layers[n].parts[*].{insets,skin_parts,boundingBox} and write mesh.layers[n].parts[*].infill_area
*/
void generateInfill(int layerNr, SliceMeshStorage& mesh, const int innermost_wall_line_width, int infill_skin_overlap, int wall_line_count)
{
SliceLayer& layer = mesh.layers[layerNr];
@@ -146,6 +190,7 @@ void generateInfill(int layerNr, SliceMeshStorage& mesh, const int innermost_wal
int extra_offset = 0;
EFillMethod fill_pattern = mesh.getSettingAsFillMethod("infill_pattern");
if ((fill_pattern == EFillMethod::CONCENTRIC || fill_pattern == EFillMethod::CONCENTRIC_3D)
&& mesh.getSettingBoolean("alternate_extra_perimeter")
&& layerNr % 2 == 0
&& mesh.getSettingInMicrons("infill_line_distance") > mesh.getSettingInMicrons("infill_line_width") * 2)
{
+24 -4
Ver Arquivo
@@ -1,6 +1,11 @@
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "sliceDataStorage.h"
#include "FffProcessor.h" //To create a mesh group with if none is provided.
#include "infill/SubDivCube.h" // For the destructor
namespace cura
{
@@ -67,6 +72,14 @@ void SliceLayer::getSecondOrInnermostWalls(Polygons& layer_walls) const
}
}
SliceMeshStorage::~SliceMeshStorage()
{
if (base_subdiv_cube)
{
delete base_subdiv_cube;
}
}
std::vector<RetractionConfig> SliceDataStorage::initializeRetractionConfigs()
{
std::vector<RetractionConfig> ret;
@@ -106,7 +119,8 @@ SliceDataStorage::SliceDataStorage(MeshGroup* meshgroup) : SettingsMessenger(mes
raft_surface_config(PrintFeatureType::SupportInterface),
support_config(PrintFeatureType::Support),
support_skin_config(PrintFeatureType::SupportInterface),
max_print_height_second_to_last_extruder(-1)
max_print_height_second_to_last_extruder(-1),
primeTower(*this)
{
}
@@ -162,7 +176,10 @@ Polygons SliceDataStorage::getLayerOutlines(int layer_nr, bool include_helper_pa
total.add(support.supportLayers[std::max(0, layer_nr)].supportAreas);
total.add(support.supportLayers[std::max(0, layer_nr)].skin);
}
total.add(primeTower.ground_poly);
if (primeTower.enabled)
{
total.add(primeTower.ground_poly);
}
}
return total;
}
@@ -190,7 +207,7 @@ Polygons SliceDataStorage::getLayerSecondOrInnermostWalls(int layer_nr, bool inc
{
const SliceLayer& layer = mesh.layers[layer_nr];
layer.getSecondOrInnermostWalls(total);
if (const_cast<SliceMeshStorage&>(mesh).getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL) // TODO: make getSetting const? make settings.setting_values mapping mutable??
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
{
total = total.unionPolygons(layer.openPolyLines.offsetPolyLine(100));
}
@@ -203,7 +220,10 @@ Polygons SliceDataStorage::getLayerSecondOrInnermostWalls(int layer_nr, bool inc
total.add(support.supportLayers[std::max(0, layer_nr)].supportAreas);
total.add(support.supportLayers[std::max(0, layer_nr)].skin);
}
total.add(primeTower.ground_poly);
if (primeTower.enabled)
{
total.add(primeTower.ground_poly);
}
}
return total;
}
+9
Ver Arquivo
@@ -143,6 +143,8 @@ public:
};
/******************/
class SubDivCube; // forward declaration to prevent dependency loop
class SliceMeshStorage : public SettingsMessenger // passes on settings from a Mesh object
{
public:
@@ -153,20 +155,27 @@ public:
GCodePathConfig inset0_config;
GCodePathConfig insetX_config;
GCodePathConfig skin_config;
GCodePathConfig perimeter_gap_config;
std::vector<GCodePathConfig> infill_config;
SubDivCube* base_subdiv_cube;
SliceMeshStorage(SettingsBaseVirtual* settings, unsigned int slice_layer_count)
: SettingsMessenger(settings)
, layer_nr_max_filled_layer(0)
, inset0_config(PrintFeatureType::OuterWall)
, insetX_config(PrintFeatureType::InnerWall)
, skin_config(PrintFeatureType::Skin)
, perimeter_gap_config(PrintFeatureType::Skin)
, base_subdiv_cube(nullptr)
{
layers.resize(slice_layer_count);
infill_config.reserve(MAX_INFILL_COMBINE);
for(int n=0; n<MAX_INFILL_COMBINE; n++)
infill_config.emplace_back(PrintFeatureType::Infill);
}
virtual ~SliceMeshStorage();
};
class SliceDataStorage : public SettingsMessenger, NoCopy
+7 -3
Ver Arquivo
@@ -759,7 +759,7 @@ void SlicerLayer::makePolygons(const Mesh* mesh, bool keep_none_closed, bool ext
for (PolygonRef polyline : open_polylines)
{
if (polyline.size() > 0)
openPolylines.add(polyline);
polygons.add(polyline);
}
}
@@ -887,10 +887,14 @@ Slicer::Slicer(Mesh* mesh, int initial, int thickness, int slice_layer_count, bo
}
}
log("slice of mesh took %.3f seconds\n",slice_timer.restart());
for(unsigned int layer_nr=0; layer_nr<layers.size(); layer_nr++)
std::vector<SlicerLayer>& layers_ref = layers; // force layers not to be copied into the threads
#pragma omp parallel for default(none) shared(mesh,layers_ref) firstprivate(keep_none_closed, extensive_stitching)
for(unsigned int layer_nr=0; layer_nr<layers_ref.size(); layer_nr++)
{
layers[layer_nr].makePolygons(mesh, keep_none_closed, extensive_stitching);
layers_ref[layer_nr].makePolygons(mesh, keep_none_closed, extensive_stitching);
}
mesh->expandXY(mesh->getSettingInMicrons("xy_offset"));
log("slice make polygons took %.3f seconds\n",slice_timer.restart());
}
+80 -53
Ver Arquivo
@@ -1,4 +1,7 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
//Copyright (C) 2013 David Braam
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include <cmath> // sqrt
#include <utility> // pair
#include <deque>
@@ -87,6 +90,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int l
storage.support.supportLayers.resize(layer_count);
}
// generate support areas
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
@@ -97,25 +101,33 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int l
std::vector<Polygons> supportAreas;
supportAreas.resize(layer_count, Polygons());
generateSupportAreas(storage, mesh_idx, layer_count, supportAreas);
if (mesh.getSettingBoolean("support_interface_enable"))
for (unsigned int layer_idx = 0; layer_idx < layer_count; layer_idx++)
{
generateSupportInterface(storage, mesh, supportAreas, layer_count);
}
else
{
for (unsigned int layer_idx = 0; layer_idx < layer_count ; layer_idx++)
{
storage.support.supportLayers[layer_idx].supportAreas.add(supportAreas[layer_idx]);
}
storage.support.supportLayers[layer_idx].supportAreas.add(supportAreas[layer_idx]);
}
}
for (unsigned int layer_idx = 0; layer_idx < layer_count ; layer_idx++)
{
Polygons& support_areas = storage.support.supportLayers[layer_idx].supportAreas;
support_areas = support_areas.unionPolygons();
}
// handle support interface
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
if (mesh.getSettingBoolean("infill_mesh") || mesh.getSettingBoolean("anti_overhang_mesh"))
{
continue;
}
if (mesh.getSettingBoolean("support_interface_enable"))
{
generateSupportInterface(storage, mesh, layer_count);
}
}
}
/*
@@ -153,6 +165,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
const int supportTowerDiameter = mesh.getSettingInMicrons("support_tower_diameter");
const int supportMinAreaSqrt = mesh.getSettingInMicrons("support_minimal_diameter");
const double supportTowerRoofAngle = mesh.getSettingInAngleRadians("support_tower_roof_angle");
const bool use_towers = mesh.getSettingBoolean("support_use_towers") && supportMinAreaSqrt > 0;
const int layerThickness = storage.getSettingInMicrons("layer_height");
const int supportXYDistance = mesh.getSettingInMicrons("support_xy_distance");
@@ -222,7 +235,10 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
std::vector<std::pair<int, std::vector<Polygons>>> overhang_points; // stores overhang_points along with the layer index at which the overhang point occurs
AreaSupport::detectOverhangPoints(storage, mesh, overhang_points, layer_count, supportMinAreaSqrt);
if (use_towers)
{
AreaSupport::detectOverhangPoints(storage, mesh, overhang_points, layer_count, supportMinAreaSqrt);
}
std::deque<std::pair<Polygons, Polygons>> basic_and_full_overhang_above;
for (unsigned int layer_idx = support_layer_count - 1; layer_idx != support_layer_count - 1 - layerZdistanceTop ; layer_idx--)
@@ -252,7 +268,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
supportLayer_this = supportLayer_this.offset(extension_offset);
}
if (supportMinAreaSqrt > 0)
if (use_towers)
{
// handle straight walls
AreaSupport::handleWallStruts(supportLayer_this, supportMinAreaSqrt, supportTowerDiameter);
@@ -274,8 +290,8 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
int bottomLayer = ((layer_idx - layerZdistanceBottom) / stepHeight) * stepHeight;
supportLayer_this = supportLayer_this.difference(storage.getLayerOutlines(bottomLayer, false));
}
supportLayer_last = supportLayer_this;
@@ -295,7 +311,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
}
else
{
supportLayer_this = supportLayer_this.difference(storage.getLayerOutlines(layer_idx, false).offset(supportXYDistance));
supportLayer_this = supportLayer_this.difference(outlines.offset(supportXYDistance));
}
}
@@ -338,6 +354,17 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
}
}
//Enforce top Z distance.
if (layerZdistanceTop > 1)
{
// this is performed after the main support generation loop above, because it affects the joining of polygons
// if this would be performed in the main loop then some support would not have been generated under the overhangs and consequently no support is generated for that,
// meaning almost no support would be generated in some cases which definitely need support.
for (size_t layer_idx = 0; layer_idx < storage.support.supportLayers.size() && layer_idx < support_layer_count - (layerZdistanceTop - 1); layer_idx++)
{
supportAreas[layer_idx] = supportAreas[layer_idx].difference(storage.getLayerOutlines(layer_idx + layerZdistanceTop - 1, false));
}
}
for (unsigned int layer_idx = supportAreas.size() - 1; layer_idx != (unsigned int) std::max(-1, storage.support.layer_nr_max_filled_layer) ; layer_idx--)
{
@@ -373,7 +400,10 @@ std::pair<Polygons, Polygons> AreaSupport::computeBasicAndFullOverhang(const Sli
Polygons basic_overhang = supportLayer_supportee.difference(supportLayer_supported);
const SupportLayer& support_layer = storage.support.supportLayers[layer_idx];
basic_overhang = basic_overhang.difference(support_layer.anti_overhang);
if (support_layer.anti_overhang.size())
{
basic_overhang = basic_overhang.difference(support_layer.anti_overhang);
}
// Polygons support_extension = basic_overhang.offset(max_dist_from_lower_layer);
// support_extension = support_extension.intersection(supportLayer_supported);
@@ -542,7 +572,7 @@ void AreaSupport::handleWallStruts(
}
void AreaSupport::generateSupportInterface(SliceDataStorage& storage, const SliceMeshStorage& mesh, std::vector<Polygons>& support_areas, const unsigned int layer_count)
void AreaSupport::generateSupportInterface(SliceDataStorage& storage, const SliceMeshStorage& mesh, const unsigned int layer_count)
{
const unsigned int roof_layer_count = round_divide(mesh.getSettingInMicrons("support_roof_height"), storage.getSettingInMicrons("layer_height"));
const unsigned int bottom_layer_count = round_divide(mesh.getSettingInMicrons("support_bottom_height"), storage.getSettingInMicrons("layer_height"));
@@ -559,44 +589,41 @@ void AreaSupport::generateSupportInterface(SliceDataStorage& storage, const Slic
const unsigned int top_layer_idx_above = layer_idx + roof_layer_count + z_distance_top;
const unsigned int bottom_layer_idx_below = std::max(0, int(layer_idx) - int(bottom_layer_count) - int(z_distance_bottom));
if (top_layer_idx_above < supportLayers.size())
if (top_layer_idx_above >= supportLayers.size())
{
Polygons roofs;
if (roof_layer_count > 0)
{
Polygons model;
const unsigned int n_scans = std::max(1u, (roof_layer_count - 1) / skip_layer_count);
const float z_skip = std::max(1.0f, float(roof_layer_count - 1) / float(n_scans));
for (float layer_idx_above = top_layer_idx_above; layer_idx_above > layer_idx + z_distance_top; layer_idx_above -= z_skip)
{
const Polygons outlines_above = mesh.layers[std::round(layer_idx_above)].getOutlines();
model = model.unionPolygons(outlines_above);
}
roofs = support_areas[layer_idx].intersection(model);
}
Polygons bottoms;
if (bottom_layer_count > 0)
{
Polygons model;
const unsigned int n_scans = std::max(1u, (bottom_layer_count - 1) / skip_layer_count);
const float z_skip = std::max(1.0f, float(bottom_layer_count - 1) / float(n_scans));
for (float layer_idx_below = bottom_layer_idx_below; std::round(layer_idx_below) < (int)(layer_idx - z_distance_bottom); layer_idx_below += z_skip)
{
const Polygons outlines_below = mesh.layers[std::round(layer_idx_below)].getOutlines();
model = model.unionPolygons(outlines_below);
}
bottoms = support_areas[layer_idx].intersection(model);
}
// expand skin a bit so that we're sure it's not too thin to be printed.
Polygons skin = roofs.unionPolygons(bottoms).offset(interface_line_width).intersection(support_areas[layer_idx]);
skin.removeSmallAreas(1.0);
layer.skin.add(skin);
layer.supportAreas.add(support_areas[layer_idx].difference(layer.skin));
continue;
}
else
Polygons roofs;
if (roof_layer_count > 0)
{
layer.skin.add(support_areas[layer_idx]);
Polygons model;
const unsigned int n_scans = std::max(1u, (roof_layer_count - 1) / skip_layer_count);
const float z_skip = std::max(1.0f, float(roof_layer_count - 1) / float(n_scans));
for (float layer_idx_above = top_layer_idx_above; layer_idx_above > layer_idx + z_distance_top; layer_idx_above -= z_skip)
{
const Polygons outlines_above = mesh.layers[std::round(layer_idx_above)].getOutlines();
model = model.unionPolygons(outlines_above);
}
roofs = layer.supportAreas.intersection(model);
}
Polygons bottoms;
if (bottom_layer_count > 0)
{
Polygons model;
const unsigned int n_scans = std::max(1u, (bottom_layer_count - 1) / skip_layer_count);
const float z_skip = std::max(1.0f, float(bottom_layer_count - 1) / float(n_scans));
for (float layer_idx_below = bottom_layer_idx_below; std::round(layer_idx_below) < (int)(layer_idx - z_distance_bottom); layer_idx_below += z_skip)
{
const Polygons outlines_below = mesh.layers[std::round(layer_idx_below)].getOutlines();
model = model.unionPolygons(outlines_below);
}
bottoms = layer.supportAreas.intersection(model);
}
// expand skin a bit so that we're sure it's not too thin to be printed.
Polygons skin = roofs.unionPolygons(bottoms).offset(interface_line_width).intersection(layer.supportAreas);
skin.removeSmallAreas(1.0);
layer.skin.add(skin);
layer.supportAreas = layer.supportAreas.difference(layer.skin);
}
}
+1 -2
Ver Arquivo
@@ -36,10 +36,9 @@ private:
*
* \param storage Output storage: support area + support skin area output
* \param mesh The mesh to generate support skins for.
* \param support_areas The basic support areas for the current mesh
* \param layer_count The number of layers in this mesh group.
*/
static void generateSupportInterface(SliceDataStorage& storage, const SliceMeshStorage& mesh, std::vector<Polygons>& support_areas, const unsigned int layer_count);
static void generateSupportInterface(SliceDataStorage& storage, const SliceMeshStorage& mesh, const unsigned int layer_count);
/*!
* Join current support layer with the support of the layer above, (make support conical) and perform smoothing etc operations.
+1 -1
Ver Arquivo
@@ -57,7 +57,7 @@ public:
};
private:
double max_feedrate[NUM_AXIS] = {600, 600, 40, 25};
double max_feedrate[NUM_AXIS] = {600, 600, 40, 25}; // mm/s
double minimumfeedrate = 0.01;
double acceleration = 3000;
double max_acceleration[NUM_AXIS] = {9000, 9000, 100, 10000};
+6
Ver Arquivo
@@ -37,6 +37,12 @@ void AABB3D::include(Point3 p)
max.z = std::max(max.z, p.z);
}
void AABB3D::includeZ(int32_t z)
{
min.z = std::min(min.z, z);
max.z = std::max(max.z, z);
}
void AABB3D::offset(Point3 offset)
{
min += offset;
+8
Ver Arquivo
@@ -38,6 +38,14 @@ struct AABB3D
*/
void include(Point3 p);
/*!
* Expand the AABB3D to include a z-coordinate.
*
* This is for including a point of which the X and Y coordinates are
* unknown but known to already be included in the bounding box.
*/
void includeZ(int32_t z);
/*!
* Offset the coordinates of the bounding box.
* \param offset The offset with which to offset the AABB3D.
+60
Ver Arquivo
@@ -285,6 +285,66 @@ public:
}
};
class Point3Matrix
{
public:
double matrix[9];
Point3Matrix()
{
matrix[0] = 1;
matrix[1] = 0;
matrix[2] = 0;
matrix[3] = 0;
matrix[4] = 1;
matrix[5] = 0;
matrix[6] = 0;
matrix[7] = 0;
matrix[8] = 1;
}
/*!
* Initializes the top left corner with the values of \p b
* and the rest as if it's a unit matrix
*/
Point3Matrix(const PointMatrix& b)
{
matrix[0] = b.matrix[0];
matrix[1] = b.matrix[1];
matrix[2] = 0;
matrix[3] = b.matrix[2];
matrix[4] = b.matrix[3];
matrix[5] = 0;
matrix[6] = 0;
matrix[7] = 0;
matrix[8] = 1;
}
Point3 apply(const Point3 p) const
{
return Point3(p.x * matrix[0] + p.y * matrix[1] + p.z * matrix[2]
, p.x * matrix[3] + p.y * matrix[4] + p.z * matrix[5]
, p.x * matrix[6] + p.y * matrix[7] + p.z * matrix[8]);
}
Point3Matrix compose(const Point3Matrix& b)
{
Point3Matrix ret;
for (int outx = 0; outx < 3; outx++)
{
for (int outy = 0; outy < 3; outy++)
{
ret.matrix[outy * 3 + outx] = 0;
for (int in = 0; in < 3; in++)
{
ret.matrix[outy * 3 + outx] += matrix[outy * 3 + in] * b.matrix[in * 3 + outx];
}
}
}
return ret;
}
};
inline Point3 operator+(const Point3& p3, const Point& p2) {
return Point3(p3.x + p2.X, p3.y + p2.Y, p3.z);
+4 -4
Ver Arquivo
@@ -45,7 +45,7 @@ public:
other.instance = nullptr;
}
template<class... Args>
constexpr explicit optional(bool not_used, Args&&... args ) //!< construct the value in place
constexpr explicit optional(bool, Args&&... args ) //!< construct the value in place
: instance(new T(args...))
{
}
@@ -62,7 +62,7 @@ public:
* \param null_ptr exactly [nullptr]
* \return this
*/
optional& operator=(std::nullptr_t null_ptr)
optional& operator=(std::nullptr_t)
{
if (instance)
{
@@ -121,12 +121,12 @@ public:
}
constexpr T* operator->() const
{
assert(instance && "instance should be instatiated!");
assert(instance && "Instance should be instantiated!");
return instance;
}
constexpr T& operator*() const&
{
assert(instance && "instance should be instatiated!");
assert(instance && "Instance should be instantiated!");
return *instance;
}
constexpr explicit operator bool() const
+99
Ver Arquivo
@@ -0,0 +1,99 @@
/** Copyright (C) 2016 Ultimaker B.V. - Released under terms of the AGPLv3 License */
#ifndef UTILS_ORDER_OPTIMIZER_H
#define UTILS_ORDER_OPTIMIZER_H
#include <stdint.h>
#include <vector>
#include <list>
#include <utility> // pair
#include "intpoint.h"
namespace cura {
/*!
* Order optimization class.
*
* Utility class for optimizing the path order by minimizing the cyclic distance traveled between several items.
*
* The path is heuristically optimized in a way such that each node is visited and the salesman which is travelling ends up where he started.
*/
template <typename T>
class OrderOptimizer
{
public:
std::vector<std::pair<const Point, T>> items; //!< the items in arbitrary order
OrderOptimizer()
{
}
void addItem(const Point location, const T item);
/*!
* Optimize the order of \ref OrderOptimizer::items
* \return A vector of the ordered indices into \ref OrderOptimizer::items
*/
std::list<unsigned int> optimize();
};
template <typename T>
void OrderOptimizer<T>::addItem(const Point location, const T item)
{
this->items.emplace_back(location, item);
}
template <typename T>
std::list<unsigned int> OrderOptimizer<T>::optimize()
{
// least detour insertion algorithm
std::list<unsigned int> order;
if (items.size() == 0)
{
return order;
}
order.push_back(0u);
if (items.size() == 1)
{
return order;
}
order.push_back(1u);
if (items.size() == 2)
{
return order;
}
order.push_back(2u);
for (unsigned int item_idx = 3; item_idx < items.size(); item_idx++)
{
Point to_insert_item_location = items[item_idx].first;
// find best_item_to_insert_before
std::list<unsigned int>::iterator best_item_to_insert_before = order.begin();
coord_t best_detour_dist = vSize(items[*best_item_to_insert_before].first - to_insert_item_location)
+ vSize(to_insert_item_location - items[order.back()].first)
- vSize(items[*best_item_to_insert_before].first - items[order.back()].first);
std::list<unsigned int>::iterator prev = order.begin();
for (std::list<unsigned int>::iterator nearby = ++order.begin(); nearby != order.end(); ++nearby)
{
coord_t detour_dist = vSize(items[*nearby].first - to_insert_item_location)
+ vSize(to_insert_item_location - items[*prev].first)
- vSize(items[*nearby].first - items[*prev].first);
if (detour_dist < best_detour_dist)
{
best_detour_dist = detour_dist;
best_item_to_insert_before = nearby;
}
prev = nearby;
}
order.insert(best_item_to_insert_before, item_idx);
}
return order;
}
}//namespace cura
#endif//UTILS_ORDER_OPTIMIZER_H
+1 -1
Ver Arquivo
@@ -837,7 +837,6 @@ void PolygonRef::smooth_corner_simple(ListPolygon& poly, const Point p0, const P
Point b;
bool success = LinearAlg2D::getPointOnLineWithDist(a, p1, p2, shortcut_length, b);
// v02 has to be longer than ab!
p1_it.remove();
if (success)
{ // if not success then assume b is negligibly close to 2, but rounding errors caused a problem
#ifdef ASSERT_INSANE_OUTPUT
@@ -845,6 +844,7 @@ void PolygonRef::smooth_corner_simple(ListPolygon& poly, const Point p0, const P
#endif // #ifdef ASSERT_INSANE_OUTPUT
ListPolyIt::insertPointNonDuplicate(p1_it, p2_it, b);
}
p1_it.remove();
}
}
}
+40 -5
Ver Arquivo
@@ -11,6 +11,8 @@
#include <limits> // int64_t.min
#include <list>
#include <initializer_list>
#include "intpoint.h"
#define CHECK_POLY_ACCESS
@@ -52,7 +54,7 @@ public:
Point& operator[] (unsigned int index) const
{
POLY_ASSERT(index < size() && index >= 0);
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
return (*path)[index];
}
@@ -85,7 +87,7 @@ public:
void remove(unsigned int index)
{
POLY_ASSERT(index < size() && index >= 0);
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
path->erase(path->begin() + index);
}
@@ -407,7 +409,7 @@ public:
PolygonRef operator[] (unsigned int index)
{
POLY_ASSERT(index < size() && index >= 0);
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
return PolygonRef(paths[index]);
}
const PolygonRef operator[] (unsigned int index) const
@@ -430,11 +432,23 @@ public:
{
return paths.end();
}
/*!
* Remove a polygon from the list and move the last polygon to its place
*
* \warning changes the order of the polygons!
*/
void remove(unsigned int index)
{
POLY_ASSERT(index < size() && index >= 0);
paths.erase(paths.begin() + index);
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
if (index < paths.size() - 1)
{
paths[index] = std::move(paths.back());
}
paths.resize(paths.size() - 1);
}
/*!
* Remove a range of polygons
*/
void erase(ClipperLib::Paths::iterator start, ClipperLib::Paths::iterator end)
{
paths.erase(start, end);
@@ -456,6 +470,13 @@ public:
for(unsigned int n=0; n<other.paths.size(); n++)
paths.push_back(other.paths[n]);
}
/*!
* Add a 'polygon' consisting of two points
*/
void addLine(const Point from, const Point to)
{
paths.emplace_back((std::initializer_list<Point>){from, to});
}
template<typename... Args>
void emplace_back(Args... args)
@@ -514,6 +535,20 @@ public:
clipper.Execute(ClipperLib::ctIntersection, ret.paths);
return ret;
}
/*!
* Clips input line segments by this Polygons.
* \param other Input line segments to be cropped
* \return the resulting interior line segments
*/
ClipperLib::PolyTree lineSegmentIntersection(const Polygons& other) const
{
ClipperLib::PolyTree ret;
ClipperLib::Clipper clipper(clipper_init);
clipper.AddPaths(paths, ClipperLib::ptClip, true);
clipper.AddPaths(other.paths, ClipperLib::ptSubject, false);
clipper.Execute(ClipperLib::ctIntersection, ret);
return ret;
}
Polygons xorPolygons(const Polygons& other) const
{
Polygons ret;
+19 -6
Ver Arquivo
@@ -596,12 +596,25 @@ ClosestPolygonPoint PolygonUtils::findClosest(Point from, const Polygons& polygo
{
ClosestPolygonPoint none;
if (polygons.size() == 0) return none;
PolygonRef aPolygon = polygons[0];
if (aPolygon.size() == 0) return none;
Point aPoint = aPolygon[0];
ClosestPolygonPoint best(aPoint, 0, aPolygon, 0);
if (polygons.size() == 0)
{
return none;
}
PolygonRef any_polygon = polygons[0];
unsigned int any_poly_idx;
for (any_poly_idx = 0; any_poly_idx < polygons.size(); any_poly_idx++)
{ // find first point in all polygons
if (polygons[any_poly_idx].size() > 0)
{
any_polygon = polygons[any_poly_idx];
break;
}
}
if (any_polygon.size() == 0)
{
return none;
}
ClosestPolygonPoint best(any_polygon[0], 0, any_polygon, any_poly_idx);
int64_t closestDist2_score = vSize2(from - best.location) + penalty_function(best.location);
+4 -1
Ver Arquivo
@@ -1,3 +1,6 @@
//Copyright (c) 2017 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef UTILS_STRING_H
#define UTILS_STRING_H
@@ -35,7 +38,7 @@ static inline void writeInt2mm(const int64_t coord, std::ostream& ss)
{
constexpr size_t buffer_size = 24;
char buffer[buffer_size];
int char_count = sprintf(buffer, "%" PRId64, coord); // convert int to string
int char_count = sprintf(buffer, "%d", int(coord)); // convert int to string
#ifdef DEBUG
if (char_count + 1 >= int(buffer_size)) // + 1 for the null character
{
+4 -1
Ver Arquivo
@@ -235,11 +235,14 @@ class Setting:
tree = ast.parse(code, "eval")
compiled = compile(code, self._key, "eval")
except (SyntaxError, TypeError) as e:
print("Parse error in function (" + code + ") for setting", self._key + ":", str(e))
print("Parse error in function (" + str(code) + ") for setting", self._key + ":", str(e))
return None
except IllegalMethodError as e:
print("Use of illegal method", str(e), "in function (" + code + ") for setting", self._key)
return None
except Exception as e:
print("Exception in function (" + code + ") for setting", self._key + ":", str(e))
return None
return eval(compiled, globals(), locals)