Comparar commits

...

2027 Commits

Autor SHA1 Mensagem Data
Tim Kuipers 5a48d86bd7 refactor: handle layer plans outside of buffer (CURA-3339)
allocation is handled outside buffer
writing gcode is handled outside buffer
buffer processing is handled separately from adding to the buffer
2017-02-17 11:44:53 +01:00
Tim Kuipers 79cb7850e9 refactor: simplified processLayer calls (CURA-3339) 2017-02-17 11:44:53 +01:00
Tim Kuipers 9e4a786f3d refactor: clean up GCodePathConfig (CURA-3339)
have one constructor rather than a constructor, init, setLayerHeight and smoothSpeed
2017-02-17 11:44:53 +01:00
Tim Kuipers fe49157ca8 refactor: PathConfigs ==> PathConfigStorage (CURA-3339)
because the structure follows the structure of SliceDataStorage.
2017-02-17 11:44:53 +01:00
Tim Kuipers 889c2e4b13 fix: GCodePathConfig extrusion_per_mm was calculated too early (CURA-3339)
this resulted in all extrusion lines being replaced by travel paths.
This problem was introduced a couple of commits ago.
The underlying problem, that there needs to be a definite order between init and setLayerHeight, will be solved in a commit soon to come.
2017-02-17 11:44:53 +01:00
Tim Kuipers ca3848f79a fix: const correctness (except some const_cast instances!) (CURA-3339) 2017-02-17 11:44:53 +01:00
Tim Kuipers 77f1aebef9 fix: bundle state from gcodePlanner into class (CURA-3339)
this helps in making GCodePlanner multithreaded
The state of the gcodePlanner which is carried over to the next layer is bundled in a nice package, which is to be dealt with soon in a coming commit
2017-02-17 11:44:53 +01:00
Tim Kuipers 046c34b31b lil gitignore 2017-02-17 11:44:53 +01:00
Tim Kuipers 066a0d7318 fix: move writeGcode configs out of sliceDataStorage (CURA-3339)
This contributes to making sliceDataStorage const after FffPolygonGenerator has been called
2017-02-17 11:44:53 +01:00
Tim Kuipers 989317a293 fix: const correctness in combing (CURA-3339) 2017-02-17 11:43:45 +01:00
Tim Kuipers cf3d18eb75 fix: const correctness in prime tower (CURA-3339) 2017-02-17 11:43:45 +01:00
Tim Kuipers c9096424c1 fix: lil const correctnes MergeInfillLines (CURA-3339) 2017-02-17 11:43:45 +01:00
Tim Kuipers d489143fcb fix: const correctness in polygon (CURA-3339) 2017-02-17 11:43:45 +01:00
Tim Kuipers 8ac3b49549 refactor: introduced ConstPolygonRef (CURA-3339)
Adapted from 9712301aa8
From @Johan3DV 'Improve const correctness and remove const_cast'
2017-02-17 11:43:45 +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 4da8c6d8e7 fix: no more aabb hit check fails (CURA-2992) 2016-11-28 14:35:13 +01:00
Tim Kuipers c5ce425924 fix: no more use of deleted memory by optional (CURA-3008) 2016-11-28 14:34:45 +01:00
Tim Kuipers c74d4f7550 Revert "feat: PolygonPointer as distinct from PolygonRef (CURA-3008)"
This reverts commit 20cd4275fc.
2016-11-28 13:43:03 +01:00
Tim Kuipers 19f093e0cc safety: assert on optional::instance (CURA-3008) 2016-11-28 13:42:36 +01:00
Tim Kuipers 2a4cca0402 fix: use ClosestPolygonPoint::isValid where neccesary (CURA-3008) 2016-11-28 13:40:54 +01:00
Tim Kuipers 32804c102c fix: use optional<PolygonRef> instead of PolygonPointer (CURA-3008) 2016-11-28 13:40:02 +01:00
Tim Kuipers 776f56fc37 lil fix: no more un/signed int comaprison 2016-11-28 12:18:13 +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 a92cd23e62 safety: extra assert for too many nozzle switches in a layer 2016-11-25 16:10:10 +01:00
Tim Kuipers 4725001564 fix: remove printing_temperature_command if precooling goes further back (CURA-1932)
If the precooling command will precede the printing temeprature command to heat to the temp of the next layer, then don't use that temp;
we should already be cooling down, rather than heating toward the temp of the next layer.
2016-11-25 14:00:26 +01:00
Tim Kuipers a18595877f safety: extra assert on temp in NozzleTempInsert (CURA-1932) 2016-11-25 14:00:26 +01:00
Tim Kuipers 40e7c450d5 fix: getCoolDownPointAfterWarmUp outer_temp was switched (CURA-1932)
This caused the timing of the precool command to be off
2016-11-25 14:00:26 +01:00
Tim Kuipers 13a0b11d68 fix: don't use material_print_temperature_layer_0 if it's zero (CURA-1932) 2016-11-25 14:00:26 +01:00
Ghostkeeper 4fc69f608a Fix max extruder height if only using bed adhesion
If an extruder only prints bed adhesion, the maximum extruder height for that extruder is now correct.

Contributes to issue CURA-2993.
2016-11-25 11:21:59 +01:00
Ghostkeeper deb577d559 Make extruder numbers const and unsigned
This is in line with the first one, and more correct.

Contributes to issue CURA-2993.
2016-11-25 11:17:45 +01:00
Ghostkeeper c8161da3eb Remove spaces within brackets
As per our code style.

Contributes to issue CURA-2993.
2016-11-25 11:16:30 +01:00
Ghostkeeper 87733834d1 Expand documentation for computePrintHeightStatistics
Should make it more overseeable.

Contributes to issue CURA-2993.
2016-11-25 11:08:29 +01:00
Ghostkeeper b9aeea425f Correct documentation of computePrintHeightStatistics
It's initialised, not uninitialised (or unitialised).

Contributes to issue CURA-2993.
2016-11-25 11:01:51 +01:00
Tim Kuipers 44b3039db6 optimization: use already computed ClosestPolygonPoint for ensureInsideOrOutside during combing crossing calculation (CURA-2229) 2016-11-24 15:09:41 +01:00
Tim Kuipers 6476270cf6 fix: combing start crossing inside location was sometimes on the destination part, rather than the starting part (CURA-2229) 2016-11-24 13:56:57 +01:00
Ghostkeeper e532f3ddda Merge branch 'feature_anti_support' 2016-11-22 16:36:52 +01:00
Tim Kuipers 7aaab151e7 fix: better handling of edge cases for Preheat::getCoolDownPointAfterWarmUp and getWarmUpPointAfterCoolDown (CURA-3006) 2016-11-22 14:54:59 +01:00
Tim Kuipers 0353433919 fix: also ensure prime after first layer of raft (CURA-3006) 2016-11-22 14:52:21 +01:00
Tim Kuipers 40a6c495c7 refactor: move code from FffGcodeWriter::processLayer into new FffGcodeWriter::ensureAllExtrudersArePrimed (CURA-3006) 2016-11-22 14:51:48 +01:00
Ghostkeeper cfa6758911 Merge branch 'fix_support_order'
Conflicts:
	src/FffGcodeWriter.cpp
	src/PrimeTower.cpp
2016-11-22 13:03:38 +01:00
Tim Kuipers f6b29b1d8a Merge branch 'feature_anti_support' of github.com:Ultimaker/CuraEngine into feature_anti_support 2016-11-22 10:21:44 +01:00
Ghostkeeper bd79a8468e Merge branch 'feature_hollow_prime_tower' 2016-11-22 09:19:16 +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
Ghostkeeper 35dcc6906f Merge branch 'feature_precool' 2016-11-21 17:35:40 +01:00
Tim Kuipers db7bc279ee fix: removeEmptyFirstLayers can still remove even when support was generated (but removed by anti support meshes (CURA-2077) 2016-11-21 16:50:26 +01:00
Tim Kuipers a7ea623266 fix: removeEmptyFirstLayers can still remove even when support was generated (but removed by anti support meshes (CURA-2077) 2016-11-21 16:34:55 +01:00
Tim Kuipers 724589c13a fix: support towers went all the way to the bed (CURA-2077) 2016-11-21 16:31:52 +01:00
Tim Kuipers db1fa098ad Merge branch 'master' into feature_anti_support 2016-11-21 16:12:57 +01:00
Tim Kuipers be99db30c0 fix: combing referenced element zero of a polygons (CURA-3008) 2016-11-21 15:54:07 +01:00
Tim Kuipers 9456592dd7 fix: use PolygonPointer in ClosestPolygonPoint (CURA-3008)
sometimes functions cannot return a ClosestPolygonPoint, or we start with an empty one untill we find any point

cherry-picked from 4634338c7d
2016-11-21 15:45:27 +01:00
Tim Kuipers 20cd4275fc feat: PolygonPointer as distinct from PolygonRef (CURA-3008)
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...

cherry-picked from a2a8604c72
2016-11-21 15:38:12 +01:00
Tim Kuipers 67697d5258 fix: handle modulo operations for negative layer numbers (CURA-2789) 2016-11-21 14:18:39 +01:00
Tim Kuipers 7d8e4de7ba fix: prime tower didn't get added in filler layers (CURA-2789)
PrimeTower always received layer_nr=0 for those layers, so i had to propagate the negative layer numbers to addSupportToGcode and to PrimeTower
2016-11-21 14:17:32 +01:00
Tim Kuipers 2486120a38 fix: don't send polygons over command socket during planning phase (CURA-2789)
The polygons of the prime tower were also sent on the wrong layer / height, causing it to be visualized within raft layers
2016-11-21 14:13:56 +01:00
Tim Kuipers 43c8f2a913 fix: print prime tower directly after platform adhesion on layer 0 (CURA-2789) 2016-11-21 13:19:25 +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
Ghostkeeper dd8b57b666 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-11-18 15:51:10 +01:00
Jaime van Kessel 72ed492a61 Merge branch 'feature_alternate_carving' of github.com:Ultimaker/CuraEngine 2016-11-18 15:14:12 +01:00
Ghostkeeper c02482590f Merge branch 'feature_fill_small_gaps' 2016-11-18 15:05:58 +01:00
Tim Kuipers f32e2d9554 Merge branch 'master' into feature_anti_support 2016-11-18 14:07:29 +01:00
Tim Kuipers 40a6075022 Merge branch 'master' into feature_recursive_infill_code_review 2016-11-18 13:55:06 +01:00
Jaime van Kessel bf61814849 Merge branch 'feature_fan_speed_0' of github.com:Ultimaker/CuraEngine 2016-11-18 10:43:56 +01:00
Jaime van Kessel 5741e79ade Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-11-18 10:42:17 +01:00
Jaime van Kessel 09419fd6be Merge branch 'feature_bed_adhesion_none' of github.com:Ultimaker/CuraEngine 2016-11-18 10:35:29 +01:00
Tim Kuipers a002f4b3b2 feat: alternate_carve_order (CURA-2992) 2016-11-17 19:58:31 +01:00
Tim Kuipers 25c7ccb0d3 fix: outside combing put starting and ending points of basic comb path on the wrong side (CURA-2988)
basic comb paths started on the wrong side, then followed the polygon on the right side and ended on the wrong side again
2016-11-17 17:22:53 +01:00
Tim Kuipers 58a99a403b fix: createLocToLineGrid didn't create any cells and copied the hashmap (CURA-2988)
std::bind doesn't allow for binding by reference
2016-11-17 17:01:57 +01:00
Tim Kuipers dd8594b200 fix: inside combing put starting and ending points of basic comb path on the wrong side (CURA-2988)
basic comb paths started on the wrong side, then followed the polygon on the right side and ended on the wrong side again
2016-11-17 17:00:23 +01:00
Ghostkeeper 6df5368cb9 Update variable names in documentation
The variable names were changed but changed incorrectly here.

Contributes to issue CURA-1932.
2016-11-17 14:49:29 +01:00
Ghostkeeper 3a038a2cd2 Put correct bounding box in g-code header
This is according to the Griffin header specification.

Contributes to issue CURA-2625.
2016-11-17 13:35:59 +01:00
Tim Kuipers 9613e186a3 docs: fixed docs location and included precool diagram in LayerPlanBuffer (CURA-1932) 2016-11-16 17:54:11 +01:00
Tim Kuipers 82b2362b2d lil compiler warning removal (CURA-1932) 2016-11-16 16:52:54 +01:00
Tim Kuipers a6ee34602c refactor: rename rediculous timeBeforeEndToInsertPreheatCommand_coolDownWarmUp ==> sensible getWarmUpPointAfterCoolDown and vice versa (CURA-1932) 2016-11-16 16:50:05 +01:00
Tim Kuipers 05d29eabcd refactor: timeBeforeEndToInsertPreheatCommand arguments better names (CURA-1932) 2016-11-16 16:41:18 +01:00
Tim Kuipers f7e3534a79 fix: update outdated function signature (add const and better naming) (CURA-1932) 2016-11-16 16:30:56 +01:00
Tim Kuipers bd4972e466 refactor: rename function argument to better match the intent (CURA-1932) 2016-11-16 16:27:44 +01:00
Tim Kuipers 0acf3beec2 fix: insertFinalPrintTempCommand: compute weighted average_print_temp by taking time into account (CURA-1932)
note that the print temp statistic doesn't really matter that much
2016-11-16 16:20:51 +01:00
Tim Kuipers 081055be46 fix: better documentation for LayerPlanBuffer::insertFinalPrintTempCommand (CURA-1932) 2016-11-16 16:17:42 +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
Ghostkeeper 560d23d3f2 Simplify skipping current extruder in calculateExtruderOrder
These are equivalent, but the code is now simpler.

Contributes to issue CURA-2789.
2016-11-16 12:51:50 +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 44e7b0e0be fix: apply outer wall line width offset for interperimeter gaps (CURA-2306) 2016-11-16 10:18:40 +01:00
Tim Kuipers 8c48d1ce82 fix: material_extrusion_cool_down_speed handled correctly (CURA-1932)
it was handled as if the inverse (in s/*c) was the modifier rather than the original (in *C/s)
2016-11-15 17:53:38 +01:00
Tim Kuipers 8432e9ed9f fix: first start of extruder, require print temp rather than initial print temp (CURA-1932) 2016-11-15 17:52:07 +01:00
Tim Kuipers 1b014199c9 refactor: store initial_printing_temperature in ExtruderPlan (CURA-1932) 2016-11-15 17:46:47 +01:00
Tim Kuipers 7e0c5c6323 refactor: replaced timeBeforeEndToInsertPreheatCommand_warmUp by getTimeToGoFromTempToTemp (CURA-1932)
both functions actually tried to do the same thing
2016-11-15 17:42:37 +01:00
Tim Kuipers 9ada0901a6 refactor: insertPreheatCommands ==> insertTempCommands (CURA-1932) 2016-11-15 17:38:26 +01:00
Tim Kuipers d60d32a5d8 fix: exposed less internal functions of LayerPlanBuffer (CURA-1932) 2016-11-15 14:38:15 +01:00
Tim Kuipers 667c00aa5a lil assert (CURA-1932) 2016-11-15 14:37:32 +01:00
Tim Kuipers cf0ca05843 fix: insert initial/final print temp commands for groups of extruder plans rather than each (CURA-1932)
before this we would get precool and preheat during a layer change even when the last extruder of the previous layer is the first extruder of the next...
2016-11-15 14:37:07 +01:00
Tim Kuipers 3bcabacef4 fix: wrong check whether initial print temp was unused (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers b5801ea847 fix: warmUpCoolDown computed cool_down_time as if it was warm_up_time (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers 1bb90a2f03 fix: use more accurate coolDownWarmUp time estimations (CURA-1932)
with the initial and final printing temperature the old assumption didn't hold any more:
'Assumes from_temp is approximately the same as @p temp'

It uses the same logic as timeBeforeEndToInsertPreheatCommand_warmUpCoolDown(.)
2016-11-14 17:50:08 +01:00
Tim Kuipers cf55aef52b fix: for warmUpCoolDown compute max temp accurately (CURA-1932)
Didn't take extra heating time into account
2016-11-14 17:50:08 +01:00
Tim Kuipers c0f7538fdb fix: take care of during_printing for heatup/cooldown timings (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers 395ab9b7cd fix: warmup and cooldown times were incorrect (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers 80ecabb618 refactor: move Preheat functions to cpp file (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers ff291cc4d1 fix: insert temp commands for preheat and precool (CURA-1932)
insert heat command from initial_print_temp to print_temp at the first extrusion in a layer plan
insert cool command from print_temp to final_print_temp during the last extrusion moves in a layer plan
2016-11-14 17:50:08 +01:00
Tim Kuipers 4183835d2b fix: use initial_print_temp where print_temp used to be used (CURA-1932)
heating up is now done toward initial_print_temp
and the required temp at the start of a layer is initial_print_temp
2016-11-14 17:50:08 +01:00
Tim Kuipers 0e24d8db47 cleanup: no more boolean trappiness (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers f7bde54869 feat: some handy Preheat functions (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers bf8f027a97 setting: material_initial_print_temperature, material_final_print_temperature (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers 60625ea4bf refactor: ExtruderPlan::required_temp ==> printing_temperature (CURA-1932) 2016-11-14 17:50:08 +01:00
Tim Kuipers a9f6ae1943 refactor: rewrote logic in FffGcodeWriter::calculateExtruderOrder (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers cd01d7051b refactor: support_skin ==> support_interface (CURA-2789) 2016-11-14 17:49:16 +01:00
Ghostkeeper bd126bb841 Fix typo in assert message
Contributes to issue CURA-2789.
2016-11-14 17:49:16 +01:00
Tim Kuipers f1b3fb3cd6 refactor/fix: plan extruders independently of meshes and plan support per extruder plan (CURA-2789)
When printing dual color models with dual support (different support infill extruder than support skin extruder)
all support would either be printed before all models or after, leading to two extruder switches in one layer.

Now the extruder_order is calculated independently of the mesh_order and the support is added per extruder plan.

The support is always added first, so that:
- in single extrusion we never print in order support-support-model-model which would lead to model being printed on top of model which hasn't cooled enough
- in dual color, dual support we always print E1-support-model-support-model-E2-support-model-support-model so that oozle is automatically wiped on support
2016-11-14 17:49:16 +01:00
Tim Kuipers d48f06db0e refactor/fix: return whether support was added to extruder plan and only switch extruder if plans were added (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers 5567b06ed4 cleanup: remove unused parameter to FffGcodeWriter::addSupportToGCode (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers e87b11179f fix: getExtrudersUsed only include platform adhesion for first layer(s) (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers a17fef9d4b refactor: separate handleSupportBeforeModels out of FffGcodeWriter::addSupportToGCode (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers 4c49bf7894 cleanup: const-correctness for SliceDataStorage::getExtrudersUsed (CURA-2789) 2016-11-14 17:49:16 +01:00
Tim Kuipers bcb0ded784 fix: print support consecutive instead of always at end of layer (CURA-2789)
also support_interface_extruder_nr mattered even if the interface was turned off
2016-11-14 17:49:16 +01:00
jack 54ba25e7f5 Merge pull request #411 from Ultimaker/bugfix_prime_tower_too_high
CURA-2633 fix: limit prime tower height when support is touching buildplate onl…
2016-11-14 14:57:13 +01:00
Tim Kuipers 84a7f401a2 lil indent fix only (CURA-759) 2016-11-14 12:41:58 +01:00
Tim Kuipers 6afdf19ce4 feat: adhesion_type none (CURA-759) 2016-11-14 12:41:29 +01:00
Tim Kuipers 4aa1cc47f4 fix: don't start output decimal numbers with the decimal dot 2016-11-11 17:23:53 +01:00
Tim Kuipers 166473596a fix: compute perimeter_gaps for zigzag skin infill (CURA-2306) 2016-11-11 16:00:35 +01:00
Tim Kuipers feb21b67d1 fix: turn off gap filling if fill_perimeter_gaps is set to nowhere (CURA-2306) 2016-11-11 14:58:59 +01:00
Tim Kuipers dae7ec184f removal: remove skin option from fill_perimeter_gaps mode (CURA-2306) 2016-11-11 14:44:48 +01:00
Tim Kuipers cd170cae99 Revert "cleanup: removed fill_perimeter_gaps setting (CURA-996)"
This reverts commit 9c47644e55.

This reintroduces the fill_perimeter_gaps setting (CURA-2306)
2016-11-11 14:41:33 +01:00
Tim Kuipers d47d0a2e46 fix: handle perimeter_gaps for concentric skin infill (CURA-2306) 2016-11-11 14:37:51 +01:00
Tim Kuipers f0d59db203 refactor: optionally pass down perimeter_gaps to Infill constructor (CURA-2306) 2016-11-11 14:37:14 +01:00
Tim Kuipers f34a4e566b feat: handle perimeter_gaps between skin walls (CURA-2306) 2016-11-11 14:35:43 +01:00
Tim Kuipers 9c1ef177d1 feat: perimeter gaps for normal walls (CURA-2306) 2016-11-11 14:33:45 +01:00
Tim Kuipers e1c7e86b66 fix: optimize skin part order (CURA-2306) 2016-11-11 14:29:32 +01:00
Tim Kuipers 384071aaeb feat: z seam position (CURA-1461) 2016-11-11 12:02:46 +01:00
Tim Kuipers 79d1074d47 feat: cool_fan_speed_0 (CURA-2182) 2016-11-10 16:41:42 +01:00
Tim Kuipers 348ca93dcb fix: add more special casing to ignore (anti)support meshes (CURA-2077) 2016-11-09 17:27:59 +01:00
Tim Kuipers e70b3c099f Merge branch 'fix_support_order' of github.com:Ultimaker/CuraEngine into fix_support_order 2016-11-09 16:40:50 +01:00
Tim Kuipers 8c9858a14c refactor: rewrote logic in FffGcodeWriter::calculateExtruderOrder (CURA-2789) 2016-11-09 16:38:14 +01:00
Tim Kuipers 6e56cb3416 refactor: support_skin ==> support_interface (CURA-2789) 2016-11-09 16:31:43 +01:00
Ghostkeeper 8761ae1e53 Merge branch 'feature_retract_at_layer_change' 2016-11-09 13:37:48 +01:00
Ghostkeeper d32be27b50 Fix typo in assert message
Contributes to issue CURA-2789.
2016-11-09 11:58:48 +01:00
Tim Kuipers 11b33215a2 fix: set extruder count (CURA-2325) 2016-11-09 10:24:31 +01:00
Tim Kuipers e8a31f1380 fix: remove GCodePlanner::makeLastPathZhopped (CURA-2325) 2016-11-09 10:24:31 +01:00
Ghostkeeper 7cbfb22f1f )
'I have to sort my books' she cried,
With self-indulgent glee;
With senseless, narcissistic pride:
'I'm just so OCD.'

'How random guys,' I smiled and said,
Then left without a peep -
And washed my hands until they bled,
And cried myself to sleep.
2016-11-09 10:24:24 +01:00
Tim Kuipers 40e6aac22b fix: only wipe in the middle of the prime tower if it's hollow (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers 33cc601a1b fix: only wipe on inside of prime tower if z hops are already being performed (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers d50b0c9c2f fix: go down on middle of hollow wipe tower (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers 77f415be61 fix: made hollow prime tower robust against zero wall thickness (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers 1aa784e521 doc update prime tower (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers ef8258da2f fix: make move to prime location z-hopped (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers 79692200b0 fix: make move toward hollow prime tower always z hopped (CURA-2325) 2016-11-09 10:24:24 +01:00
Tim Kuipers 966912ccc5 fix: more prime positions cause inside of hollow prime tower is quite big (CURA-2325) 2016-11-09 10:19:15 +01:00
Tim Kuipers 1513dcad5c fix: add brim on inside of hollow prime tower (CURA-2325)
even when we have selected to generate brim only for outside polygons
2016-11-09 10:19:15 +01:00
Tim Kuipers 41050ac835 fix: wipe on middle of prime tower (CURA-2325) 2016-11-09 10:19:15 +01:00
Tim Kuipers fb8625756f fix: return *this for operator= (CURA-2325) 2016-11-09 10:19:15 +01:00
Tim Kuipers 886bab29f7 refactor: cache prime tower walls as well as infill (CURA-2325) 2016-11-09 10:19:15 +01:00
Tim Kuipers 5bdf538d35 lil cleanup prime tower (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers 7d5040e283 feat: hollow prime tower (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers a49ed9a90e cleanup: removed unused var in PrimeTower (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers 7a4e732f3b refactor: pass along new_extruder to wipe tower generator functions (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers 653ce82255 fix: make wipe settings settable per extruder (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers 0b1df81945 feat: separate setting for pre-wipe (CURA-2325) 2016-11-09 10:19:14 +01:00
Tim Kuipers f65993c5b6 fix: put prime_tower_wipe_enabled back to old functionality (CURA-2325) 2016-11-09 10:19:14 +01:00
Ghostkeeper df91b3d8aa Merge branch 'feature_extruder_temp_layer_0' 2016-11-08 14:46:45 +01:00
Tim Kuipers 4b58ab0ad9 refactor/fix: plan extruders independently of meshes and plan support per extruder plan (CURA-2789)
When printing dual color models with dual support (different support infill extruder than support skin extruder)
all support would either be printed before all models or after, leading to two extruder switches in one layer.

Now the extruder_order is calculated independently of the mesh_order and the support is added per extruder plan.

The support is always added first, so that:
- in single extrusion we never print in order support-support-model-model which would lead to model being printed on top of model which hasn't cooled enough
- in dual color, dual support we always print E1-support-model-support-model-E2-support-model-support-model so that oozle is automatically wiped on support
2016-11-08 11:36:28 +01:00
Tim Kuipers 9cbdfd2152 refactor/fix: return whether support was added to extruder plan and only switch extruder if plans were added (CURA-2789) 2016-11-08 11:30:16 +01:00
Tim Kuipers 4a0a0088fe cleanup: remove unused parameter to FffGcodeWriter::addSupportToGCode (CURA-2789) 2016-11-07 17:49:35 +01:00
Ghostkeeper dc37384ffd Merge branch 'bugfix_support_retractions' 2016-11-07 15:40:08 +01:00
Tim Kuipers 2a21e6c348 fix: don't write temperature gcode commands for the UM2 family (CURA-2781, CURA-2736)
they are fixed by the firmware
2016-11-07 15:16:43 +01:00
Tim Kuipers 30011a5285 fix: insert preheat commands even in single extruder mode (CURA-2736) 2016-11-07 13:56:22 +01:00
Tim Kuipers 965b28e009 fix: compiler warnings for unsigned layer_nr and extruder_nr (CURA-2736) 2016-11-07 13:55:22 +01:00
Tim Kuipers 1b37007003 feat: initial layer extruder temp (CURA-2736) 2016-11-07 13:48:48 +01:00
Tim Kuipers 5cf0bcd399 feat: add is_initial_layer to layerplan and extruderplan (CURA-2736) 2016-11-07 13:48:48 +01:00
Tim Kuipers 0930d61dad feat: material_bed_temperature_layer_0 (CURA-2781)
set bed temeprature to normal at first layer
set bed temp to initial layer bed temp the first layer of each next meshgroup (one-at-a-time mode)
wait for initial bed temp to be reached
don't wait for second layer bed temp
2016-11-07 13:48:48 +01:00
Tim Kuipers a181977ce9 refactor: moved command line settings to fdmprinter.def.json (CURA-566)
also fixed some problems:
- type of one setting was string rather than str
- there were some old unused settings in there (prime_tower_outward_dir, machine_prinbt_temp_wait)
2016-11-07 11:59:13 +01:00
Ghostkeeper 3ab19f2f29 Merge branch 'feature_wall_wipe' 2016-11-07 11:37:18 +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
Ghostkeeper c4a3830838 Merge branch 'bugfix_support_brim_round' 2016-11-04 15:23:47 +01:00
Jaime van Kessel d546c27462 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-11-04 14:59:57 +01:00
Jaime van Kessel 7664e81aa2 Merge branch 'feature_concentric_3d_infill' of github.com:Ultimaker/CuraEngine 2016-11-04 14:54:07 +01:00
Tim Kuipers aa2ce7c770 refactor: retrieve print_layer_count from SliceDataStore rather than passing it to all functions (CURA-2077) 2016-11-04 14:23:27 +01:00
Tim Kuipers f63fc1ed74 fix: compute layer_count once and for all (CURA-2077) 2016-11-04 14:18:47 +01:00
Tim Kuipers ac183f4e4b refactor: don't pass down total_layers, but use mesh.layers.size instead (CURA-2077) 2016-11-04 13:15:03 +01:00
Tim Kuipers 4f3c337cc7 fix: resize layers vector in all meshes beforehand (CURA-2077)
A lot of (outdated) code depends on there being the same amount of layers in each mesh.
This was not the case for anti-overhang meshes and support meshes
Now each mesh starts out with the same amount of empty layers
2016-11-04 13:14:23 +01:00
Ghostkeeper 1e24769061 Merge branch 'feature_start_layer_far_away' 2016-11-04 11:36:48 +01:00
Tim Kuipers 02134eb822 fix: don't retract while performing the outer wall wipe (CURA-1698) 2016-11-03 20:18:45 +01:00
Tim Kuipers b436da841a fix2: don't access protected member from within lambda function (CURA-2704) 2016-11-03 14:45:58 +01:00
Tim Kuipers fa95e56b76 fix: don't access protected member from within lambda function (CURA-2704) 2016-11-03 14:13:52 +01:00
Ghostkeeper 6bed19c295 Merge branch 'feature_infill_support' 2016-11-03 13:37:07 +01:00
Tim Kuipers 2a20853b92 fix: getExtrudersUsed only include platform adhesion for first layer(s) (CURA-2789) 2016-11-02 17:50:30 +01:00
Tim Kuipers 09ad6301e7 refactor: separate handleSupportBeforeModels out of FffGcodeWriter::addSupportToGCode (CURA-2789) 2016-11-02 16:55:34 +01:00
Tim Kuipers d8fa29e979 cleanup: const-correctness for SliceDataStorage::getExtrudersUsed (CURA-2789) 2016-11-02 16:54:50 +01:00
Tim Kuipers ab91cc2def lil refactor: p0 ==> b_from_transformed (CURA-2704)
to conform to the other parameters such as a_from_transformed
2016-11-02 16:39:31 +01:00
Tim Kuipers cd4e2e29a3 lil refactor: transformed_startPoint ==> transformed_from (CURA-2704) 2016-11-02 16:37:12 +01:00
Tim Kuipers 0f454e897b refactor: polygonCollidesWithlineSegment ==> polygonCollidesWithLineSegment (l==>L) (CURA-2704) 2016-11-02 16:35:33 +01:00
Tim Kuipers c1d53811f3 lil (no unneccesary type cast (CURA-2077) 2016-11-02 16:05:36 +01:00
Tim Kuipers dbe6269262 Revert "refactor: support_mesh ==> overhang_mesh (CURA-2077)"
This reverts commit 00041da2df.
2016-11-02 16:01:08 +01:00
Tim Kuipers 0c395c5bfa fix: wall wipe didn't update last point (CURA-1698) 2016-11-02 15:35:34 +01:00
Tim Kuipers f312f15813 Merge branch 'master' into feature_infill_support 2016-11-01 11:04:13 +01:00
Ghostkeeper 406ea7155c Merge pull request #408 from thopiekar/master-gcc6-fix
Adding <numeric> for GCC 6.x
2016-11-01 10:21:16 +01:00
Thomas Karl Pietrowski f0f23ed732 Adding <numeric> for GCC 6.x
Otherwise you will get something like:

In file included from /<<PKGBUILDDIR>>/src/FffPolygonGenerator.cpp:7:0:
/<<PKGBUILDDIR>>/src/utils/algorithm.h: In function ‘std::vector<long unsigned int> cura::order(const std::vector<_Tp>&)’:
/<<PKGBUILDDIR>>/src/utils/algorithm.h:30:5: error: ‘iota’ is not a member of ‘std’
     std::iota(order.begin(), order.end(), 0); // fill vector with 1, 2, 3,.. etc
     ^~~
2016-11-01 09:48:46 +01: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
Ghostkeeper 0a59a059f4 Merge branch 'feature_nozzle_off_after_use' 2016-10-31 13:31:37 +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
Tim Kuipers e902fb3fc9 lil (CURA-2704)
makes for better debugging of the scenario of doom (isinside =/= inside)
2016-10-27 22:55:20 +02:00
Tim Kuipers c7be93e850 test: isinside error I couldn't reproduce (CURA-2704) 2016-10-27 22:53:51 +02:00
Tim Kuipers fe8207fb1b fix: user clipper functions for Polygons::inside (CURA-2704) 2016-10-27 22:53:15 +02:00
Tim Kuipers d1fbe96d6f feat: use LocToLineGrid for moveInside-like functions (CURA-2704) 2016-10-27 17:17:07 +02:00
Tim Kuipers ccc89e6263 refactor: typedef SparseLineGrid<PolygonsPointIndex, PolygonsPointIndexSegmentLocator> LocToLineGrid (CURA-2704) 2016-10-27 16:28:41 +02:00
Tim Kuipers d235de6ca2 fix: early stopping for SparseGrid for_each-like functions (CURA-2704) 2016-10-27 15:06:54 +02:00
Tim Kuipers 4d98e07eb4 fix: safety for polygon operator[] (CURA-2704) 2016-10-27 12:22:50 +02:00
Tim Kuipers 7c3f69a5bf bugfixes: combing edge cases (CURA-2704) 2016-10-27 12:22:13 +02:00
Tim Kuipers 846bb1109a fix: combing: create inside_loc_to_line grid after partsView (CURA-2704) 2016-10-27 12:02:48 +02:00
Tim Kuipers 8c5ba49068 fix: more lenient assertions due to rounding errors (CURA-2704) 2016-10-26 18:33:14 +02:00
Tim Kuipers 8e18139ae9 fix: use loc_to_line_grid for optimized combpath optimization (CURA-2704) 2016-10-26 18:32:05 +02:00
Tim Kuipers 410d42ccb3 fix: use inside_loc_to_line grid for checking whether a small move crosses the boundary (CURA-2704) 2016-10-26 18:02:10 +02:00
Tim Kuipers 2c35ba595c refactor: use LazyInitialization for Comb::outside_loc_to_line (CURA-2704) 2016-10-26 17:53:34 +02:00
Tim Kuipers 8f04afbff9 refactor/fix: LazyInitialization: from bind to lambdas (CURA-2704)
also fixes the problem of temporary rvalues being used by the constructor function
2016-10-26 17:51:57 +02:00
Tim Kuipers 1fd5355290 fix: combing: compute whether a small move is cross-boundary (CURA-2704)
That is: whether the move is (party) over the in_between area
2016-10-26 15:43:59 +02:00
Tim Kuipers 65b6c48391 refactor: use LazyInitialization for Comb::boundary_outside (CURA-2704) 2016-10-26 15:41:16 +02:00
Tim Kuipers 34c0960cc2 fix: LazyInitialization constructor with function object (CURA-2704) 2016-10-26 15:39:41 +02:00
Tim Kuipers d6175e8269 feat: LazyInitialization (CURA-2704) 2016-10-26 15:38:42 +02:00
Thomas Karl Pietrowski 47984afb5f Fixing formatting in README.md 2016-10-25 20:08:49 +02:00
Tim Kuipers c86823033d feat: PolygonUtils::polygonCollidesWithlineSegment(.) for a loc_to_line_grid (CURA-2704) 2016-10-25 17:59:19 +02:00
Tim Kuipers 6c157b4e1f fix: made function parameters const in SparseGrid (CURA-2704) 2016-10-25 17:52:32 +02:00
Tim Kuipers 97b8d63547 fix: LinearAlg2D::lineSegmentsCollide now properly handles colinear cases (CURA-2704) 2016-10-25 16:58:28 +02:00
Tim Kuipers f0536be401 refactor: move part of LinearAlg2D::lineSegmentsCollide to LinearAlg2D (CURA-2704) 2016-10-25 16:56:57 +02:00
Tim Kuipers 2c983ce39c feat: SparseGrid::processLine (CURA-2704) 2016-10-25 16:04:38 +02:00
Tim Kuipers a3eb8ebb2d refactor: made SparseGrid function templates into std::function (CURA-2704) 2016-10-25 16:04:01 +02:00
Tim Kuipers bb98cb983e refactor: abstract SparseLineGrid::insert to SparseGrid::processLine (CURA-2704) 2016-10-25 11:56:17 +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 a67f7465c1 fix: print support consecutive instead of always at end of layer (CURA-2789)
also support_interface_extruder_nr mattered even if the interface was turned off
2016-10-22 16:34:02 +02:00
Tim Kuipers 9b8ef3981a feat: retract_at_layer_change (CURA-2780) 2016-10-22 16:21:20 +02:00
Tim Kuipers 24a22eec82 feat: start_layers_at_same_position (CURA-1112) 2016-10-21 17:45:44 +02:00
Ghostkeeper 4d34cbc66b Merge branch 'bugfix_double_to_stream' 2016-10-21 17:28:58 +02:00
Tim Kuipers 405a2b2a5f fix: allow outer wall wipe to wrap around as many times as requested (CURA-1698) 2016-10-21 17:08:09 +02:00
Tim Kuipers 17260b0272 feat: wall_0_wipe (CURA-1698) 2016-10-21 17:01:40 +02:00
Tim Kuipers 2785baf7be refactor: allow wall_0_wipe distance as parameter to GCodePlanner::addPolygon (CURA-1698) 2016-10-21 17:01:25 +02:00
Tim Kuipers c4bc6b8d19 cleanup: codestyle in GCodePlanner::addPolygon (CURA-1698) 2016-10-21 17:00:24 +02:00
Tim Kuipers a29af7f791 Revert "Revert "feat: setting for carveMultipleVolumes (CURA-2712)""
This reverts commit d50f67e583.

Reapplies b2d837efde
2016-10-21 16:22:45 +02:00
Tim Kuipers f304c09db4 Merge branch '2.3' 2016-10-21 16:22:30 +02:00
Tim Kuipers d50f67e583 Revert "feat: setting for carveMultipleVolumes (CURA-2712)"
This reverts commit b2d837efde.
2016-10-21 16:22:16 +02:00
Tim Kuipers b2d837efde feat: setting for carveMultipleVolumes (CURA-2712) 2016-10-21 16:05:15 +02:00
Ghostkeeper 5c680b312b Indent broken-up lines
So that you can see that the line is broken up into multiple lines.

Contributes to issue CURA-1103.
2016-10-21 15:52:22 +02:00
Ghostkeeper 0a683ff05e Transform order algorithm to our code style
Lukasz needs to obey the rulesz!

Contributes to issue CURA-1103.
2016-10-21 15:39:19 +02: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
Tim Kuipers 0dc6dcbb34 fix: concentric infill doesn't start right next to the inner wall any more (CURA-2772) 2016-10-20 23:22:07 +02:00
Tim Kuipers dbb48c82bf fix: concentric infill doesn't oscilate because of alternate extra wall (CURA-2772)
because the innermost wall was different every layer, the concentric infill was also shifted every layer
2016-10-20 23:13:57 +02:00
Tim Kuipers 2a1e4da930 feat: concentric 3d infill (CURA-2772) 2016-10-20 22:57:31 +02:00
Tim Kuipers dd481bcc2e fix: tetrahedral infill line distance is now the average line distance (CURA-2772)
Because the lines of tetrahedral infill sway toward and away from each other, we need to speak of an average line distance.
However, the line distance when you skip one line is constant; I call that the period.
2016-10-20 22:56:51 +02:00
Tim Kuipers f68d1a4e2d fix: concentric infill copied instead of pass by reference (CURA-2772) 2016-10-20 22:52:51 +02:00
Tim Kuipers 9d56baba41 fix: keep SliceMeshStorage aligned with Mesh (CURA-2077) 2016-10-20 09:38:25 +02:00
Tim Kuipers 4e96d9cbe6 feat: infill_hollow (CURA-2748) 2016-10-19 18:13:38 +02:00
Tim Kuipers 00041da2df refactor: support_mesh ==> overhang_mesh (CURA-2077) 2016-10-19 16:42:50 +02:00
Tim Kuipers 478bd31d02 Merge branch 'bugfix_double_to_stream' of github.com:Ultimaker/CuraEngine into bugfix_double_to_stream 2016-10-18 11:02:37 +02:00
Tim Kuipers faab907bab fix: int64_t and double formatting (CURA-2627) 2016-10-17 17:51:38 +02:00
Tim Kuipers dff554863c fix: nozzle was never turned off (CURA-1103) 2016-10-17 17:25:18 +02:00
Tim Kuipers f2222f97fd fix: PrimeTower::extruder_count wasn't set (CUTA-1103) 2016-10-17 17:20:25 +02:00
Tim Kuipers aa18e7bd08 feat: turn nozzle off after last layer switch (CUTA-1103) 2016-10-17 17:12:15 +02:00
Tim Kuipers 07dc53765a fix: removeEmptyFirstLayers invalidated mesh.layer_nr_max_filled_layer (CURA-1103) 2016-10-17 17:11:37 +02:00
Tim Kuipers 559deb8914 refactor: moved max_print_height_second_to_last_extruder to FffPolygonGenerator (CURA-1103) 2016-10-17 17:10:57 +02:00
Tim Kuipers 421ff6d818 feat: prime tower max print height calculation more generic (CURA-1103)
Also fix for platform adhesion in registering the max height an extruder is used.
2016-10-17 15:32:26 +02:00
Tim Kuipers e85a1004cd feat: algorithm::order function (CURA-1103) 2016-10-17 14:46:07 +02:00
Tim Kuipers 627848bc41 refactor: max_object_height_second_to_last_extruder ==> max_print_height_second_to_last_extruder (CURA-1103) 2016-10-17 11:30:53 +02:00
Ghostkeeper eccc62cf1d Add whitespace around binary operators
As per our code style.

Contributes to issue CURA-2627.
2016-10-17 11:06:22 +02:00
Tim Kuipers 1d251fef70 fix: limit prime tower height when support is touching buildplate only (CURA-2633) 2016-10-15 16:15:18 +02:00
Tim Kuipers 16a0cf0fd5 fix: make first layer brim under support round (CURA-2686) 2016-10-15 15:59:48 +02:00
mboerwinkle 06c3729d51 cleaned up a few more things 2016-10-14 14:48:06 +00:00
Tim Kuipers 3c7c352bfc fix: add support during generation, causing all support settings to be applied to support meshes (CURA-2077)
This has the disadvantage that support meshes are re-evaluated for each normal mesh.
However, otherwise support meshes could overlap with each other mesh..
2016-10-14 16:44:50 +02:00
Tim Kuipers 66e6375942 fix: lil typo in AreaSupport::generateSupportAreas for support meshes (CURA-2077) 2016-10-14 16:43:26 +02:00
Tim Kuipers 8d3f66c2cb fix: don't switch extruder if support interface is too small to be printed (CURA-2077) 2016-10-14 16:41:15 +02:00
Tim Kuipers 1fd540c231 fix: also print support of support meshes above normal support (CURA-2077) 2016-10-14 16:00:45 +02:00
Tim Kuipers ac799dd00e fix: don't do multi volumes functions on support meshes (CURA-2077) 2016-10-14 16:00:22 +02:00
Tim Kuipers 699406b044 refactor: anti_support_mesh ==> anti_overhang_mesh (CURA-2077) 2016-10-14 15:31:53 +02:00
Tim Kuipers 2f3333e87c feat: anti support meshes (CURA-2077) 2016-10-14 15:30:19 +02: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 58e2e1a4e1 fix: better buffer for double to stream and more tests (CURA-2627) 2016-10-13 17:39:59 +02:00
Tim Kuipers 4ebbceb3e3 Merge branch '2.3' 2016-10-11 16:43:05 +02:00
Tim Kuipers c0495edf48 fix: turn off fans if fans are disabled (CURA-2603) 2016-10-11 16:42:56 +02:00
Tim Kuipers ace0045109 Merge branch '2.3' 2016-10-11 16:14:44 +02:00
Tim Kuipers 1574292945 fix: forgot to write retractions with given precision (CURA-2619) 2016-10-11 16:14:01 +02:00
Tim Kuipers ed3f9f107c fix: only wipe on prime tower when enabled (CURA-2605) 2016-10-11 15:55:05 +02:00
Tim Kuipers 7a4a7fe46a Merge branch '2.3' 2016-10-11 15:01:03 +02:00
Tim Kuipers 18bf08a1b5 fix: retrieve adhesion_type globally (CURA-2605) 2016-10-11 15:00:51 +02:00
Tim Kuipers dc41117078 Merge branch 'master' into feature_recursive_infill 2016-10-11 13:30:24 +02:00
Tim Kuipers 977d02a9a2 Updated link to code conventions 2016-10-11 09:22:02 +02:00
mboerwinkle c339dbc8ae added subdivcube infill 2016-10-10 17:13:29 +00:00
Tim Kuipers f30c309249 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-10-10 16:08:31 +02:00
Tim Kuipers af3536b307 Merge remote-tracking branch 'remotes/origin/feature_remove_trailing_zeros' 2016-10-10 16:08:22 +02:00
Tim Kuipers 8aed4c9139 Merge pull request #399 from Renha/master
Extra dollars removed from readme.
2016-10-10 15:48:30 +02:00
Renha 03fa1c2d37 Extra dollars removed from readme.
There are no need to write $s twice.
2016-10-10 16:40:49 +03:00
Tim Kuipers 7582100fba fix: force prime tower wipe as extrusion move so that it's not z hopped (CURA-2522) 2016-10-06 13:42:02 +02:00
Tim Kuipers edd1d5c8dd fix: possible infinite loop in support interface generation (CURA-2545) 2016-10-05 17:35:16 +02:00
Tim Kuipers 5971604805 cleanup: less boolean trappy (CURA-2525) 2016-10-05 17:20:48 +02:00
Tim Kuipers a8ea6511bd fix: Polygon::smooth_outward can now remove whole hole polygons (CURA-2526) 2016-10-05 14:28:39 +02:00
Tim Kuipers 5c1083db0b fix: dont remove support for brim inside empty holes (CURA-2525) 2016-10-04 15:43:04 +02:00
Tim Kuipers f9b917f9d1 feat: Polygons::getEmptyHoles (CURA-2525) 2016-10-04 15:42:40 +02:00
Tim Kuipers eb065c1a07 fix: avoid obstacles and retract when moving to prime tower (CURA-2522) 2016-10-04 14:16:06 +02:00
Jack Ha 29978b8654 Fix testsuite by adding mock resolveOrValue 2016-10-04 13:23:21 +02:00
Tim Kuipers 9563aeb1c0 fix: prime tower back to LINEs because of CURA-2511 (CURA-2510) 2016-10-03 17:10:46 +02:00
Ghostkeeper fb7cd6a572 Fix indenting
Contributes to issue CURA-1962.
2016-09-30 16:26:39 +02:00
Tim Kuipers 3f02cf1f33 Merge branch 'feature_rotation_matrix' of github.com:Ultimaker/CuraEngine into feature_rotation_matrix 2016-09-30 16:21:14 +02:00
Tim Kuipers 7bdd5690f7 fix: mesh_rotation renamed to mesh_rotation_matrix and warning emitted if matrix is incorrect (CURA-2416) 2016-09-30 16:20:45 +02:00
Tim Kuipers 1de4107ea6 refactor: also use my own << operator for writing integers to stream (CURA-1962) 2016-09-30 15:30:59 +02:00
Tim Kuipers 6306321007 lil fixes (CURA-1962) 2016-09-30 15:26:55 +02:00
Tim Kuipers 7281e2187e feat: faster double to stream without trailing zeros (CURA-1962) 2016-09-30 15:26:14 +02:00
Ghostkeeper 5f99281478 Fix setting name mesh_rotation_matrix
This was not congruent with the setting name in command_line_settings.def.json

Contributes to issue CURA-2416.
2016-09-30 14:00:17 +02:00
Tim Kuipers 3d3c12a9d2 feat: get transformation matrix from settings (CURA-2416) 2016-09-30 12:29:08 +02:00
Ghostkeeper 739aedf8ad Merge branch 'feature_wipe_on_prime_tower' 2016-09-29 20:46:00 +02:00
Tim Kuipers 1bb79f850a fix: no more wipe after last printed prime tower; no z hop for wipe; wipe slower (CURA-2420) 2016-09-29 18:30:25 +02:00
Tim Kuipers 3d77a426dd fix: only wipe on single closest line of prime tower (CURA-2420)
otherwise the move from the switch location to the wipe tower already wiped the nozzle on the prime tower, because it moved through the prime tower toward the wipe location
2016-09-29 15:03:41 +02:00
Arjen Hiemstra 3aa3e4ef92 Merge branch 'feature_export_speedup'
* feature_export_speedup:
  lil writeInt2mm improvements (CURA-2472)
  fix: output integers directly to stream rather than converting to double first (CURA-2472)
2016-09-29 13:32:34 +02:00
Tim Kuipers eb5231e7a8 lil fix: forgotten return statement in hopefully unreachable code (CURA-2420) 2016-09-29 12:16:53 +02:00
Tim Kuipers 17a9764181 fix: retrieve support_enable per mesh (CURA-2492) 2016-09-29 11:57:09 +02:00
Tim Kuipers 86e7dbf2b1 lil writeInt2mm improvements (CURA-2472) 2016-09-29 10:00:36 +02:00
Tim Kuipers ccaf8538d8 fix: multVolumes: merge overlap better with model (CURA-2427)
when models where directly adjacent, the overlap area wouldn't be merged with the model at all places because of rounding errors
2016-09-29 09:46:44 +02:00
Tim Kuipers a248662077 lil doc (CURA-2420) 2016-09-28 18:53:56 +02:00
Tim Kuipers fc28698479 fix: tests for PolygonUtils::spreadDots (CURA-2420) 2016-09-28 18:41:59 +02:00
Tim Kuipers 263bb3099b bugfixes PolygonUtils::spreadDots, segmentLength and PolygonsPointIndex (CURA-2420) 2016-09-28 18:41:30 +02:00
Tim Kuipers 25b83c9dda factored out PolygonUtils::spreadDots from PrimeTower::generateWipeLocations (CURA-2420) 2016-09-28 17:54:54 +02:00
Tim Kuipers 7025e5cea4 indent only (CURA-2420) 2016-09-28 17:24:57 +02:00
Tim Kuipers 183fc38ca9 refactor PrimeTower::generateWipeLocations (CURA-2420) 2016-09-28 17:24:38 +02:00
Tim Kuipers f4461ca41a feat: simple fuctions to find the nearest vert in polygons (CURA-2420) 2016-09-28 17:20:12 +02:00
Tim Kuipers 5ba9026632 factored PolygonsPointIndex out of PolygonUtils (CURA-2420) 2016-09-28 17:19:29 +02:00
Tim Kuipers 01ec0b847f lil (CURA-2420) 2016-09-28 16:40:04 +02:00
Tim Kuipers 9fe8796844 fix: generateMultipleVolumesOverlap wasn't applied (CURA-2427) 2016-09-28 15:47:11 +02:00
Tim Kuipers c554ec4178 fix: register horizontal expansion in the AABB of a mesh (CURA-2427) 2016-09-28 15:16:05 +02:00
Tim Kuipers dce8a4629f fix: output integers directly to stream rather than converting to double first (CURA-2472) 2016-09-28 11:32:25 +02:00
Tim Kuipers 10af83137b prime tower: changed from lines to zigzag infill (CURA-2420) 2016-09-27 12:05:14 +02:00
Tim Kuipers d45d00b441 fix: wipe tower overlapped with brim (CURA-2420) 2016-09-27 11:56:31 +02:00
Tim Kuipers b2abcbd7b4 refactor: move last_prime_tower_poly_printed inside PrimeTower class (CURA-2420) 2016-09-27 11:29:50 +02:00
Tim Kuipers 9c15d18cfb unfeat: remove setting prime_tower_dir_outward (CURA-2420) 2016-09-27 11:22:59 +02:00
Tim Kuipers 7122335a55 prime tower: cleanup, const correctness and documentation (CURA-2420) 2016-09-27 11:21:01 +02:00
Tim Kuipers b5b05c1894 lil cleanup (CURA-1062) 2016-09-22 20:51:16 +02:00
Tim Kuipers 8d6dd5ae8b fix: dont draw skirt through ooze/draft shield (CURA-1062) 2016-09-22 20:08:18 +02:00
Tim Kuipers 433c90617e fix: always wipe nozzle diagonally on wipe tower (CURA-2420) 2016-09-22 16:50:24 +02:00
Tim Kuipers 2980b20346 cleanup & documentation of primetower (CURA-2420) 2016-09-22 16:06:53 +02:00
Tim Kuipers 5993b5f606 oops committed debug code (CURA-2420) 2016-09-22 15:45:50 +02:00
Tim Kuipers f7940498f0 feat: wipe nozzle before starting prime tower (CURA-2420)
wipe at different locations each layer, so that there won't be a buildup of material on one place, which might get the tower knocked over
2016-09-22 15:42:58 +02:00
Tim Kuipers 03acc7629c made some polygon functions const as they should be (CURA-2420) 2016-09-22 15:41:46 +02:00
Ghostkeeper f903d438f2 Merge branch 'bugfixes_adhesion' 2016-09-22 13:53:47 +02:00
Tim Kuipers 04dc8ac68b lil auxiliary functions (CURA-2420) 2016-09-22 13:34:53 +02:00
Tim Kuipers 1a2ba63c74 lil cleanup (CURA-2420) 2016-09-21 18:03:11 +02:00
Tim Kuipers d28d86c208 doc: better documentation of limit_to_extruder property in the proto file (CURA-2308) 2016-09-21 17:59:55 +02:00
Tim Kuipers afd91bfd2e cleanup: remove old concentric and spiral prime tower (CURA-2420)
I think these prime towers only printed half of the space, assuming the other extruder would print the other half
2016-09-21 17:18:21 +02:00
Tim Kuipers 4cd55f0907 refactor: move wipePoint inside wipeTower (CURA-2420) 2016-09-21 16:55:56 +02:00
Tim Kuipers f20320031f fix: precision was inconsistent (CURA-1955) 2016-09-21 16:07:38 +02:00
Tim Kuipers 44f7b92958 some cleanup and const correctness (CURA-1062) 2016-09-21 10:45:11 +02:00
Tim Kuipers 0b4eda9592 fix: brim was slow for high poly dual extrusion models (CURA-1062, CURA-2422) 2016-09-20 18:12:01 +02:00
Tim Kuipers c674a84f38 Merge branch 'master' into bugfixes_adhesion 2016-09-20 17:31:55 +02:00
Tim Kuipers 2660bd1bc1 Merge branch 'totalretribution-reverse_inset_order' 2016-09-20 13:43:31 +02:00
Tim Kuipers 618660c16f Merge branch 'reverse_inset_order' of https://github.com/totalretribution/CuraEngine into totalretribution-reverse_inset_order 2016-09-20 13:35:25 +02:00
Tim Kuipers 252a797f36 fix: shield-brim got odd number of brim lines, causing gaps (CURA-1062) 2016-09-20 11:37:26 +02:00
Tim Kuipers 2db70b4b5c fix: put helper parts of initial layer in separate layer so as to not apply the layer_0_z_overlap (CURA-1062) 2016-09-20 11:13:09 +02:00
Tim Kuipers 379a3d54f1 fix: brim for ooze/draft shield (CURA-1062) 2016-09-20 09:57:46 +02:00
Tim Kuipers 92fca17411 fix: always even number of brim lines between support and model (CURA-1062) 2016-09-20 09:57:23 +02:00
Ghostkeeper 87637c9ef7 Fix comparison between long and int64_t
On some machines, long isn't 64-bit.

Contributes to issue CURA-2296.
2016-09-20 09:18:44 +02:00
Tim Kuipers d2bbe41ff1 refactor: generateSkirtBrim ==> SkirtBrim::generate CURA-1062) 2016-09-19 18:34:24 +02:00
Tim Kuipers a70fdfb917 feat: introduce layers with helper objects in the airgap (CURA-1062) 2016-09-19 18:01:35 +02:00
Tim Kuipers ceff626d87 raft auciliary functions (CURA-1062) 2016-09-19 17:46:33 +02:00
Tim Kuipers 53c4552de7 removed unused CommandSocket::sendLayerInfo (CURA-1062) 2016-09-19 17:39:08 +02:00
Ghostkeeper a576dd8929 Fix literal long on 32-bit
On some machines, this literal is only 32 bits wide.

I've now made it always 64 bits wide.

Contributes to issue CURA-2296.
2016-09-19 17:11:24 +02:00
Tim Kuipers dcec2d2584 refactor: generateRaft ==> Raft::generate (CURA-1062) 2016-09-19 16:31:58 +02:00
Tim Kuipers 6c2d7b72cb cleanup: removed unused param (CURA-1062) 2016-09-19 16:03:35 +02:00
Tim Kuipers 228b13c96c fix: raft base came half the line width too far (CURA-1062) 2016-09-19 15:54:40 +02:00
Tim Kuipers 4607d0a8ad fix: raft goes inward from draft/ooze shield and starts half a line width outward (CURA-1062) 2016-09-19 15:50:09 +02:00
Tim Kuipers cec7d2bef4 fix: make ooze shield offset round (CURA-1062)
so that the ooze shield can never fall outside of the build plate
2016-09-19 14:49:57 +02:00
Tim Kuipers 1eee21a16c fix: removeSmallAreas works on floats (CURA-1062) 2016-09-19 14:48:49 +02:00
Ghostkeeper e52beb8239 Fix warning of unused variable
It was used only in an assert, so if you're skipping asserts, the variable was unused. I've now cast it into the void to make it 'used'.
2016-09-19 14:40:37 +02:00
Ghostkeeper 72f09d3fa0 Merge bugfix_jagged_support
Conflicts:
	src/gcodeExport.cpp
	src/support.cpp
	src/utils/LinearAlg2D.cpp
	src/utils/linearAlg2D.h
	src/utils/polygon.cpp
2016-09-19 14:34:17 +02:00
Tim Kuipers 9ba3e301d6 fix: don't place ooze shield through thin areas; don't diagonalize oozze shield for too hgih angle; remove small areas afterwards (CURA-1062) 2016-09-19 14:25:34 +02:00
Ghostkeeper 4bea7d8ba2 Use unsigned long string interpreter
Sadly, stoui doesn't exist in C++11. We do have stoul though, which comes closer to what we intend and is still more powerful than we need.

Contributes to issue CURA-2314.
2016-09-16 17:03:08 +02:00
Ghostkeeper b03a7bd9ee Interpret cool_fan_full_layer as a layer number
Because it is.

Contributes to issue CURA-2314.
2016-09-16 16:43:06 +02:00
Ghostkeeper 1f5071c739 Add setting interpretation as layer number
Layer numbers are one-based and not negative. This translates it to zero-based.

Contributes to issue CURA-2314.
2016-09-16 16:41:44 +02:00
TotalRetribution a165265c0a Simplified outer_inset_first based on BagelOrb suggestion. 2016-09-16 10:34:53 +01:00
Ghostkeeper 7ba5b5c0c8 Merge branch 'bugfix_jagged_support' of github.com:Ultimaker/CuraEngine into bugfix_jagged_support 2016-09-15 16:12:22 +02:00
Tim Kuipers adcd061f00 fix: smooth_outward fixes (CURA-2296) 2016-09-15 15:39:13 +02:00
Tim Kuipers f6df79a134 sanity checks (CURA-2296) 2016-09-15 15:19:27 +02:00
Tim Kuipers 955399765c fix: smooth_outward: continue if a step in both directions doesn't violate the shortcut_length constraint (CURA-2296) 2016-09-15 15:07:30 +02:00
Tim Kuipers b79043f772 fix: smooth_outward: no more asserts which are violated by rounding errors (CURA-2296) 2016-09-15 14:42:27 +02:00
Tim Kuipers 1380d76075 Merge branch 'bugfix_jagged_support' of github.com:Ultimaker/CuraEngine into bugfix_jagged_support 2016-09-15 13:43:23 +02:00
Tim Kuipers a2c5a73f09 fix: support: prefer more smoothing rather than less (CURA-2296) 2016-09-15 13:10:41 +02:00
Tim Kuipers 1bdf07ae88 fix: support smoothing based on whether the current mesh has an interface (CURA-2296)
before it looked at all meshes
2016-09-15 13:06:51 +02:00
TotalRetribution ca1d6082e6 In processInsets moved code in for loops to processInsetLoop function to reduce duplication caused by outer_inset_first. 2016-09-15 12:06:02 +01:00
Tim Kuipers 33eabda16f refactor: support: limited support_line_width to somputation for smoothing_distance (CURA-2296) 2016-09-15 13:02:39 +02:00
TotalRetribution da659759cf Merge remote-tracking branch 'origin/master' into reverse_inset_order 2016-09-15 12:00:53 +01:00
Tim Kuipers 5b99143761 lil doc (CURA-2296) 2016-09-15 12:59:05 +02:00
Tim Kuipers dc92c1376c lil refactor (CURA-2296) 2016-09-15 12:32:01 +02:00
Tim Kuipers beaf71dfe8 lil optimization: pass down the square of shortcut_length in smooth_outward (CURA-2296) 2016-09-15 12:30:33 +02:00
Tim Kuipers 3062c07763 fix: smooth_outward used outdated v02 var (CURA-2296) 2016-09-15 12:23:53 +02:00
Tim Kuipers 134b37da2e refactor: factored out complex case out of smooth_outward (CURA-2296) 2016-09-15 12:15:12 +02:00
Tim Kuipers af10ef571d refactor: factor out the simple case from smooth_outward (CURA-2296) 2016-09-15 11:54:47 +02:00
Tim Kuipers 92af4b76b7 doc: more comments for smooth_outward (CURA-2296) 2016-09-15 10:25:58 +02:00
Tim Kuipers d97cfa4152 refactor: factor out inner part of loop in smoot_outward (CURA-2296) 2016-09-15 09:50:53 +02:00
Tim Kuipers 9988c67397 fix: invalid assert removed (CURA-2296)
assertion didn't hold for lines with a very shallow angle
2016-09-15 09:32:24 +02:00
Tim Kuipers b7f77e9dca lil improvement (CURA-2296) 2016-09-15 09:11:31 +02:00
Tim Kuipers ca25ce076c lil comment (CURA-2317) 2016-09-14 18:12:30 +02:00
TotalRetribution 71bfafbc0f Fixed Indentation in FffGcodeWriter.cpp FffGcodeWriter::processInsets. 2016-09-14 14:53:52 +01:00
Ghostkeeper ec44e711fb Fix long literals
Turns out the 1 wasn't an 1 but a lowercase L. This is why people tend to use uppercase L for long.

Contributes to issue CURA-2296.
2016-09-14 13:48:02 +02:00
Ghostkeeper 8fd5c6d404 Fix wording of angle parameter documentation
Maximal is a local maximum. Maximum is the actual maximum, where there is nothing higher. The second is correct here.

Contributes to issue CURA-2296.
2016-09-14 13:39:42 +02:00
Ghostkeeper 9da278795f Fixed numerical literal typo
Contributes to issue CURA-2296.
2016-09-14 13:33:39 +02:00
Ghostkeeper 2050e71dda Fixed numerical literal typo
Contributes to issue CURA-2296.
2016-09-14 13:30:48 +02:00
Tim Kuipers df003d7649 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-09-14 10:47:17 +02:00
Tim Kuipers 281e647b82 refactor: global_inherits_stack ==> limit_to_extruder (CURA-2308) 2016-09-14 10:47:08 +02:00
Ghostkeeper 0771eafc60 Fix warning of comparison unsigned to signed
This now allows for higher amounts of draft shield layers, in theory, with the same memory and processing cost.
2016-09-13 17:20:14 +02:00
Ghostkeeper 0743994375 Add spaces after comma
As per the code style.

Contributes to issue CURA-2296.
2016-09-13 16:53:42 +02:00
Tim Kuipers 7b9e571474 fix: don't retrieve the machine name from the json document, but from the settings (CURA-2360) 2016-09-13 16:44:07 +02:00
Ghostkeeper 73506345ac Fix line direction mix-up in documentation
The point is before ab, or after ba.

Contributes to issue CURA-2296.
2016-09-13 16:39:52 +02:00
Tim Kuipers ff57c578db fix: copy first extruder if there's no definition for a latter one (CURA-2016) 2016-09-13 15:00:53 +02:00
TotalRetribution 0436916f4a Merge remote-tracking branch 'origin/master' into reverse_inset_order
Conflicts:
	src/FffGcodeWriter.cpp

Fixed Conflict with src/FffGcodeWriter.cpp
2016-09-13 10:55:31 +01:00
Tim Kuipers 4a392d1e79 fix: interface wasn't generated near the top of the print (CURA-2308) 2016-09-13 11:42:53 +02:00
Tim Kuipers eb277a1181 lil type fix (CURA-2016) 2016-09-13 11:38:09 +02:00
Tim Kuipers 7b972305b5 fix: exit when file couldn't load (CURA-2016) 2016-09-13 11:35:41 +02:00
Tim Kuipers 103b2ef7a8 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-09-13 11:18:23 +02:00
Tim Kuipers a4bb8ed287 fix: exit when json couldn't load (CURA-2016) 2016-09-13 11:15:54 +02:00
Tim Kuipers 8edce9d470 log errors when json files couldn't load (CURA-2016) 2016-09-13 11:08:46 +02:00
Tim Kuipers 54152aded7 lil cleanup (CURA-2016) 2016-09-13 10:35:58 +02:00
Tim Kuipers 771e840d07 lil cleanup (CURA-2016) 2016-09-13 10:26:55 +02:00
Tim Kuipers 1057b1e277 fix: load extruder json when and only when extruder is created (CURA-2016) 2016-09-13 10:25:54 +02:00
Tim Kuipers 26b78d68f4 fix: don't overload extruder settings over user supplied (CURA-2016) 2016-09-12 18:30:39 +02:00
Tim Kuipers 2583c2e594 Revert "fix: command line slicing overwrote child settings with parent settings"
This reverts commit 9c2fb686e6.
2016-09-12 18:29:35 +02:00
Tim Kuipers 9c2fb686e6 fix: command line slicing overwrote child settings with parent settings 2016-09-12 18:08:08 +02:00
Tim Kuipers 7396deb65b fix: jerk gcode for repetier firmware 2016-09-12 11:07:53 +02:00
Tim Kuipers 32f234eb87 Merge branch '2.3' 2016-09-12 10:49:15 +02:00
Tim Kuipers adbf0354e6 refactor: getDraftShieldHeight==>getDraftShieldLayerCount (CURA-2098) 2016-09-12 10:49:00 +02:00
Tim Kuipers 5e7acc8b62 fix: draft shield is computed over all layers used now (CURA-2098) 2016-09-12 10:47:13 +02:00
Tim Kuipers b1044cbe24 lil innocent assert change 2016-09-09 17:19:16 +02:00
Tim Kuipers 91a5589413 Merge branch '2.3' 2016-09-09 17:04:50 +02:00
Tim Kuipers dc97b5f312 fix: add brim around support and around model (CURA-2317) 2016-09-09 12:30:04 +02:00
Tim Kuipers b494b7b86d fix: made secondary skirt generate even when the primary is empty; retrieved minimal_length per extruder (CURA-2308) 2016-09-09 12:10:38 +02:00
Tim Kuipers 970789fb4b lil renames (CURA-2308) 2016-09-09 11:45:18 +02:00
Tim Kuipers f4e19dd217 lil rename 2016-09-08 19:47:56 +02:00
Tim Kuipers 700ce8ef3b fix: retrieve interface_enable per mesh (CURA-2296) 2016-09-08 19:47:26 +02:00
Tim Kuipers df3426e8bb Merge branch '2.3' 2016-09-08 17:31:02 +02:00
Tim Kuipers fd73470580 fix: carveMultipleVolumes again! (CURA-1917) 2016-09-08 17:30:35 +02:00
Tim Kuipers 959664c080 Merge branch '2.3' 2016-09-08 17:17:53 +02:00
Tim Kuipers 3e9b42a2a2 fix: only print ooze shield up to the layer where the last extruder switch will happen (CURA-2139) 2016-09-08 17:17:44 +02:00
Tim Kuipers eb74c5ce88 Merge branch '2.3' 2016-09-08 16:24:47 +02:00
Tim Kuipers 51b840caee cleanup: made some stuff const in support.cpp (CURA-2052) 2016-09-08 16:24:34 +02:00
Tim Kuipers d695344f1b cleanup: removed debugging code (CURA-2296)
and removed acciodental bracket, which f*cks things up when you try to build previous commits
2016-09-08 15:44:52 +02:00
Tim Kuipers 0e9a7154ca removal: made support_area_smoothing hardcoded (CURA-2296) 2016-09-08 15:39:20 +02:00
Tim Kuipers 72e4bf8069 cleanup: some doc, parameter name changes, lil bugfix (CURA-2296) 2016-09-08 15:35:18 +02:00
Tim Kuipers acf26ba2f8 fix: made LinearAlg2D::getDist2FromLine more robust against rounding errors (CURA-2296) 2016-09-08 15:15:28 +02:00
Tim Kuipers 347f5c6238 fix: made LinearAlg2D::getPointOnLineWithDist more robust against rounding errors (CURA-2296) 2016-09-08 14:55:27 +02:00
Tim Kuipers aebe1ef46c fix: smooth_outward half blocked case was too naive (CURA-2296)
In the case which loks like \/ the sides may be longer than the shortcut on top, while there might be a shortcut halfway through which is long enough
2016-09-08 13:48:06 +02:00
Tim Kuipers 4f073ab23f fix: smooth_outward takes care of degenerate verts (CURA-2296) 2016-09-08 11:51:12 +02:00
Tim Kuipers 62dd1c1575 fix: smooth_outward now handles separately when v02 dist is about the required dist (CURA-2296)
This is to avoid rounding errors which conclude that no shortcut is possible
Now also in the general case
2016-09-08 11:18:50 +02:00
Tim Kuipers 04df283704 indent only (CURA-2296) 2016-09-08 10:46:47 +02:00
Tim Kuipers 695e5dd982 fix: smooth_outward now handles separately when v02 dist is about the required dist (CURA-2296)
This is to avoid rounding errors which conclude that no shortcut is possible
2016-09-08 10:45:18 +02:00
Tim Kuipers 26757ef802 fix: smooth_outward used degrees instead of radians (CURA-2296) 2016-09-07 19:40:01 +02:00
Tim Kuipers baf8f49360 feat: Polygon::smooth_outward (CURA-2296) 2016-09-07 19:23:27 +02:00
Tim Kuipers 4b20528a34 feat: LinearAlg2D::getPointOnLineWithDist(.) (CURA-2296) 2016-09-07 15:41:05 +02:00
Ghostkeeper 487b990f46 Merge branch '2.3' 2016-09-07 15:31:01 +02:00
Ghostkeeper 27d940191e Merge branch 'bugfix_polygon_oversimplification' into 2.3
Conflicts:
	src/utils/ListPolyIt.cpp
	src/utils/ListPolyIt.h
2016-09-07 15:29:05 +02:00
Ghostkeeper 7c48706e80 Fix compiler warning with multiline comment
Because the line ended in a backslash, it would take the next line as a comment too. The next line was already a comment, so it didn't matter, but this period is now at the end to prevent the compiler warning.

Contributes to issue CURA-1966.
2016-09-07 14:51:53 +02:00
Tim Kuipers 09a3ec4790 feat: LinearAlg2D::pointIsLeftOfLine(.) (CURA-2296) 2016-09-07 13:34:52 +02:00
Tim Kuipers b1e602f9f2 lil refactor: argument reorder in PolygonRef::smooth(.) (CURA-1966) 2016-09-07 09:21:11 +02:00
Tim Kuipers f98836c279 cleanup/optimization: PolygonRef::smooth has no more code duplication and values aren't recomputed any more (CURA-1966) 2016-09-07 09:17:43 +02:00
Tim Kuipers b54a0d3b91 fix: revamped Polygon smooth(.) (CURA-1966) 2016-09-06 17:43:27 +02:00
Jack Ha a3f2d08f13 Merge branch '2.3' 2016-09-06 16:53:22 +02:00
Ghostkeeper 2b6c70d19c Remove unnecessary brackets
Contributes to issue CURA-2052.
2016-09-06 15:14:51 +02:00
Tim Kuipers b79f362196 refactor: moves smooth(.) from Polygon.h to Polygon.cpp (CURA-1966) 2016-09-06 14:25:52 +02:00
Tim Kuipers 535bb8cf66 Merge branch '2.3' 2016-09-06 11:14:53 +02:00
Tim Kuipers eb2d4d3ad1 fix: test SparseLineGrid through origin and visualize correct 2016-09-06 11:12:35 +02:00
Tim Kuipers a8152bb727 Merge branch '2.3' into markwal-negativesparselinegrid 2016-09-06 10:55:11 +02:00
Tim Kuipers 3e0a2ca48a Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-09-06 10:54:25 +02:00
Tim Kuipers 2dc4411702 fix: help didn't get outputted 2016-09-06 10:54:18 +02:00
Mark Walker 0d38105a1a Simplify since we don't need the locals outside of
inner block any more
2016-09-05 11:30:40 -07:00
Mark Walker c179d16a9e sign to nonzero_sign and remove corner crossing fix 2016-09-05 11:14:03 -07:00
Mark Walker 76ac083eb3 Add some variable comments 2016-09-05 10:37:10 -07:00
Mark Walker da998384f0 SparseGridLine for negative coordinates
and also the TODO for precisely crossing cell corners
2016-09-05 10:37:10 -07:00
Tim Kuipers 13f7e0d7e4 fix: give support interface a different color (CURA-2049) 2016-09-05 18:01:21 +02:00
Tim Kuipers 1f721a2513 fix: expand support interface so that it's never too thin to be printed (CURA-2052) 2016-09-05 17:50:37 +02:00
Tim Kuipers 4df0a27cb2 fix: support interface skip layer flaw (CURA-2052)
we should divide up the remaining layers after we have checked the top or bottom most
2016-09-05 17:49:34 +02:00
Tim Kuipers 0c6aca19aa fix: interface also checks in-between layers for model (CURA-2052) 2016-09-05 17:05:17 +02:00
Aldo Hoeben bd8c501dc3 Update Cura.proto
Add polygon type for Support Interface

CURA-2049
2016-09-05 16:33:45 +02:00
Tim Kuipers b36acb07c5 fix: don't put skirt under support (CURA-2264) 2016-09-05 16:14:38 +02:00
Tim Kuipers 492bf72ffd fix: wire printing: processStartingCode copied from FffGcodeWriter and replaced setting retrieval to naive approach (CURA-1555) 2016-09-05 15:38:18 +02:00
Tim Kuipers f7ef517f01 fix: div by zero in LinePolygonsCrossings::lineSegmentCollidesWithBoundary() (CURA-2237) 2016-09-05 13:50:06 +02:00
Tim Kuipers 7a015ea146 fix: combing could cross exactly between two consectuive line segments of the boundary (CURA-2237) 2016-09-01 19:15:35 +02:00
Tim Kuipers 48aaebc20d fix: only set support.generates when it actually generated support (CURA-1571) 2016-09-01 18:03:02 +02:00
Tim Kuipers 209f770cf4 fix: don't drop on buildplate when there's support under the model (CURA-1571) 2016-09-01 18:02:01 +02:00
Tim Kuipers ec6c1216f2 fix: wireprint skirt extrusion was 10x too big (CURA-1555) 2016-09-01 15:04:29 +02:00
Tim Kuipers c638ca822b fix: wireprint flow now calculated as mm3 instead of E steps (CURA-1555) 2016-09-01 15:03:59 +02:00
Tim Kuipers 9007e3ff50 refactor: extrusion_per_mm ==> extrusion_mm3_per_mm (CURA-1555) 2016-09-01 15:01:25 +02:00
Tim Kuipers 32ce5e5a44 fix: wireprint don't print skirt at z0 (CURA-1555) 2016-09-01 14:57:29 +02:00
Tim Kuipers 825882100f fix: wire printing pointer bug (CURA-1555) 2016-09-01 13:47:32 +02:00
Tim Kuipers a47aa1e4fd cleanup: changed some logError to log or logWarning and cleaned up the messages 2016-09-01 13:06:01 +02:00
Tim Kuipers f5f1886175 feat: outputing correct gcode header after command line slicing 2016-09-01 12:02:27 +02:00
Tim Kuipers 26d05dc5e6 Merge pull request #385 from markwal/fixconstexprwarning
Fix constexpr function warning for C++14
2016-08-31 17:16:22 +02:00
Mark Walker 2715599791 Fix constexpr function warning for C++14
See https://akrzemi1.wordpress.com/2013/06/20/constexpr-function-is-not-const/
2016-08-28 20:51:36 -07:00
Jaime van Kessel 3c6b153e60 Removed double indication as this caused mac build to fail 2016-08-19 14:58:43 +02:00
Ghostkeeper 9bfdeb4ccd Move per-path offset to use it only on skirt
This is the only place where an outside offset is done and the inside polygons don't matter, so it is the only place where the union can safely be performed, since the union treats holes as normal polygons.

Contributes to issue CURA-2088.
2016-08-19 11:11:10 +02:00
Ghostkeeper 3aaddb08ba Move approxConvexHull implementation to CPP file
Where it damn well belongs, the little runt.

Contributes to issue CURA-2088.
2016-08-19 11:01:20 +02:00
Ghostkeeper 752985c9b2 Remove debug include
Because this include is at the top of the file, I didn't see it was still there. Sorry.

Contributes to issue CURA-2088.
2016-08-18 14:22:22 +02:00
Ghostkeeper dcb8a03a73 Offset polygons one path at a time
This prevents an infinite loop in the offset code in Clipper if the polygons overlap.

Contributes to issue CURA-2088.
2016-08-18 14:16:57 +02:00
Ghostkeeper 028c408be3 Move Polygons::Offset to CPP file
We should really do this with all of these functions. In this case, I required this in order to be able to import SVG for a bit of debugging.

Contributes to issue CURA-2088.
2016-08-18 13:21:27 +02:00
Ghostkeeper 822a2d55f2 Rebase bugfix_overlap_compensation onto master
Contributes to issue CURA-1911.
2016-08-17 17:09:21 +02:00
Ghostkeeper 3e283a375e Revert "lil feat: LinearAlg2D::projectPointOnLine(.) (CURA-1911)"
This reverts commit 7f08d37408eb9d010a24095f3f9b6facbe862c2e.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 635ef25030 Optimize if-statement structure
Also more readable, in my opinion. It's just a bunch of cases and a base case, with lazy evaluation in between.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 9a9855c0a5 Swap ifs so that we use else-if instead of recompute
Saves some computation time.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 83e52f6e53 Make projections constant
These variables aren't changed. This might allow for better optimisations by the compiler.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 9d59dde760 Improve overlap estimation for stair-case
In the case of stairs, there is no overlap either. The approximation now takes that into account at hardly any additional computational cost.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 9b40d6053c Switch from and to back
Since these parameters are now renamed, this is clearer.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper ba05f42c91 Remove intermediary variable
The intermediary variable was supposed to make the variable name more clear. Instead, I just renamed the input parameter, removing the weird construct.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 5684a0cbb4 Remove commented code
As per our code style.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 0647fa21fe Switch to and from other parameters
For consistency.

Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper cb5467d2b3 Fix typo in documentation
Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Ghostkeeper 24ec8bb254 Fix spelling in documentation
Contributes to issue CURA-1911.
2016-08-17 16:43:09 +02:00
Tim Kuipers 8069aba0b5 fix: proximity: don't disregard potential linking between a point and a consecutive line segment (CURA-1911)
short line segments might need linking from front to end when the previous and next line segment are parallel
2016-08-17 16:43:09 +02:00
Tim Kuipers 591cd105b5 lil TODO idea (CURA-1911) 2016-08-17 16:43:09 +02:00
Tim Kuipers 13e5e786bc fix: proximity: don't disregard potential linking between consecutive line segments (CURA-1911)
the end point of the new line segment might still need to be projected onto the other line segment
short line segments might need linking from front to end when the previous and next line segment are parallel
2016-08-17 16:43:09 +02:00
Tim Kuipers 6f0ef96c5e fix: small fixes for overlap compensation (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers ed636f9a44 lil assert change 2016-08-17 16:43:08 +02:00
Tim Kuipers 8f50db989c fix: remove degenerate verts which result in multiple verts sharing the same location (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers f4e22ae7a0 lil feat: LinearAlg2D::projectPointOnLine(.) (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers cbc6e6f270 fix: PolygonProximityLinker::addProximityEnding don't add to the same set we are looping over (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers 07b8165d47 fix: getApproxOverlapArea had arguments ordered wrong (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers e2409148cc fix: compute less overlap when line segments are not opposite each other (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers a3129bf1f6 feat: LinearAlg2D::pointIsProjectedBeyondLine (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers f191497234 fix: overlap compensation: move direction info down to getApproxOverlapArea (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers ef9c477ee2 lil cleanup & doc (CURA-1911) 2016-08-17 16:43:08 +02:00
Tim Kuipers bdcaa6c9ac lil refactor (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 046310efcb more doc of PolygonProximityLinker::addNewPolyPoint (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 74133ae7d7 rename PolygonProximityLinker::findProximatePoints a_from ==> a_point (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 20dff1fe8b Revert "lil doc fix (CURA-1911)"
This reverts commit 1651e04f2cd1cfd69c8c92d397abfba53cb5dcc9.
2016-08-17 16:43:07 +02:00
Tim Kuipers c7be6e147b fix: was taking std::max of double and float (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 574739e193 lil doc fix (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers b3c0f0d2da lil rewrite (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 33be01596c lil doc of wall overlap (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 2cbd6d1c8a lil rename in wall overlap (CURA-1911) 2016-08-17 16:43:07 +02:00
Tim Kuipers 510c328127 lil refactor: user unordered_map/set.find(.) rather than .count(.) (CURA-1911) 2016-08-17 16:43:06 +02:00
Ghostkeeper 9413aceaf2 Add space after comma
Thus haveth the code style spoken.

Contributes to issue CURA-1911.
2016-08-17 16:43:06 +02:00
Ghostkeeper aee1887b57 Add spaces around assignment operators
As the code style declares.

Contributes to issue CURA-1911.
2016-08-17 16:43:06 +02:00
Ghostkeeper b72917305c Add missing brackets
To comply to the code style.

Contributes to issue CURA-1911.
2016-08-17 16:43:06 +02:00
Ghostkeeper 7d61f00b3a Fix documentation grammar
It was hard to read due to the point A vs. the indefinite article a.

Contributes to issue CURA-1911.
2016-08-17 16:43:06 +02:00
Tim Kuipers 247f5d3cde fix: removed debugging member from WallOverlapComputation (CURA-1911) 2016-08-17 16:43:06 +02:00
Tim Kuipers 21202c2e8c fix: don't compensate for overlap if the two lines are going in the same direction (CURA-1911) 2016-08-17 16:43:06 +02:00
Tim Kuipers 6973e99cd1 cleanup: removed old slow overlap computation (CURA-1911) 2016-08-17 16:43:06 +02:00
Tim Kuipers 8cf1f1646b safety: check for duplicate points in input polygon (CURA-1911) 2016-08-17 16:43:06 +02:00
Tim Kuipers 2a1fc8245a safety: check for duplicate points in input polygon (CURA-1911) 2016-08-17 16:43:06 +02:00
Tim Kuipers a1a3931f68 feat: improved slicing speed by letting overlap compensation use SparseLineGrid (CURA-1911)
also iterate over the newly introduced points again, because they might need links which don't get introduced when we already passed that point in the poly
also prevert newly introduced points to again introduce new points, cause otherwise we might introduce a lot of new points in a corner (visual explanation in code)
2016-08-17 16:43:05 +02:00
Tim Kuipers e3dd8f0bdf forgotten import (CURA-1911) 2016-08-17 16:43:05 +02:00
Tim Kuipers 3a06f49fba fix: fixes for SparseLineGrid line to pixel algorithm (CURA-1911)
sometimes a line wouldn't be added to the grid at all
2016-08-17 16:43:05 +02:00
Tim Kuipers 65e90d5de0 feat: ListPolyIt operator!= and hash function object (CURA-1911) 2016-08-17 16:43:05 +02:00
Tim Kuipers e33c441f6d feat: Polygons::pointCount (CURA-1911) 2016-08-17 16:43:05 +02:00
Tim Kuipers 418de5d822 refactor: use actual SparseLineGrid rather than the hacked locToLineGrid (CURA-1911) 2016-08-17 16:43:05 +02:00
Tim Kuipers a6b45b683e fix: no more overlap areas are skipped because neighboring overlap areas were already processed (CURA-1911) 2016-08-17 16:43:05 +02:00
Tim Kuipers eda2c987ff feat: symmetric pair utility class (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers a71c18a146 safety: debug check for line grids (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 424e3edb4d fix: SparseLineGrid computes cells based on print coords rather than grid coords (CURA-1911)
also a fix for horizontal lines, which caused division by zero.
2016-08-17 16:43:04 +02:00
Tim Kuipers ad1c442c9a feat: SparseLineGrid (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 65ced4a4bb feat: SparseGrid now exposes more functions for grid to print space coords to inheriting classes (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 242e8118e3 refactor: split off SparseGrid from SparsePointGrid (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers f720cc1f0b refactor: SparseGridInvasive ==> SparsePointGrid (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 721d7d799f refactor: SparseGrid ==> SparsePointGridInclusive (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 26c3a35150 fix: moved SparseGridElem to SparseGrid.h (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers c1d097f7fe lil rename (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers fedcfe582e safety: asserts in PolygonProximityLinker (CURA-1911) 2016-08-17 16:43:04 +02:00
Tim Kuipers 1ffafd4b17 debug fix: don't visualize SVG upside down (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 45c4e2e0a1 fix: proximitylinker: don't add points twice (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 6ae7fdac5c fix: proximitylinker: don't add points on the same location as other points (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers bf2123b82c feat/refactor: PolygonProximityLinker::addCornerLink (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 81881a876d fix: link points ifthey are proximate even though the line segments are connected (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 34859670ef refactor: bit of renaming (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 4038d39e85 fix: process sharp corners before normal proximite points (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 999a131ecf fix: ListPolyIt assignment overwrite referred polygon (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 2bcffaa0ab fix: overlap comensation is now also activated for sharp corners (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 7f584c2e4f refactor: merge proximity_point_links_endings into proximity_point_links (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers ba045e803b indent change only (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 1fd2c66ec7 fix: don't create ending link when other side continues to overlap with the same point (CURA-1911)
also inverted some logic; indent change follows
2016-08-17 16:43:03 +02:00
Tim Kuipers be7ea53325 fix: account for overlap areas ending in a pointy end (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 8045fb49ff refactor: let PolygonProximityLinker::findProximatePoints use ListPolyIt instead of separate iterators and references (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers 1504e38c8c fix: proximity was only recorded between points and line segments further on in the polygon (CURA-1911) 2016-08-17 16:43:03 +02:00
Tim Kuipers b646e94880 refactor: renaming in PolygonProximityLinker::findProximatePoints (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 929719ebdd refactor: findProximatePoints actual linking functionality moved to its own function (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 905d788c3c fix: findProximatePoints used wrong first segment (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 0dba144c37 doc: PolygonProximityLinker overlap ==> proximity (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers f7ba6979da refactor: moved SparseGridInvasive to its own file (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers ae832cba68 fix: overlap links got introduced twice sometimes (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 6bdc8dae51 refactor: factored out ProximityPointLink into ints own class file (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 9a23163564 copyright 2016-08-17 16:43:02 +02:00
Tim Kuipers fcc207ad0d fix: store whether an overlap link is passed once outside of the link (CURA-1911)
The link was stored at multiple places (copies), so the information was not shared between all copies.
2016-08-17 16:43:02 +02:00
Tim Kuipers 44df11bc2c fix: PolygonProximityLinker::getLink now returns pointer instead of optionally a copy (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 2458a9a580 lil optimization for wall overlap compensation (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers ba92bf9693 cleanup: PolygonProximityLinker::isLinked(.) makes wallOverlap more simple (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 8c1ecf1200 cleanup: simplified WallOverlapComputation::handlePotentialOverlap (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 4fdcf4ed29 cleanup: removed code duplication and add more documentation (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers cde315109a fix: overlap compensation now also compensates segments overlapping with points (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers 50ca8d7473 fix: let overlap compensation account for segments overlapping with multiple other segments (CURA-1911)
Make PolygONProximityLinker::Point2Link be a multimap, mapping points to multiple links
Change getLink(.) to getLinks(.)
Expose Point2Link so that outside classes can reason about which link is which

wallOverlap
Compute the actual overlapping area, since the ratio cannot easily be computed when multiple overlaps are involved
Compute the overlap area for segments for which both ends are linked to the same point
2016-08-17 16:43:02 +02:00
Tim Kuipers 9b8b3d150c cleanup: the list_polygons are used after the contructor of PolygonProximityLinker (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers f4fd6ab0f4 cleanup: lil doc and trailing whitespace (CURA-1911) 2016-08-17 16:43:02 +02:00
Tim Kuipers b593331c17 cleanup: removed outcommented debug code (CURA-1640) 2016-08-17 16:43:02 +02:00
Tim Kuipers afb6237cbf dox fix: updated doc of WallOverlap (CURA-1640) 2016-08-17 16:43:02 +02:00
Tim Kuipers a716b88621 dox fix: updated doc of PolygonProximityLinker (CURA-1640) 2016-08-17 16:43:02 +02:00
Tim Kuipers 0bc384c807 cleanup: removed unused commented code (CURA-1640) 2016-08-17 16:43:02 +02:00
Tim Kuipers a2e4f2a1cb fix: accidentally removed line (CURA-654) 2016-08-17 16:43:01 +02:00
Tim Kuipers d3c62049eb refactor: made WallOverlap use PolygonProximityLinker (CURA-654) 2016-08-17 16:43:00 +02:00
Tim Kuipers e773029266 refactor+fix: moved ProximityLinkAttributes into (mutable) ProximityLink + fixed iterator invalidation issues (CURA-654)
the [passed] attribute needs to be mutable: it doesn't change the hash of the object and needs to be changed after it's been in the set

fixed iterator invalidation issues by simply copying items from the set into the map, rather than referring to them
2016-08-17 16:39:35 +02:00
Tim Kuipers c42b3322cd removed debug function 2016-08-17 16:39:35 +02:00
Tim Kuipers b652db33c1 refactor: rename WallOverlap ==> Proximity (CURA-654) 2016-08-17 16:39:35 +02:00
Tim Kuipers 596082dc7c cleanup PolygonProximityLinker and use ListPolyIt (CURA-654) 2016-08-17 16:39:35 +02:00
Tim Kuipers 411300e0e1 refactor: factor out ListPolyIt class (CURA-654) 2016-08-17 16:39:35 +02:00
Tim Kuipers b44116c4e5 feat: PolygonProximityLinker class (CURA-654) 2016-08-17 16:39:35 +02:00
Ghostkeeper bf0cd02928 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-08-11 16:37:53 +02:00
Ghostkeeper 3b4c54839d Merge feature_brim_under_support
Conflicts:
	src/SkirtBrim.cpp
	src/gcodeExport.cpp
2016-08-11 16:35:27 +02:00
Tim Kuipers b6cb7cd271 fix: don't limit speeds to 1 mm/s when retrieving a setting (CURA-1049) 2016-08-11 16:29:25 +02:00
Tim Kuipers ee447a9191 merge conflict fix (CUYRA-1956) 2016-08-11 16:22:31 +02:00
Ghostkeeper 9d755211cd Update reference to support skin
This new code was introduced by the brim-only-outside feature and gave no merge conflict, but was not up-to-date with the support roof rename to support skin.

Contributes to issue CURA-1413.
2016-08-11 15:58:46 +02:00
Tim Kuipers db83fcd57e fix: also generate brim for parts which flly lie inside other parts (CURA-1413) 2016-08-11 15:38:17 +02:00
Tim Kuipers 2ccaef10b9 feat: Polygons::removeEmptyHoles() (CURA-1413) 2016-08-11 15:38:17 +02:00
Tim Kuipers d004c77106 feat: brim only for outside polygons (CURA-1413) 2016-08-11 15:38:17 +02:00
Tim Kuipers 2bddfcd42a feat: Polygons::getOutsidePolygons() (CURA-1413) 2016-08-11 15:38:17 +02:00
Tim Kuipers 4cd1b5066c fix: only generate skirt polygons for used extruders (CURA-1647)
also cleaned up generateSkirtBrim a bit
also applied code conventions
inadvertently also causes support not to be removed by unprinted skirt
removed skirts_or_brims which didn't need to be a vector (only last elem was used)
2016-08-11 15:38:17 +02:00
Tim Kuipers e0959e4aa0 feat: ExtruderTrain::is_used (CURA-1647) 2016-08-11 15:38:17 +02:00
Tim Kuipers a29dcb33da fix: brim removed support rather than going around it (CURA-1647) 2016-08-11 15:24:20 +02:00
Tim Kuipers 152cf5835f Merge branch 'master' into feature_brim_under_support 2016-08-11 15:19:20 +02:00
Tim Kuipers eb065aa415 lil 2016-08-11 14:53:28 +02:00
Tim Kuipers 9430432af7 fix: support simplifies based on line width (CURA-1966) 2016-08-10 14:17:48 +02:00
Tim Kuipers 252c2cae28 assert fix: default jedi profile has speeds up to 200 2016-08-10 13:12:27 +02:00
Aldo Hoeben 9ee30bba12 Merge pull request #379 from Ultimaker/master-CURA-1724
CURA-1724: Updating README.md
2016-08-10 12:45:03 +02:00
Tim Kuipers 3afef5d29f fix: PolygonRef::simplify early catch for duplicate points in polygons (CURA-1966) 2016-08-10 12:01:48 +02:00
Tim Kuipers 056240d55c fix: PolygonRef::simplify prev wasn't recorded correctly (CURA-1966) 2016-08-10 11:59:28 +02:00
Tim Kuipers 10b43fc9f8 lil: AABB for single polygon (CURA-1966) 2016-08-10 11:37:44 +02:00
Tim Kuipers f83fbfe143 fix: PolygonRef::simplify only removes verts if BOTH line segments are too small now (CURA-1966) 2016-08-09 17:46:10 +02:00
Thomas Karl Pietrowski bcfe400c18 Correcting formatting 2016-08-09 17:38:37 +02:00
Tim Kuipers b67b51ce76 fix: overhauled PolygonRef::simplify (CURA-1966)
polygons would be simplified such that previously removed points violated the allowed error constraint further on in the algorithm
2016-08-09 17:37:10 +02:00
Tim Kuipers 83aeb36bcf feat: ListPolyIt convert functions for single (list)polygon (CURA-1966) 2016-08-09 17:34:00 +02:00
Thomas Karl Pietrowski e75cdf3f7c Removing hack for skipping build of protobuf using gtest
Can't find anything except of gmock in https://github.com/google/protobuf/blob/e8ae137c96444ea313485ed1118c5e43b2099cf1/autogen.sh that mentions gtest.
For about a year gmock has been moved to gtest, but 3.0.0 is still using gmock from it's old repository.
Additionally as the lines mentioned don't fit to the content of automake.sh, I just removed this part.
2016-08-09 17:21:21 +02:00
Thomas Karl Pietrowski ecd11212f4 Referencing to download page 2016-08-09 17:14:07 +02:00
Thomas Karl Pietrowski 5763b1704f Update README.md 2016-08-09 17:01:51 +02:00
Jack Ha f14d67934d Added some mock locals functions in runtests. CURA-1828. 2016-08-09 15:28:57 +02:00
Tim Kuipers 9ef35e2b14 copied ListPolyIt from bugfix_overlap_compensation branch (CURA-1966) 2016-08-09 14:18:34 +02:00
Tim Kuipers fadfaa5a80 removed debug code (CURA-1956) 2016-08-09 11:42:17 +02:00
Tim Kuipers fc962709b0 fix: clipper offset bug testing (CURA-1956) 2016-08-09 11:16:48 +02:00
Tim Kuipers a848b8c71d fix: UPDATE CLIPPER (CURA-1956)
this was loooooooong overdue
2016-08-09 11:15:35 +02:00
Tim Kuipers dc05c2749a feat: write max z feedrate when overriden by user value (CURA-1049) 2016-08-08 17:01:48 +02:00
Tim Kuipers cea312a23a rename: zPos ==> current_layer_z (CURA-1049) 2016-08-08 14:52:14 +02:00
Tim Kuipers deee23d1f8 fix: generate support interface correctly also inside a model (CURA-2074) 2016-08-08 13:48:54 +02:00
Tim Kuipers d097cfa78f rename: generateSupportRoofs ==> generateSupportInterface (CURA-2074) 2016-08-08 13:38:45 +02:00
Tim Kuipers 09c1df7ea6 Merge branch 'markwal-mergeinfillchanges' 2016-08-08 09:53:39 +02:00
Mark Walker 7f9e034dbb Propagate rename pressure->flow all the way down 2016-08-04 11:14:56 -07:00
Mark Walker 05b5a0b45c Rename pressure to flow and make it per extruder 2016-08-04 10:46:25 -07:00
Mark Walker ca1a076db3 nozzle_size doesn't change in the loop 2016-08-04 10:31:59 -07:00
Mark Walker 36c2bd81d0 Add setting to control autospeed for mergeinfill
Also:
- use travel speed for travel moves and extrusion speeds for
extrusion moves
- get the nozzle size from settings
2016-08-04 10:31:59 -07:00
Tim Kuipers d44c8eb067 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-08-04 12:02:44 +02:00
Tim Kuipers 2b81ce1dd5 fix: don't switch to adhesion extruder for skirt when printing raft (CURA-2013) 2016-08-04 12:02:29 +02:00
Tim Kuipers 73df32881a fix: support bottoms now don't check below zero any more (CURA-1013)
taking the max of unsigned int zero and another has no use!
The other value probably wrapped around to unsigned int max_value already
2016-08-02 12:45:05 +02:00
Tim Kuipers 01357eacc4 Merge branch 'master' into feature_support_bottoms 2016-08-02 12:40:05 +02:00
Ghostkeeper fc7c55768a Don't apply first layer speeds on raft layers
This only applied to travel speeds, since raft print speeds are determined by other settings, support is not on the raft layers, and meshes are not on the raft layers.

Contributes to issue CURA-1507.
2016-08-01 13:41:36 +02:00
Ghostkeeper fea300cfc3 Remove unnecessary static cast from int to int
It's already an int.

Contributes to issue CURA-1507.
2016-08-01 13:30:46 +02:00
Arjen Hiemstra 4f4a5dd1e7 Merge branch 'feature_support_settings_from_support_extruder'
* feature_support_settings_from_support_extruder:
  Remove debug statement
  Set settingInheritBase on every mesh in the meshgroup
  Be more robust against wrong input from Arcus
  Distribute global_inherits_stack across meshgroups
  Register SettingExtruder message type
  Sync from frontend: global_inherits_stack message
  feat: setting retrieval inheritance overrides (CURA-1953)
2016-08-01 13:01:18 +02:00
Ghostkeeper 02fe987035 Remove debug statement
Oops. Sorry.

Contributes to issue CURA-2011.
2016-08-01 12:08:46 +02:00
Ghostkeeper 9e7b6212b0 Set settingInheritBase on every mesh in the meshgroup
Also changed the nesting of the for loops around to make it a bit more efficient.

Contributes to issue CURA-2011.
2016-08-01 11:41:44 +02:00
Ghostkeeper 94a3a6b642 Abort thread after it has completed
Otherwise it stays sleeping for 60s. This produced too many threads on OSX.

Contributes to issue CURA-1828.
2016-08-01 11:10:27 +02:00
Tim Kuipers d7eef238ce cleanup: removed dead code (CURA-1647) 2016-07-31 22:12:01 +02:00
Tim Kuipers 3cbfe3b037 fix: retract after each meshgroup (CURA-1829)
also fixes (CURA-1379)
2016-07-31 19:07:55 +02:00
Ghostkeeper 9b8917e763 Be more robust against wrong input from Arcus
A simple range check against the extruder list.

Contributes to issues CURA-2011 and CURA-1953.
2016-07-29 17:38:00 +02:00
Ghostkeeper a5b7b474a6 Distribute global_inherits_stack across meshgroups
Every meshgroup gets the same global_inherits_stack values.

Contributes to issues CURA-2011 and CURA-1953.
2016-07-29 17:18:47 +02:00
Ghostkeeper 839fc30c91 Register SettingExtruder message type
So that we can read it.

Contributes to issue CURA-2011.
2016-07-29 16:29:15 +02:00
Ghostkeeper b8a6888d94 Sync from frontend: global_inherits_stack message
The front-end added the global_inherits_stack SettingExtruder message. We should add it too to be able to read the message. This is a copy from the same file in Cura's front-end.

Contributes to issue CURA-2011.
2016-07-29 16:25:59 +02:00
Jaime van Kessel 14cb8eeabd Removed anciend debug output
This statement of a time before time slowed down the frontend.
2016-07-29 16:17:06 +02:00
Tim Kuipers f9f79fa0e8 fix: only generate skirt polygons for used extruders (CURA-1647)
also cleaned up generateSkirtBrim a bit
also applied code conventions
inadvertently also causes support not to be removed by unprinted skirt
removed skirts_or_brims which didn't need to be a vector (only last elem was used)
2016-07-28 23:20:34 +02:00
Tim Kuipers 691efb3b6e feat: ExtruderTrain::is_used (CURA-1647) 2016-07-28 22:58:45 +02:00
Tim Kuipers 93be9431b7 fix: brim removed support rather than going around it (CURA-1647) 2016-07-28 21:29:46 +02:00
Ghostkeeper 6c757f3fcf Rename draft_shield_height to draft_shield_layers
This was considered better.

Contributes to issue CURA-1295.
2016-07-28 20:06:35 +02:00
Tim Kuipers ae66df7b0a Merge branch 'master' into feature_first_layer_travel_speed 2016-07-28 16:48:48 +02:00
Tim Kuipers d447d9d711 fix: process brim for each meshgroup again (CURA-1721) 2016-07-28 14:22:57 +02:00
Tim Kuipers b30f1c1a2e secret fix: change gcode type comment back to SKIRT 2016-07-28 14:16:08 +02:00
Tim Kuipers 2ff1c876b3 secret fix: change gcode type comment back to SKIRT 2016-07-28 14:14:02 +02:00
Tim Kuipers 6db1097faa API change: support_roof_... ==> support_interface... (CURA-1013) 2016-07-28 14:05:28 +02:00
Tim Kuipers 86cbe1797b Merge branch 'master' into feature_support_bottoms 2016-07-28 13:53:47 +02:00
Tim Kuipers 65f0ba9673 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-28 13:52:25 +02:00
Tim Kuipers 7d6df9746e fix: always generate skin when layer number is almost at top (CURA-1837)
dont try to compare with non-existent layer number which is too high
2016-07-28 13:52:18 +02:00
Ghostkeeper 2d2196648f Make draft shield limit work with small models
Problem was that the draft shield height limit was measured in number of layers, but it was compared with the height of the first layer to determine if we should skip adding draft shield layers, and the first layer height was measured in microns.

Contributes to issue CURA-1295.
2016-07-28 13:45:18 +02:00
Ghostkeeper 6992bb6e03 Code style: Indentation and brackets
Contributes to issue CURA-1509.
2016-07-28 11:44:49 +02:00
Tim Kuipers dee2f82d87 Merge pull request #374 from Ultimaker/bugfix_slicer_initializer
Properly initialize member variables of classes in slicer.h
2016-07-28 10:54:15 +02:00
Tim Kuipers bec685e004 fix: initialize slicer members to invalid values 2016-07-28 10:51:19 +02:00
Tim Kuipers d38ccb7691 fix: changed round_divide to work with unsigned ints (CURA-1013)
the math was wrong for negative numbers
2016-07-27 18:31:22 +02:00
Tim Kuipers e5036763fe fix: round support z distance up (CURA-1013) 2016-07-27 18:26:04 +02:00
Ghostkeeper 865f97c5d7 Repair draft shield height limitation part 2
Renamed DraftShieldLimitation to DraftShieldHeightLimitation. Also applied the limit to FffGcodeWriter and made the draft shield function more logical and make it only check for the limit if the draft shield height is limited.

Contributes to issue CURA-1295.
2016-07-27 17:48:53 +02:00
Ghostkeeper 0b4b04f31a Don't generate skirt if draft shield is full
If draft shield limitation is set to full but the height is set to 0, don't generate a skirt.

Contributes to issue CURA-1295.
2016-07-27 17:48:53 +02:00
Ghostkeeper 39fea42b92 Fix draft shield limitation setting
The engine now listens to the draft shield limitation. If it's set to full, we use the full height of the print to limit the draft shield rather than the height limit setting.

Contributes to issue CURA-1295.
2016-07-27 17:48:53 +02:00
Ghostkeeper f810356bdb Add draft shield height limitation enum
This enum will be needed to determine what height we should use for the draft shield.

Contributes to issue CURA-1278.
2016-07-27 17:48:53 +02:00
Ghostkeeper 4c41acd946 Re-enable skirt if draft shield disabled but height is not 0
It used to only look at the height.

Contributes to issue CURA-1295.
2016-07-27 17:48:52 +02:00
Ghostkeeper af135fff49 Take draft shield height of 0 if draft shield is disabled
This fixes the boolean setting again.

Contributes to issue CURA-1295.
2016-07-27 17:48:52 +02:00
Tim Kuipers ed4457a3f4 Merge branch 'master' into feature_support_bottoms 2016-07-27 17:40:11 +02:00
Tim Kuipers 7ea9b14a33 fix: retrieve globalish support settings from support extruder (CURA-2003) 2016-07-27 17:10:07 +02:00
Tim Kuipers 957c56c6b2 feat: setting retrieval inheritance overrides (CURA-1953) 2016-07-27 16:28:11 +02:00
Arjen Hiemstra 0a689a0da8 Properly initialize member variables of classes in slicer.h
I get crashes because SlicerSegment::endVertex is used uninitialized.
2016-07-27 15:36:58 +02:00
Ghostkeeper 39efcf5680 Add more asserts for isOutsideTest
This also tests other cases where the point happens to be on other edge cases for other sides of the triangle.

Contributes to issue CURA-1981.
2016-07-27 15:25:37 +02:00
Ghostkeeper 0bc373e935 Remove whitespace at end of line
As per our code style rules.

Contributes to issue CURA-1981.
2016-07-27 15:19:31 +02:00
Ghostkeeper 0c82c00e15 Improve documentation for generateSkirtBrim
Contributes to issue CURA-1678.
2016-07-27 11:56:56 +02:00
Tim Kuipers 1859de69d4 fix: round support_z_distance to nearest layer_height multiple, rather than always rounding up (CURA-1013)
this caused the number of roof/bottom layers to be incorrect (CURA-647)
2016-07-27 11:37:46 +02:00
Tim Kuipers e2fc79889b fix rename: .._support_skin options back to .._support_roof (CURA-1013)
We shouldn't change the interface so easily. This makes the json as it was a couple of ocmmits ago
2016-07-27 11:22:42 +02:00
Ghostkeeper b31646f10d Improve documentation of completeConfigs
Contributes to issue CURA-1507.
2016-07-27 11:18:39 +02:00
Tim Kuipers 10a8265674 Merge branch 'master' into feature_support_bottoms 2016-07-27 11:15:15 +02:00
Tim Kuipers 1445472530 fix: use round_divide where neccesary (CURA-1013) 2016-07-27 11:11:22 +02:00
Tim Kuipers 37f7e18269 fix: inline function definition in header (CURA-1013)
inline functions must always be defined in the header
2016-07-27 11:10:42 +02:00
Simon Edwards a854dc692d Added a lot more logging which kicks in when the -vv flag is given.
Contributes to CURA-1509 Cura in slicing loop, Arcus Error (8)
2016-07-27 11:00:28 +02:00
Tim Kuipers 9cbecf5782 fix: z_distance_top/bottom was computed in micron rather than in layers (CURA-1013) 2016-07-27 10:56:26 +02:00
Tim Kuipers b5575093d0 replace square function by math::square (CURA-1013) 2016-07-27 10:52:51 +02:00
Tim Kuipers 368747b213 feat: math file (CURA-1013)
for simple mathematical constructs
2016-07-27 10:52:05 +02:00
Tim Kuipers 64d3ee9728 rename: support_skin_.. options back to support_roof_... (CURA-1013)
We shouldn't change the interface so easily. This makes the json as it was a couple of ocmmits ago
2016-07-27 10:17:29 +02:00
Tim Kuipers 0ba0188bcd rename: support roof ==> support skin (CURA-1013)
the areas now include both roofs and skins
2016-07-26 18:44:40 +02:00
Tim Kuipers b8691c776e fix: (un)signed int syntax mistake (CUTA-1013) 2016-07-26 18:31:41 +02:00
Tim Kuipers afde126052 refactor: roofs ==> interface (CURA-1013)
the support interface contains areas which are roof and/or bottom
2016-07-26 18:31:14 +02:00
Tim Kuipers 5c22649d7b feat: support bottoms; bugfix: support roof height (CURA-647, CURA-1013) 2016-07-26 18:24:18 +02:00
Tim Kuipers 1e0f2ec7c1 lil refactor: switched two lines (CURA-1972) 2016-07-26 17:20:52 +02:00
Tim Kuipers c0d59627eb removed debug.h
I didn't really know how to write c++ at the time and it only gave difficult to solve problems up till now

(CURA-1792)
2016-07-26 15:58:25 +02:00
Tim Kuipers 836686b90c Merge branch 'slicer-speedup-clean' of https://github.com/scottlenser/CuraEngine 2016-07-26 12:48:21 +02:00
Tim Kuipers 4d7dd3adce fix: reflection graph improvements 2016-07-26 12:45:07 +02:00
Tim Kuipers 14013e657a removed dead code
code was probably used in the past to send layer data in a premature stage
2016-07-26 12:44:48 +02:00
Tim Kuipers 2a1cb236c8 reflection feat: visualize global-only mode 2016-07-26 11:47:07 +02:00
Tim Kuipers 0d17a056a2 lil reflection script fix 2016-07-26 11:22:34 +02:00
Tim Kuipers 722456ba64 lil fix: try-catch for debug code to find clipper bug 2016-07-26 10:29:35 +02:00
Scott Lenser ce1fe33b2e Slicer: Added better documentation on SlicerLayer::Terminus::Index. 2016-07-25 21:40:42 -04:00
Tim Kuipers df3c77d0ce code conventions for commandSocket (CURA-1272) 2016-07-25 17:43:03 +02:00
Tim Kuipers 39e1c5ffd9 fix: set command socket current location when starting printing a meshgroup (CURA-1272) 2016-07-25 17:34:06 +02:00
Tim Kuipers af31f141d8 Merge branch 'layerview_dev' of https://github.com/Johan3DV/CuraEngine into Johan3DV-layerview_dev 2016-07-25 15:53:33 +02:00
Tim Kuipers 5d7687228c test: isinside (CURA-1981) 2016-07-25 11:41:50 +02:00
Tim Kuipers ffb4cdaacd refactor: split off PolygonTest from PolygonUtilsTest (CURA-1981) 2016-07-25 11:35:29 +02:00
Scott Lenser ce10cdecc7 Moved some reference symbols in Slicer to match convention. 2016-07-22 17:53:03 -04:00
Scott Lenser d7806994be Slicer: renamed StitchGridValPointAccess to StitchGridValLocator. 2016-07-22 17:49:32 -04:00
Scott Lenser 6d5762bc59 Slicer: Fixed bug where polylines stitching wouldn't consider joining at start points. 2016-07-22 17:48:12 -04:00
Scott Lenser f96f189d0a Slicer: Improved case when joining polylines via start points. 2016-07-22 17:34:03 -04:00
Scott Lenser d9605a4a53 Slicer: Moved code out of if/else that was common to both cases. 2016-07-22 17:31:46 -04:00
Scott Lenser 0238d1822c Slicer: Comment and formatting improvements. 2016-07-22 17:30:42 -04:00
Scott Lenser d1f38c2be0 Slicer: Documented newer private functions in SlicerLayer. 2016-07-22 16:45:47 -04:00
Scott Lenser 0df427bc7a Slicer: Moved terminus tracking logic into a class. 2016-07-22 15:42:41 -04:00
Scott Lenser 6328aa7210 Slicer: Moved more of connectOpenPolylinesImpl into private functions. 2016-07-22 14:53:54 -04:00
Scott Lenser 2d761096b8 Spacing changes in slicer. 2016-07-22 14:37:12 -04:00
Scott Lenser 1a8b4c6655 Slicer: split off part of connectPolylinesImpl into new function.
Split off the finding possible stitches part into a new private function.
2016-07-22 14:33:55 -04:00
Scott Lenser cdb451b679 Slicer: Moved Terminus and PossibleStitch classes into SlicerLayer.
This moves them from the SlicerLayer::connectPolylinesImpl() function
to the SlicerLayer class.  This results in the declaration movign to
the header file.
2016-07-22 14:24:33 -04:00
Scott Lenser 7aa157c955 Slicer: Made terminus into a class.
This hides the implementation of a polyline index and a flag as an
unsigned int.  This also makes some of the uses more clear because
of the accessor function names.
2016-07-22 14:18:15 -04:00
Scott Lenser 52f71823f4 Removed trailing whitespace in slicer. 2016-07-22 13:31:46 -04:00
Scott Lenser 7522ca3ddc SparseGrid: changed name of PointAccess to Locator. 2016-07-22 13:27:26 -04:00
Scott Lenser b502a74a28 Slicer: switched storage for segments ending in vertex.
This switches the storage for segments ending in a vertex to a vertex *
instead of copying the connected faces of the vertex into a copy
of the vector.
2016-07-22 13:19:43 -04:00
Scott Lenser 3f131e40b9 Added spaces (especially around binary operators) in SparseGrid. 2016-07-22 13:10:09 -04:00
Scott Lenser 9b1a8fab73 Expanded doxygen function comment for SlicerLayer::connectOpenPolylinesImpl. 2016-07-22 12:44:04 -04:00
Scott Lenser 7e5538b65e Improved variable name in slicer. 2016-07-22 12:35:08 -04:00
Scott Lenser 1f60e35bd2 Slicer: Fixed usage of INVALID_TERMINUS value not going through constant. 2016-07-22 12:30:48 -04:00
Scott Lenser 70b3da26b9 Simplified SparseGrid usage in pathOrderOptimizer.
Now using the getNearbyVals() API call which is what the function
really wanted.
2016-07-22 12:26:42 -04:00
Scott Lenser ecdfbd89ed Merge remote-tracking branch 'origin/master' into slicer-speedup-clean 2016-07-22 12:22:15 -04:00
Ghostkeeper 134e52b15f Rename setting skirt_minimal_length to skirt_brim_minimal_length
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 17:03:21 +02:00
Ghostkeeper 5722a3e086 Rename setting skirt_line_width to skirt_brim_line_width
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:55:27 +02:00
Ghostkeeper e6adbd2f1d Rename jerk_skirt to jerk_skirt_brim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:52:24 +02:00
Ghostkeeper 533d00cc3a Rename setting acceleration_skirt to acceleration_skirt_brim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:47:47 +02:00
Ghostkeeper 586e0031d5 Rename skirt_speed to skirt_brim_speed
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:46:44 +02:00
Ghostkeeper 3ab6beb239 Update documentation
Contributes to issue CURA-1678.
2016-07-22 16:35:17 +02:00
Ghostkeeper 1da383d0d0 Make count unsigned
It can't be negative anyway.

Contributes to issue CURA-1678.
2016-07-22 16:33:52 +02:00
Ghostkeeper 479742cea3 Rename skirt_primary_extruder to skirt_brim_primary_extruder in generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:32:42 +02:00
Ghostkeeper e2c206e8ee Rename skirtNr to skirt_brim_number in generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:30:40 +02:00
Ghostkeeper f58c506c6a Rename skirt_sent to skirt_brim_sent in processPlatformAdhesion
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:27:58 +02:00
Ghostkeeper da2a329db4 Rename skirts to skirts_or_brims in generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:26:25 +02:00
Ghostkeeper ecb7ba8904 Rename skirt_polygons to skirt_brim_polygons in generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:21:33 +02:00
Ghostkeeper a84bb21d10 Rename skirt_polygons to skirt_brim_polygons in generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:20:43 +02:00
Ghostkeeper d41c2c6ac2 Rename primary_extruder_skirt_line_width to primary_extruder_skirt_brim_line_width
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 16:18:57 +02:00
Ghostkeeper 73f9b09951 Change feature type comment in g-code SKIRT to SKIRTBRIM
Because it is used not only for skirt but also for brim. This essentially means an API break, though Cura doesn't rely on this. Printers should not rely on this as per the g-code spec. The only things that rely on this are the postprocessing scripts, but it should be a trivial change for them.

Contributes to issue CURA-1678.
2016-07-22 16:16:51 +02:00
Ghostkeeper ac0b15eb93 Rename PrintFeature::Skirt to SkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:48:32 +02:00
Ghostkeeper 27ab0658df Rename skirt.cpp/h to SkirtBrim.cpp/h
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:44:36 +02:00
Ghostkeeper 759eb0ab90 Rename generateSkirt to generateSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:40:35 +02:00
Ghostkeeper 2099302a3b Update skirt/brim documentation
Contributes to issue CURA-1678.
2016-07-22 15:35:50 +02:00
Ghostkeeper 8365cb070d Rename skirt_is_processed to skirt_brim_is_processed
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:32:02 +02:00
Ghostkeeper 4121b3da1e Rename processSkirt to proceesSkirtBrim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:28:36 +02:00
Ghostkeeper 931df895c6 Rename skirt to skirt_brim in processSkirt
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:25:14 +02:00
Ghostkeeper 5b20d02c11 Rename SliceDataStorage::skirt to skirt_brim
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:18:47 +02:00
Ghostkeeper a702fa711d Rename initializeSkirtConfigs to initializeSkirtBrimConfigs
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:06:30 +02:00
Ghostkeeper eeb741bfb6 Rename SliceDataStorage::skirt_config to skirt_brim_config
Because it concerns not only the skirt, but also the brim.

Contributes to issue CURA-1678.
2016-07-22 15:01:21 +02:00
Ghostkeeper 5942bb3d4c Only generate support roof below mesh
Support roof takes quite a lot of time to print, so only generate it below the actual mesh, not where the support area is X/Y expanded or where multiple pieces of support are joined and such.

Contributes to issue CURA-647.
2016-07-22 14:40:20 +02:00
Ghostkeeper dd3007a61e Load support roof height and layer height from mesh
Don't have to pass it through via parameters.

Contributes to issue CURA-647.
2016-07-22 14:23:37 +02:00
Ghostkeeper 0e0119a3e6 Make parameters const and unsigned
Negative is not possible anyway. And these are not changed.

Contributes to issue CURA-647.
2016-07-22 13:49:43 +02:00
Ghostkeeper ef38ed3688 Rename variables according to code style
We use lowercase with underscores.

Contributes to issue CURA-647.
2016-07-22 13:47:17 +02:00
Ghostkeeper 142464ebeb Round support Z-distance up instead of down
The z-distance is rounded to the next layer. This guarantees that there is at least the specified Z-distance.

Contributes to issue CURA-1283.
2016-07-22 13:31:26 +02:00
Ghostkeeper 1d54240c32 Make retraction config take extruder of current plan
Rather than taking the extruder of the current g-code, which is for an entire layer, take the retraction settings of the current extruder plan. This allows for different retraction settings on the same layer rather than just taking the retraction settings that layer begins with.

Contributes to issue CURA-1972.
2016-07-22 11:52:07 +02:00
Johan K 25384faeed Merge branch 'master' of https://github.com/Ultimaker/CuraEngine into layerview_dev 2016-07-22 10:36:34 +02:00
Johan K 610685e13b Removing layer_nr argument from CommandSocket::send* functions. 2016-07-22 03:08:59 +02:00
Johan K ae59b2b8d8 Clean up the interface functions for sending data to the layer view in GUI.
Functions are now static and internally check in the command socket is instansiated to make the using code cleaner.
The sendLine function has been renamed to sendLineTo and only take the destination point to match how data is used and written to gcode.
CURA-1272
2016-07-22 02:29:42 +02:00
Ghostkeeper fe184f9177 Always make tests select from arrays
In some cases it was selecting characters from a string and passed those as a string. That's wrong!

Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Ghostkeeper bce51f4807 Add setting types polygon and polygons
It just evaluates the default. It doesn't try to edit these.

Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Ghostkeeper e371c43395 Don't evaluate default_value as fallback
Just take the value itself without evaluating it. Otherwise enum values accidentally get evaluated as a variable.

Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Ghostkeeper b3f80cec83 Repair evaluation functions
The names of these properties have changed a bit. Also, we're now getting the normal value first and defaulting back to default_value if there is no inheritance functions.

Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Ghostkeeper e34f2ffc67 Remove commented code
Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Ghostkeeper 0f0bd3c32c Remove redundant parentheses
As per the code style.

Contributes to issue CURA-1758.
2016-07-21 18:27:49 +02:00
Tim Kuipers 71beb1cc98 fix: no support for infill meshes (CURA-833) 2016-07-21 15:45:07 +02:00
Tim Kuipers bc56e73e36 Merge branch 'feature_remove_extruder_width' 2016-07-21 15:32:40 +02:00
Ghostkeeper ea364c4cd8 Obtain combined infill line width per layer
If the line width is different per combined layer this would get the correct one, and it is also more robust if there are 0 layers in the vector.

Contributes to issue CURA-736.
2016-07-21 13:54:01 +02:00
Ghostkeeper d581957308 Rename primary_skirt_line_width to primary_extruder_skirt_line_width
This was deemed better by the reviewer.

Contributes to issue CURA-736.
2016-07-21 13:36:25 +02:00
Ghostkeeper 11c611c9e4 Restore support for negative conical support angles
Negative conical support angles are also allowed. Only when the support angle is exactly zero, it is nonsensical to generate conical support.

Contributes to issue CURA-736.
2016-07-21 13:32:23 +02:00
Tim Kuipers 5ab937ba03 indent fix only (CURA-833)
only indentation and a lot of bs diff
2016-07-21 11:27:06 +02:00
Tim Kuipers aa5c9d37fd fix: command line slicing was broken (CURA-833) 2016-07-21 11:26:19 +02:00
Tim Kuipers 9de3edee39 debug fix: better debug output of clipper bug 2016-07-21 11:10:43 +02:00
Ghostkeeper 21fa313feb Move support line width into detect overhang points
It's the only place where it's used. This makes the stack trace slimmer, potentially making the program faster. Also, it moves the dependency on the setting closer to where the setting is used.

Contributes to issue CURA-736.
2016-07-21 09:31:00 +02:00
Ghostkeeper 6fb61a3c79 Make a few settings const
While we're at it...

Contributes to issue CURA-736.
2016-07-21 09:24:57 +02:00
Ghostkeeper bc2efcfc39 Rename extrusionWidth to line_width
This line width is the width of the lines in the wireframe mode.

Contributes to issue CURA-736.
2016-07-21 09:19:59 +02:00
Ghostkeeper cb40a72eda Rename extrusionWidth to line_width
This is the width of all wireframe lines.

Contributes to issue CURA-736.
2016-07-20 17:14:26 +02:00
Ghostkeeper 096e8f7675 Remove old code
This prime tower is long unused. The queue import also seems to be unused, since compiling gives no error and a CTRL+F has no results either.

Contributes to issue CURA-736.
2016-07-20 17:10:17 +02:00
Ghostkeeper 87e02722e7 Rename primary_extrusion_width to primary_skirt_line_width
Sometimes it is the brim line width. But this convention is held elsewhere throughout the code too.

Contributes to issue CURA-736.
2016-07-20 17:07:24 +02:00
Ghostkeeper d15387905b Rename innermost_wall_extrusion_width to innermost_wall_line_width
Neighbouring variables are also renamed, such as extrusionWidth that was actually the wall line width.

Contributes to issue CURA-736.
2016-07-20 16:58:50 +02:00
Ghostkeeper 5280c9df10 Correct skin-wall to skin overlap
The skin-wall now has the line width of the inner walls.

Contributes to issue CURA-736.
2016-07-20 16:28:13 +02:00
Ghostkeeper 021c7ac0bf Use inner wall config to extrude skin border lines
This makes the line width with which we're extruding equal to the line width with which we did the insets for these lines.

Contributes to issue CURA-736.
2016-07-20 16:25:00 +02:00
Ghostkeeper 3825e200a6 Make skin insets use inner wall line width
We deemed that the inner wall line width is more akin to the line width you're seeking for the border line of skins, which attaches slin lines that end on the border with infill. More akin than skin line width anyway.

Contributes to issue CURA-736.
2016-07-20 15:39:22 +02:00
Ghostkeeper 6022e44dee Rename extrusion_width to support_line_width
Also made it const.

Contributes to issue CURA-736.
2016-07-20 15:11:51 +02:00
Ghostkeeper b0054e1b39 Move getting skin line width into skin generator
This makes the stack lighter, because the context switch to the functions doesn't need to copy the value over to the stack. Also removes the reference to old terminology: extrusion_width, and makes the variable const.

Contributes to issue CURA-736.
2016-07-20 15:09:51 +02:00
Ghostkeeper 7a1ee0429e Move getting infill line width into infill functions
This makes the stack lighter, because the context switch to the functions doesn't need to copy the value over to the stack. The local variable can be an order of magnitude faster even though it needs to look-up the value from the mesh one additional time. Also removes the reference to old terminology: extrusion_width, and makes the variable const.

Contributes to issue CURA-736.
2016-07-20 15:03:05 +02:00
Johan K fddaa58d67 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine into layerview_dev 2016-07-20 14:49:24 +02:00
Ghostkeeper 0ff87b785f Split speed_layer_0 into two settings
There are now distinct settings for speed_print_layer_0 (the extrusion moves) and speed_travel_layer_0 (the non-extrusion moves).

Contributes to issue CURA-1507.
2016-07-20 10:54:55 +02:00
Ghostkeeper 71df0e2586 Initial layer travel speed uses initial layer config
It uses the same gradient as the rest of the speeds. This is per extruder though.

Contributes to issue CURA-1507.
2016-07-19 14:49:00 +02:00
Ghostkeeper 53c8cc5e78 Document initialLayersSetup()
Better structured, really.

Contributes to issue CURA-1507.
2016-07-19 14:41:00 +02:00
Tim Kuipers aa87a720c0 refactor: code conventions (CURA-1856) 2016-07-19 13:42:25 +02:00
Tim Kuipers 6e171f795c Merge branch 'scottlenser-add-convex-hull' 2016-07-19 13:32:22 +02:00
Tim Kuipers e76cda3ea8 Merge branch 'add-convex-hull' of https://github.com/scottlenser/CuraEngine into scottlenser-add-convex-hull 2016-07-19 13:23:58 +02:00
Ghostkeeper 8794688c48 Merge branch 'feature_tetrahedral_infill' 2016-07-19 09:28:25 +02:00
Tim Kuipers 957c82715d fix: use print_layer_count everywhere after infill meshes have been generated/confined (CURA-833) 2016-07-18 18:06:37 +02:00
Tim Kuipers c0813b2c77 fix: send layer info after processing infill meshes (CURA-833) 2016-07-18 18:04:28 +02:00
Tim Kuipers 3042483f73 update mesh.layer_nr_max_filled_layer during processing infill meshes (CURA-833) 2016-07-18 18:00:52 +02:00
Tim Kuipers 3abc718240 fix: reserve enough layers in the vector (speedup) (CURA-833) 2016-07-18 18:00:09 +02:00
Tim Kuipers a52208b15e refactor: rename layer_count ==> slice_layer_count because infill meshes may be sliced at layers which aren't printed (CURA-833) 2016-07-18 17:58:53 +02:00
Ghostkeeper edd44de9e3 Spelling fixes
Contributes to issue CURA-1925.
2016-07-18 17:17:59 +02:00
Tim Kuipers d4b1c70790 fix: limit infill meshes to the own infill area of other meshes rather than their basic infill area (CURA-833)
second order infill mehses could overlap with first order infill meshes before
2016-07-18 15:54:40 +02:00
Tim Kuipers 534e265fd2 refactor: factored out a new function getOwnInfillArea whic returns the infill_area_own or the infill_area (CURA-833) 2016-07-18 15:53:27 +02:00
Tim Kuipers 120de96bb5 fix: optional assignment used wrong constructor (CURA-833) 2016-07-18 14:47:13 +02:00
Tim Kuipers a611739ff7 Merge branch 'master' into feature_gradual_infill 2016-07-18 12:20:16 +02:00
Tim Kuipers 791e436222 fix: only first infill mesh part got removed from infill of normal mesh (for gradual infill branch) (CURA-833) 2016-07-18 12:17:10 +02:00
Tim Kuipers d16f52e776 fix: only first infill mehs part got removed from infill of normal mesh (CURA-833) 2016-07-18 12:14:45 +02:00
Tim Kuipers a99020e995 Merge branch 'master' into feature_gradual_infill 2016-07-18 11:57:50 +02:00
Tim Kuipers 5237b1bb01 fix: made raft top layers into zigzag (CURA-1637)
previous commit was actually for the middle layers instead of the top layers
2016-07-15 15:34:25 +02:00
Tim Kuipers 7e0d44cfcb fix: combing thought it was never inside when printing the raft (CURA-1637) 2016-07-15 15:31:11 +02:00
Tim Kuipers 453b3ebbc5 fix: made raft top layers into zigzag (CURA-1637) 2016-07-15 15:10:07 +02:00
Tim Kuipers 473b925814 feat/fix: changed mat GUID to string and retrieve it from settings (CURA-1836) 2016-07-15 14:27:57 +02:00
Tim Kuipers 4199fcf8ac feat/fix: changed mat GUID to string and retrieve it from settings (CURA-1836) 2016-07-15 14:27:24 +02:00
Tim Kuipers 203f04571c fix: delete instance when de-assigning an optional value (CURA-836) 2016-07-15 13:45:45 +02:00
Tim Kuipers 186472c26e feat: tetrahedral infill (CURA-1925) 2016-07-15 12:35:48 +02:00
Tim Kuipers dc2b505274 fix: combination of gradual infill and infill mehses didn't work (CURA-836)
The part.infill_area should remain the whole initial infill area for combing
During the generation of the part.infill_area_per_combine_per_density it refered to part.infill_area, rather than the infill-mesh-limited infill
I had to introduce an intermediate result - part.infill_area_own - which records the area where that mesh should print its infill pattern
In case there are no infill meshes the part.infill_area_own remains a nullptr, so that we don't waste resources.
After it's used and incorporated into infill_area_per_combine_per_density, its destroyed.
2016-07-14 17:57:16 +02:00
Tim Kuipers 9adc0a128c fix: optional::operator=(nullptr) didn't work (CURA-836) 2016-07-14 17:51:12 +02:00
Tim Kuipers e6a5eccf03 Merge branch 'master' into feature_gradual_infill 2016-07-14 16:29:28 +02:00
Johan K 71ea91b61b Implement adding extruder number to path compiler 2016-07-14 12:13:14 +02:00
Tim Kuipers 00d6a55836 lil: less whitespace at end of lines 2016-07-14 12:12:25 +02:00
Tim Kuipers 4308c74451 fix: multiVolumesOverlap failed when two meshes are directly adjacent in the X direction (CURA-833)
when there was no X which covered both models
2016-07-14 12:05:17 +02:00
Tim Kuipers 757df8c7c8 fix: let combing not see infill meshes (CURA-833) 2016-07-14 11:39:38 +02:00
Tim Kuipers ff5cc9399d refactor: lil rename (CURA-833) 2016-07-14 11:35:46 +02:00
Johan K ddf7bbe06e Changed the data type of the layer visualization data from int64 to float.
Also added extruder number and point dimensionality to the message.
2016-07-14 11:00:39 +02:00
Tim Kuipers e34608442a doc: processInfillMesh (CURA-833) 2016-07-14 10:50:37 +02:00
Tim Kuipers c0446f81e0 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-13 17:30:13 +02:00
Ghostkeeper 27ac98caa5 Code style: Whitespace around binary operators
Contributes to issue CURA-833.
2016-07-13 15:47:37 +02:00
Ghostkeeper ebcfad8200 Codestyle: Whitespace around binary operators
Contributes to issue CURA-833.
2016-07-13 15:45:52 +02:00
Ghostkeeper 69665a0d4a Codestyle: Space after comma and no whitespace at end of line
Contributes to issue CURA-833.
2016-07-13 15:13:21 +02:00
Johan K a50d6fe5a9 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine into layerview_dev 2016-07-13 14:52:11 +02:00
Ghostkeeper bed556a5e6 Codestyle: Brackets after if-statements
Instead of making new brackets after every if-statement, I opted for making it into or-clauses.

Contributes to issue CURA-833.
2016-07-13 14:48:53 +02:00
Tim Kuipers a86c5b1105 doc: documented ExtruderPlan 2016-07-13 14:34:05 +02:00
Tim Kuipers 3db1c2580f Merge branch 'feature_gradual_infill' of github.com:Ultimaker/CuraEngine into feature_gradual_infill 2016-07-13 14:19:22 +02:00
Tim Kuipers 2925af497c lil doc 2016-07-13 14:17:07 +02:00
Johan K 0bd5ae9e01 Added documentaion
More documentation for PathCompiler and SliceDataStruct.
2016-07-13 14:03:46 +02:00
Tim Kuipers eff7f0e326 fix: always retract after priming (CURA-1816) 2016-07-13 11:09:12 +02:00
Scott Lenser a6ad786443 Cleaned up size handling in convexHull. 2016-07-12 10:08:35 -04:00
Scott Lenser ce85280971 Merge remote-tracking branch 'origin/master' into slicer-speedup-clean 2016-07-12 09:13:41 -04:00
Tim Kuipers a7bc153db5 Merge branch 'feature_overhang_dropdown' 2016-07-12 11:25:20 +02:00
Tim Kuipers 3d98bb7e74 Merge branch 'feature_firmware_travel_settings' 2016-07-12 11:06:56 +02:00
Tim Kuipers cc632cd201 Merge branch 'master' of github.com:Ultimaker/CuraEngine into feature_fan_control_per_extruder 2016-07-12 11:02:31 +02:00
Tim Kuipers b0ee1ca57d Merge branch 'scottlenser-slenser-cleanup-pr-A' 2016-07-12 10:35:10 +02:00
Tim Kuipers e7992fc17a fix: USE_CPU_TIME iff in debug mode (CURA-1856) 2016-07-12 10:28:02 +02:00
Tim Kuipers 3f2162d76c doc: better documentation and function naming (CURA-1856) 2016-07-12 10:23:48 +02:00
Johan K 019116cd33 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine into layerview_dev 2016-07-12 01:03:19 +02:00
Johan K b0f725c1e5 Added extruder nr to PathSegment definition in Cura.proto 2016-07-12 01:02:24 +02:00
Tim Kuipers 17c125d395 fixed header guard of WallsComputation 2016-07-11 22:29:17 +02:00
Tim Kuipers d0d0532cb8 Merge branch 'slenser-cleanup-pr-A' of https://github.com/scottlenser/CuraEngine into scottlenser-slenser-cleanup-pr-A 2016-07-11 18:35:31 +02:00
Tim Kuipers 563be4980d doc: visual explanation of gradual infill shift and line dist (CURA-836) 2016-07-11 18:10:29 +02:00
Tim Kuipers 4a91663bb4 fix: gradual infill steps are skipped through regularly now (CURA-836)
whenb computing gradual infill, we skip layersto compute which regions count as top. These skips are now such that
you end exactly one gradual infill step above.
2016-07-11 17:44:30 +02:00
Tim Kuipers f486d6be6f bugfix: sqrt doesn't return a constexpr (CURA-833) 2016-07-11 16:34:21 +02:00
Tim Kuipers 945711f10a bugfix: sqrt doesn't return a constexpr (CURA-833) 2016-07-11 16:27:36 +02:00
Tim Kuipers 0ae670ce0c Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-11 16:16:07 +02:00
Tim Kuipers 2db4730f00 lil: removed done TODO CURA-833 2016-07-11 16:04:25 +02:00
Jaime van Kessel 09b36ecdd8 Merge branch 'feature_cubic_isometric_infill' of github.com:Ultimaker/CuraEngine 2016-07-11 14:41:08 +02:00
Tim Kuipers 5e83d4252d fix: handle inactive temp of second nozzle on first layer (CURA-1508) 2016-07-11 13:37:08 +02:00
Tim Kuipers a69270e212 fix/refactor: factored writePrimeTrain out of startExtruder so that we can enforce printing temperature before priming (CURA-1508) 2016-07-11 13:14:48 +02:00
Ghostkeeper d197c7f3d7 Fix spelling in documentation
Contributes to issue CURA-836 and a few others probably.
2016-07-11 10:26:35 +02:00
Tim Kuipers c82a8c5a47 fix: warning msg bug: was string instead of Cstring (CURA-1568) 2016-07-11 10:22:42 +02:00
Scott Lenser 288f053abd Updated mentions of BucketGrid in comments to SparseGrid.
Some of the comments had mentions of BucketGrid were the code had
already been updated to change BucketGrid2D uses to SparseGrid.
I didn't notice them before because of the different spelling.
2016-07-09 12:48:13 -04:00
Scott Lenser f73586190e Fixed warning message about unused variable. 2016-07-08 19:53:03 -04:00
Scott Lenser 0fd0dd6869 Removed BucketGrid2D which has been replaced by SparseGrid. 2016-07-08 19:24:14 -04:00
Scott Lenser dee0ae12d6 Converted polygonUtils to SparseGrid from BucketGrid2D.
This also converts Comb which relies on polygonUtils (Comb just stores
the type from polygonUtils).
2016-07-08 19:21:44 -04:00
Scott Lenser c2571d41af Converted pathOrderOptimizer to SparseGrid from BucketGrid2D. 2016-07-08 18:39:45 -04:00
Scott Lenser c8fd58376b Converted BucketGrid2D test to SparseGrid test. 2016-07-08 17:53:44 -04:00
Scott Lenser bce0a8a3a8 Added parameters to SparseGrid constructor to allow more control of map.
This adds functionality that was present in BucketGrid2D's constructors.
2016-07-08 16:59:26 -04:00
Scott Lenser 25c2f7086d Moved SparseGrid::processNearby into public interface. 2016-07-08 16:44:49 -04:00
Scott Lenser 941f4e3a66 Added getNearest() function to SparseGrid.
Refactored so that getNearest and getNearby can share a lot of the
implementation.
2016-07-08 16:42:15 -04:00
Scott Lenser 6d8d453df9 Added missing doxygen comment for SparseGrid. 2016-07-08 15:35:33 -04:00
Scott Lenser 90c212b52e Split SparseGrid into an invasive and non-invasive version.
The invansive version requires that the stored type being able to
provide a Point location on demand.  This is a general version in
case the type being stored already has a location in it.  The
non-invasive version is more convenient if the type to be stored
does not already contain a Point location.
2016-07-08 15:32:32 -04:00
Scott Lenser db79eb7ece Added convexHull function for Polygons.
This renames the previous version which is an approximate convex hull
to approxConvexHull.
2016-07-08 13:29:50 -04:00
Scott Lenser 9afcbddf29 Added rounding to coordinates from slicing of mesh. 2016-07-08 13:26:21 -04:00
Scott Lenser c4c221145e More const correctness. 2016-07-08 13:24:56 -04:00
Scott Lenser 1956fc00d3 Added error message if inherited JSON file can't be found. 2016-07-08 13:16:56 -04:00
Scott Lenser 8ac6c3b597 Changed signature of Mesh::getFaceIdxWithPoints to avoid redundant calculation. 2016-07-08 13:16:00 -04:00
Scott Lenser 76b3c8757d Fixed bug which sent multiple finished slice messages.
The slicing finished message is already sent in CommandSocket::connect().
This confused the GUI since it is only expecting 1 finished slice message.
2016-07-08 13:11:52 -04:00
Scott Lenser c6b6688170 Added code to use cpu time instead of wall clock time for timings.
This is controlled by a #define on which timings to use.
2016-07-08 13:10:18 -04:00
Scott Lenser d2c80127ef Fixed bug in print out about number of layers. 2016-07-08 13:09:19 -04:00
Scott Lenser 3ada6f266c Switched command_line_settings to version 2 from version 1. 2016-07-08 13:03:08 -04:00
Scott Lenser 4b5553019e Fixed bug in bridge generation.
It was calculating the angle to use for infill but then not using it.
This makes it use the calculated angle.  This makes the bridge
generation go from basically completely non-functional to just mostly
non-functional.
2016-07-08 12:59:41 -04:00
Scott Lenser 4fd499f7a1 Correctness improvements to SlicerLayer::makeBasicPolygonLoop.
From the slicing, we know which edge generated the end point of the
segment.  We then know that the face that shares this edge is the only
candidate to have generated the next segment.  This avoids checking
the other 2 segments.

Improved logic used in SlicerLayer::getNextSegmentIdx().  The previous
version only considered candidate faces for extending the current
polygon loop by looking at faces that shared an edge.  This works for
many models, but if the slice height exactly intersects vertices of
the mesh, then the segment that would extend the loop is not typically
found.  We know whether we hit a vertex with the slice from the
slicing calculation.  There is a slight cost to checking for equality
to see if we hit a vertex.  This can very slightly slow down normal
models but substantially increase speed on bad case models.  This
extends the logic to use the faces connected to the vertex that the
segment ended on to try to extend the polygon loop.  Theoretically,
this adds a slight performance penalty to makeBasicPolygonLoops when
vertices were hit by the slice.  However, in very limited testing,
this extra time is not measurable.  Adding this improved correctness
makes a big difference in the number of polygon loops successfully
constructed.  In a bad case model, the number of polygons found
increased from 0 to 19 and the number of open polylines for the next
stage of processing went from 6357 to 0.  This made the
connectOpenPolylines() go from taking .048 seconds to 0.  The overall
effect on this model was to reduce the slicing time from 0.084 to 0.04
seconds (this is a small model for testing so total times are low).
2016-07-08 12:50:03 -04:00
Scott Lenser 28aedf57c5 Sped up SlicerLayer::connectOpenPolylines and SlicerLayer::stitch.
Added use of spatial data structure in SlicerLayer::stitch().  Added
SparseGrid spatial data structure.  This is similar to BucketGrid2D
but a bit more general and without the possibility of duplication in
returned points.  SparseGrid does not offer a findNearestObject
function like BucketGrid2D does, although one could be added if
desired.

Sped up SlicerLayer::stit() further by only finding nearby points
once.  The possible stitch points are calculated once and remembered.
They are put into a priority queue.  A bidirectional map (via vectors)
is used to keep track of the transforms that happen to the polygons to
map from the original polyline ends to the new polyline ends.

Combined stitch and connectOpenPolylines implementations.
connectOpenPolylines basically does the same thing as stitch except
has a smaller search radius and doesn't allow for inverting edges.  I
expressed these as parameters to the stitch implementation and then
reused the implementation.  It is now much faster.
connectOpenPolylines has gone from O(n^2) to O(n) and stitch has gone
from O(n^3) to O(n).  connectOpenPolylines has also gotten more
correct.  With the original version,if polys 0 -> 10 -> 5 formed a
chain, then 0 -> 10 would be merged into 0 but the 10 -> 5 would never
be used.  0 -> 10 would be merged into 0, but this new 0 would not be
considered for merging with 5 since 10 > 5.  It also wouldn't be
considered for merging 10 with 5 because 10 has already been cleared
out.
2016-07-08 12:34:47 -04:00
Scott Lenser 28e6a54961 Added timer for time to load mesh. 2016-07-08 12:06:06 -04:00
Scott Lenser b1b49f16e0 Added timers in slicer.
This gives the breakdown between intersecting planes with the model
and the conversion of the resulting segments into polygons.
2016-07-08 12:02:17 -04:00
Scott Lenser 6b72d52c65 Added new spatial data structure SparseGrid.
This class is intended to be used for speeding up fixed radius
nearby neighbor searches.
2016-07-08 11:48:41 -04:00
Scott Lenser 07d416691a Add move version of adding Polygon to Polygons. 2016-07-08 11:43:15 -04:00
Scott Lenser 960c56a9fa Added a convenience typedef for the type of a coordinate in a Point. 2016-07-08 11:33:44 -04:00
Scott Lenser a18b05f347 Fix to make bridging work much better. 2016-07-08 14:22:45 +02:00
Tim Kuipers 4d46fbea8f fix: conical overhang wouldn't do anything for an angle of zero (CURA-1412)
It should then drop any overhang down: \ becomes L
2016-07-08 00:00:48 +02:00
Tim Kuipers 5620abfd95 fix: make infill mesh AABB collision detection take into account horizontal expansion (CURA-833) 2016-07-07 22:17:41 +02:00
Tim Kuipers 3d307112de fix: infill meshes couldn't handle zero infill meshes (CURA-833)
zero infill meshes didn't generate any infill areas, while infill mehses assumed there to be infill areas_per_combine
2016-07-07 22:07:39 +02:00
Tim Kuipers 2c5639097e fix: got a warning about an uninitializes unused variable 2016-07-07 20:47:44 +02:00
Tim Kuipers cbf5d962b7 fix: catch temp flow graph reading input errors (CURA-1792) 2016-07-07 20:42:18 +02:00
Tim Kuipers 744264481a ignore callgrind files 2016-07-07 20:09:52 +02:00
Tim Kuipers 2cd22bdfd5 Merge branch 'master' into feature_fan_control_per_extruder 2016-07-07 17:33:35 +02:00
Tim Kuipers c259d90def fix: extruder switched to old extruder instead of new one (CURA-1816 and CURA-1508) 2016-07-07 17:33:21 +02:00
Tim Kuipers a7b3d53872 Merge branch 'master' into feature_fan_control_per_extruder 2016-07-07 16:50:21 +02:00
Tim Kuipers 57219beb98 fix: nozzle switch was never written (CURA-1508 CURA-1816) 2016-07-07 16:49:31 +02:00
Tim Kuipers 8f0c3c9a49 Merge branch 'feature_fan_control_per_extruder' of github.com:Ultimaker/CuraEngine into feature_fan_control_per_extruder 2016-07-07 16:47:57 +02:00
Tim Kuipers 6adfdd7ad4 Merge branch 'master' into feature_fan_control_per_extruder 2016-07-07 16:42:44 +02:00
Tim Kuipers 59b516702e Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-07 15:19:08 +02:00
Tim Kuipers 78c155b1ab fix: only perform prime gcode for griffin (CURA-1816 CURA-1508) 2016-07-07 15:18:25 +02:00
Tim Kuipers f39a3e62e7 fix: only prime the initial extruder at the start of a print (CURA-1508) 2016-07-07 15:14:24 +02:00
Tim Kuipers 00bcbe7192 fix: get prime location from settings and use travel speed to get there when switching to a yet unused extruder (CURA-1816 and CURA-1508) 2016-07-07 15:13:37 +02:00
Tim Kuipers ab850577b5 fix: initial planned extruder was always set to zero (CURA-1816) 2016-07-07 15:10:45 +02:00
Tim Kuipers 307551b1db fix: skirt assumed extruder 0 for primary adhesion extruder rather than adhesion_extruder_nr (CURA-1816) 2016-07-07 13:33:25 +02:00
Tim Kuipers 9a09cdc18a feat/refactor: factored out startExtruder from GCodeExport::switchExtruder (CURA-1816) 2016-07-07 13:25:28 +02:00
Tim Kuipers dfcc993034 refactor: replaced old SliceDataStorage::getExtrudersUsed(.) with GcodeExport::getExtruderIsUsed (CURA-1816) 2016-07-07 13:24:10 +02:00
Ghostkeeper 65df6439fa Codestyle: Spaces around operators
Contributes to issue CURA-1792.
2016-07-07 11:43:22 +02:00
Jaime van Kessel 43a51f5757 Changed extruder_nr to int (instead of uint)
CURA-1687
2016-07-06 15:31:38 +02:00
Tim Kuipers 96a2ac56c5 fix: don't give warnings for known parent settings (secretly on CURA-1792)
the frontend sends all known settings (and categories) via the command socket even though it should know which settings will be used by the engine.
This is because the json file is the interface ofthe engine and so the frontend sends everything in the interface.
2016-07-06 15:15:26 +02:00
Ghostkeeper 63cd06ca02 Fix typo
Contributes to issue CURA-1568.
2016-07-06 14:59:00 +02:00
Tim Kuipers 39da22630f bugfix: PolygonUtils::findClose(... BucketGrid2D) return pointer to heap resulting in mem leaks (CURA-1792)
now solved with optional
2016-07-06 14:47:19 +02:00
Ghostkeeper 3528b9eca7 Remove TODO
We don't need to do this. Discussed with Tim and Paul.

Contributes to issue CURA-1568.
2016-07-06 14:42:33 +02:00
Tim Kuipers 8d7827aa87 fix: parsing of temp flow graph was buggy ==> rewrite (CURA-1792) 2016-07-06 14:35:38 +02:00
Tim Kuipers c73084bbd1 fix: instantiate command socket after loading the json file (CURA-1792)| 2016-07-06 14:31:24 +02:00
Tim Kuipers bf372cb3aa fix: merge conflic resolution for fan speeds per extruder (CURA-1568)
The ExtruderPlan needed access to the retraction_config for that extruder
2016-07-05 17:44:04 +02:00
Tim Kuipers 0b8c30616a Merge branch 'master' into feature_overhang_dropdown 2016-07-05 15:22:22 +02:00
Tim Kuipers a7720bcfbf Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-04 17:20:14 +02:00
Tim Kuipers bf19300def fix: raft outline now uses rounded offset (CURA-1835) 2016-07-04 17:19:59 +02:00
Jaime van Kessel 9a34e09806 Only send material estimates for extruders a machine has.
CURA-1687
2016-07-04 16:51:43 +02:00
Jaime van Kessel 62a90f86c6 Merge branch 'master' of github.com:Ultimaker/CuraEngine into SendMaterialEstimatesOfBothExtrudersToFrontend 2016-07-04 16:17:47 +02:00
Tim Kuipers f3b6042243 fix: fixing output stream precision when outputting to standard out 2016-07-04 13:54:48 +02:00
Tim Kuipers 795d68d142 fix runtest.py: new setting attributes after settings rework (CURA-1828) 2016-07-04 12:26:10 +02:00
Tim Kuipers c8e9091764 Merge branch 'feature_retraction_settings_per_extruder' 2016-07-04 12:02:26 +02:00
Tim Kuipers 4b43c96cbc Merge branch 'feature_zhop_over_other_material' 2016-07-04 11:59:55 +02:00
Tim Kuipers 4ba0ae104e Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-04 11:55:55 +02:00
Tim Kuipers f99c8b86cc fix runtest.py: new setting attributes after settings rework (CURA-1828) 2016-07-04 11:55:32 +02:00
Tim Kuipers 5c7862287f fix runtest.py: setting category structure after settings rework (CURA-1828) 2016-07-04 11:55:02 +02:00
Tim Kuipers a2c8311c68 fix/feat: gradual infill: pass settings through from frontend and choose better hardcoded values (CURA-836) 2016-07-01 22:27:25 +02:00
Tim Kuipers 018f952a67 fix: linear based infill scaline algorithm was broken (CURA-836) 2016-07-01 21:39:01 +02:00
Tim Kuipers b05928fb52 bugfix: infill shifting could result in sigaborts (CURA-836, CURA-1723) 2016-07-01 21:38:53 +02:00
Tim Kuipers 8b5f2f8ff8 fix/feat: gradual infill now also working for infil thickness aka infill combine (CURA-836) 2016-07-01 21:36:40 +02:00
Tim Kuipers 50d92ff91e fix: linear based infill scaline algorithm was broken (CURA-836) 2016-07-01 17:41:01 +02:00
Jaime van Kessel e3c0439575 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-07-01 17:22:48 +02:00
Jaime van Kessel a0f624992d Merge branch 'feature_time_estimates_per_layer' of github.com:Ultimaker/CuraEngine 2016-07-01 17:09:42 +02:00
Tim Kuipers a41a0285f0 lil: removed unused var (CURA-836) 2016-07-01 16:51:55 +02:00
Tim Kuipers dbeab1ec05 fix: gradual infill logic was the wrong way around (CURA-836) 2016-07-01 16:51:25 +02:00
Tim Kuipers b81b956965 bugfix: infill shifting could result in sigaborts (CURA-836, CURA-1723) 2016-07-01 14:54:06 +02:00
Tim Kuipers db2462882c feat: Infill no accepts extra parameter for etra_infill_shift (CURA-836) 2016-07-01 14:09:34 +02:00
Tim Kuipers cc0f0918d3 feat/fix: generate infill lines for gradual infill (CURA-836) 2016-07-01 13:59:43 +02:00
Tim Kuipers 3d93407b61 feat/fix: SkinInfillAreaComputation::generateGradualInfill (CURA-836) 2016-07-01 13:37:02 +02:00
Tim Kuipers ead062757a refactor: part.infill_area_per_combine ==> part.infill_area_per_combine_per_density (CURA-836)
from vector of polygons to vector of vectors of polygons
2016-07-01 11:47:17 +02:00
Tim Kuipers 35b1a42cf3 fix: moved cubic shift computation into a static double (CURA-1723) 2016-07-01 01:37:04 +02:00
Tim Kuipers 420508099a feat: cubic isometric infill computation (CURA-1723) 2016-07-01 00:36:43 +02:00
Tim Kuipers 7d1586ec4c refactor: pass down z height into Infill computation (CURA-1723) 2016-07-01 00:33:09 +02:00
Tim Kuipers cc40088b3e feat: shift linear based infill types (CURA-1723) 2016-06-30 23:47:11 +02:00
Tim Kuipers e28f64d36d fix: removed unused safe_outline_offset (remove overlapping wall parts) (CURA-1723) 2016-06-30 23:10:51 +02:00
Tim Kuipers 0357102399 feat: dont heat up unused extruder (CURA-1508) 2016-06-30 18:01:10 +02:00
Tim Kuipers bdd1a5c4ed bugfix: bs init of extruder_attr.is_used (CURA-1508) 2016-06-30 17:38:44 +02:00
Tim Kuipers d9b47a8c96 refactor: lil rename n ==> extruder_nr (CURA-1508) 2016-06-30 17:27:45 +02:00
Tim Kuipers 507aa1c9d9 fix: initialize gcodeExport::extr_attr::is_used (CURA-1508) 2016-06-30 17:26:44 +02:00
Tim Kuipers c2a0dd952c feat: gcodeExport::extr_attr::is_used (CURA-1508) 2016-06-30 17:26:24 +02:00
Tim Kuipers edc4e3e57b refactor: introduce cpp file for ExtruderTrain (CURA-1508) 2016-06-30 17:07:52 +02:00
Tim Kuipers cbf7960e08 lil codestyle fix 2016-06-30 10:55:36 +02:00
Javier Lechuga 74e52455fa SendMaterialEstimatesOfBothExtrudersToFrontend. Including sendPrintTimeMaterialEstimates in protobuf scheme. CURA-1687 2016-06-30 09:49:46 +02:00
Javier Lechuga fc7a60b34a SendMaterialEstimatesOfBothExtrudersToFrontend. First commit not ready yet. CURA-1687 2016-06-30 09:49:45 +02:00
Tim Kuipers 6fa82e044b fix: skin areas were always wrong (CURA-1773) 2016-06-29 17:59:05 +02:00
Tim Kuipers 8dbfb70c67 fix: retrieve machine_min_cool_heat_time_window per extruder (CURA-1783) 2016-06-29 14:58:37 +02:00
Tim Kuipers 513d1347ca feat: retrieve minimal cooling+heating time window from settings (CURA-1783) 2016-06-29 14:44:43 +02:00
Tim Kuipers 97d895b0a3 feat: don't allow unused extruder to cool down when time window is too small (CURA-1783) 2016-06-29 14:34:41 +02:00
Ghostkeeper ac1087dda3 Merge branch 'materials_test'
Conflicts:
	src/gcodePlanner.cpp
2016-06-29 14:26:15 +02:00
Tim Kuipers f23a91f0aa refactor: rename time_to_start_warmup_earlier_to_be_extra_sure_we_dont_have_to_wait ==> extra_preheat_time (CURA-1731) 2016-06-29 12:50:28 +02:00
Tim Kuipers dd7fb1941f fix: time within path where preheat commands were inserted was inverted (CURA-1731) 2016-06-29 10:22:32 +02:00
Tim Kuipers 54f7a45f65 small codestyle fixes (CURA-1506) 2016-06-28 18:48:22 +02:00
Tim Kuipers 7d7ca8ae4a refactor: inversed logic of and calls to LayerPlanBuffer::insertPreheatCommand (CURA-1731) 2016-06-28 18:41:50 +02:00
Tim Kuipers 9ab0839b4a indent only (CURA-1731) 2016-06-28 18:33:24 +02:00
Tim Kuipers 844bfd34ab refactor+bugfix: simplified LayerPlanBuffer by passing around a vector of extruder plans rather than layers AND fixed a bug in handleStandbyTemp (CURA-1731)
handleStandbyTemp set the standby temp of the wrong extruder plan...
2016-06-28 18:32:59 +02:00
Tim Kuipers 7a87848562 refactor: layer plan buffer: bubble up special case for very first extruder plan of a meshgroup (CURA-1731) 2016-06-28 18:28:28 +02:00
Tim Kuipers 69a62a74ca fix: removed superfluous if case (CURA-1731) 2016-06-28 17:59:30 +02:00
Tim Kuipers 162f39e3fb fix: the standby temperatures were reset for all previous extruder plans with the same extruder in the buffer (CURA-1731) 2016-06-28 17:45:29 +02:00
Tim Kuipers 7fa436de51 fix: adjust lowest temperature when there's no time to heat to the required temperature (CURA-1731) 2016-06-28 17:44:55 +02:00
Tim Kuipers 1ef7ae46b2 lil: includes fixed for optional (CURA-1731) 2016-06-28 16:40:55 +02:00
Tim Kuipers 8b9695b913 doc: optional documentation (CURA-1731) 2016-06-28 16:39:34 +02:00
Tim Kuipers 5879a3cdaa fix: set extruder temps at ExtruderPlan start fixed instead of via TempInsert (CURA-1731) 2016-06-28 16:33:54 +02:00
Tim Kuipers 2236b3afeb feat: crude implementation of c++17::std::optional (CURA-1731) 2016-06-28 16:14:35 +02:00
Tim Kuipers ed283a978b feat: let Preheat compute from_temperature along with heating_time and bubble the result up (CURA-1731) 2016-06-28 14:03:48 +02:00
Tim Kuipers 9f44d8362a fix: start cooldown in new extruder plan instead of old to combat snowballing effect (CURA-1731)
snowballing: when we start cooling T0 before we require the temp of T1 to be reached, due to small discrepancy between the computed and actual heatup times, the time it takes to actually reach the required temp of T1 - while computed to be zero - causes T0 to drop in temperature in that time. This in turn will mean it will also take longer to heat up again, creating the same problem in the next extruder switch from T1 to T0, thereby snowballing into layer switches taking longer and longer.
2016-06-28 13:59:29 +02:00
Ghostkeeper 7e12817974 Codestyle: Spaces after comma
Contributes to issue CURA-1506.
2016-06-28 13:05:34 +02:00
Tim Kuipers 93bf338ff2 fix: start heating one second earlier (CURA-1731) 2016-06-28 12:14:42 +02:00
Jaime van Kessel 48c6b2a058 Merge branch 'feature_zhop_over_other_material' of github.com:Ultimaker/CuraEngine 2016-06-28 11:35:22 +02:00
Tim Kuipers e132db6142 codestyle: brackets (CURA-1506) 2016-06-27 18:09:51 +02:00
Tim Kuipers a0536af848 fixup: more consts in PolygonUtils::moveInside2 (CURA-1506) 2016-06-27 18:05:31 +02:00
Tim Kuipers 8e8c7fcfc9 doc: more documentation in combing (CURA-1506) 2016-06-27 18:01:45 +02:00
Tim Kuipers 6d672cc840 refactor: over_unavoidable_obstacles_makes_combing_fail ==> fail_on_unavoidable_obstacles (CURA-1506) 2016-06-27 17:49:01 +02:00
Tim Kuipers 9bf8dbbc96 fix: pass down penalty_function through PolygonUtils::ensureInside and moveInside2 (CURA-1506) 2016-06-27 17:42:25 +02:00
Tim Kuipers c1d4ba89d2 lil: removed unused code in unit test (CURA-1506) 2016-06-27 17:19:39 +02:00
Tim Kuipers 58269b363c Merge branch 'feature_zhop_over_other_material' of https://github.com/Ultimaker/CuraEngine into feature_zhop_over_other_material 2016-06-27 17:13:36 +02:00
Ghostkeeper a2f6e62795 Codestyle: Brackets around indented blocks
Contributes to issue CURA-1506.
2016-06-27 16:42:48 +02:00
Tim Kuipers 1e1a7e4f95 refactor/fix: removed retraction_config from GCodePathConfig and removed all last_retraction_config logic to revert to just using the retraction config of the extruder (CURA-303) 2016-06-27 15:02:05 +02:00
Ghostkeeper b035b47526 Spelling fix in documentation
Contributes to issue CURA-1506.
2016-06-27 14:47:14 +02:00
Ghostkeeper 53eda52041 Remove trailing whitespace
Contributes to issue CURA-1506.
2016-06-27 14:37:40 +02:00
Tim Kuipers 52331d0c83 fix: skin areas were missing when alternate extra perimeter was enabled (CURA-1773) 2016-06-27 10:43:55 +02:00
Tim Kuipers 5cc85d3bf6 fix: no more configurable switch_extruder_retraction_hop (CURA-1506 CURA-1061)
making the height configurable is quite difficult with how retraction currently works and there is not a lot of added value
2016-06-24 15:25:00 +02:00
Tim Kuipers 7cf21e9926 fix unit test: GCodePlannerTest::computeNaiveTimeEstimatesRetractionTest() (CURA-1061) 2016-06-24 15:04:10 +02:00
Tim Kuipers 26d506a0f4 refactor/fix: move extruder switch retraction config to sliceDataStorage so that extruder switch z hop can be applied (CURA-1061) 2016-06-24 15:03:43 +02:00
Tim Kuipers 607c21ee46 fix: extruder switch zhop not performed on layer start anymore (CURA-1061)
only when the layer starts with a different extruder as the previous ended with
2016-06-24 14:18:55 +02:00
Tim Kuipers 402ede10d4 fix: perform zhops on very first travel of extruder plan. (CURA-1061)
still buggy: Now it does a zhop also on the start of a layer
2016-06-24 14:04:36 +02:00
Tim Kuipers bdd86ab9aa fix: made max_crossing_dist2 smaller cause other material was being crossed (CURA-1506) 2016-06-23 23:48:01 +02:00
Tim Kuipers ab3b1c2320 removed assert which doesn't seem to be true given the updated description of PolygonUtils::ensureInsideOrOutside(.) (CURA-1506) 2016-06-23 23:27:53 +02:00
Tim Kuipers 85e2ecc87e doc: warning for polygonUtils::ensureInsideOrOutside(.) that it may give false positives (CURA-1506) 2016-06-23 23:26:14 +02:00
Tim Kuipers 82846c0cc2 debug: PolygonUtils::ensureInsideOrOutside(.) does a polygon offset which sometimes seems to fail (CURA-1506)
sometimes it results in too small polygons which clipper itself and we cannot handle.
sometimes very small polygons are offsetted to polygons which lie outise the original polygon.
2016-06-23 23:25:20 +02:00
Tim Kuipers 09015e188a lil SVG const correctness 2016-06-23 23:06:23 +02:00
Tim Kuipers 36dbcfc667 check: assert to see whether ensureInsideOrOutside really moved inside (CURA-1506) 2016-06-23 22:56:34 +02:00
Tim Kuipers 5db83799d2 fix: PolygonUtils::ensureInsideOrOutside(.) checks is_inside to see if polygon offset failed (CURA-1506) 2016-06-23 22:55:54 +02:00
Tim Kuipers 9cb04d9e7a SVG fix for font size 2016-06-23 22:46:47 +02:00
Tim Kuipers 1c966cb6a5 deleted ancient test.cpp 2016-06-23 22:45:05 +02:00
Tim Kuipers f4d7695700 fix: replaced PolygonRef::inside(.) by Clipper function (CURA-1506) 2016-06-23 22:44:18 +02:00
Tim Kuipers 2288d2da49 fix: combing fails instead of crashes when combing fails due to too thin parts (CURA-1506) 2016-06-23 17:14:57 +02:00
Tim Kuipers 5d5a02739c fix: moveInside failed when distance was more than max_dist, but it was already inside anyway (CURA-1506) 2016-06-23 17:11:06 +02:00
Tim Kuipers 9248c17ace fix: combing findCrossingInOrMid can fail when part is too small (now doesn't crash anymore) (CURA-1506) 2016-06-23 16:46:35 +02:00
Tim Kuipers 7417e7d674 fix: Comb::moveInside forgot to set the inside_poly output parameter (CURA-1506) 2016-06-23 16:45:09 +02:00
Tim Kuipers 58228ff9a6 fix: PolygonUtils::findClose etc functions are now safe wrt ClosePolygonPoints which are not found (CURA-1506) 2016-06-23 16:18:44 +02:00
Tim Kuipers 329199af15 feat/fix: combing: findCrossingInOrMid now ensures to be inside (CURA-1506) 2016-06-23 16:17:39 +02:00
Tim Kuipers 2aa67efa20 refactor: changes ClosestPolygonPoint::point_idx and poly_idx to _unsigned_ int (CURA-1506)
NO_INDEX is an unsigned int and we don't need to waste all negative numbers which are invalid anyway
2016-06-23 15:47:37 +02:00
Tim Kuipers 7b79debf9a feat/fix: combing: moveInside now ensures to be inside, or changes startInside / endInside (CURA-1506) 2016-06-23 15:46:24 +02:00
Tim Kuipers 1314f00713 test: unit tests for PolygonUtils::ensureInside and for moveInside2 (CURA-1506) 2016-06-23 15:36:57 +02:00
Tim Kuipers a407ea6b61 fix: PolygonUtils::ensureInsideOrOutside passed output parameter by value (CURA-1506)| 2016-06-23 15:13:01 +02:00
Tim Kuipers 02e22b9442 small fixes in PolygonUtils (CURA-1506) 2016-06-23 14:47:17 +02:00
Tim Kuipers 5062a985fe feat: PolygonUtils::ensureInsideOrOutside more rigorous than a simple moveInside (CURA-1506) 2016-06-23 14:46:41 +02:00
Tim Kuipers 5294ea508c refactor: const correctness in PolygonUtils (CURA-1506) 2016-06-23 14:45:27 +02:00
Tim Kuipers 286a6edaa4 feat: PolygonUtils::moveInside2 a more simple version of moveInside and also for single polygons (CURA-1506) 2016-06-23 14:43:49 +02:00
Tim Kuipers 6af8a8eb85 feat: polygon::offset(.) (CURA-1506) 2016-06-23 14:36:21 +02:00
Tim Kuipers ee38f51af8 refactor: ClosestPolygonPoint::pos ==> point_idx (CURA-1506) 2016-06-23 12:09:22 +02:00
Tim Kuipers 7428a47344 unit test: polygon offset on holes works the same as offset on outer boundary (CURA-1506) 2016-06-23 12:07:17 +02:00
Tim Kuipers b859327bbd refactor/feat: ClosestPolygonPoint now also includes the poly index of the polygon which it refers to (CURA-1506) 2016-06-23 12:06:21 +02:00
Tim Kuipers 0a02a140fb fix: combing: better findInOrMid for tiny segments (CURA-1506) 2016-06-22 18:01:15 +02:00
Tim Kuipers 5d2d1fe6f3 lil fix: combing: made a small crossing more important than a large detour, cause otherwise sometimes combing fails because of it (CURA-1506) 2016-06-22 17:41:12 +02:00
Tim Kuipers ed2cdfa67a lil debug svg constness 2016-06-22 17:17:43 +02:00
Tim Kuipers 6d22cceac5 fix: Polygonutils::findClose only checked vertices of from-poly, now also checks points on line segments (CURA-1506) 2016-06-22 17:17:12 +02:00
Tim Kuipers 8a9f7dbf2b fix: use last_retraction_config for retractions (CURA-1506) 2016-06-22 17:16:32 +02:00
Ghostkeeper aa5bc6385b Merge branch 'materials_test' 2016-06-22 15:32:22 +02:00
Ghostkeeper 764d9868c7 Take max of double+double, not int+double
Not properly overloaded by max, I think.

Contributes to issue CURA-1717.
2016-06-22 15:32:07 +02:00
Ghostkeeper 5153022d28 Merge branch 'materials_test' 2016-06-22 15:28:42 +02:00
Ghostkeeper 7d87d2baea Improve time estimate when accelerating wrong way
When accelerating the wrong way, the discriminant of this parabolic is negative. Instead of returning a time estimate of 0, return the extremum of the parabola.

Contributes to issue CURA-1717.
2016-06-22 15:24:58 +02:00
Tim Kuipers 14518007a4 refactor: GCodePlanner::last_retraction_config ==> last_planned_retraction_config (CURA-1506 CURA-958) 2016-06-22 14:38:05 +02:00
Tim Kuipers 64f69d7629 fix: writeRetraction refered to last *planned* retraction config AND removed functionality to make a retraction into the extruder switch retraction (CURA-1506 CURA-958)
The only function using the last_retraction_config was the function which owuld convert a normal retraction into a nozzle switch retraction, instead of first performing the normal retraction and then the nozzle switch retraction. That functionality had to be removed anyway, because performing the nozzle switch retraction on the print can leave more scarring.
2016-06-22 14:34:42 +02:00
Tim Kuipers c93facc43c fix combing: moveInside always returned false even if we found a point inside (CURA-1506) 2016-06-21 18:09:49 +02:00
Tim Kuipers c2144cfe1c fix: PolygonUtils::moveInside tackled the corner case wrong when the point was exactly on the last point of a polygon (CURA-1506) 2016-06-21 17:32:55 +02:00
Tim Kuipers ca2b4af6f7 fix combing: move inside from previous move inside try so we can get out of the tip of a narrow angled piece (CURA-1506)
also I fixed that moveInside always made inside true, when it was false before.
2016-06-21 17:31:58 +02:00
Tim Kuipers 4d429eb719 fix: combing: better move inside strategy (CURA-1506) 2016-06-21 16:53:41 +02:00
Tim Kuipers e76109697e refactor: move combings moveInside into its own function (CURA-1506) 2016-06-21 16:01:17 +02:00
Tim Kuipers 213b67528a lil debug fix to SVG 2016-06-21 14:13:59 +02:00
Tim Kuipers 162d9aa0f7 fix: combing used offset_outside instead of distance between inside and outside at some places (CURA-1506) 2016-06-21 14:13:33 +02:00
Tim Kuipers 1c8f859885 fix: max_crossing_dist only accounted for the outside_boundary offset, not the inside_boundary_offset (CURA-1506) 2016-06-20 18:02:41 +02:00
Tim Kuipers db4c9b63f8 fix: combing: find better crossing when crossing diagonally between vertices (CURA-1506) 2016-06-20 18:02:02 +02:00
Javier Lechuga cc349cd046 bugfix_SegfaultDeletedCString 2016-06-20 17:34:57 +02:00
Tim Kuipers 6a925b73d6 lil doc 2016-06-20 17:25:23 +02:00
Tim Kuipers 2290a0927d refactor: moved Comb::findBestCrossing into Crossing (CURA-1506)
also used the same close_to for finding the crossing with the least detour, which is technically a change, but practically does the same thing.
2016-06-20 17:14:25 +02:00
Tim Kuipers 297a22280d refactor: combing crossings calculated factored out to new class Crossing (CURA-1506) 2016-06-20 17:11:25 +02:00
Javier Lechuga cd98c620af Merge branch 'bugfix_wallcount0' 2016-06-20 16:22:49 +02:00
Tim Kuipers e9647413f8 lil fix: polygon::PartsView::asseblePart is now const (CURA-1506) 2016-06-20 15:41:51 +02:00
Javier Lechuga 998ed5a76c bugfix: wall line count 0. CURA-1467 2016-06-20 14:39:23 +02:00
Tim Kuipers 2d62e67a24 refactor: moved combing classes into separate files (CURA-1506) 2016-06-20 13:18:46 +02:00
Tim Kuipers 69d2ab837f refactor: moved Comb into dir pathPlanning (CURa-1506) 2016-06-20 12:23:48 +02:00
Ghostkeeper ab8f84aa2d Merge branch 'materials_test' 2016-06-17 17:57:04 +02:00
Ghostkeeper 72c0a8391b Fix time estimates with accelerations
This was giving NaN values in the time estimates for the edge case where the discriminant of this quadratic was actually 0.0, but due to floating point rounding errors ended up below 0.

Contributes to issue CURA-1717.
2016-06-17 17:56:30 +02:00
Tim Kuipers 4b9a79df4d fix: combing: scanline crossings edge case for line segments ending exactly on the scanline (CURA-1506) 2016-06-17 17:51:01 +02:00
Tim Kuipers f7decf86a2 fix: combing can now fail if moving too far over in_between (CURA-1506) 2016-06-17 15:25:39 +02:00
Tim Kuipers 61b735ce89 fix: combing used pointer to local variable (CURA-1506) 2016-06-17 15:21:44 +02:00
Tim Kuipers c4b78fdfd1 fix: perform z hop always when not combing (CURA-1506)
whether to perform a z hop only when the comb move would collide only influences when the combing calculation decides to fail
2016-06-17 14:38:39 +02:00
Tim Kuipers 96769cb90c fix: combing: early calculation stopping for z-hops (CURA-1506) 2016-06-17 14:32:42 +02:00
Tim Kuipers 0ee60d2d3a fix: return whether the combing crosses an inavoidable boundary, aka being locked in/out (CURA-1506) 2016-06-17 14:01:05 +02:00
Tim Kuipers 9cbbdad56f lil: made clear where endInside and startInside are finally computed (CURA-1506) 2016-06-17 13:58:18 +02:00
Tim Kuipers 4a18f5d03d fix: combing: optimized and fixed going via hole polygon when endpoint is inside of the part containing the start point (CURA-1506) 2016-06-17 13:56:57 +02:00
Tim Kuipers 9b76a2e820 fix: combing/avoid always went to outside of part even when the endpoint was inside of a hole in the start part (CURA-1506) 2016-06-17 12:36:19 +02:00
Tim Kuipers 5a1897d631 feat: SVG::writePolygons and better border handling 2016-06-17 12:31:54 +02:00
Tim Kuipers 9d83fe08d8 doc: more documentation on combing and scanline crossings (CURA-1506) 2016-06-17 12:30:44 +02:00
Tim Kuipers 428198b4f9 feat: combing: find crossing from in to out closer to end point (CURA-1506) 2016-06-16 16:44:53 +02:00
Tim Kuipers e92bf03293 feat: combing: prefer crossings closer to start/end point a bit more (CURA-1506) 2016-06-16 16:33:13 +02:00
Tim Kuipers 9fe77a5761 test: PolygonUtils::findClose with penalty_function (CURA-1506) 2016-06-16 16:19:21 +02:00
Tim Kuipers fa07addba2 feat: PolygonUtils::findClose now support a penalty_function (CURA-1506) 2016-06-16 16:19:00 +02:00
Tim Kuipers ba4e4cc38f fix: PolygonUtils::findClose would return nothing when first arbitrary point was best (CURA-1506) 2016-06-16 16:17:45 +02:00
Tim Kuipers e2a47e1619 fix: pass by value bug and doc (CURA-1506) 2016-06-16 15:53:24 +02:00
Tim Kuipers e107626026 unit test: Polygonutils::findClosest with penalty function (CURA-1506) 2016-06-16 15:36:35 +02:00
Tim Kuipers 527b1f9b13 feat: added optional penalty function to PolygonUtils::findClosest (CURA-1506) 2016-06-16 15:27:10 +02:00
Tim Kuipers 6abc896bab feat: perform z-hop only when combing fails (CURA-1506) 2016-06-16 15:00:20 +02:00
Tim Kuipers f2de0fd5df refactor/feat: introduced getLastPlannedExtruderTrainSettings and replaced code with that function and with getExtruder() (CURA-1506) 2016-06-16 14:59:45 +02:00
Johan K c202d1b47a Changed the message used to send the final slice result to the front-end to LayerOptimized
Corrected the name of the data from polygon to path segment and left the old message for future visualization of the earlier stages.
2016-06-16 00:10:43 +02:00
Tim Kuipers d4349818b7 fix: reset acceleration and jerk back to default firmware values afterwards (CURA-1443) 2016-06-16 00:02:17 +02:00
Tim Kuipers ce80ceb165 lil doc typo 2016-06-15 23:21:27 +02:00
Tim Kuipers d19310ee27 refactor: removed superfluous/old writeTypeComment(string ..) (CURA-1350) 2016-06-15 23:20:30 +02:00
Tim Kuipers 63e6a249e3 feat: write time estimates in comments every layer (CURA-1350) 2016-06-15 23:17:50 +02:00
Johan K 0b05457fac Adding polygon packing feature and change the structure of the layer data sent to the front-end to speed up the layer view 2016-06-14 18:20:01 +02:00
Tim Kuipers 63356dca41 feat: set firmware values from configuration (CURA-1646) 2016-06-14 17:05:14 +02:00
awhiemstra 4bce36550f Merge pull request #353 from Johan3DV/master_polyutil_ref
Adding some references
2016-06-14 10:35:40 +02:00
Johan K 3ca1e6673f Adding some missing references 2016-06-13 22:07:31 +02:00
Ghostkeeper b2a4ee1647 Merge pull request #350 from thopiekar/master-windows-work
Ignore generated Makefile and archives of code
2016-06-13 00:35:31 +02:00
Thomas Karl Pietrowski 81ef194164 Merge remote-tracking branch 'refs/remotes/Ultimaker/master' into master-windows-work 2016-06-11 12:40:24 +02:00
Thomas Karl Pietrowski 2c698c8ba0 Ignore generated Makefile and archives of code 2016-06-11 12:40:20 +02:00
Jaime van Kessel 54e63de3a8 Merge branch 'feature_accelerations_and_jerk_per_feature_settigns_rework' of github.com:Ultimaker/CuraEngine 2016-06-10 15:36:52 +02:00
Tim Kuipers 0186d35372 fix: retrieved extruder_count instead of machine_extruder_count (CURA-1560) 2016-06-10 15:21:14 +02:00
Tim Kuipers c018a44c38 fix: retrieved extruder_count instead of machine_extruder_count (CURA-1560) 2016-06-10 13:13:13 +02:00
Tim Kuipers 0c62d1ab65 Merge branch 'master' into feature_accelerations_and_jerk_per_feature_settigns_rework 2016-06-10 12:19:41 +02:00
Tim Kuipers ff1fca976e bugfix: global settigns were never loaded (CURA-1682) 2016-06-09 19:03:52 +02:00
Tim Kuipers a7ad42eb1f fix: bugfix in comandSocket Extruder.settings (CURA-1682) 2016-06-09 13:10:30 +02:00
Tim Kuipers fb526ffc6d lil doc (CURA-1682) 2016-06-09 12:13:08 +02:00
Tim Kuipers d806c23d59 feat: handle extruder train settings (CURA-1682) 2016-06-09 12:07:24 +02:00
Tim Kuipers 28b8b41475 Added extruder to proto message
CURA-1681
CURA-1682
2016-06-09 12:00:35 +02:00
Tim Kuipers 457e609091 refactor/bugfix: inline handleSettingList (CURA-1682)
Two commits above introduced a bug where I passed thw wrong objects to handleSettingList
2016-06-09 11:40:50 +02:00
Tim Kuipers ffcd076f3e doc: commented proto file (CURA-1682 CURA-1681) 2016-06-09 11:39:11 +02:00
Tim Kuipers 01951ac513 feat: global settings are now passed via the same message as the objects (CURA-1682) 2016-06-09 11:08:36 +02:00
Tim Kuipers a8debfde40 refactor: comandSocket::handleSettingList now takes a settings base (CURA-1682) 2016-06-09 11:06:51 +02:00
Tim Kuipers 3194e30772 Updated proto file
Objects & global settings are now sent in one message.
    Also added support for extruder settings

    CURA-1681
CURA-1682
2016-06-09 10:50:46 +02:00
Tim Kuipers 223313c5ef Merge pull request #349 from thopiekar/master-windows-work
Adding generated CMake files to .gitignore
2016-06-08 15:18:17 +02:00
Thomas Karl Pietrowski 5a8f580edd Adding generated CMake files to ignore
These files are generated by CMake on Windows 10 64bit with Visual
Studio installed. They are not tracked by the project, so they can be
savely removed by git clean.
2016-06-08 13:50:59 +02:00
Tim Kuipers 394fbda0ff lil codestyle 2016-06-08 12:12:42 +02:00
Tim Kuipers e778cc6bf0 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-06-08 10:38:09 +02:00
Tim Kuipers af6b581167 lil doc 2016-06-08 10:36:34 +02:00
Tim Kuipers 2f026d006c fix: mergeInfillLines had a boolean mistake due to 497c969 (CURA-1560) 2016-06-08 10:33:15 +02:00
Tim Kuipers 86daf598e5 fix: minimal avoid distance is zero (CURA-1560) 2016-06-08 10:30:42 +02:00
Tim Kuipers e77ddee5de fix: put back the *2 I accidentally removed in ee087f23 (CURA-1560) 2016-06-08 09:58:09 +02:00
Tim Kuipers 162fac057d fix: support_type was retrieved per mesh instead of globally (CURA-1560) 2016-06-08 09:55:25 +02:00
Thomas Karl Pietrowski 5c3c038c43 Merge remote-tracking branch 'refs/remotes/Ultimaker/master' 2016-06-08 09:41:58 +02:00
Tim Kuipers 78432b49fe Update README.md 2016-06-07 16:06:18 +02:00
Tim Kuipers 4395f9a465 fix: only force minimal layer time on the last extruder plan (CURA-1568) 2016-06-06 17:37:37 +02:00
fieldOfView 0288f08cc3 Fixes for codestyle and find/replace accident
CURA-967
2016-06-05 15:28:45 +02:00
Tim Kuipers beb14b3e15 fix: machine_extruder_end_pos_abs was retrieved globally (CURA-1568) 2016-06-03 17:30:38 +02:00
Tim Kuipers c436a108ec fix: dynamic char array size instead of static (CURA-1574)
A static char array length is open to buffer overflow problems/attacks
2016-06-03 17:04:51 +02:00
Tim Kuipers 5f9bfb6ac5 fix: cool_lift_head is now retrieved per meshgroup (CURA-1568) 2016-06-03 17:00:16 +02:00
Tim Kuipers 43a69544fb fix: handleAllRemainingInserts at the very end of an extruder plan (CURA-1568) 2016-06-03 16:37:40 +02:00
Tim Kuipers a53141089c indent fix (CURA-1568) 2016-06-03 16:36:55 +02:00
Tim Kuipers 57a58afc7a fix: don't lift head if we are at the switching bay (CUTA-1568) 2016-06-03 16:36:31 +02:00
Tim Kuipers 2e9f712eae indent: fixed indentation (CURA-1568) 2016-06-03 16:13:29 +02:00
Tim Kuipers 075b3e6581 refactor/feat: move fanSpeedLayerTime computation inside the ExtruderPlan class (CURA-1568) 2016-06-03 16:12:26 +02:00
Tim Kuipers 8c4c2bae67 refactor: fan_speed_layer_time_settings_per_extruder.emplace_back (BUGGY STATE) (CURA-1568) 2016-06-03 16:10:55 +02:00
Tim Kuipers 8318f290fa fix: better GCodePlannerTest (CURA-1560) 2016-06-03 13:13:28 +02:00
Tim Kuipers 191f699309 fix: testcase GCodePlannerTest restored (CURA-1560) 2016-06-03 13:09:32 +02:00
Tim Kuipers 2dac16b44f refactor: remove unnecessary argument parent_file from SettingRegistry::getDefinitionFile (CURA-1574) 2016-06-03 12:47:32 +02:00
Tim Kuipers 9db735e2e5 fix: record search paths for extruder train defs (CURA-1574) 2016-06-03 12:44:18 +02:00
Tim Kuipers ee087f23de fix: wall_line_width/count not retrieved per extruder anymore (CURA-1560) 2016-06-03 00:02:50 +02:00
Tim Kuipers 5878916b03 fix: retrieve travel_avoid_distance per extruder and use the highest value (CURA-1560) 2016-06-02 23:24:24 +02:00
Tim Kuipers 7e7dbf34be refactor: rename some vars from storage ==> mesh (CURA-1560) 2016-06-02 23:02:14 +02:00
Tim Kuipers c3d535d88f fix: adhesion_type was retrieved per mesh (CURA-1560) 2016-06-02 22:59:49 +02:00
Tim Kuipers 2b987a9a73 DEBUG: commented a whole testcase (CURA-1560) 2016-06-02 22:53:18 +02:00
Tim Kuipers 315f01daef refactor: removed global retrieval of travel config (CURA-1560) 2016-06-02 22:50:26 +02:00
Tim Kuipers fdc756a22b refactor: moved sliceDataStorage initialization to header file (CURA-1560) 2016-06-02 22:28:46 +02:00
Tim Kuipers 497c969048 refactor: removed global travel config (CURA-1560) 2016-06-02 22:23:07 +02:00
Tim Kuipers e22d4d30e7 refactor: removed global retraction config (CURA-1560) 2016-06-02 21:40:22 +02:00
Tim Kuipers 432761690b fix: removed (globally retrieved) travel speed dependancy from finalize (CURA-1560) 2016-06-02 18:25:23 +02:00
Tim Kuipers 39422e6dbc fix: platform adhesion options now all retrieved from extruder train (CURA-1560) 2016-06-02 18:22:23 +02:00
Tim Kuipers 0f9c14e42a fix: temps set multiple times and temps retrieved per mesh (CURA-1560) 2016-06-02 17:29:22 +02:00
Tim Kuipers d9374270cf fix: magic_spiralize was retrieved globally (CURA-1560) 2016-06-02 17:10:28 +02:00
Tim Kuipers 9f8cdf69f0 fix: layer_height was retrieved per mesh (CURA-1560) 2016-06-02 17:04:15 +02:00
Tim Kuipers 492e4f7b29 fix: machine_name was never actually loaded in the settings (CURA-1574) 2016-06-01 17:19:59 +02:00
Tim Kuipers b50bc938df lil refactor 2016-06-01 15:58:40 +02:00
Tim Kuipers aa36ad175e fix: overlaps were compensated twice when layer would start within an overlap zone (CURA-1635) 2016-06-01 15:56:58 +02:00
Tim Kuipers 0d50fe50b4 fix: heuristic solution to circumvent iterator invalidation (CURA-1635)
complex models with almost everywhere pieces smaller than twice the nozzle width could break the heuristic, when there are a lot of 3-way intersections of thin walls
2016-06-01 15:54:52 +02:00
Tim Kuipers 8bf31f771c refactor: moved WallOverlapComputation constructor to cpp file (CURA-1635) 2016-06-01 13:47:25 +02:00
Tim Kuipers 634fddd908 lil doc 2016-06-01 13:32:24 +02:00
Tim Kuipers 7f64494dec lil refactor (CURA-1635) 2016-06-01 13:27:10 +02:00
Tim Kuipers dffb1ef459 doc: lil doc for walloverlap comp (CURA-1635) 2016-06-01 13:22:43 +02:00
Tim Kuipers 9b74c6c0a2 better debugging for wallOverlapComp 2016-06-01 13:21:44 +02:00
Tim Kuipers b23ede94f3 lil debug fix for WallOverlapComputation 2016-06-01 11:53:27 +02:00
Tim Kuipers 1837d658dd fix: infill_area_per_combine wasn't always filled (CURA-1255) 2016-05-31 15:27:30 +02:00
Tim Kuipers 7086762216 refactor: early out for polygon settings (which are unsupported) (CURA-1574) 2016-05-31 12:43:04 +02:00
Tim Kuipers bc78163d70 fix: settings default values got deleted when overriden by json object which didn't define a default_value (CURA-1574) 2016-05-31 12:41:56 +02:00
Tim Kuipers 81c2091ddb lil fix in help (CURA-1574) 2016-05-30 17:05:07 +02:00
Tim Kuipers 6e3d71e39b fix: load machine_extruder_trains ids from machine definition after the recursion, so that the parent json file doesn't overload the current (CURA-1574) 2016-05-30 17:02:27 +02:00
Tim Kuipers 35112600bc fix: dont warn for duplicated for non-base files and for extruder trains (CURA-1574)
extruder train base definition file gets loaded for each extruder, and we don't want to get duplicate errors every time we load the second extruder
2016-05-30 17:00:29 +02:00
Tim Kuipers 0e58fb960f feat: load extruder train defaults (and definitions) on creation of new extruder train (CURA-1574) 2016-05-30 16:44:42 +02:00
Tim Kuipers a36c90d076 clenaup: removed unused function in settingsRegistry (CURA-1574) 2016-05-30 16:36:10 +02:00
Tim Kuipers b72625b28f feat: settingsRewgistry::loadExtruderJSONsettings (CURA-1574) 2016-05-30 16:35:44 +02:00
Tim Kuipers 8ead13d2be cleanup: removed old extruder_trains unused default saving mechanism (CURA-1574) 2016-05-30 16:27:31 +02:00
Tim Kuipers d30d2af4f0 feat: remember extruder train ids from json (CURA-1574) 2016-05-30 16:20:46 +02:00
Tim Kuipers 6808e25cd8 Merge branch 'feature_accelerations_and_jerk_per_feature_settigns_rework' of https://github.com/Ultimaker/CuraEngine into feature_accelerations_and_jerk_per_feature_settigns_rework 2016-05-30 15:18:22 +02:00
Tim Kuipers cdc2d17455 fix: spiralzie got reintroduced by merge with code which moved GCodePathConfig (CURA-1443) 2016-05-30 15:17:18 +02:00
Tim Kuipers 31dbc4ef24 Merge branch 'feature_accelerations_and_jerk_per_feature' into feature_accelerations_and_jerk_per_feature_settigns_rework 2016-05-30 15:16:11 +02:00
Tim Kuipers 01c78d555c Merge branch 'feature_accelerations_and_jerk_per_feature' into feature_accelerations_and_jerk_per_feature_settigns_rework 2016-05-30 15:12:31 +02:00
Tim Kuipers 2f46c0e473 fix: make path delimiter depend on OS (CURA-1574) 2016-05-30 11:27:54 +02:00
Tim Kuipers 34f60e6616 lil codestyle 2016-05-30 11:08:41 +02:00
Tim Kuipers 303246b39c fix: generateMultipleVolumesOverlap was broken (CURA-833) 2016-05-27 13:45:10 +02:00
Tim Kuipers 3b80ac93ea lil prime tower fix 2016-05-27 13:30:16 +02:00
Tim Kuipers 6b7b5a7ea9 refactor: load setting defaults into settings at the moment they get loaded (CURA-1574) 2016-05-27 13:27:48 +02:00
Tim Kuipers 231eee1e46 lil prime tower fix 2016-05-27 13:26:25 +02:00
Tim Kuipers 81424528f3 refactor: no more overload_defaults_only (CURA-1574) 2016-05-27 13:00:17 +02:00
Tim Kuipers c78808b69d lil 2016-05-27 12:59:37 +02:00
Tim Kuipers 1c347be3be fix: don't overload defaults only when loading extruder json files (CURA-1574) 2016-05-27 12:53:38 +02:00
Tim Kuipers c79c503621 fix: setting loading always segfaulted (CURA-1574) 2016-05-26 21:01:49 +02:00
Tim Kuipers e6fb617f3f refactor: simplified SettingRegistry::handleSetting (CURA-1574) 2016-05-26 08:46:37 +02:00
Tim Kuipers ca1799efc6 remove unneeded function (CURA-1574) 2016-05-26 08:46:13 +02:00
Tim Kuipers 749e85b15b doc: setting registry stuff (CURA-1574) 2016-05-26 08:45:50 +02:00
Tim Kuipers 82c7bfaf7a fix: don't retrieve settings from registry (CURA-1574)
The settings are set during the loading of the json file, not during retrieval of settings
2016-05-25 17:08:54 +02:00
Tim Kuipers d5df34b3cf fix: don't set extruder train defaults anymore via some special casing for extruder trains (CURA-1574) 2016-05-25 17:07:35 +02:00
Tim Kuipers 59774e7f14 lil: less warnings when handling json (CURA-1574)
warnings were given twice and were given for overriding frontend settings
2016-05-25 17:05:36 +02:00
Tim Kuipers bf8e73a4ae feat: load json setting default directly into a given settings base (CURA-1574)
Instead of keeping the defaults in the global settings registry, load the defaults immediately into a settings base, so that we can override the extruder train defaults.
2016-05-25 16:58:41 +02:00
Tim Kuipers 8b778b82be fix: support_extruder_nr used instead of support_infill_extruder_nr 2016-05-25 15:28:25 +02:00
Tim Kuipers d42b0ac9eb fix: SettingsToGv for new setting json files (CURA 1574) 2016-05-25 15:27:11 +02:00
Tim Kuipers cda656d43d lil: made etDefinitionFile static (CURA-1574) 2016-05-25 15:02:55 +02:00
Tim Kuipers 8c18b2ca89 fix doc: help and README show new way of handling settings and the CURA_ENGINE_SEARCH_PATH env var (CURA-1574) 2016-05-25 15:01:56 +02:00
Tim Kuipers eeb69776de feat: load json settings recursively and check in paths provided in CURA_ENGINE_SEARCH_PATH (CURA-1574) 2016-05-25 14:46:08 +02:00
Tim Kuipers cee01abe16 refactor: pass down warn_duplicates via setting calls (CURA-1574)
Extruder train definition .def.json files shouldn't warn for duplicates; only the base file should.
2016-05-25 12:30:49 +02:00
Tim Kuipers 8df1562d7b cleanup imports (CURA-1574) 2016-05-25 12:23:18 +02:00
Tim Kuipers 3bbc4a1d72 refactor: split settingRegistry into separate class and header files (CURA-1574) 2016-05-25 12:19:23 +02:00
Tim Kuipers 5a9eaa29ea refactor: move settings related files into separate folder (CURA-1574) 2016-05-25 12:07:59 +02:00
Tim Kuipers 6faeaf8c0b fix: accidental __cxx11:: in type (CURA-1574) 2016-05-20 14:04:46 +02:00
Tim Kuipers f9b15a2f47 refactor: settingsResistry.settings ==> setting_key_to_config (CURA-1574) 2016-05-20 12:58:02 +02:00
Tim Kuipers c1eb1fdd85 fix: forgotten newline in SettingContainer debug out (CURA-1574) 2016-05-20 12:57:27 +02:00
Tim Kuipers 324f424e69 refactor: simplified machine name loading (CURA-1574) 2016-05-20 12:51:04 +02:00
Tim Kuipers 3dfb35d73e fix: a settings container is now used only for the global settings base and for the separate extruder train settings default bases (CURA-1574) 2016-05-20 12:50:38 +02:00
Tim Kuipers e72789e3cb fix: read new setting .def.json files (CURA-1574)
Simplified the recursion of reading settings
Made the settings registry into a flat list, rather than a tree
Made each setting record a path instead (to keep the same information as the tree)
Moved extruder trains into a separate object, rather than it being a normal category
warn_duplicates strategy simplified: always after the first file
(rather than when applying overrides)
temporarily removed reading of machine_extruder_trains
made label attribute obligatory
Always add a setting to the global setting config (cause reading machine_extruder_trains is currently not implemented)
2016-05-20 12:42:14 +02:00
Tim Kuipers d6ac9e69c1 lil 2016-05-19 17:08:02 +02:00
Tim Kuipers 358d2e26c2 lil 2016-05-19 17:07:04 +02:00
Tim Kuipers e9fb973a05 fix: machine_settings became just another category, so doesnt need special handling (CURA-1574) 2016-05-19 14:29:55 +02:00
Tim Kuipers 22b86f81b7 fix: don't load inheriting json document (CURA-1574)
The inherit property now refers to an id instead of a filename, so I cannot simply know which file I have to load from a given json file
2016-05-19 14:28:59 +02:00
Tim Kuipers cf05c65061 lil: don't wait after priming second nozzle 2016-05-18 17:25:45 +02:00
Tim Kuipers 5f8f0110cf fix: switch infill direction every X layers (CURA-1569 CURA-943)
infill combine always prints infill of any thickness on infill of the first fully combined layer below
2016-05-18 16:35:10 +02:00
Tim Kuipers d3715e8e76 refactor: moved getSettingBoolean(cool_lift_head) inside gcodePlanner::writeGCode(.) (CURA-1568) 2016-05-18 13:36:05 +02:00
Tim Kuipers 31e2996104 refactor: removed superfluous layerThickness parameter to gcodePlanner::writeGCode(.) (CURA-1568) 2016-05-18 13:32:13 +02:00
Tim Kuipers 3ff329033a lil doc 2016-05-18 10:24:42 +02:00
Tim Kuipers f7d72623d2 fix: better naming for infill/skin overlap for support (CURA-967) 2016-05-13 13:22:34 +02:00
Tim Kuipers fee8867855 feat: skin_overlap separated from infill_overlap (CURA-967) 2016-05-13 13:22:04 +02:00
Tim Kuipers 62a4db8632 fix: initial layer thickness stays the same even when having a raft 2016-05-12 23:42:06 +02:00
Tim Kuipers efb20afc76 fix: only process if there's any non-infill meshes (CURA-833) 2016-05-12 20:49:46 +02:00
Tim Kuipers 683c887e53 fix: made generateMultipleVolumesOverlap ignore infill meshes and made overlap changable per object (CURA-883) 2016-05-12 20:11:00 +02:00
Tim Kuipers 4d9daccb5b fix: don't generateMultipleVolumesOverlap for infill meshes (CURA-833) 2016-05-12 20:06:25 +02:00
Tim Kuipers c0611904bb refactor: compute generateMultipleVolumesOverlap differently (CURA-833)
instead of for each layer computing overlap for all volumes, go through all volumes computing overlap for each layer
2016-05-12 20:04:03 +02:00
Tim Kuipers cecac0fe90 lil: code conventions (CURA-833) 2016-05-12 19:56:00 +02:00
Tim Kuipers f48c858ec4 fix: syntax fix of last merge 2016-05-12 19:55:34 +02:00
Tim Kuipers fc4d24fb01 optimization: carveMultipleVolumes uses aabb of meshes and discards infill meshes (CURA-1551 CURA-833) 2016-05-12 19:49:42 +02:00
Tim Kuipers 529301f950 Merge branch '2.1' 2016-05-12 19:25:10 +02:00
Tim Kuipers 33d2594b20 fix: M204 confirmed to too new Marlin standard (CURA-1443) 2016-05-12 16:54:22 +02:00
Tim Kuipers 9c47644e55 cleanup: removed fill_perimeter_gaps setting (CURA-996) 2016-05-12 16:30:11 +02:00
Tim Kuipers 2949f89b29 cleanup: removed perimeterGaps and functionality of fill_perimeter_gaps (CURA-996) 2016-05-12 16:28:39 +02:00
Tim Kuipers 1793961094 cleanup: removed avoidOverlappingPerimeters as parameters to functions and as member variables (CURA-996) 2016-05-12 16:22:34 +02:00
Tim Kuipers 590795921e cleanup: removed avoidOverlappingPerimeters and in_between from Infill factory (CURA-996) 2016-05-12 16:17:43 +02:00
Tim Kuipers b79c404dc3 remove: removed offsetSafe functions used for 'remove overlapping wall parts' (CURA-996) 2016-05-12 16:05:37 +02:00
Tim Kuipers 0065532d6d lil doc (CURA-996) 2016-05-12 14:00:09 +02:00
Tim Kuipers b89c8fd1fa fix: infill meshes didn't update bounding boxes (CURA-833) 2016-05-11 23:25:56 +02:00
Tim Kuipers d409c4d245 feat: infill_mesh_order to determine the order of infill meshes in eachother (CURA-833) 2016-05-11 23:25:28 +02:00
Tim Kuipers fd64b5ce60 fix: infill meshes updated infill_area, but not infill_are_per_combine (CURA-833) 2016-05-11 22:35:06 +02:00
Tim Kuipers 5bc3b86dc4 fix: infill meshes relied on old infill_area implementation (CURA-833) 2016-05-11 21:47:41 +02:00
Tim Kuipers 9ec92fa33f Merge branch 'feature_infill_mesh_correct_progress' 2016-05-11 21:43:58 +02:00
Tim Kuipers 03b654af3e feat: layer_0_z_overlap (CURA-1549) 2016-05-11 17:15:28 +02:00
Tim Kuipers e3c03e6c04 feat: switch_extruder_retraction_hop (CURA-1061) 2016-05-11 16:41:08 +02:00
Tim Kuipers 33c40f3398 Merge branch '2.1' 2016-05-11 13:27:16 +02:00
Tim Kuipers c79a7f1819 fix: spiralize would leave the z at the next layer for the next polygon on the same layer (CURA-1541) 2016-05-11 12:57:47 +02:00
Tim Kuipers 7843a68d7c lil: doc 2016-05-11 12:13:18 +02:00
Tim Kuipers 8f912835cf lil: doc indent 2016-05-11 12:11:37 +02:00
Tim Kuipers 36de33b735 fix: some small fixes of second last refactor (CURA-1367) 2016-05-11 12:07:24 +02:00
Tim Kuipers 01884663c3 refactor: rename files insets ==> WallsComputation (CURA-1367) 2016-05-11 12:04:11 +02:00
Tim Kuipers 4c46dd37a7 refactor: put generateInsets functions into a class (CURA-1367) 2016-05-11 12:01:16 +02:00
Tim Kuipers 9245a4fa41 fix: only compute print_outline when the mesh uses support (CURA-1367) 2016-05-11 11:50:31 +02:00
Tim Kuipers 4b240e8057 fix: let getLayerOutlines use an outline approximation based on the outer wall (CURA-1367)
Thin walls may be unprintable, so getLayerOutlines returns pieces of polygons which aren't actually printed.
This caused an edge overhang to remove support due to the XY distance of unprinted parts of the edge overhang.
When two parts are connected via an unprintably thin wall, also combing would be affected, but not anymore.
2016-05-11 11:36:38 +02:00
Tim Kuipers fff8195d51 Merge branch '2.1' 2016-05-11 08:52:55 +02:00
Tim Kuipers e01f18c7d4 lil: doc 2016-05-11 08:52:06 +02:00
Tim Kuipers 42891874f4 fix: multiple polygons & spiralize resulted in extrusions where travels should have been (CURA-1513) 2016-05-10 17:37:16 +02:00
Tim Kuipers 257d6a6635 fix: spiralize each polygon of a spiralized mesh even though that might cause a print head crash (CURA-1443) 2016-05-10 15:58:34 +02:00
Tim Kuipers bec8bef455 fix: consecutive spiralize paths are handled as one (CURA-1443 CURA-1541) 2016-05-10 15:32:09 +02:00
Tim Kuipers 4efeaa7083 fix: let bool spiralize bubble down from FffGcodeWriter into GCodePath instead of going via the GCodePathConfig (CURA-1443)
Because of the LayerPlanBuffer the GCodePathConfig changed a couple of layers too early, resulting in spiralization in the first layers which include the bottom skin.
2016-05-10 15:14:50 +02:00
Tim Kuipers 95fd9d6685 lil: doc 2016-05-10 13:25:11 +02:00
Tim Kuipers f6cf3356f8 feat: change time estimates based on jerk and acceleration (CURA-1443) 2016-05-10 09:38:06 +02:00
Tim Kuipers c041ca5ea1 fix: acceleration used wrong gcode (CURA-1443) 2016-05-10 09:33:42 +02:00
Tim Kuipers 92cb2f82ab refactor: moved firmware values inside TimeEstimateCalculator (CURA-1443) 2016-05-10 09:16:11 +02:00
Tim Kuipers fa7ff61bf5 feat: apply acceleration and jerk (CURA-1443) 2016-05-09 18:30:02 +02:00
Tim Kuipers 255c62782e feat: initial layer speedup also applied to acceleration and jerk (CURA-1443) 2016-05-09 17:14:58 +02:00
Tim Kuipers 9cbf760c80 feat: acceleration and jerk for GCodePathConfig (CURA-1443) 2016-05-09 15:27:47 +02:00
Tim Kuipers 506560e9e0 refactor: move path config parameters which change over layers into a separate struct (CURA-1443)
now the iconic settings and current settings are well separated, making it easier to introduce more settings which change over layers
2016-05-09 13:39:52 +02:00
Tim Kuipers d634e310fd refactor: moved GCodePathConfig implementation to new cpp file (CURA-1443) 2016-05-09 12:38:59 +02:00
Tim Kuipers 255dd4ffcd refactor: moved GCodePathConfig and RetractionConfig to their own header files (CURA-1443) 2016-05-09 12:34:47 +02:00
Tim Kuipers 6d54a31bcd Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-05-06 15:31:04 +02:00
Tim Kuipers 18df36ca06 refactor: moved AABB3D out of AABB (CURA-1436) 2016-05-06 15:30:22 +02:00
Tim Kuipers 55f47523b2 refactor: moved AABB implementation out of header file (CURA-1436) 2016-05-06 15:24:46 +02:00
Tim Kuipers 4130af0ad6 feat: boundingbox.expand (CURA-1436) 2016-05-06 15:06:19 +02:00
Tim Kuipers c08a0221c8 fix: combing basic comb path had wrong offsets to beginning and end of poly (CURA-1436) 2016-05-06 15:05:19 +02:00
Tim Kuipers 31f8459a0f Merge pull request #335 from sean041/patch-2
Compare in PolygonRef::shorterThan is strange.
2016-05-05 11:11:51 +02:00
Peng Liu 4642076fdc Compare in PolygonRef::shorterThan is strange.
PolygonRef::shorterThan will always return false?
2016-05-05 15:27:46 +08:00
Tim Kuipers 5fd3277919 doc&refactor: moved ConicalOverhang to cpp file (CURA-1412) 2016-05-04 15:34:06 +02:00
Tim Kuipers 13b3c715bf feat: compensate overlapping inner wlal parts (CURA-995) 2016-05-04 15:09:33 +02:00
Tim Kuipers 3583d71dcd lil: indent (CURA-1479) 2016-05-04 11:40:38 +02:00
Tim Kuipers c5ab004ece feat: option to apply different xy distance at overhang places (CURA-1479) 2016-05-04 11:40:15 +02:00
Tim Kuipers b8fe70ee74 feat: SupportDistPriority setting enum (CURA-1479) 2016-05-04 11:38:30 +02:00
Tim Kuipers 6db88290c2 lil debug 2016-05-03 15:57:55 +02:00
Tim Kuipers be6fd8cc7c fix: skirt was processed sometimes twice for the first extruder sometimes not at all for the second extruder (CURA-1446) 2016-05-03 15:57:40 +02:00
Tim Kuipers baeb736705 fix: if all layers got removed slicing didn't quit (CURA-1465) 2016-05-03 14:15:57 +02:00
Tim Kuipers 05fa05bb5a Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-05-03 13:51:33 +02:00
Tim Kuipers 5a7c2e5ef1 fix codestyle (tabs) 2016-05-03 13:50:33 +02:00
Tim Kuipers c9de58ceba fix: material used was logged on the wrong extruder (CURA-520) 2016-05-03 13:15:53 +02:00
Ghostkeeper 1d60079220 Merge branch 'feature_slicer_refactor_rebased' 2016-05-03 11:06:09 +02:00
Tim Kuipers 77d40fb0e9 fix: griffin header micron ==> mm (CURA-520) 2016-05-03 09:34:03 +02:00
Tim Kuipers 72e9906bb8 Merge branch '2.1' 2016-05-02 18:29:30 +02:00
Tim Kuipers 2db37c6018 fix: erase with impossible iterator when trying to simplify an empty polygon (CURA-1430) 2016-05-02 18:28:00 +02:00
Tim Kuipers 41b0966d26 fix: constructor prime tower called incorrectly 2016-05-02 17:33:00 +02:00
Ghostkeeper d5bff03a1c Codestyle: Space around binary operators
Contributes to issue CURA-520.
2016-04-29 16:18:59 +02:00
Tim Kuipers 0d5cc686c9 fix: exclude enum values from setting reflection 2016-04-29 14:32:07 +02:00
Tim Kuipers 3103acb7b0 fix: curaEngine analyse 2016-04-29 14:28:04 +02:00
Tim Kuipers bcce1bd8a4 feat:setting inheritance diagram 2016-04-29 14:27:50 +02:00
Tim Kuipers cda16c4429 Merge branch 'reflection_setting_inheritance_visualization' 2016-04-29 14:19:54 +02:00
Tim Kuipers 21a8afb895 fix: extruder train initialization M227 ==> G280 (CURA-520) 2016-04-28 17:05:32 +02:00
Tim Kuipers 0d7074ee8b doc: documented stuff in gcodePlanner.h (CURA-537) 2016-04-28 17:01:48 +02:00
Tim Kuipers 8bb91cecb9 fix: dont switch extruder if there is no priontable support (CURA-1437) 2016-04-28 15:49:30 +02:00
Tim Kuipers 7aaf3b9bae fix: dont switch extruder if there is no priontable model (CURA-1437) 2016-04-28 15:48:57 +02:00
Tim Kuipers a806a27836 fix: sometimes the first layer could be totally empty / no walls (CURA-1465) 2016-04-26 18:28:05 +02:00
Tim Kuipers d556999aed fix: jedi header: save json machine name as if it is a setting and retrieve it for the header (CURA-520) 2016-04-25 17:57:45 +02:00
Tim Kuipers 9da99b67fc fix: jedi header: PRINT.SIZE obtained from machine dimensions (CURA-520) 2016-04-25 17:15:55 +02:00
Tim Kuipers 4b02912ab6 fix: jedi header: BED ==> BUILD_PLATE (CURA-520) 2016-04-25 17:00:25 +02:00
Tim Kuipers 58234e4125 doc: Date documentation (CURA-520) 2016-04-25 16:45:21 +02:00
Tim Kuipers e825637f14 feat: jedi header includes date stamp (CURA-520) 2016-04-25 16:41:31 +02:00
Tim Kuipers 242384bd28 Merge branch 'feature_jedi_cura_starting_state' 2016-04-25 13:21:46 +02:00
Tim Kuipers b0cb94aeca Merge branch 'feature_slicer_refactor_rebased' of https://github.com/Ultimaker/CuraEngine into feature_slicer_refactor_rebased 2016-04-22 17:21:58 +02:00
Tim Kuipers 95fc4695d2 fix: polylines got copied, const correctness and documentation in slicer.cpp (CURA-738) 2016-04-22 17:19:51 +02:00
Tim Kuipers 1f6f847b51 lil: inlined one line of code 2016-04-22 16:19:03 +02:00
Tim Kuipers 3e1b5128bb lil: made polygon.shorterThan const (CURA-738) 2016-04-22 16:17:43 +02:00
Tim Kuipers b88ee700fc refactor: moved implementation to cpp file for polygon.shorterThan (CURA-738) 2016-04-22 16:16:15 +02:00
Tim Kuipers b43b98da25 bugfix: polygon.shorterThan didn't take last line segment into account (CURA-738) 2016-04-22 16:07:43 +02:00
Ghostkeeper ecdb4f7879 Codestyle: Space after control statement
Contributes to issue CURA-738.
2016-04-22 15:24:21 +02:00
Ghostkeeper 20ef9ce1c0 Codestyle: Space after control statement, always use brackets
Contributes to issue CURA-738.
2016-04-22 14:33:32 +02:00
Ghostkeeper aec58f7e00 Codestyle: Space around operators and after control statement
Contributes to issue CURA-738.
2016-04-22 14:06:01 +02:00
Tim Kuipers 7dca18fe6a removed debugging code 2016-04-21 14:35:39 +02:00
Tim Kuipers dc761c2f57 lil: removed commented code 2016-04-21 13:47:18 +02:00
Tim Kuipers 059c97b2cd refactor: moved implementation in Meshgroup.h to cpp file (CURA-520) 2016-04-21 13:46:01 +02:00
Tim Kuipers d14e05f318 refactor: jedi ==> griffin (CURA-520) 2016-04-21 13:31:39 +02:00
Tim Kuipers a533559918 fix: combing always went to closest point to origin, instead of crossing_1_in_or_mid (CURA-579) 2016-04-21 10:42:47 +02:00
Tim Kuipers 78ca299380 quickfix: set temperature during priming (CURA-520) 2016-04-20 17:13:26 +02:00
Tim Kuipers 1d581c0fec fix: only reset E-value after toolswitch (CURA-520)
Given that having an G92 E0 at the start of the first use of a toolhead is no problem in any printer, we can just reset the E-value every start of a toolhead
2016-04-20 14:53:06 +02:00
Tim Kuipers d0c58acfcf rebase fixes 2016-04-20 13:13:57 +02:00
Tim Kuipers 7b90354033 refactor: renaming local vars and rewrite of Remove all the tiny polygons 2016-04-20 13:10:30 +02:00
Tim Kuipers 5c4fdfdd0b refactor: renamed clipper polygon to path 2016-04-20 13:10:30 +02:00
Tim Kuipers c8051f5b37 refactor: renaming local vars 2016-04-20 13:10:30 +02:00
Tim Kuipers fa203bd976 refactor: some functions moved and extensive stitching moved to its own function 2016-04-20 13:10:30 +02:00
Tim Kuipers 4d2e544be0 refactor: renamed clipper polygon to path 2016-04-20 13:10:30 +02:00
Tim Kuipers bd27011107 bugfix: lil) 2016-04-20 13:08:04 +02:00
Tim Kuipers fb3c99ebe0 changed stitching poly decision 2016-04-20 13:08:03 +02:00
Tim Kuipers 2a8a86aac4 refactor: moved first stitching out of slicer 2016-04-20 13:08:03 +02:00
Tim Kuipers 4fa497ee8c bugfix: slicer didn't connect anything 2016-04-20 13:08:03 +02:00
Tim Kuipers 76eaeeb196 refactored first part of slicer: connect segments 2016-04-20 13:08:03 +02:00
Tim Kuipers 9cebeb770a Merge branch 'feature_combing_refactor' 2016-04-20 10:35:35 +02:00
Tim Kuipers a0200f1548 Merge branch 'feature_combing_refactor' 2016-04-20 10:32:46 +02:00
Tim Kuipers 83164fe1e7 fix: don't recalculate line distance in the engine (CURA-1317) 2016-04-19 17:30:43 +02:00
Tim Kuipers f9f162383b removed old test stls and gcode files 2016-04-19 16:41:59 +02:00
Tim Kuipers 403f7515b8 fix: forgot ProgressStageEstimator.h (CURA-873) 2016-04-18 17:38:38 +02:00
Tim Kuipers a0aa69f8b0 fix: forgot ConicalOverhang.h (CURA-1412) 2016-04-18 17:34:57 +02:00
Tim Kuipers 969ed87600 refactor: moved ProgressStageEstimator implementation to cpp file (CURA-873) 2016-04-18 17:30:22 +02:00
Tim Kuipers a2dccb118c Merge branch 'feature_progress_refactor_folder_refactor' 2016-04-18 17:23:38 +02:00
Tim Kuipers 64e5c5b8bf Merge branch 'feature_progress_refactor' 2016-04-18 17:22:46 +02:00
Tim Kuipers 8bb2a6ba7f refactor: moved progress files into separate folder (CURA-873) 2016-04-18 17:21:53 +02:00
Tim Kuipers da38e958ac Merge branch 'feature_rework_fffPolygonProcessor_per_mesh' 2016-04-18 17:02:49 +02:00
Tim Kuipers 081a46118c refactor: merged writeRetraction and writeRetraction_extruderSwitch (CURA-1431) 2016-04-18 15:45:00 +02:00
Tim Kuipers bd006e676b feat: zHop during extruder switch (CURA-1431) 2016-04-18 15:28:26 +02:00
Tim Kuipers afc40e1c70 refactor: moved extruder switch member values into normal RetractionConfig (CURA-1431) 2016-04-18 15:27:26 +02:00
Tim Kuipers cc6583b214 fix: writeRetraction did early exit sometimes when going from normal retracted to extruder switch retracted (CURA-1431) 2016-04-18 15:25:26 +02:00
Tim Kuipers 55fbd2ba54 refactor: extruder_attr[current_extruder] ==> extr_attr (CURA-1431) 2016-04-18 14:55:02 +02:00
Tim Kuipers 916d26417f fix: unretraction speeds were wrong when going from exdtruder switch retraction state to normal retraction state (CURA-1431) 2016-04-18 14:54:11 +02:00
Tim Kuipers 258a7e6f37 fix: let LayerplanBuffer decide the starting temperature (CURA-520)
That way flow dependent temperature decides on the starting temperature when using the command sucket
2016-04-18 13:39:43 +02:00
Tim Kuipers d5f13616c2 refactor: moved meshgroup_number to FffProcessor (CURA-520) 2016-04-18 11:44:57 +02:00
Tim Kuipers 54c7f942c4 fix: no more temp commands at start for Jedi gcode (CURA-520) 2016-04-18 11:07:57 +02:00
Tim Kuipers f63d78357b feat: conical ocerhang (CURA-1412) 2016-04-15 20:05:27 +02:00
Tim Kuipers bd565ab000 fix: don't zero extruder value after toolchange (CURA-959) 2016-04-14 18:09:29 +02:00
Tim Kuipers fc24ce974d feat: jedi prime gcode commands (CURA-520)
priming is now perfored by moving to a location, perform the prime gcode, retract, switch extruder, same for other extruder
2016-04-14 15:50:23 +02:00
Tim Kuipers 7a7c824b0d refactor: moved preSetup implementation to cpp file (CURA-520)| 2016-04-14 14:24:14 +02:00
Tim Kuipers a4227db5b1 fix: also set initial temps when doing wireprinting (CURA-520) 2016-04-14 14:21:58 +02:00
Tim Kuipers 7fdc77c74c Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-04-14 14:10:09 +02:00
Tim Kuipers 508b1b2933 machine extruder trains now can't be an array anymore (CURA-494) 2016-04-14 14:09:58 +02:00
Tim Kuipers 387ef30ca1 machine extruder trains now can't be an array anymore (CURA-494) 2016-04-14 13:21:00 +02:00
Tim Kuipers 1b6df75591 fix: jedi header (CURA-520) 2016-04-14 11:26:02 +02:00
Tim Kuipers 53ccadbf91 feat: const preserving getExtruderTrain function (CURA-520) 2016-04-14 11:23:05 +02:00
Tim Kuipers 612f6cac3d fix: extruder trains didn't get properly initialized when one-at-a-time printing with command line slicing 2016-04-14 11:16:45 +02:00
Tim Kuipers 166601492b fix: always prepend bogus header to fool firmware into accepting the print (CURA-520)
this was done so that Jedi gcode also always includes a header
it also means that UMO gcode always gets a header, which is ok, as it is ignored by that firmware
2016-04-13 16:13:43 +02:00
Ghostkeeper e0de929c5b Codestyle: Spaces around operators
Contributes to issue CURA-494.
2016-04-13 14:54:07 +02:00
Tim Kuipers 7ac4738435 feat: JEDI gcode flavor (CURA-520) 2016-04-13 13:07:11 +02:00
Tim Kuipers 4c547b9a66 fix const problem in BucketGrid2D (CURA-893) 2016-04-12 17:09:06 +02:00
Tim Kuipers 7ca184fb78 fix merge conflicts (CURA-893) 2016-04-12 16:53:00 +02:00
Tim Kuipers 080663a653 moved polygonUtilsTest (CURA-893) 2016-04-12 16:51:55 +02:00
Tim Kuipers cc54c8be08 Merge branch 'feature_skin_and_dual_combing' into feature_skin_and_dual_combing_merge 2016-04-12 16:49:38 +02:00
Tim Kuipers c19f35ce13 fix: writeRetraction didn't unretract if already retracted more (CURA-959) 2016-04-12 15:25:06 +02:00
Tim Kuipers 983720cfc0 fix: G92 E0 wasn't performed after the nozzle switch (CURA-959) 2016-04-12 15:24:16 +02:00
Tim Kuipers cad745f0b5 fix: infill_overlap ==> infill_overlap_mm (CURA-786) 2016-04-11 19:06:55 +02:00
Tim Kuipers 2a10954df2 lil fix: __cxx11::string ==> string 2016-04-09 01:55:11 +02:00
Tim Kuipers 7eded0ba3c Merge branch 'bugfix_support_z_xy_fight' 2016-04-08 14:39:13 +02:00
Tim Kuipers ca963d5da0 Merge branch 'bugfix_getSetting_calls' 2016-04-08 14:12:51 +02:00
Tim Kuipers 7091650876 Merge branch '2.1' 2016-04-08 13:36:26 +02:00
Tim Kuipers 93485cd0df Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-04-06 17:09:16 +02:00
Tim Kuipers 2d3382874a fix: polygon smoothing removed vertices which were connected to a small as well as a large line segment (CURA-1361) 2016-04-06 17:09:05 +02:00
Tim Kuipers 1e78397e18 fix: support max layer was set after each object (CURA-1360) 2016-04-06 17:05:33 +02:00
Ghostkeeper 6bcdd94f7e Copy protocol file from front-end
This synchronises the whitespace and comments from the front-end. The typeids are not necessary any more.

Contributes to issue CURA-1210.
2016-04-05 17:14:09 +02:00
Ghostkeeper accd28db64 Update documentation of sendLayerData
Contributes to issue CURA-1210.
2016-04-05 17:13:57 +02:00
Ghostkeeper 1c0f4c42d9 Remove superfluous set to nullptr
Shared pointers are already set to nullptr by default.

Contributes to issue CURA-1210.
2016-04-05 17:13:47 +02:00
Ghostkeeper 5da1632d9f Remove sliced object lists from protocol
Each layer is now sent individually, instead of grouped by object and grouping those objects in a sliced object list. The list was sometimes too large to send in one message. The objects weren't used by the front-end anyway.

Contributes to issue CURA-1210.
2016-04-05 17:13:37 +02:00
Ghostkeeper cbf1152f56 Remove object ID from layer
Turns out that it is not needed in the front-end either any more. If we need it in the future, we'll add it again.

Contributes to issue CURA-1210.
2016-04-05 17:13:22 +02:00
Ghostkeeper 2273c5aefe Alter protocol to no longer group sliced objects
They will be sent with one message per layer from now on.

Contributes to issue CURA-1210.
2016-04-05 17:13:09 +02:00
Tim Kuipers 991adf19a1 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-04-05 11:49:07 +02:00
Tim Kuipers 9a4e1b52ed fix: always zero E value before AND after nozzle switch (CURA-959) 2016-04-05 10:53:25 +02:00
Ghostkeeper 98d2786dd0 Merge branch '2.1'
Conflicts:
	src/gcodeExport.h
	src/gcodePlanner.cpp
	src/utils/LinearAlg2D.cpp
2016-04-04 19:03:33 +02:00
Tim Kuipers 46c793e73d fix: lil string vs c_str bug (CURA-1231) 2016-04-04 14:15:14 +02:00
Tim Kuipers fd4969887b refactor: replaced all gcode output \n by new_line (CURA-1231) 2016-04-04 14:13:32 +02:00
Tim Kuipers 6620a050a5 feat: new_line string used for BFB machines (CURA-1231) 2016-04-04 14:13:10 +02:00
Tim Kuipers 6325197fce feat/refactor: moved file header generation to gcodeExport and introduced the NOZZLE_SIZE header comment (CURA-1231) 2016-04-04 14:03:38 +02:00
Tim Kuipers f828d44365 Merge branch 'feature_better_time_estimates' into 2.1 2016-04-04 12:14:19 +02:00
Tim Kuipers 5072995a66 documentation (CURA-537) 2016-04-04 12:06:28 +02:00
Tim Kuipers a8ab0c12aa code style: space after keyword 2016-03-30 17:44:36 +02:00
Tim Kuipers 09c989a019 code style: spaces around operators 2016-03-30 17:17:12 +02:00
Tim Kuipers 29564a23e0 refactor: introduced mm, mm3, E value conversion functions instead of inline is_volumetric checks (CURA-1293) 2016-03-30 12:35:11 +02:00
Tim Kuipers 1fdda3319f fix: volumetric time estimation was bugged (CURA-1293) 2016-03-30 12:24:27 +02:00
sean041 be113eceb4 Fix typo. downSkinCount -> upSkinCount (CURA-1299)
This typo causes flaky crash when downSkinCount < upSkinCount and ignore small z gaps is disabled.
2016-03-30 10:24:58 +02:00
Tim Kuipers 0b3b8ea33b Merge pull request #323 from sean041/patch-1
Fix typo. downSkinCount -> upSkinCount (CURA-1299)

this caused a crash when Ignore small z gaps was disabled and bottom was smaller than top thickness
2016-03-30 10:22:29 +02:00
Tim Kuipers 0c42ff9bfa fix: inner (2nd) wall was refered to even if it wasn't generated (CURA-1294) 2016-03-29 15:18:47 +02:00
sean041 a5bd599ec7 Fix typo. downSkinCount -> upSkinCount
This typo causes flaky crash when downSkinCount < upSkinCount.
2016-03-26 08:07:36 +08:00
Ghostkeeper 7548c41d7b Simplify test case
This test case now reduces to the normal test cases since there is only one option again. We can re-use the function that was made for normal test cases then.

Contributes to issue CURA-579.
2016-03-25 16:41:08 +01:00
Tim Kuipers cd033ef6ab doc: autobrief for first line (CURA-537) 2016-03-24 17:50:12 +01:00
Tim Kuipers e909af9abd documentation for fffProcessor (CURA-537) 2016-03-24 17:34:02 +01:00
Tim Kuipers dd5fbf14e4 document FffGcodeWriter (CURA-537) 2016-03-24 16:59:09 +01:00
Tim Kuipers 168e041c42 Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-03-24 15:58:16 +01:00
Ghostkeeper 670ae6dd8c Spaces around minus operator
Conforming to code style.

Contributes to issue CURA-863.
2016-03-24 15:58:11 +01:00
Tim Kuipers 20adfa751f doc+refactor: fan speed calc more clear (CURA-863) 2016-03-24 15:57:54 +01:00
Tim Kuipers bf8776b112 optimization: removed superluous recalculation of line direction in LineOrderOptimizer (CURA-1170) 2016-03-23 16:25:10 +01:00
Tim Kuipers 1d0f3f519a fix syntax mistake (CURA-1170) 2016-03-23 16:25:01 +01:00
Tim Kuipers 07fef8668c calculate incoming_perpundicular_normal in end stage of line order optimizer (CURA-1170) 2016-03-23 16:24:51 +01:00
Tim Kuipers 1c06fc49fc refactor: factor out getAngleScore from line order optimizer (CURA-1170) 2016-03-23 16:24:39 +01:00
Tim Kuipers beb9422d9b refactor: clear up pathOrderOptimizer for lines (CURA-1170) 2016-03-23 16:24:27 +01:00
Tim Kuipers a8359b9a68 refactor: small optimization of line order optimizer dot score (CURA-1170) 2016-03-23 16:24:17 +01:00
Tim Kuipers 5ccfe2d1aa refactor: clear up pathOrderOptimizer for lines (CURA-1170) 2016-03-23 16:24:07 +01:00
Tim Kuipers 74577759b4 refactor: expand complicated code in pathOrderOptimizer (CURA-1170) 2016-03-23 16:23:54 +01:00
Tim Kuipers 45eb026777 refactor: rewrite line order optimizer dot score stuff (CURA-1170) 2016-03-23 16:23:42 +01:00
Tim Kuipers aabb07fd81 refactor: simple renaming of incoming_perpendicular_normal (CURA-1170)
Conflicts:
	src/pathOrderOptimizer.cpp
2016-03-23 16:23:21 +01:00
Ghostkeeper 6377ec63e1 Add edge-case tests for getAngleLeft
These test what happens when two or more points are equal. There is nothing about this in the function specification, so it allows any output, but at least it shouldn't give like a divide by zero error.

Contributes to issue CURA-1170.
2016-03-23 16:14:11 +01:00
Tim Kuipers eab2d8e667 fix: improved dot-score for preferring the z-seam on inside corners (CURA-1170) 2016-03-23 16:13:58 +01:00
Tim Kuipers 8d41003c67 feat: linearAlg2D::getAngleLeft CMAKE (CURA-1170) 2016-03-23 16:13:48 +01:00
Tim Kuipers ecfae4d75c feat: linearAlg2D::getAngleLeft (CURA-1170) 2016-03-23 16:13:37 +01:00
Tim Kuipers a2208f6b69 fix: pathOrderOptimizer was bugged (CURA-1170)
polyStart indices used wrongly
2016-03-23 16:13:26 +01:00
Tim Kuipers bacacb01dc refactor: more cleanup of pathOrderOptimizer (CURA-1170) 2016-03-23 16:13:15 +01:00
Tim Kuipers 94c9399f2c refactor: intpoint::crossZ ==> turn90CCW (CURA-1170) 2016-03-23 16:13:03 +01:00
Tim Kuipers 168dc3c12b refactor: more cleanup of pathOrderOptimizer (CURA-1170) 2016-03-23 16:12:53 +01:00
Tim Kuipers 235af65b00 refactor: code cleanup helper functions of PathOrderOptimizer (CURA-1170) 2016-03-23 16:12:43 +01:00
Tim Kuipers f3f3be74cc refactor: code cleanup of PathOrderOptimizer - lines (CURA-1170) 2016-03-23 16:12:32 +01:00
Tim Kuipers dca0bc80b5 fix: PathOrderOptimizar::polyStart had wrong indexing (CURA-1170) 2016-03-23 16:12:18 +01:00
Tim Kuipers c0e57622d0 cleanup: more clarification of pathOrderOptimizer for polygons code (CURA-1170) 2016-03-23 16:12:04 +01:00
Tim Kuipers b7a8fbe798 cleanup: pathOrderOptimizer got cleaned up (CURA-1170) 2016-03-23 16:11:49 +01:00
Ghostkeeper 0985b97c54 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-03-23 16:08:58 +01:00
Tim Kuipers 06521eef8b lil 2016-03-23 12:32:44 +01:00
Tim Kuipers 47a6f0dc36 fix: made it possible to include warning and error functions in the graph; changed the way you should call the tool 2016-03-23 11:50:39 +01:00
Tim Kuipers 4353980e78 refactor: made code more explicit: after smoothing speed (towards bottom layer speed) the speeds are set to their iconic speeds once and for all (CURA-1248) 2016-03-22 17:20:38 +01:00
Tim Kuipers 18ae9cf41d bugfix: alternate extra wall had skin overlapping with inner wall (CURA-1233)
To see if there was infill above, we looked at the innermost wall instead of the wall with index [wall line count]
2016-03-22 13:42:32 +01:00
Tim Kuipers 04edf35331 bugfix: bottom layer speed influenced all layers (CURA-1248)
smoothSpeed never got called for the final speed
2016-03-22 13:21:03 +01:00
Tim Kuipers ce4d34adb2 unit test fix: moveInside(polys, points, dist) may leave inside points as they are (CURA-579) 2016-03-21 17:51:38 +01:00
Tim Kuipers d42be2a22c removed old unused code 2016-03-21 17:29:22 +01:00
Tim Kuipers dbcbcae2e3 codestyle: closestHere ==> closest_here (CURA-893) 2016-03-21 17:26:04 +01:00
Tim Kuipers ff9cb24d99 refactor: auto ==> ClipperLib::Path (CURA-893) 2016-03-21 17:23:19 +01:00
Tim Kuipers b8ff36651e fix: tests failed due to changed GcodePlanner constructor (CURA-893)
combing changed from boolean to an enum
boolean is_inside_mesh was added
2016-03-21 17:16:24 +01:00
Tim Kuipers 98a78e1844 Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-03-21 12:30:52 +01:00
Tim Kuipers 37c8ad3061 lil (CURA-1217) 2016-03-21 12:28:56 +01:00
Tim Kuipers d2187fedbc optimization: removed superluous recalculation of line direction in LineOrderOptimizer (CURA-1170) 2016-03-21 12:17:20 +01:00
Tim Kuipers 5b0a50456f fix syntax mistake (CURA-1170) 2016-03-21 11:55:01 +01:00
Tim Kuipers 66f4b51a3e calculate incoming_perpundicular_normal in end stage of line order optimizer (CURA-1170) 2016-03-21 11:53:33 +01:00
Tim Kuipers 3ac6ee1b37 refactor: factor out getAngleScore from line order optimizer (CURA-1170) 2016-03-21 11:43:12 +01:00
Tim Kuipers 4d8b22a224 refactor: clear up pathOrderOptimizer for lines (CURA-1170) 2016-03-21 11:36:08 +01:00
Tim Kuipers 3a0143ff4c refactor: small optimization of line order optimizer dot score (CURA-1170) 2016-03-21 11:33:26 +01:00
Tim Kuipers c6a4945469 refactor: clear up pathOrderOptimizer for lines (CURA-1170) 2016-03-21 11:21:08 +01:00
Tim Kuipers abc6514b6d refactor: expand complicated code in pathOrderOptimizer (CURA-1170) 2016-03-21 11:05:01 +01:00
Tim Kuipers dc26358747 refactor: rewrite line order optimizer dot score stuff (CURA-1170) 2016-03-21 10:52:23 +01:00
Tim Kuipers 3485e5a4ad refactor: simple renaming of incoming_perpendicular_normal (CURA-1170) 2016-03-21 10:34:55 +01:00
Tim Kuipers bd47fd2c67 removed unused old commented code 2016-03-21 10:24:42 +01:00
Tim Kuipers d7d957d8f7 Removed unused code 2016-03-19 16:17:02 +01:00
Ghostkeeper bec8c235ea Add edge-case tests for getAngleLeft
These test what happens when two or more points are equal. There is nothing about this in the function specification, so it allows any output, but at least it shouldn't give like a divide by zero error.

Contributes to issue CURA-1170.
2016-03-18 14:12:51 +01:00
Ghostkeeper eb1bbd41b0 Codestyle: Spaces around binary operators
Contributes to issue 1170.
2016-03-18 13:07:28 +01:00
Tim Kuipers 49f2f21c08 feat: linearAlg2D::getAngleLeft (CURA-1170) 2016-03-17 17:40:53 +01:00
Tim Kuipers 9ed25b95ee fix: improved dot-score for preferring the z-seam on inside corners (CURA-1170) 2016-03-17 17:39:38 +01:00
Tim Kuipers c8b8abd4c6 feat: linearAlg2D::getAngleLeft CMAKE (CURA-1170) 2016-03-17 17:39:38 +01:00
Ghostkeeper 37c461fa86 Merge branch '2.1'
Conflicts:
	src/FffGcodeWriter.cpp
	src/inset.cpp
	src/pathOrderOptimizer.cpp
2016-03-17 15:43:03 +01:00
Tim Kuipers 7d9c8ee1b1 fix: pathOrderOptimizer was bugged (CURA-1170)
polyStart indices used wrongly
2016-03-17 09:45:28 +01:00
Tim Kuipers 5df73e0e30 refactor: more cleanup of pathOrderOptimizer (CURA-1170) 2016-03-16 16:59:40 +01:00
Tim Kuipers 5d8926e3e7 refactor: intpoint::crossZ ==> turn90CCW (CURA-1170) 2016-03-16 15:43:49 +01:00
Tim Kuipers 277c478e3b refactor: more cleanup of pathOrderOptimizer (CURA-1170) 2016-03-16 15:38:59 +01:00
Tim Kuipers 6f654241f7 refactor: code cleanup helper functions of PathOrderOptimizer (CURA-1170) 2016-03-16 15:17:17 +01:00
Tim Kuipers 62910c9d0a refactor: code cleanup of PathOrderOptimizer - lines (CURA-1170) 2016-03-16 15:13:36 +01:00
Tim Kuipers f92ee17577 fix: PathOrderOptimizar::polyStart had wrong indexing (CURA-1170) 2016-03-16 15:02:15 +01:00
Tim Kuipers dc3d94e0a8 cleanup: more clarification of pathOrderOptimizer for polygons code (CURA-1170) 2016-03-16 15:01:25 +01:00
Tim Kuipers 6c9db68573 cleanup: pathOrderOptimizer got cleaned up (CURA-1170) 2016-03-16 14:53:54 +01:00
Tim Kuipers fc046d5978 fixed visualization stuff for only doing parent-child or inheritance 2016-03-16 13:48:22 +01:00
Tim Kuipers 2bd8657050 vizualize dependence of child on parent via inheritance function as normal parent-child relation 2016-03-16 13:34:21 +01:00
Tim Kuipers 6718a8b2f3 fix: made engine not depend on support_z_distance, which is a parent setting value (CURA-1171) 2016-03-16 09:36:05 +01:00
Tim Kuipers 08c69ca589 child-parent arrow color overrides inheritance 2016-03-16 09:29:35 +01:00
Tim Kuipers a3d17d217a DSg 2016-03-15 18:23:11 +01:00
Tim Kuipers e47fcea2bf sdg 2016-03-15 18:21:11 +01:00
Tim Kuipers ad3903037c how to use this branch 2016-03-15 18:15:34 +01:00
Ghostkeeper f7cdd63f1d Codestyle: Whitespace around operators
Space around binary operators. No space around unary operators.

Contributes to issue CURA-1098.
2016-03-15 12:18:54 +01:00
Tim Kuipers 3400439f5d Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2016-03-15 10:18:07 +01:00
Tim Kuipers 5fbf9a8907 made outer wall offset a setting instead of being calculated from the difference between nozzle size and wall_line_width_0 (CURA-1098) 2016-03-15 10:00:01 +01:00
Ghostkeeper df6d2fc592 Codestyle: Whitespace around binary operators
Contributes to issue CURA-1097.
2016-03-14 16:50:10 +01:00
Ghostkeeper 08a5ec7dee Codestyle: Whitespace around binary operators
Contributes to issue CURA-1097.
2016-03-14 16:45:56 +01:00
Ghostkeeper 3de01763c1 Codestyle: Whitespace around binary operators.
Contributes to issue CURA-1097.
2016-03-14 16:41:34 +01:00
Tim Kuipers 7fc18c2057 made combing depend on inner wall line width instead of nozzle_size (CURA-1097) 2016-03-14 13:21:05 +01:00
Tim Kuipers c7bf1e087a made rafts' combing not depend on nozzle_size (CURA-1097) 2016-03-14 13:16:04 +01:00
Tim Kuipers bc7ee74d19 made combing depend on inner wall line width instead of nozzle_size (CURA-1097) 2016-03-14 11:02:32 +01:00
Tim Kuipers fc20a6661b made rafts' combing not depend on nozzle_size (CURA-1097) 2016-03-14 10:37:46 +01:00
Ghostkeeper cffd6ac860 Spaces around minus operator
Conforming to code style.

Contributes to issue CURA-863.
2016-03-10 12:13:26 +01:00
Tim Kuipers 81d521a58b quickfix: remove outer wall offset based on nozzle size (CURA-1097) 2016-03-10 09:56:18 +01:00
Ghostkeeper 205c4f8cc9 Add test for new filter function
Contributes to issue CURA-590.
2016-03-09 14:38:23 +01:00
Ghostkeeper c797163536 Add more tests for findNearestObject
Contributes to issue CURA-590.
2016-03-09 14:28:14 +01:00
Ghostkeeper d31acdb244 Add first test for findNearestObject
Contributes to issue CURA-590.
2016-03-09 14:07:55 +01:00
Ghostkeeper 810f689418 Add tests for a group of points on a line
Contributes to issue CURA-590.
2016-03-09 13:02:41 +01:00
Ghostkeeper 7270290fe3 Improve findNearbyObjects test template
It now allows for some points for which the answer (near or far) is indeterminate.

Contributes to issue CURA-590.
2016-03-09 12:28:39 +01:00
Ghostkeeper 37e3114311 Add two simple tests for BucketGrid2D::findNearbyObjects
Contributes to issue CURA-590.
2016-03-09 12:16:16 +01:00
Ghostkeeper c3ef64fe18 Add initial test case for BucketGrid2D::findNearbyObjects
This is just an initial test and the testing framework for this unit.

Contributes to issue CURA-590.
2016-03-09 12:09:03 +01:00
Ghostkeeper 5d592553a6 Add test directory for infill
To make it complete for future tests that might appear there.
2016-03-09 11:00:03 +01:00
Ghostkeeper 38fad10453 Move utils tests to subdirectory
This keeps the same directory structure in the tests directory as in the source directory, as is common.
2016-03-09 10:50:10 +01:00
Tim Kuipers c4eb1d9f27 bugfix: uninitialised infill (CURA-1084)
not always did the basic infill_area get initialised, notably when there was no infill, which should be an empty polygon instead of no polygon
2016-03-08 17:52:12 +01:00
Ghostkeeper 1c16c77d56 Add test cases for moveInside
One of the edge cases currently fails.

Contributes to issue CURA-579.
2016-03-08 17:28:09 +01:00
Tim Kuipers 883f0c7419 current setting inheritance structure 2016-03-07 13:50:51 +01:00
Tim Kuipers bc11121a2e feat: ouput json inheritance structure 2016-03-07 13:50:51 +01:00
Tim Kuipers 0dbf80587b Merge branch '2.1' 2016-03-07 09:50:02 +01:00
Tim Kuipers 32d1bb6d75 bugfix: one-at-a-time printing went to z height of last position planned on the previous object (CURA-988) 2016-03-02 13:55:46 +01:00
Tim Kuipers afdb552f63 bugfix: retraction limitation segfaulted when retraction count == 1, cause it handled retraction count as if it was [retraction count - 1] (CURA-977) 2016-03-01 13:18:53 +01:00
Tim Kuipers a400ba28f2 fix: supportOnByuildplateOnly didn't account for conical support (CURA-914) 2016-03-01 12:06:54 +01:00
Tim Kuipers d18843abe3 fix: all settings now implicitly retrieved from meshgroup instead of explicitly (CURA-927) 2016-02-29 13:58:15 +01:00
Tim Kuipers ea12d310b0 fix: all settings retrieved from meshgroup instead of globally (CURA-927) 2016-02-29 13:54:36 +01:00
Tim Kuipers b993e4aff1 fix: support_roof_height was retrieved globally and per mesh - now only per mesh (CURA-956) 2016-02-29 13:39:35 +01:00
Tim Kuipers e0a7818d9e fix: infill wipe distance also on skin (CURA-964) 2016-02-29 13:03:42 +01:00
Tim Kuipers 277b5dce75 fix: get infill sparse combine per mesh (CURA-949) 2016-02-29 12:21:11 +01:00
Tim Kuipers 462a6e8c16 bugfix: skin didn't overlap with walls (CURA-941) 2016-02-29 12:16:02 +01:00
Tim Kuipers 20701117fb fix: support line width retrieved from same settings base everywhere (globally) (CURA-956) 2016-02-29 11:29:40 +01:00
Tim Kuipers a40d48c1be fix: initial layer speed for support requested from extruder train (CURA-956) 2016-02-29 11:18:20 +01:00
Tim Kuipers d7e966ad83 Merge branch 'analog10-master' 2016-02-29 10:40:58 +01:00
Tim Kuipers 593dd03987 Merge branch 'master' of https://github.com/analog10/CuraEngine into analog10-master 2016-02-29 10:37:19 +01:00
Tim Kuipers 07203c9d91 lil: removed unused const-incorrect function 2016-02-29 09:25:31 +01:00
David Bender 59e6a075e8 made a few intpoint methods const 2016-02-26 11:37:57 -05:00
David Bender 3f348ab1ba more const correctness for MeshGroup 2016-02-26 11:34:05 -05:00
David Bender 44fedbae7a make fpoint and fmatrix methods const 2016-02-26 11:33:29 -05:00
David Bender 77a378ba1c const cleanups in the Mesh class 2016-02-26 11:24:57 -05:00
David Bender 4f408847fb make members of settingRegistry.h const 2016-02-26 11:20:27 -05:00
Tim Kuipers 8d941063c1 fix: get raft settings from extruder train settingsbase; get extruder_nr settings with getSettingAsIndex instead of getSettingAsCount (CURA-956) 2016-02-25 20:04:56 +01:00
Tim Kuipers 471d20ff75 fix: print temp at startingCode based on extrudertrain settingsbase & lil bugfix '->' ==> '.' (CURA-956) 2016-02-25 19:55:59 +01:00
Tim Kuipers b82d6f9aff fix: retrieve machine_nozzle_size from extruder (CURA-956) 2016-02-25 18:41:24 +01:00
Tim Kuipers 277e1581d0 fix: retrieve all layer_height and layer_height_0 settings from meshgroup or global settings (CURA-956) 2016-02-25 18:32:35 +01:00
Tim Kuipers d4b128e0f3 fix: retrieve all layer_height settings from meshgroup or global settings (CURA-956) 2016-02-25 18:30:40 +01:00
Tim Kuipers eec65df83e refactored SliceMeshStorage storage ==> mesh (CURA-956) 2016-02-25 18:15:08 +01:00
Tim Kuipers 78e1c3114d refactor: introduce getSettingInMillimeters (CURA-956) 2016-02-25 18:07:39 +01:00
Tim Kuipers 5941d2252c fix: get infill sparse combine per mesh (CURA-949) 2016-02-25 10:21:44 +01:00
Tim Kuipers 6897a87584 fix: infill direction switch every two layers when infill_sparse_thickness is 2 layers and pattern is lines (CURA-943) 2016-02-25 09:49:51 +01:00
David Bender cc2bb36fb4 getSetting functions should be const 2016-02-24 11:01:57 -05:00
David Bender 0ea387a6f0 min/max functions should be const 2016-02-24 11:01:16 -05:00
Tim Kuipers 14a01a6253 fix: supportOnByuildplateOnly didn't account for conical support (CURA-914) 2016-02-24 16:07:32 +01:00
Tim Kuipers c20d35e293 fix: used adress comparison on ListPolygons instead of in depth comparison (CURA-934) 2016-02-23 16:23:09 +01:00
Tim Kuipers 9e56841cd2 fix: explicitly deleted polygon comparison, cause it is inefficient, and you most likely need to compare either the memory adress or need to account for the fact that two different polygons might have a different starting point (CURA-934) 2016-02-23 16:21:30 +01:00
Tim Kuipers c39e43c161 bugfix: combing shortcuts to end of comb move (CURA-893) 2016-02-23 15:38:33 +01:00
Tim Kuipers 421a6d4095 removed line from wrong cherry-pick (CURA-894) 2016-02-23 15:38:23 +01:00
Tim Kuipers 8497e46542 bugfix: moveInside always moved in the positive direction for the corner case (CURA-579) 2016-02-23 15:33:04 +01:00
Tim Kuipers 6510ebbd92 Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-02-22 17:27:06 +01:00
Tim Kuipers c1b4a5398b bugfix: small zgaps no-heuristic bugfixes (CURA-921)
It didn't create the right amount of top and bottom layers and didn't work correctly on the topmost and bottom most layers.
2016-02-22 17:26:57 +01:00
Arjen Hiemstra 11c4b9339a Store layer messages in a hash map to speed up lookups for layers 2016-02-22 17:23:17 +01:00
Tim Kuipers 75efbac68e fix: cone angle sign inverted: more sensible fix (CURA-869) 2016-02-22 17:08:04 +01:00
Tim Kuipers cd199dc43e fix: cone angle sign inverted (CURA-869) 2016-02-22 16:50:27 +01:00
Tim Kuipers e85eec54ec bugfix: combing shortcuts to end of comb move (CURA-893) 2016-02-22 15:57:29 +01:00
Tim Kuipers dcc4d956b2 feat: limit inside boundary to infill (CURA-694) 2016-02-22 15:35:12 +01:00
Tim Kuipers 91249dd012 refactor: infill_area ==> infill_area_per_combine; introduced infill_area for the whole infill area (CURA-694) 2016-02-22 15:34:39 +01:00
Tim Kuipers 4de1f1abdf removed old unused function (CURA-694) 2016-02-22 15:32:48 +01:00
Tim Kuipers 59abad0197 feat: refactor combing from bool into enum; introduced noskin (CURA-694) 2016-02-22 15:31:54 +01:00
Tim Kuipers 0dc7e326c9 refactor: made combPath.throughAir a property of all combPaths (CURA-893) 2016-02-22 11:27:56 +01:00
Tim Kuipers 3271bde77e lil 2016-02-19 16:13:03 +01:00
Tim Kuipers 7b71426839 refactor: const correctness loosely related to combing (CURA-893) 2016-02-19 15:30:29 +01:00
Tim Kuipers 27e3df2fbc fix: one combing calc changed avoid_other_parts for the next (CURA-893) 2016-02-19 15:06:50 +01:00
Tim Kuipers 2e915039e6 fix: is_inside info is retained after layer switch (CURA-893) 2016-02-19 14:38:37 +01:00
Tim Kuipers 8262ff3ac6 refactor/fix: call setIsInside only in addMeshLayerToGcode (CURA-893) 2016-02-19 12:19:57 +01:00
Tim Kuipers 5cc0eb24ef optimization: faster moveOutside - if possible (CURA-893) 2016-02-19 10:59:31 +01:00
Tim Kuipers dad74e1cd6 fix: crossing_2_in_or_mid was based on itself instead of closest to crossing_1 (CURA-893) 2016-02-18 18:33:05 +01:00
Tim Kuipers a878a7f091 fix: setIsInside bugs (CURA-893) 2016-02-18 18:27:48 +01:00
Tim Kuipers 53a543c548 lil 2016-02-18 17:26:15 +01:00
Tim Kuipers 0366b9df71 feat: skip crossing computation when boundary to boundary is already closer than twice the avoid distance (CURA-893) 2016-02-18 17:23:51 +01:00
Tim Kuipers 9c1f74fff1 fix: moveInside registered wrongly whether the point was already on the correct side of the boudary (CURA-893) 2016-02-18 16:49:52 +01:00
Tim Kuipers 1e0d416a5b lil fix: wrong move outside distance for crossings for combing (CURA-893) 2016-02-18 16:46:39 +01:00
Tim Kuipers 4612c69ae3 feat: moveInside utility function; directly calls moveInside (CURA-893) 2016-02-18 15:57:17 +01:00
Tim Kuipers 916e0b221d fix: larger admitted crossing dist for combing (CURA-893) 2016-02-18 15:51:16 +01:00
Tim Kuipers a05d31456d feat: also use dist from start to crossing when evaluating which crossing is the best (CURA-893) 2016-02-18 13:28:06 +01:00
Tim Kuipers 8d82b8b943 bugfix: lil mistake in combing second crossing (CURA-893) 2016-02-18 13:16:18 +01:00
Tim Kuipers 948c9b7054 refactor & fix: made findBestCrossing return ClosestPolygonPoints themselves which makes it easy to move inside/outisde with the offset_dist_to_get_from_on_the_polygon_to_outside (CURA-893) 2016-02-18 12:09:49 +01:00
Tim Kuipers 28d13b4aa1 bugfix: crossing dists were based on wrong value (CURA-893) 2016-02-18 12:07:59 +01:00
Tim Kuipers 0b0f85f9ff bugfix: moveInside couldn't perform moving outside well (CURA-579) 2016-02-17 17:59:33 +01:00
Tim Kuipers ef55f2ea11 bugfix: combing crossing computation refered to wrong crossing (CURA-579) 2016-02-17 17:23:56 +01:00
Tim Kuipers 692180e185 bugfix: combing crossing computation refered to wrong crossing (CURA-579) 2016-02-17 17:23:27 +01:00
Tim Kuipers e25a681201 lil refactor (CURA-893) 2016-02-17 17:13:29 +01:00
Tim Kuipers dca1beeba2 feat: combing: better finding of good crossing between inside and outide (CURA-893) 2016-02-17 16:45:22 +01:00
Tim Kuipers d10fea3ee6 refactor: modified findClose(Polygon ,...) such that it returns pairs of points on the first and points on the second polygon (CURA-893) 2016-02-17 16:04:51 +01:00
Tim Kuipers 1e93ffd83b feat: made Comb have an optional bucketGrid mapping from locations to line segments in the outside boundary (computed when needed) (CURA-893) 2016-02-17 15:56:44 +01:00
Tim Kuipers d41b842b39 refactor: introduced some const correctness for BucketGrid (CURA-893) 2016-02-17 15:43:30 +01:00
Tim Kuipers 59c3047543 feat: introduced findClose for a whole polygon (CURA-893) 2016-02-17 15:41:15 +01:00
Tim Kuipers b53f147b14 doc: findClosest & createLocToLineGrid (CURA-893) 2016-02-17 14:59:11 +01:00
Tim Kuipers 1768072cec unittest: findClose (CURA-893) 2016-02-17 14:45:01 +01:00
Tim Kuipers b2b4847b85 bugfix: findClose: end point of line segment was inserted instead of start point (CURA-893) 2016-02-17 14:43:09 +01:00
Tim Kuipers 3a832ef492 feat: findClose based on BucketGrid (CURA-893) 2016-02-17 12:33:00 +01:00
Tim Kuipers 03749e98ea fix: BucketGrid.insert expected reference instead of an object (CURA-893) 2016-02-17 12:15:03 +01:00
Tim Kuipers 9e410e7007 lil include reorder 2016-02-17 12:01:23 +01:00
Tim Kuipers beab605308 lil (CURA-579) 2016-02-16 17:35:46 +01:00
Tim Kuipers 9de4b7e939 fix: combing now uses correctly offsetted points from in_between (CURA-579) 2016-02-16 17:31:15 +01:00
Tim Kuipers 0d7710ecd1 refactor: made combing make use of new moveInside (CURA-579) 2016-02-16 17:21:22 +01:00
Tim Kuipers fe7364c146 refactor: simplified moveInside code (CURA-579)
make use of getBoundaryPointWithOffset
2016-02-16 17:16:24 +01:00
Tim Kuipers 98b1fda1f1 lil (CURA-579) 2016-02-16 16:56:11 +01:00
Tim Kuipers 151bef23c9 tests: better moveInside tests for both moveInside functions (CURA-579) 2016-02-16 16:51:14 +01:00
Tim Kuipers b9a411df10 bugfix: moveInside always moved in the positive direction for the corner case (CURA-579) 2016-02-16 16:43:43 +01:00
Tim Kuipers 0f53a7a231 tests of PolygonUtils::moveInside(ClosestPolygonPoint) (CURA-579) 2016-02-16 16:42:11 +01:00
Tim Kuipers 57ac6aa926 refactor: make new moveInside function work on ClosestPolygonPoint (CURA-579) 2016-02-16 14:47:00 +01:00
Tim Kuipers 2ba03ff1dc fixes: improved moveInside function for when you already found the nearest polygon point (CURA-579) 2016-02-16 14:25:33 +01:00
Tim Kuipers f59ca9c33e fixes: moveInside function for when you already found the nearest polygon point (CURA-579) 2016-02-16 13:39:46 +01:00
Tim Kuipers 8fc6ee87ee introduced moveInside function for when you already found the nearest polygon point (CURA-579) 2016-02-16 13:32:24 +01:00
Tim Kuipers 48707d95f7 refactor: some more renaming in combing (CURA-579) 2016-02-16 10:52:53 +01:00
Tim Kuipers 7a1a900d78 refactor: better naming for stuff like inside_middle_from (CURA-579) 2016-02-15 18:07:24 +01:00
Tim Kuipers 38c8941b59 Revert "fix: no move outside if it's a detour (CURA-579)"
This reverts commit f28cf53651.
2016-02-15 17:18:34 +01:00
Tim Kuipers df47cf8b2d refactor: typo iddle ==> middle (CURA-579) 2016-02-15 17:13:51 +01:00
Tim Kuipers f28cf53651 fix: no move outside if it's a detour (CURA-579) 2016-02-15 17:03:33 +01:00
Tim Kuipers 9d063d885c refactor: code indentation for readability (CURA-579) 2016-02-15 16:57:07 +01:00
Tim Kuipers 3ec63017cc refactor: getBoundaryOutside now returns ref instead of pointer, cause it ensures the return is instantiated (CURA-579) 2016-02-15 16:55:28 +01:00
Tim Kuipers 26dfd02b26 refactor: separate inside_middle_from computation from inside_middle_to comp (CURA-579) 2016-02-15 16:42:53 +01:00
Tim Kuipers e177303c4b Merge branch '2.1' 2016-02-15 15:20:30 +01:00
Ghostkeeper 4c1c43649d Fix setting-crash test with function evaluation
The minimum value, maximum value, minimum warning value and maximum warning value of each setting is now evaluated as a function, preventing casting errors. Runtest.py runs without errors or even test failures again now.

Contributes to issue CURA-814.
2016-02-15 14:05:27 +01:00
Ghostkeeper 2372a78c9b Fix setting-crash test with function evaluation
The minimum value, maximum value, minimum warning value and maximum warning value of each setting is now evaluated as a function, preventing casting errors. Runtest.py runs without errors or even test failures again now.

Contributes to issue CURA-814.
2016-02-15 12:54:44 +01:00
Tim Kuipers d3f0a06ee0 lil TODO (CURA-833) 2016-02-12 12:09:37 +01:00
Ghostkeeper 4f524613fd Merge pull request #304 from soyersoyer/master
fix build warnings
2016-02-12 09:51:34 +01:00
Tim Kuipers f94c95dd97 bugfix: total layers got updated by infill mehses CURA-833 2016-02-11 21:21:23 +01:00
Tim Kuipers 07b7d84df2 bugfixes new progress system (CURA-873) 2016-02-11 20:56:35 +01:00
Tim Kuipers 97ee04c12b lil fixes better progress estimator structure (CURA-873) 2016-02-11 20:13:21 +01:00
Tim Kuipers 18c7c6bdb9 fix: more secure layer indexing in infill mehses (CURA-833) 2016-02-11 20:01:38 +01:00
Tim Kuipers e93770017f refactor+cleanup for infill mehses (CURA-833) 2016-02-11 19:56:15 +01:00
Tim Kuipers 60e1f30c60 lil optimization: less splitIntoParts in processInfillMesh (CURA-833) 2016-02-11 19:47:56 +01:00
Tim Kuipers d4844d08f2 lil refactor: processDerivedWallSkinInfill doesn't have argument TimeKeeper anymore (CURA-833) 2016-02-11 19:46:06 +01:00
Tim Kuipers 30df9853e4 bugfix: infill meshes had too much infill overlap (CURA-833) 2016-02-11 18:59:46 +01:00
Tim Kuipers 4ff00a8f73 first approximation infill meshes (CURA-833) 2016-02-11 18:25:45 +01:00
Tim Kuipers f5b7cadcb5 refactor progress for better progress during skin and insets (CURA-873) 2016-02-11 17:44:24 +01:00
Tim Kuipers 17ca8fce0a fix: progress fixed for fffPolygonProcessor refactor
CURA-872

there is no progress information during processing insets and skin of a single mesh
2016-02-11 16:44:48 +01:00
Tim Kuipers dbdbec44cc refactor: split up slices2polygons in functions which work on each mesh separately (CURA-872) 2016-02-11 16:21:50 +01:00
soyer a9fdad71b4 SettingConfig’s parent is unused 2016-02-11 16:17:55 +01:00
soyer 9fb6a217a4 use the std::abs, it has a proper overload for the long long 2016-02-11 16:15:35 +01:00
soyer c480c96066 this is a function declaration, and this is useless here 2016-02-11 16:13:38 +01:00
Tim Kuipers 1bcb38dcb6 Merge pull request #303 from soyersoyer/master
fix build in the without arcus case
2016-02-11 15:22:34 +01:00
soyer 0e7b164532 without arcus the code can’t send SlicingFinished message, so do nothing. 2016-02-11 12:11:34 +01:00
soyer 0f6bdfd36e the static CommandSocket::instance should be set without arcus too 2016-02-11 12:08:22 +01:00
Tim Kuipers 4d79ea3e9e doc+refactor: fan speed calc more clear (CURA-863) 2016-02-10 17:00:57 +01:00
Tim Kuipers 199fa070d6 feat: findNearestObject with extra conditions (CURA-590) 2016-02-10 11:43:46 +01:00
Tim Kuipers ef1dece5d2 fix: BucketGrid2D: disregard bucket-collision items in findNearbyObjects (CURA-590) 2016-02-10 11:19:19 +01:00
Tim Kuipers 87e42fd9bd fix: BucketGrid2D: enhancement of hashing protocols (CURA-590) 2016-02-10 11:12:54 +01:00
Tim Kuipers 8d0a75779d doc; refactor: BucketGrid2D (CURA-590)
introduced typedef CellIdx to make clear which Point variables are used to signify a cell index
2016-02-10 11:11:47 +01:00
Tim Kuipers e882b23d76 Merge branch '2.1' 2016-02-09 17:08:34 +01:00
Tim Kuipers 142f4d519f Merge branch 'bugfix_coasting_prime' into 2.1 2016-02-08 16:28:50 +01:00
Arjen Hiemstra 9ea43e7fc1 Move addListener call to before message registration
This makes it possible to receive debug information about message registration
2016-02-07 18:56:28 +01:00
Arjen Hiemstra 9b92de9b8b Add an Arcus::SocketListener subclass so we can log all errors and debug 2016-02-04 12:16:30 +01:00
Tim Kuipers 4361dbf8fb better print time output 2016-02-03 18:02:34 +01:00
Tim Kuipers 81ae074b86 Merge branch '2.1' 2016-02-03 17:45:04 +01:00
Ghostkeeper 6826581497 Fix compile error
That needs to be a C-string.
2016-02-02 13:08:25 +01:00
Jaime van Kessel 4fead4612b Merge branch 'new_arcus_api' of github.com:Ultimaker/CuraEngine into 2.1 2016-02-02 11:25:45 +01:00
Ghostkeeper f763edfb05 Send FinishedSlicing message later
The FinishedSlicing message was being sent after the mesh group is done slicing, but it should've been sent after all slicing is done (also other mesh groups and after sending the metadata). This indicates that the slicer is really really done.

Contributes to issue CURA-427.
2016-02-01 10:21:53 +01:00
Ghostkeeper 0e662d7d67 Register SlicingFinished message type
The message type of this message is 8 (as documented in the proto file).

Contributes to issue CURA-427.
2016-02-01 10:21:53 +01:00
Ghostkeeper 94d8c3ff32 Document protobuf message typeid
Contributes to issue CURA-427.
2016-02-01 10:21:53 +01:00
Arjen Hiemstra 8e91753afc Ignore ObjectList messages with no objects and Objects with no vertices 2016-01-28 18:17:24 +01:00
Tim Kuipers 3171bd4dcb fix: infill overlap in mm (CURA-786) 2016-01-28 16:30:07 +01:00
Tim Kuipers 199007fa76 Merge branch '2.1' 2016-01-28 15:07:26 +01:00
Tim Kuipers 203eb05d7c bugfix: support overlapping with model for xy_distance=0 (CURA-795) 2016-01-28 13:22:23 +01:00
Tim Kuipers 9e75f8c70c fix: z distance used at overhang instead of xy-distance (CURA-795)
factored computeBasicAndFullOverhang out of generateSupportAreas
keep overhang areas in a rolling deque so that they are available for the current layer and the layer supportZDistanceTop above
implemented some polygon magic to ensure that the distance of support to overhang areas is less than from non-overhang areas
2016-01-28 13:12:24 +01:00
Tim Kuipers 93b3d2e46e refactor: made some functions const in sliceDataStorage (CURA-795) 2016-01-28 13:03:49 +01:00
Arjen Hiemstra 21e59cc1e2 Update CommandSocket with the new Arcus API 2016-01-28 03:24:12 +01:00
Tim Kuipers f0f14b0be3 fix: prime too slow after coasting due to unset speed (CURA-796) 2016-01-27 17:40:04 +01:00
Tim Kuipers a82c00bead fix: prime too much after coasting (CURA-796) 2016-01-27 17:39:37 +01:00
Tim Kuipers 14b1c5333a fix: retraction was prevented for non-direct support to support moves which did avoid other parts (CURA-777)
most notably I introduced path[0] == lastPosition && path[1] == p to the condistion; rest is just restruction
2016-01-27 12:16:20 +01:00
Tim Kuipers bbe809dabc fix: sendPolygons in coasting had a lil bug (CURA-778)
sendPolygons was called for lines toward the starting point instead of the new point

also a line was sent for the coasted path, which is actually just a move path
2016-01-25 17:08:45 +01:00
Tim Kuipers ed581a92b2 fix: reintroduced infill_overlap for the right features (CURA-765) 2016-01-25 16:38:47 +01:00
Tim Kuipers 9b68305851 refactor: matrix ==> rotation_matrix (CURA-401) 2016-01-25 12:01:09 +01:00
Tim Kuipers 940d3a86bd refactor: moved some implementation comments and renamed 'uneven' to 'odd' (CURA-401) 2016-01-25 11:27:52 +01:00
Tim Kuipers 55047120d8 refactor: split ZigZagConnectorProcessor into separate files (CURA-401) 2016-01-25 11:05:58 +01:00
Tim Kuipers e50b00fd73 fix: introduced new socket msg SlicingFinished (CURA-427) 2016-01-22 10:57:27 +01:00
Tim Kuipers 7377f30fd0 lil (remove unused var) 2016-01-21 10:26:24 +01:00
Tim Kuipers c9245e0926 Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-01-20 14:55:28 +01:00
Tim Kuipers 7149b7dbf1 fix: infill was overlapping with wall with incorrect amount; skin was incorrect when using a single wall and the outer wall line width differs from the inner walls (CURA-729) 2016-01-20 14:37:13 +01:00
Ghostkeeper daa3927a99 Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-01-20 14:34:13 +01:00
Ghostkeeper 074d1125e6 Fix STL header size
This was actually causing errors with loading STL files.

Sort of contributes to issue CURA-605.
2016-01-20 14:33:52 +01:00
Tim Kuipers a92274678d Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-01-20 11:22:36 +01:00
Tim Kuipers 081393d7f0 fix: offset issues (CURA-401) 2016-01-20 11:22:10 +01:00
Tim Kuipers 30da3097d0 lil code convention refactor (CURA-401) 2016-01-19 17:33:46 +01:00
Tim Kuipers d830fc515b lil 2016-01-19 17:28:47 +01:00
Tim Kuipers 5f2d924771 refactor: let fill_angle and line_distance be retrieved from Infill members (CURA-401) 2016-01-19 17:23:01 +01:00
Tim Kuipers b1ab1cae5a refactor: renamed variables to lower_case (code convention) (CURA-401) 2016-01-19 17:19:49 +01:00
Tim Kuipers 1fb6b20d90 refactor: let in_outline and outlineOffset be retrieved from Infill members (CURA-401) 2016-01-19 17:14:29 +01:00
Tim Kuipers dfb4c98e35 doc: infill documentation (CURA-401) 2016-01-19 13:40:21 +01:00
Tim Kuipers e455d63ad2 refactor: made infill generation functions public and let them use Infill member variables; also a bugfix where a PointMatrix was requested but a double was given (CURA-401) 2016-01-19 13:07:45 +01:00
Tim Kuipers cb024c73b1 refactor: made infill generation functions non-static (CURA-401) 2016-01-19 12:45:59 +01:00
Tim Kuipers d2d25058cb more comments for infill generation (CURA-401) 2016-01-19 12:29:12 +01:00
Tim Kuipers e85362370b more comments for (zigzag) infill generation (CURA-401) 2016-01-19 12:24:18 +01:00
Tim Kuipers 00c6f5c092 refactor: extrusionWidth ==> infill_line_width (CURA-401) 2016-01-18 17:29:14 +01:00
Tim Kuipers 818c7da951 lil comments (CURA-401) 2016-01-18 17:28:58 +01:00
Tim Kuipers 41723c8b38 removed unused registerPolyStart (CURA-401) 2016-01-18 17:22:10 +01:00
Tim Kuipers c8d75dd913 refactor: cleaned up inheritance structure of ZigZagConnectorProcessor classes (CURA-401)
removed code duplication by introducing another class called ActualZigzagConnectorProcessor.

explained the inheritance structure in the base class description.

made some things protected instead of public.
2016-01-18 16:49:39 +01:00
Tim Kuipers faa60c408f doc: documentation cleanup and expansion (CURA-401) 2016-01-18 15:27:40 +01:00
Tim Kuipers 7e322bc57c refactor: correction of tabs and spaces only (CURA-401) 2016-01-18 14:55:07 +01:00
Tim Kuipers 888fc54660 refactor: made all global infill functions private static (CURA-401) 2016-01-18 14:53:33 +01:00
Tim Kuipers fd660fcc11 refactor: connect_zigzags ==> connected_zigzags (cura-401) 2016-01-18 14:18:56 +01:00
Tim Kuipers e8080422a4 refactor: generateLineInfill_alt ==> generateLinearBasedInfill (CURA-401) 2016-01-18 14:16:33 +01:00
Tim Kuipers 5fecf2cd17 removed all old unused generateLine/ZigZagInfill code (CURA-401) 2016-01-18 14:15:26 +01:00
Tim Kuipers b4bf17c6be refactor: let rotation_matrix bubble down from Infill class; introduce some appropriate consts (CURA-401) 2016-01-18 14:07:38 +01:00
Ghostkeeper fabd658b53 STL file binary vs. ASCII detection robust against whitespace
The ASCII file may contain whitespace at the start of the file. This causes the STL file to be flagged as binary (since it doesn't start with "solid"). This fix first skips all whitespace before trying to find "solid".

Contributes to issue CURA-605.
2016-01-17 04:42:48 +01:00
Ghostkeeper a2050de513 Binary STL load use file size instead of face count
To determine the amount of memory allocated and the amount of faces to try to load, use the size of the file rather than the reported face count in the file. The reported face count may be missing or corrupt, in which case the engine would crash. If that happens now, it might miss one face. It will also give a warning if the reported face count does not match.

Contributes to issue CURA-605.
2016-01-17 04:09:14 +01:00
Tim Kuipers 9bfb5b17e9 refactor: made ZigzagConnectedEndpieces and ZigzagDisconnectgedEndpieces inherit from virtual ZigzagEndpieces; fix: several bugfixes (CURA-401)
notably the disconnected endpieces now disconnects all endpieces instead of half
2016-01-15 17:37:03 +01:00
Tim Kuipers e93d39d6d5 fix: disconnected endpieces (zigzag); reordered some of the connected endpieces code (CURA-401) 2016-01-15 17:16:46 +01:00
Tim Kuipers 175a65415a fix: support zigzag connected endpieces bugfixes (CURA-401)
before, only half of the endpieces were drawn

some problems had slipped into the translation, such as the resetting after each polygon
2016-01-15 16:53:39 +01:00
Tim Kuipers 74986dd95c lil refactor: changed last_var to this_var at the moment it was set for conceptual clarity (CURA-401) 2016-01-15 16:49:55 +01:00
Tim Kuipers 55dd35ae5e refactor: logic simplifications; fix: reintroduce skipping of scanline if poly is simple (CURA-401)
rewrote some for-if combinations which could be made simpler

small polygons which only cover a single scanline which are printed in total don't need the scanline...
2016-01-15 15:39:25 +01:00
Tim Kuipers 8caf810642 refactor: code conventions etc for generate(Lines/Zigzag)Infill (CURA-401) 2016-01-15 15:23:41 +01:00
Tim Kuipers 76efc41407 refactor: merge of generate(Lines/ZigZag)Infill (CURA-401) 2016-01-15 14:50:24 +01:00
Tim Kuipers b0a0fe8f30 refactor: code conventions in generate infill paths (CURA-401) 2016-01-14 11:17:06 +01:00
Tim Kuipers 653b631ffd lil 2016-01-14 11:16:36 +01:00
Tim Kuipers b9a01ed031 bugfix: made MargeInfill.isConvertible not static, cause it needs the nozzle_size class member (CURA-581) 2016-01-13 12:10:37 +01:00
Tim Kuipers de9d3bb447 lil fix: MergeInfill.nozzle_size used instead of line_width (CURA-581)
MergeInfillLines already had a member nozzle_size, though still it had a line defining a local variable 'int nozzle_size = line_width; // TODO'

Also some minor code convention brackets...
2016-01-13 11:50:47 +01:00
Arjen Hiemstra 8f5a46f77d Ensure we use libc++ as stdlib on OSX 2016-01-06 16:56:04 +01:00
Tim Kuipers d0858bbdb6 merge of 2.1 2016-01-06 15:03:29 +01:00
Tim Kuipers c22793b5d7 Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2016-01-05 18:22:52 +01:00
Tim Kuipers 1e684f23a7 refactor: removed old sendPolygons functions (CURA-379) 2016-01-05 18:22:34 +01:00
Tim Kuipers 7d0025975b refactor: removed old sendPolygons functions (CURa-379) 2016-01-05 18:20:44 +01:00
Tim Kuipers 5c892b564b fix: send all polygons at end of slicing process instead of during (CURA-379) 2016-01-05 18:17:03 +01:00
Tim Kuipers d5327ec3f1 refactor: let all CommandSocket calls go throught CommandSocket.getInstance() (CURA-379) 2016-01-05 17:35:12 +01:00
Tim Kuipers c48104bc86 refactor: made CommandSocket a kind of singleton class (CURA-379) 2016-01-05 17:09:08 +01:00
Tim Kuipers f58f1daec3 refactor: commandSocket ==> command_socket (CURA-379) 2016-01-05 17:08:24 +01:00
Tim Kuipers 669bb523a3 bugfix: commandSocket depends on there being a NoneType (CURA-581) 2016-01-05 13:07:26 +01:00
Tim Kuipers fa74f672ac lil 2016-01-05 12:23:44 +01:00
Tim Kuipers e224d9c853 MergeInfillLines early abort if space filling type is not Lines (CURA-581) 2016-01-05 12:23:10 +01:00
Tim Kuipers 338d80a7a9 lil fix in test (CURA-581) 2016-01-05 12:20:46 +01:00
Tim Kuipers 87123dac31 introduction of GCOdePath.space_fill_type (Polygon,Line or PolyLine) (CURA-581) 2016-01-05 12:20:09 +01:00
Tim Kuipers 73de288f44 lil cleanup of unused commented out code (CURA-581) 2016-01-05 11:30:43 +01:00
Tim Kuipers 9f5b5f405d lil enhancements mergeInfillLines (CURA-581) 2016-01-05 11:27:06 +01:00
Tim Kuipers 2850b34227 fix: mergeInfillLines aborts if applied to a print feature other than infill or skin (CURA-581) 2016-01-05 11:23:51 +01:00
Tim Kuipers 072d320f1d refactor: FeatureType ==> PrintFeatureType (CURA-581) 2016-01-05 11:11:39 +01:00
Tim Kuipers 8e4b61d2a5 merge of 4c139d6441 (CURA-581) 2016-01-05 11:10:56 +01:00
Tim Kuipers ba4e26f801 bugfix: concentric infill overlapped with skin; extra offset for concentric infill moved inside infill.cpp (CURA-650) 2016-01-05 10:04:33 +01:00
Tim Kuipers cea0a0a98f bugfix: no draft shield or concentric infill sendPolygons (CURA-639) 2016-01-04 16:55:41 +01:00
Ghostkeeper 2b51a11739 Fix new command socket not propagating to LayerPlanBuffer
This caused the command socket in LayerPlanBuffer to remain null, thus never flushing the g-code until the very end, thus causing the front-end to interpret the entire g-code as one layer, thus causing the post processing plugin to inject g-code at the wrong places.

Contributes to issue CURA-443.
2015-12-31 11:22:37 +01:00
Tim Kuipers cc23d73532 refactor: FeatureType ==> PrintFeatureType (CURA-606) 2015-12-18 16:32:13 +01:00
Tim Kuipers 4c139d6441 refactor: PolygonType ==> FeatureType in PrintFeature.h (CURA-606) 2015-12-18 16:32:02 +01:00
Tim Kuipers 13a18549bf Merge branch '2.1' 2015-12-18 14:32:47 +01:00
Tim Kuipers d32443ca9b bugfixes: merge infill (CURA-581) 2015-12-18 14:25:07 +01:00
Tim Kuipers 792aa9e8e8 merge infill improvements (CURA-581) 2015-12-18 12:50:50 +01:00
Tim Kuipers a63abb4e88 merge infill improvements maybe (CURA-581) 2015-12-18 10:49:12 +01:00
Tim Kuipers 9f82f58f03 bugfix: moveInside called with max_dist instead of max_dist_squared (CURA-522) 2015-12-15 16:33:51 +01:00
Tim Kuipers bd2f66e2eb bugfix: child settings got duplicated in extruder trains... (CURA-494) 2015-12-14 15:29:26 +01:00
Tim Kuipers 267eb7aef0 bugfix: made engine work both both extruder trains being an array as it being an object (CURA-494) 2015-12-14 14:14:08 +01:00
Tim Kuipers df04467ab1 better doc (CURA-522) 2015-12-09 17:24:05 +01:00
Tim Kuipers bbd9412b5f bugfixes moveInside (CURA-522) 2015-12-09 17:23:50 +01:00
Tim Kuipers c476acd522 bugfix: moveInside distance was BS (CURA-522) 2015-12-09 17:22:50 +01:00
Tim Kuipers 278efdeb39 merge of cherry-pick of 6115bde (CURA-522) 2015-12-09 17:22:09 +01:00
Tim Kuipers bb8a9dacba removed Comb.moveInside and Comb.isInside and inlined the implementation (CURA-522)
Since comb_boundary_inside is now a field of gcodeplanner these utility functions were at an awkward place.

Conflicts:
	src/gcodePlanner.cpp
	src/gcodePlanner.h
2015-12-09 17:18:55 +01:00
Tim Kuipers 42420edeed merge of cherry-pick of 5c3727d (CURA-522) 2015-12-09 17:11:56 +01:00
Tim Kuipers be2e96f3fd getLayerSecondOrInnermostWalls functions (CURA-522) 2015-12-09 17:04:50 +01:00
Tim Kuipers 18adc0bbc9 merge of cherry-pick of c7ce43e (CURA-522) 2015-12-09 17:02:37 +01:00
Tim Kuipers e7824faefe merge of cherry-pick of c7ce43e (CURA-522) 2015-12-09 17:01:37 +01:00
Tim Kuipers 7199be1b4f merge of cherry-pick of d9e2b39 (CURA-522) 2015-12-09 16:54:13 +01:00
Tim Kuipers 8cd48bf5a2 settingsRegistry reorganized and made more robust; more stuff will override if possible; extruder trains can now be overridden (CURA-494) 2015-12-09 16:27:31 +01:00
Tim Kuipers a766455ec8 lil (CURA-494) 2015-12-09 16:24:47 +01:00
Tim Kuipers af08b57799 makefile now copies command_line_settings.json to binary dir (CURA-566) 2015-12-09 09:37:29 +01:00
Tim Kuipers dbecb29dc8 command line settings json (CURA-566) 2015-12-09 09:06:29 +01:00
Tim Kuipers 7df0a34464 lil bugfix settingsRegistry (CURA-566) 2015-12-09 09:05:39 +01:00
Tim Kuipers 925d50fc5d removed prime_tower_distance (was already unused) (CURA-566) 2015-12-09 09:05:11 +01:00
Tim Kuipers e3163586af Merge of branch 2.1 2015-12-08 16:24:53 +01:00
Tim Kuipers 727c863f1a optimization: handle socket object list after listening for messages (CURA-441) 2015-12-08 15:58:00 +01:00
Tim Kuipers d732c49dd7 bugfix: close socket before exiting the program (CURA-441) 2015-12-08 15:57:26 +01:00
Tim Kuipers 781fc5ed7b lil doc (CURA-524) 2015-12-08 14:48:19 +01:00
Tim Kuipers 7243cf6da4 renamed commandSocket.d to commandSocket.private_data (CURA-524) 2015-12-08 14:44:15 +01:00
Tim Kuipers 1cdcce4205 revert of 6224713998 (CURA-524) 2015-12-08 14:42:00 +01:00
Tim Kuipers acf381c008 bugfix: no vizualization of last layers trvel moves (CURA-524) 2015-12-08 14:29:44 +01:00
Tim Kuipers 4b7df9ddc0 lil refac + doc (CURA*524) 2015-12-08 14:28:52 +01:00
Tim Kuipers 7788a4a234 refactor: sendGCodeLayer ==> flushGcode (CURA-524) 2015-12-08 14:28:20 +01:00
Tim Kuipers 6224713998 renamed commandSocket.d to commandSocket.private_data (CURA-524) 2015-12-08 13:53:22 +01:00
Tim Kuipers db8b30d77a refactor: Min Volume Before Coasting doesn't include Coasting Volume anymore (CURA-528) 2015-12-08 13:32:31 +01:00
Tim Kuipers f58441a6ad refactor: added braces for checks of command_socket (CURA-499) 2015-12-08 13:16:03 +01:00
Tim Kuipers 050b9c88f2 bugfix: coasting volume more than min volume (CURA-528) 2015-12-07 18:03:40 +01:00
Ghostkeeper 8ac63fca6e Log a warning when trying to override nonexistent setting
If there's a problem in the front-end this should expose it.

Contributes to issue CURA-544.
2015-12-07 15:38:21 +01:00
Ghostkeeper 1383882bc5 Fixed segfault when provided with unknown settings
When an override of a setting is provided via the JSON the engine would crash. This ignores those settings.

Contributes to issue CURA-544.
2015-12-07 15:18:39 +01:00
Tim Kuipers 04b4b2c057 merge 2015-12-07 13:42:31 +01:00
Tim Kuipers 3a773d3c0f bugfix: layer plan buffer flush did flush water, but left the turd (CURA-463) 2015-12-07 12:39:25 +01:00
Tim Kuipers 734ddce3c8 lil (CURA-463) 2015-12-07 12:38:14 +01:00
Tim Kuipers 0b19936299 main didn't allow for next meshgroup to be processed (CURA-463) 2015-12-07 12:37:02 +01:00
Tim Kuipers 691d5de591 lil doc (CURA-499) 2015-12-04 17:04:45 +01:00
Tim Kuipers 490cef1a5c Merge branch '2.1' of https://github.com/Ultimaker/CuraEngine into 2.1 2015-12-04 16:57:00 +01:00
Tim Kuipers b777b55935 bugfix: output command line call (CURA-499) 2015-12-04 16:56:49 +01:00
Ghostkeeper 0f5fd8d6ca Merge branch 'master' of https://github.com/Ultimaker/CuraEngine 2015-12-04 16:47:16 +01:00
Ghostkeeper 645b06271d Remove support-specific test
Support is already tested somewhat in the default test model. This makes the testing a bit more efficient.

Contributes to issue CURA-349.
2015-12-04 16:46:59 +01:00
Ghostkeeper 0428c08152 Fix indenting
The main function of runtest.py was indented with tabs instead of spaces.
2015-12-04 15:58:53 +01:00
Tim Kuipers ef61337ef8 better doc (CURA-522) 2015-12-04 13:55:08 +01:00
Tim Kuipers 20c74dd22d lil bugfix CURA-486 (stiekum gekoppeld) 2015-12-03 18:47:12 +01:00
Tim Kuipers 188b190d21 inlined writePathWithCoasting (CURA-486) 2015-12-03 18:05:29 +01:00
Tim Kuipers 1cd128decd coasting collapsed: no more diff between move-coasting and retract-coasting (CURA-486) 2015-12-03 18:01:34 +01:00
Tim Kuipers 925247a54d bugfix: don't perform the retraction *during* coasting (CURA-486) 2015-12-03 18:00:34 +01:00
TotalRetribution fb2dac0f96 Cleaned up White space in processInsets 2015-11-18 13:26:33 +00:00
TotalRetribution e2e9cf8ea8 Merge remote-tracking branch 'origin/master' into reverse_inset_order 2015-11-18 11:51:18 +00:00
TotalRetribution 57ec92a645 Merge remote-tracking branch 'origin/master' into reverse_inset_order 2015-11-13 11:13:26 +00:00
TotalRetribution 6a26649fe4 Merged and fixed Conflict with outer_inset_first option in src/FffGcodeWriter.cpp 2015-08-25 15:12:28 +01:00
TotalRetribution 5334fb881e Merge remote-tracking branch 'origin/master' into reverse_inset_order 2015-08-21 15:49:01 +01:00
TotalRetribution bc9d7aced8 Added: Option to print outer inset first. 2015-08-19 10:35:09 +01:00
TotalRetribution 5bb794dc91 Merge remote-tracking branch 'origin/master' into reverse_inset_order
Conflicts:
	src/fffProcessor.h
	src/settings.cpp
	src/settings.h
2015-08-19 10:32:04 +01:00
TotalRetribution 7d928703a5 Changed option name enableReverseInsetOrder to outerInsetFirst to better explain its function. 2015-04-07 09:59:55 +01:00
TotalRetribution 8961df4342 Add option to Reverse Inset Print Order 2015-03-27 13:36:16 +00:00
206 arquivos alterados com 23068 adições e 1934195 exclusões
+22
Ver Arquivo
@@ -7,15 +7,36 @@
NUL
*.gcode
## Directories used for other stuff
Trash/*
output/*
callgrind/*
## Building result.
build/*
debug_build/*
*.pyc
*.exe
*.a
*.o
CuraEngine
_bin
_obj
## CMake files
cmake_install.cmake
CMakeCache.txt
CMakeFiles/
CPackSourceConfig.cmake
# Visual Studio files generated by CMake
*.vcxproj
*.vcxproj.filters
CuraEngine.sln
# Makefile generated by CMake
Makefile
## IDE project files.
CuraEngine.layout
CuraEngine.cbp
@@ -32,3 +53,4 @@ documentation/latex/*
## Test results.
tests/output.xml
callgrind.out.*
+79 -11
Ver Arquivo
@@ -17,6 +17,10 @@ else()
set(CMAKE_CXX_FLAGS "-std=c++11")
endif()
if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CURA_ENGINE_VERSION "master" CACHE STRING "Version name of Cura")
@@ -24,9 +28,11 @@ set(CURA_ENGINE_VERSION "master" CACHE STRING "Version name of Cura")
option(BUILD_TESTS OFF)
# Add a compiler flag to check the output for insane values if we are in debug mode.
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Building debug release of CuraEngine.")
add_definitions(-DASSERT_INSANE_OUTPUT)
if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message(STATUS "Building debug release of CuraEngine.")
add_definitions(-DASSERT_INSANE_OUTPUT)
add_definitions(-DUSE_CPU_TIME)
add_definitions(-DDEBUG)
endif()
# Add warnings
@@ -36,21 +42,33 @@ 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)
set(engine_SRCS # Except main.cpp.
src/bridge.cpp
src/comb.cpp
src/commandSocket.cpp
src/ConicalOverhang.cpp
src/ExtruderTrain.cpp
src/FffGcodeWriter.cpp
src/FffPolygonGenerator.cpp
src/FffProcessor.cpp
src/gcodeExport.cpp
src/GCodePathConfig.cpp
src/gcodePlanner.cpp
src/infill.cpp
src/inset.cpp
src/WallsComputation.cpp
src/layerPart.cpp
src/LayerPlanBuffer.cpp
src/MergeInfillLines.cpp
@@ -58,31 +76,67 @@ set(engine_SRCS # Except main.cpp.
src/MeshGroup.cpp
src/multiVolumes.cpp
src/pathOrderOptimizer.cpp
src/Preheat.cpp
src/PrimeTower.cpp
src/Progress.cpp
src/raft.cpp
src/settingRegistry.cpp
src/settings.cpp
src/skin.cpp
src/skirt.cpp
src/SkirtBrim.cpp
src/sliceDataStorage.cpp
src/slicer.cpp
src/support.cpp
src/timeEstimate.cpp
src/WallsComputation.cpp
src/wallOverlap.cpp
src/Weaver.cpp
src/Wireframe2gcode.cpp
src/infill/NoZigZagConnectorProcessor.cpp
src/infill/ZigzagConnectorProcessorConnectedEndPieces.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
src/settings/PathConfigStorage.cpp
src/settings/SettingConfig.cpp
src/settings/SettingContainer.cpp
src/settings/SettingRegistry.cpp
src/settings/settings.cpp
src/utils/AABB.cpp
src/utils/AABB3D.cpp
src/utils/Date.cpp
src/utils/gettime.cpp
src/utils/LinearAlg2D.cpp
src/utils/ListPolyIt.cpp
src/utils/logoutput.cpp
src/utils/PolygonProximityLinker.cpp
src/utils/polygonUtils.cpp
src/utils/polygon.cpp
src/utils/ProximityPointLink.cpp
)
# List of tests. For each test there must be a file tests/${NAME}.cpp and a file tests/${NAME}.h.
set(engine_TEST
GCodePlannerTest
GCodePlannerTest
)
set(engine_TEST_INFILL
)
set(engine_TEST_UTILS
SparseGridTest
LinearAlg2DTest
PolygonUtilsTest
PolygonTest
StringTest
)
# Generating ProtoBuf protocol
@@ -114,10 +168,24 @@ if (BUILD_TESTS)
target_link_libraries(${test} _CuraEngine cppunit)
add_test(${test} ${test})
endforeach()
foreach (test ${engine_TEST_INFILL})
add_executable(${test} tests/main.cpp tests/infill/${test}.cpp)
target_link_libraries(${test} _CuraEngine cppunit)
add_test(${test} ${test})
endforeach()
foreach (test ${engine_TEST_UTILS})
add_executable(${test} tests/main.cpp tests/utils/${test}.cpp)
target_link_libraries(${test} _CuraEngine cppunit)
add_test(${test} ${test})
endforeach()
endif()
add_custom_command(TARGET CuraEngine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:CuraEngine>)
# Installing CuraEngine.
include(GNUInstallDirs)
install(TARGETS CuraEngine DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CPackConfig.cmake)
+64 -40
Ver Arquivo
@@ -2,20 +2,27 @@ syntax = "proto3";
package cura.proto;
message ObjectList
message ObjectList
{
repeated Object objects = 1;
repeated Setting settings = 2;
repeated Setting settings = 2; // meshgroup settings (for one-at-a-time printing)
}
// typeid 1
message Slice
{
repeated ObjectList object_lists = 1;
repeated ObjectList object_lists = 1; // The meshgroups to be printed one after another
SettingList global_settings = 2; // The global settings used for the whole print job
repeated Extruder extruders = 3; // The settings sent to each extruder object
repeated SettingExtruder limit_to_extruder = 4; // From which stack the setting would inherit if not defined per object
}
message Object
message Extruder
{
int32 id = 1;
SettingList settings = 2;
}
message Object
{
int64 id = 1;
bytes vertices = 2; //An array of 3 floats.
@@ -24,32 +31,17 @@ message Object
repeated Setting settings = 5; // Setting override per object, overruling the global settings.
}
// typeid 3
message Progress
message Progress
{
float amount = 1;
}
// typeid 2
message SlicedObjectList
{
repeated SlicedObject objects = 1;
}
message SlicedObject
{
int64 id = 1;
repeated Layer layers = 2;
}
message Layer {
int32 id = 1;
float height = 2; // Z position
float thickness = 3; // height of a single layer
float height = 2;
float thickness = 3;
repeated Polygon polygons = 4;
repeated Polygon polygons = 4; // layer data
}
message Polygon {
@@ -64,37 +56,69 @@ message Polygon {
SupportInfillType = 7;
MoveCombingType = 8;
MoveRetractionType = 9;
SupportInterfaceType = 10;
}
Type type = 1;
bytes points = 2;
float line_width = 3;
Type type = 1; // Type of move
bytes points = 2; // The points of the polygon, or two points if only a line segment (Currently only line segments are used)
float line_width = 3; // The width of the line being laid down
}
// typeid 4
message LayerOptimized {
int32 id = 1;
float height = 2; // Z position
float thickness = 3; // height of a single layer
repeated PathSegment path_segment = 4; // layer data
}
message PathSegment {
int32 extruder = 1; // The extruder used for this path segment
enum PointType {
Point2D = 0;
Point3D = 1;
}
PointType point_type = 2;
bytes points = 3; // The points defining the line segments, bytes of float[2/3] array of length N+1
bytes line_type = 4; // Type of line segment as an unsigned char array of length 1 or N, where N is the number of line segments in this path
bytes line_width = 5; // The widths of the line segments as bytes of a float array of length 1 or N
}
message GCodeLayer {
int64 id = 1;
bytes data = 2;
}
// typeid 5
message ObjectPrintTime {
int64 id = 1;
float time = 2;
float material_amount = 3;
message PrintTimeMaterialEstimates { // The print time for the whole print and material estimates for the extruder
float time = 1; // Total time estimate
repeated MaterialEstimates materialEstimates = 2; // materialEstimates data
}
message MaterialEstimates {
int64 id = 1;
float material_amount = 2; // material used in the extruder
}
// typeid 6
message SettingList {
repeated Setting settings = 1;
}
message Setting {
string name = 1;
string name = 1; // Internal key to signify a setting
bytes value = 2;
bytes value = 2; // The value of the setting
}
message SettingExtruder {
string name = 1; //The setting key.
int32 extruder = 2; //From which extruder stack the setting should inherit.
}
// typeid 7
message GCodePrefix {
bytes data = 2;
bytes data = 2; //Header string to be prepended before the rest of the g-code sent from the engine.
}
message SlicingFinished {
}
+2 -2
Ver Arquivo
@@ -178,7 +178,7 @@ JAVADOC_AUTOBRIEF = NO
# requiring an explicit \brief command for a brief description.)
# The default value is: NO.
QT_AUTOBRIEF = NO
QT_AUTOBRIEF = YES
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
@@ -832,7 +832,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).
IMAGE_PATH = documentation/assets
IMAGE_PATH = docs/assets
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
+22 -14
Ver Arquivo
@@ -19,46 +19,54 @@ But in general it boils down to: You need to share the source of any CuraEngine
How to Install
==============
1. Clone the repository from https://github.com/Ultimaker/CuraEngine.git (the URL at the right hand side of this page).
2. Install Protobuf (see below)
2. Install Protobuf >= 3.0.0 (see below)
3. Install libArcus (see https://github.com/Ultimaker/libArcus)
In order to compile CuraEngine, either use CMake or start a project in your preferred IDE.
CMake compilation:
1. Navigate to the CuraEngine directory and execute the following commands
2. $ mkdir build && cd build
3. $ cmake ..
4. $ make
2. ```$ mkdir build && cd build```
3. ```$ cmake ..```
4. ```$ make```
Project files generation:
1. Navigate to the CuraEngine directory and execute the following commands
2. cmake . -G "CodeBlocks - Unix Makefiles"
2. ```cmake . -G "CodeBlocks - Unix Makefiles"```
3. (for a list of supported IDE's see http://www.cmake.org/Wiki/CMake_Generator_Specific_Information#Code::Blocks_Generator)
Installing Protobuf
-------------------
1. Be sure to have libtool installed.
2. Download protobuf from https://github.com/google/protobuf/ (download ZIP and unZIP at desired location, or clone the repo) The protocol buffer is used for communication between the CuraEngine and the GUI.
3. Before installing protobuf, change autogen.sh : comment line 18 to line 38 using '#'s. This removes the dependency on gtest-1.7.0.
4. Run autogen.sh from the protobuf directory:
$ ./autogen.sh
5. $ ./configure
6. $ make
7. $ make install # Requires superused priviliges.
8. (In case the shared library cannot be loaded, you can try "sudo ldconfig" on Linux systems)
2. Download protobuf from https://github.com/google/protobuf/releases (download ZIP and unZIP at desired location, or clone the repo). The protocol buffer is used for communication between the CuraEngine and the GUI.
3. Run ```autogen.sh``` from the protobuf directory:
```$ ./autogen.sh```
4. ```$ ./configure```
5. ```$ make```
6. ```# make install```
(Please note the ```#```. It indicates the need of superuser, as known as root, priviliges.)
7. (In case the shared library cannot be loaded, you can try ```sudo ldconfig``` on Linux systems)
Running
=======
Other than running CuraEngine from a frontend, such as Ultimaker/Cura, one can run CuraEngine from the command line.
For that one needs a settings JSON file, which can be found in the Ultimaker/Cura repository.
Note that the structure of the json files has changed since 2.1. In the corresponding branch of the Cura repository you can find how the json files used to be structured.
An example run for an UM2 machine looks as follows:
* Navigate to the CuraEngine directory and execute the following
```
./build/CuraEngine slice -v -j ../Cura/resources/machines/dual_extrusion_printer.json -o "output/test.gcode" -e1 -s infill_line_distance=0 -e0 -l "/model_1.stl" -e1 -l "fully_filled_model.stl"
./build/CuraEngine slice -v -j ../Cura/resources/definitions/dual_extrusion_printer.def.json -o "output/test.gcode" -e1 -s infill_line_distance=0 -e0 -l "/model_1.stl" -e1 -l "fully_filled_model.stl"
```
Run `CuraEngine help` for a general description of how to use the CuraEngine tool.
[Set the environment variable](https://help.ubuntu.com/community/EnvironmentVariables) CURA_ENGINE_SEARCH_PATH to the appropriate paths, delimited by a colon e.g.
```
CURA_ENGINE_SEARCH_PATH=/path/to/Cura/resources/definitions:/user/defined/path
```
Internals
=========

Antes

Largura:  |  Altura:  |  Tamanho: 18 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 18 KiB

Arquivo binário não exibido.

Depois

Largura:  |  Altura:  |  Tamanho: 70 KiB

Antes

Largura:  |  Altura:  |  Tamanho: 20 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 20 KiB

+1 -1
Ver Arquivo
@@ -7,4 +7,4 @@ This is the documentation for CuraEngine, the back-end slicer of Cura.
[Glossary](documentation/glossary.md)
[Code Conventions](documentation/code_conventions.md)
[Code Conventions](https://github.com/Ultimaker/Meta/blob/master/code_conventions.md)
-1
Ver Arquivo
@@ -1 +0,0 @@
html/index.html
+19 -21
Ver Arquivo
@@ -1,26 +1,24 @@
The Clipper Library (including Delphi, C++ & C# source code, other accompanying
code, examples and documentation), hereafter called "the Software", has been
released under the following license, terms and conditions:
Boost Software License - Version 1.0 - August 17th, 2003
http://www.boost.org/LICENSE_1_0.txt
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the Software covered by this license to use, reproduce,
display, distribute, execute, and transmit the Software, and to prepare
derivative works of the Software, and to permit third-parties to whom the
Software is furnished to do so, all subject to the following:
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including the
above license grant, this restriction and the following disclaimer, must be
included in all copies of the Software, in whole or in part, and all derivative
works of the Software, unless such copies or derivative works are solely in the
form of machine-executable object code generated by a source language processor.
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY
DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+34 -3
Ver Arquivo
@@ -1,8 +1,39 @@
=====================================================================
Clipper Change Log
=====================================================================
v6.2.1 (31 October 2014) Rev 482
* Bugfix in ClipperOffset.Execute where the Polytree.IsHole property
was returning incorrect values with negative offsets
* Very minor improvement to join rounding in ClipperOffset
* Fixed CPP OpenGL demo.
v6.1.3 (19 January 2014)
v6.2.0 (17 October 2014) Rev 477
* Numerous minor bugfixes, too many to list.
(See revisions 454-475 in Sourceforge Repository)
* The ZFillFunction (custom callback function) has had its parameters
changed.
* Curves demo removed (temporarily).
* Deprecated functions have been removed.
v6.1.5 (26 February 2014) Rev 460
* Improved the joining of output polygons sharing a common edge
when those common edges are horizontal.
* Fixed a bug in ClipperOffset.AddPath() which would produce
incorrect solutions when open paths were added before closed paths.
* Minor code tidy and performance improvement
v6.1.4 (6 February 2014)
* Fixed bugs in MinkowskiSum
* Fixed minor bug when using Clipper.ForceSimplify.
* Modified use_xyz callback so that all 4 vertices around an
intersection point are now passed to the callback function.
v6.1.3a (22 January 2014) Rev 453
* Fixed buggy PointInPolygon function (C++ and C# only).
Note this bug only affected the newly exported function, the
internal PointInPolygon function used by Clipper was OK.
v6.1.3 (19 January 2014) Rev 452
* Fixed potential endless loop condition when adding open
paths to Clipper.
* Fixed missing implementation of SimplifyPolygon function
@@ -13,11 +44,11 @@ v6.1.3 (19 January 2014)
* Overloaded MinkowskiSum function to accommodate multi-contour
paths.
v6.1.2 (15 December 2013)
v6.1.2 (15 December 2013) Rev 444
* Fixed broken C++ header file.
* Minor improvement to joining polygons.
v6.1.1 (13 December 2013)
v6.1.1 (13 December 2013) Rev 441
* Fixed a couple of bugs affecting open paths that could
raise unhandled exceptions.
+388 -534
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+33 -36
Ver Arquivo
@@ -1,8 +1,8 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.1.3a *
* Date : 22 January 2014 *
* Version : 6.2.1 *
* Date : 31 October 2014 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2014 *
* *
@@ -34,7 +34,7 @@
#ifndef clipper_hpp
#define clipper_hpp
#define CLIPPER_VERSION "6.1.3"
#define CLIPPER_VERSION "6.2.0"
//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
//improve performance but coordinate values are limited to the range +/- 46340
@@ -44,11 +44,10 @@
//#define use_xyz
//use_lines: Enables line clipping. Adds a very minor cost to performance.
//#define use_lines
#define use_lines
//use_deprecated: Enables support for the obsolete OffsetPaths() function
//which has been replace with the ClipperOffset class.
#define use_deprecated
//use_deprecated: Enables temporary support for the obsolete functions
//#define use_deprecated
#include <vector>
#include <set>
@@ -57,6 +56,7 @@
#include <cstdlib>
#include <ostream>
#include <functional>
#include <queue>
namespace ClipperLib {
@@ -69,11 +69,16 @@ enum PolyType { ptSubject, ptClip };
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
#ifdef use_int32
typedef int cInt;
typedef unsigned int cUInt;
typedef int cInt;
static cInt const loRange = 0x7FFF;
static cInt const hiRange = 0x7FFF;
#else
typedef signed long long cInt;
typedef unsigned long long cUInt;
typedef signed long long cInt;
static cInt const loRange = 0x3FFFFFFF;
static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
typedef signed long long long64; //used by Int128 class
typedef unsigned long long ulong64;
#endif
struct IntPoint {
@@ -117,15 +122,12 @@ struct DoublePoint
//------------------------------------------------------------------------------
#ifdef use_xyz
typedef void (*TZFillCallback)(IntPoint& z1, IntPoint& z2, IntPoint& pt);
typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
#endif
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
enum JoinType {jtSquare, jtRound, jtMiter};
enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
#ifdef use_deprecated
enum EndType_ {etClosed, etButt = 2, etSquare, etRound};
#endif
class PolyNode;
typedef std::vector< PolyNode* > PolyNodes;
@@ -134,6 +136,7 @@ class PolyNode
{
public:
PolyNode();
virtual ~PolyNode(){};
Path Contour;
PolyNodes Childs;
PolyNode* Parent;
@@ -168,11 +171,6 @@ bool Orientation(const Path &poly);
double Area(const Path &poly);
int PointInPolygon(const IntPoint &pt, const Path &path);
#ifdef use_deprecated
void OffsetPaths(const Paths &in_polys, Paths &out_polys,
double delta, JoinType jointype, EndType_ endtype, double limit = 0);
#endif
void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
@@ -183,8 +181,7 @@ void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.
void CleanPolygons(Paths& polys, double distance = 1.415);
void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
void MinkowskiSum(const Path& pattern, const Paths& paths,
Paths& solution, PolyFillType pathFillType, bool pathIsClosed);
void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
@@ -202,7 +199,7 @@ enum EdgeSide { esLeft = 1, esRight = 2};
//forward declarations (for stuff used internally) ...
struct TEdge;
struct IntersectNode;
struct LocalMinima;
struct LocalMinimum;
struct Scanbeam;
struct OutPt;
struct OutRec;
@@ -213,7 +210,6 @@ typedef std::vector < TEdge* > EdgeList;
typedef std::vector < Join* > JoinList;
typedef std::vector < IntersectNode* > IntersectList;
//------------------------------------------------------------------------------
//ClipperBase is the ancestor to the Clipper class. It should not be
@@ -236,12 +232,14 @@ protected:
void PopLocalMinima();
virtual void Reset();
TEdge* ProcessBound(TEdge* E, bool IsClockwise);
void InsertLocalMinima(LocalMinima *newLm);
void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed);
TEdge* DescendToMin(TEdge *&E);
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
LocalMinima *m_CurrentLM;
LocalMinima *m_MinimaList;
typedef std::vector<LocalMinimum> MinimaList;
MinimaList::iterator m_CurrentLM;
MinimaList m_MinimaList;
bool m_UseFullRange;
EdgeList m_edges;
bool m_PreserveCollinear;
@@ -268,7 +266,7 @@ public:
void StrictlySimple(bool value) {m_StrictSimple = value;};
//set the callback function for z value filling on intersections (otherwise Z is 0)
#ifdef use_xyz
void ZFillFunction(TZFillCallback zFillFunc);
void ZFillFunction(ZFillCallback zFillFunc);
#endif
protected:
void Reset();
@@ -279,7 +277,8 @@ private:
JoinList m_GhostJoins;
IntersectList m_IntersectList;
ClipType m_ClipType;
std::set< cInt, std::greater<cInt> > m_Scanbeam;
typedef std::priority_queue<cInt> ScanbeamList;
ScanbeamList m_Scanbeam;
TEdge *m_ActiveEdges;
TEdge *m_SortedEdges;
bool m_ExecuteLocked;
@@ -289,7 +288,7 @@ private:
bool m_UsingPolyTree;
bool m_StrictSimple;
#ifdef use_xyz
TZFillCallback m_ZFill; //custom callback
ZFillCallback m_ZFill; //custom callback
#endif
void SetWindingCount(TEdge& edge);
bool IsEvenOddFillType(const TEdge& edge) const;
@@ -308,21 +307,19 @@ private:
bool IsTopHorz(const cInt XPos);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DoMaxima(TEdge *e);
void PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam);
void ProcessHorizontals(bool IsTopOfScanbeam);
void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam);
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutRec* GetOutRec(int idx);
void AppendPolygon(TEdge *e1, TEdge *e2);
void IntersectEdges(TEdge *e1, TEdge *e2,
const IntPoint &pt, bool protect = false);
void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
OutRec* CreateOutRec();
OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeAllOutRecs();
void DisposeOutRec(PolyOutList::size_type index);
bool ProcessIntersections(const cInt botY, const cInt topY);
void BuildIntersectList(const cInt botY, const cInt topY);
bool ProcessIntersections(const cInt topY);
void BuildIntersectList(const cInt topY);
void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const cInt topY);
void BuildResult(Paths& polys);
@@ -344,7 +341,7 @@ private:
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
#ifdef use_xyz
void SetZ(IntPoint& pt, TEdge& e);
void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
#endif
};
//------------------------------------------------------------------------------
+19
Ver Arquivo
@@ -0,0 +1,19 @@
find engine setting literals
cd ~/Development/CuraEngine/output/reflection/
~/bin/substitute.pl y 'while(/getSetting\w+\("(\w+)"\)/gsm) { print "$1\n"; }' ../../src/ | sort | uniq > engineSettingLiterals.txt
run setting inheritance reflection
cd ~/Development/CuraEngine
./build/CuraEngine analyse ../Cura/resources/definitions/fdmprinter.def.json meta/refl_ff.gv output/reflection/engineSettingLiterals.txt -piew
dot meta/refl_ff.gv -Tpng > meta/rafl_ff_dotted.png
green block = used in engine
red edge = inherit function only
black edge = parent-child relation
Arquivo binário não exibido.

Depois

Largura:  |  Altura:  |  Tamanho: 284 KiB

+35
Ver Arquivo
@@ -0,0 +1,35 @@
/** Copyright (C) 2016 Tim Kuipers - Released under terms of the AGPLv3 License */
#include "ConicalOverhang.h"
namespace cura {
void ConicalOverhang::apply(Slicer* slicer, double angle, int layer_thickness)
{
double tanAngle = tan(angle); // the XY-component of the angle
int max_dist_from_lower_layer = tanAngle * layer_thickness; // max dist which can be bridged
for (unsigned int layer_nr = slicer->layers.size() - 2; static_cast<int>(layer_nr) >= 0; layer_nr--)
{
SlicerLayer& layer = slicer->layers[layer_nr];
SlicerLayer& layer_above = slicer->layers[layer_nr + 1];
if (std::abs(max_dist_from_lower_layer) < 5)
{ // magically nothing happens when max_dist_from_lower_layer == 0
// below magic code solves that
int safe_dist = 20;
Polygons diff = layer_above.polygons.difference(layer.polygons.offset(-safe_dist));
layer.polygons = layer.polygons.unionPolygons(diff);
layer.polygons = layer.polygons.smooth(safe_dist);
layer.polygons.simplify(safe_dist, safe_dist * safe_dist / 4);
// somehow layer.polygons get really jagged lines with a lot of vertices
// without the above steps slicing goes really slow
}
else
{
layer.polygons = layer.polygons.unionPolygons(layer_above.polygons.offset(-max_dist_from_lower_layer));
}
}
}
}//namespace cura
+30
Ver Arquivo
@@ -0,0 +1,30 @@
/** Copyright (C) 2016 Tim Kuipers - Released under terms of the AGPLv3 License */
#ifndef CONICAL_OVERHANG_H
#define CONICAL_OVERHANG_H
#include "slicer.h"
namespace cura {
/*!
* A class for changing the geometry of a model such that it is printable without support -
* Or at least with at least support as possible
*/
class ConicalOverhang
{
public:
/*!
* Change the slice data such that the model becomes more printable
*
* \param[in,out] slicer The slice data
* \param angle The maximum angle which can be printed without generating support (or at least generating least support)
* \param layer_thickness The general layer thickness
*/
static void apply(Slicer* slicer, double angle, int layer_thickness);
};
}//namespace cura
#endif // CONICAL_OVERHANG_H
+27
Ver Arquivo
@@ -0,0 +1,27 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "ExtruderTrain.h"
namespace cura
{
int ExtruderTrain::getExtruderNr()
{
return extruder_nr;
}
ExtruderTrain::ExtruderTrain(SettingsBaseVirtual* settings, int extruder_nr)
: SettingsBase(settings)
, extruder_nr(extruder_nr)
{
}
bool ExtruderTrain::getIsUsed() const
{
return is_used;
}
void ExtruderTrain::setIsUsed(bool used)
{
is_used = used;
}
}//namespace cura
+10 -8
Ver Arquivo
@@ -1,7 +1,8 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef EXTRUDER_TRAIN_H
#define EXTRUDER_TRAIN_H
#include "settings.h"
#include "settings/settings.h"
namespace cura
{
@@ -9,14 +10,15 @@ namespace cura
class ExtruderTrain : public SettingsBase
{
int extruder_nr;
bool is_used = false; //!< whether this extruder train is (probably) used during printing the current meshgroup
public:
int getExtruderNr() { return extruder_nr; }
ExtruderTrain(SettingsBaseVirtual* settings, int extruder_nr)
: SettingsBase(settings)
, extruder_nr(extruder_nr)
{ }
int getExtruderNr();
bool getIsUsed() const; //!< return whether this extruder train is (probably) used during printing the current meshgroup
void setIsUsed(bool used); //!< set whether this extruder train is (probably) used during printing the current meshgroup
ExtruderTrain(SettingsBaseVirtual* settings, int extruder_nr);
};
}//namespace cura
+2 -1
Ver Arquivo
@@ -1,7 +1,7 @@
#ifndef FAN_SPEED_LAYER_TIME_H
#define FAN_SPEED_LAYER_TIME_H
#include "settings.h"
#include "settings/settings.h"
namespace cura
{
@@ -11,6 +11,7 @@ struct FanSpeedLayerTimeSettings
public:
double cool_min_layer_time;
double cool_min_layer_time_fan_speed_max;
double cool_fan_speed_0;
double cool_fan_speed_min;
double cool_fan_speed_max;
double cool_min_speed;
+967 -500
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+260 -134
Ver Arquivo
@@ -17,6 +17,7 @@
#include "commandSocket.h"
#include "PrimeTower.h"
#include "FanSpeedLayerTime.h"
#include "PrintFeature.h"
#include "LayerPlanBuffer.h"
@@ -36,53 +37,66 @@ class FffGcodeWriter : public SettingsMessenger, NoCopy
{
friend class FffProcessor; // cause WireFrame2Gcode uses the member [gcode] (TODO)
private:
int max_object_height;
int meshgroup_number; //!< used for sequential printing of objects
LayerPlanBuffer layer_plan_buffer;
GCodeExport gcode;
CommandSocket* command_socket;
std::ofstream output_file;
/*!
* Layer number of the last layer in which a prime tower has been printed per extruder train.
int max_object_height; //!< The maximal height of all previously sliced meshgroups, used to avoid collision when moving to the next meshgroup to print.
/*
* Buffer for all layer plans (of type GCodePlanner)
*
* This is recorded per extruder to account for a prime tower per extruder, instead of the mixed prime tower.
* The layer plans are buffered so that we can start heating up a nozzle several layers before it needs to be used.
* Another reason is to perform Auto Temperature.
*/
int last_prime_tower_poly_printed[MAX_EXTRUDERS];
FanSpeedLayerTimeSettings fan_speed_layer_time_settings;
Point last_position_planned; //!< The position of the head before planning the next layer
int current_extruder_planned; //!< The extruder train in use before planning the next layer
LayerPlanBuffer layer_plan_buffer;
/*!
* The class holding the current state of the gcode being written.
*
* It holds information such as the last written position etc.
*/
GCodeExport gcode;
/*!
* The gcode file to write to when using CuraEngine as command line tool.
*/
std::ofstream output_file;
/*!
* Whether the skirt or brim polygons have been processed into planned paths
* for each extruder train.
*/
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.
GCodePlanner::PlanningState planner_state;
public:
FffGcodeWriter(SettingsBase* settings_)
: SettingsMessenger(settings_)
, layer_plan_buffer(this, command_socket, gcode)
, last_position_planned(no_point)
, current_extruder_planned(0) // TODO: make configurable
, max_object_height(0)
, layer_plan_buffer(this, gcode)
, extruder_prime_is_planned {} // initialize all values in array with [false]
, planner_state{ no_point
, 0 // changed somewhere early in FffGcodeWriter::writeGCode
, false
}
{
meshgroup_number = 1;
max_object_height = 0;
command_socket = NULL;
}
void resetFileNumber()
{
meshgroup_number = 1;
}
void setCommandSocket(CommandSocket* socket)
{
command_socket = socket;
}
void sendPolygons(PolygonType type, int layer_nr, Polygons& polygons, int line_width)
{
if (command_socket)
command_socket->sendPolygons(type, layer_nr, polygons, line_width);
}
/*!
* Set the target to write gcode to: to a file.
*
* Used when CuraEngine is used as command line tool.
*
* \param filename The filename of the file to which to write the gcode.
*/
bool setTargetFile(const char* filename)
{
output_file.open(filename);
@@ -93,220 +107,332 @@ public:
}
return false;
}
/*!
* Set the target to write gcode to: an output stream.
*
* Used when CuraEngine is NOT used as command line tool.
*
* \param stream The stream to write gcode to.
*/
void setTargetStream(std::ostream* stream)
{
gcode.setOutputStream(stream);
}
double getTotalFilamentUsed(int e)
/*!
* Get the total extruded volume for a specific extruder in mm^3
*
* Retractions and unretractions don't contribute to this.
*
* \param extruder_nr The extruder number for which to get the total netto extruded volume
* \return total filament printed in mm^3
*/
double getTotalFilamentUsed(int extruder_nr)
{
return gcode.getTotalFilamentUsed(e);
return gcode.getTotalFilamentUsed(extruder_nr);
}
/*!
* Get the total estimated print time in seconds
*
* \return total print time in seconds
*/
double getTotalPrintTime()
{
return gcode.getTotalPrintTime();
}
/*!
* Write all the gcode for the current meshgroup.
* This is the primary function of this class.
*
* \param[in] storage The data storage from which to get the polygons to print and the areas to fill.
* \param timeKeeper The stop watch to see how long it takes for each of the stages in the slicing process.
*/
void writeGCode(SliceDataStorage& storage, TimeKeeper& timeKeeper);
private:
void setConfigFanSpeedLayerTime();
/*!
* Set the FffGcodeWriter::fan_speed_layer_time_settings by retrieving all settings from the global/per-meshgroup settings.
*
* \param[out] storage The data storage to which to save the configuration
*/
void setConfigFanSpeedLayerTime(SliceDataStorage& storage);
/*!
* Create and set the SliceDataStorage::coasting_config for each extruder.
*
* \param[out] storage The data storage to which to save the configuration
*/
void setConfigCoasting(SliceDataStorage& storage);
//Setup the retraction parameters.
/*!
* Set the retraction config globally, per extruder and per mesh.
*
* \param[out] storage The data storage to which to save the configurations
*/
void setConfigRetraction(SliceDataStorage& storage);
/*!
* initialize GcodePathConfig config parameters which don't change over all layers
*/
void initConfigs(SliceDataStorage& storage);
/*!
* Set temperatures and perform initial priming.
* \param storage Input: where the slice data is stored.
*/
void processStartingCode(SliceDataStorage& storage);
/*!
* Move up and over the just printed model to print the next model.
* \param storage Input: where the slice data is stored.
* 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.
*/
void processNextMeshGroupCode(SliceDataStorage& storage);
unsigned int getStartExtruder(const 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(const SliceDataStorage& storage, const unsigned int start_extruder_nr);
/*!
* Move up and over the already printed meshgroups to print the next meshgroup.
*
* \param[in] storage where the slice data is stored.
*/
void processNextMeshGroupCode(const SliceDataStorage& storage);
/*!
* Add raft gcode.
* \param storage Input: where the slice data is stored.
* Add raft layer plans onto the FffGcodeWriter::layer_plan_buffer
*
* \param[in,out] storage where the slice data is stored.
* \param total_layers The total number of layers.
*/
void processRaft(SliceDataStorage& storage, unsigned int total_layers);
void processRaft(const SliceDataStorage& storage, unsigned int total_layers);
/*!
* Add a layer to the gcode.
* \param storage Input: where the slice data is stored.
* Convert the polygon data of a layer into a layer plan on the FffGcodeWriter::layer_plan_buffer
*
* In case of negative layer numbers, create layers only containing the data from
* the helper parts (support etc) to fill up the gap between the raft and the model.
*
* \param[in] storage where the slice data is stored.
* \param layer_nr The index of the layer to write the gcode of.
* \param total_layers The total number of layers.
* \param has_raft Whether a raft is used for this print.
* \return The layer plans
*/
void processLayer(SliceDataStorage& storage, unsigned int layer_nr, unsigned int total_layers, bool has_raft);
GCodePlanner& processLayer(const SliceDataStorage& storage, int layer_nr, unsigned int total_layers) const;
/*!
* 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() const;
/*!
* Plan priming of all used extruders which haven't been primed yet
* \param[in] storage where the slice data is stored.
* \param layer_plan The initial planning of the g-code of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*/
void ensureAllExtrudersArePrimed(const SliceDataStorage& storage, GCodePlanner& layer_plan, const int layer_nr) const;
/*!
* Add the skirt or the brim to the layer plan \p gcodeLayer.
*
* \param Storage where the slice data is stored.
* \param gcodeLayer The initial planning of the g-code of the layer.
* \param extruder_nr The extruder train for which to process the skirt or
* brim.
*/
void processSkirtBrim(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int extruder_nr) const;
/*!
* Add the skirt to the gcode.
* \param storage Input: where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param extruder_nr The extrudewr train for which to process the skirt
*/
void processSkirt(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int extruder_nr);
/*!
* Adds the ooze shield to the print.
* \param storage Input: where the slice data is stored.
* Adds the ooze shield to the layer plan \p gcodeLayer.
*
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*/
void processOozeShield(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr);
void processOozeShield(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr) const;
/*!
* Adds the draft protection screen to the print.
* \param storage Input: where the slice data is stored.
* Adds the draft protection screen to the layer plan \p gcodeLayer.
*
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*/
void processDraftShield(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr);
void processDraftShield(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr) const;
/*!
* Calculate in which order to print the meshes.
* \param storage Input: where the slice data is stored.
* Calculate in which order to plan the extruders
*
* \param[in] storage where the slice data is stored.
* \param current_extruder The current extruder with which we last printed
* \return A vector of mesh indices ordered on print order.
* \return A vector of pairs of extruder numbers coupled with the mesh indices ordered on print order for that extruder.
*/
std::vector<unsigned int> calculateMeshOrder(SliceDataStorage& storage, int current_extruder);
std::vector<int> calculateExtruderOrder(const SliceDataStorage& storage, int current_extruder) const;
/*!
* Add a single layer from a single mesh-volume to the GCode in mesh surface mode.
* \param storage Input: where the slice data is stored.
* \param mesh The mesh to add to the gcode.
* Calculate in which order to plan the meshes of a specific extruder
*
* \param[in] storage where the slice data is stored.
* \param extruder_nr The extruder for which to determine the order
* \return A vector of pairs of extruder numbers coupled with the mesh indices ordered on print order for that extruder.
*/
std::vector<unsigned int> calculateMeshOrder(const SliceDataStorage& storage, int extruder_nr) const;
/*!
* Add a single layer from a single mesh-volume to the layer plan \p gcodeLayer in mesh surface mode.
*
* \param[in] storage where the slice data is stored.
* \param mesh The mesh to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*
*/
void addMeshLayerToGCode_meshSurfaceMode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcodeLayer, int layer_nr);
void addMeshLayerToGCode_meshSurfaceMode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcodeLayer, int layer_nr) const;
/*!
* Add the open polylines from a single layer from a single mesh-volume to the GCode for mesh surface mode.
* \param storage Input: where the slice data is stored.
* \param mesh The mesh for which to add to the gcode.
* Add the open polylines from a single layer from a single mesh-volume to the layer plan \p gcodeLayer for mesh the surface modes.
*
* \param[in] storage where the slice data is stored.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
*
*/
void addMeshOpenPolyLinesToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcode_layer, int layer_nr);
void addMeshOpenPolyLinesToGCode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcode_layer, int layer_nr) const;
/*!
* Add a single layer from a single mesh-volume to the GCode.
* \param storage Input: where the slice data is stored.
* \param mesh The mesh to add to the gcode.
* \param gcodeLayer The initial planning of the gcode of the layer.
* 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 gcode_layer.
* \param mesh_config the line config with which to print a print feature
* \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(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcode_layer, int layer_nr) const;
/*!
* 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 mesh_config the line config with which to print a print feature
* \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(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, GCodePlanner& gcode_layer, int layer_nr) const;
/*!
* Add thicker (multiple layers) sparse infill for a given part in a layer.
* Add thicker (multiple layers) sparse infill for a given part in a layer plan.
*
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param mesh The mesh for which to add to the gcode.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \param part The part for which to create gcode
* \param layer_nr The current layer number.
* \param infill_line_distance The distance between the infill lines
* \param infill_overlap The fraction of the extrusion width by which the infill overlaps with the wall insets.
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
* \param fillAngle The angle in the XY plane at which the infill is generated.
* \param extrusionWidth extrusionWidth
*/
void processMultiLayerInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, double infill_overlap, int fillAngle, int extrusionWidth);
void processMultiLayerInfill(GCodePlanner& gcodeLayer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle) const;
/*!
* Add normal sparse infill for a given part in a layer.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param mesh The mesh for which to add to the gcode.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \param part The part for which to create gcode
* \param layer_nr The current layer number.
* \param infill_line_distance The distance between the infill lines
* \param infill_overlap The fraction of the extrusion width by which the infill overlaps with the wall insets.
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
* \param fillAngle The angle in the XY plane at which the infill is generated.
* \param extrusionWidth extrusionWidth
*/
void processSingleLayerInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, double infill_overlap, int fillAngle, int extrusionWidth);
void processSingleLayerInfill(GCodePlanner& gcodeLayer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle) const;
/*!
* Generate the insets for the walls of a given layer part.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param mesh The mesh for which to add to the gcode.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \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, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type, Point z_seam_pos) const;
/*!
* 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 gcode.
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
* \param mesh_config the line config with which to print a print feature
* \param part The part for which to create gcode
* \param layer_nr The current layer number.
* \param infill_overlap The fraction of the extrusion width by which the infill 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.
* \param extrusionWidth extrusionWidth
*/
void processSkin(cura::GCodePlanner& gcode_layer, cura::SliceMeshStorage* mesh, cura::SliceLayerPart& part, unsigned int layer_nr, double infill_overlap, int infill_angle, int extrusion_width);
void processSkinAndPerimeterGaps(GCodePlanner& gcode_layer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int infill_angle) const;
/*!
* Add the support to the gcode of the current layer.
* \param storage Input: where the slice data is stored.
* Add the support to the layer plan \p gcodeLayer of the current layer for all support parts with the given \p extruder_nr.
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
* \param extruder_nr_before The extruder number at the start of the layer (before other print parts aka the rest)
* \param before_rest Whether the function has been called before adding the rest to the gcode, or after.
* \return whether any support was added to the layer plan
*/
void addSupportToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int extruder_nr_before, bool before_rest);
bool addSupportToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int extruder_nr) const;
/*!
* Add the support lines/walls to the gcode of the current layer.
* \param storage Input: where the slice data is stored.
* Add the support lines/walls to the layer plan \p gcodeLayer of the current layer.
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
* \return whether any support infill was added to the layer plan
*/
void addSupportInfillToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr);
bool addSupportInfillToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr) const;
/*!
* Add the support roofs to the gcode of the current layer.
* \param storage Input: where the slice data is stored.
* Add the support skins to the layer plan \p gcodeLayer of the current layer.
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
* \return whether any support skin was added to the layer plan
*/
void addSupportRoofsToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr);
bool addSupportRoofsToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr) const;
/*!
* Change to a new extruder, and add the prime tower instructions if the new extruder is different from the last.
*
* On layer 0 this function adds the skirt for the nozzle it switches to, instead of the prime tower.
*
* \param storage Input: where the slice data is stored.
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
* \param extruder_nr The extruder to which to switch
*/
void setExtruder_addPrime(SliceDataStorage& storage, GCodePlanner& gcode_layer, int layer_nr, int extruder_nr);
void setExtruder_addPrime(const SliceDataStorage& storage, GCodePlanner& gcode_layer, int layer_nr, int extruder_nr) const;
/*!
* Add the prime tower gcode for the current layer.
* \param storage Input: where the slice data is stored.
* \param[in] storage where the slice data is stored.
* \param gcodeLayer The initial planning of the gcode of the layer.
* \param layer_nr The index of the layer to write the gcode of.
* \param prev_extruder The current extruder with which we last printed.
*/
void addPrimeTower(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int prev_extruder);
void addPrimeTower(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int prev_extruder) const;
/*!
* Add the end gcode and set all temperatures to zero.
+563 -236
Ver Arquivo
@@ -1,7 +1,11 @@
#include "FffPolygonGenerator.h"
#include <algorithm>
#include <map> // multimap (ordered map allowing duplicate keys)
#include <omp.h>
#include "utils/math.h"
#include "utils/algorithm.h"
#include "slicer.h"
#include "utils/gettime.h"
#include "utils/logoutput.h"
@@ -9,23 +13,25 @@
#include "support.h"
#include "multiVolumes.h"
#include "layerPart.h"
#include "inset.h"
#include "skirt.h"
#include "WallsComputation.h"
#include "SkirtBrim.h"
#include "skin.h"
#include "infill.h"
#include "raft.h"
#include "debug.h"
#include "Progress.h"
#include "progress/Progress.h"
#include "PrintFeature.h"
#include "ConicalOverhang.h"
#include "progress/ProgressEstimator.h"
#include "progress/ProgressStageEstimator.h"
#include "progress/ProgressEstimatorLinear.h"
namespace cura
{
bool FffPolygonGenerator::generateAreas(SliceDataStorage& storage, MeshGroup* meshgroup, TimeKeeper& timeKeeper)
{
if (commandSocket)
commandSocket->beginSendSlicedObject();
if (!sliceModel(meshgroup, timeKeeper, storage))
{
return false;
@@ -36,36 +42,47 @@ bool FffPolygonGenerator::generateAreas(SliceDataStorage& storage, MeshGroup* me
return true;
}
unsigned int FffPolygonGenerator::getDraftShieldLayerCount(const unsigned int total_layers) const
{
if (!getSettingBoolean("draft_shield_enabled"))
{
return 0;
}
switch (getSettingAsDraftShieldHeightLimitation("draft_shield_height_limitation"))
{
default:
case DraftShieldHeightLimitation::FULL:
return total_layers;
case DraftShieldHeightLimitation::LIMITED:
return std::max((coord_t)0, (getSettingInMicrons("draft_shield_height") - getSettingInMicrons("layer_height_0")) / getSettingInMicrons("layer_height") + 1);
}
}
bool FffPolygonGenerator::sliceModel(MeshGroup* meshgroup, TimeKeeper& timeKeeper, SliceDataStorage& storage) /// slices the model
{
Progress::messageProgressStage(Progress::Stage::SLICING, &timeKeeper, commandSocket);
Progress::messageProgressStage(Progress::Stage::SLICING, &timeKeeper);
storage.model_min = meshgroup->min();
storage.model_max = meshgroup->max();
storage.model_size = storage.model_max - storage.model_min;
log("Slicing model...\n");
int initial_layer_thickness = meshgroup->getSettingInMicrons("layer_height_0");
int initial_layer_thickness = getSettingInMicrons("layer_height_0");
if(initial_layer_thickness <= 0) //Initial layer height of 0 is not allowed. Negative layer height is nonsense.
{
logError("Initial layer height %i is disallowed.",initial_layer_thickness);
logError("Initial layer height %i is disallowed.\n", initial_layer_thickness);
return false;
}
int layer_thickness = meshgroup->getSettingInMicrons("layer_height");
int layer_thickness = getSettingInMicrons("layer_height");
if(layer_thickness <= 0) //Layer height of 0 is not allowed. Negative layer height is nonsense.
{
logError("Layer height %i is disallowed.",layer_thickness);
logError("Layer height %i is disallowed.\n", layer_thickness);
return false;
}
if (meshgroup->getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT)
{
initial_layer_thickness = layer_thickness;
}
int initial_slice_z = initial_layer_thickness - layer_thickness / 2;
int layer_count = (storage.model_max.z - initial_slice_z) / layer_thickness + 1;
if(layer_count <= 0) //Model is shallower than layer_height_0, so not even the first layer is sliced. Return an empty model then.
int slice_layer_count = (storage.model_max.z - initial_slice_z) / layer_thickness + 1;
if (slice_layer_count <= 0) //Model is shallower than layer_height_0, so not even the first layer is sliced. Return an empty model then.
{
Progress::messageProgressStage(Progress::Stage::INSET,&timeKeeper,commandSocket); //Continue directly with the inset stage, which will also immediately stop.
return true; //This is NOT an error state!
}
@@ -73,222 +90,490 @@ bool FffPolygonGenerator::sliceModel(MeshGroup* meshgroup, TimeKeeper& timeKeepe
for(unsigned int mesh_idx = 0; mesh_idx < meshgroup->meshes.size(); mesh_idx++)
{
Mesh& mesh = meshgroup->meshes[mesh_idx];
Slicer* slicer = new Slicer(&mesh, initial_slice_z, layer_thickness, layer_count, mesh.getSettingBoolean("meshfix_keep_open_polygons"), mesh.getSettingBoolean("meshfix_extensive_stitching"));
Slicer* slicer = new Slicer(&mesh, initial_slice_z, layer_thickness, slice_layer_count, mesh.getSettingBoolean("meshfix_keep_open_polygons"), mesh.getSettingBoolean("meshfix_extensive_stitching"));
slicerList.push_back(slicer);
/*
for(SlicerLayer& layer : slicer->layers)
{
//Reporting the outline here slows down the engine quite a bit, so only do so when debugging.
//sendPolygons("outline", layer_nr, layer.z, layer.polygonList);
//sendPolygons("openoutline", layer_nr, layer.openPolygonList);
sendPolygons("outline", layer_nr, layer.z, layer.polygonList);
sendPolygons("openoutline", layer_nr, layer.openPolygonList);
}
*/
Progress::messageProgress(Progress::Stage::SLICING, mesh_idx + 1, meshgroup->meshes.size(), commandSocket);
Progress::messageProgress(Progress::Stage::SLICING, mesh_idx + 1, meshgroup->meshes.size());
}
log("Layer count: %i\n", layer_count);
meshgroup->clear();///Clear the mesh face and vertex data, it is no longer needed after this point, and it saves a lot of memory.
Progress::messageProgressStage(Progress::Stage::PARTS, &timeKeeper, commandSocket);
//carveMultipleVolumes(storage.meshes);
generateMultipleVolumesOverlap(slicerList, getSettingInMicrons("multiple_mesh_overlap"));
storage.meshes.reserve(slicerList.size()); // causes there to be no resize in meshes so that the pointers in sliceMeshStorage._config to retraction_config don't get invalidated.
for(unsigned int meshIdx=0; meshIdx < slicerList.size(); meshIdx++)
{
storage.meshes.emplace_back(&meshgroup->meshes[meshIdx]); // new mesh in storage had settings from the Mesh
SliceMeshStorage& meshStorage = storage.meshes.back();
Mesh& mesh = storage.meshgroup->meshes[meshIdx];
createLayerParts(meshStorage, slicerList[meshIdx], mesh.getSettingBoolean("meshfix_union_all"), mesh.getSettingBoolean("meshfix_union_all_remove_holes"));
if (mesh.getSettingBoolean("conical_overhang_enabled") && !mesh.getSettingBoolean("anti_overhang_mesh"))
{
ConicalOverhang::apply(slicerList[meshIdx], mesh.getSettingInAngleRadians("conical_overhang_angle"), layer_thickness);
}
}
Progress::messageProgressStage(Progress::Stage::PARTS, &timeKeeper);
if (storage.getSettingBoolean("carve_multiple_volumes"))
{
carveMultipleVolumes(slicerList, storage.getSettingBoolean("alternate_carve_order"));
}
generateMultipleVolumesOverlap(slicerList);
storage.print_layer_count = 0;
for (unsigned int meshIdx = 0; meshIdx < slicerList.size(); meshIdx++)
{
Mesh& mesh = storage.meshgroup->meshes[meshIdx];
Slicer* slicer = slicerList[meshIdx];
if (!mesh.getSettingBoolean("anti_overhang_mesh") && !mesh.getSettingBoolean("infill_mesh"))
{
storage.print_layer_count = std::max(storage.print_layer_count, (unsigned int)slicer->layers.size());
}
}
storage.support.supportLayers.resize(storage.print_layer_count);
storage.meshes.reserve(slicerList.size()); // causes there to be no resize in meshes so that the pointers in sliceMeshStorage._config to retraction_config don't get invalidated.
for (unsigned int meshIdx = 0; meshIdx < slicerList.size(); meshIdx++)
{
Slicer* slicer = slicerList[meshIdx];
Mesh& mesh = storage.meshgroup->meshes[meshIdx];
// always make a new SliceMeshStorage, so that they have the same ordering / indexing as meshgroup.meshes
storage.meshes.emplace_back(&meshgroup->meshes[meshIdx], slicer->layers.size()); // new mesh in storage had settings from the Mesh
SliceMeshStorage& meshStorage = storage.meshes.back();
if (mesh.getSettingBoolean("anti_overhang_mesh"))
{
for (unsigned int layer_nr = 0; layer_nr < slicer->layers.size(); layer_nr++)
{
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;
}
if (mesh.getSettingBoolean("support_mesh"))
{
for (unsigned int layer_nr = 0; layer_nr < slicer->layers.size(); layer_nr++)
{
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;
}
createLayerParts(meshStorage, slicer, mesh.getSettingBoolean("meshfix_union_all"), mesh.getSettingBoolean("meshfix_union_all_remove_holes"));
delete slicerList[meshIdx];
bool has_raft = meshStorage.getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT;
bool has_raft = getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT;
//Add the raft offset to each layer.
for(unsigned int layer_nr=0; layer_nr<meshStorage.layers.size(); layer_nr++)
{
SliceLayer& layer = meshStorage.layers[layer_nr];
meshStorage.layers[layer_nr].printZ +=
meshStorage.getSettingInMicrons("layer_height_0")
getSettingInMicrons("layer_height_0")
- initial_slice_z;
if (has_raft)
{
ExtruderTrain* train = storage.meshgroup->getExtruderTrain(getSettingAsIndex("adhesion_extruder_nr"));
layer.printZ +=
meshStorage.getSettingInMicrons("raft_base_thickness")
+ meshStorage.getSettingInMicrons("raft_interface_thickness")
+ meshStorage.getSettingAsCount("raft_surface_layers") * getSettingInMicrons("raft_surface_thickness")
+ meshStorage.getSettingInMicrons("raft_airgap");
Raft::getTotalThickness(storage)
+ train->getSettingInMicrons("raft_airgap")
- train->getSettingInMicrons("layer_0_z_overlap"); // shift all layers (except 0) down
if (layer_nr == 0)
{
layer.printZ += train->getSettingInMicrons("layer_0_z_overlap"); // undo shifting down of first layer
}
}
if (layer.parts.size() > 0 || (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL && layer.openPolyLines.size() > 0) )
{
meshStorage.layer_nr_max_filled_layer = layer_nr; // last set by the highest non-empty layer
}
if (commandSocket)
{
commandSocket->sendLayerInfo(layer_nr, layer.printZ, layer_nr == 0? meshStorage.getSettingInMicrons("layer_height_0") : meshStorage.getSettingInMicrons("layer_height"));
}
}
Progress::messageProgress(Progress::Stage::PARTS, meshIdx + 1, slicerList.size(), commandSocket);
Progress::messageProgress(Progress::Stage::PARTS, meshIdx + 1, slicerList.size());
}
Progress::messageProgressStage(Progress::Stage::INSET, &timeKeeper, commandSocket);
return true;
}
void FffPolygonGenerator::slices2polygons(SliceDataStorage& storage, TimeKeeper& time_keeper)
{
size_t total_layers = 0;
// compute layer count and remove first empty layers
// there is no separate progress stage for removeEmptyFisrtLayer (TODO)
unsigned int slice_layer_count = 0;
for (SliceMeshStorage& mesh : storage.meshes)
{
total_layers = std::max<unsigned int>(total_layers, mesh.layers.size());
if (!mesh.getSettingBoolean("infill_mesh") && !mesh.getSettingBoolean("anti_overhang_mesh"))
{
slice_layer_count = std::max<unsigned int>(slice_layer_count, mesh.layers.size());
}
}
// handle meshes
std::vector<double> mesh_timings;
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{
mesh_timings.push_back(1.0); // TODO: have a more accurate estimate of the relative time it takes per mesh, based on the height and number of polygons
}
ProgressStageEstimator inset_skin_progress_estimate(mesh_timings);
Progress::messageProgressStage(Progress::Stage::INSET_SKIN, &time_keeper);
std::vector<unsigned int> mesh_order;
{ // compute mesh order
std::multimap<int, unsigned int> order_to_mesh_indices;
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{
order_to_mesh_indices.emplace(storage.meshes[mesh_idx].getSettingAsIndex("infill_mesh_order"), mesh_idx);
}
for (std::pair<const int, unsigned int>& order_and_mesh_idx : order_to_mesh_indices)
{
mesh_order.push_back(order_and_mesh_idx.second);
}
}
for (unsigned int mesh_order_idx(0); mesh_order_idx < mesh_order.size(); ++mesh_order_idx)
{
processBasicWallsSkinInfill(storage, mesh_order_idx, mesh_order, inset_skin_progress_estimate);
Progress::messageProgress(Progress::Stage::INSET_SKIN, mesh_order_idx + 1, storage.meshes.size());
}
for (unsigned int layer_nr = 0; layer_nr < slice_layer_count; layer_nr++)
{
SliceLayer* layer = nullptr;
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
{ // find first mesh which has this layer
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
if (int(layer_nr) <= mesh.layer_nr_max_filled_layer)
{
layer = &mesh.layers[layer_nr];
break;
}
}
if (layer != nullptr)
{
if (CommandSocket::isInstantiated())
{ // send layer info
CommandSocket::getInstance()->sendOptimizedLayerInfo(layer_nr, layer->printZ, layer_nr == 0? getSettingInMicrons("layer_height_0") : getSettingInMicrons("layer_height"));
}
}
}
log("Layer count: %i\n", storage.print_layer_count);
//layerparts2HTML(storage, "output/output.html");
for(unsigned int layer_number = 0; layer_number < total_layers; layer_number++)
Progress::messageProgressStage(Progress::Stage::SUPPORT, &time_keeper);
AreaSupport::generateSupportAreas(storage, storage.print_layer_count);
// we need to remove empty layers after we have procesed the insets
// processInsets might throw away parts if they have no wall at all (cause it doesn't fit)
// brim depends on the first layer not being empty
// only remove empty layers if we haven't generate support, because then support was added underneath the model.
// for some materials it's better to print on support than on the buildplate.
removeEmptyFirstLayers(storage, getSettingInMicrons("layer_height"), storage.print_layer_count); // changes storage.print_layer_count!
if (storage.print_layer_count == 0)
{
processInsets(storage, layer_number);
Progress::messageProgress(Progress::Stage::INSET, layer_number+1, total_layers, commandSocket);
}
removeEmptyFirstLayers(storage, getSettingInMicrons("layer_height"), total_layers);
if (total_layers < 1)
{
log("Stopping process because there are no layers.\n");
log("Stopping process because there are no non-empty layers.\n");
return;
}
Progress::messageProgressStage(Progress::Stage::SUPPORT, &time_keeper, commandSocket);
AreaSupport::generateSupportAreas(storage, total_layers, commandSocket);
/*
if (storage.support.generated)
{
for (unsigned int layer_idx = 0; layer_idx < total_layers; layer_idx++)
for (unsigned int layer_idx = 0; layer_idx < storage.print_layer_count; layer_idx++)
{
Polygons& support = storage.support.supportLayers[layer_idx].supportAreas;
sendPolygons(SupportType, layer_idx, support, getSettingInMicrons("support_line_width"));
ExtruderTrain* infill_extr = storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("support_infill_extruder_nr"));
CommandSocket::sendPolygons(PrintFeatureType::Infill, support, 100); // infill_extr->getSettingInMicrons("support_line_width"));
}
}
*/
Progress::messageProgressStage(Progress::Stage::SKIN, &time_keeper, commandSocket);
int mesh_max_bottom_layer_count = 0;
if (getSettingBoolean("magic_spiralize"))
{
for(SliceMeshStorage& mesh : storage.meshes)
{
mesh_max_bottom_layer_count = std::max(mesh_max_bottom_layer_count, mesh.getSettingAsCount("bottom_layers"));
}
}
for(unsigned int layer_number = 0; layer_number < total_layers; layer_number++)
{
if (!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(storage, layer_number);
}
Progress::messageProgress(Progress::Stage::SKIN, layer_number+1, total_layers, commandSocket);
}
unsigned int combined_infill_layers = storage.getSettingInMicrons("infill_sparse_thickness") / std::max(storage.getSettingInMicrons("layer_height"),1); //How many infill layers to combine to obtain the requested sparse thickness.
for(SliceMeshStorage& mesh : storage.meshes)
{
combineInfillLayers(mesh,combined_infill_layers);
}
storage.primeTower.computePrimeTowerMax(storage);
storage.primeTower.generatePaths(storage, total_layers);
processOozeShield(storage, total_layers);
processDraftShield(storage, total_layers);
computePrintHeightStatistics(storage);
// handle helpers
storage.primeTower.generatePaths(storage);
storage.primeTower.subtractFromSupport(storage);
logDebug("Processing ooze shield\n");
processOozeShield(storage);
logDebug("Processing draft shield\n");
processDraftShield(storage);
logDebug("Processing platform adhesion\n");
processPlatformAdhesion(storage);
for(SliceMeshStorage& mesh : storage.meshes)
// meshes post processing
for (SliceMeshStorage& mesh : storage.meshes)
{
if (mesh.getSettingBoolean("magic_fuzzy_skin_enabled"))
{
processFuzzyWalls(mesh);
}
else if (mesh.getSettingAsCount("wall_line_count") > 0)
{ // only send polygon data
for (unsigned int layer_nr = 0; layer_nr < total_layers; layer_nr++)
{
SliceLayer* layer = &mesh.layers[layer_nr];
for(SliceLayerPart& part : layer->parts)
{
sendPolygons(Inset0Type, layer_nr, (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE)? part.outline : part.insets[0], mesh.getSettingInMicrons("wall_line_width_0"));
}
}
}
processDerivedWallsSkinInfill(mesh);
}
}
void FffPolygonGenerator::processInsets(SliceDataStorage& storage, unsigned int layer_nr)
void FffPolygonGenerator::processBasicWallsSkinInfill(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order, ProgressStageEstimator& inset_skin_progress_estimate)
{
for(SliceMeshStorage& mesh : storage.meshes)
unsigned int mesh_idx = mesh_order[mesh_order_idx];
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
size_t mesh_layer_count = mesh.layers.size();
if (mesh.getSettingBoolean("infill_mesh"))
{
SliceLayer* layer = &mesh.layers[layer_nr];
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::SURFACE)
{
int inset_count = mesh.getSettingAsCount("wall_line_count");
if (mesh.getSettingBoolean("magic_spiralize") && static_cast<int>(layer_nr) < mesh.getSettingAsCount("bottom_layers") && layer_nr % 2 == 1)//Add extra insets every 2 layers when spiralizing, this makes bottoms of cups watertight.
inset_count += 5;
int line_width_x = mesh.getSettingInMicrons("wall_line_width_x");
int line_width_0 = mesh.getSettingInMicrons("wall_line_width_0");
if (mesh.getSettingBoolean("alternate_extra_perimeter"))
inset_count += layer_nr % 2;
generateInsets(layer, mesh.getSettingInMicrons("machine_nozzle_size"), line_width_0, line_width_x, inset_count, mesh.getSettingBoolean("remove_overlapping_walls_0_enabled"), mesh.getSettingBoolean("remove_overlapping_walls_x_enabled"));
for(unsigned int partNr=0; partNr<layer->parts.size(); partNr++)
{
if (layer->parts[partNr].insets.size() > 0)
{
// sendPolygons(Inset0Type, layer_nr, layer->parts[partNr].insets[0], line_width_0); // done after processing fuzzy skin
for(unsigned int inset=1; inset<layer->parts[partNr].insets.size(); inset++)
sendPolygons(InsetXType, layer_nr, layer->parts[partNr].insets[inset], line_width_x);
}
}
processInfillMesh(storage, mesh_order_idx, mesh_order);
}
// TODO: make progress more accurate!!
// note: estimated time for insets : skins = 22.953 : 48.858
std::vector<double> walls_vs_skin_timing({22.953, 48.858});
ProgressStageEstimator* mesh_inset_skin_progress_estimator = new ProgressStageEstimator(walls_vs_skin_timing);
inset_skin_progress_estimate.nextStage(mesh_inset_skin_progress_estimator); // the stage of this function call
ProgressEstimatorLinear* inset_estimator = new ProgressEstimatorLinear(mesh_layer_count);
mesh_inset_skin_progress_estimator->nextStage(inset_estimator);
// 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);
#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);
}
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
#pragma omp atomic
processed_layer_count++;
}
ProgressEstimatorLinear* skin_estimator = new ProgressEstimatorLinear(mesh_layer_count);
mesh_inset_skin_progress_estimator->nextStage(skin_estimator);
bool process_infill = mesh.getSettingInMicrons("infill_line_distance") > 0;
if (!process_infill)
{ // do process infill anyway if it's modified by modifier meshes
for (unsigned int other_mesh_order_idx(mesh_order_idx + 1); other_mesh_order_idx < mesh_order.size(); ++other_mesh_order_idx)
{
for (PolygonRef polyline : layer->openPolyLines)
unsigned int other_mesh_idx = mesh_order[other_mesh_order_idx];
SliceMeshStorage& other_mesh = storage.meshes[other_mesh_idx];
if (other_mesh.getSettingBoolean("infill_mesh"))
{
Polygons segments;
for (unsigned int point_idx = 1; point_idx < polyline.size(); point_idx++)
AABB3D aabb = storage.meshgroup->meshes[mesh_idx].getAABB();
AABB3D other_aabb = storage.meshgroup->meshes[other_mesh_idx].getAABB();
if (aabb.hit(other_aabb))
{
PolygonRef segment = segments.newPoly();
segment.add(polyline[point_idx-1]);
segment.add(polyline[point_idx]);
process_infill = true;
}
sendPolygons(Inset0Type, layer_nr, segments, mesh.getSettingInMicrons("wall_line_width_0"));
}
}
}
// skin & infill
// Progress::messageProgressStage(Progress::Stage::SKIN, &time_keeper);
int mesh_max_bottom_layer_count = 0;
if (mesh.getSettingBoolean("magic_spiralize"))
{
mesh_max_bottom_layer_count = std::max(mesh_max_bottom_layer_count, mesh.getSettingAsCount("bottom_layers"));
}
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)
{
#pragma omp for schedule(dynamic)
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
{
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++;
}
}
}
void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, int layer_height, unsigned int total_layers)
{
void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order)
{
unsigned int mesh_idx = mesh_order[mesh_order_idx];
SliceMeshStorage& mesh = storage.meshes[mesh_idx];
mesh.layer_nr_max_filled_layer = -1;
for (unsigned int layer_idx = 0; layer_idx < mesh.layers.size(); layer_idx++)
{
SliceLayer& layer = mesh.layers[layer_idx];
std::vector<PolygonsPart> new_parts;
for (unsigned int other_mesh_idx : mesh_order)
{ // limit the infill mesh's outline to within the infill of all meshes with lower order
if (other_mesh_idx == mesh_idx)
{
break; // all previous meshes have been processed
}
SliceMeshStorage& other_mesh = storage.meshes[other_mesh_idx];
if (layer_idx >= other_mesh.layers.size())
{ // there can be no interaction between the infill mesh and this other non-infill mesh
continue;
}
SliceLayer& other_layer = other_mesh.layers[layer_idx];
for (SliceLayerPart& part : layer.parts)
{
for (SliceLayerPart& other_part : other_layer.parts)
{ // limit the outline of each part of this infill mesh to the infill of parts of the other mesh with lower infill mesh order
if (!part.boundaryBox.hit(other_part.boundaryBox))
{ // early out
continue;
}
Polygons new_outline = part.outline.intersection(other_part.getOwnInfillArea());
if (new_outline.size() == 1)
{ // we don't have to call splitIntoParts, because a single polygon can only be a single part
PolygonsPart outline_part_here;
outline_part_here.add(new_outline[0]);
new_parts.push_back(outline_part_here);
}
else if (new_outline.size() > 1)
{ // we don't know whether it's a multitude of parts because of newly introduced holes, or because the polygon has been split up
std::vector<PolygonsPart> new_parts_here = new_outline.splitIntoParts();
for (PolygonsPart& new_part_here : new_parts_here)
{
new_parts.push_back(new_part_here);
}
}
// change the infill area of the non-infill mesh which is to be filled with e.g. lines
other_part.infill_area_own = other_part.getOwnInfillArea().difference(part.outline);
// note: don't change the part.infill_area, because we change the structure of that area, while the basic area in which infill is printed remains the same
// the infill area remains the same for combing
}
}
}
layer.parts.clear();
for (PolygonsPart& part : new_parts)
{
layer.parts.emplace_back();
layer.parts.back().outline = part;
layer.parts.back().boundaryBox.calculate(part);
}
if (layer.parts.size() > 0 || (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL && layer.openPolyLines.size() > 0) )
{
mesh.layer_nr_max_filled_layer = layer_idx; // last set by the highest non-empty layer
}
}
}
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"), (coord_t)1))); //How many infill layers to combine to obtain the requested sparse thickness.
combineInfillLayers(mesh,combined_infill_layers);
// fuzzy skin
if (mesh.getSettingBoolean("magic_fuzzy_skin_enabled"))
{
processFuzzyWalls(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];
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::SURFACE)
{
int inset_count = mesh.getSettingAsCount("wall_line_count");
if (mesh.getSettingBoolean("magic_spiralize") && static_cast<int>(layer_nr) < mesh.getSettingAsCount("bottom_layers") && ((layer_nr % 2) + 2) % 2 == 1)//Add extra insets every 2 layers when spiralizing, this makes bottoms of cups watertight.
inset_count += 5;
int line_width_x = mesh.getSettingInMicrons("wall_line_width_x");
int line_width_0 = mesh.getSettingInMicrons("wall_line_width_0");
if (mesh.getSettingBoolean("alternate_extra_perimeter"))
{
inset_count += ((layer_nr % 2) + 2) % 2;
}
bool recompute_outline_based_on_outer_wall = mesh.getSettingBoolean("support_enable");
WallsComputation walls_computation(mesh.getSettingInMicrons("wall_0_inset"), line_width_0, line_width_x, inset_count, recompute_outline_based_on_outer_wall);
walls_computation.generateInsets(layer);
}
}
void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, const int layer_height, unsigned int& total_layers)
{
int n_empty_first_layers = 0;
for (unsigned int layer_idx = 0; layer_idx < total_layers; layer_idx++)
{
bool layer_is_empty = true;
for (SliceMeshStorage& mesh : storage.meshes)
if (storage.support.generated && layer_idx < storage.support.supportLayers.size())
{
SliceLayer& layer = mesh.layers[layer_idx];
if (layer.parts.size() > 0 || (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL && layer.openPolyLines.size() > 0) )
SupportLayer& support_layer = storage.support.supportLayers[layer_idx];
if (support_layer.supportAreas.size() > 0 || support_layer.skin.size() > 0)
{
layer_is_empty = false;
break;
}
}
for (SliceMeshStorage& mesh : storage.meshes)
{
SliceLayer& layer = mesh.layers[layer_idx];
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)
{
@@ -310,133 +595,176 @@ void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, int
{
layer.printZ -= n_empty_first_layers * layer_height;
}
mesh.layer_nr_max_filled_layer -= n_empty_first_layers;
}
total_layers -= n_empty_first_layers;
storage.support.layer_nr_max_filled_layer -= n_empty_first_layers;
std::vector<SupportLayer>& support_layers = storage.support.supportLayers;
support_layers.erase(support_layers.begin(), support_layers.begin() + n_empty_first_layers);
}
}
void FffPolygonGenerator::processSkinsAndInfill(SliceDataStorage& storage, unsigned int layer_nr)
/*
* 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)
{
for(SliceMeshStorage& mesh : storage.meshes)
{
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE) { continue; }
int wall_line_count = mesh.getSettingAsCount("wall_line_count");
int skin_extrusion_width = mesh.getSettingInMicrons("skin_line_width");
int innermost_wall_extrusion_width = mesh.getSettingInMicrons("wall_line_width_x");
int extrusionWidth_infill = mesh.getSettingInMicrons("infill_line_width");
generateSkins(layer_nr, mesh, skin_extrusion_width, mesh.getSettingAsCount("bottom_layers"), mesh.getSettingAsCount("top_layers"), wall_line_count, innermost_wall_extrusion_width, mesh.getSettingAsCount("skin_outline_count"), mesh.getSettingBoolean("skin_no_small_gaps_heuristic"), mesh.getSettingBoolean("remove_overlapping_walls_0_enabled"), mesh.getSettingBoolean("remove_overlapping_walls_x_enabled"));
if (mesh.getSettingInMicrons("infill_line_distance") > 0)
{
int infill_skin_overlap = 0;
if (mesh.getSettingInMicrons("infill_line_distance") > mesh.getSettingInMicrons("infill_line_width") + 10)
{
infill_skin_overlap = skin_extrusion_width / 2;
}
generateInfill(layer_nr, mesh, extrusionWidth_infill, infill_skin_overlap, wall_line_count);
if (mesh.getSettingAsFillPerimeterGapMode("fill_perimeter_gaps") == FillPerimeterGapMode::SKIN)
{
generatePerimeterGaps(layer_nr, mesh, skin_extrusion_width, mesh.getSettingAsCount("bottom_layers"), mesh.getSettingAsCount("top_layers"));
}
else if (mesh.getSettingAsFillPerimeterGapMode("fill_perimeter_gaps") == FillPerimeterGapMode::EVERYWHERE)
{
generatePerimeterGaps(layer_nr, mesh, skin_extrusion_width, 0, 0);
}
}
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE)
{
return;
}
bool frontend_can_show_polygon_as_filled_polygon = false;
if (frontend_can_show_polygon_as_filled_polygon)
const int wall_line_count = mesh.getSettingAsCount("wall_line_count");
const int innermost_wall_line_width = (wall_line_count == 1) ? mesh.getSettingInMicrons("wall_line_width_0") : mesh.getSettingInMicrons("wall_line_width_x");
generateSkins(layer_nr, mesh, mesh.getSettingAsCount("bottom_layers"), mesh.getSettingAsCount("top_layers"), wall_line_count, innermost_wall_line_width, mesh.getSettingAsCount("skin_outline_count"), mesh.getSettingBoolean("skin_no_small_gaps_heuristic"));
if (process_infill)
{ // process infill when infill density > 0
// or when other infill meshes want to modify this infill
int infill_skin_overlap = 0;
bool infill_is_dense = mesh.getSettingInMicrons("infill_line_distance") < mesh.getSettingInMicrons("infill_line_width") + 10;
if (!infill_is_dense && mesh.getSettingAsFillMethod("infill_pattern") != EFillMethod::CONCENTRIC)
{
SliceLayer& layer = mesh.layers[layer_nr];
for(SliceLayerPart& part : layer.parts)
{
// sendPolygons(InfillType, layer_nr, part.infill_area[0], extrusionWidth_infill); // sends the outline, not the actual infill
for (SkinPart& skin_part : part.skin_parts)
{
sendPolygons(SkinType, layer_nr, skin_part.outline, innermost_wall_extrusion_width);
}
}
infill_skin_overlap = innermost_wall_line_width / 2;
}
generateInfill(layer_nr, mesh, innermost_wall_line_width, infill_skin_overlap, wall_line_count);
}
}
void FffPolygonGenerator::processOozeShield(SliceDataStorage& storage, unsigned int total_layers)
void FffPolygonGenerator::computePrintHeightStatistics(SliceDataStorage& storage)
{
int extruder_count = storage.meshgroup->getExtruderCount();
std::vector<int>& max_print_height_per_extruder = storage.max_print_height_per_extruder;
assert(max_print_height_per_extruder.size() == 0 && "storage.max_print_height_per_extruder shouldn't have been initialized yet!");
max_print_height_per_extruder.resize(extruder_count, -1); //Initialize all as -1.
{ // compute max_object_height_per_extruder
//Height of the meshes themselves.
for (SliceMeshStorage& mesh : storage.meshes)
{
if (mesh.getSettingBoolean("anti_overhang_mesh") || mesh.getSettingBoolean("support_mesh"))
{
continue; //Special type of mesh that doesn't get printed.
}
const unsigned int extr_nr = mesh.getSettingAsIndex("extruder_nr");
max_print_height_per_extruder[extr_nr] = std::max(max_print_height_per_extruder[extr_nr], mesh.layer_nr_max_filled_layer);
}
//Height of where the support reaches.
const unsigned int support_infill_extruder_nr = storage.getSettingAsIndex("support_infill_extruder_nr"); // TODO: support extruder should be configurable per object
max_print_height_per_extruder[support_infill_extruder_nr] =
std::max(max_print_height_per_extruder[support_infill_extruder_nr],
storage.support.layer_nr_max_filled_layer);
const unsigned int support_skin_extruder_nr = storage.getSettingAsIndex("support_interface_extruder_nr"); // TODO: support skin extruder should be configurable per object
max_print_height_per_extruder[support_skin_extruder_nr] =
std::max(max_print_height_per_extruder[support_skin_extruder_nr],
storage.support.layer_nr_max_filled_layer);
//Height of where the platform adhesion reaches.
if (storage.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::NONE)
{
const unsigned int adhesion_extruder_nr = storage.getSettingAsIndex("adhesion_extruder_nr");
max_print_height_per_extruder[adhesion_extruder_nr] =
std::max(0, max_print_height_per_extruder[adhesion_extruder_nr]);
}
}
storage.max_print_height_order = order(max_print_height_per_extruder);
if (extruder_count >= 2)
{
int second_highest_extruder = storage.max_print_height_order[extruder_count - 2];
storage.max_print_height_second_to_last_extruder = max_print_height_per_extruder[second_highest_extruder];
}
else
{
storage.max_print_height_second_to_last_extruder = -1;
}
}
void FffPolygonGenerator::processOozeShield(SliceDataStorage& storage)
{
if (!getSettingBoolean("ooze_shield_enabled"))
{
return;
}
int ooze_shield_dist = getSettingInMicrons("ooze_shield_dist");
for(unsigned int layer_nr=0; layer_nr<total_layers; layer_nr++)
const int ooze_shield_dist = getSettingInMicrons("ooze_shield_dist");
for (int layer_nr = 0; layer_nr <= storage.max_print_height_second_to_last_extruder; layer_nr++)
{
storage.oozeShield.push_back(storage.getLayerOutlines(layer_nr, true).offset(ooze_shield_dist));
storage.oozeShield.push_back(storage.getLayerOutlines(layer_nr, true).offset(ooze_shield_dist, ClipperLib::jtRound));
}
int largest_printed_radius = MM2INT(1.0); // TODO: make var a parameter, and perhaps even a setting?
for(unsigned int layer_nr=0; layer_nr<total_layers; layer_nr++)
double angle = getSettingInAngleDegrees("ooze_shield_angle");
if (angle <= 89)
{
storage.oozeShield[layer_nr] = storage.oozeShield[layer_nr].offset(-largest_printed_radius).offset(largest_printed_radius);
int allowed_angle_offset = tan(getSettingInAngleRadians("ooze_shield_angle")) * getSettingInMicrons("layer_height"); // Allow for a 60deg angle in the oozeShield.
for (int layer_nr = 1; layer_nr <= storage.max_print_height_second_to_last_extruder; layer_nr++)
{
storage.oozeShield[layer_nr] = storage.oozeShield[layer_nr].unionPolygons(storage.oozeShield[layer_nr - 1].offset(-allowed_angle_offset));
}
for (int layer_nr = storage.max_print_height_second_to_last_extruder; layer_nr > 0; layer_nr--)
{
storage.oozeShield[layer_nr - 1] = storage.oozeShield[layer_nr - 1].unionPolygons(storage.oozeShield[layer_nr].offset(-allowed_angle_offset));
}
}
int allowed_angle_offset = tan(getSettingInAngleRadians("ooze_shield_angle")) * getSettingInMicrons("layer_height");//Allow for a 60deg angle in the oozeShield.
for(unsigned int layer_nr=1; layer_nr<total_layers; layer_nr++)
const float largest_printed_area = 1.0; // TODO: make var a parameter, and perhaps even a setting?
for (int layer_nr = 0; layer_nr <= storage.max_print_height_second_to_last_extruder; layer_nr++)
{
storage.oozeShield[layer_nr] = storage.oozeShield[layer_nr].unionPolygons(storage.oozeShield[layer_nr-1].offset(-allowed_angle_offset));
}
for(unsigned int layer_nr=total_layers-1; layer_nr>0; layer_nr--)
{
storage.oozeShield[layer_nr-1] = storage.oozeShield[layer_nr-1].unionPolygons(storage.oozeShield[layer_nr].offset(-allowed_angle_offset));
storage.oozeShield[layer_nr].removeSmallAreas(largest_printed_area);
}
}
void FffPolygonGenerator::processDraftShield(SliceDataStorage& storage, unsigned int total_layers)
void FffPolygonGenerator::processDraftShield(SliceDataStorage& storage)
{
int draft_shield_height = getSettingInMicrons("draft_shield_height");
int draft_shield_dist = getSettingInMicrons("draft_shield_dist");
int layer_height_0 = getSettingInMicrons("layer_height_0");
int layer_height = getSettingInMicrons("layer_height");
if (draft_shield_height < layer_height_0)
const unsigned int draft_shield_layers = getDraftShieldLayerCount(storage.print_layer_count);
if (draft_shield_layers <= 0)
{
return;
}
unsigned int max_screen_layer = (draft_shield_height - layer_height_0) / layer_height + 1;
int layer_skip = 500 / layer_height + 1;
const int layer_height = getSettingInMicrons("layer_height");
const unsigned int layer_skip = 500 / layer_height + 1;
Polygons& draft_shield = storage.draft_protection_shield;
for (unsigned int layer_nr = 0; layer_nr < total_layers && layer_nr < max_screen_layer; layer_nr += layer_skip)
for (unsigned int layer_nr = 0; layer_nr < storage.print_layer_count && layer_nr < draft_shield_layers; layer_nr += layer_skip)
{
draft_shield = draft_shield.unionPolygons(storage.getLayerOutlines(layer_nr, true));
}
storage.draft_protection_shield = draft_shield.convexHull(draft_shield_dist);
const int draft_shield_dist = getSettingInMicrons("draft_shield_dist");
storage.draft_protection_shield = draft_shield.approxConvexHull(draft_shield_dist);
}
void FffPolygonGenerator::processPlatformAdhesion(SliceDataStorage& storage)
{
SettingsBaseVirtual* train = storage.meshgroup->getExtruderTrain(getSettingBoolean("adhesion_extruder_nr"));
switch(getSettingAsPlatformAdhesion("adhesion_type"))
{
case EPlatformAdhesion::SKIRT:
if (getSettingInMicrons("draft_shield_height") == 0)
{ // draft screen replaces skirt
generateSkirt(storage, getSettingInMicrons("skirt_gap"), getSettingAsCount("skirt_line_count"), getSettingInMicrons("skirt_minimal_length"));
{
constexpr bool outside_polygons_only = true;
SkirtBrim::generate(storage, train->getSettingInMicrons("skirt_gap"), train->getSettingAsCount("skirt_line_count"), outside_polygons_only);
}
break;
case EPlatformAdhesion::BRIM:
generateSkirt(storage, 0, getSettingAsCount("brim_line_count"), getSettingInMicrons("skirt_minimal_length"));
SkirtBrim::generate(storage, 0, train->getSettingAsCount("brim_line_count"), train->getSettingBoolean("brim_outside_only"));
break;
case EPlatformAdhesion::RAFT:
generateRaft(storage, getSettingInMicrons("raft_margin"));
Raft::generate(storage, train->getSettingInMicrons("raft_margin"));
break;
case EPlatformAdhesion::NONE:
break;
}
Polygons skirt_sent = storage.skirt[0];
for (int extruder = 1; extruder < storage.meshgroup->getExtruderCount(); extruder++)
skirt_sent.add(storage.skirt[extruder]);
sendPolygons(SkirtType, 0, skirt_sent, getSettingInMicrons("skirt_line_width"));
}
@@ -472,7 +800,7 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh)
for (int64_t p0pa_dist = dist_left_over; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + rand() % range_random_point_dist)
{
int r = rand() % (fuzziness * 2) - fuzziness;
Point perp_to_p0p1 = crossZ(p0p1);
Point perp_to_p0p1 = turn90CCW(p0p1);
Point fuzz = normal(perp_to_p0p1, r);
Point pa = *p0 + normal(p0p1, p0pa_dist) + fuzz;
result.add(pa);
@@ -497,7 +825,6 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh)
}
}
skin = results;
sendPolygons(Inset0Type, layer_nr, skin, mesh.getSettingInMicrons("wall_line_width_0"));
}
}
}
+71 -40
Ver Arquivo
@@ -6,9 +6,12 @@
#include "utils/polygonUtils.h"
#include "utils/NoCopy.h"
#include "utils/gettime.h"
#include "settings.h"
#include "settings/settings.h"
#include "sliceDataStorage.h"
#include "commandSocket.h"
#include "PrintFeature.h"
#include "progress/ProgressEstimator.h"
#include "progress/ProgressStageEstimator.h"
namespace cura
{
@@ -24,26 +27,14 @@ namespace cura
*/
class FffPolygonGenerator : public SettingsMessenger, NoCopy
{
private:
CommandSocket* commandSocket;
public:
/*!
* Basic constructor; doesn't set the FffAreaGenerator::commandSocket .
* Basic constructor
*/
FffPolygonGenerator(SettingsBase* settings_)
: SettingsMessenger(settings_)
, commandSocket(nullptr)
{
}
/*!
* Set the FffAreaGenerator::commandSocket
*/
void setCommandSocket(CommandSocket* socket)
{
commandSocket = socket;
}
/*!
* Slice the \p object, process the outline information into inset perimeter polygons, support area polygons, etc.
@@ -56,17 +47,18 @@ public:
private:
/*!
* Send polygons over the command socket, if there is one.
* \param type The type of polygon to send
* \param layer_nr The layer number at which the polygons occur
* \param polygons The polygons to be sent
* \brief Helper function to get the actual height of the draft shield.
*
* The draft shield is the height of the print if we've set the draft shield
* limitation to FULL. Otherwise the height is set to the height limit
* setting. If the draft shield is disabled, the height is always 0.
*
* \param total_layers The total number of layers in the print (the height
* of the draft shield if the limit is FULL.
* \return The actual height of the draft shield.
*/
void sendPolygons(PolygonType type, int layer_nr, Polygons& polygons, int line_width)
{
if (commandSocket)
commandSocket->sendPolygons(type, layer_nr, polygons, line_width);
}
unsigned int getDraftShieldLayerCount(unsigned int total_layers) const;
/*!
* Slice the \p object and store the outlines in the \p storage.
*
@@ -86,58 +78,97 @@ private:
*/
void slices2polygons(SliceDataStorage& storage, TimeKeeper& timeKeeper);
/*!
* Processes the outline information as stored in the \p storage: generates inset perimeter polygons, skin and infill
*
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param mesh_order_idx The index of the mesh_idx in \p mesh_order to process in the vector of meshes in \p storage
* \param mesh_order The order in which the meshes are processed (used for infill meshes)
* \param inset_skin_progress_estimate The progress stage estimate calculator
*/
void processBasicWallsSkinInfill(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order, ProgressStageEstimator& inset_skin_progress_estimate);
/*!
* Process the mesh to be an infill mesh: limit all outlines to within the infill of normal meshes and subtract their volume from the infill of those meshes
*
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param mesh_order_idx The index of the mesh_idx in \p mesh_order to process in the vector of meshes in \p storage
* \param mesh_order The order in which the meshes are processed
*/
void processInfillMesh(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order);
/*!
* Process features which are derived from the basic walls, skin, and infill:
* fuzzy skin, infill combine
*
* \param mesh Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
*/
void processDerivedWallsSkinInfill(SliceMeshStorage& mesh);
/*!
* Remove all bottom layers which are empty.
*
* \warning Changes \p total_layers
*
* \param storage Input and Ouput parameter: stores all layers
* \param layer_height The height of each layer
* \param total_layers The total number of layers
*/
void removeEmptyFirstLayers(SliceDataStorage& storage, int layer_height, unsigned int total_layers);
void removeEmptyFirstLayers(SliceDataStorage& storage, const int layer_height, unsigned int& total_layers);
/*!
* Set \ref SliceDataStorage::max_print_height_per_extruder and \ref SliceDataStorage::max_print_height_order and \ref SliceDataStorage::max_print_height_second_to_last_extruder
*
* \param[in,out] storage Where to retrieve mesh and support etc settings from and where the print height statistics are saved.
*/
void computePrintHeightStatistics(SliceDataStorage& storage);
/*!
* Generate the inset polygons which form the walls.
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param mesh Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param layer_nr The layer for which to generate the insets.
*/
void processInsets(SliceDataStorage& storage, unsigned int layer_nr);
void processInsets(SliceMeshStorage& mesh, unsigned int layer_nr);
/*!
* Generate the outline of the ooze shield.
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param total_layers The total number of layers
*/
void processOozeShield(SliceDataStorage& storage, unsigned int total_layers);
void processOozeShield(SliceDataStorage& storage);
/*!
* Generate the skin areas.
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param mesh Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param layer_nr The layer for which to generate the skin areas.
* \param process_infill Generate infill areas
*/
void processSkinsAndInfill(SliceDataStorage& storage, unsigned int layer_nr);
void processSkinsAndInfill(SliceMeshStorage& mesh, unsigned int layer_nr, bool process_infill);
/*!
* Generate the polygons where the draft screen should be.
*
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param total_layers The total number of layers
*/
void processDraftShield(SliceDataStorage& storage, unsigned int total_layers);
void processDraftShield(SliceDataStorage& storage);
/*!
* Generate the skirt/brim/raft areas/insets.
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
*/
void processPlatformAdhesion(SliceDataStorage& storage);
/*!
* Make the outer wall 'fuzzy'
*
* Introduce new vertices and move existing vertices in or out by a random distance, based on the fuzzy skin settings.
*
* This only changes the outer wall.
*
* \param[in,out] mesh where the outer wall is retrieved and stored in.
*/
void processFuzzyWalls(SliceMeshStorage& mesh);
};
}//namespace cura
#endif // FFF_AREA_GENERATOR_H
+45 -36
Ver Arquivo
@@ -5,12 +5,25 @@ namespace cura
FffProcessor FffProcessor::instance; // definition must be in cpp
FffProcessor::FffProcessor()
: polygon_generator(this)
, gcode_writer(this)
, meshgroup_number(0)
{
}
int FffProcessor::getMeshgroupNr()
{
return meshgroup_number;
}
std::string FffProcessor::getAllSettingsString(MeshGroup& meshgroup, bool first_meshgroup)
{
std::stringstream sstream;
if (first_meshgroup)
{
sstream << getAllLocalSettingsString(); // global settings
sstream << " -g";
}
else
@@ -26,50 +39,38 @@ std::string FffProcessor::getAllSettingsString(MeshGroup& meshgroup, bool first_
for (unsigned int mesh_idx = 0; mesh_idx < meshgroup.meshes.size(); mesh_idx++)
{
Mesh& mesh = meshgroup.meshes[mesh_idx];
sstream << " -e" << mesh.getSettingAsCount("extruder_nr") << " -l \"" << mesh_idx << "\"" << mesh.getAllLocalSettingsString();
sstream << " -e" << mesh.getSettingAsIndex("extruder_nr") << " -l \"" << mesh_idx << "\"" << mesh.getAllLocalSettingsString();
}
sstream << "\n";
return sstream.str();
}
bool FffProcessor::processFiles(const std::vector< std::string >& files)
{
time_keeper.restart();
MeshGroup* meshgroup = new MeshGroup(this);
for(std::string filename : files)
{
log("Loading %s from disk...\n", filename.c_str());
FMatrix3x3 matrix;
if (!loadMeshIntoMeshGroup(meshgroup, filename.c_str(), matrix))
{
logError("Failed to load model: %s\n", filename.c_str());
return false;
}
}
meshgroup->finalize();
log("Loaded from disk in %5.3fs\n", time_keeper.restart());
return processMeshGroup(meshgroup);
}
bool FffProcessor::processMeshGroup(MeshGroup* meshgroup)
{
if (SHOW_ALL_SETTINGS) { logWarning(getAllSettingsString(*meshgroup, first_meshgroup).c_str()); }
if (SHOW_ALL_SETTINGS) { logWarning(getAllSettingsString(*meshgroup, meshgroup_number == 0).c_str()); }
time_keeper.restart();
if (!meshgroup)
return false;
TimeKeeper time_keeper_total;
if (meshgroup->meshes.empty())
polygon_generator.setParent(meshgroup);
gcode_writer.setParent(meshgroup);
bool empty = true;
for (Mesh& mesh : meshgroup->meshes)
{
Progress::messageProgress(Progress::Stage::FINISH, 1, 1, command_socket); //Report the GUI that a file has been fully processed.
if (!mesh.getSettingBoolean("infill_mesh") && !mesh.getSettingBoolean("anti_overhang_mesh"))
{
empty = false;
}
}
if (empty)
{
Progress::messageProgress(Progress::Stage::FINISH, 1, 1); // 100% on this meshgroup
log("Total time elapsed %5.2fs.\n", time_keeper_total.restart());
profile_string += getAllSettingsString(*meshgroup, first_meshgroup);
profile_string += getAllSettingsString(*meshgroup, meshgroup_number == 0);
return true;
}
@@ -78,11 +79,11 @@ bool FffProcessor::processMeshGroup(MeshGroup* meshgroup)
log("starting Neith Weaver...\n");
Weaver w(this);
w.weave(meshgroup, command_socket);
w.weave(meshgroup);
log("starting Neith Gcode generation...\n");
Wireframe2gcode gcoder(w, gcode_writer.gcode, this);
gcoder.writeGCode(command_socket);
gcoder.writeGCode();
log("finished Neith Gcode generation...\n");
} else
@@ -93,17 +94,25 @@ bool FffProcessor::processMeshGroup(MeshGroup* meshgroup)
{
return false;
}
gcode_writer.setCommandSocket(command_socket);
Progress::messageProgressStage(Progress::Stage::EXPORT, &time_keeper, command_socket);
Progress::messageProgressStage(Progress::Stage::EXPORT, &time_keeper);
gcode_writer.writeGCode(storage, time_keeper);
}
Progress::messageProgress(Progress::Stage::FINISH, 1, 1, command_socket); //Report the GUI that a file has been fully processed.
Progress::messageProgress(Progress::Stage::FINISH, 1, 1); // 100% on this meshgroup
if (CommandSocket::isInstantiated())
{
CommandSocket::getInstance()->flushGcode();
CommandSocket::getInstance()->sendOptimizedLayerData();
}
log("Total time elapsed %5.2fs.\n", time_keeper_total.restart());
profile_string += getAllSettingsString(*meshgroup, first_meshgroup);
first_meshgroup = false;
profile_string += getAllSettingsString(*meshgroup, meshgroup_number == 0);
meshgroup_number++;
polygon_generator.setParent(this); // otherwise consequent getSetting calls (e.g. for finalize) will refer to non-existent meshgroup
gcode_writer.setParent(this); // otherwise consequent getSetting calls (e.g. for finalize) will refer to non-existent meshgroup
return true;
}
+102 -33
Ver Arquivo
@@ -1,13 +1,13 @@
#ifndef FFF_PROCESSOR_H
#define FFF_PROCESSOR_H
#include "settings.h"
#include "settings/settings.h"
#include "FffGcodeWriter.h"
#include "FffPolygonGenerator.h"
#include "commandSocket.h"
#include "Weaver.h"
#include "Wireframe2gcode.h"
#include "Progress.h"
#include "progress/Progress.h"
#include "utils/gettime.h"
#include "utils/NoCopy.h"
@@ -19,76 +19,145 @@ namespace cura {
class FffProcessor : public SettingsBase , NoCopy
{
private:
/*!
* The FffProcessor used for the (current) slicing (The instance of this singleton)
*/
static FffProcessor instance;
FffProcessor()
: polygon_generator(this)
, gcode_writer(this)
, first_meshgroup(true)
{
command_socket = NULL;
}
FffProcessor();
public:
/*!
* Get the instance
* \return The instance
*/
static FffProcessor* getInstance()
{
return &instance;
}
/*!
* Get the index of the meshgroup currently being processed, starting at zero.
*/
int getMeshgroupNr();
private:
/*!
* The polygon generator, which slices the models and generates all polygons to be printed and areas to be filled.
*/
FffPolygonGenerator polygon_generator;
/*!
* The gcode writer, which generates paths in layer plans in a buffer, which converts these paths into gcode commands.
*/
FffGcodeWriter gcode_writer;
CommandSocket* command_socket; // TODO: replace all refs to command_socket by CommandSocket::getInstance()
bool first_meshgroup;
/*!
* The index of the meshgroup currently being processed, starting at zero.
*/
int meshgroup_number;
/*!
* A string containing all setting values passed to the engine in the format by which CuraEngine is called via the command line.
*
* Used in debugging.
*/
std::string profile_string = "";
/*!
* Get all settings for the current meshgroup in the format by which CuraEngine is called via the command line.
*
* Also includes all global settings if this is the first meshgroup.
*
* Used in debugging.
*
* \param meshgroup The meshgroup for which to stringify all settings
* \param first_meshgroup Whether this is the first meshgroup and all global settigns should be included as well
*/
std::string getAllSettingsString(MeshGroup& meshgroup, bool first_meshgroup);
public:
/*!
* Get a string containing all setting values passed to the engine in the format by which CuraEngine is called via the command line.
*
* \return A string containing all setting values passed to the engine in the format by which CuraEngine is called via the command line.
*/
std::string getProfileString() { return profile_string; }
/*!
* The stop watch used to time how long the different stages take to compute.
*/
TimeKeeper time_keeper; // TODO: use singleton time keeper
void resetFileNumber()
/*!
* Reset the meshgroup number to the first meshgroup to start a new slicing.
*/
void resetMeshGroupNumber()
{
gcode_writer.resetFileNumber();
meshgroup_number = 0;
}
void setCommandSocket(CommandSocket* socket)
{
command_socket = socket;
gcode_writer.setCommandSocket(socket);
polygon_generator.setCommandSocket(socket);
}
/*!
* Set the target to write gcode to: to a file.
*
* Used when CuraEngine is used as command line tool.
*
* \param filename The filename of the file to which to write the gcode.
*/
bool setTargetFile(const char* filename)
{
return gcode_writer.setTargetFile(filename);
}
/*!
* Set the target to write gcode to: an output stream.
*
* Used when CuraEngine is NOT used as command line tool.
*
* \param stream The stream to write gcode to.
*/
void setTargetStream(std::ostream* stream)
{
return gcode_writer.setTargetStream(stream);
}
double getTotalFilamentUsed(int e)
/*!
* Get the total extruded volume for a specific extruder in mm^3
*
* Retractions and unretractions don't contribute to this.
*
* \param extruder_nr The extruder number for which to get the total netto extruded volume
* \return total filament printed in mm^3
*/
double getTotalFilamentUsed(int extruder_nr)
{
return gcode_writer.getTotalFilamentUsed(e);
return gcode_writer.getTotalFilamentUsed(extruder_nr);
}
/*!
* Get the total estimated print time in seconds
*
* \return total print time in seconds
*/
double getTotalPrintTime()
{
return gcode_writer.getTotalPrintTime();
}
/*!
* Add the end gcode and set all temperatures to zero.
*/
void finalize()
{
gcode_writer.finalize();
}
bool processFiles(const std::vector<std::string> &files);
/*!
* Generate gcode for a given \p meshgroup
* The primary function of this class.
*
* \param meshgroup The meshgroup for which to generate gcode
* \return Whether this function succeeded
*/
bool processMeshGroup(MeshGroup* meshgroup);
};
+80
Ver Arquivo
@@ -0,0 +1,80 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "utils/intpoint.h" // INT2MM
#include "GCodePathConfig.h"
namespace cura
{
GCodePathConfig::GCodePathConfig(const GCodePathConfig& other)
: type(other.type)
, speed_derivatives(other.speed_derivatives)
, line_width(other.line_width)
, layer_thickness(other.layer_thickness)
, flow(other.flow)
, extrusion_mm3_per_mm(other.extrusion_mm3_per_mm)
{
}
GCodePathConfig::GCodePathConfig(PrintFeatureType type, int line_width, int layer_height, double flow, GCodePathConfig::SpeedDerivatives speed_derivatives)
: type(type)
, speed_derivatives(speed_derivatives)
, line_width(line_width)
, layer_thickness(layer_height)
, flow(flow)
, extrusion_mm3_per_mm(calculateExtrusion())
{
}
void GCodePathConfig::smoothSpeed(GCodePathConfig::SpeedDerivatives first_layer_config, int layer_nr, int max_speed_layer_nr)
{
double max_speed_layer = max_speed_layer_nr;
speed_derivatives.speed = (speed_derivatives.speed * layer_nr) / max_speed_layer + (first_layer_config.speed * (max_speed_layer - layer_nr) / max_speed_layer);
speed_derivatives.acceleration = (speed_derivatives.acceleration * layer_nr) / max_speed_layer + (first_layer_config.acceleration * (max_speed_layer - layer_nr) / max_speed_layer);
speed_derivatives.jerk = (speed_derivatives.jerk * layer_nr) / max_speed_layer + (first_layer_config.jerk * (max_speed_layer - layer_nr) / max_speed_layer);
}
double GCodePathConfig::getExtrusionMM3perMM() const
{
return extrusion_mm3_per_mm;
}
double GCodePathConfig::getSpeed() const
{
return speed_derivatives.speed;
}
double GCodePathConfig::getAcceleration() const
{
return speed_derivatives.acceleration;
}
double GCodePathConfig::getJerk() const
{
return speed_derivatives.jerk;
}
int GCodePathConfig::getLineWidth() const
{
return line_width;
}
bool GCodePathConfig::isTravelPath() const
{
return line_width == 0;
}
double GCodePathConfig::getFlowPercentage() const
{
return flow;
}
double GCodePathConfig::calculateExtrusion() const
{
return INT2MM(line_width) * INT2MM(layer_thickness) * double(flow) / 100.0;
}
}//namespace cura
+88
Ver Arquivo
@@ -0,0 +1,88 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef G_CODE_PATH_CONFIG_H
#define G_CODE_PATH_CONFIG_H
#include "RetractionConfig.h"
#include "PrintFeature.h"
namespace cura
{
/*!
* The GCodePathConfig is the configuration for moves/extrusion actions. This defines at which width the line is printed and at which speed.
*/
class GCodePathConfig
{
friend class GCodePlannerTest;
public:
/*!
* A simple wrapper class for all derivatives of position which are used when printing a line
*/
struct SpeedDerivatives
{
double speed; //!< movement speed (mm/s)
double acceleration; //!< acceleration of head movement (mm/s^2)
double jerk; //!< jerk of the head movement (around stand still) as instantaneous speed change (mm/s)
};
const PrintFeatureType type; //!< name of the feature type
private:
SpeedDerivatives speed_derivatives; //!< The speed settings (and acceleration and jerk) of the extruded line. May be changed when smoothSpeed is called.
const int line_width; //!< width of the line extruded
const int layer_thickness; //!< current layer height in micron
const double flow; //!< extrusion flow modifier in %
const double extrusion_mm3_per_mm;//!< current mm^3 filament moved per mm line traversed
public:
GCodePathConfig(PrintFeatureType type, int line_width, int layer_height, double flow, SpeedDerivatives speed_derivatives); // , SpeedDerivatives slowdown_speed_derivatives, int layer_nr, int max_speed_layer_nr);
/*!
* copy constructor
*/
GCodePathConfig(const GCodePathConfig& other);
/*!
* Set the speed to somewhere between the speed of @p first_layer_config and the iconic speed.
*
* \warning This functions should not be called with @p layer_nr > @p max_speed_layer !
*
* \warning Calling this function twice will smooth the speed more toward \p first_layer_config
*
* \param first_layer_config The speed settings at layer zero
* \param layer_nr The layer number
* \param max_speed_layer The layer number for which the speed_iconic should be used.
*/
void smoothSpeed(SpeedDerivatives first_layer_config, int layer_nr, int max_speed_layer);
/*!
* Can only be called after the layer height has been set (which is done while writing the gcode!)
*/
double getExtrusionMM3perMM() const;
/*!
* Get the movement speed in mm/s
*/
double getSpeed() const;
/*!
* Get the current acceleration of this config
*/
double getAcceleration() const;
/*!
* Get the current jerk of this config
*/
double getJerk() const;
int getLineWidth() const;
bool isTravelPath() const;
double getFlowPercentage() const;
private:
double calculateExtrusion() const;
};
}//namespace cura
#endif // G_CODE_PATH_CONFIG_H
+310 -133
Ver Arquivo
@@ -3,6 +3,7 @@
#include "LayerPlanBuffer.h"
#include "gcodeExport.h"
#include "utils/logoutput.h"
#include "FffProcessor.h"
namespace cura {
@@ -12,216 +13,392 @@ void LayerPlanBuffer::flush()
{
if (buffer.size() > 0)
{
insertPreheatCommands(); // insert preheat commands of the very last layer
insertTempCommands(); // insert preheat commands of the very last layer
}
for (GCodePlanner& layer_plan : buffer)
while (!buffer.empty())
{
layer_plan.writeGCode(gcode, getSettingBoolean("cool_lift_head"), layer_plan.getLayerNr() > 0 ? getSettingInMicrons("layer_height") : getSettingInMicrons("layer_height_0"));
if (command_socket)
command_socket->sendGCodeLayer();
buffer.front()->writeGCode(gcode);
if (CommandSocket::isInstantiated())
{
CommandSocket::getInstance()->flushGcode();
}
buffer.pop_front();
}
}
void LayerPlanBuffer::insertPreheatCommand(ExtruderPlan& extruder_plan_before, double time_after_extruder_plan_start, int extruder, double temp)
{
double acc_time = 0.0;
for (unsigned int path_idx = 0; path_idx < extruder_plan_before.paths.size(); path_idx++)
for (unsigned int path_idx = extruder_plan_before.paths.size() - 1; int(path_idx) != -1 ; path_idx--)
{
GCodePath& path = extruder_plan_before.paths[path_idx];
acc_time += path.estimates.getTotalTime();
const double time_this_path = path.estimates.getTotalTime();
acc_time += time_this_path;
if (acc_time > time_after_extruder_plan_start)
{
// logError("Inserting %f\t seconds too early!\n", acc_time - time_after_extruder_plan_start);
extruder_plan_before.insertCommand(path_idx, extruder, temp, false, acc_time - time_after_extruder_plan_start);
const double time_before_path_end = acc_time - time_after_extruder_plan_start;
bool wait = false;
extruder_plan_before.insertCommand(path_idx, extruder, temp, wait, time_this_path - time_before_path_end);
return;
}
}
extruder_plan_before.insertCommand(extruder_plan_before.paths.size(), extruder, temp, false); // insert at end of extruder plan if time_after_extruder_plan_start > extruder_plan.time
// = special insert after all extruder plans
bool wait = false;
unsigned int path_idx = 0;
extruder_plan_before.insertCommand(path_idx, extruder, temp, wait); // insert at start of extruder plan if time_after_extruder_plan_start > extruder_plan.time
}
double LayerPlanBuffer::timeBeforeExtruderPlanToInsert(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx)
Preheat::WarmUpResult LayerPlanBuffer::timeBeforeExtruderPlanToInsert(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx)
{
ExtruderPlan& extruder_plan = layers[layer_plan_idx]->extruder_plans[extruder_plan_idx];
ExtruderPlan& extruder_plan = *extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
double required_temp = extruder_plan.required_temp;
unsigned int extruder_plan_before_idx = extruder_plan_idx - 1;
bool first_it = true;
double initial_print_temp = extruder_plan.initial_printing_temperature;
double in_between_time = 0.0;
for (unsigned int layer_idx = layer_plan_idx; int(layer_idx) >= 0; layer_idx--)
{
GCodePlanner& layer = *layers[layer_idx];
if (!first_it)
for (unsigned int extruder_plan_before_idx = extruder_plan_idx - 1; int(extruder_plan_before_idx) >= 0; extruder_plan_before_idx--)
{ // find a previous extruder plan where the same extruder is used to see what time this extruder wasn't used
ExtruderPlan& extruder_plan_before = *extruder_plans[extruder_plan_before_idx];
if (extruder_plan_before.extruder == extruder)
{
extruder_plan_before_idx = layer.extruder_plans.size() - 1;
}
for ( ; int(extruder_plan_before_idx) >= 0; extruder_plan_before_idx--)
{
ExtruderPlan& extruder_plan = layer.extruder_plans[extruder_plan_before_idx];
if (extruder_plan.extruder == extruder)
double temp_before = preheat_config.getFinalPrintTemp(extruder);
if (temp_before == 0)
{
return preheat_config.timeBeforeEndToInsertPreheatCommand_coolDownWarmUp(in_between_time, extruder, required_temp);
temp_before = extruder_plan_before.printing_temperature;
}
in_between_time += extruder_plan.estimates.getTotalTime();
constexpr bool during_printing = false;
Preheat::WarmUpResult warm_up = preheat_config.getWarmUpPointAfterCoolDown(in_between_time, extruder, temp_before, preheat_config.getStandbyTemp(extruder), initial_print_temp, during_printing);
warm_up.heating_time = std::min(in_between_time, warm_up.heating_time + extra_preheat_time);
return warm_up;
}
first_it = false;
in_between_time += extruder_plan_before.estimates.getTotalTime();
}
// The last extruder plan with the same extruder falls outside of the buffer
// assume the nozzle has cooled down to strandby temperature already.
return preheat_config.timeBeforeEndToInsertPreheatCommand_warmUp(preheat_config.getStandbyTemp(extruder), extruder, required_temp, false);
Preheat::WarmUpResult warm_up;
warm_up.total_time_window = in_between_time;
warm_up.lowest_temperature = preheat_config.getStandbyTemp(extruder);
constexpr bool during_printing = false;
warm_up.heating_time = preheat_config.getTimeToGoFromTempToTemp(extruder, warm_up.lowest_temperature, initial_print_temp, during_printing);
if (warm_up.heating_time > in_between_time)
{
warm_up.heating_time = in_between_time;
warm_up.lowest_temperature = in_between_time / preheat_config.getTimeToHeatup1Degree(extruder, during_printing);
}
warm_up.heating_time = warm_up.heating_time + extra_preheat_time;
return warm_up;
}
void LayerPlanBuffer::insertPreheatCommand_singleExtrusion(ExtruderPlan& prev_extruder_plan, int extruder, double required_temp)
{
// time_before_extruder_plan_end is halved, so that at the layer change the temperature will be half way betewen the two requested temperatures
double time_before_extruder_plan_end = 0.5 * preheat_config.timeBeforeEndToInsertPreheatCommand_warmUp(prev_extruder_plan.required_temp, extruder, required_temp, true);
double time_after_extruder_plan_start = prev_extruder_plan.estimates.getTotalTime() - time_before_extruder_plan_end;
if (time_after_extruder_plan_start < 0)
{
time_after_extruder_plan_start = 0; // don't override the extruder plan with same extruder of the previous layer
}
insertPreheatCommand(prev_extruder_plan, time_after_extruder_plan_start, extruder, required_temp);
constexpr bool during_printing = true;
double time_before_extruder_plan_end = 0.5 * preheat_config.getTimeToGoFromTempToTemp(extruder, prev_extruder_plan.printing_temperature, required_temp, during_printing);
time_before_extruder_plan_end = std::min(prev_extruder_plan.estimates.getTotalTime(), time_before_extruder_plan_end);
insertPreheatCommand(prev_extruder_plan, time_before_extruder_plan_end, extruder, required_temp);
}
void LayerPlanBuffer::insertPreheatCommand_multiExtrusion(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx)
void LayerPlanBuffer::handleStandbyTemp(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx, double standby_temp)
{
ExtruderPlan& extruder_plan = layers[layer_plan_idx]->extruder_plans[extruder_plan_idx];
ExtruderPlan& extruder_plan = *extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
double required_temp = extruder_plan.required_temp;
extruder_plan.insertCommand(0, extruder, required_temp, true); // just after the extruder switch, wait for the destination temperature to be reached
double time_before_extruder_plan_to_insert = timeBeforeExtruderPlanToInsert(layers, layer_plan_idx, extruder_plan_idx);
unsigned int extruder_plan_before_idx = extruder_plan_idx - 1;
bool first_it = true; // Whether it's the first iteration of the for loop below
for (unsigned int layer_idx = layer_plan_idx; int(layer_idx) >= 0; layer_idx--)
for (unsigned int extruder_plan_before_idx = extruder_plan_idx - 2; int(extruder_plan_before_idx) >= 0; extruder_plan_before_idx--)
{
GCodePlanner& layer = *layers[layer_idx];
if (!first_it)
if (extruder_plans[extruder_plan_before_idx]->extruder == extruder)
{
extruder_plan_before_idx = layer.extruder_plans.size() - 1;
}
for ( ; int(extruder_plan_before_idx) >= 0; extruder_plan_before_idx--)
{
ExtruderPlan& extruder_plan_before = layer.extruder_plans[extruder_plan_before_idx];
assert (extruder_plan_before.extruder != extruder);
double time_here = extruder_plan_before.estimates.getTotalTime();
if (time_here > time_before_extruder_plan_to_insert)
{
insertPreheatCommand(extruder_plan_before, time_here - time_before_extruder_plan_to_insert, extruder, required_temp);
return;
}
time_before_extruder_plan_to_insert -= time_here;
}
first_it = false;
}
// time_before_extruder_plan_to_insert falls before all plans in the buffer
ExtruderPlan& first_extruder_plan = layers[0]->extruder_plans[0];
first_extruder_plan.insertCommand(0, extruder, required_temp, false); // insert preheat command at verfy beginning of buffer
}
void LayerPlanBuffer::insertPreheatCommand(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx)
{
ExtruderPlan& extruder_plan = layers[layer_plan_idx]->extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
double required_temp = extruder_plan.required_temp;
ExtruderPlan* prev_extruder_plan = nullptr;
if (extruder_plan_idx == 0)
{
if (layer_plan_idx == 0)
{ // the very first extruder plan
for (int extruder_idx = 0; extruder_idx < getSettingAsCount("machine_extruder_count"); extruder_idx++)
{ // set temperature of the first nozzle, turn other nozzles down
if (extruder_idx == extruder)
{
// extruder_plan.insertCommand(0, extruder, required_temp, true);
// the first used extruder should already be set to the required temp in the start gcode
}
else
{
extruder_plan.insertCommand(0, extruder_idx, preheat_config.getStandbyTemp(extruder_idx), false);
}
}
extruder_plans[extruder_plan_before_idx + 1]->prev_extruder_standby_temp = standby_temp;
return;
}
prev_extruder_plan = &layers[layer_plan_idx - 1]->extruder_plans.back();
}
else
logWarning("Warning: Couldn't find previous extruder plan so as to set the standby temperature. Inserting temp command in earliest available layer.\n");
ExtruderPlan& earliest_extruder_plan = *extruder_plans[0];
constexpr bool wait = false;
earliest_extruder_plan.insertCommand(0, extruder, standby_temp, wait);
}
void LayerPlanBuffer::insertPreheatCommand_multiExtrusion(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx)
{
ExtruderPlan& extruder_plan = *extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
double initial_print_temp = extruder_plan.initial_printing_temperature;
Preheat::WarmUpResult heating_time_and_from_temp = timeBeforeExtruderPlanToInsert(extruder_plans, extruder_plan_idx);
if (heating_time_and_from_temp.total_time_window < preheat_config.getMinimalTimeWindow(extruder))
{
prev_extruder_plan = &layers[layer_plan_idx]->extruder_plans[extruder_plan_idx - 1];
handleStandbyTemp(extruder_plans, extruder_plan_idx, initial_print_temp);
return; // don't insert preheat command and just stay on printing temperature
}
assert(prev_extruder_plan != nullptr);
else
{
handleStandbyTemp(extruder_plans, extruder_plan_idx, heating_time_and_from_temp.lowest_temperature);
}
// handle preheat command
double time_before_extruder_plan_to_insert = heating_time_and_from_temp.heating_time;
for (unsigned int extruder_plan_before_idx = extruder_plan_idx - 1; int(extruder_plan_before_idx) >= 0; extruder_plan_before_idx--)
{
ExtruderPlan& extruder_plan_before = *extruder_plans[extruder_plan_before_idx];
assert (extruder_plan_before.extruder != extruder);
double time_here = extruder_plan_before.estimates.getTotalTime();
if (time_here >= time_before_extruder_plan_to_insert)
{
insertPreheatCommand(extruder_plan_before, time_before_extruder_plan_to_insert, extruder, initial_print_temp);
return;
}
time_before_extruder_plan_to_insert -= time_here;
}
// time_before_extruder_plan_to_insert falls before all plans in the buffer
bool wait = false;
unsigned int path_idx = 0;
extruder_plans[0]->insertCommand(path_idx, extruder, initial_print_temp, wait); // insert preheat command at verfy beginning of buffer
}
void LayerPlanBuffer::insertTempCommands(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx)
{
ExtruderPlan& extruder_plan = *extruder_plans[extruder_plan_idx];
int extruder = extruder_plan.extruder;
ExtruderPlan* prev_extruder_plan = extruder_plans[extruder_plan_idx - 1];
int prev_extruder = prev_extruder_plan->extruder;
if (prev_extruder != extruder)
{ // set previous extruder to standby temperature
prev_extruder_plan->insertCommand(prev_extruder_plan->paths.size(), prev_extruder, preheat_config.getStandbyTemp(prev_extruder), false);
extruder_plan.prev_extruder_standby_temp = preheat_config.getStandbyTemp(prev_extruder);
}
if (prev_extruder == extruder)
{
if (preheat_config.usesFlowDependentTemp(extruder))
{
insertPreheatCommand_singleExtrusion(*prev_extruder_plan, extruder, required_temp);
}
insertPreheatCommand_singleExtrusion(*prev_extruder_plan, extruder, extruder_plan.printing_temperature);
prev_extruder_plan->printing_temperature_command = --prev_extruder_plan->inserts.end();
}
else
{
insertPreheatCommand_multiExtrusion(layers, layer_plan_idx, extruder_plan_idx);
insertPreheatCommand_multiExtrusion(extruder_plans, extruder_plan_idx);
insertFinalPrintTempCommand(extruder_plans, extruder_plan_idx - 1);
insertPrintTempCommand(extruder_plan);
}
}
void LayerPlanBuffer::insertPreheatCommands()
void LayerPlanBuffer::insertPrintTempCommand(ExtruderPlan& extruder_plan)
{
if (buffer.back().extruder_plans.size() == 0 || (buffer.back().extruder_plans.size() == 1 && buffer.back().extruder_plans[0].paths.size() == 0))
unsigned int extruder = extruder_plan.extruder;
double print_temp = extruder_plan.printing_temperature;
double heated_pre_travel_time = 0;
if (preheat_config.getInitialPrintTemp(extruder) != 0)
{ // handle heating from initial_print_temperature to printing_tempreature
unsigned int path_idx;
for (path_idx = 0; path_idx < extruder_plan.paths.size(); path_idx++)
{
GCodePath& path = extruder_plan.paths[path_idx];
heated_pre_travel_time += path.estimates.getTotalTime();
if (!path.isTravelPath())
{
break;
}
}
bool wait = false;
extruder_plan.insertCommand(path_idx, extruder, print_temp, wait);
}
extruder_plan.heated_pre_travel_time = heated_pre_travel_time;
}
void LayerPlanBuffer::insertFinalPrintTempCommand(std::vector<ExtruderPlan*>& extruder_plans, unsigned int last_extruder_plan_idx)
{
ExtruderPlan& last_extruder_plan = *extruder_plans[last_extruder_plan_idx];
int extruder = last_extruder_plan.extruder;
double final_print_temp = preheat_config.getFinalPrintTemp(extruder);
if (final_print_temp == 0)
{
return;
}
double heated_post_travel_time = 0; // The time after the last extrude move toward the end of the extruder plan during which the nozzle is stable at the final print temperature
{ // compute heated_post_travel_time
unsigned int path_idx;
for (path_idx = last_extruder_plan.paths.size() - 1; int(path_idx) >= 0; path_idx--)
{
GCodePath& path = last_extruder_plan.paths[path_idx];
if (!path.isTravelPath())
{
break;
}
heated_post_travel_time += path.estimates.getTotalTime();
}
}
double time_window = 0; // The time window within which the nozzle needs to heat from the initial print temp to the printing temperature and then back to the final print temp; i.e. from the first to the last extrusion move with this extruder
double weighted_average_print_temp = 0; // The average of the normal printing temperatures of the extruder plans (which might be different due to flow dependent temp or due to initial layer temp) Weighted by time
double initial_print_temp = -1; // The initial print temp of the first extruder plan with this extruder
{ // compute time window and print temp statistics
double heated_pre_travel_time = -1; // The time before the first extrude move from the start of the extruder plan during which the nozzle is stable at the initial print temperature
for (unsigned int prev_extruder_plan_idx = last_extruder_plan_idx; (int)prev_extruder_plan_idx >= 0; prev_extruder_plan_idx--)
{
ExtruderPlan& prev_extruder_plan = *extruder_plans[prev_extruder_plan_idx];
if (prev_extruder_plan.extruder != extruder)
{
break;
}
double prev_extruder_plan_time = prev_extruder_plan.estimates.getTotalTime();
time_window += prev_extruder_plan_time;
heated_pre_travel_time = prev_extruder_plan.heated_pre_travel_time;
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;
initial_print_temp = prev_extruder_plan.initial_printing_temperature;
}
}
weighted_average_print_temp /= time_window;
time_window -= heated_pre_travel_time + heated_post_travel_time;
assert(heated_pre_travel_time != -1 && "heated_pre_travel_time must have been computed; there must have been an extruder plan!");
}
assert((time_window >= 0 || last_extruder_plan.estimates.getMaterial() == 0) && "Time window should always be positive if we actually extrude");
// ,layer change .
// : ,precool command ,layer change .
// : ____: : ,precool command .
// :/ \ _____:_____: .
// _____/ \ / \ .
// / \ / \ .
// / / .
// / / .
// .
// approximate ^ by ^ .
// This approximation is quite ok since it only determines where to insert the precool temp command,
// which means the stable temperature of the previous extruder plan and the stable temperature of the next extruder plan couldn't be reached
constexpr bool during_printing = true;
Preheat::CoolDownResult warm_cool_result = preheat_config.getCoolDownPointAfterWarmUp(time_window, extruder, initial_print_temp, weighted_average_print_temp, final_print_temp, during_printing);
double cool_down_time = warm_cool_result.cooling_time;
assert(cool_down_time >= 0);
// find extruder plan in which to insert cooling command
ExtruderPlan* precool_extruder_plan = &last_extruder_plan;
{
for (unsigned int precool_extruder_plan_idx = last_extruder_plan_idx; (int)precool_extruder_plan_idx >= 0; precool_extruder_plan_idx--)
{
precool_extruder_plan = extruder_plans[precool_extruder_plan_idx];
if (precool_extruder_plan->printing_temperature_command)
{ // the precool command ends up before the command to go to the print temperature of the next extruder plan, so remove that print temp command
precool_extruder_plan->inserts.erase(*precool_extruder_plan->printing_temperature_command);
}
double time_here = precool_extruder_plan->estimates.getTotalTime();
if (cool_down_time < time_here)
{
break;
}
cool_down_time -= time_here;
}
}
// at this point cool_down_time is what time is left if cool down time of extruder plans after precool_extruder_plan (up until last_extruder_plan) are already taken into account
{ // insert temp command in precool_extruder_plan
double extrusion_time_seen = 0;
unsigned int path_idx;
for (path_idx = precool_extruder_plan->paths.size() - 1; int(path_idx) >= 0; path_idx--)
{
GCodePath& path = precool_extruder_plan->paths[path_idx];
extrusion_time_seen += path.estimates.getTotalTime();
if (extrusion_time_seen >= cool_down_time)
{
break;
}
}
bool wait = false;
double time_after_path_start = extrusion_time_seen - cool_down_time;
precool_extruder_plan->insertCommand(path_idx, extruder, final_print_temp, wait, time_after_path_start);
}
}
void LayerPlanBuffer::insertTempCommands()
{
if (buffer.back()->extruder_plans.size() == 0 || (buffer.back()->extruder_plans.size() == 1 && buffer.back()->extruder_plans[0].paths.size() == 0))
{ // disregard empty layer
buffer.pop_back();
return;
}
std::vector<GCodePlanner*> layers;
layers.reserve(buffer.size());
for (GCodePlanner& layer_plan : buffer)
std::vector<ExtruderPlan*> extruder_plans;
extruder_plans.reserve(buffer.size() * 2);
for (GCodePlanner* layer_plan : buffer)
{
layers.push_back(&layer_plan);
for (ExtruderPlan& extr_plan : layer_plan->extruder_plans)
{
extruder_plans.push_back(&extr_plan);
}
}
unsigned int layer_idx = layers.size() - 1;
// insert commands for all extruder plans on this layer
GCodePlanner& layer_plan = *layers[layer_idx];
GCodePlanner& layer_plan = *buffer.back();
for (unsigned int extruder_plan_idx = 0; extruder_plan_idx < layer_plan.extruder_plans.size(); extruder_plan_idx++)
{
unsigned int overall_extruder_plan_idx = extruder_plans.size() - layer_plan.extruder_plans.size() + extruder_plan_idx;
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;
}
double avg_flow = extruder_plan.estimates.getMaterial() / time; // TODO: subtract retracted travel time
extruder_plan.required_temp = preheat_config.getTemp(extruder_plan.extruder, avg_flow);
insertPreheatCommand(layers, layer_idx, extruder_plan_idx);
double avg_flow = extruder_plan.estimates.getMaterial() / time;
extruder_plan.printing_temperature = preheat_config.getTemp(extruder, avg_flow, extruder_plan.is_initial_layer);
extruder_plan.initial_printing_temperature = preheat_config.getInitialPrintTemp(extruder);
if (extruder_plan.initial_printing_temperature == 0
|| !extruder_used_in_meshgroup[extruder]
|| (overall_extruder_plan_idx > 0 && extruder_plans[overall_extruder_plan_idx - 1]->extruder == extruder)
)
{
extruder_plan.initial_printing_temperature = extruder_plan.printing_temperature;
extruder_used_in_meshgroup[extruder] = true;
}
assert(extruder_plan.printing_temperature != -1 && "extruder_plan.printing_temperature should now have been set");
if (buffer.size() == 1 && extruder_plan_idx == 0)
{ // the very first extruder plan of the current meshgroup
int extruder = extruder_plan.extruder;
for (int extruder_idx = 0; extruder_idx < getSettingAsCount("machine_extruder_count"); extruder_idx++)
{ // set temperature of the first nozzle, turn other nozzles down
if (FffProcessor::getInstance()->getMeshgroupNr() == 0)
{
// override values from GCodeExport::setInitialTemps
// the first used extruder should be set to the required temp in the start gcode
// see FffGcodeWriter::processStartingCode
if (extruder_idx == extruder)
{
gcode.setInitialTemp(extruder_idx, extruder_plan.printing_temperature);
}
else
{
gcode.setInitialTemp(extruder_idx, preheat_config.getStandbyTemp(extruder_idx));
}
}
else
{
if (extruder_idx != extruder)
{ // TODO: do we need to do this?
extruder_plan.prev_extruder_standby_temp = preheat_config.getStandbyTemp(extruder_idx);
}
}
}
continue;
}
insertTempCommands(extruder_plans, overall_extruder_plan_idx);
}
}
} // namespace cura
+92 -35
Ver Arquivo
@@ -1,9 +1,10 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef LAYER_PLAN_BUFFER_H
#define LAYER_PLAN_BUFFER_H
#include <list>
#include "settings.h"
#include "settings/settings.h"
#include "commandSocket.h"
#include "gcodeExport.h"
@@ -15,78 +16,104 @@
namespace cura
{
/*!
* Class for buffering multiple layer plans (\ref GCodePlanner) / extruder plans within those layer plans, so that temperature commands can be inserted in earlier layer plans.
*
* This class handles where to insert temperature commands for:
* - initial layer temperature
* - flow dependent temperature
* - starting to heat up from the standby temperature
* - initial printing temperature | printing temperature | final printing temperature
*
* \image html assets/precool.png "Temperature Regulation" width=10cm
* \image latex assets/precool.png "Temperature Regulation" width=10cm
*
*/
class LayerPlanBuffer : SettingsMessenger
{
CommandSocket* command_socket;
GCodeExport& gcode;
Preheat preheat_config; //!< the nozzle and material temperature settings for each extruder train.
static constexpr unsigned int buffer_size = 5; // should be as low as possible while still allowing enough time in the buffer to heat up from standby temp to printing temp // TODO: hardcoded value
// this value should be higher than 1, cause otherwise each layer is viewed as the first layer and no temp commands are inserted.
static constexpr const double extra_preheat_time = 1.0; //!< Time to start heating earlier than computed to avoid accummulative discrepancy between actual heating times and computed ones.
std::vector<bool> extruder_used_in_meshgroup; //!< For each extruder whether it has already been planned once in this meshgroup. This is used to see whether we should heat to the initial_print_temp or to the printing_temperature
public:
std::list<GCodePlanner> buffer; //!< The buffer containing several layer plans (GCodePlanner) before writing them to gcode.
std::list<GCodePlanner*> buffer; //!< The buffer containing several layer plans (GCodePlanner) before writing them to gcode.
LayerPlanBuffer(SettingsBaseVirtual* settings, CommandSocket* command_socket, GCodeExport& gcode)
LayerPlanBuffer(SettingsBaseVirtual* settings, GCodeExport& gcode)
: SettingsMessenger(settings)
, command_socket(command_socket)
, gcode(gcode)
, extruder_used_in_meshgroup(MAX_EXTRUDERS, false)
{ }
void setPreheatConfig(MeshGroup& settings)
{
preheat_config.setConfig(settings);
}
/*!
* Place a new layer plan (GcodePlanner) by constructing it with the given arguments.
* Pop back the oldest layer plan is it exceeds the buffer size and write it to gcode.
* Push a new layer plan into the buffer
*/
template<typename... Args>
GCodePlanner& emplace_back(Args&&... constructor_args)
void push(GCodePlanner& layer_plan)
{
buffer.push_back(&layer_plan);
}
/*!
* Process all layers in the buffer
* This inserts the temperature commands to start warming for a given layer in earlier layers
*
* Pop out the earliest layer in the buffer if the buffer size is exceeded
* \return A nullptr or the popped gcode_layer
*/
GCodePlanner* processBuffer()
{
if (buffer.size() > 0)
{
insertPreheatCommands(); // insert preheat commands of the just completed layer plan (not the newly emplaced one)
insertTempCommands(); // insert preheat commands of the just completed layer plan (not the newly emplaced one)
}
buffer.emplace_back(constructor_args...);
if (buffer.size() > buffer_size)
{
buffer.front().writeGCode(gcode, getSettingBoolean("cool_lift_head"), buffer.front().getLayerNr() > 0 ? getSettingInMicrons("layer_height") : getSettingInMicrons("layer_height_0"));
if (command_socket)
command_socket->sendGCodeLayer();
GCodePlanner* ret = buffer.front();
if (CommandSocket::isInstantiated())
{
CommandSocket::getInstance()->flushGcode();
}
buffer.pop_front();
return ret;
}
return buffer.back();
return nullptr;
}
/*!
* Write all remaining layer plans (GCodePlanner) to gcode and empty the buffer.
*/
void flush();
private:
/*!
* Insert the preheat command for @p extruder into @p extruder_plan_before
*
* \param extruder_plan_before An extruder plan before the extruder plan for which the temperature is computed, in which to insert the preheat command
* \param time_after_extruder_plan_start The time after the start of the extruder plan, before which to insert the preheat command
* \param time_before_extruder_plan_end The time before the end of the extruder plan, before which to insert the preheat command
* \param extruder The extruder for which to set the temperature
* \param temp The temperature of the preheat command
*/
void insertPreheatCommand(ExtruderPlan& extruder_plan_before, double time_after_extruder_plan_start, int extruder, double temp);
void insertPreheatCommand(ExtruderPlan& extruder_plan_before, double time_before_extruder_plan_end, int extruder, double temp);
/*!
* Compute the time needed to preheat, based either on the time the extruder has been on standby
* or based on the temp of the previous extruder plan which has the same extruder nr.
*
* \param layers The layers in the buffer, moved to a vector
* \param layer_plan_idx The index into @p layers in which to find the extruder plan
* \param extruder_plan_idx The index of the extruder plan in the layer corresponding to @p layer_plan_idx for which to find the preheat time needed
* \return the time needed to preheat
* \param extruder_plans The extruder plans in the buffer, moved to a temporary vector (from lower to upper layers)
* \param extruder_plan_idx The index of the extruder plan in \p extruder_plans for which to find the preheat time needed
* \return the time needed to preheat and the temperature from which heating starts
*/
double timeBeforeExtruderPlanToInsert(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx);
Preheat::WarmUpResult timeBeforeExtruderPlanToInsert(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx);
/*!
* For two consecutive extruder plans of the same extruder (so on different layers),
@@ -106,25 +133,55 @@ public:
* and compute at what time the preheat command needs to be inserted.
* Then insert the preheat command in the right extruder plan.
*
* \param layers The layers in the buffer, moved to a vector
* \param layer_plan_idx The index into @p layers in which to find the extruder plan
* \param extruder_plan_idx The index of the extruder plan in the layer corresponding to @p layer_plan_idx for which to find the preheat time needed
* \param extruder_plans The extruder plans in the buffer, moved to a temporary vector (from lower to upper layers)
* \param extruder_plan_idx The index of the extruder plan in \p extruder_plans for which to find the preheat time needed
*/
void insertPreheatCommand_multiExtrusion(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx);
void insertPreheatCommand_multiExtrusion(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx);
/*!
* Insert the preheat command for the extruder plan corersponding to @p extruder_plan_idx of the layer corresponding to @p layer_plan_idx.
*
* \param layers The layers of the buffer, moved to a temporary vector (from lower to upper layers)
* \param layer_plan_idx The index of the layer plan for which to generate a preheat command
* \param extruder_plan_idx The index of the extruder plan in the layer corresponding to @p layer_plan_idx for which to generate the preheat command
* \param extruder_plans The extruder plans in the buffer, moved to a temporary vector (from lower to upper layers)
* \param extruder_plan_idx The index of the extruder plan in \p extruder_plans for which to generate the preheat command
*/
void insertPreheatCommand(std::vector<GCodePlanner*>& layers, unsigned int layer_plan_idx, unsigned int extruder_plan_idx);
void insertTempCommands(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx);
/*!
* Insert the temperature command to heat from the initial print temperature to the printing temperature
*
* The temperature command is insert at the start of the very first extrusion move
*
* \param extruder_plan The extruder plan in which to insert the heat up command
*/
void insertPrintTempCommand(ExtruderPlan& extruder_plan);
/*!
* Insert the temp command to start cooling from the printing temperature to the final print temp
*
* The print temp is inserted before the last extrusion move of the extruder plan corresponding to \p last_extruder_plan_idx
*
* The command is inserted at a timed offset before the end of the last extrusion move
*
* \param extruder_plans The extruder plans in the buffer, moved to a temporary vector (from lower to upper layers)
* \param last_extruder_plan_idx The index of the last extruder plan in \p extruder_plans with the same extruder as previous extruder plans
*/
void insertFinalPrintTempCommand(std::vector<ExtruderPlan*>& extruder_plans, unsigned int last_extruder_plan_idx);
/*!
* Insert the preheat commands for the last added layer (unless that layer was empty)
*/
void insertPreheatCommands();
void insertTempCommands();
/*!
* Reconfigure the standby temperature during which we didn't print with this extruder.
* Find the previous extruder plan with the same extruder as layers[layer_plan_idx].extruder_plans[extruder_plan_idx]
* Set the prev_extruder_standby_temp in the next extruder plan
*
* \param extruder_plans The extruder plans in the buffer, moved to a temporary vector (from lower to upper layers)
* \param extruder_plan_idx The index of the extruder plan in \p extruder_plans before which to reconfigure the standby temperature
* \param standby_temp The temperature to which to cool down when the extruder is in standby mode.
*/
void handleStandbyTemp(std::vector<ExtruderPlan*>& extruder_plans, unsigned int extruder_plan_idx, double standby_temp);
};
+124 -45
Ver Arquivo
@@ -2,6 +2,8 @@
#include <algorithm> // min
#include "utils/linearAlg2D.h"
namespace cura
{
@@ -9,13 +11,18 @@ void MergeInfillLines::writeCompensatedMove(Point& to, double speed, GCodePath&
{
double old_line_width = INT2MM(last_path.config->getLineWidth());
double new_line_width_mm = INT2MM(new_line_width);
double speed_mod = old_line_width / new_line_width_mm;
double extrusion_mod = new_line_width_mm / old_line_width;
double new_speed = std::min(speed * speed_mod, 150.0); // TODO: hardcoded value: max extrusion speed is 150 mm/s = 9000 mm/min
double new_speed = speed;
if (speed_equalize_flow_enabled)
{
double speed_mod = old_line_width / new_line_width_mm;
new_speed = std::min(speed * speed_mod, speed_equalize_flow_max);
}
sendLineTo(last_path.config->type, to, last_path.getLineWidth());
gcode.writeMove(to, new_speed, last_path.getExtrusionMM3perMM() * extrusion_mod);
}
bool MergeInfillLines::mergeInfillLines(double speed, unsigned int& path_idx)
bool MergeInfillLines::mergeInfillLines(unsigned int& path_idx)
{ //Check for lots of small moves and combine them into one large line
Point prev_middle;
Point last_middle;
@@ -28,12 +35,12 @@ bool MergeInfillLines::mergeInfillLines(double speed, unsigned int& path_idx)
GCodePath& move_path = paths[path_idx];
for(unsigned int point_idx = 0; point_idx < move_path.points.size() - 1; point_idx++)
{
gcode.writeMove(move_path.points[point_idx], speed, move_path.getExtrusionMM3perMM());
gcode.writeMove(move_path.points[point_idx], move_path.config->getSpeed() * extruder_plan.getTravelSpeedFactor(), move_path.getExtrusionMM3perMM());
}
gcode.writeMove(prev_middle, travelConfig.getSpeed(), 0);
GCodePath& last_path = paths[path_idx + 3];
writeCompensatedMove(last_middle, speed, last_path, line_width);
writeCompensatedMove(last_middle, last_path.config->getSpeed() * extruder_plan.getExtrudeSpeedFactor(), last_path, line_width);
}
path_idx += 2;
@@ -42,7 +49,7 @@ bool MergeInfillLines::mergeInfillLines(double speed, unsigned int& path_idx)
{
extruder_plan.handleInserts(path_idx, gcode);
GCodePath& last_path = paths[path_idx + 3];
writeCompensatedMove(last_middle, speed, last_path, line_width);
writeCompensatedMove(last_middle, last_path.config->getSpeed() * extruder_plan.getExtrudeSpeedFactor(), last_path, line_width);
}
path_idx = path_idx + 1; // means that the next path considered is the travel path after the converted extrusion path corresponding to the updated path_idx
extruder_plan.handleInserts(path_idx, gcode);
@@ -51,64 +58,136 @@ bool MergeInfillLines::mergeInfillLines(double speed, unsigned int& path_idx)
return false;
};
bool MergeInfillLines::isConvertible(unsigned int path_idx_first_move, Point& first_middle, Point& second_middle, int64_t& line_width, bool use_second_middle_as_first)
bool MergeInfillLines::isConvertible(unsigned int path_idx_first_move, Point& first_middle, Point& second_middle, int64_t& resulting_line_width, bool use_second_middle_as_first)
{
int64_t max_line_width = nozzle_size * 3 / 2;
unsigned int idx = path_idx_first_move;
if (idx + 3 > paths.size()-1) return false;
if (paths[idx+0].config != &travelConfig) return false;
if (paths[idx+1].points.size() > 1) return false;
if (paths[idx+1].config == &travelConfig) return false;
// if (paths[idx+2].points.size() > 1) return false;
if (paths[idx+2].config != &travelConfig) return false;
if (paths[idx+3].points.size() > 1) return false;
if (paths[idx+3].config == &travelConfig) return false;
if (idx + 3 > paths.size()-1)
{
return false;
}
if ( paths[idx+0].config != &travelConfig // must be travel
|| paths[idx+1].points.size() > 1 // extrusion path is single line
|| paths[idx+1].config == &travelConfig // must be extrusion
// || paths[idx+2].points.size() > 1 // travel must be direct
|| paths[idx+2].config != &travelConfig // must be travel
|| paths[idx+3].points.size() > 1 // extrusion path is single line
|| paths[idx+3].config == &travelConfig // must be extrusion
|| paths[idx+1].config != paths[idx+3].config // both extrusion moves should have the same config
)
{
return false;
}
if (!(paths[idx+1].config->type == PrintFeatureType::Infill || paths[idx+1].config->type == PrintFeatureType::Skin))
{ // only (skin) infill lines can be merged (note that the second extrusion line config is already checked to be the same as the first in code above)
return false;
}
if (paths[idx+1].space_fill_type != SpaceFillType::Lines || paths[idx+3].space_fill_type != SpaceFillType::Lines)
{ // both extrusion moves must be of lines space filling type!
return false;
}
int64_t line_width = paths[idx+1].config->getLineWidth();
Point& a = paths[idx+0].points.back(); // first extruded line from
Point& b = paths[idx+1].points.back(); // first extruded line to
Point& c = paths[idx+2].points.back(); // second extruded line from
Point& d = paths[idx+3].points.back(); // second extruded line to
return isConvertible(a, b, c, d, line_width, first_middle, second_middle, resulting_line_width, use_second_middle_as_first);
}
bool MergeInfillLines::isConvertible(const Point& a, const Point& b, const Point& c, const Point& d, int64_t line_width, Point& first_middle, Point& second_middle, int64_t& resulting_line_width, bool use_second_middle_as_first)
{
use_second_middle_as_first = false;
int64_t max_line_width = nozzle_size * 3 / 2;
Point ab = b - a;
Point cd = d - c;
if (b == c)
{
return false; // the line segments are connected!
}
int64_t ab_size = vSize(ab);
int64_t cd_size = vSize(cd);
if (ab_size > nozzle_size * 5 || cd_size > nozzle_size * 5)
{
return false; // infill lines are too long; otherwise infill lines might be merged when the next infill line is coincidentally shorter like |, would become \ ...
}
// if the lines are in the same direction then abs( dot(ab,cd) / |ab| / |cd| ) == 1
int64_t prod = dot(ab,cd);
if (std::abs(prod) + 400 < vSize(ab) * vSize(cd)) // 400 = 20*20, where 20 micron is the allowed inaccuracy in the dot product, introduced by the inaccurate point locations of a,b,c,d
if (std::abs(prod) + 400 < ab_size * cd_size) // 400 = 20*20, where 20 micron is the allowed inaccuracy in the dot product, introduced by the inaccurate point locations of a,b,c,d
{
return false; // extrusion moves not in the same or opposite diraction
if (prod < 0) { ab = ab * -1; }
}
Point infill_vector = (cd + ab) / 2;
if (!shorterThen(infill_vector, 5 * nozzle_size)) return false; // infill lines too far apart
// make lines in the same direction by flipping one
if (prod < 0)
{
ab = ab * -1;
}
else if (prod == 0)
{
return false; // lines are orthogonal!
}
else if (b == d || a == c)
{
return false; // the line segments are connected!
}
first_middle = (use_second_middle_as_first)?
second_middle :
(a + b) / 2;
second_middle = (c + d) / 2;
Point dir_vector_perp = crossZ(second_middle - first_middle);
Point dir_vector_perp = turn90CCW(second_middle - first_middle);
int64_t dir_vector_perp_length = vSize(dir_vector_perp); // == dir_vector_length
if (dir_vector_perp_length == 0) return false;
if (dir_vector_perp_length > 5 * nozzle_size) return false; // infill lines too far apart
line_width = std::abs( dot(dir_vector_perp, infill_vector) / dir_vector_perp_length );
if (line_width > max_line_width) return false; // combined lines would be too wide
if (line_width == 0) return false; // dot is zero, so lines are in each others extension, not next to eachother
{ // check whether the two lines are adjacent
Point ca = first_middle - c;
double ca_size = vSizeMM(ca);
double cd_size = vSizeMM(cd);
double prod = INT2MM(dot(ca, cd));
double fraction = prod / ( ca_size * cd_size );
int64_t line2line_dist = MM2INT(cd_size * std::sqrt(1.0 - fraction * fraction));
if (line2line_dist + 20 > paths[idx+1].config->getLineWidth()) return false; // there is a gap between the two lines
if (dir_vector_perp_length == 0)
{
return false;
}
if (dir_vector_perp_length > 5 * nozzle_size)
{
return false; // infill lines too far apart
}
Point infill_vector = (cd + ab) / 2; // (similar to) average line / direction of the infill
// compute the resulting line width
resulting_line_width = std::abs( dot(dir_vector_perp, infill_vector) / dir_vector_perp_length );
if (resulting_line_width > max_line_width)
{
return false; // combined lines would be too wide
}
if (resulting_line_width == 0)
{
return false; // dot is zero, so lines are in each others extension, not next to eachother
}
// check whether two lines are adjacent (note: not 'line segments' but 'lines')
Point ac = c - first_middle;
Point infill_vector_perp = turn90CCW(infill_vector);
int64_t perp_proj = dot(ac, infill_vector_perp);
int64_t infill_vector_perp_length = vSize(infill_vector_perp);
if (std::abs(std::abs(perp_proj) / infill_vector_perp_length - line_width) > 20) // it should be the case that dot(ac, infill_vector_perp) / |infill_vector_perp| == line_width
{
return false; // lines are too far apart or too close together
}
// check whether the two line segments are adjacent.
// full infill in a narrow area might result in line segments with arbitrary distance between them
// the more the narrow passage in the area gets aligned with the infill direction, the further apart the line segments will be
// however, distant line segments might also be due to different narrow passages, so we limit the distance between merged line segments.
if (!LinearAlg2D::lineSegmentsAreCloserThan(a, b, c, d, line_width * 2))
{
return false;
}
return true;
};
@@ -152,4 +231,4 @@ void MergeInfillLines::merge(Point& from, Point& p0, Point& p1)
}//namespace cura
}//namespace cura
+48 -12
Ver Arquivo
@@ -4,6 +4,7 @@
#include "utils/intpoint.h"
#include "gcodeExport.h"
#include "gcodePlanner.h"
#include "GCodePathConfig.h"
namespace cura
{
@@ -12,24 +13,44 @@ class MergeInfillLines
{
// void merge(Point& from, Point& p0, Point& p1);
GCodeExport& gcode; //!< Where to write the combined line to
int layer_nr; //!< The current layer number
std::vector<GCodePath>& paths; //!< The paths currently under consideration
ExtruderPlan& extruder_plan; //!< The extruder plan of the paths currently under consideration
GCodePathConfig& travelConfig; //!< The travel settings used to see whether a path is a travel path or an extrusion path
const GCodePathConfig& travelConfig; //!< The travel settings used to see whether a path is a travel path or an extrusion path
int64_t nozzle_size; //!< The diameter of the hole in the nozzle
bool speed_equalize_flow_enabled; //!< Should the speed be varied with extrusion width
double speed_equalize_flow_max; //!< Maximum speed when adjusting speed for flow
/*!
* Whether the next two extrusion paths are convertible to a single line segment, starting from the end point the of the last travel move at \p path_idx_first_move
* \param path_idx_first_move Index into MergeInfillLines::paths to the travel before the two extrusion moves udner consideration
* \param first_middle Output parameter: the middle of the first extrusion move
* \param second_middle Input/Output parameter: outputs the middle of the second extrusion move; inputs \p first_middle so we don't have to compute it
* \param line_width Output parameter: The width of the resulting combined line (the average length of the lines combined)
* \param resulting_line_width Output parameter: The width of the resulting combined line (the average length of the lines combined)
* \param use_second_middle_as_first Whether to use \p second_middle as input parameter for \p first_middle
* \return Whether the next two extrusion paths are convertible to a single line segment, starting from the end point the of the last travel move at \p path_idx_first_move
*/
bool isConvertible(unsigned int path_idx_first_move, Point& first_middle, Point& second_middle, int64_t& line_width, bool use_second_middle_as_first);
bool isConvertible(unsigned int path_idx_first_move, Point& first_middle, Point& second_middle, int64_t& resulting_line_width, bool use_second_middle_as_first = false);
/*!
* Whether the two consecutive extrusion paths (ab and cd) are convitrible to a single line segment.
*
* Note: as an optimization the \p second_middle from the previous call to isConvertible can be used for \p first_middle, instead of recomputing it.
*
* \param a first from
* \param b first to
* \param c second from
* \param d second to
* \param line_width The line width of the moves
* \param first_middle Output parameter: the middle of the first extrusion move
* \param second_middle Input/Output parameter: outputs the middle of the second extrusion move; inputs \p first_middle so we don't have to compute it
* \param resulting_line_width Output parameter: The width of the resulting combined line (the average length of the lines combined)
* \param use_second_middle_as_first Whether to use \p second_middle as input parameter for \p first_middle
* \return Whether the next two extrusion paths are convertible to a single line segment, starting from the end point the of the last travel move at \p path_idx_first_move
*/
bool isConvertible(const Point& a, const Point& b, const Point& c, const Point& d, int64_t line_width, Point& first_middle, Point& second_middle, int64_t& resulting_line_width, bool use_second_middle_as_first = false);
/*!
* Write an extrusion move with compensated width and compensated speed so that the material flow will be the same.
*
@@ -43,9 +64,18 @@ public:
/*!
* Simple constructor only used by MergeInfillLines::isConvertible to easily convey the environment
*/
MergeInfillLines(GCodeExport& gcode, std::vector<GCodePath>& paths, ExtruderPlan& extruder_plan, GCodePathConfig& travelConfig, int64_t nozzle_size)
: gcode(gcode), paths(paths), extruder_plan(extruder_plan), travelConfig(travelConfig), nozzle_size(nozzle_size) { }
MergeInfillLines(GCodeExport& gcode, int layer_nr, std::vector<GCodePath>& paths, ExtruderPlan& extruder_plan, const GCodePathConfig& travelConfig, int64_t nozzle_size, bool speed_equalize_flow_enabled, double speed_equalize_flow_max)
: gcode(gcode)
, layer_nr(layer_nr)
, paths(paths)
, extruder_plan(extruder_plan)
, travelConfig(travelConfig)
, nozzle_size(nozzle_size)
, speed_equalize_flow_enabled(speed_equalize_flow_enabled)
, speed_equalize_flow_max(speed_equalize_flow_max)
{
}
/*!
* Check for lots of small moves and combine them into one large line.
* Updates \p path_idx to the next path which is not combined.
@@ -54,13 +84,19 @@ public:
* \param paths The paths currently under consideration
* \param travelConfig The travel settings used to see whether a path is a travel path or an extrusion path
* \param nozzle_size The diameter of the hole in the nozzle
* \param speed A factor used to scale the movement speed
* \param path_idx Input/Output parameter: The current index in \p paths where to start combining and the current index after combining as output parameter.
* \return Whether lines have been merged and normal path-to-gcode generation can be skipped for the current resulting \p path_idx .
*/
bool mergeInfillLines(double speed, unsigned int& path_idx);
bool mergeInfillLines(unsigned int& path_idx);
/*!
* send a line segment through the command socket from the previous point to the given point \p to
*/
void sendLineTo(PrintFeatureType print_feature_type, Point to, int line_width)
{
CommandSocket::sendLineTo(print_feature_type, to, line_width);
}
};
}//namespace cura
#endif // MERGE_INFILL_LINES_H
#endif // MERGE_INFILL_LINES_H
+209 -12
Ver Arquivo
@@ -4,9 +4,12 @@
#include <stdio.h>
#include "MeshGroup.h"
#include "utils/gettime.h"
#include "utils/logoutput.h"
#include "utils/string.h"
#include "settings/SettingRegistry.h" // loadExtruderJSONsettings
namespace cura
{
@@ -28,7 +31,165 @@ void* fgets_(char* ptr, size_t len, FILE* f)
return nullptr;
}
bool loadMeshSTL_ascii(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
MeshGroup::MeshGroup(SettingsBaseVirtual* settings_base)
: SettingsBase(settings_base)
, extruder_count(-1)
{}
MeshGroup::~MeshGroup()
{
for (unsigned int extruder = 0; extruder < MAX_EXTRUDERS; extruder++)
{
if (extruders[extruder])
{
delete extruders[extruder];
}
}
}
int MeshGroup::getExtruderCount() const
{
if (extruder_count == -1)
{
extruder_count = getSettingAsCount("machine_extruder_count");
}
return extruder_count;
}
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);
int err = SettingRegistry::getInstance()->loadExtruderJSONsettings(extruder_nr, extruders[extruder_nr]);
if (err)
{
logError("Couldn't load extruder.def.json for extruder %i\n", extruder_nr);
std::exit(1);
}
}
return extruders[extruder_nr];
}
ExtruderTrain* MeshGroup::getExtruderTrain(unsigned int extruder_nr)
{
assert(extruders[extruder_nr]);
return extruders[extruder_nr];
}
const ExtruderTrain* MeshGroup::getExtruderTrain(unsigned int extruder_nr) const
{
assert(extruders[extruder_nr]);
return extruders[extruder_nr];
}
Point3 MeshGroup::min() const
{
if (meshes.size() < 1)
{
return Point3(0, 0, 0);
}
Point3 ret = meshes[0].min();
for(unsigned int i=1; i<meshes.size(); i++)
{
Point3 v = meshes[i].min();
ret.x = std::min(ret.x, v.x);
ret.y = std::min(ret.y, v.y);
ret.z = std::min(ret.z, v.z);
}
return ret;
}
Point3 MeshGroup::max() const
{
if (meshes.size() < 1)
{
return Point3(0, 0, 0);
}
Point3 ret = meshes[0].max();
for(unsigned int i=1; i<meshes.size(); i++)
{
Point3 v = meshes[i].max();
ret.x = std::max(ret.x, v.x);
ret.y = std::max(ret.y, v.y);
ret.z = std::max(ret.z, v.z);
}
return ret;
}
void MeshGroup::clear()
{
for(Mesh& m : meshes)
{
m.clear();
}
}
void MeshGroup::finalize()
{
extruder_count = getSettingAsCount("machine_extruder_count");
for (int extruder_nr = 0; extruder_nr < extruder_count; extruder_nr++)
{
createExtruderTrain(extruder_nr); // create it if it didn't exist yet
if (getSettingAsIndex("adhesion_extruder_nr") == extruder_nr && getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::NONE)
{
getExtruderTrain(extruder_nr)->setIsUsed(true);
continue;
}
for (const Mesh& mesh : meshes)
{
if (mesh.getSettingBoolean("support_enable")
&& (
getSettingAsIndex("support_infill_extruder_nr") == extruder_nr
|| getSettingAsIndex("support_extruder_nr_layer_0") == extruder_nr
|| (getSettingBoolean("support_interface_enable") && getSettingAsIndex("support_interface_extruder_nr") == extruder_nr)
)
)
{
getExtruderTrain(extruder_nr)->setIsUsed(true);
break;
}
}
}
for (const Mesh& mesh : meshes)
{
if (!mesh.getSettingBoolean("anti_overhang_mesh")
&& !mesh.getSettingBoolean("support_mesh")
)
{
getExtruderTrain(mesh.getSettingAsIndex("extruder_nr"))->setIsUsed(true);
}
}
//If the machine settings have been supplied, offset the given position vertices to the center of vertices (0,0,0) is at the bed center.
Point3 meshgroup_offset(0, 0, 0);
if (!getSettingBoolean("machine_center_is_zero"))
{
meshgroup_offset.x = getSettingInMicrons("machine_width") / 2;
meshgroup_offset.y = getSettingInMicrons("machine_depth") / 2;
}
// If a mesh position was given, put the mesh at this position in 3D space.
for(Mesh& mesh : meshes)
{
Point3 mesh_offset(mesh.getSettingInMicrons("mesh_position_x"), mesh.getSettingInMicrons("mesh_position_y"), mesh.getSettingInMicrons("mesh_position_z"));
if (mesh.getSettingBoolean("center_object"))
{
Point3 object_min = mesh.min();
Point3 object_max = mesh.max();
Point3 object_size = object_max - object_min;
mesh_offset += Point3(-object_min.x - object_size.x / 2, -object_min.y - object_size.y / 2, -object_min.z);
}
mesh.offset(mesh_offset + meshgroup_offset);
}
}
bool loadMeshSTL_ascii(Mesh* mesh, const char* filename, const FMatrix3x3& matrix)
{
FILE* f = fopen(filename, "rt");
char buffer[1024];
@@ -61,29 +222,41 @@ bool loadMeshSTL_ascii(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
return true;
}
bool loadMeshSTL_binary(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
bool loadMeshSTL_binary(Mesh* mesh, const char* filename, const FMatrix3x3& matrix)
{
FILE* f = fopen(filename, "rb");
fseek(f, 0L, SEEK_END);
long long file_size = ftell(f); //The file size is the position of the cursor after seeking to the end.
rewind(f); //Seek back to start.
size_t face_count = (file_size - 80 - sizeof(uint32_t)) / 50; //Subtract the size of the header. Every face uses exactly 50 bytes.
char buffer[80];
uint32_t faceCount;
//Skip the header
if (fread(buffer, 80, 1, f) != 1)
{
fclose(f);
return false;
}
//Read the face count
if (fread(&faceCount, sizeof(uint32_t), 1, f) != 1)
uint32_t reported_face_count;
//Read the face count. We'll use it as a sort of redundancy code to check for file corruption.
if (fread(&reported_face_count, sizeof(uint32_t), 1, f) != 1)
{
fclose(f);
return false;
}
if (reported_face_count != face_count)
{
logWarning("Face count reported by file (%s) is not equal to actual face count (%s). File could be corrupt!\n", std::to_string(reported_face_count).c_str(), std::to_string(face_count).c_str());
}
//For each face read:
//float(x,y,z) = normal, float(X,Y,Z)*3 = vertexes, uint16_t = flags
// Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer
mesh->faces.reserve(faceCount);
mesh->vertices.reserve(faceCount);
for(unsigned int i=0;i<faceCount;i++)
mesh->faces.reserve(face_count);
mesh->vertices.reserve(face_count);
for (unsigned int i = 0; i < face_count; i++)
{
if (fread(buffer, 50, 1, f) != 1)
{
@@ -102,13 +275,34 @@ bool loadMeshSTL_binary(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
return true;
}
bool loadMeshSTL(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
bool loadMeshSTL(Mesh* mesh, const char* filename, const FMatrix3x3& matrix)
{
FILE* f = fopen(filename, "r");
char buffer[6];
if (f == nullptr)
{
return false;
}
//Skip any whitespace at the beginning of the file.
unsigned long long num_whitespace = 0; //Number of whitespace characters.
unsigned char whitespace;
if (fread(&whitespace, 1, 1, f) != 1)
{
fclose(f);
return false;
}
while(isspace(whitespace))
{
num_whitespace++;
if (fread(&whitespace, 1, 1, f) != 1)
{
fclose(f);
return false;
}
}
fseek(f, num_whitespace, SEEK_SET); //Seek to the place after all whitespace (we may have just read too far).
char buffer[6];
if (fread(buffer, 5, 1, f) != 1)
{
fclose(f);
@@ -135,8 +329,10 @@ bool loadMeshSTL(Mesh* mesh, const char* filename, FMatrix3x3& matrix)
return loadMeshSTL_binary(mesh, filename, matrix);
}
bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings)
bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, const FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings)
{
TimeKeeper load_timer;
const char* ext = strrchr(filename, '.');
if (ext && (strcmp(ext, ".stl") == 0 || strcmp(ext, ".STL") == 0))
{
@@ -144,10 +340,11 @@ bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, FMatrix3x
if(loadMeshSTL(&mesh,filename,transformation)) //Load it! If successful...
{
meshgroup->meshes.push_back(mesh);
log("loading '%s' took %.3f seconds\n",filename,load_timer.restart());
return true;
}
}
return false;
}
}//namespace cura
}//namespace cura
+15 -102
Ver Arquivo
@@ -18,118 +18,31 @@ namespace cura
class MeshGroup : public SettingsBase, NoCopy
{
ExtruderTrain* extruders[MAX_EXTRUDERS] = {nullptr};
int extruder_count;
mutable int extruder_count; //!< The number of extruders. (mutable because of lazy evaluation)
public:
int getExtruderCount()
{
if (extruder_count == -1)
{
extruder_count = getSettingAsCount("machine_extruder_count");
}
return extruder_count;
}
int getExtruderCount() const;
MeshGroup(SettingsBaseVirtual* settings_base)
: SettingsBase(settings_base)
, extruder_count(-1)
{}
MeshGroup(SettingsBaseVirtual* settings_base);
~MeshGroup()
{
for (unsigned int extruder = 0; extruder < MAX_EXTRUDERS; extruder++)
{
if (extruders[extruder])
{
delete extruders[extruder];
}
}
}
~MeshGroup();
/*!
* Create a new extruder train for the @p extruder_nr, or return the one which already exists.
*/
ExtruderTrain* createExtruderTrain(unsigned int extruder_nr)
{
if (!extruders[extruder_nr])
{
extruders[extruder_nr] = new ExtruderTrain(this, extruder_nr);
}
return extruders[extruder_nr];
}
ExtruderTrain* getExtruderTrain(unsigned int extruder_nr)
{
assert(extruders[extruder_nr]);
return extruders[extruder_nr];
}
ExtruderTrain* createExtruderTrain(unsigned int extruder_nr);
ExtruderTrain* getExtruderTrain(unsigned int extruder_nr);
const ExtruderTrain* getExtruderTrain(unsigned int extruder_nr) const;
std::vector<Mesh> meshes;
Point3 min() //! minimal corner of bounding box
{
if (meshes.size() < 1)
{
return Point3(0, 0, 0);
}
Point3 ret = meshes[0].min();
for(unsigned int i=1; i<meshes.size(); i++)
{
Point3 v = meshes[i].min();
ret.x = std::min(ret.x, v.x);
ret.y = std::min(ret.y, v.y);
ret.z = std::min(ret.z, v.z);
}
return ret;
}
Point3 max() //! maximal corner of bounding box
{
if (meshes.size() < 1)
{
return Point3(0, 0, 0);
}
Point3 ret = meshes[0].max();
for(unsigned int i=1; i<meshes.size(); i++)
{
Point3 v = meshes[i].max();
ret.x = std::max(ret.x, v.x);
ret.y = std::max(ret.y, v.y);
ret.z = std::max(ret.z, v.z);
}
return ret;
}
Point3 min() const; //! minimal corner of bounding box
Point3 max() const; //! maximal corner of bounding box
void clear()
{
for(Mesh& m : meshes)
{
m.clear();
}
}
void clear();
void finalize()
{
//If the machine settings have been supplied, offset the given position vertices to the center of vertices (0,0,0) is at the bed center.
Point3 meshgroup_offset(0, 0, 0);
if (!getSettingBoolean("machine_center_is_zero"))
{
meshgroup_offset.x = getSettingInMicrons("machine_width") / 2;
meshgroup_offset.y = getSettingInMicrons("machine_depth") / 2;
}
// If a mesh position was given, put the mesh at this position in 3D space.
for(Mesh& mesh : meshes)
{
Point3 mesh_offset(mesh.getSettingInMicrons("mesh_position_x"), mesh.getSettingInMicrons("mesh_position_y"), mesh.getSettingInMicrons("mesh_position_z"));
if (mesh.getSettingBoolean("center_object"))
{
Point3 object_min = mesh.min();
Point3 object_max = mesh.max();
Point3 object_size = object_max - object_min;
mesh_offset += Point3(-object_min.x - object_size.x / 2, -object_min.y - object_size.y / 2, -object_min.z);
}
mesh.offset(mesh_offset + meshgroup_offset);
}
}
void finalize();
};
/*!
@@ -141,7 +54,7 @@ public:
* \param object_parent_settings (optional) The parent settings object of the new mesh. Defaults to \p meshgroup if none is given.
* \return whether the file could be loaded
*/
bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings = nullptr);
bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, const FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings = nullptr);
}//namespace cura
#endif//MESH_GROUP_H
+184
Ver Arquivo
@@ -0,0 +1,184 @@
#include "Preheat.h"
namespace cura
{
void Preheat::setConfig(const MeshGroup& meshgroup)
{
for (int extruder_nr = 0; extruder_nr < meshgroup.getExtruderCount(); extruder_nr++)
{
assert(meshgroup.getExtruderTrain(extruder_nr) != nullptr);
const ExtruderTrain& extruder_train = *meshgroup.getExtruderTrain(extruder_nr);
config_per_extruder.emplace_back();
Config& config = config_per_extruder.back();
double machine_nozzle_cool_down_speed = extruder_train.getSettingInSeconds("machine_nozzle_cool_down_speed");
double machine_nozzle_heat_up_speed = extruder_train.getSettingInSeconds("machine_nozzle_heat_up_speed");
double material_extrusion_cool_down_speed = extruder_train.getSettingInSeconds("material_extrusion_cool_down_speed");
assert(material_extrusion_cool_down_speed < machine_nozzle_heat_up_speed && "The extrusion cooldown speed must be smaller than the heat up speed; otherwise the printing temperature cannot be reached!");
config.time_to_cooldown_1_degree[0] = 1.0 / machine_nozzle_cool_down_speed;
config.time_to_heatup_1_degree[0] = 1.0 / machine_nozzle_heat_up_speed;
config.time_to_cooldown_1_degree[1] = 1.0 / (machine_nozzle_cool_down_speed + material_extrusion_cool_down_speed);
config.time_to_heatup_1_degree[1] = 1.0 / (machine_nozzle_heat_up_speed - material_extrusion_cool_down_speed);
config.standby_temp = extruder_train.getSettingInSeconds("material_standby_temperature");
config.min_time_window = extruder_train.getSettingInSeconds("machine_min_cool_heat_time_window");
config.material_print_temperature = extruder_train.getSettingInDegreeCelsius("material_print_temperature");
config.material_print_temperature_layer_0 = extruder_train.getSettingInDegreeCelsius("material_print_temperature_layer_0");
config.material_initial_print_temperature = extruder_train.getSettingInDegreeCelsius("material_initial_print_temperature");
config.material_final_print_temperature = extruder_train.getSettingInDegreeCelsius("material_final_print_temperature");
config.flow_dependent_temperature = extruder_train.getSettingBoolean("material_flow_dependent_temperature");
config.flow_temp_graph = extruder_train.getSettingAsFlowTempGraph("material_flow_temp_graph"); // [[0.1,180],[20,230]]
}
}
double Preheat::getTimeToGoFromTempToTemp(int extruder, double temp_before, double temp_after, bool during_printing)
{
Config& config = config_per_extruder[extruder];
double time;
if (temp_after > temp_before)
{
time = (temp_after - temp_before) * config.time_to_heatup_1_degree[during_printing];
}
else
{
time = (temp_before - temp_after) * config.time_to_cooldown_1_degree[during_printing];
}
return std::max(0.0, time);
}
double Preheat::getTemp(unsigned int extruder, double flow, bool is_initial_layer)
{
if (is_initial_layer && config_per_extruder[extruder].material_print_temperature_layer_0 != 0)
{
return config_per_extruder[extruder].material_print_temperature_layer_0;
}
return config_per_extruder[extruder].flow_temp_graph.getTemp(flow, config_per_extruder[extruder].material_print_temperature, config_per_extruder[extruder].flow_dependent_temperature);
}
Preheat::WarmUpResult Preheat::getWarmUpPointAfterCoolDown(double time_window, unsigned int extruder, double temp_start, double temp_mid, double temp_end, bool during_printing)
{
WarmUpResult result;
const Config& config = config_per_extruder[extruder];
double time_to_cooldown_1_degree = config.time_to_cooldown_1_degree[during_printing];
double time_to_heatup_1_degree = config.time_to_heatup_1_degree[during_printing];
result.total_time_window = time_window;
// ,temp_end
// / .
// ,temp_start / .
// \ ' ' ' ' '/ ' ' '> outer_temp .
// \________/ .
// "-> temp_mid
// ^^^^^^^^^^
// limited_time_window
double outer_temp;
double limited_time_window;
if (temp_start < temp_end)
{ // extra time needed during heating
double extra_heatup_time = (temp_end - temp_start) * time_to_heatup_1_degree;
result.heating_time = extra_heatup_time;
limited_time_window = time_window - extra_heatup_time;
outer_temp = temp_start;
}
else
{
double extra_cooldown_time = (temp_start - temp_end) * time_to_cooldown_1_degree;
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 = 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);
if (time_needed_to_reach_standby_temp < limited_time_window)
{
result.heating_time += time_to_heat_from_standby_to_print_temp;
result.lowest_temperature = temp_mid;
}
else
{
result.heating_time += limited_time_window * time_to_heatup_1_degree / (time_to_cooldown_1_degree + time_to_heatup_1_degree);
result.lowest_temperature = std::max(temp_mid, temp_end - result.heating_time / time_to_heatup_1_degree);
}
if (result.heating_time > time_window || result.heating_time < 0.0)
{
logWarning("getWarmUpPointAfterCoolDown returns result outside of the time window!");
}
return result;
}
Preheat::CoolDownResult Preheat::getCoolDownPointAfterWarmUp(double time_window, unsigned int extruder, double temp_start, double temp_mid, double temp_end, bool during_printing)
{
CoolDownResult result;
const Config& config = config_per_extruder[extruder];
double time_to_cooldown_1_degree = config.time_to_cooldown_1_degree[during_printing];
double time_to_heatup_1_degree = config.time_to_heatup_1_degree[during_printing];
assert(temp_start != -1 && temp_mid != -1 && temp_end != -1 && "temperatures must be initialized!");
result.total_time_window = time_window;
// limited_time_window
// :^^^^^^^^^^^^:
// : ________. : . . .> temp_mid
// : / \ : .
// :/ . . . . .\:. . .> outer_temp .
// ^temp_start \ .
// \ .
// ^temp_end
double outer_temp;
double limited_time_window;
if (temp_start < temp_end)
{ // extra time needed during heating
double extra_heatup_time = (temp_end - temp_start) * time_to_heatup_1_degree;
result.cooling_time = 0;
limited_time_window = time_window - extra_heatup_time;
outer_temp = temp_end;
}
else
{
double extra_cooldown_time = (temp_start - temp_end) * time_to_cooldown_1_degree;
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 = 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);
double time_needed_to_reach_temp1 = cool_down_time * (1.0 + time_ratio_cooldown_heatup);
if (time_needed_to_reach_temp1 < limited_time_window)
{
result.cooling_time += cool_down_time;
result.highest_temperature = temp_mid;
}
else
{
result.cooling_time += limited_time_window * time_to_heatup_1_degree / (time_to_cooldown_1_degree + time_to_heatup_1_degree);
result.highest_temperature = std::min(temp_mid, temp_end + result.cooling_time / time_to_cooldown_1_degree);
}
if (result.cooling_time > time_window || result.cooling_time < 0.0)
{
logWarning("getCoolDownPointAfterWarmUp returns result outside of the time window!");
}
return result;
}
}//namespace cura
+122 -98
Ver Arquivo
@@ -26,15 +26,21 @@ class Preheat
class Config
{
public:
double time_to_heatup_1_degree; //!< average time it takes to heat up one degree (in the range of normal print temperatures and standby temperature)
double time_to_cooldown_1_degree; //!< average time it takes to cool down one degree (in the range of normal print temperatures and standby temperature)
double heatup_cooldown_time_mod_while_printing; //!< The time to be added to Preheat::time_to_heatup_1_degree and subtracted from Preheat::time_to_cooldown_1_degree to get the timings while printing
double time_to_heatup_1_degree[2]; //!< average time it takes to heat up one degree (in the range of normal print temperatures and standby temperature), while not-printing and while printing
double time_to_cooldown_1_degree[2]; //!< average time it takes to cool down one degree (in the range of normal print temperatures and standby temperature), while not-printing and while printing
double standby_temp; //!< The temperature at which the nozzle rests when it is not printing.
double min_time_window; //!< Minimal time (in seconds) to allow an extruder to cool down and then warm up again.
double material_print_temperature; //!< default print temp (backward compatilibily)
double material_print_temperature_layer_0; //!< initial layer print temp
double material_initial_print_temperature; //!< print temp when first starting to extrude after a layer switch
double material_final_print_temperature; //!< print temp at the end of all extrusion moves of an extruder to which it's cooled down just before - during the extrusion
bool flow_dependent_temperature; //!< Whether to make the temperature dependent on flow
FlowTempGraph flow_temp_graph; //!< The graph linking flows to corresponding temperatures
@@ -42,6 +48,26 @@ class Preheat
std::vector<Config> config_per_extruder;//!< the nozzle and material temperature settings for each extruder train.
public:
/*!
* The type of result when computing when to start heating up a nozzle before it's going to be used again.
*/
struct WarmUpResult
{
double total_time_window; //!< The total time in which cooling and heating takes place.
double heating_time; //!< The total time needed to heat to the required temperature.
double lowest_temperature; //!< The lower temperature from which heating starts.
};
/*!
* The type of result when computing when to start cooling down a nozzle before it's not going to be used again.
*/
struct CoolDownResult
{
double total_time_window; //!< The total time in which heating and cooling takes place.
double cooling_time; //!< The total time needed to cool down to the required temperature.
double highest_temperature; //!< The upper temperature from which cooling starts.
};
/*!
* Get the standby temperature of an extruder train
* \param extruder the extruder train for which to get the standby tmep
@@ -51,126 +77,124 @@ public:
{
return config_per_extruder[extruder].standby_temp;
}
/*!
* Get the time it takes to heat up one degree celsius
*
* \param extruder the extruder train for which to get time it takes to heat up one degree celsius
* \param during_printing whether the heating takes time during printing or when idle
* \return the time it takes to heat up one degree celsius
*/
double getTimeToHeatup1Degree(int extruder, bool during_printing)
{
return config_per_extruder[extruder].time_to_heatup_1_degree[during_printing];
}
/*!
* Get the initial print temperature when starting to extrude.
* \param during_printing whether the heating takes time during printing or when idle
*/
double getInitialPrintTemp(int extruder)
{
return config_per_extruder[extruder].material_initial_print_temperature;
}
/*!
* Get the final print temperature at the end of all extrusion moves with the current extruder
*/
double getFinalPrintTemp(int extruder)
{
return config_per_extruder[extruder].material_final_print_temperature;
}
/*!
* Set the nozzle and material temperature settings for each extruder train.
* \param meshgroup Where to get settings from
*/
void setConfig(MeshGroup& settings)
{
for (int extruder_nr = 0; extruder_nr < settings.getExtruderCount(); extruder_nr++)
{
assert(settings.getExtruderTrain(extruder_nr) != nullptr);
ExtruderTrain& extruder_train = *settings.getExtruderTrain(extruder_nr);
config_per_extruder.emplace_back();
Config& config = config_per_extruder.back();
config.time_to_cooldown_1_degree = 1.0 / extruder_train.getSettingInSeconds("machine_nozzle_cool_down_speed"); // 0.5
config.time_to_heatup_1_degree = 1.0 / extruder_train.getSettingInSeconds("machine_nozzle_heat_up_speed"); // 0.5
config.heatup_cooldown_time_mod_while_printing = 1.0 / extruder_train.getSettingInSeconds("material_extrusion_cool_down_speed"); // 0.1
config.standby_temp = extruder_train.getSettingInSeconds("material_standby_temperature"); // 150
config.material_print_temperature = extruder_train.getSettingInDegreeCelsius("material_print_temperature"); // 220
config.flow_dependent_temperature = extruder_train.getSettingBoolean("material_flow_dependent_temperature");
config.flow_temp_graph = extruder_train.getSettingAsFlowTempGraph("material_flow_temp_graph"); // [[0.1,180],[20,230]]
}
}
void setConfig(const MeshGroup& meshgroup);
bool usesFlowDependentTemp(int extruder_nr)
{
return config_per_extruder[extruder_nr].flow_dependent_temperature;
}
private:
/*!
* Calculate time to heat up from standby temperature to a given temperature.
* Assumes @p temp is higher than the standby temperature.
* Get the optimal temperature corresponding to a given average flow,
* or the initial layer temperature.
*
* \param extruder The extruder for which to get the time
* \param temp The temperature to be reached
*/
double timeToHeatFromStandbyToPrintTemp(unsigned int extruder, double temp)
{
return (temp - config_per_extruder[extruder].standby_temp) * config_per_extruder[extruder].time_to_heatup_1_degree;
}
public:
/*!
* Get the optimal temperature corresponding to a given average flow.
* \param extruder The extruder train
* \param flow The flow for which to get the optimal temperature
* \param is_initial_layer Whether the initial layer temperature should be returned instead of flow-based temperature
* \return The corresponding optimal temperature
*/
double getTemp(unsigned int extruder, double flow)
{
return config_per_extruder[extruder].flow_temp_graph.getTemp(flow, config_per_extruder[extruder].material_print_temperature, config_per_extruder[extruder].flow_dependent_temperature);
}
double getTemp(unsigned int extruder, double flow, bool is_initial_layer);
/*!
* Decide when to start warming up again after starting to cool down towards the standby temperature.
* Return the minimal time window of a specific extruder for letting an unused extruder cool down and warm up again
* \param extruder The extruder for which to get the minimal time window
* \return the minimal time window of a specific extruder for letting an unused extruder cool down and warm up again
*/
double getMinimalTimeWindow(unsigned int extruder)
{
return config_per_extruder[extruder].min_time_window;
}
/*!
* Decide when to start warming up again after starting to cool down towards \p temp_mid.
* Two cases are considered:
* the case where the standby temperature is reached \__/ .
* and the case where it isn't \/ .
*
* IT is assumed that the printer is not printing during this cool down and warm up time.
*
* Assumes from_temp is approximately the same as @p temp
* \warning it is assumed that \p temp_mid is lower than both \p temp_start and \p temp_end. If not somewhat weird results may follow.
*
// ,temp_end
// / .
// ,temp_start / .
// \ / .
// \________/ .
// "-> temp_mid
* \param window_time The time window within which the cooldown and heat up must take place.
* \param extruder The extruder used
* \param temp The temperature to which to heat
* \return The time before the end of the @p time_window to insert the preheat command
* \param temp_start The temperature from which to start cooling down
* \param temp_mid The temeprature to which we try to cool down
* \param temp_end The temperature to which we need to have heated up at the end of the \p time_window
* \param during_printing Whether the warming up and cooling down is performed during printing
* \return The time before the end of the @p time_window to insert the preheat command and the temperature from which the heating starts
*/
double timeBeforeEndToInsertPreheatCommand_coolDownWarmUp(double time_window, unsigned int extruder, double temp)
{
double time_ratio_cooldown_heatup = config_per_extruder[extruder].time_to_cooldown_1_degree / config_per_extruder[extruder].time_to_heatup_1_degree;
double time_to_heat_from_standby_to_print_temp = timeToHeatFromStandbyToPrintTemp(extruder, temp);
double time_needed_to_reach_standby_temp = time_to_heat_from_standby_to_print_temp * (1.0 + time_ratio_cooldown_heatup);
if (time_needed_to_reach_standby_temp < time_window)
{
return time_to_heat_from_standby_to_print_temp;
}
else
{
return time_window * config_per_extruder[extruder].time_to_heatup_1_degree / (config_per_extruder[extruder].time_to_cooldown_1_degree + config_per_extruder[extruder].time_to_heatup_1_degree);
}
}
WarmUpResult getWarmUpPointAfterCoolDown(double time_window, unsigned int extruder, double temp_start, double temp_mid, double temp_end, bool during_printing);
/*!
* Calculate time needed to warm up the nozzle from a given temp to a given temp.
* If the printer is printing in the mean time the warming up will take longer.
* Decide when to start cooling down again after starting to warm up towards the \p temp_mid
* Two cases are considered:
* the case where the temperature is reached /"""\ .
* and the case where it isn't /\ .
*
* \warning it is assumed that \p temp_mid is higher than both \p temp_start and \p temp_end. If not somewhat weird results may follow.
*
* \param from_temp The temperature at which the nozzle was before
// _> temp_mid
// /""""""""\ .
// / \ .
// ^temp_start \ .
// \ .
// ^temp_end
* \param window_time The time window within which the cooldown and heat up must take place.
* \param extruder The extruder used
* \param temp The temperature to which to heat
* \param printing Whether the printer is printing in the time to heat up the nozzle
* \return The time needed to reach the desired temperature (@p temp)
* \param temp_start The temperature from which to start heating up
* \param temp_mid The temeprature to which we try to heat up
* \param temp_end The temperature to which we need to have cooled down after \p time_window time
* \param during_printing Whether the warming up and cooling down is performed during printing
* \return The time before the end of the \p time_window to insert the preheat command and the temperature from which the cooling starts
*/
double timeBeforeEndToInsertPreheatCommand_warmUp(double from_temp, unsigned int extruder, double temp, bool printing)
{
if (temp > from_temp)
{
if (printing)
{
return (temp - from_temp) * (config_per_extruder[extruder].time_to_heatup_1_degree + config_per_extruder[extruder].heatup_cooldown_time_mod_while_printing);
}
else
{
return (temp - from_temp) * config_per_extruder[extruder].time_to_heatup_1_degree;
}
}
else
{
if (printing)
{
return (from_temp - temp) * config_per_extruder[extruder].time_to_cooldown_1_degree;
}
else
{
return (from_temp - temp) * std::max(0.0, config_per_extruder[extruder].time_to_cooldown_1_degree - config_per_extruder[extruder].heatup_cooldown_time_mod_while_printing);
}
}
}
CoolDownResult getCoolDownPointAfterWarmUp(double time_window, unsigned int extruder, double temp_start, double temp_mid, double temp_end, bool during_printing);
/*!
* Get the time to go from one temperature to another temperature
* \param extruder The extruder number for which to perform the heatup / cooldown
* \param temp_before The before temperature
* \param temp_after The after temperature
* \param during_printing Whether the planned cooldown / warmup occurs during printing or while in standby mode
* \return The time needed
*/
double getTimeToGoFromTempToTemp(int extruder, double temp_before, double temp_after, bool during_printing);
};
} // namespace cura
+199 -226
Ver Arquivo
@@ -1,299 +1,272 @@
#include "PrimeTower.h"
#include <limits>
#include "ExtruderTrain.h"
#include "sliceDataStorage.h"
#include "gcodeExport.h"
#include "gcodePlanner.h"
#include "infill.h"
#include "PrintFeature.h"
namespace cura
{
PrimeTower::PrimeTower()
PrimeTower::PrimeTower(const SliceDataStorage& storage)
: is_hollow(false)
, wipe_from_middle(false)
{
}
void PrimeTower::initConfigs(MeshGroup* meshgroup, std::vector<RetractionConfig>& retraction_config_per_extruder)
{
extruder_count = meshgroup->getSettingAsCount("machine_extruder_count");
for (int extr = 0; extr < extruder_count; extr++)
enabled = storage.getSettingBoolean("prime_tower_enable")
&& storage.getSettingInMicrons("prime_tower_wall_thickness") > 10
&& storage.getSettingInMicrons("prime_tower_size") > 10;
if (enabled)
{
config_per_extruder.emplace_back(&retraction_config_per_extruder[extr], "SUPPORT");// so that visualization in the old Cura still works (TODO)
}
for (int extr = 0; extr < extruder_count; extr++)
{
ExtruderTrain* train = meshgroup->getExtruderTrain(extr);
config_per_extruder[extr].init(train->getSettingInMillimetersPerSecond("speed_prime_tower"), train->getSettingInMicrons("prime_tower_line_width"), train->getSettingInPercentage("prime_tower_flow"));
generateGroundpoly(storage);
}
}
void PrimeTower::setConfigs(MeshGroup* meshgroup, int layer_thickness)
void PrimeTower::generateGroundpoly(const SliceDataStorage& storage)
{
extruder_count = meshgroup->getSettingAsCount("machine_extruder_count");
for (int extr = 0; extr < extruder_count; extr++)
extruder_count = storage.meshgroup->getExtruderCount();
int64_t prime_tower_wall_thickness = storage.getSettingInMicrons("prime_tower_wall_thickness");
int64_t tower_size = storage.getSettingInMicrons("prime_tower_size");
if (prime_tower_wall_thickness * 2 < tower_size)
{
GCodePathConfig& conf = config_per_extruder[extr];
conf.setLayerHeight(layer_thickness);
is_hollow = true;
}
}
void PrimeTower::computePrimeTowerMax(SliceDataStorage& storage)
{ // compute storage.max_object_height_second_to_last_extruder, which is used to determine the highest point in the prime tower
extruder_count = storage.getSettingAsCount("machine_extruder_count");
int max_object_height_per_extruder[extruder_count];
std::fill_n(max_object_height_per_extruder, extruder_count, -1); // unitialize all as -1
{ // compute max_object_height_per_extruder
for (SliceMeshStorage& mesh : storage.meshes)
{
max_object_height_per_extruder[mesh.getSettingAsIndex("extruder_nr")] =
std::max( max_object_height_per_extruder[mesh.getSettingAsIndex("extruder_nr")]
, mesh.layer_nr_max_filled_layer );
}
int support_infill_extruder_nr = storage.getSettingAsIndex("support_infill_extruder_nr"); // TODO: support extruder should be configurable per object
max_object_height_per_extruder[support_infill_extruder_nr] =
std::max( max_object_height_per_extruder[support_infill_extruder_nr]
, storage.support.layer_nr_max_filled_layer );
int support_roof_extruder_nr = storage.getSettingAsIndex("support_roof_extruder_nr"); // TODO: support roof extruder should be configurable per object
max_object_height_per_extruder[support_roof_extruder_nr] =
std::max( max_object_height_per_extruder[support_roof_extruder_nr]
, storage.support.layer_nr_max_filled_layer );
}
{ // // compute max_object_height_second_to_last_extruder
int extruder_max_object_height = 0;
for (int extruder_nr = 1; extruder_nr < extruder_count; extruder_nr++)
{
if (max_object_height_per_extruder[extruder_nr] > max_object_height_per_extruder[extruder_max_object_height])
{
extruder_max_object_height = extruder_nr;
}
}
int extruder_second_max_object_height = -1;
for (int extruder_nr = 0; extruder_nr < extruder_count; extruder_nr++)
{
if (extruder_nr == extruder_max_object_height) { continue; }
if (extruder_second_max_object_height == -1 || max_object_height_per_extruder[extruder_nr] > max_object_height_per_extruder[extruder_second_max_object_height])
{
extruder_second_max_object_height = extruder_nr;
}
}
if (extruder_second_max_object_height < 0)
{
storage.max_object_height_second_to_last_extruder = -1;
}
else
{
storage.max_object_height_second_to_last_extruder = max_object_height_per_extruder[extruder_second_max_object_height];
}
}
}
void PrimeTower::generateGroundpoly(SliceDataStorage& storage)
{
PolygonRef p = storage.primeTower.ground_poly.newPoly();
int tower_size = storage.getSettingInMicrons("prime_tower_size");
int tower_distance = 0; //storage.getSettingInMicrons("prime_tower_distance");
PolygonRef p = ground_poly.newPoly();
int tower_distance = 0;
int x = storage.getSettingInMicrons("prime_tower_position_x"); // storage.model_max.x
int y = storage.getSettingInMicrons("prime_tower_position_y"); // storage.model_max.y
p.add(Point(x + tower_distance, y + tower_distance));
p.add(Point(x + tower_distance, y + tower_distance + tower_size));
p.add(Point(x + tower_distance - tower_size, y + tower_distance + tower_size));
p.add(Point(x + tower_distance - tower_size, y + tower_distance));
middle = Point(x - tower_size / 2, y + tower_size / 2);
storage.wipePoint = Point(x + tower_distance - tower_size / 2, y + tower_distance + tower_size / 2);
if (is_hollow)
{
ground_poly = ground_poly.difference(ground_poly.offset(-prime_tower_wall_thickness));
}
post_wipe_point = Point(x + tower_distance - tower_size / 2, y + tower_distance + tower_size / 2);
}
void PrimeTower::generatePaths(SliceDataStorage& storage, unsigned int total_layers)
void PrimeTower::generatePaths(const SliceDataStorage& storage)
{
if (storage.max_object_height_second_to_last_extruder >= 0
// && storage.getSettingInMicrons("prime_tower_distance") > 0
&& storage.getSettingInMicrons("prime_tower_size") > 0)
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)
{
generatePaths3(storage);
generatePaths_denseInfill(storage);
generateWipeLocations(storage);
}
}
void PrimeTower::generatePaths_OLD(SliceDataStorage& storage, unsigned int total_layers)
{
if (storage.max_object_height_second_to_last_extruder >= 0 && storage.getSettingInMicrons("prime_tower_distance") > 0 && storage.getSettingInMicrons("prime_tower_size") > 0)
{
PolygonRef p = storage.primeTower.ground_poly.newPoly();
int tower_size = storage.getSettingInMicrons("prime_tower_size");
int tower_distance = 0; //storage.getSettingInMicrons("prime_tower_distance");
int x = storage.getSettingInMicrons("prime_tower_position_x"); // storage.model_max.x
int y = storage.getSettingInMicrons("prime_tower_position_y"); // storage.model_max.y
p.add(Point(x + tower_distance, y + tower_distance));
p.add(Point(x + tower_distance, y + tower_distance + tower_size));
p.add(Point(x + tower_distance - tower_size, y + tower_distance + tower_size));
p.add(Point(x + tower_distance - tower_size, y + tower_distance));
storage.wipePoint = Point(x + tower_distance - tower_size / 2, y + tower_distance + tower_size / 2);
}
}
void PrimeTower::generatePaths2(SliceDataStorage& storage) // half baked attempt at spiral shaped prime tower pattern
void PrimeTower::generatePaths_denseInfill(const SliceDataStorage& storage)
{
// extruder_count = storage.getSettingAsCount("machine_extruder_count");
//
// int64_t line_dists[extruder_count + 1]; // distance between the lines of different extruders, and half the line dist for beginning and ending
// int64_t total_width = 0;
// {
// int64_t last_line_width = 0;
// for (int extr = 0; extr < extruder_count; extr++)
// {
// int64_t line_width = config_per_extruder[extr].getLineWidth();
// line_dists[extr] = (line_width + last_line_width) / 2;
// total_width += line_width;
// last_line_width = line_width;
// }
// line_dists[extruder_count] = last_line_width / 2;
// }
//
}
void PrimeTower::generatePaths3(SliceDataStorage& storage)
{
int n_patterns = 2; // alternating patterns between layers
double infill_overlap = 15; // so that it can't be zero
generateGroundpoly(storage);
int infill_overlap = 60; // so that it can't be zero; EDIT: wtf?
int extra_infill_shift = 0;
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++)
{
int line_width = storage.meshgroup->getExtruderTrain(extruder)->getSettingInMicrons("prime_tower_line_width");
patterns_per_extruder.emplace_back(n_patterns);
std::vector<Polygons>& patterns = patterns_per_extruder.back();
std::vector<ExtrusionMoves>& patterns = patterns_per_extruder.back();
patterns.resize(n_patterns);
for (int pattern_idx = 0; pattern_idx < n_patterns; pattern_idx++)
{
generateLineInfill(ground_poly, -line_width/2, patterns[pattern_idx], line_width, line_width, infill_overlap, 45 + pattern_idx*90);
patterns[pattern_idx].polygons = ground_poly.offset(-line_width / 2);
Polygons& result_lines = patterns[pattern_idx].lines;
int outline_offset = -line_width;
int line_distance = line_width;
double fill_angle = 45 + pattern_idx * 90;
Polygons result_polygons; // should remain empty, since we generate lines pattern!
Infill infill_comp(EFillMethod::LINES, ground_poly, outline_offset, line_width, line_distance, infill_overlap, fill_angle, z, extra_infill_shift);
infill_comp.generate(result_polygons, result_lines);
}
}
}
void PrimeTower::addToGcode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket)
void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder) const
{
if (!( storage.max_object_height_second_to_last_extruder >= 0
// && storage.getSettingInMicrons("prime_tower_distance") > 0
&& storage.getSettingInMicrons("prime_tower_size") > 0) )
if (!enabled)
{
return;
}
bool prime_tower_added = false;
for (int extruder = 0; extruder < storage.meshgroup->getExtruderCount() && !prime_tower_added; extruder++)
{
prime_tower_added = last_prime_tower_poly_printed[extruder] == int(layer_nr);
}
if (prime_tower_added)
if (gcodeLayer.getPrimeTowerIsPlanned())
{ // don't print the prime tower if it has been printed already
return;
}
if (prev_extruder == gcodeLayer.getExtruder())
{
wipe = false;
}
addToGcode3(storage, gcodeLayer, gcode, layer_nr, prev_extruder, prime_tower_dir_outward, wipe, last_prime_tower_poly_printed, command_socket);
}
void PrimeTower::addToGcode3(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket)
{
if (layer_nr > storage.max_object_height_second_to_last_extruder + 1)
if (layer_nr > storage.max_print_height_second_to_last_extruder + 1)
{
return;
}
int new_extruder = gcodeLayer.getExtruder();
Polygons& pattern = patterns_per_extruder[new_extruder][layer_nr % 2];
bool pre_wipe = storage.meshgroup->getExtruderTrain(new_extruder)->getSettingBoolean("dual_pre_wipe");
bool post_wipe = storage.meshgroup->getExtruderTrain(prev_extruder)->getSettingBoolean("prime_tower_wipe_enabled");
GCodePathConfig& config = config_per_extruder[new_extruder];
int start_idx = 0; // TODO: figure out which idx is closest to the far right corner
gcodeLayer.addPolygon(ground_poly.back(), start_idx, &config);
gcodeLayer.addLinesByOptimizer(pattern, &config);
last_prime_tower_poly_printed[new_extruder] = layer_nr;
if (prev_extruder == new_extruder)
{
pre_wipe = false;
post_wipe = false;
}
// pre-wipe:
if (pre_wipe)
{
preWipe(storage, gcodeLayer, layer_nr, new_extruder);
}
if (command_socket)
command_socket->sendPolygons(SupportType, layer_nr, pattern, config.getLineWidth());
addToGcode_denseInfill(gcodeLayer, layer_nr, new_extruder);
if (wipe)
// post-wipe:
if (post_wipe)
{ //Make sure we wipe the old extruder on the prime tower.
gcodeLayer.addTravel(storage.wipePoint - gcode.getExtruderOffset(prev_extruder) + gcode.getExtruderOffset(new_extruder));
gcodeLayer.addTravel(post_wipe_point - gcode.getExtruderOffset(prev_extruder) + gcode.getExtruderOffset(new_extruder));
}
gcodeLayer.setPrimeTowerIsPlanned();
}
void PrimeTower::addToGcode_OLD(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket)
void PrimeTower::addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const
{
if (layer_nr > storage.max_object_height_second_to_last_extruder + 1)
{
return;
}
int new_extruder = gcodeLayer.getExtruder();
const ExtrusionMoves& pattern = patterns_per_extruder[extruder_nr][((layer_nr % 2) + 2) % 2]; // +2) %2 to handle negative layer numbers
int64_t offset = -config_per_extruder[new_extruder].getLineWidth();
if (layer_nr > 0)
offset *= 2;
//If we changed extruder, print the wipe/prime tower for this nozzle;
std::vector<Polygons> insets;
{ // generate polygons
if ((layer_nr % 2) == 1)
insets.push_back(storage.primeTower.ground_poly.offset(offset / 2));
else
insets.push_back(storage.primeTower.ground_poly);
while(true)
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern.polygons, &config);
gcode_layer.addLinesByOptimizer(pattern.lines, &config, SpaceFillType::Lines);
}
Point PrimeTower::getLocationBeforePrimeTower(const SliceDataStorage& storage) const
{
Point ret(0, 0);
int absolute_starting_points = 0;
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); extruder_nr++)
{
ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(0);
if (train.getSettingBoolean("machine_extruder_start_pos_abs"))
{
Polygons new_inset = insets[insets.size() - 1].offset(offset);
if (new_inset.size() < 1)
break;
insets.push_back(new_inset);
ret += Point(train.getSettingInMicrons("machine_extruder_start_pos_x"), train.getSettingInMicrons("machine_extruder_start_pos_y"));
absolute_starting_points++;
}
}
for(unsigned int n=0; n<insets.size(); n++)
if (absolute_starting_points > 0)
{ // take the average over all absolute starting positions
ret /= absolute_starting_points;
}
else
{ // use the middle of the bed
if (!storage.getSettingBoolean("machine_center_is_zero"))
{
ret = Point(storage.getSettingInMicrons("machine_width"), storage.getSettingInMicrons("machine_depth")) / 2;
}
// otherwise keep (0, 0)
}
return ret;
}
void PrimeTower::generateWipeLocations(const SliceDataStorage& storage)
{
wipe_from_middle = is_hollow;
// only wipe from the middle of the prime tower if we have a z hop already on the first move after the layer switch
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); extruder_nr++)
{
GCodePathConfig& config = config_per_extruder[new_extruder];
gcodeLayer.addPolygonsByOptimizer(insets[(prime_tower_dir_outward)? insets.size() - 1 - n : n], &config);
const ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(extruder_nr);
wipe_from_middle &= train.getSettingBoolean("retraction_hop_enabled")
&& (!train.getSettingBoolean("retraction_hop_only_when_collides") || train.getSettingBoolean("retraction_hop_after_extruder_switch"));
}
last_prime_tower_poly_printed[new_extruder] = layer_nr;
if (wipe)
{ //Make sure we wipe the old extruder on the prime tower.
gcodeLayer.addTravel(storage.wipePoint - gcode.getExtruderOffset(prev_extruder) + gcode.getExtruderOffset(new_extruder));
PolygonsPointIndex segment_start; // from where to start the sequence of wipe points
PolygonsPointIndex segment_end; // where to end the sequence of wipe points
if (wipe_from_middle)
{
// take the same start as end point so that the whole poly os covered.
// find the inner polygon.
segment_start = segment_end = PolygonUtils::findNearestVert(middle, ground_poly);
}
};
}//namespace cura
else
{
// take the closer corner of the wipe tower and generate wipe locations on that side only:
//
// |
// |
// +-----
// .
// ^ nozzle switch location
Point from = getLocationBeforePrimeTower(storage);
// find the single line segment closest to [from] pointing most toward [from]
PolygonsPointIndex closest_vert = PolygonUtils::findNearestVert(from, ground_poly);
PolygonsPointIndex prev = closest_vert.prev();
PolygonsPointIndex next = closest_vert.next();
int64_t prev_dot_score = dot(from - closest_vert.p(), turn90CCW(prev.p() - closest_vert.p()));
int64_t next_dot_score = dot(from - closest_vert.p(), turn90CCW(closest_vert.p() - next.p()));
if (prev_dot_score > next_dot_score)
{
segment_start = prev;
segment_end = closest_vert;
}
else
{
segment_start = closest_vert;
segment_end = next;
}
}
PolygonUtils::spreadDots(segment_start, segment_end, number_of_pre_wipe_locations, pre_wipe_locations);
}
void PrimeTower::preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const
{
int current_pre_wipe_location_idx = (pre_wipe_location_skip * layer_nr) % number_of_pre_wipe_locations;
const ClosestPolygonPoint wipe_location = pre_wipe_locations[current_pre_wipe_location_idx];
ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(extruder_nr);
const int inward_dist = train.getSettingInMicrons("machine_nozzle_size") * 3 / 2 ;
const int start_dist = train.getSettingInMicrons("machine_nozzle_size") * 2;
const Point end = PolygonUtils::moveInsideDiagonally(wipe_location, inward_dist);
const Point outward_dir = wipe_location.location - end;
const Point start = wipe_location.location + normal(outward_dir, start_dist);
if (wipe_from_middle)
{
// for hollow wipe tower:
// start from above
// go to wipe start
// go to the Z height of the previous/current layer
// wipe
// go to normal layer height (automatically on the next extrusion move)...
GCodePath& toward_middle = gcode_layer.addTravel(middle);
toward_middle.perform_z_hop = true;
gcode_layer.forceNewPathStart();
GCodePath& toward_wipe_start = gcode_layer.addTravel_simple(start);
toward_wipe_start.perform_z_hop = false;
toward_wipe_start.retract = true;
}
else
{
gcode_layer.addTravel(start);
}
float flow = 0.0001; // force this path being interpreted as an extrusion path, so that no Z hop will occur (TODO: really separately handle travel and extrusion moves)
gcode_layer.addExtrusionMove(end, &gcode_layer.configs_storage.prime_tower_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
+121 -32
Ver Arquivo
@@ -1,9 +1,15 @@
//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
#include "gcodeExport.h" // GCodePathConfig
#include <vector>
#include "GCodePathConfig.h"
#include "MeshGroup.h"
#include "utils/polygon.h" // Polygons
#include "utils/polygonUtils.h"
namespace cura
{
@@ -13,51 +19,134 @@ class SliceDataStorage;
class GCodePlanner;
class GCodeExport;
typedef std::vector<IntPoint> PolyLine;
/*!
* Class for everything to do with the prime tower:
* - generating the areas
* - checking up till which height the prime tower has to be printed
* - generating the paths and adding them to the layer plan
*/
class PrimeTower
{
private:
int extruder_count;
std::vector<GCodePathConfig> config_per_extruder;
class WallInfill
struct ExtrusionMoves
{
Polygons polygons;
Polygons lines;
};
public:
void initConfigs(MeshGroup* meshgroup, std::vector<RetractionConfig>& retraction_config_per_extruder);
void setConfigs(MeshGroup* configs, int layer_thickness);
Polygons ground_poly;
std::vector<PolyLine> extruder_paths;
void generateGroundpoly(SliceDataStorage& storage);
int extruder_count; //!< number of extruders
bool is_hollow; //!< Whether the prime tower is hollow
bool wipe_from_middle; //!< Whether to wipe on the inside of the hollow prime tower
Point middle; //!< The middle of the prime tower
Point post_wipe_point; //!< location to post-wipe the unused nozzle off on
std::vector<ClosestPolygonPoint> pre_wipe_locations; //!< The differernt locations where to pre-wipe the active nozzle
const unsigned int pre_wipe_location_skip = 13; //!< How big the steps are when stepping through \ref PrimeTower::wipe_locations
const unsigned int number_of_pre_wipe_locations = 21; //!< The required size of \ref PrimeTower::wipe_locations
// note that the above are two consecutive numbers in the Fibonacci sequence
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);
/*!
* Generate the prime tower area to be used on each layer
*
* Fills \ref PrimeTower::ground_poly and sets \ref PrimeTower::middle
*
* \param storage Where to retrieve prime tower settings from
*/
void generateGroundpoly(const SliceDataStorage& storage);
std::vector<std::vector<Polygons>> patterns_per_extruder; //!< for each extruder a vector of patterns to alternate between, over the layers
void generatePaths3(SliceDataStorage& storage);
void generatePaths2(SliceDataStorage& storage);
/*!
* Generate the area where the prime tower should be.
*
* \param storage Input and Output parameter: fetches the outline information (see SliceLayerPart::outline) and generates the other reachable field of the \p storage
* \param storage where to get settings from
* \param total_layers The total number of layers
*/
void generatePaths(SliceDataStorage& storage, unsigned int total_layers);
void generatePaths_OLD(SliceDataStorage& storage, unsigned int total_layers);
void generatePaths(const SliceDataStorage& storage);
void computePrimeTowerMax(SliceDataStorage& storage);
PrimeTower();
/*!
* 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.
*/
void addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder) const;
void addToGcode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket);
void addToGcode_OLD(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket);
void addToGcode3(SliceDataStorage& storage, GCodePlanner& gcodeLayer, GCodeExport& gcode, int layer_nr, int prev_extruder, bool prime_tower_dir_outward, bool wipe, int* last_prime_tower_poly_printed, CommandSocket* command_socket);
/*!
* \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:
/*!
* Find an approriate representation for the point representing the location before going to the prime tower
*
* \warning This is not the actual position each time before the wipe tower
*
* \param storage where to get settings from
* \return that location
*/
Point getLocationBeforePrimeTower(const SliceDataStorage& storage) const;
/*!
* \param storage where to get settings from
* Depends on ground_poly being generated
*/
void generateWipeLocations(const SliceDataStorage& storage);
/*!
* \see WipeTower::generatePaths
*
* Generate the extrude paths for each extruder on even and odd layers
* Fill the ground poly with dense infill.
*
* \param storage where to get settings from
* \param total_layers The total number of layers
*/
void generatePaths_denseInfill(const SliceDataStorage& storage);
/*!
* \see PrimeTower::addToGcode
*
* Add path plans for the prime tower to the \p gcode_layer
*
* \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 extruder The extruder we just switched to, with which the prime
* tower paths should be drawn.
*/
void addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder) const;
/*!
* Plan the moves for wiping the current nozzles oozed material before starting to print the prime tower.
*
* \param storage where to get settings from
* \param[out] gcode_layer where to add the planned paths for wiping
* \param layer_nr The layer number of the \p gcode_layer
* \param extruder_nr The current extruder
*/
void preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const;
};
+14 -14
Ver Arquivo
@@ -4,24 +4,24 @@
namespace cura
{
enum class EPrintFeature : unsigned int // unused!!
{ // TODO: use in gcodePathConfigs ?
OUTER_WALL,
INNER_WALLS,
INFILL,
SKIN,
HELPERS,
UNCLASSIFIED,
ENUM_COUNT
enum class PrintFeatureType: unsigned char
{
NoneType, // used to mark unspecified jumps in polygons. libArcus depends on it
OuterWall,
InnerWall,
Skin,
Support,
SkirtBrim,
Infill,
SupportInfill,
MoveCombing,
MoveRetraction,
SupportInterface
};
} // namespace cura
#endif // PRINT_FEATURE
#endif // PRINT_FEATURE
+28
Ver Arquivo
@@ -0,0 +1,28 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef RETRACTION_CONFIG_H
#define RETRACTION_CONFIG_H
namespace cura
{
/*!
* The retraction configuration used in the GCodePathConfig of each feature (and the travel config)
*/
class RetractionConfig
{
public:
double distance; //!< The distance retracted (in mm)
double speed; //!< The speed with which to retract (in mm/s)
double primeSpeed; //!< the speed with which to unretract (in mm/s)
double prime_volume; //!< the amount of material primed after unretracting (in mm^3)
int zHop; //!< the amount with which to lift the head during a retraction-travel
int retraction_min_travel_distance; //!< Minimal distance traversed to even consider retracting (in micron)
double retraction_extrusion_window; //!< Window of mm extruded filament in which to limit the amount of retractions
int retraction_count_max; //!< The maximum amount of retractions allowed to occur in the RetractionConfig::retraction_extrusion_window
};
}//namespace cura
#endif // RETRACTION_CONFIG_H
+198
Ver Arquivo
@@ -0,0 +1,198 @@
//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"
namespace cura
{
void SkirtBrim::getFirstLayerOutline(SliceDataStorage& storage, const unsigned int primary_line_count, const int primary_extruder_skirt_brim_line_width, const bool is_skirt, const bool outside_only, Polygons& first_layer_outline)
{
bool external_only = is_skirt; // whether to include holes or not
const int layer_nr = 0;
if (is_skirt)
{
const bool include_helper_parts = true;
first_layer_outline = storage.getLayerOutlines(layer_nr, include_helper_parts, external_only);
first_layer_outline = first_layer_outline.approxConvexHull();
}
else
{ // 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)
{
first_layer_empty_holes = first_layer_outline.getEmptyHoles();
first_layer_outline = first_layer_outline.removeEmptyHoles();
}
if (storage.support.generated && primary_line_count > 0)
{ // remove model-brim from support
// avoid gap in the middle
// V
// +---+ +----+
// |+-+| |+--+|
// || || ||[]|| > expand to fit an extra brim line
// |+-+| |+--+|
// +---+ +----+
Polygons model_brim_covered_area = first_layer_outline.offset(primary_extruder_skirt_brim_line_width * (primary_line_count + primary_line_count % 2), ClipperLib::jtRound); // always leave a gap of an even number of brim lines, so that it fits if it's generating brim from both sides
if (outside_only)
{ // don't remove support within empty holes where no brim is generated.
model_brim_covered_area.add(first_layer_empty_holes);
}
SupportLayer& support_layer = storage.support.supportLayers[0];
support_layer.supportAreas = support_layer.supportAreas.difference(model_brim_covered_area);
first_layer_outline.add(support_layer.supportAreas);
first_layer_outline.add(support_layer.skin);
}
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)
{
int offset_distance = start_distance - primary_extruder_skirt_brim_line_width / 2;
for (unsigned int skirt_brim_number = 0; skirt_brim_number < primary_line_count; skirt_brim_number++)
{
offset_distance += primary_extruder_skirt_brim_line_width;
Polygons outer_skirt_brim_line = first_layer_outline.offset(offset_distance, ClipperLib::jtRound);
//Remove small inner skirt and brim holes. Holes have a negative area, remove anything smaller then 100x extrusion "area"
for (unsigned int n = 0; n < outer_skirt_brim_line.size(); n++)
{
double area = outer_skirt_brim_line[n].area();
if (area < 0 && area > -primary_extruder_skirt_brim_line_width * primary_extruder_skirt_brim_line_width * 100)
{
outer_skirt_brim_line.remove(n--);
}
}
skirt_brim_primary_extruder.add(outer_skirt_brim_line);
int length = skirt_brim_primary_extruder.polygonLength();
if (skirt_brim_number + 1 >= primary_line_count && length > 0 && length < primary_extruder_minimal_length) //Make brim or skirt have more lines when total length is too small.
{
primary_line_count++;
}
}
return offset_distance;
}
void SkirtBrim::generate(SliceDataStorage& storage, int start_distance, unsigned int primary_line_count, bool outside_only)
{
const bool is_skirt = start_distance > 0;
const int adhesion_extruder_nr = storage.getSettingAsIndex("adhesion_extruder_nr");
const ExtruderTrain* adhesion_extruder = storage.meshgroup->getExtruderTrain(adhesion_extruder_nr);
const int primary_extruder_skirt_brim_line_width = adhesion_extruder->getSettingInMicrons("skirt_brim_line_width");
const int64_t primary_extruder_minimal_length = adhesion_extruder->getSettingInMicrons("skirt_brim_minimal_length");
Polygons& skirt_brim_primary_extruder = storage.skirt_brim[adhesion_extruder_nr];
Polygons first_layer_outline;
getFirstLayerOutline(storage, primary_line_count, primary_extruder_skirt_brim_line_width, is_skirt, outside_only, first_layer_outline);
const bool has_ooze_shield = storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0;
const bool has_draft_shield = storage.draft_protection_shield.size() > 0;
if (is_skirt && (has_ooze_shield || has_draft_shield))
{ // make sure we don't generate skirt through draft / ooze shield
first_layer_outline = first_layer_outline.offset(start_distance - primary_extruder_skirt_brim_line_width / 2, ClipperLib::jtRound).unionPolygons(storage.draft_protection_shield);
if (has_ooze_shield)
{
first_layer_outline = first_layer_outline.unionPolygons(storage.oozeShield[0]);
}
first_layer_outline = first_layer_outline.approxConvexHull();
start_distance = primary_extruder_skirt_brim_line_width / 2;
}
int offset_distance = generatePrimarySkirtBrimLines(storage, start_distance, primary_line_count, primary_extruder_skirt_brim_line_width, primary_extruder_minimal_length, first_layer_outline, skirt_brim_primary_extruder);
// generate brim for ooze shield and draft shield
if (!is_skirt && (has_ooze_shield || has_draft_shield))
{
// generate areas where to make extra brim for the shields
// avoid gap in the middle
// V
// +---+ +----+
// |+-+| |+--+|
// || || ||[]|| > expand to fit an extra brim line
// |+-+| |+--+|
// +---+ +----+
const int64_t primary_skirt_brim_width = (primary_line_count + primary_line_count % 2) * primary_extruder_skirt_brim_line_width; // always use an even number, because we will fil the area from both sides
Polygons shield_brim;
if (has_ooze_shield)
{
shield_brim = storage.oozeShield[0].difference(storage.oozeShield[0].offset(-primary_skirt_brim_width - primary_extruder_skirt_brim_line_width));
}
if (has_draft_shield)
{
shield_brim = shield_brim.unionPolygons(storage.draft_protection_shield.difference(storage.draft_protection_shield.offset(-primary_skirt_brim_width - primary_extruder_skirt_brim_line_width)));
}
const Polygons outer_primary_brim = first_layer_outline.offset(offset_distance, ClipperLib::jtRound);
shield_brim = shield_brim.difference(outer_primary_brim.offset(primary_extruder_skirt_brim_line_width));
// generate brim within shield_brim
skirt_brim_primary_extruder.add(shield_brim);
while (shield_brim.size() > 0)
{
shield_brim = shield_brim.offset(-primary_extruder_skirt_brim_line_width);
skirt_brim_primary_extruder.add(shield_brim);
}
// update parameters to generate secondary skirt around
first_layer_outline = outer_primary_brim;
if (has_draft_shield)
{
first_layer_outline = first_layer_outline.unionPolygons(storage.draft_protection_shield);
}
if (has_ooze_shield)
{
first_layer_outline = first_layer_outline.unionPolygons(storage.oozeShield[0]);
}
offset_distance = 0;
}
{ // process other extruders' brim/skirt (as one brim line around the old brim)
int last_width = primary_extruder_skirt_brim_line_width;
for (int extruder = 0; extruder < storage.meshgroup->getExtruderCount(); extruder++)
{
if (extruder == adhesion_extruder_nr || !storage.meshgroup->getExtruderTrain(extruder)->getIsUsed())
{
continue;
}
const ExtruderTrain* train = storage.meshgroup->getExtruderTrain(extruder);
const int width = train->getSettingInMicrons("skirt_brim_line_width");
const int64_t minimal_length = train->getSettingInMicrons("skirt_brim_minimal_length");
offset_distance += last_width / 2 + width/2;
last_width = width;
while (storage.skirt_brim[extruder].polygonLength() < minimal_length)
{
storage.skirt_brim[extruder].add(first_layer_outline.offset(offset_distance, ClipperLib::jtRound));
offset_distance += width;
}
}
}
}
}//namespace cura
+59
Ver Arquivo
@@ -0,0 +1,59 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef SKIRT_BRIM_H
#define SKIRT_BRIM_H
#include "sliceDataStorage.h"
namespace cura
{
class SkirtBrim
{
public:
/*!
* Generate skirt or brim (depending on parameters).
*
* When \p distance > 0 and \p count == 1 a skirt is generated, which has
* slightly different configuration. Otherwise, a brim is generated.
*
* \param storage Storage containing the parts at the first layer.
* \param distance The distance of the first outset from the parts at the first
* layer.
* \param primary_line_count Number of outsets / brim lines of the primary extruder.
* \param outside_only Whether to only generate a brim on the outside, rather than also in holes
*/
static void generate(SliceDataStorage& storage, int distance, unsigned int primary_line_count, bool outside_only);
private:
/*!
* Get the reference outline of the first layer around which to generate the first brim/skirt line.
*
* This function may change the support polygons in the first layer
* in order to meet criteria for putting brim around the model as well as around the support.
*
* \param storage Storage containing the parts at the first layer.
* \param primary_line_count Number of outsets / brim lines of the primary extruder.
* \param primary_extruder_skirt_brim_line_width Line widths of the initial skirt/brim lines
* \param is_skirt Whether a skirt is being generated vs a brim
* \param outside_only Whether to only generate a brim on the outside, rather than also in holes
* \param[out] first_layer_outline The resulting reference polygons
*/
static void getFirstLayerOutline(SliceDataStorage& storage, const unsigned int primary_line_count, const int primary_extruder_skirt_brim_line_width, const bool is_skirt, const bool outside_only, Polygons& first_layer_outline);
/*!
* Generate the skirt/brim lines around the model
*
* \param storage Storage containing the parts at the first layer.
* \param start_distance The distance of the first outset from the parts at the first
* \param primary_line_count Number of outsets / brim lines of the primary extruder.
* \param primary_extruder_skirt_brim_line_width Line widths of the initial skirt/brim lines
* \param primary_extruder_minimal_length The minimal total length of the skirt/brim lines of the primary extruder
* \param first_layer_outline The reference polygons from which to offset outward to generate skirt/brim lines
* \param[out] skirt_brim_primary_extruder Where to store the resulting brim/skirt lines in
* \return The offset of the last brim/skirt line from the reference polygon \p first_layer_outline
*/
static int 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);
};
}//namespace cura
#endif //SKIRT_BRIM_H
+25
Ver Arquivo
@@ -0,0 +1,25 @@
#ifndef SPACE_FILL_TYPE
#define SPACE_FILL_TYPE
namespace cura
{
/*!
* Enum class enumerating the strategies with which an area can be occupied with filament
*
* The walls/perimeters are Polygons
* ZigZag infill is PolyLines, and so is following mesh surface mode for non-polygon surfaces
* Grid, Triangles and lines infill is Lines
*/
enum class SpaceFillType
{
None,
Polygons,
PolyLines,
Lines
};
} // namespace cura
#endif // SPACE_FILL_TYPE
+92
Ver Arquivo
@@ -0,0 +1,92 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "WallsComputation.h"
#include "utils/polygonUtils.h"
namespace cura {
WallsComputation::WallsComputation(int wall_0_inset, int line_width_0, int line_width_x, int insetCount, bool recompute_outline_based_on_outer_wall)
: wall_0_inset(wall_0_inset)
, line_width_0(line_width_0)
, line_width_x(line_width_x)
, insetCount(insetCount)
, recompute_outline_based_on_outer_wall(recompute_outline_based_on_outer_wall)
{
}
/*
* 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)
{
part->insets.push_back(part->outline);
part->print_outline = part->outline;
return;
}
for(int i=0; i<insetCount; i++)
{
part->insets.push_back(Polygons());
if (i == 0)
{
part->insets[0] = part->outline.offset(-line_width_0 / 2 - wall_0_inset);
} else if (i == 1)
{
part->insets[1] = part->insets[0].offset(-line_width_0 / 2 + wall_0_inset - line_width_x / 2);
} else
{
part->insets[i] = part->insets[i-1].offset(-line_width_x);
}
//Finally optimize all the polygons. Every point removed saves time in the long run.
part->insets[i].simplify();
part->insets[i].removeDegenerateVerts();
if (i == 0)
{
if (recompute_outline_based_on_outer_wall)
{
part->print_outline = part->insets[0].offset(line_width_0 / 2);
}
else
{
part->print_outline = part->outline;
}
}
if (part->insets[i].size() < 1)
{
part->insets.pop_back();
break;
}
}
}
/*
* 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++)
{
generateInsets(&layer->parts[partNr]);
}
//Remove the parts which did not generate an inset. As these parts are too small to print,
// and later code can now assume that there is always minimal 1 inset line.
for(unsigned int partNr = 0; partNr < layer->parts.size(); partNr++)
{
if (layer->parts[partNr].insets.size() < 1)
{
layer->parts.erase(layer->parts.begin() + partNr);
partNr -= 1;
}
}
}
}//namespace cura
+69
Ver Arquivo
@@ -0,0 +1,69 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef WALLS_COMPUTATION_H
#define WALLS_COMPUTATION_H
#include "sliceDataStorage.h"
namespace cura
{
/*!
* Function container for computing the outer walls / insets / perimeters polygons of a layer
*/
class WallsComputation
{
public:
/*!
* The offset applied to the outer wall
*/
int wall_0_inset;
/*!
* line width of the outer wall
*/
int line_width_0;
/*!
* line width of other walls
*/
int line_width_x;
/*!
* The number of insets to to generate
*/
int insetCount;
/*!
* Whether to compute a more accurate poly representation of the printed outlines, based on the outer wall
*/
bool recompute_outline_based_on_outer_wall;
/*!
* Basic constructor initializing the parameters with which to perform the walls computation
*
* \param wall_0_inset The offset applied to the outer wall
* \param line_width_0 line width of the outer wall
* \param line_width_x line width of other walls
* \param insetCount The number of insets to to generate
* \param recompute_outline_based_on_outer_wall Whether to compute a more accurate poly representation of the printed outlines, based on the outer wall
*/
WallsComputation(int wall_0_inset, int line_width_0, int line_width_x, int insetCount, bool recompute_outline_based_on_outer_wall);
/*!
* Generates the insets / perimeters for all parts in a layer.
*
* Note that the second inset gets offsetted by WallsComputation::line_width_0 instead of the first,
* which leads to better results for a smaller WallsComputation::line_width_0 than WallsComputation::line_width_x and when printing the outer wall last.
*
* \param layer The layer for which to generate the insets.
*/
void generateInsets(SliceLayer* layer);
private:
/*!
* Generates the insets / perimeters for a single layer part.
*
* \param part The part for which to generate the insets.
*/
void generateInsets(SliceLayerPart* part);
};
}//namespace cura
#endif//WALLS_COMPUTATION_H
+24 -37
Ver Arquivo
@@ -4,13 +4,14 @@
#include <fstream> // debug IO
#include <unistd.h>
#include "Progress.h"
#include "progress/Progress.h"
#include "weaveDataStorage.h"
#include "PrintFeature.h"
namespace cura
{
void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
void Weaver::weave(MeshGroup* meshgroup)
{
wireFrame.meshgroup = meshgroup;
@@ -18,7 +19,7 @@ void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
int layer_count = (maxz - initial_layer_thickness) / connectionHeight + 1;
DEBUG_SHOW(layer_count);
std::cerr << "Layer count: " << layer_count << "\n";
std::vector<cura::Slicer*> slicerList;
@@ -34,14 +35,14 @@ void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
{
Polygons parts;
for (cura::Slicer* slicer : slicerList)
parts.add(slicer->layers[starting_layer_idx].polygonList);
parts.add(slicer->layers[starting_layer_idx].polygons);
if (parts.size() > 0)
break;
}
if (starting_layer_idx > 0)
{
logError("First %i layers are empty!\n", starting_layer_idx);
logWarning("First %i layers are empty!\n", starting_layer_idx);
}
}
@@ -50,10 +51,9 @@ void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
{
int starting_z = -1;
for (cura::Slicer* slicer : slicerList)
wireFrame.bottom_outline.add(slicer->layers[starting_layer_idx].polygonList);
wireFrame.bottom_outline.add(slicer->layers[starting_layer_idx].polygons);
if (commandSocket)
commandSocket->sendPolygons(Inset0Type, 0, wireFrame.bottom_outline, 1);
CommandSocket::sendPolygons(PrintFeatureType::OuterWall, /*0,*/ wireFrame.bottom_outline, 1);
if (slicerList.empty()) //Wait, there is nothing to slice.
{
@@ -70,23 +70,22 @@ void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
else
starting_point_in_layer = (Point(0,0) + meshgroup->max() + meshgroup->min()) / 2;
Progress::messageProgressStage(Progress::Stage::INSET, nullptr, commandSocket);
Progress::messageProgressStage(Progress::Stage::INSET_SKIN, nullptr);
for (int layer_idx = starting_layer_idx + 1; layer_idx < layer_count; layer_idx++)
{
Progress::messageProgress(Progress::Stage::INSET, layer_idx+1, layer_count, commandSocket); // abuse the progress system of the normal mode of CuraEngine
Progress::messageProgress(Progress::Stage::INSET_SKIN, layer_idx+1, layer_count); // abuse the progress system of the normal mode of CuraEngine
Polygons parts1;
for (cura::Slicer* slicer : slicerList)
parts1.add(slicer->layers[layer_idx].polygonList);
parts1.add(slicer->layers[layer_idx].polygons);
Polygons chainified;
chainify_polygons(parts1, starting_point_in_layer, chainified, false);
if (commandSocket)
commandSocket->sendPolygons(Inset0Type, layer_idx - starting_layer_idx, chainified, 1);
CommandSocket::sendPolygons(PrintFeatureType::OuterWall, /*layer_idx - starting_layer_idx,*/ chainified, 1);
if (chainified.size() > 0)
{
if (starting_z == -1) starting_z = slicerList[0]->layers[layer_idx-1].z;
@@ -107,10 +106,10 @@ void Weaver::weave(MeshGroup* meshgroup, CommandSocket* commandSocket)
{
Polygons* lower_top_parts = &wireFrame.bottom_outline;
Progress::messageProgressStage(Progress::Stage::SKIN, nullptr, commandSocket);
Progress::messageProgressStage(Progress::Stage::SUPPORT, nullptr);
for (unsigned int layer_idx = 0; layer_idx < wireFrame.layers.size(); layer_idx++)
{
Progress::messageProgress(Progress::Stage::SKIN, layer_idx+1, wireFrame.layers.size(), commandSocket); // abuse the progress system of the normal mode of CuraEngine
Progress::messageProgress(Progress::Stage::SUPPORT, layer_idx+1, wireFrame.layers.size()); // abuse the progress system of the normal mode of CuraEngine
WeaveLayer& layer = wireFrame.layers[layer_idx];
@@ -325,7 +324,7 @@ void Weaver::connections2moves(WeaveRoofPart& inset)
WeaveConnectionSegment& segment = segments[idx];
assert(segment.segmentType == WeaveSegmentType::UP);
Point3 from = (idx == 0)? part.connection.from : segments[idx-1].to;
bool skipped = (segment.to - from).vSize2() < extrusionWidth * extrusionWidth;
bool skipped = (segment.to - from).vSize2() < line_width * line_width;
if (skipped)
{
unsigned int begin = idx;
@@ -334,9 +333,11 @@ void Weaver::connections2moves(WeaveRoofPart& inset)
WeaveConnectionSegment& segment = segments[idx];
assert(segments[idx].segmentType == WeaveSegmentType::UP);
Point3 from = (idx == 0)? part.connection.from : segments[idx-1].to;
bool skipped = (segment.to - from).vSize2() < extrusionWidth * extrusionWidth;
bool skipped = (segment.to - from).vSize2() < line_width * line_width;
if (!skipped)
{
break;
}
}
int end = idx - ((include_half_of_last_down)? 2 : 1);
if (idx >= segments.size())
@@ -386,11 +387,9 @@ void Weaver::connect(Polygons& parts0, int z0, Polygons& parts1, int z1, WeaveCo
void Weaver::chainify_polygons(Polygons& parts1, Point start_close_to, Polygons& result, bool include_last)
{
for (unsigned int prt = 0 ; prt < parts1.size(); prt++)
{
const PolygonRef upperPart = parts1[prt];
ConstPolygonRef upperPart = parts1[prt];
ClosestPolygonPoint closestInPoly = PolygonUtils::findClosest(start_close_to, upperPart);
@@ -401,9 +400,9 @@ void Weaver::chainify_polygons(Polygons& parts1, Point start_close_to, Polygons&
bool found = true;
int idx = 0;
for (Point upper_point = upperPart[closestInPoly.pos]; found; upper_point = next_upper.location)
for (Point upper_point = upperPart[closestInPoly.point_idx]; found; upper_point = next_upper.location)
{
found = PolygonUtils::getNextPointWithDistance(upper_point, nozzle_top_diameter, upperPart, idx, closestInPoly.pos, next_upper);
found = PolygonUtils::getNextPointWithDistance(upper_point, nozzle_top_diameter, upperPart, idx, closestInPoly.point_idx, next_upper);
if (!found)
@@ -428,7 +427,7 @@ void Weaver::connect_polygons(Polygons& supporting, int z0, Polygons& supported,
if (supporting.size() < 1)
{
DEBUG_PRINTLN("lower layer has zero parts!");
std::cerr << "lower layer has zero parts!\n";
return;
}
@@ -440,7 +439,7 @@ void Weaver::connect_polygons(Polygons& supporting, int z0, Polygons& supported,
for (unsigned int prt = 0 ; prt < supported.size(); prt++)
{
const PolygonRef upperPart = supported[prt];
ConstPolygonRef upperPart(supported[prt]);
parts.emplace_back(prt);
@@ -474,16 +473,4 @@ void Weaver::connect_polygons(Polygons& supporting, int z0, Polygons& supported,
}
}//namespace cura
+4 -7
Ver Arquivo
@@ -3,7 +3,7 @@
#include "weaveDataStorage.h"
#include "commandSocket.h"
#include "settings.h"
#include "settings/settings.h"
#include "MeshGroup.h"
#include "slicer.h"
@@ -12,8 +12,6 @@
#include "utils/polygon.h"
#include "utils/polygonUtils.h"
#include "debug.h"
namespace cura
{
@@ -30,7 +28,7 @@ private:
int initial_layer_thickness;
int connectionHeight;
int extrusionWidth;
int line_width;
int roof_inset;
@@ -47,7 +45,7 @@ public:
initial_layer_thickness = getSettingInMicrons("layer_height_0");
connectionHeight = getSettingInMicrons("wireframe_height");
extrusionWidth = getSettingInMicrons("wall_line_width_x");
line_width = getSettingInMicrons("wall_line_width_x");
roof_inset = getSettingInMicrons("wireframe_roof_inset");
nozzle_outer_diameter = getSettingInMicrons("machine_nozzle_tip_outer_diameter"); // ___ ___ .
@@ -61,9 +59,8 @@ public:
* Creates a wireframe for the model consisting of horizontal 'flat' parts and connections between consecutive flat parts consisting of UP moves and diagonally DOWN moves.
*
* \param objects The objects for which to create a wireframe print
* \param commandSocket the commandSocket
*/
void weave(MeshGroup* objects, CommandSocket* commandSocket);
void weave(MeshGroup* objects);
private:
+98 -84
Ver Arquivo
@@ -3,24 +3,29 @@
#include <cmath> // sqrt
#include <fstream> // debug IO
#include "utils/math.h"
#include "utils/logoutput.h"
#include "weaveDataStorage.h"
#include "Progress.h"
#include "progress/Progress.h"
#include "pathOrderOptimizer.h" // for skirt
#include "pathOrderOptimizer.h" //For skirt/brim.
namespace cura
{
void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
void Wireframe2gcode::writeGCode()
{
gcode.preSetup(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)
commandSocket->beginGCode();
if (CommandSocket::getInstance())
CommandSocket::getInstance()->beginGCode();
processStartingCode(commandSocket);
processStartingCode();
int maxObjectHeight;
if (wireFrame.layers.empty())
@@ -31,23 +36,22 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
{
maxObjectHeight = wireFrame.layers.back().z1;
}
processSkirt(commandSocket);
unsigned int total_layers = wireFrame.layers.size();
gcode.writeLayerComment(0);
gcode.writeTypeComment("SKIRT");
gcode.setZ(initial_layer_thickness);
processSkirt();
unsigned int total_layers = wireFrame.layers.size();
gcode.writeLayerComment(0);
gcode.writeTypeComment(PrintFeatureType::SkirtBrim);
for (PolygonRef bottom_part : wireFrame.bottom_infill.roof_outlines)
{
if (bottom_part.size() == 0) continue;
writeMoveWithRetract(bottom_part[bottom_part.size()-1]);
for (Point& segment_to : bottom_part)
{
gcode.writeMove(segment_to, speedBottom, extrusion_per_mm_flat);
gcode.writeMove(segment_to, speedBottom, extrusion_mm3_per_mm_flat);
}
}
@@ -63,7 +67,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
writeMoveWithRetract(segment.to);
} else
{
gcode.writeMove(segment.to, speedBottom, extrusion_per_mm_connection);
gcode.writeMove(segment.to, speedBottom, extrusion_mm3_per_mm_connection);
}
}
,
@@ -73,13 +77,13 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
else if (segment.segmentType == WeaveSegmentType::DOWN_AND_FLAT)
return; // do nothing
else
gcode.writeMove(segment.to, speedBottom, extrusion_per_mm_flat);
gcode.writeMove(segment.to, speedBottom, extrusion_mm3_per_mm_flat);
}
);
Progress::messageProgressStage(Progress::Stage::EXPORT, nullptr, commandSocket);
Progress::messageProgressStage(Progress::Stage::EXPORT, nullptr);
for (unsigned int layer_nr = 0; layer_nr < wireFrame.layers.size(); layer_nr++)
{
Progress::messageProgress(Progress::Stage::EXPORT, layer_nr+1, total_layers, commandSocket); // abuse the progress system of the normal mode of CuraEngine
Progress::messageProgress(Progress::Stage::EXPORT, layer_nr+1, total_layers); // abuse the progress system of the normal mode of CuraEngine
WeaveLayer& layer = wireFrame.layers[layer_nr];
@@ -96,7 +100,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
if (part.connection.segments.size() == 0) continue;
gcode.writeTypeComment("SUPPORT"); // connection
gcode.writeTypeComment(PrintFeatureType::Support); // connection
{
if (vSize2(gcode.getPositionXY() - part.connection.from) > connectionHeight)
{
@@ -112,7 +116,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
gcode.writeTypeComment("WALL-OUTER"); // top
gcode.writeTypeComment(PrintFeatureType::OuterWall); // top
{
for (unsigned int segment_idx = 0; segment_idx < part.connection.segments.size(); segment_idx++)
{
@@ -123,7 +127,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
writeMoveWithRetract(segment.to);
} else
{
gcode.writeMove(segment.to, speedFlat, extrusion_per_mm_flat);
gcode.writeMove(segment.to, speedFlat, extrusion_mm3_per_mm_flat);
gcode.writeDelay(flat_delay);
}
}
@@ -145,7 +149,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
// do nothing
} else
{
gcode.writeMove(segment.to, speedFlat, extrusion_per_mm_flat);
gcode.writeMove(segment.to, speedFlat, extrusion_mm3_per_mm_flat);
gcode.writeDelay(flat_delay);
}
});
@@ -156,7 +160,7 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
gcode.setZ(maxObjectHeight);
gcode.writeRetraction(&standard_retraction_config);
gcode.writeRetraction(standard_retraction_config);
gcode.updateTotalPrintTime();
@@ -166,12 +170,6 @@ void Wireframe2gcode::writeGCode(CommandSocket* commandSocket)
gcode.writeFanCommand(0);
finalize();
if (commandSocket)
{
commandSocket->sendGCodeLayer();
commandSocket->endSendSlicedObject();
}
}
@@ -183,7 +181,7 @@ void Wireframe2gcode::go_down(WeaveLayer& layer, WeaveConnectionPart& part, unsi
gcode.writeMove(from, speedDown, 0);
if (straight_first_when_going_down <= 0)
{
gcode.writeMove(segment.to, speedDown, extrusion_per_mm_connection);
gcode.writeMove(segment.to, speedDown, extrusion_mm3_per_mm_connection);
} else
{
Point3& to = segment.to;
@@ -195,14 +193,14 @@ void Wireframe2gcode::go_down(WeaveLayer& layer, WeaveConnectionPart& part, unsi
int64_t new_length = (up - from).vSize() + (to - up).vSize() + 5;
int64_t orr_length = vec.vSize();
double enlargement = new_length / orr_length;
gcode.writeMove(up, speedDown*enlargement, extrusion_per_mm_connection / enlargement);
gcode.writeMove(to, speedDown*enlargement, extrusion_per_mm_connection / enlargement);
gcode.writeMove(up, speedDown*enlargement, extrusion_mm3_per_mm_connection / enlargement);
gcode.writeMove(to, speedDown*enlargement, extrusion_mm3_per_mm_connection / enlargement);
}
gcode.writeDelay(bottom_delay);
if (up_dist_half_speed > 0)
{
gcode.writeMove(Point3(0,0,up_dist_half_speed) + gcode.getPosition(), speedUp / 2, extrusion_per_mm_connection * 2);
gcode.writeMove(Point3(0,0,up_dist_half_speed) + gcode.getPosition(), speedUp / 2, extrusion_mm3_per_mm_connection * 2);
}
}
@@ -211,7 +209,7 @@ void Wireframe2gcode::go_down(WeaveLayer& layer, WeaveConnectionPart& part, unsi
void Wireframe2gcode::strategy_knot(WeaveLayer& layer, WeaveConnectionPart& part, unsigned int segment_idx)
{
WeaveConnectionSegment& segment = part.connection.segments[segment_idx];
gcode.writeMove(segment.to, speedUp, extrusion_per_mm_connection);
gcode.writeMove(segment.to, speedUp, extrusion_mm3_per_mm_connection);
Point3 next_vector;
if (segment_idx + 1 < part.connection.segments.size())
{
@@ -245,7 +243,7 @@ void Wireframe2gcode::strategy_retract(WeaveLayer& layer, WeaveConnectionPart& p
retraction_config.primeSpeed = 15; // 30;
retraction_config.zHop = 0; //getSettingInt("retraction_hop");
retraction_config.retraction_count_max = getSettingAsCount("retraction_count_max");
retraction_config.retraction_extrusion_window = INT2MM(getSettingInMicrons("retraction_extrusion_window"));
retraction_config.retraction_extrusion_window = getSettingInMillimeters("retraction_extrusion_window");
retraction_config.retraction_min_travel_distance = getSettingInMicrons("retraction_min_travel");
double top_retract_pause = 2.0;
@@ -261,8 +259,8 @@ void Wireframe2gcode::strategy_retract(WeaveLayer& layer, WeaveConnectionPart& p
Point3 vec = to - from;
Point3 lowering = vec * retract_hop_dist / 2 / vec.vSize();
Point3 lower = to - lowering;
gcode.writeMove(lower, speedUp, extrusion_per_mm_connection);
gcode.writeRetraction(&retraction_config);
gcode.writeMove(lower, speedUp, extrusion_mm3_per_mm_connection);
gcode.writeRetraction(retraction_config);
gcode.writeMove(to + lowering, speedUp, 0);
gcode.writeDelay(top_retract_pause);
if (after_retract_hop)
@@ -270,8 +268,8 @@ void Wireframe2gcode::strategy_retract(WeaveLayer& layer, WeaveConnectionPart& p
} else
{
gcode.writeMove(to, speedUp, extrusion_per_mm_connection);
gcode.writeRetraction(&retraction_config);
gcode.writeMove(to, speedUp, extrusion_mm3_per_mm_connection);
gcode.writeRetraction(retraction_config);
gcode.writeMove(to + Point3(0, 0, retract_hop_dist), speedFlat, 0);
gcode.writeDelay(top_retract_pause);
if (after_retract_hop)
@@ -308,7 +306,7 @@ void Wireframe2gcode::strategy_compensate(WeaveLayer& layer, WeaveConnectionPart
int64_t orrLength = (segment.to - from).vSize() + next_vector.vSize() + 1; // + 1 in order to avoid division by zero
int64_t newLength = (newTop - from).vSize() + (next_point - newTop).vSize() + 1; // + 1 in order to avoid division by zero
gcode.writeMove(newTop, speedUp * newLength / orrLength, extrusion_per_mm_connection * orrLength / newLength);
gcode.writeMove(newTop, speedUp * newLength / orrLength, extrusion_mm3_per_mm_connection * orrLength / newLength);
}
void Wireframe2gcode::handle_segment(WeaveLayer& layer, WeaveConnectionPart& part, unsigned int segment_idx)
{
@@ -323,7 +321,7 @@ void Wireframe2gcode::handle_segment(WeaveLayer& layer, WeaveConnectionPart& par
go_down(layer, part, segment_idx);
break;
case WeaveSegmentType::FLAT:
DEBUG_SHOW("flat piece in connection?!!?!");
logWarning("Warning: flat piece in wire print connection.\n");
break;
case WeaveSegmentType::UP:
if (strategy == STRATEGY_KNOT)
@@ -387,12 +385,12 @@ void Wireframe2gcode::handle_roof_segment(WeaveRoofPart& inset, WeaveConnectionP
detoured -= next_dir;
}
gcode.writeMove(detoured, speedUp, extrusion_per_mm_connection);
gcode.writeMove(detoured, speedUp, extrusion_mm3_per_mm_connection);
}
break;
case WeaveSegmentType::DOWN:
gcode.writeMove(segment.to, speedDown, extrusion_per_mm_connection);
gcode.writeMove(segment.to, speedDown, extrusion_mm3_per_mm_connection);
gcode.writeDelay(roof_outer_delay);
break;
case WeaveSegmentType::FLAT:
@@ -410,7 +408,7 @@ void Wireframe2gcode::writeFill(std::vector<WeaveRoofPart>& infill_insets, Polyg
{
// bottom:
gcode.writeTypeComment("FILL");
gcode.writeTypeComment(PrintFeatureType::Infill);
for (unsigned int inset_idx = 0; inset_idx < infill_insets.size(); inset_idx++)
{
WeaveRoofPart& inset = infill_insets[inset_idx];
@@ -421,7 +419,7 @@ void Wireframe2gcode::writeFill(std::vector<WeaveRoofPart>& infill_insets, Polyg
WeaveConnectionPart& inset_part = inset.connections[inset_part_nr];
std::vector<WeaveConnectionSegment>& segments = inset_part.connection.segments;
gcode.writeTypeComment("SUPPORT"); // connection
gcode.writeTypeComment(PrintFeatureType::Support); // connection
if (segments.size() == 0) continue;
Point3 first_extrusion_from = inset_part.connection.from;
unsigned int first_segment_idx;
@@ -437,7 +435,7 @@ void Wireframe2gcode::writeFill(std::vector<WeaveRoofPart>& infill_insets, Polyg
connectionHandler(*this, inset, inset_part, segment_idx);
}
gcode.writeTypeComment("WALL-INNER"); // top
gcode.writeTypeComment(PrintFeatureType::InnerWall); // top
for (unsigned int segment_idx = 0; segment_idx < segments.size(); segment_idx++)
{
WeaveConnectionSegment& segment = segments[segment_idx];
@@ -451,7 +449,7 @@ void Wireframe2gcode::writeFill(std::vector<WeaveRoofPart>& infill_insets, Polyg
}
gcode.writeTypeComment("WALL-OUTER"); // outer perimeter of the flat parts
gcode.writeTypeComment(PrintFeatureType::OuterWall); // outer perimeter of the flat parts
for (PolygonRef poly : roof_outlines)
{
writeMoveWithRetract(poly[poly.size() - 1]);
@@ -470,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);
}
@@ -491,16 +489,15 @@ Wireframe2gcode::Wireframe2gcode(Weaver& weaver, GCodeExport& gcode, SettingsBas
roof_inset = getSettingInMicrons("wireframe_roof_inset");
filament_diameter = getSettingInMicrons("material_diameter");
extrusionWidth = getSettingInMicrons("wall_line_width_x");
line_width = getSettingInMicrons("wall_line_width_x");
flowConnection = getSettingInPercentage("wireframe_flow_connection");
flowFlat = getSettingInPercentage("wireframe_flow_flat");
double filament_area = /* M_PI * */ (INT2MM(filament_diameter) / 2.0) * (INT2MM(filament_diameter) / 2.0);
double lineArea = /* M_PI * */ (INT2MM(extrusionWidth) / 2.0) * (INT2MM(extrusionWidth) / 2.0);
extrusion_per_mm_connection = lineArea / filament_area * flowConnection / 100.0;
extrusion_per_mm_flat = lineArea / filament_area * flowFlat / 100.0;
const double line_area = M_PI * square(INT2MM(line_width) / 2.0);
extrusion_mm3_per_mm_connection = line_area * flowConnection / 100.0;
extrusion_mm3_per_mm_flat = line_area * flowFlat / 100.0;
nozzle_outer_diameter = getSettingInMicrons("machine_nozzle_tip_outer_diameter"); // ___ ___ .
nozzle_head_distance = getSettingInMicrons("machine_nozzle_head_distance"); // | | .
nozzle_expansion_angle = getSettingInAngleRadians("machine_nozzle_expansion_angle"); // \_U_/ .
@@ -540,51 +537,58 @@ Wireframe2gcode::Wireframe2gcode(Weaver& weaver, GCodeExport& gcode, SettingsBas
roof_outer_delay = getSettingInSeconds("wireframe_roof_outer_delay");
standard_retraction_config.distance = INT2MM(getSettingInMicrons("retraction_amount"));
standard_retraction_config.distance = getSettingInMillimeters("retraction_amount");
standard_retraction_config.prime_volume = getSettingInCubicMillimeters("retraction_extra_prime_amount");
standard_retraction_config.speed = getSettingInMillimetersPerSecond("retraction_retract_speed");
standard_retraction_config.primeSpeed = getSettingInMillimetersPerSecond("retraction_prime_speed");
standard_retraction_config.zHop = getSettingInMicrons("retraction_hop");
standard_retraction_config.retraction_count_max = getSettingAsCount("retraction_count_max");
standard_retraction_config.retraction_extrusion_window = INT2MM(getSettingInMicrons("retraction_extrusion_window"));
standard_retraction_config.retraction_extrusion_window = getSettingInMillimeters("retraction_extrusion_window");
standard_retraction_config.retraction_min_travel_distance = getSettingInMicrons("retraction_min_travel");
}
void Wireframe2gcode::processStartingCode(CommandSocket* command_socket)
void Wireframe2gcode::processStartingCode()
{
if (gcode.getFlavor() == EGCodeFlavor::ULTIGCODE)
if (!CommandSocket::isInstantiated())
{
if (!command_socket)
{
gcode.writeCode(";FLAVOR:UltiGCode\n;TIME:666\n;MATERIAL:666\n;MATERIAL2:-1\n");
}
std::string prefix = gcode.getFileHeader();
gcode.writeCode(prefix.c_str());
}
else
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") > 0)
if (getSettingBoolean("machine_heated_bed") && getSettingInDegreeCelsius("material_bed_temperature") != 0)
{
gcode.writeBedTemperatureCommand(getSettingInDegreeCelsius("material_bed_temperature"), getSettingBoolean("material_bed_temp_wait"));
}
}
if (getSettingBoolean("material_print_temp_prepend"))
{
if (getSettingInDegreeCelsius("material_print_temperature") > 0)
for (int extruder_nr = 0; extruder_nr < getSettingAsCount("machine_extruder_count"); extruder_nr++)
{
gcode.writeTemperatureCommand(getSettingAsIndex("extruder_nr"), getSettingInDegreeCelsius("material_print_temperature"));
if (getSettingBoolean("machine_print_temp_wait"))
double print_temp = getSettingInDegreeCelsius("material_print_temperature");
gcode.writeTemperatureCommand(extruder_nr, print_temp);
}
if (getSettingBoolean("material_print_temp_wait"))
{
for (int extruder_nr = 0; extruder_nr < getSettingAsCount("machine_extruder_count"); extruder_nr++)
{
gcode.writeTemperatureCommand(getSettingAsIndex("extruder_nr"), getSettingInDegreeCelsius("material_print_temperature"), true);
double print_temp = getSettingInDegreeCelsius("material_print_temperature");
gcode.writeTemperatureCommand(extruder_nr, print_temp, true);
}
}
}
}
gcode.writeCode(getSettingString("machine_start_gcode").c_str());
gcode.writeComment("Generated with Cura_SteamEngine " VERSION);
if (gcode.getFlavor() == EGCodeFlavor::BFB)
{
gcode.writeComment("enable auto-retraction");
@@ -592,10 +596,20 @@ void Wireframe2gcode::processStartingCode(CommandSocket* command_socket)
tmp << "M227 S" << (getSettingInMicrons("retraction_amount") * 2560 / 1000) << " P" << (getSettingInMicrons("retraction_amount") * 2560 / 1000);
gcode.writeLine(tmp.str().c_str());
}
else if (gcode.getFlavor() == EGCodeFlavor::GRIFFIN)
{ // initialize extruder trains
gcode.writeCode("T0"); // Toolhead already assumed to be at T0, but writing it just to be safe...
CommandSocket::setSendCurrentPosition(gcode.getPositionXY());
gcode.startExtruder(start_extruder_nr);
constexpr bool wait = true;
gcode.writeTemperatureCommand(start_extruder_nr, getSettingInDegreeCelsius("material_print_temperature"), wait);
gcode.writePrimeTrain(getSettingInMillimetersPerSecond("speed_travel"));
gcode.writeRetraction(standard_retraction_config);
}
}
void Wireframe2gcode::processSkirt(CommandSocket* commandSocket)
void Wireframe2gcode::processSkirt()
{
if (wireFrame.bottom_outline.size() == 0) //If we have no layers, don't create a skirt either.
{
@@ -605,16 +619,16 @@ void Wireframe2gcode::processSkirt(CommandSocket* commandSocket)
PathOrderOptimizer order(Point(INT32_MIN, INT32_MIN));
order.addPolygons(skirt);
order.optimize();
for (unsigned int poly_idx = 0; poly_idx < skirt.size(); poly_idx++)
for (unsigned int poly_order_idx = 0; poly_order_idx < skirt.size(); poly_order_idx++)
{
unsigned int actual_poly_idx = order.polyOrder[poly_idx];
PolygonRef poly = skirt[actual_poly_idx];
gcode.writeMove(poly[order.polyStart[actual_poly_idx]], getSettingInMillimetersPerSecond("speed_travel"), 0);
unsigned int poly_idx = order.polyOrder[poly_order_idx];
PolygonRef poly = skirt[poly_idx];
gcode.writeMove(poly[order.polyStart[poly_idx]], getSettingInMillimetersPerSecond("speed_travel"), 0);
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
{
Point& p = poly[(point_idx + order.polyStart[actual_poly_idx] + 1) % poly.size()];
gcode.writeMove(p, getSettingInMillimetersPerSecond("skirt_speed"), getSettingInMillimetersPerSecond("skirt_line_width"));
Point& p = poly[(point_idx + order.polyStart[poly_idx] + 1) % poly.size()];
gcode.writeMove(p, getSettingInMillimetersPerSecond("skirt_brim_speed"), getSettingInMillimeters("skirt_brim_line_width") * INT2MM(initial_layer_thickness));
}
}
}
@@ -622,7 +636,7 @@ void Wireframe2gcode::processSkirt(CommandSocket* commandSocket)
void Wireframe2gcode::finalize()
{
gcode.finalize(getSettingInMillimetersPerSecond("speed_travel"), getSettingString("machine_end_gcode").c_str());
gcode.finalize(getSettingString("machine_end_gcode").c_str());
for(int e=0; e<getSettingAsCount("machine_extruder_count"); e++)
gcode.writeTemperatureCommand(e, 0, false);
}
+7 -9
Ver Arquivo
@@ -8,7 +8,7 @@
#include "weaveDataStorage.h"
#include "commandSocket.h"
#include "settings.h"
#include "settings/settings.h"
#include "MeshGroup.h"
#include "slicer.h"
@@ -16,8 +16,6 @@
#include "utils/polygon.h"
#include "Weaver.h"
#include "debug.h"
namespace cura
{
@@ -33,11 +31,11 @@ private:
int initial_layer_thickness;
int filament_diameter;
int extrusionWidth;
int line_width;
double flowConnection;
double flowFlat;
double extrusion_per_mm_connection;
double extrusion_per_mm_flat;
double extrusion_mm3_per_mm_connection;
double extrusion_mm3_per_mm_flat;
int nozzle_outer_diameter;
int nozzle_head_distance;
double nozzle_expansion_angle;
@@ -71,7 +69,7 @@ public:
Wireframe2gcode(Weaver& weaver, GCodeExport& gcode, SettingsBase* settings_base);
void writeGCode(CommandSocket* commandSocket);
void writeGCode();
private:
@@ -80,12 +78,12 @@ private:
/*!
* Startup gcode: nozzle temp up, retraction settings, bed temp
*/
void processStartingCode(CommandSocket* command_socket);
void processStartingCode();
/*!
* Lay down a skirt
*/
void processSkirt(CommandSocket* commandSocket);
void processSkirt();
/*!
* End gcode: nozzle temp down
+1 -1
Ver Arquivo
@@ -5,7 +5,7 @@
namespace cura {
int bridgeAngle(Polygons outline, SliceLayer* prevLayer)
int bridgeAngle(Polygons outline, const SliceLayer* prevLayer)
{
AABB boundaryBox(outline);
//To detect if we have a bridge, first calculate the intersection of the current layer with the previous layer.
+1 -1
Ver Arquivo
@@ -6,7 +6,7 @@ namespace cura {
class Polygons;
class SliceLayer;
int bridgeAngle(Polygons outline, SliceLayer* prevLayer);
int bridgeAngle(Polygons outline, const SliceLayer* prevLayer);
}//namespace cura
-391
Ver Arquivo
@@ -1,391 +0,0 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "comb.h"
#include <algorithm>
#include "utils/polygonUtils.h"
#include "sliceDataStorage.h"
#include "utils/SVG.h"
namespace cura {
// boundary_outside is only computed when it's needed!
Polygons* Comb::getBoundaryOutside()
{
if (!boundary_outside)
{
boundary_outside = new Polygons();
*boundary_outside = storage.getLayerOutlines(layer_nr, false).offset(offset_from_outlines_outside);
}
return boundary_outside;
}
Comb::Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
: storage(storage)
, layer_nr(layer_nr)
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls
, max_moveInside_distance2(offset_from_outlines * 2 * offset_from_outlines * 2)
, offset_from_outlines_outside(travel_avoid_distance)
, avoid_other_parts(travel_avoid_other_parts)
// , boundary_inside( boundary.offset(-offset_from_outlines) ) // TODO: make inside boundary configurable?
, boundary_inside( comb_boundary_inside )
, boundary_outside(nullptr)
, partsView_inside( boundary_inside.splitIntoPartsView() ) // !! changes the order of boundary_inside !!
{
}
Comb::~Comb()
{
if (boundary_outside)
delete boundary_outside;
}
bool Comb::calc(Point startPoint, Point endPoint, CombPaths& combPaths, bool startInside, bool endInside, int64_t max_comb_distance_ignored)
{
if (shorterThen(endPoint - startPoint, max_comb_distance_ignored))
{
return true;
}
//Move start and end point inside the comb boundary
unsigned int start_inside_poly = NO_INDEX;
if (startInside)
{
start_inside_poly = PolygonUtils::moveInside(boundary_inside, startPoint, offset_extra_start_end, max_moveInside_distance2);
if (!boundary_inside.inside(start_inside_poly) || start_inside_poly == NO_INDEX)
{
if (start_inside_poly != NO_INDEX)
{ // if not yet inside because of overshoot, try again
start_inside_poly = PolygonUtils::moveInside(boundary_inside, startPoint, offset_extra_start_end, max_moveInside_distance2);
}
if (start_inside_poly == NO_INDEX) //If we fail to move the point inside the comb boundary we need to retract.
{
startInside = false;
}
}
}
unsigned int end_inside_poly = NO_INDEX;
if (endInside)
{
end_inside_poly = PolygonUtils::moveInside(boundary_inside, endPoint, offset_extra_start_end, max_moveInside_distance2);
if (!boundary_inside.inside(endPoint) || end_inside_poly == NO_INDEX)
{
if (end_inside_poly != NO_INDEX)
{ // if not yet inside because of overshoot, try again
end_inside_poly = PolygonUtils::moveInside(boundary_inside, endPoint, offset_extra_start_end, max_moveInside_distance2);
}
if (end_inside_poly == NO_INDEX) //If we fail to move the point inside the comb boundary we need to retract.
{
endInside = false;
}
}
}
unsigned int start_part_boundary_poly_idx;
unsigned int end_part_boundary_poly_idx;
unsigned int start_part_idx = (start_inside_poly == NO_INDEX)? NO_INDEX : partsView_inside.getPartContaining(start_inside_poly, &start_part_boundary_poly_idx);
unsigned int end_part_idx = (end_inside_poly == NO_INDEX)? NO_INDEX : partsView_inside.getPartContaining(end_inside_poly, &end_part_boundary_poly_idx);
if (startInside && endInside && start_part_idx == end_part_idx)
{ // normal combing within part
PolygonsPart part = partsView_inside.assemblePart(start_part_idx);
combPaths.emplace_back();
LinePolygonsCrossings::comb(part, startPoint, endPoint, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored);
return true;
}
else
{ // comb inside part to edge (if needed) >> move through air avoiding other parts >> comb inside end part upto the endpoint (if needed)
Point middle_from;
Point middle_to;
Point inside_middle_from;
Point inside_middle_to;
if (startInside && endInside)
{
ClosestPolygonPoint middle_from_cp = PolygonUtils::findClosest(endPoint, boundary_inside[start_part_boundary_poly_idx]);
ClosestPolygonPoint middle_to_cp = PolygonUtils::findClosest(middle_from_cp.location, boundary_inside[end_part_boundary_poly_idx]);
// walkToNearestSmallestConnection(middle_from_cp, middle_to_cp); // TODO: perform this optimization?
middle_from = middle_from_cp.location;
inside_middle_from = middle_from_cp.location;
middle_to = middle_to_cp.location;
inside_middle_to = middle_to_cp.location;
PolygonUtils::moveInside(boundary_inside,inside_middle_from,offset_dist_to_get_from_on_the_polygon_to_outside,max_comb_distance_ignored); //Also move the intermediary waypoint inside if it isn't yet.
PolygonUtils::moveInside(boundary_inside,inside_middle_to,offset_dist_to_get_from_on_the_polygon_to_outside,max_comb_distance_ignored);
}
else if(!startInside && !endInside)
{
middle_from = startPoint;
inside_middle_from = startPoint;
middle_to = endPoint;
inside_middle_to = endPoint;
}
else if(!startInside && endInside)
{
middle_from = startPoint;
inside_middle_from = startPoint;
ClosestPolygonPoint middle_to_cp = PolygonUtils::findClosest(middle_from,boundary_inside[end_part_boundary_poly_idx]);
middle_to = middle_to_cp.location;
inside_middle_to = middle_to_cp.location;
PolygonUtils::moveInside(boundary_inside,inside_middle_to,offset_dist_to_get_from_on_the_polygon_to_outside,max_comb_distance_ignored);
}
else if(startInside && !endInside)
{
middle_to = endPoint;
inside_middle_to = endPoint;
ClosestPolygonPoint middle_from_cp = PolygonUtils::findClosest(middle_to,boundary_inside[start_part_boundary_poly_idx]);
middle_from = middle_from_cp.location;
inside_middle_from = middle_from_cp.location;
PolygonUtils::moveInside(boundary_inside,inside_middle_from,offset_dist_to_get_from_on_the_polygon_to_outside,max_comb_distance_ignored);
}
if (startInside)
{
// start to boundary
PolygonsPart part_begin = partsView_inside.assemblePart(start_part_idx); // comb through the starting part only
combPaths.emplace_back();
LinePolygonsCrossings::comb(part_begin, startPoint, inside_middle_from, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored);
}
// throught air from boundary to boundary
if (avoid_other_parts)
{
Polygons& middle = *getBoundaryOutside(); // comb through all air, since generally the outside consists of a single part
Point from_outside = middle_from;
if (startInside || middle.inside(from_outside, true))
{ // move outside
PolygonUtils::moveInside(middle, from_outside, -offset_extra_start_end, max_moveInside_distance2);
}
Point to_outside = middle_to;
if (endInside || middle.inside(to_outside, true))
{ // move outside
PolygonUtils::moveInside(middle, to_outside, -offset_extra_start_end, max_moveInside_distance2);
}
combPaths.emplace_back();
combPaths.back().throughAir = true;
if ( vSize(inside_middle_from - inside_middle_to) < vSize(inside_middle_from - from_outside) + vSize(inside_middle_to - to_outside) )
{ // via outside is a detour
combPaths.back().push_back(inside_middle_from);
combPaths.back().push_back(inside_middle_to);
}
else
{
LinePolygonsCrossings::comb(middle, from_outside, to_outside, combPaths.back(), offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored);
}
}
else
{ // directly through air (not avoiding other parts)
combPaths.emplace_back();
combPaths.back().throughAir = true;
combPaths.back().cross_boundary = true; // TODO: calculate whether we cross a boundary!
combPaths.back().push_back(inside_middle_from);
combPaths.back().push_back(inside_middle_to);
}
if (endInside)
{
// boundary to end
PolygonsPart part_end = partsView_inside.assemblePart(end_part_idx); // comb through end part only
combPaths.emplace_back();
LinePolygonsCrossings::comb(part_end, inside_middle_to, endPoint, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored);
}
return true;
}
}
void LinePolygonsCrossings::calcScanlineCrossings()
{
min_crossing_idx = NO_INDEX;
max_crossing_idx = NO_INDEX;
for(unsigned int poly_idx = 0; poly_idx < boundary.size(); poly_idx++)
{
PolyCrossings minMax(poly_idx);
PolygonRef poly = boundary[poly_idx];
Point p0 = transformation_matrix.apply(poly[poly.size() - 1]);
for(unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
{
Point p1 = transformation_matrix.apply(poly[point_idx]);
if((p0.Y >= transformed_startPoint.Y && p1.Y <= transformed_startPoint.Y) || (p1.Y >= transformed_startPoint.Y && p0.Y <= transformed_startPoint.Y))
{
if(p1.Y == p0.Y) //Line segment is parallel with the scanline. That means that both endpoints lie on the scanline, so they will have intersected with the adjacent line.
{
p0 = p1;
continue;
}
int64_t x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y);
if (x >= transformed_startPoint.X && x <= transformed_endPoint.X)
{
if(x < minMax.min.x) //For the leftmost intersection, move x left to stay outside of the border.
//Note: The actual distance from the intersection to the border is almost always less than dist_to_move_boundary_point_outside, since it only moves along the direction of the scanline.
{
minMax.min.x = x;
minMax.min.point_idx = point_idx;
}
if(x > minMax.max.x) //For the rightmost intersection, move x right to stay outside of the border.
{
minMax.max.x = x;
minMax.max.point_idx = point_idx;
}
}
}
p0 = p1;
}
if (minMax.min.point_idx != NO_INDEX)
{ // then also max.point_idx != -1
if (min_crossing_idx == NO_INDEX || minMax.min.x < crossings[min_crossing_idx].min.x) { min_crossing_idx = crossings.size(); }
if (max_crossing_idx == NO_INDEX || minMax.max.x > crossings[max_crossing_idx].max.x) { max_crossing_idx = crossings.size(); }
crossings.push_back(minMax);
}
}
}
bool LinePolygonsCrossings::lineSegmentCollidesWithBoundary()
{
Point diff = endPoint - startPoint;
transformation_matrix = PointMatrix(diff);
transformed_startPoint = transformation_matrix.apply(startPoint);
transformed_endPoint = transformation_matrix.apply(endPoint);
for(PolygonRef poly : boundary)
{
Point p0 = transformation_matrix.apply(poly.back());
for(Point p1_ : poly)
{
Point p1 = transformation_matrix.apply(p1_);
if ((p0.Y > transformed_startPoint.Y && p1.Y < transformed_startPoint.Y) || (p1.Y > transformed_startPoint.Y && p0.Y < transformed_startPoint.Y))
{
int64_t x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y);
if (x > transformed_startPoint.X && x < transformed_endPoint.X)
return true;
}
p0 = p1;
}
}
return false;
}
void LinePolygonsCrossings::getCombingPath(CombPath& combPath, int64_t max_comb_distance_ignored)
{
if (shorterThen(endPoint - startPoint, max_comb_distance_ignored) || !lineSegmentCollidesWithBoundary())
{
//We're not crossing any boundaries. So skip the comb generation.
combPath.push_back(startPoint);
combPath.push_back(endPoint);
return;
}
calcScanlineCrossings();
CombPath basicPath;
getBasicCombingPath(basicPath);
optimizePath(basicPath, combPath);
}
void LinePolygonsCrossings::getBasicCombingPath(CombPath& combPath)
{
for (PolyCrossings* crossing = getNextPolygonAlongScanline(transformed_startPoint.X)
; crossing != nullptr
; crossing = getNextPolygonAlongScanline(crossing->max.x))
{
getBasicCombingPath(*crossing, combPath);
}
combPath.push_back(endPoint);
}
void LinePolygonsCrossings::getBasicCombingPath(PolyCrossings& polyCrossings, CombPath& combPath)
{
PolygonRef poly = boundary[polyCrossings.poly_idx];
combPath.push_back(transformation_matrix.unapply(Point(polyCrossings.min.x + dist_to_move_boundary_point_outside, transformed_startPoint.Y)));
if ( ( polyCrossings.max.point_idx - polyCrossings.min.point_idx + poly.size() ) % poly.size()
< poly.size() / 2 )
{ // follow the path in the same direction as the winding order of the boundary polygon
for(unsigned int point_idx = polyCrossings.min.point_idx
; point_idx != polyCrossings.max.point_idx
; point_idx = (point_idx < poly.size() - 1) ? (point_idx + 1) : (0))
{
combPath.push_back(PolygonUtils::getBoundaryPointWithOffset(poly, point_idx, dist_to_move_boundary_point_outside));
}
}
else
{ // follow the path in the opposite direction of the winding order of the boundary polygon
unsigned int min_idx = (polyCrossings.min.point_idx == 0)? poly.size() - 1: polyCrossings.min.point_idx - 1;
unsigned int max_idx = (polyCrossings.max.point_idx == 0)? poly.size() - 1: polyCrossings.max.point_idx - 1;
for(unsigned int point_idx = min_idx; point_idx != max_idx; point_idx = (point_idx > 0) ? (point_idx - 1) : (poly.size() - 1))
{
combPath.push_back(PolygonUtils::getBoundaryPointWithOffset(poly, point_idx, dist_to_move_boundary_point_outside));
}
}
combPath.push_back(transformation_matrix.unapply(Point(polyCrossings.max.x - dist_to_move_boundary_point_outside, transformed_startPoint.Y)));
}
LinePolygonsCrossings::PolyCrossings* LinePolygonsCrossings::getNextPolygonAlongScanline(int64_t x)
{
PolyCrossings* ret = nullptr;
for(PolyCrossings& crossing : crossings)
{
if (crossing.min.x > x && (ret == nullptr || crossing.min.x < ret->min.x) )
{
ret = &crossing;
}
}
return ret;
}
bool LinePolygonsCrossings::optimizePath(CombPath& comb_path, CombPath& optimized_comb_path)
{
optimized_comb_path.push_back(startPoint);
for(unsigned int point_idx = 1; point_idx<comb_path.size(); point_idx++)
{
if(comb_path[point_idx] == comb_path[point_idx - 1]) //Two points are the same. Skip the second.
{
continue;
}
Point& current_point = optimized_comb_path.back();
if (PolygonUtils::polygonCollidesWithlineSegment(boundary, current_point, comb_path[point_idx]))
{
if (PolygonUtils::polygonCollidesWithlineSegment(boundary, current_point, comb_path[point_idx - 1]))
{
comb_path.cross_boundary = true;
}
optimized_comb_path.push_back(comb_path[point_idx - 1]);
}
else
{
// : dont add the newest point
// TODO: add the below extra optimization? (+/- 7% extra computation time, +/- 2% faster print for Dual_extrusion_support_generation.stl)
while (optimized_comb_path.size() > 1)
{
if (PolygonUtils::polygonCollidesWithlineSegment(boundary, optimized_comb_path[optimized_comb_path.size() - 2], comb_path[point_idx]))
{
break;
}
else
{
optimized_comb_path.pop_back();
}
}
}
}
return true;
}
}//namespace cura
+598 -172
Ver Arquivo
@@ -1,13 +1,15 @@
#include "utils/logoutput.h"
#include "commandSocket.h"
#include "FffProcessor.h"
#include "Progress.h"
#include "progress/Progress.h"
#include <thread>
#include <cinttypes>
#ifdef ARCUS
#include <Arcus/Socket.h>
#include <Arcus/SocketListener.h>
#include <Arcus/Error.h>
#endif
#include <string> // stoi
@@ -17,6 +19,7 @@
#endif
#define DEBUG_OUTPUT_OBJECT_STL_THROUGH_CERR(x)
// std::cerr << x;
namespace cura {
@@ -25,166 +28,424 @@ namespace cura {
#define FLOATS_PER_VECTOR 3
#define VECTORS_PER_FACE 3
CommandSocket* CommandSocket::instance = nullptr; // instantiate instance
#ifdef ARCUS
class Listener : public Arcus::SocketListener
{
public:
void stateChanged(Arcus::SocketState::SocketState newState) override
{
}
void messageReceived() override
{
}
void error(const Arcus::Error & error) override
{
if (error.getErrorCode() == Arcus::ErrorCode::Debug)
{
log("%s\n", error.toString().c_str());
}
else
{
logError("%s\n", error.toString().c_str());
}
}
};
/*!
* A template structure used to store data to be sent to the front end.
*/
template <typename T>
class SliceDataStruct
{
SliceDataStruct(const SliceDataStruct&) = delete;
SliceDataStruct& operator=(const SliceDataStruct&) = delete;
public:
SliceDataStruct()
: sliced_objects(0)
, current_layer_count(0)
, current_layer_offset(0)
{ }
//! The number of sliced objects for this sliced object list
int sliced_objects;
int current_layer_count;//!< Number of layers for which data has been buffered in slice_data so far.
int current_layer_offset;//!< Offset to add to layer number for the current slice object when slicing one at a time.
std::unordered_map<int, std::shared_ptr<T>> slice_data;
};
class CommandSocket::Private
{
public:
Private()
: socket(nullptr)
, object_count(0)
, current_sliced_object(nullptr)
, sliced_objects(0)
, current_layer_count(0)
, current_layer_offset(0)
{ }
cura::proto::Layer* getLayerById(int id);
std::shared_ptr<cura::proto::Layer> getLayerById(int id);
std::shared_ptr<cura::proto::LayerOptimized> getOptimizedLayerById(int id);
Arcus::Socket* socket;
// Number of objects that need to be sliced
int object_count;
// Message that holds a list of sliced objects
std::shared_ptr<cura::proto::SlicedObjectList> sliced_object_list;
// Message that holds the currently sliced object (to be added to sliced_object_list)
cura::proto::SlicedObject* current_sliced_object;
// Number of sliced objects for this sliced object list
int sliced_objects;
// Number of layers sent to the front end so far
// Used for incrementing the current layer in one at a time mode
int current_layer_count;
int current_layer_offset;
// Ids of the sliced objects
std::vector<int64_t> object_ids;
std::string temp_gcode_file;
std::ostringstream gcode_output_stream;
// Print object that olds one or more meshes that need to be sliced.
std::vector< std::shared_ptr<MeshGroup> > objects_to_slice;
SliceDataStruct<cura::proto::Layer> sliced_layers;
SliceDataStruct<cura::proto::LayerOptimized> optimized_layers;
};
/*!
* PathCompiler buffers and prepares the sliced data to be sent to the front end and saves them in
* appropriate buffers
*/
class CommandSocket::PathCompiler
{
typedef cura::proto::PathSegment::PointType PointType;
static_assert(sizeof(PrintFeatureType) == 1, "To be compatible with the Cura frontend code PrintFeatureType needs to be of size 1");
//! Reference to the private data of the CommandSocket used to send the data to the front end.
CommandSocket::Private& _cs_private_data;
//! Keeps track of the current layer number being processed. If layer number is set to a different value, the current data is flushed to CommandSocket.
int _layer_nr;
int extruder;
PointType data_point_type;
std::vector<PrintFeatureType> line_types; //!< Line types for the line segments stored, the size of this vector is N.
std::vector<float> line_widths; //!< Line widths for the line segments stored, the size of this vector is N.
std::vector<float> points; //!< The points used to define the line segments, the size of this vector is D*(N+1) as each line segment is defined from one point to the next. D is the dimensionality of the point.
Point last_point;
PathCompiler(const PathCompiler&) = delete;
PathCompiler& operator=(const PathCompiler&) = delete;
public:
PathCompiler(CommandSocket::Private& cs_private_data):
_cs_private_data(cs_private_data),
_layer_nr(0),
extruder(0),
data_point_type(cura::proto::PathSegment::Point2D),
line_types(),
line_widths(),
points(),
last_point{0,0}
{}
~PathCompiler()
{
if (line_types.size())
{
flushPathSegments();
}
}
/*!
* Used to select which layer the following layer data is intended for.
*/
void setLayer(int new_layer_nr)
{
if (_layer_nr != new_layer_nr)
{
flushPathSegments();
_layer_nr = new_layer_nr;
}
}
/*!
* Returns the current layer which data is written to.
*/
int getLayer() const
{
return _layer_nr;
}
/*!
* Used to set which extruder will be used for printing the following layer data is intended for.
*/
void setExtruder(int new_extruder)
{
if (extruder != new_extruder)
{
flushPathSegments();
extruder = new_extruder;
}
}
/*!
* Special handling of the first point in an added line sequence.
* If the new sequence of lines does not start at the current end point
* of the path this jump is marked as PrintFeatureType::NoneType
*/
void handleInitialPoint(Point from)
{
if (points.size() == 0)
{
addPoint2D(from);
}
else if (from != last_point)
{
addLineSegment(PrintFeatureType::NoneType, from, 1.0);
}
}
/*!
* Transfers the currently buffered line segments to the
* CommandSocket layer message storage.
*/
void flushPathSegments();
/*!
* Move the current point of this path to \position.
*/
void setCurrentPosition(Point position)
{
handleInitialPoint(position);
}
/*!
* Adds a single line segment to the current path. The line segment added is from the current last point to point \p to
*/
void sendLineTo(PrintFeatureType print_feature_type, Point to, int width);
/*!
* Adds closed polygon to the current path
*/
void sendPolygon(PrintFeatureType print_feature_type, ConstPolygonRef poly, int width);
private:
/*!
* Convert and add a point to the points buffer, each point being represented as two consecutive floats. All members adding a 2D point to the data should use this function.
*/
void addPoint2D(Point point)
{
points.push_back(INT2MM(point.X));
points.push_back(INT2MM(point.Y));
last_point = point;
}
/*!
* Implements the functionality of adding a single 2D line segment to the path data. All member functions adding a 2D line segment should use this functions.
*/
void addLineSegment(PrintFeatureType print_feature_type, Point point, int line_width)
{
addPoint2D(point);
line_types.push_back(print_feature_type);
line_widths.push_back(INT2MM(line_width));
}
};
#endif
CommandSocket::CommandSocket()
#ifdef ARCUS
: d(new Private)
: private_data(new Private)
, path_comp(new PathCompiler(*private_data))
#endif
{
#ifdef ARCUS
FffProcessor::getInstance()->setCommandSocket(this);
#endif
}
CommandSocket* CommandSocket::getInstance()
{
return instance;
}
void CommandSocket::instantiate()
{
instance = new CommandSocket();
}
bool CommandSocket::isInstantiated()
{
return instance != nullptr;
}
void CommandSocket::connect(const std::string& ip, int port)
{
#ifdef ARCUS
d->socket = new Arcus::Socket();
//d->socket->registerMessageType(1, &Cura::ObjectList::default_instance());
d->socket->registerMessageType(1, &cura::proto::Slice::default_instance());
d->socket->registerMessageType(2, &cura::proto::SlicedObjectList::default_instance());
d->socket->registerMessageType(3, &cura::proto::Progress::default_instance());
d->socket->registerMessageType(4, &cura::proto::GCodeLayer::default_instance());
d->socket->registerMessageType(5, &cura::proto::ObjectPrintTime::default_instance());
d->socket->registerMessageType(6, &cura::proto::SettingList::default_instance());
d->socket->registerMessageType(7, &cura::proto::GCodePrefix::default_instance());
private_data->socket = new Arcus::Socket();
private_data->socket->addListener(new Listener());
d->socket->connect(ip, port);
//private_data->socket->registerMessageType(1, &Cura::ObjectList::default_instance());
private_data->socket->registerMessageType(&cura::proto::Slice::default_instance());
private_data->socket->registerMessageType(&cura::proto::Layer::default_instance());
private_data->socket->registerMessageType(&cura::proto::LayerOptimized::default_instance());
private_data->socket->registerMessageType(&cura::proto::Progress::default_instance());
private_data->socket->registerMessageType(&cura::proto::GCodeLayer::default_instance());
private_data->socket->registerMessageType(&cura::proto::PrintTimeMaterialEstimates::default_instance());
private_data->socket->registerMessageType(&cura::proto::SettingList::default_instance());
private_data->socket->registerMessageType(&cura::proto::GCodePrefix::default_instance());
private_data->socket->registerMessageType(&cura::proto::SlicingFinished::default_instance());
private_data->socket->registerMessageType(&cura::proto::SettingExtruder::default_instance());
private_data->socket->connect(ip, port);
log("Connecting to %s:%i\n", ip.c_str(), port);
while(private_data->socket->getState() != Arcus::SocketState::Connected && private_data->socket->getState() != Arcus::SocketState::Error)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
log("Connected to %s:%i\n", ip.c_str(), port);
bool slice_another_time = true;
// Start & continue listening as long as socket is not closed and there is no error.
while(d->socket->state() != Arcus::SocketState::Closed && d->socket->state() != Arcus::SocketState::Error && slice_another_time)
while(private_data->socket->getState() != Arcus::SocketState::Closed && private_data->socket->getState() != Arcus::SocketState::Error && slice_another_time)
{
//If there is an object to slice, do so.
if(d->objects_to_slice.size())
{
FffProcessor::getInstance()->resetFileNumber();
for(auto object : d->objects_to_slice)
{
if(!FffProcessor::getInstance()->processMeshGroup(object.get()))
{
logError("Slicing mesh group failed!");
}
}
d->objects_to_slice.clear();
FffProcessor::getInstance()->finalize();
sendGCodeLayer();
sendPrintTime();
slice_another_time = false; // TODO: remove this when multiple slicing with CuraEngine is safe
//TODO: Support all-at-once/one-at-a-time printing
//d->processor->processModel(d->object_to_slice.get());
//d->object_to_slice.reset();
//d->processor->resetFileNumber();
//sendPrintTime();
}
// Actually start handling messages.
Arcus::MessagePtr message = d->socket->takeNextMessage();
Arcus::MessagePtr message = private_data->socket->takeNextMessage();
/*
* handle a message which consists purely of a SettingList
cura::proto::SettingList* setting_list = dynamic_cast<cura::proto::SettingList*>(message.get());
if(setting_list)
if (setting_list)
{
handleSettingList(setting_list);
}
*/
/*cura::proto::ObjectList* object_list = dynamic_cast<cura::proto::ObjectList*>(message.get());
if(object_list)
/*
* handle a message which consists purely of an ObjectList
cura::proto::ObjectList* object_list = dynamic_cast<cura::proto::ObjectList*>(message.get());
if (object_list)
{
handleObjectList(object_list);
}*/
cura::proto::Slice* slice = dynamic_cast<cura::proto::Slice*>(message.get());
if(slice)
}
*/
// Handle the main Slice message
cura::proto::Slice* slice = dynamic_cast<cura::proto::Slice*>(message.get()); // See if the message is of the message type Slice; returns nullptr otherwise
if (slice)
{
// Reset object counts
d->object_count = 0;
d->object_ids.clear();
for(auto object : slice->object_lists())
logDebug("Received a Slice message\n");
const cura::proto::SettingList& global_settings = slice->global_settings();
for (auto setting : global_settings.settings())
{
handleObjectList(&object);
FffProcessor::getInstance()->setSetting(setting.name(), setting.value());
}
// Reset object counts
private_data->object_count = 0;
for (auto object : slice->object_lists())
{
handleObjectList(&object, slice->extruders());
}
//For every object, set the extruder fallbacks from the limit_to_extruder.
for (const cura::proto::SettingExtruder setting_extruder : slice->limit_to_extruder())
{
const int32_t extruder_nr = setting_extruder.extruder(); //Implicit cast from Protobuf's int32 to normal int32.
for (std::shared_ptr<MeshGroup> meshgroup : private_data->objects_to_slice)
{
if (extruder_nr < 0 || extruder_nr >= meshgroup->getExtruderCount()) //We obtained an invalid value from the front-end. Ignore.
{
continue;
}
const ExtruderTrain* settings_base = meshgroup->getExtruderTrain(extruder_nr); //The extruder train that the setting should fall back to.
for (Mesh& mesh : meshgroup->meshes)
{
mesh.setSettingInheritBase(setting_extruder.name(), *settings_base);
}
}
}
logDebug("Done reading Slice message\n");
}
//If there is an object to slice, do so.
if (private_data->objects_to_slice.size())
{
int object_count = private_data->objects_to_slice.size();
logDebug("Slicing %i objects\n", object_count);
FffProcessor::getInstance()->resetMeshGroupNumber();
int i = 1;
for (auto object : private_data->objects_to_slice)
{
logDebug("Slicing object %i of %i\n", i, object_count);
if (!FffProcessor::getInstance()->processMeshGroup(object.get()))
{
logError("Slicing mesh group failed!");
}
i++;
}
logDebug("Done slicing objects\n");
private_data->objects_to_slice.clear();
FffProcessor::getInstance()->finalize();
flushGcode();
sendPrintTimeMaterialEstimates();
sendFinishedSlicing();
slice_another_time = false; // TODO: remove this when multiple slicing with CuraEngine is safe
//TODO: Support all-at-once/one-at-a-time printing
//private_data->processor->processModel(private_data->object_to_slice.get());
//private_data->object_to_slice.reset();
//private_data->processor->resetFileNumber();
//sendPrintTimeMaterialEstimates();
}
std::this_thread::sleep_for(std::chrono::milliseconds(250));
if(!d->socket->errorString().empty())
{
logError("%s\n", d->socket->errorString().data());
d->socket->clearError();
}
}
log("Closing connection\n");
private_data->socket->close();
#endif
}
#ifdef ARCUS
void CommandSocket::handleObjectList(cura::proto::ObjectList* list)
void CommandSocket::handleObjectList(cura::proto::ObjectList* list, const google::protobuf::RepeatedPtrField<cura::proto::Extruder> settings_per_extruder_train)
{
if (list->objects_size() <= 0)
{
return;
}
FMatrix3x3 matrix;
//d->object_count = 0;
//d->object_ids.clear();
d->objects_to_slice.push_back(std::make_shared<MeshGroup>(FffProcessor::getInstance()));
MeshGroup* meshgroup = d->objects_to_slice.back().get();
for(auto setting : list->settings())
//private_data->object_count = 0;
//private_data->object_ids.clear();
private_data->objects_to_slice.push_back(std::make_shared<MeshGroup>(FffProcessor::getInstance()));
MeshGroup* meshgroup = private_data->objects_to_slice.back().get();
// load meshgroup settings
for (auto setting : list->settings())
{
meshgroup->setSetting(setting.name(), setting.value());
}
for (int extruder_nr = 0; extruder_nr < FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count"); extruder_nr++)
{ // initialize remaining extruder trains and load the defaults
meshgroup->createExtruderTrain(extruder_nr)->setExtruderTrainDefaults(extruder_nr); // create new extruder train objects or use already existing ones
{ // load extruder settings
for (int extruder_nr = 0; extruder_nr < FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count"); extruder_nr++)
{ // initialize remaining extruder trains and load the defaults
meshgroup->createExtruderTrain(extruder_nr); // create new extruder train objects or use already existing ones
}
for (auto extruder : settings_per_extruder_train)
{
int extruder_nr = extruder.id();
ExtruderTrain* train = meshgroup->getExtruderTrain(extruder_nr);
for (auto setting : extruder.settings().settings())
{
train->setSetting(setting.name(), setting.value());
}
}
}
for(auto object : list->objects())
for (auto object : list->objects())
{
int bytes_per_face = BYTES_PER_FLOAT * FLOATS_PER_VECTOR * VECTORS_PER_FACE;
int face_count = object.vertices().size() / bytes_per_face;
if (face_count <= 0)
{
logWarning("Got an empty mesh, ignoring it!");
continue;
}
DEBUG_OUTPUT_OBJECT_STL_THROUGH_CERR("solid Cura_out\n");
int extruder_train_nr = 0; // TODO: make primary extruder configurable!
for(auto setting : object.settings())
// Check to which extruder train this object belongs
int extruder_train_nr = 0; // assume extruder 0 if setting wasn't supplied
for (auto setting : object.settings())
{
if (setting.name() == "extruder_nr")
{
@@ -197,9 +458,7 @@ void CommandSocket::handleObjectList(cura::proto::ObjectList* list)
meshgroup->meshes.push_back(extruder_train); //Construct a new mesh (with the corresponding extruder train as settings parent object) and put it into MeshGroup's mesh list.
Mesh& mesh = meshgroup->meshes.back();
int bytes_per_face = BYTES_PER_FLOAT * FLOATS_PER_VECTOR * VECTORS_PER_FACE;
int face_count = object.vertices().size() / bytes_per_face;
for(int i = 0; i < face_count; ++i)
for (int i = 0; i < face_count; ++i)
{
//TODO: Apply matrix
std::string data = object.vertices().substr(i * bytes_per_face, bytes_per_face);
@@ -220,73 +479,115 @@ void CommandSocket::handleObjectList(cura::proto::ObjectList* list)
DEBUG_OUTPUT_OBJECT_STL_THROUGH_CERR(" endfacet\n");
}
DEBUG_OUTPUT_OBJECT_STL_THROUGH_CERR("endsolid Cura_out\n");
for(auto setting : object.settings())
for (auto setting : object.settings())
{
mesh.setSetting(setting.name(), setting.value());
}
d->object_ids.push_back(object.id());
mesh.finish();
}
d->object_count++;
private_data->object_count++;
meshgroup->finalize();
}
void CommandSocket::handleSettingList(cura::proto::SettingList* list)
{
for(auto setting : list->settings())
{
FffProcessor::getInstance()->setSetting(setting.name(), setting.value());
}
}
#endif
void CommandSocket::sendLayerInfo(int layer_nr, int32_t z, int32_t height)
void CommandSocket::sendOptimizedLayerInfo(int layer_nr, int32_t z, int32_t height)
{
#ifdef ARCUS
if(!d->current_sliced_object)
{
return;
}
cura::proto::Layer* layer = d->getLayerById(layer_nr);
std::shared_ptr<cura::proto::LayerOptimized> layer = private_data->getOptimizedLayerById(layer_nr);
layer->set_height(z);
layer->set_thickness(height);
#endif
}
void CommandSocket::sendPolygons(PolygonType type, int layer_nr, Polygons& polygons, int line_width)
void CommandSocket::sendPolygons(PrintFeatureType type, const Polygons& polygons, int line_width)
{
#ifdef ARCUS
if(!d->current_sliced_object)
return;
if (polygons.size() == 0)
return;
cura::proto::Layer* layer = d->getLayerById(layer_nr);
for(unsigned int i = 0; i < polygons.size(); ++i)
{
cura::proto::Polygon* p = layer->add_polygons();
p->set_type(static_cast<cura::proto::Polygon_Type>(type));
std::string polydata;
polydata.append(reinterpret_cast<const char*>(polygons[i].data()), polygons[i].size() * sizeof(Point));
p->set_points(polydata);
p->set_line_width(line_width);
return;
}
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
for (unsigned int i = 0; i < polygons.size(); ++i)
{
path_comp->sendPolygon(type, polygons[i], line_width);
}
}
#endif
}
void CommandSocket::sendPolygon(PrintFeatureType type, ConstPolygonRef polygon, int line_width)
{
#ifdef ARCUS
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
path_comp->sendPolygon(type, polygon, line_width);
}
#endif
}
void CommandSocket::sendLineTo(cura::PrintFeatureType type, Point to, int line_width)
{
#ifdef ARCUS
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
path_comp->sendLineTo(type, to, line_width);
}
#endif
}
void CommandSocket::setSendCurrentPosition(Point position)
{
#ifdef ARCUS
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
path_comp->setCurrentPosition(position);
}
#endif
}
void CommandSocket::setLayerForSend(int layer_nr)
{
#ifdef ARCUS
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
path_comp->setLayer(layer_nr);
}
#endif
}
void CommandSocket::setExtruderForSend(int extruder)
{
#ifdef ARCUS
if (CommandSocket::isInstantiated())
{
auto& path_comp = CommandSocket::getInstance()->path_comp;
path_comp->setExtruder(extruder);
}
#endif
}
void CommandSocket::sendProgress(float amount)
{
#ifdef ARCUS
auto message = std::make_shared<cura::proto::Progress>();
amount /= d->object_count;
amount += d->sliced_objects * (1. / d->object_count);
amount /= private_data->object_count;
amount += private_data->optimized_layers.sliced_objects * (1. / private_data->object_count);
message->set_amount(amount);
d->socket->sendMessage(message);
private_data->socket->sendMessage(message);
#endif
}
@@ -295,13 +596,24 @@ void CommandSocket::sendProgressStage(Progress::Stage stage)
// TODO
}
void CommandSocket::sendPrintTime()
void CommandSocket::sendPrintTimeMaterialEstimates()
{
#ifdef ARCUS
auto message = std::make_shared<cura::proto::ObjectPrintTime>();
logDebug("Sending print time and material estimates.\n");
auto message = std::make_shared<cura::proto::PrintTimeMaterialEstimates>();
message->set_time(FffProcessor::getInstance()->getTotalPrintTime());
message->set_material_amount(FffProcessor::getInstance()->getTotalFilamentUsed(0));
d->socket->sendMessage(message);
int num_extruders = FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count");
for (int extruder_nr (0); extruder_nr < num_extruders; ++extruder_nr)
{
cura::proto::MaterialEstimates* material_message = message->add_materialestimates();
material_message->set_id(extruder_nr);
material_message->set_material_amount(FffProcessor::getInstance()->getTotalFilamentUsed(extruder_nr));
}
private_data->socket->sendMessage(message);
logDebug("Done sending print time and material estimates.\n");
#endif
}
@@ -314,57 +626,84 @@ void CommandSocket::sendPrintMaterialForObject(int index, int extruder_nr, float
// socket.sendFloat32(print_time);
}
void CommandSocket::beginSendSlicedObject()
void CommandSocket::sendLayerData()
{
#ifdef ARCUS
if(!d->sliced_object_list)
{
d->sliced_object_list = std::make_shared<cura::proto::SlicedObjectList>();
}
#endif
#ifdef ARCUS
auto& data = private_data->sliced_layers;
d->current_sliced_object = d->sliced_object_list->add_objects();
d->current_sliced_object->set_id(d->object_ids[d->sliced_objects]);
data.sliced_objects++;
data.current_layer_offset = data.current_layer_count;
// log("End sliced object called. Sending %d layers.", data.current_layer_count);
// Only send the data to the front end when all mesh groups have been processed.
if (data.sliced_objects >= private_data->object_count)
{
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;
data.current_layer_count = 0;
data.current_layer_offset = 0;
data.slice_data.clear();
}
#endif
}
void CommandSocket::endSendSlicedObject()
void CommandSocket::sendOptimizedLayerData()
{
#ifdef ARCUS
d->sliced_objects++;
d->current_layer_offset = d->current_layer_count;
std::cout << "End sliced object called. sliced objects " << d->sliced_objects << " object count: " << d->object_count << std::endl;
path_comp->flushPathSegments(); // make sure the last path segment has been flushed from the compiler
std::cout << "current layer count" << d->current_layer_count << std::endl;
std::cout << "current layer offset" << d->current_layer_offset << std::endl;
auto& data = private_data->optimized_layers;
if(d->sliced_objects >= d->object_count)
data.sliced_objects++;
data.current_layer_offset = data.current_layer_count;
log("End sliced object called. Sending %d layers.", data.current_layer_count);
if (data.sliced_objects >= private_data->object_count)
{
d->socket->sendMessage(d->sliced_object_list);
d->sliced_objects = 0;
d->current_layer_count = 0;
d->current_layer_offset = 0;
d->sliced_object_list.reset();
d->current_sliced_object = nullptr;
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;
data.current_layer_count = 0;
data.current_layer_offset = 0;
data.slice_data.clear();
}
#endif
}
void CommandSocket::sendFinishedSlicing()
{
#ifdef ARCUS
logDebug("Sending Slicing Finished message.\n");
std::shared_ptr<cura::proto::SlicingFinished> done_message = std::make_shared<cura::proto::SlicingFinished>();
private_data->socket->sendMessage(done_message);
logDebug("Done sending Slicing Finished message.\n");
#endif
}
void CommandSocket::beginGCode()
{
#ifdef ARCUS
FffProcessor::getInstance()->setTargetStream(&d->gcode_output_stream);
FffProcessor::getInstance()->setTargetStream(&private_data->gcode_output_stream);
#endif
}
void CommandSocket::sendGCodeLayer()
void CommandSocket::flushGcode()
{
#ifdef ARCUS
auto message = std::make_shared<cura::proto::GCodeLayer>();
message->set_id(d->object_ids[0]);
message->set_data(d->gcode_output_stream.str());
d->socket->sendMessage(message);
message->set_data(private_data->gcode_output_stream.str());
private_data->socket->sendMessage(message);
d->gcode_output_stream.str("");
private_data->gcode_output_stream.str("");
#endif
}
@@ -373,31 +712,118 @@ void CommandSocket::sendGCodePrefix(std::string prefix)
#ifdef ARCUS
auto message = std::make_shared<cura::proto::GCodePrefix>();
message->set_data(prefix);
d->socket->sendMessage(message);
private_data->socket->sendMessage(message);
#endif
}
#ifdef ARCUS
cura::proto::Layer* CommandSocket::Private::getLayerById(int id)
std::shared_ptr<cura::proto::Layer> CommandSocket::Private::getLayerById(int id)
{
id += current_layer_offset;
id += sliced_layers.current_layer_offset;
auto itr = std::find_if(current_sliced_object->mutable_layers()->begin(), current_sliced_object->mutable_layers()->end(), [id](cura::proto::Layer& l) { return l.id() == id; });
auto itr = sliced_layers.slice_data.find(id);
cura::proto::Layer* layer = nullptr;
if(itr != current_sliced_object->mutable_layers()->end())
std::shared_ptr<cura::proto::Layer> layer;
if (itr != sliced_layers.slice_data.end())
{
layer = &(*itr);
layer = itr->second;
}
else
{
layer = current_sliced_object->add_layers();
layer = std::make_shared<cura::proto::Layer>();
layer->set_id(id);
current_layer_count++;
sliced_layers.current_layer_count++;
sliced_layers.slice_data[id] = layer;
}
return layer;
}
#endif
#ifdef ARCUS
std::shared_ptr<cura::proto::LayerOptimized> CommandSocket::Private::getOptimizedLayerById(int id)
{
id += optimized_layers.current_layer_offset;
auto itr = optimized_layers.slice_data.find(id);
std::shared_ptr<cura::proto::LayerOptimized> layer;
if (itr != optimized_layers.slice_data.end())
{
layer = itr->second;
}
else
{
layer = std::make_shared<cura::proto::LayerOptimized>();
layer->set_id(id);
optimized_layers.current_layer_count++;
optimized_layers.slice_data[id] = layer;
}
return layer;
}
#endif
#ifdef ARCUS
void CommandSocket::PathCompiler::flushPathSegments()
{
if (line_types.size() > 0 && CommandSocket::isInstantiated())
{
std::shared_ptr<cura::proto::LayerOptimized> proto_layer = _cs_private_data.getOptimizedLayerById(_layer_nr);
cura::proto::PathSegment* p = proto_layer->add_path_segment();
p->set_extruder(extruder);
p->set_point_type(data_point_type);
std::string line_type_data;
line_type_data.append(reinterpret_cast<const char*>(line_types.data()), line_types.size()*sizeof(PrintFeatureType));
p->set_line_type(line_type_data);
std::string polydata;
polydata.append(reinterpret_cast<const char*>(points.data()), points.size() * sizeof(float));
p->set_points(polydata);
std::string line_width_data;
line_width_data.append(reinterpret_cast<const char*>(line_widths.data()), line_widths.size()*sizeof(float));
p->set_line_width(line_width_data);
}
points.clear();
line_widths.clear();
line_types.clear();
}
void CommandSocket::PathCompiler::sendLineTo(PrintFeatureType print_feature_type, Point to, int width)
{
assert(points.size() > 0 && "A point must already be in the buffer for sendLineTo(.) to function properly");
if (to != last_point)
{
addLineSegment(print_feature_type, to, width);
}
}
void CommandSocket::PathCompiler::sendPolygon(PrintFeatureType print_feature_type, ConstPolygonRef polygon, int width)
{
if (polygon.size() < 2)
{
return;
}
auto it = polygon.begin();
handleInitialPoint(*it);
const auto it_end = polygon.end();
while (++it != it_end)
{
// Ignore zero-length segments.
if (*it != last_point)
{
addLineSegment(print_feature_type, *it, width);
}
}
// Make sure the polygon is closed
if (*polygon.begin() != polygon.back())
{
addLineSegment(print_feature_type, *polygon.begin(), width);
}
}
#endif
}//namespace cura
+90 -22
Ver Arquivo
@@ -3,8 +3,9 @@
#include "utils/socket.h"
#include "utils/polygon.h"
#include "settings.h"
#include "Progress.h"
#include "settings/settings.h"
#include "progress/Progress.h"
#include "PrintFeature.h"
#include <memory>
@@ -17,8 +18,18 @@ namespace cura
class CommandSocket
{
private:
static CommandSocket* instance; //!< May be a nullptr in case it hasn't been instantiated.
CommandSocket(); //!< The single constructor is known only privately, since this class is similar to a singleton class (except the single object doesn't need to be instantiated)
public:
CommandSocket();
static CommandSocket* getInstance(); //!< Get the CommandSocket instance, or nullptr if it hasn't been instantiated.
static void instantiate(); //!< Instantiate the CommandSocket.
static bool isInstantiated(); //!< Check whether the singleton is instantiated
/*!
* Connect with the GUI
* This creates and initialises the arcus socket and then continues listening for messages.
@@ -31,26 +42,55 @@ public:
/*!
* Handler for ObjectList message.
* Loads all objects from the message and starts the slicing process
*
* Also handles meshgroup settings and extruder settings.
*
* \param[in] list The list of objects to slice
* \param[in] settings_per_extruder_train The extruder train settings to load into the meshgroup
*/
void handleObjectList(cura::proto::ObjectList* list);
/*!
* Handler for SettingList message.
* This simply sets all the settings by using key value pair
*/
void handleSettingList(cura::proto::SettingList* list);
void handleObjectList(cura::proto::ObjectList* list, const google::protobuf::RepeatedPtrField<cura::proto::Extruder> settings_per_extruder_train);
#endif
/*!
* Does nothing at the moment
* Send info on an optimized layer to be displayed by the forntend: set the z and the thickness of the layer.
*/
void sendLayerInfo(int layer_nr, int32_t z, int32_t height);
void sendOptimizedLayerInfo(int layer_nr, int32_t z, int32_t height);
/*!
* Send a polygon to the engine. This is used for the layerview in the GUI
* Send a polygon to the front-end. This is used for the layerview in the GUI
*/
void sendPolygons(cura::PolygonType type, int layer_nr, cura::Polygons& polygons, int line_width);
static void sendPolygons(cura::PrintFeatureType type, const cura::Polygons& polygons, int line_width);
/*!
* Send a polygon to the front-end. This is used for the layerview in the GUI
*/
static void sendPolygon(cura::PrintFeatureType type, ConstPolygonRef polygon, int line_width);
/*!
* Send a line to the front-end. This is used for the layerview in the GUI
*/
static void sendLineTo(cura::PrintFeatureType type, Point to, int line_width);
/*!
* Set the current position of the path compiler to \p position. This is used for the layerview in the GUI
*/
static void setSendCurrentPosition(Point position);
/*!
* Set which layer is being used for the following calls to SendPolygons, SendPolygon and SendLineTo.
*/
static void setLayerForSend(int layer_nr);
/*!
* Set which extruder is being used for the following calls to SendPolygons, SendPolygon and SendLineTo.
*/
static void setExtruderForSend(int extruder);
/*!
* Send a polygon to the front-end if the command socket is instantiated. This is used for the layerview in the GUI
*/
static void sendPolygonsToCommandSocket(cura::PrintFeatureType type, int layer_nr, const cura::Polygons& polygons, int line_width);
/*!
* Send progress to GUI
*/
@@ -64,24 +104,52 @@ public:
/*!
* Send time estimate of how long print would take.
*/
void sendPrintTime();
void sendPrintTimeMaterialEstimates();
/*!
* Does nothing at the moment
*/
void sendPrintMaterialForObject(int index, int extruder_nr, float material_amount);
/*!
* Send the slices of the model as polygons to the GUI.
*
* The GUI may use this to visualize the early result of the slicing
* process.
*/
void sendLayerData();
void beginSendSlicedObject();
void endSendSlicedObject();
/*!
* Send the sliced layer data to the GUI after the optimization is done and
* the actual order in which to print has been set.
*
* The GUI may use this to visualize the g-code, so that the user can
* inspect the result of slicing.
*/
void sendOptimizedLayerData();
/*!
* \brief Sends a message to indicate that all the slicing is done.
*
* This should indicate that no more data (g-code, prefix/postfix, metadata
* or otherwise) should be sent any more regarding the latest slice job.
*/
void sendFinishedSlicing();
void beginGCode();
void sendGCodeLayer();
/*!
* Flush the gcode in gcode_output_stream into a message queued in the socket.
*/
void flushGcode();
void sendGCodePrefix(std::string prefix);
#ifdef ARCUS
private:
class Private;
const std::unique_ptr<Private> d;
const std::unique_ptr<Private> private_data;
class PathCompiler;
const std::unique_ptr<PathCompiler> path_comp;
#endif
};
-61
Ver Arquivo
@@ -1,61 +0,0 @@
#ifndef DEBUG_H
#define DEBUG_H
#include <string.h>
#define __FILE_NAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define DEBUG_HERE std::cerr << __FILE_NAME__ << " : " << __LINE__ << std::endl
#define DEBUG 1
#define DEBUG_SHOW_LINE 1
#if DEBUG_SHOW_LINE == 1
#define DEBUG_FILE_LINE __FILE_NAME__ << "." << __LINE__ << ": "
#else
#define DEBUG_FILE_LINE ""
#endif
#if DEBUG == 1
# define DEBUG_DO(x) do { x } while (0)
# define DEBUG_SHOW(x) do { std::cerr << DEBUG_FILE_LINE << #x << " = " << x << std::endl; } while (0)
# define DEBUG_PRINTLN(x) do { std::cerr << DEBUG_FILE_LINE << x << std::endl; } while (0)
#else
# define DEBUG_DO(x)
# define DEBUG_SHOW(x)
# define DEBUG_PRINTLN(x)
#endif
#include <sstream>
#if 0==1
#define ENUM(name, ...) enum class name { __VA_ARGS__, __COUNT};
#endif
#define ENUM(name, ...) enum class name { __VA_ARGS__}; \
inline std::ostream& operator<<(std::ostream& os, name value) { \
std::string enumName = #name; \
std::string str = #__VA_ARGS__; \
int len = str.length(); \
std::vector<std::string> strings; \
std::ostringstream temp; \
for(int i = 0; i < len; i ++) { \
if(isspace(str[i])) continue; \
else if(str[i] == ',') { \
strings.push_back(temp.str()); \
temp.str(std::string());\
} \
else temp<< str[i]; \
} \
strings.push_back(temp.str()); \
os << enumName << "::" << strings[static_cast<int>(value)]; \
return os;}
#endif // DEBUG_H
+506 -176
Ver Arquivo
@@ -5,32 +5,207 @@
#include "gcodeExport.h"
#include "utils/logoutput.h"
#include "PrintFeature.h"
#include "utils/Date.h"
#include "utils/string.h" // MMtoStream, PrecisionedDouble
namespace cura {
double layer_height; //!< report basic layer height in RepRap gcode file.
GCodeExport::GCodeExport()
: output_stream(&std::cout)
, currentPosition(0,0,MM2INT(20))
, commandSocket(nullptr)
, layer_nr(0)
{
*output_stream << std::fixed;
current_e_value = 0;
current_extruder = 0;
currentFanSpeed = -1;
totalPrintTime = 0.0;
currentSpeed = 1;
current_acceleration = -1;
current_jerk = -1;
current_max_z_feedrate = -1;
isZHopped = 0;
setFlavor(EGCodeFlavor::REPRAP);
initial_bed_temp = 0;
extruder_count = 0;
total_bounding_box = AABB3D();
}
GCodeExport::~GCodeExport()
{
}
void GCodeExport::setCommandSocketAndLayerNr(CommandSocket* commandSocket_, unsigned int layer_nr_) {
commandSocket = commandSocket_;
void GCodeExport::preSetup(const MeshGroup* meshgroup)
{
setFlavor(meshgroup->getSettingAsGCodeFlavor("machine_gcode_flavor"));
use_extruder_offset_to_offset_coords = meshgroup->getSettingBoolean("machine_use_extruder_offset_to_offset_coords");
extruder_count = meshgroup->getSettingAsCount("machine_extruder_count");
for (const Mesh& mesh : meshgroup->meshes)
{
if (!mesh.getSettingBoolean("anti_overhang_mesh")
&& !mesh.getSettingBoolean("support_mesh")
)
{
extruder_attr[mesh.getSettingAsIndex("extruder_nr")].is_used = true;
}
}
for (unsigned int extruder_nr = 0; extruder_nr < extruder_count; extruder_nr++)
{
const ExtruderTrain* train = meshgroup->getExtruderTrain(extruder_nr);
if (meshgroup->getSettingAsIndex("adhesion_extruder_nr") == int(extruder_nr) && meshgroup->getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::NONE)
{
extruder_attr[extruder_nr].is_used = true;
}
for (const Mesh& mesh : meshgroup->meshes)
{
if ((mesh.getSettingBoolean("support_enable") && mesh.getSettingBoolean("support_interface_enable") && meshgroup->getSettingAsIndex("support_interface_extruder_nr") == int(extruder_nr))
|| (mesh.getSettingBoolean("support_enable") && meshgroup->getSettingAsIndex("support_infill_extruder_nr") == int(extruder_nr))
|| (mesh.getSettingBoolean("support_enable") && meshgroup->getSettingAsIndex("support_extruder_nr_layer_0") == int(extruder_nr))
)
{
extruder_attr[extruder_nr].is_used = true;
}
}
setFilamentDiameter(extruder_nr, train->getSettingInMicrons("material_diameter"));
extruder_attr[extruder_nr].prime_pos = Point3(train->getSettingInMicrons("extruder_prime_pos_x"), train->getSettingInMicrons("extruder_prime_pos_y"), train->getSettingInMicrons("extruder_prime_pos_z"));
extruder_attr[extruder_nr].prime_pos_is_abs = train->getSettingBoolean("extruder_prime_pos_abs");
extruder_attr[extruder_nr].nozzle_size = train->getSettingInMicrons("machine_nozzle_size");
extruder_attr[extruder_nr].nozzle_offset = Point(train->getSettingInMicrons("machine_nozzle_offset_x"), train->getSettingInMicrons("machine_nozzle_offset_y"));
extruder_attr[extruder_nr].material_guid = train->getSettingString("material_guid");
extruder_attr[extruder_nr].start_code = train->getSettingString("machine_extruder_start_code");
extruder_attr[extruder_nr].end_code = train->getSettingString("machine_extruder_end_code");
extruder_attr[extruder_nr].last_retraction_prime_speed = train->getSettingInMillimetersPerSecond("retraction_prime_speed"); // the alternative would be switch_extruder_prime_speed, but dual extrusion might not even be configured...
}
machine_dimensions.x = meshgroup->getSettingInMicrons("machine_width");
machine_dimensions.y = meshgroup->getSettingInMicrons("machine_depth");
machine_dimensions.z = meshgroup->getSettingInMicrons("machine_height");
machine_name = meshgroup->getSettingString("machine_name");
layer_height = meshgroup->getSettingInMillimeters("layer_height");
if (flavor == EGCodeFlavor::BFB)
{
new_line = "\r\n";
}
else
{
new_line = "\n";
}
estimateCalculator.setFirmwareDefaults(meshgroup);
}
void GCodeExport::setInitialTemps(const MeshGroup& settings, const unsigned int start_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 = (extr_nr == start_extruder_nr)? print_temp_here : train.getSettingInDegreeCelsius("material_standby_temperature");
setInitialTemp(extr_nr, temp);
}
initial_bed_temp = settings.getSettingInDegreeCelsius("material_bed_temperature_layer_0");
}
void GCodeExport::setInitialTemp(int extruder_nr, double temp)
{
extruder_attr[extruder_nr].initial_temp = temp;
if (flavor == EGCodeFlavor::GRIFFIN || flavor == EGCodeFlavor::ULTIGCODE)
{
extruder_attr[extruder_nr].currentTemperature = temp;
}
}
std::string GCodeExport::getFileHeader(const double* print_time, const std::vector<double>& filament_used, const std::vector<std::string>& mat_ids)
{
std::ostringstream prefix;
switch (flavor)
{
case EGCodeFlavor::GRIFFIN:
prefix << ";START_OF_HEADER" << new_line;
prefix << ";HEADER_VERSION:0.1" << new_line;
prefix << ";FLAVOR:" << toString(flavor) << new_line;
prefix << ";GENERATOR.NAME:Cura_SteamEngine" << new_line;
prefix << ";GENERATOR.VERSION:" << VERSION << new_line;
prefix << ";GENERATOR.BUILD_DATE:" << Date::getDate().toStringDashed() << new_line;
prefix << ";TARGET_MACHINE.NAME:" << machine_name << new_line;
for (unsigned int extr_nr = 0; extr_nr < extruder_count; extr_nr++)
{
if (!extruder_attr[extr_nr].is_used)
{
continue;
}
prefix << ";EXTRUDER_TRAIN." << extr_nr << ".INITIAL_TEMPERATURE:" << extruder_attr[extr_nr].initial_temp << new_line;
if (filament_used.size() == extruder_count)
{
prefix << ";EXTRUDER_TRAIN." << extr_nr << ".MATERIAL.VOLUME_USED:" << static_cast<int>(filament_used[extr_nr]) << new_line;
}
if (mat_ids.size() == extruder_count && mat_ids[extr_nr] != "")
{
prefix << ";EXTRUDER_TRAIN." << extr_nr << ".MATERIAL.GUID:" << mat_ids[extr_nr] << new_line;
}
prefix << ";EXTRUDER_TRAIN." << extr_nr << ".NOZZLE.DIAMETER:" << float(INT2MM(getNozzleSize(extr_nr))) << new_line;
}
prefix << ";BUILD_PLATE.INITIAL_TEMPERATURE:" << initial_bed_temp << new_line;
if (print_time)
{
prefix << ";PRINT.TIME:" << static_cast<int>(*print_time) << new_line;
}
prefix << ";PRINT.SIZE.MIN.X:" << INT2MM(total_bounding_box.min.x) << new_line;
prefix << ";PRINT.SIZE.MIN.Y:" << INT2MM(total_bounding_box.min.y) << new_line;
prefix << ";PRINT.SIZE.MIN.Z:" << INT2MM(total_bounding_box.min.z) << new_line;
prefix << ";PRINT.SIZE.MAX.X:" << INT2MM(total_bounding_box.max.x) << new_line;
prefix << ";PRINT.SIZE.MAX.Y:" << INT2MM(total_bounding_box.max.y) << new_line;
prefix << ";PRINT.SIZE.MAX.Z:" << INT2MM(total_bounding_box.max.z) << new_line;
prefix << ";END_OF_HEADER" << new_line;
return prefix.str();
default:
prefix << ";FLAVOR:" << toString(flavor) << new_line;
prefix << ";TIME:" << ((print_time)? static_cast<int>(*print_time) : 6666) << new_line;
if (flavor == EGCodeFlavor::ULTIGCODE)
{
prefix << ";MATERIAL:" << ((filament_used.size() >= 1)? static_cast<int>(filament_used[0]) : 6666) << new_line;
prefix << ";MATERIAL2:" << ((filament_used.size() >= 2)? static_cast<int>(filament_used[1]) : 0) << new_line;
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();
}
}
void GCodeExport::setLayerNr(unsigned int layer_nr_) {
layer_nr = layer_nr_;
}
@@ -40,12 +215,27 @@ void GCodeExport::setOutputStream(std::ostream* stream)
*output_stream << std::fixed;
}
Point GCodeExport::getExtruderOffset(int id)
bool GCodeExport::getExtruderIsUsed(const int extruder_nr) const
{
return extruder_attr[extruder_nr].is_used;
}
int GCodeExport::getNozzleSize(const int extruder_nr) const
{
return extruder_attr[extruder_nr].nozzle_size;
}
Point GCodeExport::getExtruderOffset(const int id) const
{
return extruder_attr[id].nozzle_offset;
}
Point GCodeExport::getGcodePos(int64_t x, int64_t y, int extruder_train)
std::string GCodeExport::getMaterialGUID(const int extruder_nr) const
{
return extruder_attr[extruder_nr].material_guid;
}
Point GCodeExport::getGcodePos(const int64_t x, const int64_t y, const int extruder_train) const
{
if (use_extruder_offset_to_offset_coords) { return Point(x,y) - getExtruderOffset(extruder_train); }
else { return Point(x,y); }
@@ -80,14 +270,14 @@ void GCodeExport::setFlavor(EGCodeFlavor flavor)
}
}
EGCodeFlavor GCodeExport::getFlavor()
EGCodeFlavor GCodeExport::getFlavor() const
{
return this->flavor;
}
void GCodeExport::setZ(int z)
{
this->zPos = z;
this->current_layer_z = z;
}
Point3 GCodeExport::getPosition()
@@ -134,12 +324,48 @@ double GCodeExport::getCurrentExtrudedVolume()
}
}
double GCodeExport::getTotalFilamentUsed(int e)
double GCodeExport::eToMm(double e)
{
if (e == current_extruder)
return extruder_attr[e].totalFilament + getCurrentExtrudedVolume();
return extruder_attr[e].totalFilament;
if (is_volumatric)
{
return e / extruder_attr[current_extruder].filament_area;
}
else
{
return e;
}
}
double GCodeExport::mm3ToE(double mm3)
{
if (is_volumatric)
{
return mm3;
}
else
{
return mm3 / extruder_attr[current_extruder].filament_area;
}
}
double GCodeExport::mmToE(double mm)
{
if (is_volumatric)
{
return mm * extruder_attr[current_extruder].filament_area;
}
else
{
return mm;
}
}
double GCodeExport::getTotalFilamentUsed(int extruder_nr)
{
if (extruder_nr == current_extruder)
return extruder_attr[extruder_nr].totalFilament + getCurrentExtrudedVolume();
return extruder_attr[extruder_nr].totalFilament;
}
double GCodeExport::getTotalPrintTime()
@@ -163,6 +389,7 @@ void GCodeExport::updateTotalPrintTime()
{
totalPrintTime += estimateCalculator.calculate();
estimateCalculator.reset();
writeTimeComment(totalPrintTime);
}
void GCodeExport::writeComment(std::string comment)
@@ -177,33 +404,68 @@ void GCodeExport::writeComment(std::string comment)
*output_stream << comment[i];
}
}
*output_stream << "\n";
*output_stream << new_line;
}
void GCodeExport::writeTypeComment(const char* type)
void GCodeExport::writeTimeComment(const double time)
{
*output_stream << ";TYPE:" << type << "\n";
*output_stream << ";TIME_ELAPSED:" << time << new_line;
}
void GCodeExport::writeTypeComment(PrintFeatureType type)
{
switch (type)
{
case PrintFeatureType::OuterWall:
*output_stream << ";TYPE:WALL-OUTER" << new_line;
break;
case PrintFeatureType::InnerWall:
*output_stream << ";TYPE:WALL-INNER" << new_line;
break;
case PrintFeatureType::Skin:
*output_stream << ";TYPE:SKIN" << new_line;
break;
case PrintFeatureType::Support:
*output_stream << ";TYPE:SUPPORT" << new_line;
break;
case PrintFeatureType::SkirtBrim:
*output_stream << ";TYPE:SKIRT" << new_line;
break;
case PrintFeatureType::Infill:
*output_stream << ";TYPE:FILL" << new_line;
break;
case PrintFeatureType::SupportInfill:
*output_stream << ";TYPE:SUPPORT" << new_line;
break;
case PrintFeatureType::MoveCombing:
case PrintFeatureType::MoveRetraction:
default:
// do nothing
break;
}
}
void GCodeExport::writeLayerComment(int layer_nr)
{
*output_stream << ";LAYER:" << layer_nr << "\n";
*output_stream << ";LAYER:" << layer_nr << new_line;
}
void GCodeExport::writeLayerCountComment(int layer_count)
{
*output_stream << ";LAYER_COUNT:" << layer_count << "\n";
*output_stream << ";LAYER_COUNT:" << layer_count << new_line;
}
void GCodeExport::writeLine(const char* line)
{
*output_stream << line << "\n";
*output_stream << line << new_line;
}
void GCodeExport::resetExtrusionValue()
{
if (current_e_value != 0.0 && flavor != EGCodeFlavor::MAKERBOT && flavor != EGCodeFlavor::BFB)
if (flavor != EGCodeFlavor::MAKERBOT && flavor != EGCodeFlavor::BFB)
{
*output_stream << "G92 " << extruder_attr[current_extruder].extruderCharacter << "0\n";
*output_stream << "G92 " << extruder_attr[current_extruder].extruderCharacter << "0" << new_line;
double current_extruded_volume = getCurrentExtrudedVolume();
extruder_attr[current_extruder].totalFilament += current_extruded_volume;
for (double& extruded_volume_at_retraction : extruder_attr[current_extruder].extruded_volume_at_previous_n_retractions)
@@ -217,13 +479,13 @@ void GCodeExport::resetExtrusionValue()
void GCodeExport::writeDelay(double timeAmount)
{
*output_stream << "G4 P" << int(timeAmount * 1000) << "\n";
*output_stream << "G4 P" << int(timeAmount * 1000) << new_line;
estimateCalculator.addTime(timeAmount);
}
void GCodeExport::writeMove(Point p, double speed, double extrusion_mm3_per_mm)
{
writeMove(p.X, p.Y, zPos, speed, extrusion_mm3_per_mm);
writeMove(p.X, p.Y, current_layer_z, speed, extrusion_mm3_per_mm);
}
void GCodeExport::writeMove(Point3 p, double speed, double extrusion_mm3_per_mm)
@@ -233,11 +495,7 @@ void GCodeExport::writeMove(Point3 p, double speed, double extrusion_mm3_per_mm)
void GCodeExport::writeMoveBFB(int x, int y, int z, double speed, double extrusion_mm3_per_mm)
{
double extrusion_per_mm = extrusion_mm3_per_mm;
if (!is_volumatric)
{
extrusion_per_mm = extrusion_mm3_per_mm / extruder_attr[current_extruder].filament_area;
}
double extrusion_per_mm = mm3ToE(extrusion_mm3_per_mm);
Point gcode_pos = getGcodePos(x,y, current_extruder);
@@ -254,11 +512,11 @@ void GCodeExport::writeMoveBFB(int x, int y, int z, double speed, double extrusi
{
//fprintf(f, "; %f e-per-mm %d mm-width %d mm/s\n", extrusion_per_mm, lineWidth, speed);
//fprintf(f, "M108 S%0.1f\r\n", rpm);
*output_stream << "M108 S" << std::setprecision(1) << rpm << "\r\n";
*output_stream << "M108 S" << PrecisionedDouble{1, rpm} << new_line;
currentSpeed = double(rpm);
}
//Add M101 or M201 to enable the proper extruder.
*output_stream << "M" << int((current_extruder + 1) * 100 + 1) << "\r\n";
*output_stream << "M" << int((current_extruder + 1) * 100 + 1) << new_line;
extruder_attr[current_extruder].retraction_e_amount_current = 0.0;
}
//Fix the speed by the actual RPM we are asking, because of rounding errors we cannot get all RPM values, but we have a lot more resolution in the feedrate value.
@@ -275,17 +533,15 @@ void GCodeExport::writeMoveBFB(int x, int y, int z, double speed, double extrusi
//If we are not extruding, check if we still need to disable the extruder. This causes a retraction due to auto-retraction.
if (!extruder_attr[current_extruder].retraction_e_amount_current)
{
*output_stream << "M103\r\n";
*output_stream << "M103" << new_line;
extruder_attr[current_extruder].retraction_e_amount_current = 1.0; // 1.0 used as stub; BFB doesn't use the actual retraction amount; it performs retraction on the firmware automatically
}
}
*output_stream << std::setprecision(3) <<
"G1 X" << INT2MM(gcode_pos.X) <<
" Y" << INT2MM(gcode_pos.Y) <<
" Z" << INT2MM(z) << std::setprecision(1) << " F" << fspeed << "\r\n";
*output_stream << "G1 X" << MMtoStream{gcode_pos.X} << " Y" << MMtoStream{gcode_pos.Y} << " Z" << MMtoStream{z};
*output_stream << " F" << PrecisionedDouble{1, fspeed} << new_line;
currentPosition = Point3(x, y, z);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), speed);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), speed);
}
void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_mm3_per_mm)
@@ -294,8 +550,9 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
return;
#ifdef ASSERT_INSANE_OUTPUT
assert(speed < 200 && speed > 1); // normal F values occurring in UM2 gcode (this code should not be compiled for release)
assert(speed < 400 && speed > 1); // normal F values occurring in UM2 gcode (this code should not be compiled for release)
assert(currentPosition != no_point3);
assert(Point3(x, y, z) != no_point3);
assert((Point3(x,y,z) - currentPosition).vSize() < MM2INT(300)); // no crazy positions (this code should not be compiled for release)
#endif //ASSERT_INSANE_OUTPUT
@@ -308,43 +565,40 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
return;
}
double extrusion_per_mm = extrusion_mm3_per_mm;
if (!is_volumatric)
{
extrusion_per_mm = extrusion_mm3_per_mm / extruder_attr[current_extruder].filament_area;
}
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)
{
Point3 diff = Point3(x,y,z) - getPosition();
if (isZHopped > 0)
{
*output_stream << std::setprecision(3) << "G1 Z" << INT2MM(currentPosition.z) << "\n";
*output_stream << "G1 Z" << MMtoStream{currentPosition.z} << new_line;
isZHopped = 0;
}
double prime_volume = extruder_attr[current_extruder].prime_volume;
current_e_value += (is_volumatric) ? prime_volume : prime_volume / extruder_attr[current_extruder].filament_area;
current_e_value += mm3ToE(prime_volume);
if (extruder_attr[current_extruder].retraction_e_amount_current)
{
if (firmware_retract)
{ // note that BFB is handled differently
*output_stream << "G11\n";
*output_stream << "G11" << new_line;
//Assume default UM2 retraction settings.
if (prime_volume > 0)
{
*output_stream << "G1 F" << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << "\n";
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
}
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), 25.0);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), 25.0);
}
else
{
current_e_value += extruder_attr[current_extruder].retraction_e_amount_current;
*output_stream << "G1 F" << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << "\n";
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), currentSpeed);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
}
if (getCurrentExtrudedVolume() > 10000.0) //According to https://github.com/Ultimaker/CuraEngine/issues/14 having more then 21m of extrusion causes inaccuracies. So reset it every 10m, just to be sure.
{
@@ -354,10 +608,9 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
}
else if (prime_volume > 0.0)
{
current_e_value += prime_volume;
*output_stream << "G1 F" << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << "\n";
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), currentSpeed);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
}
extruder_attr[current_extruder].prime_volume = 0.0;
current_e_value += extrusion_per_mm * diff.vSizeMM();
@@ -366,186 +619,204 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
else
{
*output_stream << "G0";
if (commandSocket)
{
// we should send this travel as a non-retraction move
cura::Polygons travelPoly;
PolygonRef travel = travelPoly.newPoly();
travel.add(Point(currentPosition.x, currentPosition.y));
travel.add(Point(x, y));
commandSocket->sendPolygons(extruder_attr[current_extruder].retraction_e_amount_current ? MoveRetractionType : MoveCombingType, layer_nr, travelPoly, extruder_attr[current_extruder].retraction_e_amount_current ? MM2INT(0.2) : MM2INT(0.1));
}
CommandSocket::sendLineTo(extruder_attr[current_extruder].retraction_e_amount_current ? PrintFeatureType::MoveRetraction : PrintFeatureType::MoveCombing, Point(x, y), extruder_attr[current_extruder].retraction_e_amount_current ? MM2INT(0.2) : MM2INT(0.1));
}
if (currentSpeed != speed)
{
*output_stream << " F" << (speed * 60);
*output_stream << " F" << PrecisionedDouble{1, speed * 60};
currentSpeed = speed;
}
*output_stream << std::setprecision(3) <<
" X" << INT2MM(gcode_pos.X) <<
" Y" << INT2MM(gcode_pos.Y);
*output_stream << " X" << MMtoStream{gcode_pos.X} << " Y" << MMtoStream{gcode_pos.Y};
if (z != currentPosition.z + isZHopped)
*output_stream << " Z" << INT2MM(z + isZHopped);
{
*output_stream << " Z" << MMtoStream{z + isZHopped};
}
if (extrusion_mm3_per_mm > 0.000001)
*output_stream << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value;
*output_stream << "\n";
*output_stream << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value};
*output_stream << new_line;
currentPosition = Point3(x, y, z);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), speed);
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)
void GCodeExport::writeRetraction(const RetractionConfig& config, bool force, bool extruder_switch)
{
ExtruderTrainAttributes& extr_attr = extruder_attr[current_extruder];
if (flavor == EGCodeFlavor::BFB)//BitsFromBytes does automatic retraction.
{
if (extruder_switch)
{
if (!extr_attr.retraction_e_amount_current)
*output_stream << "M103" << new_line;
extr_attr.retraction_e_amount_current = 1.0; // 1.0 is a stub; BFB doesn't use the actual retracted amount; retraction is performed by firmware
}
return;
}
if (extruder_attr[current_extruder].retraction_e_amount_current == config->distance * ((is_volumatric)? extruder_attr[current_extruder].filament_area : 1.0))
{
return;
}
if (config->distance <= 0)
double old_retraction_e_amount = extr_attr.retraction_e_amount_current;
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)
{
return;
}
{ // handle retraction limitation
double current_extruded_volume = getCurrentExtrudedVolume();
std::deque<double>& extruded_volume_at_previous_n_retractions = extruder_attr[current_extruder].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())
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())
{
// 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 - 1
&& current_extruded_volume < extruded_volume_at_previous_n_retractions.back() + config->retraction_extrusion_window * extruder_attr[current_extruder].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)
if (int(extruded_volume_at_previous_n_retractions.size()) == config.retraction_count_max + 1)
{
extruded_volume_at_previous_n_retractions.pop_back();
}
}
extruder_attr[current_extruder].last_retraction_prime_speed = config->primeSpeed;
double retraction_e_amount = config->distance * ((is_volumatric)? extruder_attr[current_extruder].filament_area : 1.0);
if (firmware_retract)
{
*output_stream << "G10\n";
//Assume default UM2 retraction settings.
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value - retraction_e_amount), 25); // TODO: hardcoded values!
}
else
{
current_e_value -= retraction_e_amount;
*output_stream << "G1 F" << (config->speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << "\n";
currentSpeed = config->speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), current_e_value), currentSpeed);
}
extruder_attr[current_extruder].retraction_e_amount_current = retraction_e_amount ;
extruder_attr[current_extruder].prime_volume += config->prime_volume;
if (config->zHop > 0)
{
isZHopped = config->zHop;
*output_stream << std::setprecision(3) << "G1 Z" << INT2MM(currentPosition.z + isZHopped) << "\n";
}
}
void GCodeExport::writeRetraction_extruderSwitch()
{
if (flavor == EGCodeFlavor::BFB)
{
if (!extruder_attr[current_extruder].retraction_e_amount_current)
*output_stream << "M103\r\n";
extruder_attr[current_extruder].retraction_e_amount_current = 1.0; // 1.0 is a stub; BFB doesn't use the actual retracted amount; retraction is performed by firmware
return;
}
double retraction_e_amount = extruder_attr[current_extruder].extruder_switch_retraction_distance * ((is_volumatric)? extruder_attr[current_extruder].filament_area : 1.0);
if (extruder_attr[current_extruder].retraction_e_amount_current == retraction_e_amount)
{
return;
}
double current_extruded_volume = getCurrentExtrudedVolume();
std::deque<double>& extruded_volume_at_previous_n_retractions = extruder_attr[current_extruder].extruded_volume_at_previous_n_retractions;
extruded_volume_at_previous_n_retractions.push_front(current_extruded_volume);
if (firmware_retract)
{
if (extruder_attr[current_extruder].retraction_e_amount_current)
if (extruder_switch && extr_attr.retraction_e_amount_current)
{
return;
}
*output_stream << "G10 S1\n";
*output_stream << "G10";
if (extruder_switch)
{
*output_stream << " S1";
}
*output_stream << new_line;
//Assume default UM2 retraction settings.
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value + retraction_diff_e_amount)), 25); // TODO: hardcoded values!
}
else
{
current_e_value -= retraction_e_amount;
*output_stream << "G1 F" << (extruder_attr[current_extruder].extruderSwitchRetractionSpeed * 60) << " "
<< extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << "\n";
// the E value of the extruder switch retraction 'overwrites' the E value of the normal retraction
currentSpeed = extruder_attr[current_extruder].extruderSwitchRetractionSpeed;
extruder_attr[current_extruder].last_retraction_prime_speed = extruder_attr[current_extruder].extruderSwitchPrimeSpeed;
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;
}
extruder_attr[current_extruder].retraction_e_amount_current = retraction_e_amount; // suppose that for UM2 the retraction amount in the firmware is equal to the provided amount
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;
}
void GCodeExport::switchExtruder(int new_extruder)
void GCodeExport::writeZhopStart(int hop_height)
{
if (current_extruder == new_extruder)
return;
if (hop_height > 0)
{
isZHopped = hop_height;
*output_stream << "G1 Z" << MMtoStream{currentPosition.z + isZHopped} << new_line;
total_bounding_box.includeZ(currentPosition.z + isZHopped);
}
}
writeRetraction_extruderSwitch();
void GCodeExport::writeZhopEnd()
{
if (isZHopped)
{
isZHopped = 0;
*output_stream << "G1 Z" << MMtoStream{currentPosition.z} << new_line;
}
}
resetExtrusionValue(); // should be called on the old extruder
void GCodeExport::startExtruder(int new_extruder)
{
if (new_extruder != current_extruder) // wouldn't be the case on the very first extruder start if it's extruder 0
{
if (flavor == EGCodeFlavor::MAKERBOT)
{
*output_stream << "M135 T" << new_extruder << new_line;
}
else
{
*output_stream << "T" << new_extruder << new_line;
}
}
int old_extruder = current_extruder;
current_extruder = new_extruder;
if (flavor == EGCodeFlavor::MACH3)
{
resetExtrusionValue(); // also zero the E value on the new extruder
}
writeCode(extruder_attr[old_extruder].end_code.c_str());
if (flavor == EGCodeFlavor::MAKERBOT)
{
*output_stream << "M135 T" << current_extruder << "\n";
}
else
{
*output_stream << "T" << current_extruder << "\n";
}
assert(getCurrentExtrudedVolume() == 0.0 && "Just after an extruder switch we haven't extruded anything yet!");
resetExtrusionValue(); // zero the E value on the new extruder, just to be sure
writeCode(extruder_attr[new_extruder].start_code.c_str());
CommandSocket::setExtruderForSend(new_extruder);
CommandSocket::setSendCurrentPosition( getPositionXY() );
//Change the Z position so it gets re-writting again. We do not know if the switch code modified the Z position.
currentPosition.z += 1;
}
void GCodeExport::switchExtruder(int new_extruder, const RetractionConfig& retraction_config_old_extruder)
{
if (current_extruder == new_extruder)
return;
bool force = true;
bool extruder_switch = true;
writeRetraction(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
int old_extruder = current_extruder;
writeCode(extruder_attr[old_extruder].end_code.c_str());
startExtruder(new_extruder);
}
void GCodeExport::writeCode(const char* str)
{
*output_stream << str;
if (flavor == EGCodeFlavor::BFB)
*output_stream << "\r\n";
else
*output_stream << "\n";
*output_stream << str << new_line;
}
void GCodeExport::writePrimeTrain(double travel_speed)
{
if (extruder_attr[current_extruder].is_primed)
{ // extruder is already primed once!
return;
}
Point3 prime_pos = extruder_attr[current_extruder].prime_pos;
if (!extruder_attr[current_extruder].prime_pos_is_abs)
{
prime_pos += currentPosition;
}
writeMove(prime_pos, travel_speed, 0.0);
if (flavor == EGCodeFlavor::GRIFFIN)
{
*output_stream << "G280" << new_line;
}
else
{
// there is no prime gcode for other firmware versions...
}
extruder_attr[current_extruder].is_primed = true;
}
void GCodeExport::writeFanCommand(double speed)
{
if (currentFanSpeed == speed)
@@ -553,16 +824,16 @@ void GCodeExport::writeFanCommand(double speed)
if (speed > 0)
{
if (flavor == EGCodeFlavor::MAKERBOT)
*output_stream << "M126 T0\n"; //value = speed * 255 / 100 // Makerbot cannot set fan speed...;
*output_stream << "M126 T0" << new_line; //value = speed * 255 / 100 // Makerbot cannot set fan speed...;
else
*output_stream << "M106 S" << (speed * 255 / 100) << "\n";
*output_stream << "M106 S" << PrecisionedDouble{1, speed * 255 / 100} << new_line;
}
else
{
if (flavor == EGCodeFlavor::MAKERBOT)
*output_stream << "M127 T0\n";
*output_stream << "M127 T0" << new_line;
else
*output_stream << "M107\n";
*output_stream << "M107" << new_line;
}
currentFanSpeed = speed;
}
@@ -571,32 +842,91 @@ void GCodeExport::writeTemperatureCommand(int extruder, double temperature, bool
{
if (!wait && extruder_attr[extruder].currentTemperature == temperature)
return;
if (flavor == EGCodeFlavor::ULTIGCODE)
{ // The UM2 family doesn't support temperature commands (they are fixed in the firmware)
return;
}
if (wait)
*output_stream << "M109";
else
*output_stream << "M104";
if (extruder != current_extruder)
*output_stream << " T" << extruder;
*output_stream << " S" << temperature << "\n";
#ifdef ASSERT_INSANE_OUTPUT
assert(temperature >= 0);
#endif // ASSERT_INSANE_OUTPUT
*output_stream << " S" << PrecisionedDouble{1, temperature} << new_line;
extruder_attr[extruder].currentTemperature = temperature;
}
void GCodeExport::writeBedTemperatureCommand(double temperature, bool wait)
{
if (flavor == EGCodeFlavor::ULTIGCODE)
{ // The UM2 family doesn't support temperature commands (they are fixed in the firmware)
return;
}
if (wait)
*output_stream << "M190 S";
else
*output_stream << "M140 S";
*output_stream << temperature << "\n";
*output_stream << PrecisionedDouble{1, temperature} << new_line;
}
void GCodeExport::finalize(double moveSpeed, const char* endCode)
void GCodeExport::writeAcceleration(double acceleration)
{
if (current_acceleration != acceleration)
{
*output_stream << "M204 S" << PrecisionedDouble{0, acceleration} << new_line; // Print and Travel acceleration
current_acceleration = acceleration;
estimateCalculator.setAcceleration(acceleration);
}
}
void GCodeExport::writeJerk(double jerk)
{
if (current_jerk != jerk)
{
if (getFlavor() == EGCodeFlavor::REPETIER)
{
*output_stream << "M207 X";
}
else
{
*output_stream << "M205 X";
}
*output_stream << PrecisionedDouble{2, jerk} << new_line;
current_jerk = jerk;
estimateCalculator.setMaxXyJerk(jerk);
}
}
void GCodeExport::writeMaxZFeedrate(double max_z_feedrate)
{
if (current_max_z_feedrate != max_z_feedrate)
{
*output_stream << "M203 Z" << PrecisionedDouble{2, max_z_feedrate} << new_line;
current_max_z_feedrate = max_z_feedrate;
estimateCalculator.setMaxZFeedrate(max_z_feedrate);
}
}
double GCodeExport::getCurrentMaxZFeedrate()
{
return current_max_z_feedrate;
}
void GCodeExport::finalize(const char* endCode)
{
writeFanCommand(0);
writeCode(endCode);
log("Print time: %d\n", int(getTotalPrintTime()));
log("Filament: %d\n", int(getTotalFilamentUsed(0)));
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);
log("Filament: %d\n", mat_0);
for(int n=1; n<MAX_EXTRUDERS; n++)
if (getTotalFilamentUsed(n) > 0)
log("Filament%d: %d\n", n + 1, int(getTotalFilamentUsed(n)));
+241 -165
Ver Arquivo
@@ -6,126 +6,30 @@
#include <deque> // for extrusionAmountAtPreviousRetractions
#include <sstream> // for stream.str()
#include "settings.h"
#include "settings/settings.h"
#include "utils/intpoint.h"
#include "utils/NoCopy.h"
#include "timeEstimate.h"
#include "MeshGroup.h"
#include "commandSocket.h"
#include "RetractionConfig.h"
namespace cura {
/*!
* Coasting configuration used during printing.
* Can differ per extruder.
*
* Might be used in the future to have different coasting per feature, e.g. outer wall only.
*/
struct CoastingConfig
{
bool coasting_enable;
double coasting_volume_move;
double coasting_speed_move;
double coasting_min_volume_move;
double coasting_volume_retract;
double coasting_speed_retract;
double coasting_min_volume_retract;
};
class RetractionConfig
{
public:
double distance; //!< The distance retracted (in mm)
double speed; //!< The speed with which to retract (in mm/s)
double primeSpeed; //!< the speed with which to unretract (in mm/s)
double prime_volume; //!< the amount of material primed after unretracting (in mm^3)
int zHop; //!< the amount with which to lift the head during a retraction-travel
int retraction_min_travel_distance; //!<
double retraction_extrusion_window; //!< in mm
int retraction_count_max;
bool coasting_enable; //!< Whether coasting is enabled on the extruder to which this config is attached
double coasting_volume; //!< The volume leeked when printing without feeding
double coasting_speed; //!< A modifier (0-1) on the last used travel speed to move slower during coasting
double coasting_min_volume; //!< The minimal volume printed to build up enough pressure to leek the coasting_volume
};
//The GCodePathConfig is the configuration for moves/extrusion actions. This defines at which width the line is printed and at which speed.
class GCodePathConfig
{
private:
double speed_base; //!< movement speed (mm/s) specific to this print feature
double speed_current; //!< current movement speed (mm/s) (modified by layer_nr etc.)
int line_width; //!< width of the line extruded
double flow; //!< extrusion flow in %
int layer_thickness; //!< layer height
double extrusion_mm3_per_mm;//!< mm^3 filament moved per mm line extruded
public:
const char* name; //!< name of the feature type
bool spiralize;
RetractionConfig *const retraction_config;
// GCodePathConfig() : speed(0), line_width(0), extrusion_mm3_per_mm(0.0), name(nullptr), spiralize(false), retraction_config(nullptr) {}
GCodePathConfig(RetractionConfig* retraction_config, const char* name) : speed_base(0), speed_current(0), line_width(0), extrusion_mm3_per_mm(0.0), name(name), spiralize(false), retraction_config(retraction_config) {}
/*!
* Initialize some of the member variables.
*
* Warning! setLayerHeight still has to be called before this object can be used.
*/
void init(double speed, int line_width, double flow)
{
speed_base = speed;
this->speed_current = speed;
this->line_width = line_width;
this->flow = flow;
}
/*!
* Set the layer height and (re)compute the extrusion_per_mm
*/
void setLayerHeight(int layer_height)
{
this->layer_thickness = layer_height;
calculateExtrusion();
}
/*!
* Set the speed to somewhere between the @p min_speed and the speed_iconic.
*
* This functions should not be called with @p layer_nr > @p max_speed_layer !
*
* \param min_speed The speed at layer zero
* \param layer_nr The layer number
* \param max_speed_layer The layer number for which the speed_iconic should be used.
*/
void smoothSpeed(double min_speed, int layer_nr, double max_speed_layer)
{
speed_current = (speed_base*layer_nr)/max_speed_layer + (min_speed*(max_speed_layer-layer_nr)/max_speed_layer);
}
/*!
* Can only be called after the layer height has been set (which is done while writing the gcode!)
*/
double getExtrusionMM3perMM()
{
return extrusion_mm3_per_mm;
}
/*!
* Get the movement speed in mm/s
*/
double getSpeed()
{
return speed_current;
}
int getLineWidth()
{
return line_width;
}
bool isTravelPath()
{
return line_width == 0;
}
private:
void calculateExtrusion()
{
extrusion_mm3_per_mm = INT2MM(line_width) * INT2MM(layer_thickness) * double(flow) / 100.0;
}
};
//The GCodeExport class writes the actual GCode. This is the only class that knows how GCode looks and feels.
// Any customizations on GCodes flavors are done in this class.
@@ -134,18 +38,23 @@ class GCodeExport : public NoCopy
private:
struct ExtruderTrainAttributes
{
Point3 prime_pos; //!< The location this nozzle is primed before printing
bool prime_pos_is_abs; //!< Whether the prime position is absolute, rather than relative to the last given position
bool is_primed; //!< Whether this extruder has currently already been primed in this print
bool is_used; //!< Whether this extruder train is actually used during the printing of all meshgroups
int nozzle_size; //!< The nozzle size label of the nozzle (e.g. 0.4mm; irrespective of tolerances)
Point nozzle_offset;
char extruderCharacter;
std::string material_guid; //!< The GUID for the material used by this extruder
std::string start_code;
std::string end_code;
double filament_area; //!< in mm^2 for non-volumetric, cylindrical filament
double extruder_switch_retraction_distance; //<! extruder switch retraction distance in mm
int extruderSwitchRetractionSpeed; //!< extruder switch retraction speed in mm/s
int extruderSwitchPrimeSpeed; //!< prime speed of extruder switch in mm/s
double totalFilament; //!< total filament used per extruder in mm^3
int currentTemperature;
int initial_temp; //!< Temperature this nozzle needs to be at the start of the print.
double retraction_e_amount_current; //!< The current retracted amount (in mm or mm^3), or zero(i.e. false) if it is not currently retracted (positive values mean retracted amount, so negative impact on E values)
double retraction_e_amount_at_e_start; //!< The ExtruderTrainAttributes::retraction_amount_current value at E0, i.e. the offset (in mm or mm^3) from E0 to the situation where the filament is at the tip of the nozzle.
@@ -156,60 +65,130 @@ private:
std::deque<double> extruded_volume_at_previous_n_retractions; // in mm^3
ExtruderTrainAttributes()
: nozzle_offset(0,0)
: prime_pos(0, 0, 0)
, prime_pos_is_abs(false)
, is_primed(false)
, is_used(false)
, nozzle_offset(0,0)
, extruderCharacter(0)
, start_code("")
, end_code("")
, filament_area(0)
, extruder_switch_retraction_distance(0.0)
, extruderSwitchRetractionSpeed(0)
, extruderSwitchPrimeSpeed(0)
, totalFilament(0)
, currentTemperature(0)
, initial_temp(0)
, retraction_e_amount_current(0.0)
, retraction_e_amount_at_e_start(0.0)
, prime_volume(0.0)
, last_retraction_prime_speed(1.0)
, last_retraction_prime_speed(0.0)
{ }
};
ExtruderTrainAttributes extruder_attr[MAX_EXTRUDERS];
unsigned int extruder_count;
bool use_extruder_offset_to_offset_coords;
Point3 machine_dimensions;
std::string machine_name;
std::ostream* output_stream;
std::string new_line;
double current_e_value; //!< The last E value written to gcode (in mm or mm^3)
Point3 currentPosition;
double currentSpeed; //!< The current speed (F values / 60) in mm/s
int zPos; // TODO: why is this different from currentPosition.z ? zPos is set every layer, while currentPosition.z is set every move. However, the z position is generally not changed within a layer!
double current_acceleration; //!< The current acceleration in the XY direction (in mm/s^2)
double current_jerk; //!< The current jerk in the XY direction (in mm/s^3)
double current_max_z_feedrate; //!< The current max z speed
AABB3D total_bounding_box; //!< The bounding box of all g-code.
/*!
* The z position to be used on the next xy move, if the head wasn't in the correct z position yet.
*
* \see GCodeExport::writeMove(Point, double, double)
*
* \note After GCodeExport::writeMove(Point, double, double) has been called currentPosition.z coincides with this value
*/
int current_layer_z;
int isZHopped; //!< The amount by which the print head is currently z hopped, or zero if it is not z hopped. (A z hop is used during travel moves to avoid collision with other layer parts)
int current_extruder;
int currentFanSpeed;
EGCodeFlavor flavor;
double totalPrintTime;
double totalPrintTime; //!< The total estimated print time in seconds
TimeEstimateCalculator estimateCalculator;
bool is_volumatric;
bool firmware_retract; //!< whether retractions are done in the firmware, or hardcoded in E values.
CommandSocket* commandSocket; //!< for sending travel data
unsigned int layer_nr; //!< for sending travel data
int initial_bed_temp; //!< bed temperature at the beginning of the print.
protected:
/*!
* Convert an E value to a value in mm (if it wasn't already in mm) for the current extruder.
*
* E values are either in mm or in mm^3
* The current extruder is used to determine the filament area to make the conversion.
*
* \param e the value to convert
* \return the value converted to mm
*/
double eToMm(double e);
/*!
* Convert a volume value to an E value (which might be volumetric as well) for the current extruder.
*
* E values are either in mm or in mm^3
* The current extruder is used to determine the filament area to make the conversion.
*
* \param mm3 the value to convert
* \return the value converted to mm or mm3 depending on whether the E axis is volumetric
*/
double mm3ToE(double mm3);
/*!
* Convert a distance value to an E value (which might be linear/distance based as well) for the current extruder.
*
* E values are either in mm or in mm^3
* The current extruder is used to determine the filament area to make the conversion.
*
* \param mm the value to convert
* \return the value converted to mm or mm3 depending on whether the E axis is volumetric
*/
double mmToE(double mm);
public:
GCodeExport();
~GCodeExport();
void setCommandSocketAndLayerNr(CommandSocket* commandSocket, unsigned int layer_nr);
/*!
* Get the gcode file header (e.g. ";FLAVOR:UltiGCode\n")
*
* \param print_time The total print time in seconds of the whole gcode (if known)
* \param filament_used The total mm^3 filament used for each extruder or a vector of the wrong size of unknown
* \param mat_ids The material GUIDs for each material.
* \return The string representing the file header
*/
std::string getFileHeader(const double* print_time = nullptr, const std::vector<double>& filament_used = std::vector<double>(), const std::vector<std::string>& mat_ids = std::vector<std::string>());
void setLayerNr(unsigned int layer_nr);
void setOutputStream(std::ostream* stream);
Point getExtruderOffset(int id);
Point getGcodePos(int64_t x, int64_t y, int extruder_train);
bool getExtruderIsUsed(const int extruder_nr) const; //!< Returns whether the extruder with the given index is used up until the current meshgroup
int getNozzleSize(const int extruder_nr) const;
Point getExtruderOffset(const int id) const;
std::string getMaterialGUID(const int extruder_nr) const; //!< returns the GUID of the material used for the nozzle with id \p extruder_nr
Point getGcodePos(const int64_t x, const int64_t y, const int extruder_train) const;
void setFlavor(EGCodeFlavor flavor);
EGCodeFlavor getFlavor();
EGCodeFlavor getFlavor() const;
void setZ(int z);
@@ -229,15 +208,35 @@ public:
void setFilamentDiameter(unsigned int n, int diameter);
double getCurrentExtrudedVolume();
double getTotalFilamentUsed(int e);
/*!
* Get the total extruded volume for a specific extruder in mm^3
*
* Retractions and unretractions don't contribute to this.
*
* \param extruder_nr The extruder number for which to get the total netto extruded volume
* \return total filament printed in mm^3
*/
double getTotalFilamentUsed(int extruder_nr);
/*!
* Get the total estimated print time in seconds
*
* \return total print time in seconds
*/
double getTotalPrintTime();
void updateTotalPrintTime();
void resetTotalPrintTimeAndFilament();
void writeComment(std::string comment);
void writeTypeComment(const char* type);
void writeTypeComment(PrintFeatureType type);
/*!
* Write a comment saying what (estimated) time has passed up to this point
*
* \param time The time passed up till this point
*/
void writeTimeComment(const double time);
void writeLayerComment(int layer_nr);
void writeLayerCountComment(int layer_count);
@@ -252,53 +251,130 @@ public:
void writeDelay(double timeAmount);
void writeMove(Point p, double speed, double extrusion_per_mm);
void writeMove(Point p, double speed, double extrusion_mm3_per_mm);
void writeMove(Point3 p, double speed, double extrusion_per_mm);
void writeMove(Point3 p, double speed, double extrusion_mm3_per_mm);
private:
void writeMove(int x, int y, int z, double speed, double extrusion_per_mm);
void writeMove(int x, int y, int z, double speed, double extrusion_mm3_per_mm);
/*!
* The writeMove when flavor == BFB
*/
void writeMoveBFB(int x, int y, int z, double speed, double extrusion_per_mm);
void writeMoveBFB(int x, int y, int z, double speed, double extrusion_mm3_per_mm);
public:
void writeRetraction(RetractionConfig* config, bool force=false);
void writeRetraction_extruderSwitch();
void switchExtruder(int newExtruder);
void writeRetraction(const RetractionConfig& config, bool force = false, bool extruder_switch = false);
/*!
* Start a z hop with the given \p hop_height
*
* \param hop_height The height to move above the current layer
*/
void writeZhopStart(int hop_height);
/*!
* End a z hop: go back to the layer height
*
*/
void writeZhopEnd();
/*!
* Start the new_extruder:
* - set new extruder
* - zero E value
* - write extruder start gcode
*
* \param new_extruder The extruder to start with
*/
void startExtruder(int new_extruder);
/*!
* Switch to the new_extruder:
* - perform neccesary retractions
* - fiddle with E-values
* - write extruder end gcode
* - set new extruder
* - write extruder start gcode
*
* \param new_extruder The extruder to switch to
* \param retraction_config_old_extruder The extruder switch retraction config of the old extruder, to perform the extruder switch retraction with.
*/
void switchExtruder(int new_extruder, const RetractionConfig& retraction_config_old_extruder);
void writeCode(const char* str);
/*!
* Write the gcode for priming the current extruder train so that it can be used.
*
* \param travel_speed The travel speed when priming involves a movement
*/
void writePrimeTrain(double travel_speed);
void writeFanCommand(double speed);
void writeTemperatureCommand(int extruder, double temperature, bool wait = false);
void writeBedTemperatureCommand(double temperature, bool wait = false);
void preSetup(MeshGroup* settings)
{
for(int n=0; n<settings->getSettingAsCount("machine_extruder_count"); n++)
{
ExtruderTrain* train = settings->getExtruderTrain(n);
setFilamentDiameter(n, train->getSettingInMicrons("material_diameter"));
extruder_attr[n].nozzle_offset = Point(train->getSettingInMicrons("machine_nozzle_offset_x"), train->getSettingInMicrons("machine_nozzle_offset_y"));
extruder_attr[n].start_code = train->getSettingString("machine_extruder_start_code");
extruder_attr[n].end_code = train->getSettingString("machine_extruder_end_code");
extruder_attr[n].extruder_switch_retraction_distance = INT2MM(train->getSettingInMicrons("switch_extruder_retraction_amount"));
extruder_attr[n].extruderSwitchRetractionSpeed = train->getSettingInMillimetersPerSecond("switch_extruder_retraction_speed");
extruder_attr[n].extruderSwitchPrimeSpeed = train->getSettingInMillimetersPerSecond("switch_extruder_prime_speed");
}
setFlavor(settings->getSettingAsGCodeFlavor("machine_gcode_flavor"));
use_extruder_offset_to_offset_coords = settings->getSettingBoolean("machine_use_extruder_offset_to_offset_coords");
}
void finalize(double moveSpeed, const char* endCode);
/*!
* Write the command for setting the acceleration to a specific value
*/
void writeAcceleration(double acceleration);
/*!
* Write the command for setting the jerk to a specific value
*/
void writeJerk(double jerk);
/*!
* Write the command for setting the maximum z feedrate to a specific value
*/
void writeMaxZFeedrate(double max_z_feedrate);
/*!
* Get the last set max z feedrate value sent in the gcode.
*
* Returns a value <= 0 when no value is set.
*/
double getCurrentMaxZFeedrate();
/*!
* Set member variables using the settings in \p settings
*
* \param settings The meshgroup to get the global bed temp from and to get the extruder trains from which to get the nozzle temperatures
*/
void preSetup(const MeshGroup* settings);
/*!
* Handle the initial (bed/nozzle) temperatures before any gcode is processed.
* These temperatures are set in the pre-print setup in the firmware.
*
* 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, 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
*/
void setInitialTemp(int extruder_nr, double temp);
/*!
* Finish the gcode: turn fans off, write end gcode and flush all gcode left in the buffer.
*
* \param endCode The end gcode to be appended at the very end.
*/
void finalize(const char* endCode);
};
}
#endif//GCODEEXPORT_H
+560 -394
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+302 -284
Ver Arquivo
@@ -1,216 +1,101 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef GCODE_PLANNER_H
#define GCODE_PLANNER_H
#include <vector>
#include "gcodeExport.h"
#include "comb.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"
#include "commandSocket.h"
#include "FanSpeedLayerTime.h"
#include "SpaceFillType.h"
#include "GCodePathConfig.h"
#include "settings/PathConfigStorage.h"
#include "utils/optional.h"
namespace cura
{
class SliceDataStorage;
class GCodePlanner; // forward declaration so that ExtruderPlan can be a friend
class LayerPlanBuffer; // forward declaration so that ExtruderPlan can be a friend
/*!
* A gcode command to insert before a specific path.
* An extruder plan contains all planned paths (GCodePath) pertaining to a single extruder train.
*
* Currently only used for preheat commands
* It allows for temperature command inserts which can be inserted in between paths.
*/
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)
{}
/*!
* 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 GCodePlanner; // 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 GCodePlanner;
private:
double extrude_time; //!< in seconds
double unretracted_travel_time; //!< in seconds
double retracted_travel_time; //!< in seconds
double material; //!< in mm^3
public:
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()
: 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;
}
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& 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);
double getTotalTime() const
{
return extrude_time + unretracted_travel_time + retracted_travel_time;
}
double getTotalUnretractedTime() const
{
return extrude_time + unretracted_travel_time;
}
double getTravelTime() const
{
return retracted_travel_time + unretracted_travel_time;
}
double getExtrudeTime() const
{
return extrude_time;
}
double getMaterial() const
{
return material;
}
};
class GCodePath
{
public:
GCodePathConfig* config; //!< The configuration settings of the path.
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.
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.
TimeMaterialEstimates estimates; //!< Naive time and material estimates
bool isTravelPath()
{
return config->isTravelPath();
}
/*!
* Can only be called after the layer height has been set (which is done while writing the gcode!)
*/
double getExtrusionMM3perMM()
{
return flow * config->getExtrusionMM3perMM();
}
};
class ExtruderPlan
{
public:
std::vector<GCodePath> paths;
std::list<NozzleTempInsert> inserts;
friend class GCodePlanner; // TODO: GCodePlanner still does a lot which should actually be handled in this class.
friend class LayerPlanBuffer; // TODO: LayerPlanBuffer handles paths directly
protected:
std::vector<GCodePath> paths; //!< The paths planned for this extruder
std::list<NozzleTempInsert> inserts; //!< The nozzle temperature command inserts, to be inserted in between paths
int extruder; //!< The extruder used for this paths in the current plan.
double required_temp;
TimeMaterialEstimates estimates;
ExtruderPlan(int extruder)
: extruder(extruder)
, required_temp(-1)
{
}
double heated_pre_travel_time; //!< The time at the start of this ExtruderPlan during which the head travels and has a temperature of initial_print_temperature
double initial_printing_temperature; //!< The required temperature at the start of this extruder plan.
double printing_temperature; //!< The normal temperature for printing this extruder plan. That start and end of this extruder plan may deviate because of the initial and final print temp
std::optional<std::list<NozzleTempInsert>::iterator> printing_temperature_command; //!< The command to heat from the printing temperature of this extruder plan to the printing temperature of the next extruder plan (if it has the same extruder).
std::optional<double> prev_extruder_standby_temp; //!< The temperature to which to set the previous extruder. Not used if the previous extruder plan was the same extruder.
TimeMaterialEstimates estimates; //!< Accumulated time and material estimates for all planned paths within this extruder plan.
public:
/*!
* Simple contructor.
*
* \warning Doesn't set the required temperature yet.
*
* \param extruder The extruder number for which this object is a plan.
* \param start_position The position the head is when this extruder plan starts
*/
ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, const FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config);
/*!
* Add a new Insert, constructed with the given arguments
*
* \see NozzleTempInsert
*
* \param contructor_args The arguments for the constructor of an insert
*/
template<typename... Args>
void insertCommand(Args&&... contructor_args)
{
inserts.emplace_back(contructor_args...);
}
/*!
* Insert the inserts into gcode which should be inserted before @p path_idx
* Insert the inserts into gcode which should be inserted before \p path_idx
*
* \param path_idx The index into ExtruderPlan::paths which is currently being consider for temperature command insertion
* \param gcode The gcode exporter to which to write the temperature command.
*/
void handleInserts(unsigned int& path_idx, GCodeExport& gcode)
{
{
while ( ! inserts.empty() && path_idx >= inserts.front().path_idx)
{ // handle the Insert to be inserted before this path_idx (and all inserts not handled yet)
inserts.front().write(gcode);
inserts.pop_front();
}
}
/*!
* Insert all remaining temp inserts into gcode, to be called at the end of an extruder plan
*
* Inserts temperature commands which should be inserted _after_ the last path.
* Also inserts all temperatures which should have been inserted earlier,
* but for which ExtruderPlan::handleInserts hasn't been called correctly.
*
* \param gcode The gcode exporter to which to write the temperature command.
*/
void handleAllRemainingInserts(GCodeExport& gcode)
{
@@ -222,23 +107,136 @@ public:
inserts.pop_front();
}
}
/*!
* Applying speed corrections for minimal layer times and determine the fanSpeed.
*
* \param force_minimal_layer_time Whether we should apply speed changes and perhaps a head lift in order to meet the minimal layer time
*/
void processFanSpeedAndMinimalLayerTime(bool force_minimal_layer_time);
/*!
* Set the extrude speed factor. This is used for printing slower than normal.
*
* Leaves the extrusion speed as is for values of 1.0
*
* \param speedFactor The factor by which to alter the extrusion move speed
*/
void setExtrudeSpeedFactor(double speedFactor);
/*!
* Get the extrude speed factor. This is used for printing slower than normal.
*
* \return The factor by which to alter the extrusion move speed
*/
double getExtrudeSpeedFactor();
/*!
* Set the travel speed factor. This is used for performing non-extrusion travel moves slower than normal.
*
* Leaves the extrusion speed as is for values of 1.0
*
* \param speedFactor The factor by which to alter the non-extrusion move speed
*/
void setTravelSpeedFactor(double speedFactor);
/*!
* Get the travel speed factor. This is used for travelling slower than normal.
*
* Limited to at most 1.0
*
* \return The factor by which to alter the non-extrusion move speed
*/
double getTravelSpeedFactor();
/*!
* Get the fan speed computed for this extruder plan
*
* \warning assumes ExtruderPlan::processFanSpeedAndMinimalLayerTime has already been called
*
* \return The fan speed computed in processFanSpeedAndMinimalLayerTime
*/
double getFanSpeed();
protected:
Point start_position; //!< The position the print head was at at the start of this extruder plan
int layer_nr; //!< The layer number at which we are currently printing.
bool is_initial_layer; //!< Whether this extruder plan is printed on the very first layer (which might be raft)
int layer_thickness; //!< The thickness of this layer in Z-direction
const FanSpeedLayerTimeSettings& fan_speed_layer_time_settings; //!< The fan speed and layer time settings used to limit this extruder plan
const RetractionConfig& retraction_config; //!< The retraction settings for the extruder of this plan
double extrudeSpeedFactor; //!< The factor by which to alter the extrusion move speed
double travelSpeedFactor; //!< The factor by which to alter the non-extrusion move speed
double extraTime; //!< Extra waiting time at the and of this extruder plan, so that the filament can cool
double totalPrintTime; //!< The total naive time estimate for this extruder plan
double fan_speed; //!< The fan speed to be used during this extruder plan
/*!
* Set the fan speed to be used while printing this extruder plan
*
* \param fan_speed The speed for the fan
*/
void setFanSpeed(double fan_speed);
/*!
* Force the minimal layer time to hold by slowing down and lifting the head if required.
*
*/
void forceMinimalLayerTime(double minTime, double minimalSpeed, double travelTime, double extrusionTime);
/*!
* Compute naive time estimates (without accounting for slow down at corners etc.) and naive material estimates (without accounting for MergeInfillLines)
* and store them in each ExtruderPlan and each GCodePath.
*
* \return the total estimates of this layer
*/
TimeMaterialEstimates computeNaiveTimeEstimates();
};
class LayerPlanBuffer; // forward declaration to prevent circular dependency
/*!
* The GCodePlanner class stores multiple moves that are planned.
*
*
* It facilitates the combing to keep the head inside the print.
* It also keeps track of the print time estimate for this planning so speed adjustments can be made for the minimal-layer-time.
*
* A GCodePlanner is also knows as a 'layer plan'.
*
*/
class GCodePlanner : public NoCopy
{
friend class LayerPlanBuffer;
friend class GCodePlannerTest;
public:
/*!
* The state which is passed along between layer plans.
* This is what a \ref GCodePlanner delivers to further computation in \ref FffGcodeWriter
* This is the state which is currently planned, not which is written to gcode.
*/
struct PlanningState
{
Point last_position; //!< The position of the head before planning the next layer
int current_extruder; //!< The extruder train in use before planning the next layer
bool is_inside_mesh_layer_part; //!< Whether the last position was inside a layer part (used in combing)
};
private:
SliceDataStorage& storage;
const SliceDataStorage& storage; //!< The polygon data obtained from FffPolygonProcessor
CommandSocket* commandSocket;
int layer_nr;
public:
const PathConfigStorage configs_storage; //!< The line configs for this layer for each feature type
private:
int layer_nr; //!< The layer number of this layer plan
int is_initial_layer; //!< Whether this is the first layer (which might be raft)
int z;
@@ -246,25 +244,20 @@ private:
Point start_position;
Point lastPosition;
bool has_prime_tower_planned;
std::vector<ExtruderPlan> extruder_plans; //!< should always contain at least one ExtruderPlan
int last_extruder_previous_layer; //!< The last id of the extruder with which was printed in the previous layer
SettingsBaseVirtual* last_planned_extruder_setting_base; //!< The setting base of the last planned extruder.
bool was_inside; //!< Whether the last planned (extrusion) move was inside a layer part
bool is_inside; //!< Whether the destination of the next planned travel move is inside a layer part
Polygons comb_boundary_inside; //!< The boundary within which to comb, or to move into when performing a retraction.
Comb* comb;
RetractionConfig* last_retraction_config;
FanSpeedLayerTimeSettings& fan_speed_layer_time_settings;
double extrudeSpeedFactor;
double travelSpeedFactor;
double fan_speed;
double extraTime;
double totalPrintTime;
const std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder;
private:
/*!
@@ -272,11 +265,14 @@ private:
* If GCodePlanner::forceNewPathStart has been called a new path will always be returned.
*
* \param config The config used for the path returned
* \param space_fill_type The type of space filling which this path employs
* \param flow (optional) A ratio for the extrusion speed
* \param spiralize Whether to gradually increase the z while printing. (Note that this path may be part of a sequence of spiralized paths, forming one polygon)
* \return A path with the given config which is now the last path in GCodePlanner::paths
*/
GCodePath* getLatestPathWithConfig(GCodePathConfig* config, float flow = 1.0);
GCodePath* getLatestPathWithConfig(const GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
public:
/*!
* Force GCodePlanner::getLatestPathWithConfig to return a new path.
*
@@ -288,34 +284,78 @@ private:
* - when changing extruder, the same travel config is used, but its extruder field is changed.
*/
void forceNewPathStart();
public:
/*!
*
* \param fan_speed_layer_time_settings_per_extruder The fan speed and layer time settings for each extruder.
* \param travel_avoid_other_parts Whether to avoid other layer parts when travaeling through air.
* \param travel_avoid_distance The distance by which to avoid other layer parts when traveling through air.
* \param last_position The position of the head at the start of this gcode layer
* \param combing_mode Whether combing is enabled and full or within infill only.
*/
GCodePlanner(CommandSocket* commandSocket, SliceDataStorage& storage, unsigned int layer_nr, int z, int layer_height, Point last_position, int current_extruder, FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, bool retraction_combing, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
GCodePlanner(const SliceDataStorage& storage, int layer_nr, int z, int layer_height, PlanningState last_planned_state, const std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder, CombingMode combing_mode, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
~GCodePlanner();
void overrideFanSpeeds(double speed);
/*!
* Get the settings base of the last extruder planned.
* \return the settings base of the last extruder planned.
*/
SettingsBaseVirtual* getLastPlannedExtruderTrainSettings();
private:
/*!
* Compute the boundary within which to comb, or to move into when performing a retraction.
* \param combing_mode Whether combing is enabled and full or within infill only.
* \return the comb_boundary_inside
*/
Polygons computeCombBoundaryInside();
Polygons computeCombBoundaryInside(CombingMode combing_mode);
public:
int getLayerNr()
int getLayerNr() const
{
return layer_nr;
}
Point getLastPosition()
PlanningState getPlanningState() const
{
PlanningState ret;
ret.last_position = lastPosition;
ret.current_extruder = getExtruder();
ret.is_inside_mesh_layer_part = was_inside;
return ret;
}
Point getLastPosition() const
{
return lastPosition;
}
/*!
* return whether the last position planned was inside the mesh (used in combing)
*/
bool getIsInsideMesh() const
{
return was_inside;
}
bool getPrimeTowerIsPlanned() const
{
return has_prime_tower_planned;
}
void setPrimeTowerIsPlanned()
{
has_prime_tower_planned = true;
}
/*!
* send a line segment through the command socket from the previous point to the given point \p to
*/
void sendLineTo(PrintFeatureType print_feature_type, Point to, int line_width) const
{
CommandSocket::sendLineTo(print_feature_type, to, line_width);
}
/*!
* Set whether the next destination is inside a layer part or not.
*
@@ -323,39 +363,24 @@ 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);
/*!
* Get the last planned extruder.
*/
int getExtruder()
int getExtruder() const
{
return extruder_plans.back().extruder;
}
void setExtrudeSpeedFactor(double speedFactor)
{
this->extrudeSpeedFactor = speedFactor;
}
double getExtrudeSpeedFactor()
{
return this->extrudeSpeedFactor;
}
void setTravelSpeedFactor(double speedFactor)
{
if (speedFactor < 1) speedFactor = 1.0;
this->travelSpeedFactor = speedFactor;
}
double getTravelSpeedFactor()
{
return this->travelSpeedFactor;
}
void setFanSpeed(double _fan_speed)
{
fan_speed = _fan_speed;
}
/*!
* Add a travel path to a certain point, retract if needed and when avoiding boundary crossings:
@@ -363,7 +388,7 @@ public:
*
* \param p The point to travel to
*/
void addTravel(Point p);
GCodePath& addTravel(Point p);
/*!
* Add a travel path to a certain point and retract if needed.
@@ -373,51 +398,82 @@ public:
* \param p The point to travel to
* \param path (optional) The travel path to which to add the point \p p
*/
void addTravel_simple(Point p, GCodePath* path = nullptr);
void addExtrusionMove(Point p, GCodePathConfig* config, float flow = 1.0);
GCodePath& addTravel_simple(Point p, GCodePath* path = nullptr);
void addPolygon(PolygonRef polygon, int startIdx, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = 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();
void addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, EZSeamType z_seam_type = EZSeamType::SHORTEST);
/*!
* Add an extrusion move to a certain point, optionally with a different flow than the one in the \p config.
*
* \param p The point to extrude to
* \param config The config with which to extrude
* \param space_fill_type Of what space filling type this extrusion move is a part
* \param flow A modifier of the extrusion width which would follow from the \p config
* \param spiralize Whether to gradually increase the z while printing. (Note that this path may be part of a sequence of spiralized paths, forming one polygon)
*/
void addExtrusionMove(Point p, const GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
/*!
* Add polygon to the gcode starting at vertex \p startIdx
* \param polygon The polygon
* \param startIdx The index of the starting vertex of the \p polygon
* \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 wall_0_wipe_dist The distance to travel along the 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 this polygon
*/
void addPolygon(ConstPolygonRef polygon, int startIdx, const GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, coord_t wall_0_wipe_dist = 0, bool spiralize = false);
/*!
* Add polygons to the gcode with optimized order.
*
* When \p spiralize is true, each polygon will gradually increase from a z corresponding to this layer to the z corresponding to the next layer.
* Doing this for each polygon means there is a chance for the print head to crash into already printed parts,
* but doing it for the last polygon only would mean you are printing half of the layer in non-spiralize mode,
* while each layer starts with a different part.
* Two towers would result in alternating spiralize and non-spiralize layers.
*
* \param polygons The polygons
* \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(const Polygons& polygons, const 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.
* \param polygons The lines
* \param config The config of the lines
* \param space_fill_type The type of space filling used to generate the line segments (should be either Lines or PolyLines!)
* \param wipe_dist (optional) the distance wiped without extruding after laying down a line.
*/
void addLinesByOptimizer(Polygons& polygons, GCodePathConfig* config, int wipe_dist = 0);
void addLinesByOptimizer(const Polygons& polygons, const GCodePathConfig* config, SpaceFillType space_fill_type, int wipe_dist = 0);
/*!
* Compute naive time estimates (without accountign for slow down at corners etc.) and naive material estimates (without accounting for MergeInfillLines)
* Compute naive time estimates (without accounting for slow down at corners etc.) and naive material estimates (without accounting for MergeInfillLines)
* and store them in each ExtruderPlan and each GCodePath.
*
* \warning This function recomputes values which are already computed if you've called processFanSpeedAndMinimalLayerTime
*
* \return the total estimates of this layer
*/
TimeMaterialEstimates computeNaiveTimeEstimates();
void forceMinimalLayerTime(double minTime, double minimalSpeed, double travelTime, double extrusionTime);
/*!
* Write the planned paths to gcode
*
* \param gcode The gcode to write the planned paths to
*/
void writeGCode(GCodeExport& gcode, bool liftHeadIfNeeded, int layerThickness);
/*!
* Complete all GcodePathConfig s by
* - altering speed to conform to speed_layer_0
* - setting the layer_height (and thereby computing the extrusionMM3perMM)
*/
void completeConfigs();
/*!
* Interpolate between the initial layer speeds and the eventual speeds.
*/
void processInitialLayersSpeedup();
void writeGCode(GCodeExport& gcode);
/*!
* Whether the current retracted path is to be an extruder switch retraction.
* This function is used to avoid a G10 S1 after a G10.
@@ -438,51 +494,13 @@ public:
* \param extruder_plan_idx The index of the current extruder plan
* \param path_idx The index into GCodePlanner::paths for the next path to be written to GCode.
* \param layerThickness The height of the current layer.
* \param coasting_volume_move The volume otherwise leaked during a normal move.
* \param coasting_speed_move The speed at which to move during move-coasting.
* \param coasting_min_volume_move The minimal volume a path should have which builds up enough pressure to ooze as much as \p coasting_volume_move.
* \param coasting_volume_retract The volume otherwise leaked during a retract move.
* \param coasting_speed_retract The speed at which to move during retract-coasting.
* \param coasting_min_volume_retract The minimal volume a path should have which builds up enough pressure to ooze as much as \p coasting_volume_retract.
* \param coasting_volume The volume otherwise leaked during a normal move.
* \param coasting_speed The speed at which to move during move-coasting.
* \param coasting_min_volume The minimal volume a path should have (before starting to coast) which builds up enough pressure to ooze as much as \p coasting_volume.
* \return Whether any GCode has been written for the path.
*/
bool writePathWithCoasting(GCodeExport& gcode, unsigned int extruder_plan_idx, unsigned int path_idx, int64_t layerThickness, double coasting_volume_move, double coasting_speed_move, double coasting_min_volume_move, double coasting_volume_retract, double coasting_speed_retract, double coasting_min_volume_retract);
bool writePathWithCoasting(GCodeExport& gcode, unsigned int extruder_plan_idx, unsigned int path_idx, int64_t layerThickness, double coasting_volume, double coasting_speed, double coasting_min_volume);
/*!
* Writes a path to GCode and performs coasting, or returns false if it did nothing.
*
* Coasting replaces the last piece of an extruded path by move commands and uses the oozed material to lay down lines.
*
* Paths shorter than \p coasting_min_volume will use less \p coasting_volume linearly.
*
* \param gcode The gcode to write the planned paths to
* \param path The extrusion path to be written to GCode.
* \param path_next The next travel path to be written to GCode.
* \param layerThickness The height of the current layer.
* \param coasting_volume The volume otherwise leaked.
* \param coasting_speed The speed at which to move during coasting.
* \param coasting_min_volume The minimal volume a path should have which builds up enough pressure to ooze as much as \p coasting_volume.
* \param extruder_switch_retract (optional) For a coasted path followed by a retraction: whether to retract normally, or do an extruder switch retraction.
* \return Whether any GCode has been written for the path.
*/
bool writePathWithCoasting(GCodeExport& gcode, GCodePath& path, GCodePath& path_next, int64_t layerThickness, double coasting_volume, double coasting_speed, double coasting_min_volume, bool extruder_switch_retract = false);
/*!
* Write a retraction: either an extruder switch retraction or a normal retraction based on the last extrusion paths retraction config.
* \param gcode The gcode to write the planned paths to
* \param extruder_plan_idx The index of the current extruder plan
* \param path_idx_travel_after Index in GCodePlanner::paths to the travel move before which to do the retraction
*/
void writeRetraction(GCodeExport& gcode, unsigned int extruder_plan_idx, unsigned int path_idx_travel_after);
/*!
* Write a retraction: either an extruder switch retraction or a normal retraction based on the given retraction config.
* \param gcode The gcode to write the planned paths to
* \param extruder_switch_retract Whether to write an extruder switch retract
* \param retraction_config The config used.
*/
void writeRetraction(GCodeExport& gcode, bool extruder_switch_retract, RetractionConfig* retraction_config);
/*!
* Applying speed corrections for minimal layer times and determine the fanSpeed.
*/
+285 -371
Ver Arquivo
@@ -2,50 +2,59 @@
#include "infill.h"
#include "functional"
#include "utils/polygonUtils.h"
#include "utils/AABB.h"
#include "utils/logoutput.h"
namespace cura {
void Infill::generate(Polygons& result_polygons, Polygons& result_lines, Polygons* in_between)
int Infill::computeScanSegmentIdx(int x, int line_width)
{
if (x < 0)
{
return (x + 1) / line_width - 1;
// - 1 because -1 belongs to scansegment -1
// + 1 because -line_width belongs to scansegment -1
}
return x / line_width;
}
void Infill::generate(Polygons& result_polygons, Polygons& result_lines, const SliceMeshStorage* mesh)
{
if (in_outline.size() == 0) return;
if (line_distance == 0) return;
const Polygons* outline = &in_outline;
Polygons outline_offsetted;
switch(pattern)
{
case EFillMethod::GRID:
generateGridInfill(in_outline, outlineOffset, result_lines, extrusion_width, line_distance * 2, infill_overlap, fill_angle);
generateGridInfill(result_lines);
break;
case EFillMethod::LINES:
generateLineInfill(in_outline, outlineOffset, result_lines, extrusion_width, line_distance, infill_overlap, fill_angle);
generateLineInfill(result_lines, line_distance, fill_angle, 0);
break;
case EFillMethod::CUBIC:
generateCubicInfill(result_lines);
break;
case EFillMethod::TETRAHEDRAL:
generateTetrahedralInfill(result_lines);
break;
case EFillMethod::TRIANGLES:
generateTriangleInfill(in_outline, outlineOffset, result_lines, extrusion_width, line_distance * 3, infill_overlap, fill_angle);
generateTriangleInfill(result_lines);
break;
case EFillMethod::CONCENTRIC:
if (outlineOffset != 0)
{
PolygonUtils::offsetSafe(in_outline, outlineOffset, extrusion_width, outline_offsetted, avoidOverlappingPerimeters);
outline = &outline_offsetted;
}
if (abs(extrusion_width - line_distance) < 10)
{
generateConcentricInfillDense(*outline, result_polygons, in_between, extrusion_width, avoidOverlappingPerimeters);
}
else
{
generateConcentricInfill(*outline, result_polygons, line_distance);
}
generateConcentricInfill(result_polygons, line_distance);
break;
case EFillMethod::CONCENTRIC_3D:
generateConcentric3DInfill(result_polygons);
break;
case EFillMethod::ZIG_ZAG:
if (outlineOffset != 0)
generateZigZagInfill(result_lines, line_distance, fill_angle, connected_zigzags, use_endpieces);
break;
case EFillMethod::CUBICSUBDIV:
if (!mesh)
{
PolygonUtils::offsetSafe(in_outline, outlineOffset, extrusion_width, outline_offsetted, avoidOverlappingPerimeters);
outline = &outline_offsetted;
logError("Cannot generate Cubic Subdivision infill without a mesh!\n");
break;
}
generateZigZagInfill(*outline, result_lines, extrusion_width, line_distance, infill_overlap, fill_angle, connect_zigzags, use_endPieces);
generateCubicSubDivInfill(result_lines, *mesh);
break;
default:
logError("Fill pattern has unknown value.\n");
@@ -53,407 +62,312 @@ void Infill::generate(Polygons& result_polygons, Polygons& result_lines, Polygon
}
}
void generateConcentricInfillDense(Polygons outline, Polygons& result, Polygons* in_between, int extrusionWidth, bool avoidOverlappingPerimeters)
void Infill::generateConcentricInfill(Polygons& result, int inset_value)
{
while(outline.size() > 0)
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
if (perimeter_gaps)
{
for (unsigned int polyNr = 0; polyNr < outline.size(); polyNr++)
{
PolygonRef r = outline[polyNr];
result.add(r);
}
Polygons next_outline;
PolygonUtils::offsetExtrusionWidth(outline, true, extrusionWidth, next_outline, in_between, avoidOverlappingPerimeters);
outline = next_outline;
}
const Polygons inner = first_concentric_wall.offset(infill_line_width / 2 + perimeter_gaps_extra_offset);
const Polygons gaps_here = in_outline.difference(inner);
perimeter_gaps->add(gaps_here);
}
generateConcentricInfill(first_concentric_wall, result, inset_value);
}
void generateConcentricInfill(Polygons outline, Polygons& result, int inset_value)
void Infill::generateConcentricInfill(Polygons& first_concentric_wall, Polygons& result, int inset_value)
{
while(outline.size() > 0)
result.add(first_concentric_wall);
Polygons* prev_inset = &first_concentric_wall;
Polygons next_inset;
while (prev_inset->size() > 0)
{
for (unsigned int polyNr = 0; polyNr < outline.size(); polyNr++)
next_inset = prev_inset->offset(-inset_value);
result.add(next_inset);
if (perimeter_gaps)
{
PolygonRef r = outline[polyNr];
result.add(r);
const Polygons outer = prev_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);
}
outline = outline.offset(-inset_value);
}
prev_inset = &next_inset;
}
}
void generateGridInfill(const Polygons& in_outline, int outlineOffset, Polygons& result,
int extrusionWidth, int lineSpacing, double infillOverlap,
double rotation)
void Infill::generateConcentric3DInfill(Polygons& result)
{
generateLineInfill(in_outline, outlineOffset, result, extrusionWidth, lineSpacing,
infillOverlap, rotation);
generateLineInfill(in_outline, outlineOffset, result, extrusionWidth, lineSpacing,
infillOverlap, rotation + 90);
int period = line_distance * 2;
int shift = int64_t(one_over_sqrt_2 * z) % period;
shift = std::min(shift, period - shift); // symmetry due to the fact that we are applying the shift in both directions
shift = std::min(shift, period / 2 - infill_line_width / 2); // don't put lines too close to each other
shift = std::max(shift, infill_line_width / 2); // don't put lines too close to each other
Polygons first_wall;
// in contrast to concentric infill we dont do "- infill_line_width / 2" cause this is already handled by the max two lines above
first_wall = in_outline.offset(outline_offset - shift);
generateConcentricInfill(first_wall, result, period);
first_wall = in_outline.offset(outline_offset - period + shift);
generateConcentricInfill(first_wall, result, period);
}
void generateTriangleInfill(const Polygons& in_outline, int outlineOffset, Polygons& result,
int extrusionWidth, int lineSpacing, double infillOverlap,
double rotation)
void Infill::generateGridInfill(Polygons& result)
{
generateLineInfill(in_outline, outlineOffset, result, extrusionWidth, lineSpacing,
infillOverlap, rotation);
generateLineInfill(in_outline, outlineOffset, result, extrusionWidth, lineSpacing,
infillOverlap, rotation + 60);
generateLineInfill(in_outline, outlineOffset, result, extrusionWidth, lineSpacing,
infillOverlap, rotation + 120);
generateLineInfill(result, line_distance, fill_angle, 0);
generateLineInfill(result, line_distance, fill_angle + 90, 0);
}
void addLineInfill(Polygons& result, PointMatrix matrix, int scanline_min_idx, int lineSpacing, AABB boundary, std::vector<std::vector<int64_t> > cutList, int extrusionWidth)
void Infill::generateCubicInfill(Polygons& result)
{
int64_t shift = one_over_sqrt_2 * z;
generateLineInfill(result, line_distance, fill_angle, shift);
generateLineInfill(result, line_distance, fill_angle + 120, shift);
generateLineInfill(result, line_distance, fill_angle + 240, shift);
}
void Infill::generateTetrahedralInfill(Polygons& result)
{
int period = line_distance * 2;
int shift = int64_t(one_over_sqrt_2 * z) % period;
shift = std::min(shift, period - shift); // symmetry due to the fact that we are applying the shift in both directions
shift = std::min(shift, period / 2 - infill_line_width / 2); // don't put lines too close to each other
shift = std::max(shift, infill_line_width / 2); // don't put lines too close to each other
generateLineInfill(result, period, fill_angle, shift);
generateLineInfill(result, period, fill_angle, -shift);
generateLineInfill(result, period, fill_angle + 90, shift);
generateLineInfill(result, period, fill_angle + 90, -shift);
}
void Infill::generateTriangleInfill(Polygons& result)
{
generateLineInfill(result, line_distance, fill_angle, 0);
generateLineInfill(result, line_distance, fill_angle + 60, 0);
generateLineInfill(result, line_distance, fill_angle + 120, 0);
}
void Infill::generateCubicSubDivInfill(Polygons& result, const 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(matrix.unapply(from));
p.add(matrix.unapply(to));
};
auto compare_int64_t = [](const void* a, const void* b)
{
int64_t n = (*(int64_t*)a) - (*(int64_t*)b);
if (n < 0) return -1;
if (n > 0) return 1;
if (n < 0)
{
return -1;
}
if (n > 0)
{
return 1;
}
return 0;
};
int scanline_idx = 0;
for(int64_t x = scanline_min_idx * lineSpacing; x < boundary.max.X; x += lineSpacing)
for(int64_t x = scanline_min_idx * line_distance + shift; x < boundary.max.X; x += line_distance)
{
qsort(cutList[scanline_idx].data(), cutList[scanline_idx].size(), sizeof(int64_t), compare_int64_t);
for(unsigned int i = 0; i + 1 < cutList[scanline_idx].size(); i+=2)
std::vector<int64_t>& crossings = cut_list[scanline_idx];
qsort(crossings.data(), crossings.size(), sizeof(int64_t), compare_int64_t);
for(unsigned int crossing_idx = 0; crossing_idx + 1 < crossings.size(); crossing_idx += 2)
{
if (cutList[scanline_idx][i+1] - cutList[scanline_idx][i] < extrusionWidth / 5)
if (crossings[crossing_idx + 1] - crossings[crossing_idx] < infill_line_width / 5)
{ // segment is too short to create infill
continue;
addLine(Point(x, cutList[scanline_idx][i]), Point(x, cutList[scanline_idx][i+1]));
}
result.addLine(rotation_matrix.unapply(Point(x, crossings[crossing_idx])), rotation_matrix.unapply(Point(x, crossings[crossing_idx + 1])));
}
scanline_idx += 1;
}
}
void generateLineInfill(const Polygons& in_outline, int outlineOffset, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation)
void Infill::generateLineInfill(Polygons& result, int line_distance, const double& fill_angle, int64_t shift)
{
if (lineSpacing == 0) return;
if (in_outline.size() == 0) return;
Polygons outline = ((outlineOffset)? in_outline.offset(outlineOffset) : in_outline).offset(extrusionWidth * infillOverlap / 100);
if (outline.size() == 0) return;
PointMatrix matrix(rotation);
outline.applyMatrix(matrix);
PointMatrix rotation_matrix(fill_angle);
NoZigZagConnectorProcessor lines_processor(rotation_matrix, result);
bool connected_zigzags = false;
generateLinearBasedInfill(outline_offset, result, line_distance, rotation_matrix, lines_processor, connected_zigzags, shift);
}
AABB boundary(outline);
int scanline_min_idx = boundary.min.X / lineSpacing;
int lineCount = (boundary.max.X + (lineSpacing - 1)) / lineSpacing - scanline_min_idx;
std::vector<std::vector<int64_t> > cutList; // mapping from scanline to all intersections with polygon segments
for(int n=0; n<lineCount; n++)
cutList.push_back(std::vector<int64_t>());
for(unsigned int poly_idx=0; poly_idx < outline.size(); poly_idx++)
void Infill::generateZigZagInfill(Polygons& result, const int line_distance, const double& fill_angle, const bool connected_zigzags, const bool use_endpieces)
{
PointMatrix rotation_matrix(fill_angle);
if (use_endpieces)
{
Point p0 = outline[poly_idx][outline[poly_idx].size()-1];
for(unsigned int i=0; i < outline[poly_idx].size(); i++)
if (connected_zigzags)
{
Point p1 = outline[poly_idx][i];
int64_t xMin = p1.X, xMax = p0.X;
if (xMin == xMax) {
p0 = p1;
continue;
}
if (xMin > xMax) { xMin = p0.X; xMax = p1.X; }
int scanline_idx0 = (p0.X + ((p0.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -1 cause a linesegment on scanline x counts as belonging to scansegment x-1 ...
int scanline_idx1 = (p1.X + ((p1.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -linespacing because a line between scanline -n and -n-1 belongs to scansegment -n-1 (for n=positive natural number)
int direction = 1;
if (p0.X > p1.X)
{
direction = -1;
scanline_idx1 += 1; // only consider the scanlines in between the scansegments
} else scanline_idx0 += 1; // only consider the scanlines in between the scansegments
for(int scanline_idx = scanline_idx0; scanline_idx != scanline_idx1+direction; scanline_idx+=direction)
{
int x = scanline_idx * lineSpacing;
int y = p1.Y + (p0.Y - p1.Y) * (x - p1.X) / (p0.X - p1.X);
cutList[scanline_idx - scanline_min_idx].push_back(y);
}
p0 = p1;
ZigzagConnectorProcessorConnectedEndPieces zigzag_processor(rotation_matrix, result);
generateLinearBasedInfill(outline_offset - infill_line_width / 2, result, line_distance, rotation_matrix, zigzag_processor, connected_zigzags, 0);
}
else
{
ZigzagConnectorProcessorDisconnectedEndPieces zigzag_processor(rotation_matrix, result);
generateLinearBasedInfill(outline_offset - infill_line_width / 2, result, line_distance, rotation_matrix, zigzag_processor, connected_zigzags, 0);
}
}
addLineInfill(result, matrix, scanline_min_idx, lineSpacing, boundary, cutList, extrusionWidth);
}
void generateZigZagInfill(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation, bool connect_zigzags, bool use_endPieces)
{
if (use_endPieces) return generateZigZagIninfill_endPieces(in_outline, result, extrusionWidth, lineSpacing, infillOverlap, rotation, connect_zigzags);
else return generateZigZagIninfill_noEndPieces(in_outline, result, extrusionWidth, lineSpacing, infillOverlap, rotation);
}
void generateZigZagIninfill_endPieces(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation, bool connect_zigzags)
{
// if (in_outline.size() == 0) return;
// Polygons outline = in_outline.offset(extrusionWidth * infillOverlap / 100 - extrusionWidth / 2);
Polygons empty;
Polygons outline = in_outline.difference(empty); // copy
if (outline.size() == 0) return;
PointMatrix matrix(rotation);
outline.applyMatrix(matrix);
auto addLine = [&](Point from, Point to)
{
PolygonRef p = result.newPoly();
p.add(matrix.unapply(from));
p.add(matrix.unapply(to));
};
AABB boundary(outline);
int scanline_min_idx = boundary.min.X / lineSpacing;
int lineCount = (boundary.max.X + (lineSpacing - 1)) / lineSpacing - scanline_min_idx;
std::vector<std::vector<int64_t> > cutList; // mapping from scanline to all intersections with polygon segments
for(int n=0; n<lineCount; n++)
cutList.push_back(std::vector<int64_t>());
for(unsigned int polyNr=0; polyNr < outline.size(); polyNr++)
else
{
std::vector<Point> firstBoundarySegment;
std::vector<Point> unevenBoundarySegment; // stored cause for connected_zigzags a boundary segment which ends in an uneven scanline needs to be included
bool isFirstBoundarySegment = true;
bool firstBoundarySegmentEndsInEven = false;
bool isEvenScanSegment = false;
Point p0 = outline[polyNr][outline[polyNr].size()-1];
Point lastPoint = p0;
for(unsigned int i=0; i < outline[polyNr].size(); i++)
ZigzagConnectorProcessorNoEndPieces zigzag_processor(rotation_matrix, result);
generateLinearBasedInfill(outline_offset - infill_line_width / 2, result, line_distance, rotation_matrix, zigzag_processor, connected_zigzags, 0);
}
}
/*
* algorithm:
* 1. for each line segment of each polygon:
* store the intersections of that line segment with all scanlines in a mapping (vector of vectors) from scanline to intersections
* (zigzag): add boundary segments to result
* 2. for each scanline:
* sort the associated intersections
* and connect them using the even-odd rule
*
* rough explanation of the zigzag algorithm:
* while walking around (each) polygon (1.)
* if polygon intersects with even scanline
* start boundary segment (add each following segment to the [result])
* when polygon intersects with a scanline again
* stop boundary segment (stop adding segments to the [result])
* (see infill/ZigzagConnectorProcessor.h for actual implementation details)
*
*
* we call the areas between two consecutive scanlines a 'scansegment'.
* Scansegment x is the area between scanline x and scanline x+1
* Edit: the term scansegment is wrong, since I call a boundary segment leaving from an even scanline to the left as belonging to an even scansegment,
* while I also call a boundary segment leaving from an even scanline toward the right as belonging to an even scansegment.
*/
void Infill::generateLinearBasedInfill(const int outline_offset, Polygons& result, const int line_distance, const PointMatrix& rotation_matrix, ZigzagConnectorProcessor& zigzag_connector_processor, const bool connected_zigzags, int64_t extra_shift)
{
if (line_distance == 0)
{
return;
}
if (in_outline.size() == 0)
{
return;
}
int shift = extra_shift + this->shift;
Polygons outline;
if (outline_offset != 0)
{
outline = in_outline.offset(outline_offset);
if (perimeter_gaps)
{
Point p1 = outline[polyNr][i];
int64_t xMin = p1.X, xMax = p0.X;
if (xMin == xMax) {
lastPoint = p1;
perimeter_gaps->add(in_outline.difference(outline.offset(infill_line_width / 2 + perimeter_gaps_extra_offset)));
}
}
else
{
outline = in_outline;
}
outline = outline.offset(infill_overlap);
if (outline.size() == 0)
{
return;
}
outline.applyMatrix(rotation_matrix);
if (shift < 0)
{
shift = line_distance - (-shift) % line_distance;
}
else
{
shift = shift % line_distance;
}
AABB boundary(outline);
int scanline_min_idx = computeScanSegmentIdx(boundary.min.X - shift, line_distance);
int line_count = computeScanSegmentIdx(boundary.max.X - shift, line_distance) + 1 - scanline_min_idx;
std::vector<std::vector<int64_t> > cut_list; // mapping from scanline to all intersections with polygon segments
for(int scanline_idx = 0; scanline_idx < line_count; scanline_idx++)
{
cut_list.push_back(std::vector<int64_t>());
}
for(unsigned int poly_idx = 0; poly_idx < outline.size(); poly_idx++)
{
PolygonRef poly = outline[poly_idx];
Point p0 = poly.back();
zigzag_connector_processor.registerVertex(p0); // always adds the first point to ZigzagConnectorProcessorEndPieces::first_zigzag_connector when using a zigzag infill type
for(unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
{
Point p1 = poly[point_idx];
if (p1.X == p0.X)
{
zigzag_connector_processor.registerVertex(p1);
// TODO: how to make sure it always adds the shortest line? (in order to prevent overlap with the zigzag connectors)
// note: this is already a problem for normal infill, but hasn't really cothered anyone so far.
p0 = p1;
continue;
}
if (xMin > xMax) { xMin = p0.X; xMax = p1.X; }
int scanline_idx0 = (p0.X + ((p0.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -1 cause a linesegment on scanline x counts as belonging to scansegment x-1 ...
int scanline_idx1 = (p1.X + ((p1.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -linespacing because a line between scanline -n and -n-1 belongs to scansegment -n-1 (for n=positive natural number)
int scanline_idx0;
int scanline_idx1;
// this way of handling the indices takes care of the case where a boundary line segment ends exactly on a scanline:
// in case the next segment moves back from that scanline either 2 or 0 scanline-boundary intersections are created
// otherwise only 1 will be created, counting as an actual intersection
int direction = 1;
if (p0.X > p1.X)
if (p0.X < p1.X)
{
scanline_idx0 = computeScanSegmentIdx(p0.X - shift, line_distance) + 1; // + 1 cause we don't cross the scanline of the first scan segment
scanline_idx1 = computeScanSegmentIdx(p1.X - shift, line_distance); // -1 cause the vertex point is handled in the next segment (or not in the case which looks like >)
}
else
{
direction = -1;
scanline_idx1 += 1; // only consider the scanlines in between the scansegments
} else scanline_idx0 += 1; // only consider the scanlines in between the scansegments
if (isFirstBoundarySegment) firstBoundarySegment.push_back(p0);
for(int scanline_idx = scanline_idx0; scanline_idx != scanline_idx1+direction; scanline_idx+=direction)
scanline_idx0 = computeScanSegmentIdx(p0.X - shift, line_distance); // -1 cause the vertex point is handled in the previous segment (or not in the case which looks like >)
scanline_idx1 = computeScanSegmentIdx(p1.X - shift, line_distance) + 1; // + 1 cause we don't cross the scanline of the first scan segment
}
for(int scanline_idx = scanline_idx0; scanline_idx != scanline_idx1 + direction; scanline_idx += direction)
{
int x = scanline_idx * lineSpacing;
int x = scanline_idx * line_distance + shift;
int y = p1.Y + (p0.Y - p1.Y) * (x - p1.X) / (p0.X - p1.X);
cutList[scanline_idx - scanline_min_idx].push_back(y);
bool last_isEvenScanSegment = isEvenScanSegment;
if (scanline_idx % 2 == 0) isEvenScanSegment = true;
else isEvenScanSegment = false;
if (!isFirstBoundarySegment)
{
if (last_isEvenScanSegment && (connect_zigzags || !isEvenScanSegment))
addLine(lastPoint, Point(x,y));
else if (connect_zigzags && !last_isEvenScanSegment && !isEvenScanSegment) // if we end an uneven boundary in an uneven segment
{ // add whole unevenBoundarySegment (including the just obtained point)
for (unsigned int p = 1; p < unevenBoundarySegment.size(); p++)
{
addLine(unevenBoundarySegment[p-1], unevenBoundarySegment[p]);
}
addLine(unevenBoundarySegment[unevenBoundarySegment.size()-1], Point(x,y));
unevenBoundarySegment.clear();
}
if (connect_zigzags && last_isEvenScanSegment && !isEvenScanSegment)
unevenBoundarySegment.push_back(Point(x,y));
else
unevenBoundarySegment.clear();
}
lastPoint = Point(x,y);
if (isFirstBoundarySegment)
{
firstBoundarySegment.emplace_back(x,y);
firstBoundarySegmentEndsInEven = isEvenScanSegment;
isFirstBoundarySegment = false;
}
assert(scanline_idx - scanline_min_idx >= 0 && scanline_idx - scanline_min_idx < int(cut_list.size()) && "reading infill cutlist index out of bounds!");
cut_list[scanline_idx - scanline_min_idx].push_back(y);
Point scanline_linesegment_intersection(x, y);
zigzag_connector_processor.registerScanlineSegmentIntersection(scanline_linesegment_intersection, scanline_idx % 2 == 0);
}
if (!isFirstBoundarySegment)
{
if (isEvenScanSegment)
addLine(lastPoint, p1);
else if (connect_zigzags)
unevenBoundarySegment.push_back(p1);
}
lastPoint = p1;
zigzag_connector_processor.registerVertex(p1);
p0 = p1;
}
if (isEvenScanSegment || isFirstBoundarySegment || connect_zigzags)
{
for (unsigned int i = 1; i < firstBoundarySegment.size() ; i++)
{
if (i < firstBoundarySegment.size() - 1 || !firstBoundarySegmentEndsInEven || connect_zigzags) // only add last element if connect_zigzags or boundary segment ends in uneven scanline
addLine(firstBoundarySegment[i-1], firstBoundarySegment[i]);
}
}
else if (!firstBoundarySegmentEndsInEven)
addLine(firstBoundarySegment[firstBoundarySegment.size()-2], firstBoundarySegment[firstBoundarySegment.size()-1]);
}
if (cutList.size() == 0) return;
if (connect_zigzags && cutList.size() == 1 && cutList[0].size() <= 2) return; // don't add connection if boundary already contains whole outline!
addLineInfill(result, matrix, scanline_min_idx, lineSpacing, boundary, cutList, extrusionWidth);
}
zigzag_connector_processor.registerPolyFinished();
}
void generateZigZagIninfill_noEndPieces(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation)
{
if (in_outline.size() == 0) return;
Polygons outline = in_outline.offset(extrusionWidth * infillOverlap / 100 - extrusionWidth / 2);
if (outline.size() == 0) return;
PointMatrix matrix(rotation);
outline.applyMatrix(matrix);
auto addLine = [&](Point from, Point to)
{
PolygonRef p = result.newPoly();
p.add(matrix.unapply(from));
p.add(matrix.unapply(to));
};
AABB boundary(outline);
int scanline_min_idx = boundary.min.X / lineSpacing;
int lineCount = (boundary.max.X + (lineSpacing - 1)) / lineSpacing - scanline_min_idx;
std::vector<std::vector<int64_t> > cutList; // mapping from scanline to all intersections with polygon segments
for(int n=0; n<lineCount; n++)
cutList.push_back(std::vector<int64_t>());
for(unsigned int polyNr=0; polyNr < outline.size(); polyNr++)
if (cut_list.size() == 0)
{
std::vector<Point> firstBoundarySegment;
std::vector<Point> boundarySegment;
bool isFirstBoundarySegment = true;
bool firstBoundarySegmentEndsInEven = true;
bool isEvenScanSegment = false;
Point p0 = outline[polyNr][outline[polyNr].size()-1];
for(unsigned int i=0; i < outline[polyNr].size(); i++)
{
Point p1 = outline[polyNr][i];
int64_t xMin = p1.X, xMax = p0.X;
if (xMin == xMax) {
p0 = p1;
continue;
}
if (xMin > xMax) { xMin = p0.X; xMax = p1.X; }
int scanline_idx0 = (p0.X + ((p0.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -1 cause a linesegment on scanline x counts as belonging to scansegment x-1 ...
int scanline_idx1 = (p1.X + ((p1.X > 0)? -1 : -lineSpacing)) / lineSpacing; // -linespacing because a line between scanline -n and -n-1 belongs to scansegment -n-1 (for n=positive natural number)
int direction = 1;
if (p0.X > p1.X)
{
direction = -1;
scanline_idx1 += 1; // only consider the scanlines in between the scansegments
} else scanline_idx0 += 1; // only consider the scanlines in between the scansegments
if (isFirstBoundarySegment) firstBoundarySegment.push_back(p0);
else boundarySegment.push_back(p0);
for(int scanline_idx = scanline_idx0; scanline_idx != scanline_idx1+direction; scanline_idx+=direction)
{
int x = scanline_idx * lineSpacing;
int y = p1.Y + (p0.Y - p1.Y) * (x - p1.X) / (p0.X - p1.X);
cutList[scanline_idx - scanline_min_idx].push_back(y);
bool last_isEvenScanSegment = isEvenScanSegment;
if (scanline_idx % 2 == 0) isEvenScanSegment = true;
else isEvenScanSegment = false;
if (!isFirstBoundarySegment)
{
if (last_isEvenScanSegment && !isEvenScanSegment)
{ // add whole boundarySegment (including the just obtained point)
for (unsigned int p = 1; p < boundarySegment.size(); p++)
{
addLine(boundarySegment[p-1], boundarySegment[p]);
}
addLine(boundarySegment[boundarySegment.size()-1], Point(x,y));
boundarySegment.clear();
}
else if (isEvenScanSegment) // we are either in an end piece or an uneven boundary segment
{
boundarySegment.clear();
boundarySegment.emplace_back(x,y);
} else
boundarySegment.clear();
}
if (isFirstBoundarySegment)
{
firstBoundarySegment.emplace_back(x,y);
firstBoundarySegmentEndsInEven = isEvenScanSegment;
isFirstBoundarySegment = false;
boundarySegment.emplace_back(x,y);
}
}
if (!isFirstBoundarySegment && isEvenScanSegment)
boundarySegment.push_back(p1);
p0 = p1;
}
if (!isFirstBoundarySegment && isEvenScanSegment && !firstBoundarySegmentEndsInEven)
{
for (unsigned int i = 1; i < firstBoundarySegment.size() ; i++)
addLine(firstBoundarySegment[i-1], firstBoundarySegment[i]);
}
}
addLineInfill(result, matrix, scanline_min_idx, lineSpacing, boundary, cutList, extrusionWidth);
return;
}
if (connected_zigzags && cut_list.size() == 1 && cut_list[0].size() <= 2)
{
return; // don't add connection if boundary already contains whole outline!
}
addLineInfill(result, rotation_matrix, scanline_min_idx, line_distance, boundary, cut_list, shift);
}
}//namespace cura
+211 -80
Ver Arquivo
@@ -3,100 +3,215 @@
#define INFILL_H
#include "utils/polygon.h"
#include "settings.h"
#include "settings/settings.h"
// #include "ZigzagConnectorProcessor.h"
#include "infill/ZigzagConnectorProcessor.h"
#include "infill/NoZigZagConnectorProcessor.h"
#include "infill/ActualZigzagConnectorProcessor.h"
#include "infill/ZigzagConnectorProcessorNoEndPieces.h"
#include "infill/ZigzagConnectorProcessorEndPieces.h"
#include "infill/ZigzagConnectorProcessorConnectedEndPieces.h"
#include "infill/ZigzagConnectorProcessorDisconnectedEndPieces.h"
#include "infill/SubDivCube.h"
#include "utils/intpoint.h"
#include "utils/AABB.h"
namespace cura
{
class Infill
class Infill
{
static constexpr int perimeter_gaps_extra_offset = 15; // extra offset so that the perimeter gaps aren't created everywhere due to rounding errors
EFillMethod pattern; //!< the space filling pattern of the infill to generate
const Polygons& in_outline; //!< a reference polygon for getting the actual area within which to generate infill (see outline_offset)
int outline_offset; //!< Offset from Infill::in_outline to get the actual area within which to generate infill
int infill_line_width; //!< The line width of the infill lines to generate
int line_distance; //!< The distance between two infill lines / polygons
int infill_overlap; //!< the distance by which to overlap with the actual area within which to generate infill
double fill_angle; //!< for linear infill types: the angle of the infill lines (or the angle of the grid)
int64_t z; //!< height of the layer for which we generate infill
int64_t shift; //!< shift of the scanlines in the direction perpendicular to the fill_angle
Polygons* perimeter_gaps; //!< (optional output) The areas in between consecutive insets when Concentric infill is used.
bool connected_zigzags; //!< (ZigZag) Whether endpieces of zigzag infill should be connected to the nearest infill line on both sides of the zigzag connector
bool use_endpieces; //!< (ZigZag) Whether to include endpieces: zigzag connector segments from one infill line to itself
static constexpr double one_over_sqrt_2 = 0.7071067811865475244008443621048490392848359376884740; //!< 1.0 / sqrt(2.0)
public:
/*!
* \warning If \p perimeter_gaps is given, then the difference between the \p in_outline
* and the polygons which result from offsetting it by the \p outline_offset
* and then expanding it again by half the \p infill_line_width
* is added to the \p perimeter_gaps
*
* \param[out] perimeter_gaps (optional output) The areas in between consecutive insets when Concentric infill is used.
*/
Infill(EFillMethod pattern
, const Polygons& in_outline
, int outline_offset
, int infill_line_width
, int line_distance
, int infill_overlap
, double fill_angle
, int64_t z
, int64_t shift
, Polygons* perimeter_gaps = nullptr
, bool connected_zigzags = false
, bool use_endpieces = false
)
: pattern(pattern)
, in_outline(in_outline)
, outline_offset(outline_offset)
, infill_line_width(infill_line_width)
, line_distance(line_distance)
, infill_overlap(infill_overlap)
, fill_angle(fill_angle)
, z(z)
, shift(shift)
, perimeter_gaps(perimeter_gaps)
, connected_zigzags(connected_zigzags)
, use_endpieces(use_endpieces)
{
EFillMethod pattern;
const Polygons& in_outline;
int outlineOffset;
bool avoidOverlappingPerimeters;
int extrusion_width;
int line_distance;
double infill_overlap;
double fill_angle;
bool connect_zigzags;
bool use_endPieces;
}
/*!
* Generate the infill.
*
* \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, const SliceMeshStorage* mesh = nullptr);
public:
Infill(EFillMethod pattern, const Polygons& in_outline, int outlineOffset, bool avoidOverlappingPerimeters, int extrusion_width, int line_distance, double infill_overlap, double fill_angle, bool connect_zigzags, bool use_endPieces)
: pattern(pattern)
, in_outline(in_outline)
, outlineOffset(outlineOffset)
, avoidOverlappingPerimeters(avoidOverlappingPerimeters)
, extrusion_width(extrusion_width)
, line_distance(line_distance)
, infill_overlap(infill_overlap)
, fill_angle(fill_angle)
, connect_zigzags(connect_zigzags)
, use_endPieces(use_endPieces)
{
}
void generate(Polygons& result_polygons, Polygons& result_lines, Polygons* in_between);
};
void generateInfill(EFillMethod pattern, const Polygons& in_outline, int outlineOffset, Polygons& result_polygons, Polygons& result_lines, Polygons* in_between, bool avoidOverlappingPerimeters, int extrusion_width, int line_distance, double infill_overlap, double fill_angle, bool connect_zigzags, bool use_endPieces);
void generateConcentricInfill(Polygons outline, Polygons& result, int inset_value);
void generateConcentricInfillDense(Polygons outline, Polygons& result, Polygons* in_between, int extrusionWidth, bool avoidOverlappingPerimeters);
void generateGridInfill(const Polygons& in_outline, int outlineOffset, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation);
void generateTriangleInfill(const Polygons& in_outline, int outlineOffset, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation);
private:
/*!
* Function which returns the scanline_idx for a given x coordinate
*
* For negative \p x this is different from simple division.
*
* \warning \p line_distance is assumed to be positive
*
* \param x the point to get the scansegment index for
* \param line_distance the width of the scan segments
*/
static inline int computeScanSegmentIdx(int x, int line_distance);
/*!
* generate lines within the area of \p in_outline, at regular intervals of \p lineSpacing
* Generate sparse concentric infill
*
* Also adds \ref Inifll::perimeter_gaps between \ref Infill::in_outline and the first wall
*
* \param result (output) The resulting polygons
* \param inset_value The offset between each consecutive two polygons
*/
void generateConcentricInfill(Polygons& result, int inset_value);
/*!
* Generate sparse concentric infill starting from a specific outer wall
* \param first_wall The outer wall from which to start
* \param result (output) The resulting polygons
* \param inset_value The offset between each consecutive two polygons
*/
void generateConcentricInfill(Polygons& first_wall, Polygons& result, int inset_value);
/*!
* Generate sparse concentric infill
* \param result (output) The resulting polygons
*/
void generateConcentric3DInfill(Polygons& result);
/*!
* Generate a rectangular grid of infill lines
* \param result (output) The resulting lines
*/
void generateGridInfill(Polygons& result);
/*!
* Generate a shifting triangular grid of infill lines, which combine with consecutive layers into a cubic pattern
* \param result (output) The resulting lines
*/
void generateCubicInfill(Polygons& result);
/*!
* Generate a double shifting square grid of infill lines, which combine with consecutive layers into a tetrahedral pattern
* \param result (output) The resulting lines
*/
void generateTetrahedralInfill(Polygons& result);
/*!
* Generate a triangular grid of infill lines
* \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, const SliceMeshStorage& mesh);
/*!
* Convert a mapping from scanline to line_segment-scanline-intersections (\p cut_list) into line segments, using the even-odd rule
* \param result (output) The resulting lines
* \param rotation_matrix The rotation matrix (un)applied to enforce the angle of the infill
* \param scanline_min_idx The lowest index of all scanlines crossing the polygon
* \param line_distance The distance between two lines which are in the same direction
* \param boundary The axis aligned boundary box within which the polygon is
* \param cut_list A mapping of each scanline to all y-coordinates (in the space transformed by rotation_matrix) where the polygons are crossing the scanline
* \param total_shift total shift of the scanlines in the direction perpendicular to the fill_angle.
*/
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
*
* idea:
* intersect a regular grid of 'scanlines' with the area inside \p in_outline
*
* we call the areas between two consecutive scanlines a 'scansegment'.
* Scansegment x is the area between scanline x and scanline x+1
*
* algorithm:
* 1) for each line segment of each polygon:
* store the intersections of that line segment with all scanlines in a mapping (vector of vectors) from scanline to intersections
* (zigzag): add boundary segments to result
* 2) for each scanline:
* sort the associated intersections
* and connect them using the even-odd rule
*
* \param result (output) The resulting lines
* \param line_distance The distance between two lines which are in the same direction
* \param fill_angle The angle of the generated lines
* \param extra_shift extra shift of the scanlines in the direction perpendicular to the fill_angle
*/
void generateLineInfill(const Polygons& in_outline, int outlineOffset, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation);
void generateZigZagInfill(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation, bool connect_zigzags, bool use_endPieces);
void generateLineInfill(Polygons& result, int line_distance, const double& fill_angle, int64_t extra_shift);
/*!
* Function for creating linear based infill types (Lines, ZigZag).
*
* This function implements the basic functionality of Infill::generateLineInfill (see doc of that function),
* but makes calls to a ZigzagConnectorProcessor which handles what to do with each line segment - scanline intersection.
*
* It is called only from Infill::generateLineinfill and Infill::generateZigZagInfill.
*
* \param outline_offset An offset from the reference polygon (Infill::in_outline) to get the actual outline within which to generate infill
* \param result (output) The resulting lines
* \param line_distance The distance between two lines which are in the same direction
* \param rotation_matrix The rotation matrix (un)applied to enforce the angle of the infill
* \param zigzag_connector_processor The processor used to generate zigzag connectors
* \param connected_zigzags Whether to connect the endpiece zigzag segments on both sides to the same infill line
* \param extra_shift extra shift of the scanlines in the direction perpendicular to the fill_angle
*/
void generateLinearBasedInfill(const int outline_offset, Polygons& result, const int line_distance, const PointMatrix& rotation_matrix, ZigzagConnectorProcessor& zigzag_connector_processor, const bool connected_zigzags, int64_t extra_shift);
/*!
* adapted from generateLineInfill(.)
*
* generate lines within the area of [in_outline], at regular intervals of [lineSpacing]
* generate lines within the area of [in_outline], at regular intervals of [line_distance]
* idea:
* intersect a regular grid of 'scanlines' with the area inside [in_outline]
* sigzag:
* intersect a regular grid of 'scanlines' with the area inside [in_outline] (see generateLineInfill)
* zigzag:
* include pieces of boundary, connecting the lines, forming an accordion like zigzag instead of separate lines |_|^|_|
*
* we call the areas between two consecutive scanlines a 'scansegment'
*
* algorithm:
* 1. for each line segment of each polygon:
* store the intersections of that line segment with all scanlines in a mapping (vector of vectors) from scanline to intersections
* (zigzag): add boundary segments to result
* 2. for each scanline:
* sort the associated intersections
* and connect them using the even-odd rule
*
* zigzag algorithm:
* while walking around (each) polygon (1.)
* if polygon intersects with even scanline
* start boundary segment (add each following segment to the [result])
* when polygon intersects with a scanline again
* stop boundary segment (stop adding segments to the [result])
* if polygon intersects with even scanline again (instead of odd)
* dont add the last line segment to the boundary (unless [connect_zigzags])
*
* Note that ZigZag consists of 3 types:
* - without endpieces
* - with disconnected endpieces
* - with connected endpieces
*
* <--
* ___
@@ -106,21 +221,37 @@ namespace cura
* -->
*
* ^ = even scanline
* ^ ^ no endpieces
*
* start boundary from even scanline! :D
*
*
* v disconnected end piece: leave out last line segment
* _____
* | | | ,
* | | | \ .
* | | | |
* |_____| |__/
*
* ^ ^ ^ scanlines
* ^ disconnected end piece
*
*
* v connected end piece
* ________
* | | | \ .
* | | | |
* |_____| |__/ .
*
* ^ ^ ^ scanlines
*
* \param result (output) The resulting lines
* \param line_distance The distance between two lines which are in the same direction
* \param fill_angle The angle of the generated lines
* \param connected_zigzags Whether to connect the endpiece zigzag segments on both sides to the same infill line
* \param use_endpieces Whether to include zigzag segments connecting a scanline to itself
*/
void generateZigZagIninfill_endPieces(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation, bool connect_zigzags);
void generateZigZagInfill(Polygons& result, const int line_distance, const double& fill_angle, const bool connected_zigzags, const bool use_endpieces);
};
void generateZigZagIninfill_noEndPieces(const Polygons& in_outline, Polygons& result, int extrusionWidth, int lineSpacing, double infillOverlap, double rotation);
}//namespace cura
#endif//INFILL_H
+47
Ver Arquivo
@@ -0,0 +1,47 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ACTUAL_ZIGZAG_CONNECTOR_PROCESSOR_H
#define INFILL_ACTUAL_ZIGZAG_CONNECTOR_PROCESSOR_H
#include "../utils/polygon.h"
#include "ZigzagConnectorProcessor.h"
#include "../utils/intpoint.h"
namespace cura
{
/*!
* In contrast to NoZigZagConnectorProcessor
*/
class ActualZigzagConnectorProcessor : public ZigzagConnectorProcessor
{
protected:
/*!
* The line segments belonging the zigzag connector to which the very first vertex belongs.
* This will be combined with the last handled zigzag_connector, which combine to a whole zigzag connector.
*
* Because the boundary polygon may start in in the middle of a zigzag connector,
*/
std::vector<Point> first_zigzag_connector;
/*!
* The currently built up zigzag connector (not the first/last) or end piece or discarded boundary segment
*/
std::vector<Point> zigzag_connector;
bool is_first_zigzag_connector; //!< Whether we're still in the first zigzag connector
bool first_zigzag_connector_ends_in_even_scanline; //!< Whether the first zigzag connector ends in an even scanline
bool last_scanline_is_even; //!< Whether the last seen scanline-boundary intersection was with an even scanline
ActualZigzagConnectorProcessor(const PointMatrix& rotation_matrix, Polygons& result)
: ZigzagConnectorProcessor(rotation_matrix, result)
, is_first_zigzag_connector(true)
, first_zigzag_connector_ends_in_even_scanline(true)
, last_scanline_is_even(false)
{
}
};
} // namespace cura
#endif // INFILL_ACTUAL_ZIGZAG_CONNECTOR_PROCESSOR_H
+25
Ver Arquivo
@@ -0,0 +1,25 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "NoZigZagConnectorProcessor.h"
namespace cura
{
void NoZigZagConnectorProcessor::registerVertex(const Point& vertex)
{
}
void NoZigZagConnectorProcessor::registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even)
{
}
void NoZigZagConnectorProcessor::registerPolyFinished()
{
}
} // namespace cura
+28
Ver Arquivo
@@ -0,0 +1,28 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H
#define INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H
#include "../utils/polygon.h"
#include "ZigzagConnectorProcessor.h"
namespace cura
{
class NoZigZagConnectorProcessor : public ZigzagConnectorProcessor
{
public:
NoZigZagConnectorProcessor(const PointMatrix& rotation_matrix, Polygons& result)
: ZigzagConnectorProcessor(rotation_matrix, result)
{
}
void registerVertex(const Point& vertex);
void registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even);
void registerPolyFinished();
};
} // namespace cura
#endif // INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H
+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
+152
Ver Arquivo
@@ -0,0 +1,152 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ZIGZAG_CONNECTOR_PROCESSOR_H
#define INFILL_ZIGZAG_CONNECTOR_PROCESSOR_H
#include "../utils/polygon.h"
namespace cura
{
/*!
* Processor class for processing the connections between lines which makes the infill a zigzag pattern.
*
* During the creation of the infill lines, calls are made to a ZigzagConnectorProcessor so that the zigzag connector segments are created
* at the same time as the lines are created.
*
* generate lines within the area of [in_outline], at regular intervals of [line_distance]
* idea:
* intersect a regular grid of 'scanlines' with the area inside [in_outline] (see generateLineInfill)
* zigzag:
* include pieces of boundary, connecting the lines, forming an accordion like zigzag instead of separate lines |_|^|_|
*
* we call the areas between two consecutive scanlines a 'scansegment'
*
* algorithm:
* 1. for each line segment of each polygon:
* store the intersections of that line segment with all scanlines in a mapping (vector of vectors) from scanline to intersections
* (zigzag): add boundary segments to result
* 2. for each scanline:
* sort the associated intersections
* and connect them using the even-odd rule
*
* zigzag algorithm:
* while walking around (each) polygon (1.)
* if polygon intersects with even scanline
* start boundary segment (add each following segment to the [result])
* when polygon intersects with a scanline again
* stop boundary segment (stop adding segments to the [result])
* if polygon intersects with even scanline again (instead of odd)
* dont add the last line segment to the boundary (unless [connected_zigzags])
*
* Note that ZigZag consists of 3 types:
* - without endpieces
* - with disconnected endpieces
* - with connected endpieces
*
* Each of these has a base class for which ZigzagConnectorProcessor is an ancestor.
* The inheritance structure is as such:
* ZigzagConnectorProcessor
* / \ .
* / \ .
* ActualZigzagConnectorProcessor NoZigZagConnectorProcessor
* / \ for lines infill .
* / \ .
* ZigzagConnectorProcessorEndPieces ZigzagConnectorProcessorNoEndPieces
* / \ for zigzag infill (without end pieces) .
* / \ .
* ZigzagConnectorProcessorConnectedEndPieces ZigzagConnectorProcessorDisconnectedEndPieces
* for zigzag support with normal endpieces for zigzag support with disconnected endpieces for more easy removability
*
* v v zigzag connectors
* <--
* :___: : < scanlines
* | | |
* | | | < infill lines along scanlines
* | |___|
* : : :
* --> winding order of polygon
*
* ^ = even scanline
* ^ ^ no endpieces
*
* start boundary from even scanline! :D
* include only a boundary segment if it starts in an even scanline and ends in an odd scanline
*
* ________
* | | | \ .
* | | | |
* |_____| |__/ .
*
* ^ ^ ^ scanlines
* ^ connected end piece
* include a boundary segment also if it starts in an odd scanline and ends odd,
* or starts in an even scanline and ends in an even scanline,
* but not when it starts in an odd and ends in an even scanline (see top left or bottom middle).
*
* _____
* | | | \ .
* | | | |
* |_____| |__/
*
* ^ ^ ^ scanlines
* ^ disconnected end piece
* Leave out the last line segment of the boundary polygon: from a vertex to the linesegment-scanline intersection.
*/
class ZigzagConnectorProcessor
{
protected:
const PointMatrix& rotation_matrix; //!< The rotation matrix used to enforce the infill angle
Polygons& result; //!< The result of the computation
virtual ~ZigzagConnectorProcessor()
{}
/*!
* Add a line to the result bu unapplying the rotation rotation_matrix.
*
* \param from The one end of the line segment
* \param to The other end of the line segment
*/
void addLine(Point from, Point to)
{
result.addLine(rotation_matrix.unapply(from), rotation_matrix.unapply(to));
}
/*!
* Basic constructor. Inheriting children should call this constructor.
*
* \param rotation_matrix The rotation matrix used to enforce the infill angle
* \param result The resulting line segments (Each line segment is a Polygon with 2 points)
*/
ZigzagConnectorProcessor(const PointMatrix& rotation_matrix, Polygons& result)
: rotation_matrix(rotation_matrix)
, result(result)
{}
public:
/*!
* Handle the next vertex on the outer boundary.
* \param vertex The vertex
*/
virtual void registerVertex(const Point& vertex) = 0;
/*!
* Handle the next intersection between a scanline and the outer boundary.
*
* \param intersection The intersection
* \param scanline_is_even Whether the scanline was even
*/
virtual void registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even) = 0;
/*!
* Handle the end of a polygon and prepare for the next.
* This function should reset all member variables.
*/
virtual void registerPolyFinished() = 0;
};
} // namespace cura
#endif // INFILL_ZIGZAG_CONNECTOR_PROCESSOR_H
@@ -0,0 +1,75 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "ZigzagConnectorProcessorConnectedEndPieces.h"
namespace cura
{
void ZigzagConnectorProcessorConnectedEndPieces::registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even)
{
bool previous_scanline_is_even = last_scanline_is_even;
last_scanline_is_even = scanline_is_even;
bool this_scanline_is_even = last_scanline_is_even;
if (is_first_zigzag_connector)
{
first_zigzag_connector.push_back(intersection);
first_zigzag_connector_ends_in_even_scanline = this_scanline_is_even;
is_first_zigzag_connector = false;
}
else
{
if (previous_scanline_is_even)
{ // when a boundary segment starts in an even scanline it is either a normal zigzag connector or an endpiece, so it should be included anyway
addLine(last_connector_point, intersection);
}
else if (!previous_scanline_is_even && !this_scanline_is_even) // if we end an odd boundary in an odd segment
{ // add whole zigzag_connector (including the just obtained point)
for (unsigned int point_idx = 1; point_idx < zigzag_connector.size(); point_idx++)
{
addLine(zigzag_connector[point_idx - 1], zigzag_connector[point_idx]);
}
addLine(zigzag_connector.back(), intersection);
zigzag_connector.clear();
}
}
zigzag_connector.clear(); // we're starting a new (odd) zigzag connector, so clear the old one
if (!this_scanline_is_even) // we are either in an end piece or an boundary segment starting in an odd scanline
{ // only when a boundary segment starts in an odd scanline it depends on whether it ends in an odd scanline for whether this segment should be included or not
zigzag_connector.push_back(intersection);
}
last_connector_point = intersection;
}
void ZigzagConnectorProcessorConnectedEndPieces::registerPolyFinished()
{
// write end segment if needed (first half of start/end-crossing segment)
if (!last_scanline_is_even && !first_zigzag_connector_ends_in_even_scanline)
{
for (unsigned int point_idx = 1; point_idx < zigzag_connector.size(); point_idx++)
{
addLine(zigzag_connector[point_idx - 1], zigzag_connector[point_idx]);
}
}
// write begin segment if needed (second half of start/end-crossing segment)
if (last_scanline_is_even || (!last_scanline_is_even && !first_zigzag_connector_ends_in_even_scanline)
|| is_first_zigzag_connector)
{
for (unsigned int point_idx = 1; point_idx < first_zigzag_connector.size(); point_idx++)
{
addLine(first_zigzag_connector[point_idx - 1], first_zigzag_connector[point_idx]);
}
}
// reset member variables
is_first_zigzag_connector = true;
first_zigzag_connector_ends_in_even_scanline = true;
last_scanline_is_even = false;
first_zigzag_connector.clear();
zigzag_connector.clear();
}
} // namespace cura
@@ -0,0 +1,27 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ZIGZAG_CONNECTOR_PROCESSOR_CONNECTED_END_PIECES_H
#define INFILL_ZIGZAG_CONNECTOR_PROCESSOR_CONNECTED_END_PIECES_H
#include "../utils/polygon.h"
#include "ZigzagConnectorProcessorEndPieces.h"
#include "../utils/intpoint.h"
namespace cura
{
class ZigzagConnectorProcessorConnectedEndPieces : public ZigzagConnectorProcessorEndPieces
{
public:
ZigzagConnectorProcessorConnectedEndPieces(const PointMatrix& rotation_matrix, Polygons& result)
: ZigzagConnectorProcessorEndPieces(rotation_matrix, result)
{
}
void registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even);
void registerPolyFinished();
};
} // namespace cura
#endif // INFILL_ZIGZAG_CONNECTOR_PROCESSOR_CONNECTED_END_PIECES_H
@@ -0,0 +1,79 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "ZigzagConnectorProcessorDisconnectedEndPieces.h"
namespace cura
{
void ZigzagConnectorProcessorDisconnectedEndPieces::registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even)
{
bool previous_scanline_is_even = last_scanline_is_even;
last_scanline_is_even = scanline_is_even;
bool this_scanline_is_even = last_scanline_is_even;
if (is_first_zigzag_connector)
{
first_zigzag_connector.push_back(intersection);
first_zigzag_connector_ends_in_even_scanline = this_scanline_is_even;
is_first_zigzag_connector = false;
}
else
{
if (previous_scanline_is_even && !this_scanline_is_even)
{ // if we left from an even scanline, but not if this is the line segment connecting that zigzag_connector to an even scanline
addLine(last_connector_point, intersection);
}
else if (!previous_scanline_is_even && !this_scanline_is_even) // if we end an odd boundary in an odd segment
{ // add whole oddBoundarySegment (including the just obtained point)
for (unsigned int point_idx = 1; point_idx < zigzag_connector.size(); point_idx++)
{
addLine(zigzag_connector[point_idx - 1], zigzag_connector[point_idx]);
}
// skip the last segment to the [intersection]
zigzag_connector.clear();
}
}
zigzag_connector.clear(); // we're starting a new (odd) zigzag connector, so clear the old one
if (!this_scanline_is_even) // we are either in an end piece or an boundary segment starting in an odd scanline
{ // only when a boundary segment starts in an odd scanline it depends on whether it ends in an odd scanline for whether this segment should be included or not
zigzag_connector.push_back(intersection);
}
last_connector_point = intersection;
}
void ZigzagConnectorProcessorDisconnectedEndPieces::registerPolyFinished()
{
// write end segment if needed (first half of start/end-crossing segment)
if (!last_scanline_is_even && !first_zigzag_connector_ends_in_even_scanline)
{
for (unsigned int point_idx = 1; point_idx < zigzag_connector.size(); point_idx++)
{
addLine(zigzag_connector[point_idx - 1], zigzag_connector[point_idx]);
}
}
// write begin segment if needed (second half of start/end-crossing segment)
if (last_scanline_is_even || is_first_zigzag_connector)
{
for (unsigned int point_idx = 1; point_idx < first_zigzag_connector.size() - 1; point_idx++) // -1 cause skipping very last line segment!
{
addLine(first_zigzag_connector[point_idx - 1], first_zigzag_connector[point_idx]);
}
}
// write very last line segment if needed
if (last_scanline_is_even && !first_zigzag_connector_ends_in_even_scanline)
{ // only add last element if boundary segment ends in odd scanline
addLine(first_zigzag_connector[first_zigzag_connector.size() - 2], first_zigzag_connector[first_zigzag_connector.size() - 1]);
}
// reset member variables
is_first_zigzag_connector = true;
first_zigzag_connector_ends_in_even_scanline = true;
last_scanline_is_even = false;
first_zigzag_connector.clear();
zigzag_connector.clear();
}
} // namespace cura
@@ -0,0 +1,26 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ZIGZAG_CONNECTOR_PROCESSOR_DISCONNECTED_END_PIECES_H
#define INFILL_ZIGZAG_CONNECTOR_PROCESSOR_DISCONNECTED_END_PIECES_H
#include "../utils/polygon.h"
#include "ZigzagConnectorProcessorEndPieces.h"
namespace cura
{
class ZigzagConnectorProcessorDisconnectedEndPieces : public ZigzagConnectorProcessorEndPieces
{
public:
ZigzagConnectorProcessorDisconnectedEndPieces(const PointMatrix& rotation_matrix, Polygons& result)
: ZigzagConnectorProcessorEndPieces(rotation_matrix, result)
{
}
void registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even);
void registerPolyFinished();
};
} // namespace cura
#endif // INFILL_ZIGZAG_CONNECTOR_PROCESSOR_DISCONNECTED_END_PIECES_H
@@ -0,0 +1,27 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "ZigzagConnectorProcessorEndPieces.h"
namespace cura
{
void ZigzagConnectorProcessorEndPieces::registerVertex(const Point& vertex)
{
if (is_first_zigzag_connector)
{
first_zigzag_connector.push_back(vertex);
}
else if (last_scanline_is_even)
{ // when a boundary segments starts in an even scanline it's either a normal zigzag connector or an endpiece to be included
// note that for ZigzagConnectorProcessorDisconnectedEndPieces only the last line segment from a boundary vertex to a scanline-boundary intersection is omitted
addLine(last_connector_point, vertex);
}
else
{ // it's yet unclear whether the line segment should be included, so we store it until we know
zigzag_connector.push_back(vertex);
}
last_connector_point = vertex;
}
} // namespace cura
@@ -0,0 +1,32 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ZIGZAG_CONNECTOR_PROCESSOR_END_PIECES_H
#define INFILL_ZIGZAG_CONNECTOR_PROCESSOR_END_PIECES_H
#include "../utils/polygon.h"
#include "ActualZigzagConnectorProcessor.h"
namespace cura
{
class ZigzagConnectorProcessorEndPieces : public ActualZigzagConnectorProcessor
{
protected:
Point last_connector_point; //!< last registered boundary vertex or scanline-coundary intersection
ZigzagConnectorProcessorEndPieces(const PointMatrix& rotation_matrix, Polygons& result)
: ActualZigzagConnectorProcessor(rotation_matrix, result)
, last_connector_point(0,0)
{
}
public:
void registerVertex(const Point& vertex);
};
} // namespace cura
#endif // INFILL_ZIGZAG_CONNECTOR_PROCESSOR_END_PIECES_H
@@ -0,0 +1,72 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#include "ZigzagConnectorProcessorNoEndPieces.h"
namespace cura
{
void ZigzagConnectorProcessorNoEndPieces::registerVertex(const Point& vertex)
{
if (is_first_zigzag_connector)
{
first_zigzag_connector.push_back(vertex);
}
else if (last_scanline_is_even)
{
zigzag_connector.push_back(vertex);
}
}
void ZigzagConnectorProcessorNoEndPieces::registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even)
{
bool previous_scanline_is_even = last_scanline_is_even;
last_scanline_is_even = scanline_is_even;
bool this_scanline_is_even = last_scanline_is_even; // for conceptual clarity
if (is_first_zigzag_connector)
{
first_zigzag_connector.push_back(intersection);
first_zigzag_connector_ends_in_even_scanline = this_scanline_is_even;
is_first_zigzag_connector = false;
}
else
{
if (previous_scanline_is_even && !this_scanline_is_even)
{ // add whole zigzag_connector (including the just obtained point)
for (unsigned int point_idx = 1; point_idx < zigzag_connector.size(); point_idx++)
{
addLine(zigzag_connector[point_idx - 1], zigzag_connector[point_idx]);
}
addLine(zigzag_connector.back(), intersection);
zigzag_connector.clear();
}
}
zigzag_connector.clear(); // we're starting a new zigzag connector, so clear the old one
if (this_scanline_is_even) // only boundary segments starting in an even segment are considered
{
zigzag_connector.push_back(intersection);
}
}
void ZigzagConnectorProcessorNoEndPieces::registerPolyFinished()
{
if (!is_first_zigzag_connector && last_scanline_is_even && !first_zigzag_connector_ends_in_even_scanline)
{ // only if it's a normal zigzag connector; not when the whole boundary didn't cross any scanlines
for (unsigned int point_idx = 1; point_idx < first_zigzag_connector.size() ; point_idx++)
{
addLine(first_zigzag_connector[point_idx - 1], first_zigzag_connector[point_idx]);
}
}
// reset member variables
is_first_zigzag_connector = true;
first_zigzag_connector_ends_in_even_scanline = true;
last_scanline_is_even = false;
first_zigzag_connector.clear();
zigzag_connector.clear();
}
} // namespace cura
@@ -0,0 +1,29 @@
/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
#ifndef INFILL_ZIGZAG_CONNECTOR_PROCESSOR_NO_ENDPIECES_H
#define INFILL_ZIGZAG_CONNECTOR_PROCESSOR_NO_ENDPIECES_H
#include "../utils/polygon.h"
#include "ActualZigzagConnectorProcessor.h"
#include "../utils/intpoint.h"
namespace cura
{
class ZigzagConnectorProcessorNoEndPieces : public ActualZigzagConnectorProcessor
{
public:
ZigzagConnectorProcessorNoEndPieces(const PointMatrix& rotation_matrix, Polygons& result)
: ActualZigzagConnectorProcessor(rotation_matrix, result)
{
}
void registerVertex(const Point& vertex);
void registerScanlineSegmentIntersection(const Point& intersection, bool scanline_is_even);
void registerPolyFinished();
};
} // namespace cura
#endif // INFILL_ZIGZAG_CONNECTOR_PROCESSOR_NO_ENDPIECES_H
-74
Ver Arquivo
@@ -1,74 +0,0 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "inset.h"
#include "utils/polygonUtils.h"
namespace cura {
void generateInsets(SliceLayerPart* part, int nozzle_width, int line_width_0, int line_width_x, int insetCount, bool avoidOverlappingPerimeters_0, bool avoidOverlappingPerimeters)
{
if (insetCount == 0)
{
part->insets.push_back(part->outline);
return;
}
for(int i=0; i<insetCount; i++)
{
part->insets.push_back(Polygons());
if (i == 0)
{
if (line_width_0 < nozzle_width)
{
PolygonUtils::offsetSafe(part->outline, - nozzle_width/2, line_width_0, part->insets[0], avoidOverlappingPerimeters_0);
}
else
{
PolygonUtils::offsetSafe(part->outline, - line_width_0/2, line_width_0, part->insets[0], avoidOverlappingPerimeters_0);
}
} else if (i == 1)
{
if (line_width_0 < nozzle_width)
{
int offset_from_first_boundary_for_edge_of_outer_wall = -nozzle_width/2;
// ideally this /\ should be: nozzle_width/2 - line_width_0; however, factually, the nozzle will fill up part of the perimeter gaps
PolygonUtils::offsetSafe(part->insets[0], nozzle_width/2 - line_width_0 - line_width_x/2, offset_from_first_boundary_for_edge_of_outer_wall, line_width_x, part->insets[1], &part->perimeterGaps, avoidOverlappingPerimeters);
}
else
{
PolygonUtils::offsetSafe(part->insets[0], -line_width_0/2 - line_width_x/2, -line_width_0/2, line_width_x, part->insets[1], &part->perimeterGaps, avoidOverlappingPerimeters);
}
} else
{
PolygonUtils::offsetExtrusionWidth(part->insets[i-1], true, line_width_x, part->insets[i], &part->perimeterGaps, avoidOverlappingPerimeters);
}
//Finally optimize all the polygons. Every point removed saves time in the long run.
part->insets[i].simplify();
if (part->insets[i].size() < 1)
{
part->insets.pop_back();
break;
}
}
}
void generateInsets(SliceLayer* layer, int nozzle_width, int line_width_0, int line_width_x, int insetCount, bool avoidOverlappingPerimeters_0, bool avoidOverlappingPerimeters)
{
for(unsigned int partNr = 0; partNr < layer->parts.size(); partNr++)
{
generateInsets(&layer->parts[partNr], nozzle_width, line_width_0, line_width_x, insetCount, avoidOverlappingPerimeters_0, avoidOverlappingPerimeters);
}
//Remove the parts which did not generate an inset. As these parts are too small to print,
// and later code can now assume that there is always minimal 1 inset line.
for(unsigned int partNr = 0; partNr < layer->parts.size(); partNr++)
{
if (layer->parts[partNr].insets.size() < 1)
{
layer->parts.erase(layer->parts.begin() + partNr);
partNr -= 1;
}
}
}
}//namespace cura
-41
Ver Arquivo
@@ -1,41 +0,0 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef INSET_H
#define INSET_H
#include "sliceDataStorage.h"
namespace cura
{
/*!
* Generates the insets / perimeters for a single layer part.
*
* \param part The part for which to generate the insets.
* \param nozzle_width The diameter of the hole in the nozzle
* \param line_width_0 line width of the outer wall
* \param line_width_x line width of other walls
* \param insetCount The number of insets to to generate
* \param avoidOverlappingPerimeters_0 Whether to remove the parts of the first perimeters where it have overlap with itself (and store the gaps thus created in the \p storage)
* \param avoidOverlappingPerimeters Whether to remove the parts of two consecutive perimeters where they have overlap (and store the gaps thus created in the \p part)
*/
void generateInsets(SliceLayerPart* part, int nozzle_width, int line_width_0, int line_width_x, int insetCount, bool avoidOverlappingPerimeters_0, bool avoidOverlappingPerimeters);
/*!
* Generates the insets / perimeters for all parts in a layer.
*
* Note that the second inset gets offsetted by \p line_width_0 instead of the first,
* which leads to better results for a smaller \p line_width_0 than \p line_width_x and when printing the outer wall last.
*
* \param layer The layer for which to generate the insets.
* \param nozzle_width The diameter of the hole in the nozzle
* \param line_width_0 line width of the outer wall
* \param line_width_x line width of other walls
* \param insetCount The number of insets to to generate
* \param avoidOverlappingPerimeters_0 Whether to remove the parts of the first perimeters where it have overlap with itself (and store the gaps thus created in the \p storage)
* \param avoidOverlappingPerimeters Whether to remove the parts of two consecutive perimeters where they have overlap (and store the gaps thus created in the \p part)
*/
void generateInsets(SliceLayer* layer, int nozzle_width, int line_width_0, int line_width_x, int insetCount, bool avoidOverlappingPerimeters_0, bool avoidOverlappingPerimeters);
}//namespace cura
#endif//INSET_H
+14 -12
Ver Arquivo
@@ -1,8 +1,8 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "layerPart.h"
#include "settings.h"
#include "Progress.h"
#include "settings/settings.h"
#include "progress/Progress.h"
#include "utils/SVG.h" // debug output
@@ -26,15 +26,15 @@ void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, bool uni
if (union_all_remove_holes)
{
for(unsigned int i=0; i<layer->polygonList.size(); i++)
for(unsigned int i=0; i<layer->polygons.size(); i++)
{
if (layer->polygonList[i].orientation())
layer->polygonList[i].reverse();
if (layer->polygons[i].orientation())
layer->polygons[i].reverse();
}
}
std::vector<PolygonsPart> result;
result = layer->polygonList.splitIntoParts(union_layers || union_all_remove_holes);
result = layer->polygons.splitIntoParts(union_layers || union_all_remove_holes);
for(unsigned int i=0; i<result.size(); i++)
{
storageLayer.parts.emplace_back();
@@ -42,14 +42,16 @@ void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, bool uni
storageLayer.parts[i].boundaryBox.calculate(storageLayer.parts[i].outline);
}
}
void createLayerParts(SliceMeshStorage& storage, Slicer* slicer, bool union_layers, bool union_all_remove_holes)
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++)
{
storage.layers.push_back(SliceLayer());
storage.layers[layer_nr].sliceZ = slicer->layers[layer_nr].z;
storage.layers[layer_nr].printZ = slicer->layers[layer_nr].z;
createLayerWithParts(storage.layers[layer_nr], &slicer->layers[layer_nr], union_layers, union_all_remove_holes);
mesh.layers[layer_nr].sliceZ = slicer->layers[layer_nr].z;
mesh.layers[layer_nr].printZ = slicer->layers[layer_nr].z;
createLayerWithParts(mesh.layers[layer_nr], &slicer->layers[layer_nr], union_layers, union_all_remove_holes);
}
}
+2 -2
Ver Arquivo
@@ -22,9 +22,9 @@ namespace cura {
void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, bool union_layers, bool union_all_remove_holes);
void createLayerParts(SliceMeshStorage& storage, Slicer* slicer, bool union_layers, bool union_all_remove_holes);
void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer, bool union_layers, bool union_all_remove_holes);
void layerparts2HTML(SliceDataStorage& storage, const char* filename, bool all_layers = true, int layer_nr = -1);
void layerparts2HTML(SliceDataStorage& mesh, const char* filename, bool all_layers = true, int layer_nr = -1);
}//namespace cura
+163 -59
Ver Arquivo
@@ -16,36 +16,43 @@
#include "utils/string.h"
#include "FffProcessor.h"
#include "settingRegistry.h"
#include "settings/SettingRegistry.h"
#include "settings/SettingsToGV.h"
#include <omp.h> // omp_get_num_threads
namespace cura
{
void print_usage()
{
cura::logError("\n");
cura::logError("usage:\n");
cura::logError("CuraEngine help\n");
cura::logError("\tShow this help message\n");
cura::logError("\n");
cura::logError("CuraEngine connect <host>[:<port>] [-j <settings.json>]\n");
cura::logError(" --connect <host>[:<port>]\n\tConnect to <host> via a command socket, \n\tinstead of passing information via the command line\n");
cura::logError(" -j\n\tLoad settings.json file to register all settings and their defaults\n");
cura::logError("\n");
cura::logError("CuraEngine slice [-v] [-p] [-j <settings.json>] [-s <settingkey>=<value>] [-g] [-e] [-o <output.gcode>] [-l <model.stl>] [--next]\n");
cura::logError(" -v\n\tIncrease the verbose level (show log messages).\n");
cura::logError(" -p\n\tLog progress information.\n");
cura::logError(" -j\n\tLoad settings.json file to register all settings and their defaults.\n");
cura::logError(" -s <setting>=<value>\n\tSet a setting to a value for the last supplied object, \n\textruder train, or general settings.\n");
cura::logError(" -l <model_file>\n\tLoad an STL model. \n");
cura::logError(" -g\n\tSwitch setting focus to the current mesh group only.\n\tUsed for one-at-a-time printing.\n");
cura::logError(" -e\n\tAdd a new extruder train.\n");
cura::logError(" --next\n\tGenerate gcode for the previously supplied mesh group and append that to \n\tthe gcode of further models for one-at-a-time printing.\n");
cura::logError(" -o <output_file>\n\tSpecify a file to which to write the generated gcode.\n");
cura::logError("\n");
cura::logError("The settings are appended to the last supplied object:\n");
cura::logError("CuraEngine slice [general settings] \n\t-g [current group settings] \n\t-e [extruder train settings] \n\t-l obj_inheriting_from_last_extruder_train.stl [object settings] \n\t--next [next group settings]\n\t... etc.\n");
cura::logError("\n");
logAlways("\n");
logAlways("usage:\n");
logAlways("CuraEngine help\n");
logAlways("\tShow this help message\n");
logAlways("\n");
logAlways("CuraEngine connect <host>[:<port>] [-j <settings.def.json>]\n");
logAlways(" --connect <host>[:<port>]\n\tConnect to <host> via a command socket, \n\tinstead of passing information via the command line\n");
logAlways(" -j<settings.def.json>\n\tLoad settings.json file to register all settings and their defaults\n");
logAlways(" -v\n\tIncrease the verbose level (show log messages).\n");
logAlways("\n");
logAlways("CuraEngine slice [-v] [-p] [-j <settings.json>] [-s <settingkey>=<value>] [-g] [-e<extruder_nr>] [-o <output.gcode>] [-l <model.stl>] [--next]\n");
logAlways(" -v\n\tIncrease the verbose level (show log messages).\n");
logAlways(" -p\n\tLog progress information.\n");
logAlways(" -j\n\tLoad settings.def.json file to register all settings and their defaults.\n");
logAlways(" -s <setting>=<value>\n\tSet a setting to a value for the last supplied object, \n\textruder train, or general settings.\n");
logAlways(" -l <model_file>\n\tLoad an STL model. \n");
logAlways(" -g\n\tSwitch setting focus to the current mesh group only.\n\tUsed for one-at-a-time printing.\n");
logAlways(" -e<extruder_nr>\n\tSwitch setting focus to the extruder train with the given number.\n");
logAlways(" --next\n\tGenerate gcode for the previously supplied mesh group and append that to \n\tthe gcode of further models for one-at-a-time printing.\n");
logAlways(" -o <output_file>\n\tSpecify a file to which to write the generated gcode.\n");
logAlways("\n");
logAlways("The settings are appended to the last supplied object:\n");
logAlways("CuraEngine slice [general settings] \n\t-g [current group settings] \n\t-e0 [extruder train 0 settings] \n\t-l obj_inheriting_from_last_extruder_train.stl [object settings] \n\t--next [next group settings]\n\t... etc.\n");
logAlways("\n");
logAlways("In order to load machine definitions from custom locations, you need to create the environment variable CURA_ENGINE_SEARCH_PATH, which should contain all search paths delimited by a (semi-)colon.\n");
logAlways("\n");
}
//Signal handler for a "floating point exception", which can also be integer division by zero errors.
@@ -66,10 +73,10 @@ void print_call(int argc, char **argv)
void connect(int argc, char **argv)
{
CommandSocket* commandSocket = new CommandSocket();
std::string ip;
int port = 49674;
// parse ip port
std::string ip_port(argv[2]);
if (ip_port.find(':') != std::string::npos)
{
@@ -77,7 +84,6 @@ void connect(int argc, char **argv)
port = std::stoi(ip_port.substr(ip_port.find(':') + 1).data());
}
for(int argn = 3; argn < argc; argn++)
{
char* str = argv[argn];
@@ -92,9 +98,10 @@ void connect(int argc, char **argv)
break;
case 'j':
argn++;
if (SettingRegistry::getInstance()->loadJSONsettings(argv[argn]))
if (SettingRegistry::getInstance()->loadJSONsettings(argv[argn], FffProcessor::getInstance()))
{
cura::logError("ERROR: Failed to load json file: %s\n", argv[argn]);
cura::logError("Failed to load json file: %s\n", argv[argn]);
std::exit(1);
}
break;
default:
@@ -106,8 +113,9 @@ void connect(int argc, char **argv)
}
}
}
commandSocket->connect(ip, port);
CommandSocket::instantiate();
CommandSocket::getInstance()->connect(ip, port);
}
void slice(int argc, char **argv)
@@ -120,7 +128,8 @@ void slice(int argc, char **argv)
int extruder_train_nr = 0;
SettingsBase* last_extruder_train = meshgroup->createExtruderTrain(0);
SettingsBase* last_extruder_train = nullptr;
// extruder defaults cannot be loaded yet cause no json has been parsed
SettingsBase* last_settings_object = FffProcessor::getInstance();
for(int argn = 2; argn < argc; argn++)
{
@@ -134,13 +143,15 @@ void slice(int argc, char **argv)
try {
//Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception.
// Only ClipperLib currently throws exceptions. And only in case that it makes an internal error.
meshgroup->finalize();
log("Loaded from disk in %5.3fs\n", FffProcessor::getInstance()->time_keeper.restart());
for (int extruder_nr = 0; extruder_nr < FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count"); extruder_nr++)
{ // initialize remaining extruder trains and load the defaults
meshgroup->getExtruderTrain(extruder_nr)->setExtruderTrainDefaults(extruder_nr); // create new extruder train objects or use already existing ones
meshgroup->createExtruderTrain(extruder_nr); // create new extruder train objects or use already existing ones
}
meshgroup->finalize();
//start slicing
FffProcessor::getInstance()->processMeshGroup(meshgroup);
@@ -148,12 +159,13 @@ void slice(int argc, char **argv)
FffProcessor::getInstance()->time_keeper.restart();
delete meshgroup;
meshgroup = new MeshGroup(FffProcessor::getInstance());
last_extruder_train = meshgroup->createExtruderTrain(0);
last_settings_object = meshgroup;
}catch(...){
cura::logError("Unknown exception\n");
exit(1);
}
break;
}else{
cura::logError("Unknown option: %s\n", str);
}
@@ -170,9 +182,10 @@ void slice(int argc, char **argv)
break;
case 'j':
argn++;
if (SettingRegistry::getInstance()->loadJSONsettings(argv[argn]))
if (SettingRegistry::getInstance()->loadJSONsettings(argv[argn], last_settings_object))
{
cura::logError("ERROR: Failed to load json file: %s\n", argv[argn]);
cura::logError("Failed to load json file: %s\n", argv[argn]);
std::exit(1);
}
break;
case 'e':
@@ -185,11 +198,17 @@ void slice(int argc, char **argv)
argn++;
log("Loading %s from disk...\n", argv[argn]);
// transformation = // TODO: get a transformation from somewhere
transformation = last_settings_object->getSettingAsPointMatrix("mesh_rotation_matrix"); // the transformation applied to a model when loaded
if (!last_extruder_train)
{
last_extruder_train = meshgroup->createExtruderTrain(0); // assume a json has already been provided on the command line
}
if (!loadMeshIntoMeshGroup(meshgroup, argv[argn], transformation, last_extruder_train))
{
logError("Failed to load model: %s\n", argv[argn]);
std::exit(1);
}
else
{
@@ -239,9 +258,10 @@ void slice(int argc, char **argv)
}
}
for (extruder_train_nr = 0; extruder_train_nr < FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count"); extruder_train_nr++)
int extruder_count = FffProcessor::getInstance()->getSettingAsCount("machine_extruder_count");
for (extruder_train_nr = 0; extruder_train_nr < extruder_count; extruder_train_nr++)
{ // initialize remaining extruder trains and load the defaults
meshgroup->createExtruderTrain(extruder_train_nr)->setExtruderTrainDefaults(extruder_train_nr); // create new extruder train objects or use already existing ones
meshgroup->createExtruderTrain(extruder_train_nr); // create new extruder train objects or use already existing ones
}
@@ -286,23 +306,23 @@ int main(int argc, char **argv)
Progress::init();
logCopyright("\n");
logCopyright("Cura_SteamEngine version %s\n", VERSION);
logCopyright("Copyright (C) 2014 David Braam\n");
logCopyright("\n");
logCopyright("This program is free software: you can redistribute it and/or modify\n");
logCopyright("it under the terms of the GNU Affero General Public License as published by\n");
logCopyright("the Free Software Foundation, either version 3 of the License, or\n");
logCopyright("(at your option) any later version.\n");
logCopyright("\n");
logCopyright("This program is distributed in the hope that it will be useful,\n");
logCopyright("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
logCopyright("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
logCopyright("GNU Affero General Public License for more details.\n");
logCopyright("\n");
logCopyright("You should have received a copy of the GNU Affero General Public License\n");
logCopyright("along with this program. If not, see <http://www.gnu.org/licenses/>.\n");
std::cerr << std::boolalpha;
logAlways("\n");
logAlways("Cura_SteamEngine version %s\n", VERSION);
logAlways("Copyright (C) 2014 David Braam\n");
logAlways("\n");
logAlways("This program is free software: you can redistribute it and/or modify\n");
logAlways("it under the terms of the GNU Affero General Public License as published by\n");
logAlways("the Free Software Foundation, either version 3 of the License, or\n");
logAlways("(at your option) any later version.\n");
logAlways("\n");
logAlways("This program is distributed in the hope that it will be useful,\n");
logAlways("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
logAlways("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
logAlways("GNU Affero General Public License for more details.\n");
logAlways("\n");
logAlways("You should have received a copy of the GNU Affero General Public License\n");
logAlways("along with this program. If not, see <http://www.gnu.org/licenses/>.\n");
if (argc < 2)
@@ -310,7 +330,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);
@@ -324,6 +356,78 @@ int main(int argc, char **argv)
print_usage();
exit(0);
}
else if (stringcasecompare(argv[1], "analyse") == 0)
{ // CuraEngine analyse [json] [output.gv] [engine_settings] -[p|i|e|w]
// p = show parent-child relations
// i = show inheritance function
// e = show error functions
// w = show warning functions
// dot refl_ff.gv -Tpng > rafl_ff_dotted.png
// see meta/HOWTO.txt
bool parent_child_viz = false;
bool inherit_viz = false;
bool warning_viz = false;
bool error_viz = false;
bool global_only_viz = false;
if (argc >= 6)
{
char* str = argv[5];
if (str[0] == '-')
{
for(str++; *str; str++)
{
switch(*str)
{
case 'p':
parent_child_viz = true;
break;
case 'i':
inherit_viz = true;
break;
case 'e':
error_viz = true;
break;
case 'w':
warning_viz = true;
break;
case 'g':
global_only_viz = true;
break;
default:
cura::logError("Unknown option: %c\n", *str);
print_call(argc, argv);
print_usage();
break;
}
}
}
}
else
{
cura::log("\n");
cura::log("usage:\n");
cura::log("CuraEngine analyse <fdmPrinter.def.json> <output.gv> <engine_settings_list> -[p|i|e|w]\n");
cura::log("\tGenerate a grpah to visualize the setting inheritance structure.\n");
cura::log("\t<fdmPrinter.def.json>\n\tThe base seting definitions file.\n");
cura::log("\t<output.gv>\n\tThe output file.\n");
cura::log("\t<engine_settings_list>\n\tA text file with all setting keys used in the engine, separated by newlines.\n");
cura::log("\t-[p|i|e|w]\n\tOptions for what to include in the visualization\n");
cura::log("\t\tp\tVisualize the parent-child relationship.\n");
cura::log("\t\ti\tVisualize inheritance function relationships.\n");
cura::log("\t\te\tVisualize (max/min) error function relationships.\n");
cura::log("\t\tw\tVisualize (max/min) warning function relationships.\n");
cura::log("\n");
}
SettingsToGv gv_out(argv[3], argv[4], parent_child_viz, inherit_viz, error_viz, warning_viz, global_only_viz);
if (gv_out.generate(std::string(argv[2])))
{
cura::logError("Failed to analyse json file: %s\n", argv[2]);
}
exit(0);
}
else
{
cura::logError("Unknown command: %s\n", argv[1]);
+28 -18
Ver Arquivo
@@ -5,7 +5,11 @@ namespace cura
{
const int vertex_meld_distance = MM2INT(0.03);
static inline uint32_t pointHash(Point3& p)
/*!
* returns a hash for the location, but first divides by the vertex_meld_distance,
* so that any point within a box of vertex_meld_distance by vertex_meld_distance would get mapped to the same hash.
*/
static inline uint32_t pointHash(const Point3& p)
{
return ((p.x + vertex_meld_distance/2) / vertex_meld_distance) ^ (((p.y + vertex_meld_distance/2) / vertex_meld_distance) << 10) ^ (((p.z + vertex_meld_distance/2) / vertex_meld_distance) << 20);
}
@@ -49,22 +53,35 @@ void Mesh::finish()
for(unsigned int i=0; i<faces.size(); i++)
{
MeshFace& face = faces[i];
face.connected_face_index[0] = getFaceIdxWithPoints(face.vertex_index[0], face.vertex_index[1], i); // faces are connected via the outside
face.connected_face_index[1] = getFaceIdxWithPoints(face.vertex_index[1], face.vertex_index[2], i);
face.connected_face_index[2] = getFaceIdxWithPoints(face.vertex_index[2], face.vertex_index[0], i);
// faces are connected via the outside
face.connected_face_index[0] = getFaceIdxWithPoints(face.vertex_index[0], face.vertex_index[1], i, face.vertex_index[2]);
face.connected_face_index[1] = getFaceIdxWithPoints(face.vertex_index[1], face.vertex_index[2], i, face.vertex_index[0]);
face.connected_face_index[2] = getFaceIdxWithPoints(face.vertex_index[2], face.vertex_index[0], i, face.vertex_index[1]);
}
}
Point3 Mesh::min()
Point3 Mesh::min() const
{
return aabb.min;
}
Point3 Mesh::max()
Point3 Mesh::max() const
{
return aabb.max;
}
AABB3D Mesh::getAABB() const
{
return aabb;
}
void Mesh::expandXY(int64_t offset)
{
if (offset)
{
aabb.expandXY(offset);
}
}
int Mesh::findIndexOfVertex(Point3& v)
int Mesh::findIndexOfVertex(const Point3& v)
{
uint32_t hash = pointHash(v);
@@ -107,17 +124,13 @@ See <a href="http://stackoverflow.com/questions/14066933/direct-way-of-computing
*/
int Mesh::getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx)
int Mesh::getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx, int notFaceVertexIdx) const
{
std::vector<int> candidateFaces; // in case more than two faces meet at an edge, multiple candidates are generated
int notFaceVertexIdx = -1; // index of the third vertex of the face corresponding to notFaceIdx
for(int f : vertices[idx0].connected_faces) // search through all faces connected to the first vertex and find those that are also connected to the second
{
if (f == notFaceIdx)
{
for (int i = 0; i<3; i++) // find the vertex which is not idx0 or idx1
if (faces[f].vertex_index[i] != idx0 && faces[f].vertex_index[i] != idx1)
notFaceVertexIdx = faces[f].vertex_index[i];
continue;
}
if ( faces[f].vertex_index[0] == idx1 // && faces[f].vertex_index[1] == idx0 // next face should have the right direction!
@@ -127,12 +140,10 @@ int Mesh::getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx)
}
if (candidateFaces.size() == 0) { cura::logError("Couldn't find face connected to face %i.\n", notFaceIdx); return -1; }
if (candidateFaces.size() == 0) { cura::logWarning("Couldn't find face connected to face %i.\n", notFaceIdx); return -1; }
if (candidateFaces.size() == 1) { return candidateFaces[0]; }
if (notFaceVertexIdx < 0) { cura::logError("Couldn't find third point on face %i.\n", notFaceIdx); return -1; }
if (candidateFaces.size() % 2 == 0) cura::log("Warning! Edge with uneven number of faces connecting it!(%i)\n", candidateFaces.size()+1);
FPoint3 vn = vertices[idx1].p - vertices[idx0].p;
@@ -167,7 +178,6 @@ int Mesh::getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx)
if (angle == 0)
{
cura::log("Warning! Overlapping faces: face %i and face %i.\n", notFaceIdx, candidateFace);
std::cerr<< n.vSize() <<"; "<<n1.vSize()<<";"<<n0.vSize() <<std::endl;
}
if (angle < smallestAngle)
{
@@ -175,8 +185,8 @@ int Mesh::getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx)
bestIdx = candidateFace;
}
}
if (bestIdx < 0) cura::logError("Couldn't find face connected to face %i.\n", notFaceIdx);
if (bestIdx < 0) cura::logWarning("Couldn't find face connected to face %i.\n", notFaceIdx);
return bestIdx;
}
}//namespace cura
}//namespace cura
+18 -8
Ver Arquivo
@@ -1,8 +1,8 @@
#ifndef MESH_H
#define MESH_H
#include "settings.h"
#include "utils/AABB.h"
#include "settings/settings.h"
#include "utils/AABB3D.h"
namespace cura
{
@@ -69,8 +69,10 @@ public:
void clear(); //!< clears all data
void finish(); //!< complete the model : set the connected_face_index fields of the faces.
Point3 min(); //!< min (in x,y and z) vertex of the bounding box
Point3 max(); //!< max (in x,y and z) vertex of the bounding box
Point3 min() const; //!< min (in x,y and z) vertex of the bounding box
Point3 max() const; //!< max (in x,y and z) vertex of the bounding box
AABB3D getAABB() const; //!< Get the axis aligned bounding box
void expandXY(int64_t offset); //!< Register applied horizontal expansion in the AABB
/*!
* Offset the whole mesh (all vertices and the bounding box).
@@ -85,12 +87,20 @@ public:
}
private:
int findIndexOfVertex(Point3& v); //!< find index of vertex close to the given point, or create a new vertex and return its index.
int findIndexOfVertex(const Point3& v); //!< find index of vertex close to the given point, or create a new vertex and return its index.
/*!
Get the index of the face connected to the face with index \p notFaceIdx, via vertices \p idx0 and \p idx1.
In case multiple faces connect with the same edge, return the next counter-clockwise face when viewing from \p idx1 to \p idx0.
* Get the index of the face connected to the face with index \p notFaceIdx, via vertices \p idx0 and \p idx1.
*
* In case multiple faces connect with the same edge, return the next counter-clockwise face when viewing from \p idx1 to \p idx0.
*
* \param idx0 the first vertex index
* \param idx1 the second vertex index
* \param notFaceIdx the index of a face which shouldn't be returned
* \param notFaceVertexIdx should be the third vertex of face \p notFaceIdx.
* \return the face index of a face sharing the edge from \p idx0 to \p idx1
*/
int getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx);
int getFaceIdxWithPoints(int idx0, int idx1, int notFaceIdx, int notFaceVertexIdx) const;
};
}//namespace cura
+69 -20
Ver Arquivo
@@ -3,18 +3,45 @@
namespace cura
{
void carveMultipleVolumes(std::vector<Slicer*> &volumes)
void carveMultipleVolumes(std::vector<Slicer*> &volumes, bool alternate_carve_order)
{
//Go trough all the volumes, and remove the previous volume outlines from our own outline, so we never have overlapped areas.
for(unsigned int idx=0; idx < volumes.size(); idx++)
for (unsigned int volume_1_idx = 1; volume_1_idx < volumes.size(); volume_1_idx++)
{
for(unsigned int idx2=0; idx2<idx; idx2++)
Slicer& volume_1 = *volumes[volume_1_idx];
if (volume_1.mesh->getSettingBoolean("infill_mesh")
|| volume_1.mesh->getSettingBoolean("anti_overhang_mesh")
|| volume_1.mesh->getSettingBoolean("support_mesh")
)
{
for(unsigned int layerNr=0; layerNr < volumes[idx]->layers.size(); layerNr++)
continue;
}
for (unsigned int volume_2_idx = 0; volume_2_idx < volume_1_idx; volume_2_idx++)
{
Slicer& volume_2 = *volumes[volume_2_idx];
if (volume_2.mesh->getSettingBoolean("infill_mesh")
|| volume_2.mesh->getSettingBoolean("anti_overhang_mesh")
|| volume_2.mesh->getSettingBoolean("support_mesh")
)
{
SlicerLayer& layer1 = volumes[idx]->layers[layerNr];
SlicerLayer& layer2 = volumes[idx2]->layers[layerNr];
layer1.polygonList = layer1.polygonList.difference(layer2.polygonList);
continue;
}
if (!volume_1.mesh->getAABB().hit(volume_2.mesh->getAABB()))
{
continue;
}
for (unsigned int layerNr = 0; layerNr < volume_1.layers.size(); layerNr++)
{
SlicerLayer& layer1 = volume_1.layers[layerNr];
SlicerLayer& layer2 = volume_2.layers[layerNr];
if (alternate_carve_order && layerNr % 2 == 0)
{
layer2.polygons = layer2.polygons.difference(layer1.polygons);
}
else
{
layer1.polygons = layer1.polygons.difference(layer2.polygons);
}
}
}
}
@@ -22,24 +49,46 @@ void carveMultipleVolumes(std::vector<Slicer*> &volumes)
//Expand each layer a bit and then keep the extra overlapping parts that overlap with other volumes.
//This generates some overlap in dual extrusion, for better bonding in touching parts.
void generateMultipleVolumesOverlap(std::vector<Slicer*> &volumes, int overlap)
void generateMultipleVolumesOverlap(std::vector<Slicer*> &volumes)
{
if (volumes.size() < 2 || overlap <= 0) return;
for(unsigned int layerNr=0; layerNr < volumes[0]->layers.size(); layerNr++)
if (volumes.size() < 2)
{
Polygons fullLayer;
for(unsigned int volIdx = 0; volIdx < volumes.size(); volIdx++)
return;
}
int offset_to_merge_other_merged_volumes = 20;
for (Slicer* volume : volumes)
{
int overlap = volume->mesh->getSettingInMicrons("multiple_mesh_overlap");
if (volume->mesh->getSettingBoolean("infill_mesh")
|| volume->mesh->getSettingBoolean("anti_overhang_mesh")
|| volume->mesh->getSettingBoolean("support_mesh")
|| overlap == 0)
{
SlicerLayer& layer1 = volumes[volIdx]->layers[layerNr];
fullLayer = fullLayer.unionPolygons(layer1.polygonList.offset(20)); // TODO: put hard coded value in a variable with an explanatory name (and make var a parameter, and perhaps even a setting?)
continue;
}
fullLayer = fullLayer.offset(-20); // TODO: put hard coded value in a variable with an explanatory name (and make var a parameter, and perhaps even a setting?)
for(unsigned int volIdx = 0; volIdx < volumes.size(); volIdx++)
AABB3D aabb(volume->mesh->getAABB());
aabb.expandXY(overlap); // expand to account for the case where two models and their bounding boxes are adjacent along the X or Y-direction
for (unsigned int layer_nr = 0; layer_nr < volume->layers.size(); layer_nr++)
{
SlicerLayer& layer1 = volumes[volIdx]->layers[layerNr];
layer1.polygonList = fullLayer.intersection(layer1.polygonList.offset(overlap / 2));
Polygons all_other_volumes;
for (Slicer* other_volume : volumes)
{
if (other_volume->mesh->getSettingBoolean("infill_mesh")
|| other_volume->mesh->getSettingBoolean("anti_overhang_mesh")
|| other_volume->mesh->getSettingBoolean("support_mesh")
|| !other_volume->mesh->getAABB().hit(aabb)
|| other_volume == volume
)
{
continue;
}
SlicerLayer& other_volume_layer = other_volume->layers[layer_nr];
all_other_volumes = all_other_volumes.unionPolygons(other_volume_layer.polygons.offset(offset_to_merge_other_merged_volumes));
}
SlicerLayer& volume_layer = volume->layers[layer_nr];
volume_layer.polygons = volume_layer.polygons.unionPolygons(all_other_volumes.intersection(volume_layer.polygons.offset(overlap / 2)));
}
}
}
+6 -2
Ver Arquivo
@@ -7,13 +7,17 @@
/* This file contains code to help fixing up and changing layers that are build from multiple volumes. */
namespace cura {
void carveMultipleVolumes(std::vector<Slicer*> &meshes);
/*!
*
* \param alternate_carve_order Whether to switch which model carves out of which with every layer
*/
void carveMultipleVolumes(std::vector<Slicer*> &meshes, bool alternate_carve_order);
/*!
* Expand each layer a bit and then keep the extra overlapping parts that overlap with other volumes.
* This generates some overlap in dual extrusion, for better bonding in touching parts.
*/
void generateMultipleVolumesOverlap(std::vector<Slicer*> &meshes, int overlap);
void generateMultipleVolumesOverlap(std::vector<Slicer*> &meshes);
}//namespace cura
+103 -128
Ver Arquivo
@@ -1,7 +1,8 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "pathOrderOptimizer.h"
#include "utils/logoutput.h"
#include "utils/BucketGrid2D.h"
#include "utils/SparsePointGridInclusive.h"
#include "utils/linearAlg2D.h"
#define INLINE static inline
@@ -15,17 +16,16 @@ void PathOrderOptimizer::optimize()
bool picked[polygons.size()];
memset(picked, false, sizeof(bool) * polygons.size());/// initialized as falses
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++) /// find closest point to initial starting point within each polygon +initialize picked
for (ConstPolygonRef poly : polygons) /// find closest point to initial starting point within each polygon +initialize picked
{
int best = -1;
float bestDist = std::numeric_limits<float>::infinity();
PolygonRef poly = polygons[i_polygon];
for(unsigned int i_point=0; i_point<poly.size(); i_point++) /// get closest point in polygon
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++) /// get closest point in polygon
{
float dist = vSize2f(poly[i_point] - startPoint);
float dist = vSize2f(poly[point_idx] - startPoint);
if (dist < bestDist)
{
best = i_point;
best = point_idx;
bestDist = dist;
}
}
@@ -37,46 +37,50 @@ void PathOrderOptimizer::optimize()
Point prev_point = startPoint;
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++) /// actual path order optimizer
for (unsigned int poly_order_idx = 0; poly_order_idx < polygons.size(); poly_order_idx++) /// actual path order optimizer
{
int best = -1;
int best_poly_idx = -1;
float bestDist = std::numeric_limits<float>::infinity();
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++)
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
if (picked[i_polygon] || polygons[i_polygon].size() < 1) /// skip single-point-polygons
if (picked[poly_idx] || polygons[poly_idx].size() < 1) /// skip single-point-polygons
{
continue;
}
assert (polygons[i_polygon].size() != 2);
assert (polygons[poly_idx].size() != 2);
float dist = vSize2f(polygons[i_polygon][polyStart[i_polygon]] - prev_point);
float dist = vSize2f(polygons[poly_idx][polyStart[poly_idx]] - prev_point);
if (dist < bestDist)
{
best = i_polygon;
best_poly_idx = poly_idx;
bestDist = dist;
}
}
if (best > -1) /// should always be true; we should have been able to identify the best next polygon
if (best_poly_idx > -1) /// should always be true; we should have been able to identify the best next polygon
{
assert(polygons[best].size() != 2);
assert(polygons[best_poly_idx].size() != 2);
prev_point = polygons[best][polyStart[best]];
prev_point = polygons[best_poly_idx][polyStart[best_poly_idx]];
picked[best] = true;
polyOrder.push_back(best);
picked[best_poly_idx] = true;
polyOrder.push_back(best_poly_idx);
}
else
{
logError("Failed to find next closest polygon.\n");
}
}
prev_point = startPoint;
for(unsigned int n=0; n<polyOrder.size(); n++) /// decide final starting points in each polygon
for (unsigned int order_idx = 0; order_idx < polyOrder.size(); order_idx++) /// decide final starting points in each polygon
{
int poly_idx = polyOrder[n];
int poly_idx = polyOrder[order_idx];
int point_idx = getPolyStart(prev_point, poly_idx);
polyStart[poly_idx] = point_idx;
prev_point = polygons[poly_idx][point_idx];
@@ -88,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);
@@ -98,23 +102,24 @@ int PathOrderOptimizer::getPolyStart(Point prev_point, int poly_idx)
int PathOrderOptimizer::getClosestPointInPolygon(Point prev_point, int poly_idx)
{
PolygonRef poly = polygons[poly_idx];
ConstPolygonRef poly = polygons[poly_idx];
int best_point_idx = -1;
float bestDist = std::numeric_limits<float>::infinity();
bool orientation = poly.orientation();
for(unsigned int i_point=0 ; i_point<poly.size() ; i_point++)
float best_point_score = std::numeric_limits<float>::infinity();
Point p0 = poly.back();
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
{
float dist = vSize2f(poly[i_point] - prev_point);
Point n0 = normal(poly[(i_point-1+poly.size())%poly.size()] - poly[i_point], 2000);
Point n1 = normal(poly[i_point] - poly[(i_point + 1) % poly.size()], 2000);
float dot_score = dot(n0, n1) - dot(crossZ(n0), n1); /// prefer binnenbocht
if (orientation)
dot_score = -dot_score;
if (dist + dot_score < bestDist)
const Point& p1 = poly[point_idx];
const Point& p2 = poly[(point_idx + 1) % poly.size()];
int64_t dist = vSize2(p1 - prev_point);
float is_on_inside_corner_score = -LinearAlg2D::getAngleLeft(p0, p1, p2) / M_PI * 5000 * 5000; // prefer inside corners
// this score is in the order of 5 mm
if (dist + is_on_inside_corner_score < best_point_score)
{
best_point_idx = i_point;
bestDist = dist;
best_point_idx = point_idx;
best_point_score = dist + is_on_inside_corner_score;
}
p0 = p1;
}
return best_point_idx;
}
@@ -124,155 +129,125 @@ 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;
}
/**
*
*/
void LineOrderOptimizer::optimize()
{
int gridSize = 5000; // the size of the cells in the hash grid.
BucketGrid2D<unsigned int> line_bucket_grid(gridSize);
int gridSize = 5000; // the size of the cells in the hash grid. TODO
SparsePointGridInclusive<unsigned int> line_bucket_grid(gridSize);
bool picked[polygons.size()];
memset(picked, false, sizeof(bool) * polygons.size());/// initialized as falses
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++) /// find closest point to initial starting point within each polygon +initialize picked
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++) /// find closest point to initial starting point within each polygon +initialize picked
{
int best = -1;
float bestDist = std::numeric_limits<float>::infinity();
PolygonRef poly = polygons[i_polygon];
for(unsigned int i_point=0; i_point<poly.size(); i_point++) /// get closest point from polygon
int best_point_idx = -1;
float best_point_dist = std::numeric_limits<float>::infinity();
ConstPolygonRef poly = polygons[poly_idx];
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++) /// get closest point from polygon
{
float dist = vSize2f(poly[i_point] - startPoint);
if (dist < bestDist)
float dist = vSize2f(poly[point_idx] - startPoint);
if (dist < best_point_dist)
{
best = i_point;
bestDist = dist;
best_point_idx = point_idx;
best_point_dist = dist;
}
}
polyStart.push_back(best);
polyStart.push_back(best_point_idx);
assert(poly.size() == 2);
line_bucket_grid.insert(poly[0], i_polygon);
line_bucket_grid.insert(poly[1], i_polygon);
line_bucket_grid.insert(poly[0], poly_idx);
line_bucket_grid.insert(poly[1], poly_idx);
}
Point incommingPerpundicularNormal(0, 0);
Point incoming_perpundicular_normal(0, 0);
Point prev_point = startPoint;
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++) /// actual path order optimizer
for (unsigned int order_idx = 0; order_idx < polygons.size(); order_idx++) /// actual path order optimizer
{
int best = -1;
float bestDist = std::numeric_limits<float>::infinity();
int best_line_idx = -1;
float best_score = std::numeric_limits<float>::infinity(); // distance score for the best next line
for(unsigned int i_close_line_polygon : line_bucket_grid.findNearbyObjects(prev_point)) /// check if single-line-polygon is close to last point
/// check if single-line-polygon is close to last point
for(unsigned int close_line_idx :
line_bucket_grid.getNearbyVals(prev_point, gridSize))
{
if (picked[i_close_line_polygon] || polygons[i_close_line_polygon].size() < 1)
if (picked[close_line_idx] || polygons[close_line_idx].size() < 1)
{
continue;
}
checkIfLineIsBest(i_close_line_polygon, best, bestDist, prev_point, incommingPerpundicularNormal);
updateBestLine(close_line_idx, best_line_idx, best_score, prev_point, incoming_perpundicular_normal);
}
if (best == -1) /// if single-line-polygon hasn't been found yet
if (best_line_idx == -1) /// if single-line-polygon hasn't been found yet
{
for(unsigned int i_polygon=0 ; i_polygon<polygons.size() ; i_polygon++)
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
if (picked[i_polygon] || polygons[i_polygon].size() < 1) /// skip single-point-polygons
if (picked[poly_idx] || polygons[poly_idx].size() < 1) /// skip single-point-polygons
{
continue;
assert(polygons[i_polygon].size() == 2);
}
assert(polygons[poly_idx].size() == 2);
checkIfLineIsBest(i_polygon, best, bestDist, prev_point, incommingPerpundicularNormal);
updateBestLine(poly_idx, best_line_idx, best_score, prev_point, incoming_perpundicular_normal);
}
}
if (best > -1) /// should always be true; we should have been able to identify the best next polygon
if (best_line_idx > -1) /// should always be true; we should have been able to identify the best next polygon
{
assert(polygons[best].size() == 2);
ConstPolygonRef best_line = polygons[best_line_idx];
assert(best_line.size() == 2);
int endIdx = polyStart[best] * -1 + 1; /// 1 -> 0 , 0 -> 1
prev_point = polygons[best][endIdx];
incommingPerpundicularNormal = crossZ(normal(polygons[best][endIdx] - polygons[best][polyStart[best]], 1000));
int line_start_point_idx = polyStart[best_line_idx];
int line_end_point_idx = line_start_point_idx * -1 + 1; /// 1 -> 0 , 0 -> 1
const Point& line_start = best_line[line_start_point_idx];
const Point& line_end = best_line[line_end_point_idx];
prev_point = line_end;
incoming_perpundicular_normal = turn90CCW(normal(line_end - line_start, 1000));
picked[best] = true;
polyOrder.push_back(best);
picked[best_line_idx] = true;
polyOrder.push_back(best_line_idx);
}
else
logError("Failed to find next closest line.\n");
}
prev_point = startPoint;
for(unsigned int n=0; n<polyOrder.size(); n++) /// decide final starting points in each polygon
{
int nr = polyOrder[n];
PolygonRef poly = polygons[nr];
int best = -1;
float bestDist = std::numeric_limits<float>::infinity();
bool orientation = poly.orientation();
for(unsigned int i=0;i<poly.size(); i++)
{
float dist = vSize2f(polygons[nr][i] - prev_point);
Point n0 = normal(poly[(i+poly.size()-1)%poly.size()] - poly[i], 2000);
Point n1 = normal(poly[i] - poly[(i + 1) % poly.size()], 2000);
float dot_score = dot(n0, n1) - dot(crossZ(n0), n1);
if (orientation)
dot_score = -dot_score;
if (dist + dot_score < bestDist)
{
best = i;
bestDist = dist + dot_score;
}
logError("Failed to find next closest line.\n");
}
polyStart[nr] = best;
assert(poly.size() == 2);
prev_point = poly[best *-1 + 1]; /// 1 -> 0 , 0 -> 1
}
}
inline void LineOrderOptimizer::checkIfLineIsBest(unsigned int i_line_polygon, int& best, float& bestDist, Point& prev_point, Point& incommingPerpundicularNormal)
inline void LineOrderOptimizer::updateBestLine(unsigned int poly_idx, int& best, float& best_score, Point prev_point, Point incoming_perpundicular_normal)
{
const Point& p0 = polygons[poly_idx][0];
const Point& p1 = polygons[poly_idx][1];
float dot_score = getAngleScore(incoming_perpundicular_normal, p0, p1);
{ /// check distance to first point on line (0)
float dist = vSize2f(polygons[i_line_polygon][0] - prev_point);
dist += abs(dot(incommingPerpundicularNormal, normal(polygons[i_line_polygon][1] - polygons[i_line_polygon][0], 1000))) * 0.0001f; /// penalize sharp corners
if (dist < bestDist)
float score = vSize2f(p0 - prev_point) + dot_score; // prefer 90 degree corners
if (score < best_score)
{
best = i_line_polygon;
bestDist = dist;
polyStart[i_line_polygon] = 0;
best = poly_idx;
best_score = score;
polyStart[poly_idx] = 0;
}
}
{ /// check distance to second point on line (1)
float dist = vSize2f(polygons[i_line_polygon][1] - prev_point);
dist += abs(dot(incommingPerpundicularNormal, normal(polygons[i_line_polygon][0] - polygons[i_line_polygon][1], 1000) )) * 0.0001f; /// penalize sharp corners
if (dist < bestDist)
float score = vSize2f(p1 - prev_point) + dot_score; // prefer 90 degree corners
if (score < best_score)
{
best = i_line_polygon;
bestDist = dist;
polyStart[i_line_polygon] = 1;
best = poly_idx;
best_score = score;
polyStart[poly_idx] = 1;
}
}
}
float LineOrderOptimizer::getAngleScore(Point incoming_perpundicular_normal, Point p0, Point p1)
{
return dot(incoming_perpundicular_normal, normal(p1 - p0, 1000)) * 0.0001f;
}
}//namespace cura
+54 -9
Ver Arquivo
@@ -4,7 +4,7 @@
#include <stdint.h>
#include "utils/polygon.h"
#include "settings.h"
#include "settings/settings.h"
namespace cura {
@@ -18,23 +18,30 @@ class PathOrderOptimizer
{
public:
EZSeamType type;
Point startPoint; //!< The location of the nozzle before starting to print the current layer
std::vector<PolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
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<ConstPolygonRef> 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)
{
}
void addPolygon(PolygonRef polygon)
{
this->polygons.push_back(polygon);
this->polygons.emplace_back(polygon);
}
void addPolygons(Polygons& polygons)
void addPolygon(ConstPolygonRef polygon)
{
this->polygons.emplace_back(polygon);
}
void addPolygons(const Polygons& polygons)
{
for(unsigned int i=0;i<polygons.size(); i++)
this->polygons.push_back(polygons[i]);
@@ -43,9 +50,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);
@@ -58,7 +71,7 @@ class LineOrderOptimizer
{
public:
Point startPoint; //!< The location of the nozzle before starting to print the current layer
std::vector<PolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
std::vector<ConstPolygonRef> 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
@@ -72,6 +85,11 @@ public:
this->polygons.push_back(polygon);
}
void addPolygon(ConstPolygonRef polygon)
{
this->polygons.push_back(polygon);
}
void addPolygons(Polygons& polygons)
{
for(unsigned int i=0;i<polygons.size(); i++)
@@ -81,8 +99,35 @@ public:
void optimize(); //!< sets #polyStart and #polyOrder
private:
void checkIfLineIsBest(unsigned int i_line_polygon, int& best, float& bestDist, Point& prev_point, Point& incommingPerpundicularNormal);
/*!
* Update LineOrderOptimizer::polyStart if the current line is better than the current best.
*
* Besides looking at the distance from the previous line segment, we also look at the angle we make.
*
* We prefer 90 degree angles; 180 degree turn arounds are slow on machines where the jerk is limited.
* 0 degree (straight ahead) 'corners' occur only when a single infill line is interrupted,
* in which case the travel move might involve combing, which makes it rather longer.
*
* \param poly_idx[in] The index in LineOrderOptimizer::polygons for the current line to test
* \param best[in, out] The index of current best line
* \param best_score[in, out] The distance score for the current best line
* \param prev_point[in] The previous point from which to find the next best line
* \param incoming_perpundicular_normal[in] The direction of movement when the print head arrived at \p prev_point, turned 90 degrees CCW
*/
void updateBestLine(unsigned int poly_idx, int& best, float& best_score, Point prev_point, Point incoming_perpundicular_normal);
/*!
* Get a score to modify the distance score for measuring how good two lines follow each other.
*
* The angle score is symmetric in \p from and \p to; they can be exchanged without altering the result. (Code relies on this property)
*
* \param incoming_perpundicular_normal The direction in which the head was moving while printing the previous line, turned 90 degrees CCW
* \param from The one end of the next line
* \param to The other end of the next line
* \return A score measuring how good the angle is of the line between \p from and \p to when the previous line had a direction given by \p incoming_perpundicular_normal
*
*/
static float getAngleScore(Point incoming_perpundicular_normal, Point from, Point to);
};
}//namespace cura
+391
Ver Arquivo
@@ -0,0 +1,391 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "Comb.h"
#include <algorithm>
#include <functional> // function
#include <unordered_set>
#include "../utils/polygonUtils.h"
#include "../utils/linearAlg2D.h"
#include "../utils/PolygonsPointIndex.h"
#include "../sliceDataStorage.h"
#include "../utils/SVG.h"
namespace cura {
LocToLineGrid& Comb::getOutsideLocToLine()
{
return *outside_loc_to_line;
}
Polygons& Comb::getBoundaryOutside()
{
return *boundary_outside;
}
Comb::Comb(const SliceDataStorage& storage, int layer_nr, const Polygons& comb_boundary_inside, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
: storage(storage)
, layer_nr(layer_nr)
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls
, max_moveInside_distance2(offset_from_outlines * 2 * offset_from_outlines * 2)
, offset_from_outlines_outside(travel_avoid_distance)
, offset_from_inside_to_outside(offset_from_outlines + offset_from_outlines_outside)
, max_crossing_dist2(offset_from_inside_to_outside * offset_from_inside_to_outside * 2) // so max_crossing_dist = offset_from_inside_to_outside * sqrt(2) =approx 1.5 to allow for slightly diagonal crossings and slightly inaccurate crossing computation
, avoid_other_parts(travel_avoid_other_parts)
, boundary_inside( comb_boundary_inside ) // copy the boundary, because the partsView_inside will reorder the polygons
, partsView_inside( boundary_inside.splitIntoPartsView() ) // WARNING !! changes the order of boundary_inside !!
, inside_loc_to_line(PolygonUtils::createLocToLineGrid(boundary_inside, comb_boundary_offset))
, boundary_outside(
[&storage, layer_nr, travel_avoid_distance]()
{
return storage.getLayerOutlines(layer_nr, false).offset(travel_avoid_distance);
}
)
, outside_loc_to_line(
[](Comb* comber, const int64_t offset_from_inside_to_outside)
{
return PolygonUtils::createLocToLineGrid(comber->getBoundaryOutside(), offset_from_inside_to_outside * 3 / 2);
}
, this
, offset_from_inside_to_outside
)
{
}
Comb::~Comb()
{
if (inside_loc_to_line)
{
delete inside_loc_to_line;
}
}
bool Comb::calc(Point startPoint, Point endPoint, CombPaths& combPaths, bool _startInside, bool _endInside, int64_t max_comb_distance_ignored, bool via_outside_makes_combing_fail, bool fail_on_unavoidable_obstacles)
{
if (shorterThen(endPoint - startPoint, max_comb_distance_ignored))
{
return true;
}
//Move start and end point inside the comb boundary
unsigned int start_inside_poly = NO_INDEX;
const bool startInside = moveInside(_startInside, startPoint, start_inside_poly);
unsigned int end_inside_poly = NO_INDEX;
const bool endInside = moveInside(_endInside, endPoint, end_inside_poly);
unsigned int start_part_boundary_poly_idx;
unsigned int end_part_boundary_poly_idx;
unsigned int start_part_idx = (start_inside_poly == NO_INDEX)? NO_INDEX : partsView_inside.getPartContaining(start_inside_poly, &start_part_boundary_poly_idx);
unsigned int end_part_idx = (end_inside_poly == NO_INDEX)? NO_INDEX : partsView_inside.getPartContaining(end_inside_poly, &end_part_boundary_poly_idx);
if (startInside && endInside && start_part_idx == end_part_idx)
{ // normal combing within part
PolygonsPart part = partsView_inside.assemblePart(start_part_idx);
combPaths.emplace_back();
return LinePolygonsCrossings::comb(part, *inside_loc_to_line, startPoint, endPoint, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored, fail_on_unavoidable_obstacles);
}
else
{ // comb inside part to edge (if needed) >> move through air avoiding other parts >> comb inside end part upto the endpoint (if needed)
// INSIDE | in_between | OUTSIDE | in_between | INSIDE
// ^crossing_1_in ^crossing_1_mid ^crossing_1_out ^crossing_2_out ^crossing_2_mid ^crossing_2_in
//
// when startPoint is inside crossing_1_in is of interest
// when it is in between inside and outside it is equal to crossing_1_mid
if (via_outside_makes_combing_fail)
{
return false;
}
Crossing start_crossing(startPoint, startInside, start_part_idx, start_part_boundary_poly_idx, boundary_inside, inside_loc_to_line);
Crossing end_crossing(endPoint, endInside, end_part_idx, end_part_boundary_poly_idx, boundary_inside, inside_loc_to_line);
{ // find crossing over the in-between area between inside and outside
start_crossing.findCrossingInOrMid(partsView_inside, endPoint);
end_crossing.findCrossingInOrMid(partsView_inside, start_crossing.in_or_mid);
}
bool skip_avoid_other_parts_path = false;
if (skip_avoid_other_parts_path && vSize2(start_crossing.in_or_mid - end_crossing.in_or_mid) < offset_from_inside_to_outside * offset_from_inside_to_outside * 4)
{ // parts are next to eachother, i.e. the direct crossing will always be smaller than two crossings via outside
skip_avoid_other_parts_path = true;
}
if (avoid_other_parts && !skip_avoid_other_parts_path)
{ // compute the crossing points when moving through air
// comb through all air, since generally the outside consists of a single part
bool success = start_crossing.findOutside(*boundary_outside, end_crossing.in_or_mid, fail_on_unavoidable_obstacles, *this);
if (!success)
{
return false;
}
success = end_crossing.findOutside(*boundary_outside, start_crossing.out, fail_on_unavoidable_obstacles, *this);
if (!success)
{
return false;
}
}
// generate the actual comb paths
if (startInside)
{
// start to boundary
assert(start_crossing.dest_part.size() > 0 && "The part we start inside when combing should have been computed already!");
combPaths.emplace_back();
bool combing_succeeded = LinePolygonsCrossings::comb(start_crossing.dest_part, *inside_loc_to_line, startPoint, start_crossing.in_or_mid, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored, fail_on_unavoidable_obstacles);
if (!combing_succeeded)
{ // Couldn't comb between start point and computed crossing from the start part! Happens for very thin parts when the offset_to_get_off_boundary moves points to outside the polygon
return false;
}
}
// throught air from boundary to boundary
if (avoid_other_parts && !skip_avoid_other_parts_path)
{
combPaths.emplace_back();
combPaths.throughAir = true;
if ( vSize(start_crossing.in_or_mid - end_crossing.in_or_mid) < vSize(start_crossing.in_or_mid - start_crossing.out) + vSize(end_crossing.in_or_mid - end_crossing.out) )
{ // via outside is moving more over the in-between zone
combPaths.back().push_back(start_crossing.in_or_mid);
combPaths.back().push_back(end_crossing.in_or_mid);
}
else
{
bool combing_succeeded = LinePolygonsCrossings::comb(*boundary_outside, *outside_loc_to_line, start_crossing.out, end_crossing.out, combPaths.back(), offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored, fail_on_unavoidable_obstacles);
if (!combing_succeeded)
{
return false;
}
}
}
else
{ // directly through air (not avoiding other parts)
combPaths.emplace_back();
combPaths.throughAir = true;
combPaths.back().cross_boundary = true; // note: we don't actually know whether this is cross boundary, but it might very well be
combPaths.back().push_back(start_crossing.in_or_mid);
combPaths.back().push_back(end_crossing.in_or_mid);
}
if (skip_avoid_other_parts_path)
{
if (startInside == endInside && start_part_idx == end_part_idx)
{
if (startInside)
{ // both start and end are inside
combPaths.back().cross_boundary = PolygonUtils::polygonCollidesWithLineSegment(startPoint, endPoint, *inside_loc_to_line);
}
else
{ // both start and end are outside
combPaths.back().cross_boundary = PolygonUtils::polygonCollidesWithLineSegment(startPoint, endPoint, *outside_loc_to_line);
}
}
else
{
combPaths.back().cross_boundary = true;
}
}
if (endInside)
{
// boundary to end
assert(end_crossing.dest_part.size() > 0 && "The part we end up inside when combing should have been computed already!");
combPaths.emplace_back();
bool combing_succeeded = LinePolygonsCrossings::comb(end_crossing.dest_part, *inside_loc_to_line, end_crossing.in_or_mid, endPoint, combPaths.back(), -offset_dist_to_get_from_on_the_polygon_to_outside, max_comb_distance_ignored, fail_on_unavoidable_obstacles);
if (!combing_succeeded)
{ // Couldn't comb between end point and computed crossing to the end part! Happens for very thin parts when the offset_to_get_off_boundary moves points to outside the polygon
return false;
}
}
return true;
}
}
Comb::Crossing::Crossing(const Point& dest_point, const bool dest_is_inside, const unsigned int dest_part_idx, const unsigned int dest_part_boundary_crossing_poly_idx, const Polygons& boundary_inside, const LocToLineGrid* inside_loc_to_line)
: dest_is_inside(dest_is_inside)
, boundary_inside(boundary_inside)
, inside_loc_to_line(inside_loc_to_line)
, dest_point(dest_point)
, dest_part_idx(dest_part_idx)
{
if (dest_is_inside)
{
dest_crossing_poly.emplace(boundary_inside[dest_part_boundary_crossing_poly_idx]); // initialize with most obvious poly, cause mostly a combing move will move outside the part, rather than inside a hole in the part
}
}
bool Comb::moveInside(bool is_inside, Point& dest_point, unsigned int& inside_poly)
{
if (is_inside)
{
ClosestPolygonPoint cpp = PolygonUtils::ensureInsideOrOutside(boundary_inside, dest_point, offset_extra_start_end, max_moveInside_distance2, &boundary_inside, inside_loc_to_line);
if (!cpp.isValid())
{
return false;
}
else
{
inside_poly = cpp.poly_idx;
return true;
}
}
return false;
}
void Comb::Crossing::findCrossingInOrMid(const PartsView& partsView_inside, const Point close_to)
{
if (dest_is_inside)
{ // in-case
// find the point on the start inside-polygon closest to the endpoint, but also kind of close to the start point
Point _dest_point(dest_point); // copy to local variable for lambda capture
std::function<int(Point)> close_towards_start_penalty_function([_dest_point](Point candidate){ return vSize2((candidate - _dest_point) / 10); });
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 _dest_point)
std::unordered_set<unsigned int> dest_part_poly_indices;
for (unsigned int poly_idx : partsView_inside[dest_part_idx])
{
dest_part_poly_indices.emplace(poly_idx);
}
coord_t dist2_score = std::numeric_limits<coord_t>::max();
std::function<bool (const PolygonsPointIndex&)> line_processor
= [close_to, _dest_point, &boundary_crossing_point, &dist2_score, &dest_part_poly_indices](const PolygonsPointIndex& boundary_segment)
{
if (dest_part_poly_indices.find(boundary_segment.poly_idx) == dest_part_poly_indices.end())
{ // we're not looking at a polygon from the dest_part
return true; // a.k.a. continue;
}
Point closest_here = LinearAlg2D::getClosestOnLineSegment(close_to, boundary_segment.p(), boundary_segment.next().p());
coord_t dist2_score_here = vSize2(close_to - closest_here) + vSize2(_dest_point - closest_here) / 10;
if (dist2_score_here < dist2_score)
{
dist2_score = dist2_score_here;
boundary_crossing_point = ClosestPolygonPoint(closest_here, boundary_segment.point_idx, boundary_segment.getPolygon(), boundary_segment.poly_idx);
}
return true;
};
inside_loc_to_line->processLine(std::make_pair(dest_point, close_to), line_processor);
}
Point result(boundary_crossing_point.p()); // the inside point of the crossing
if (!boundary_crossing_point.isValid())
{ // no point has been found in the sparse grid
result = dest_point;
}
int64_t max_dist2 = std::numeric_limits<int64_t>::max();
ClosestPolygonPoint crossing_1_in_cp = PolygonUtils::ensureInsideOrOutside(dest_part, result, boundary_crossing_point, offset_dist_to_get_from_on_the_polygon_to_outside, max_dist2, &boundary_inside, inside_loc_to_line, close_towards_start_penalty_function);
if (crossing_1_in_cp.isValid())
{
dest_crossing_poly = crossing_1_in_cp.poly;
in_or_mid = result;
}
else
{ // part is too small to be ensuring a point inside with the given distance
in_or_mid = dest_point; // just use the startPoint or endPoint itself
}
}
else
{
in_or_mid = dest_point; // mid-case
}
};
bool Comb::Crossing::findOutside(const Polygons& outside, const Point close_to, const bool fail_on_unavoidable_obstacles, Comb& comber)
{
out = in_or_mid;
if (dest_is_inside || outside.inside(in_or_mid, true)) // start in_between
{ // move outside
Point preferred_crossing_1_out = in_or_mid + normal(close_to - in_or_mid, comber.offset_from_inside_to_outside);
std::function<int(Point)> close_to_penalty_function([preferred_crossing_1_out](Point candidate){ return vSize2((candidate - preferred_crossing_1_out) / 2); });
std::optional<ClosestPolygonPoint> crossing_1_out_cpp = PolygonUtils::findClose(in_or_mid, outside, comber.getOutsideLocToLine(), close_to_penalty_function);
if (crossing_1_out_cpp)
{
out = PolygonUtils::moveOutside(*crossing_1_out_cpp, comber.offset_dist_to_get_from_on_the_polygon_to_outside);
}
else
{
PolygonUtils::moveOutside(outside, out, comber.offset_dist_to_get_from_on_the_polygon_to_outside);
}
}
int64_t in_out_dist2_1 = vSize2(out - in_or_mid);
if (dest_is_inside && in_out_dist2_1 > comber.max_crossing_dist2) // moveInside moved too far
{ // if move is too far over in_between
// find crossing closer by
assert(dest_crossing_poly && "destination crossing poly should have been instantiated!");
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> best = findBestCrossing(outside, *dest_crossing_poly, dest_point, close_to, comber);
if (best)
{
in_or_mid = PolygonUtils::moveInside(best->first, comber.offset_dist_to_get_from_on_the_polygon_to_outside);
out = PolygonUtils::moveOutside(best->second, comber.offset_dist_to_get_from_on_the_polygon_to_outside);
}
if (fail_on_unavoidable_obstacles && vSize2(out - in_or_mid) > comber.max_crossing_dist2) // moveInside moved still too far
{
return false;
}
}
return true;
}
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> Comb::Crossing::findBestCrossing(const Polygons& outside, ConstPolygonRef from, const Point estimated_start, const Point estimated_end, Comb& comber)
{
ClosestPolygonPoint* best_in = nullptr;
ClosestPolygonPoint* best_out = nullptr;
int64_t best_detour_score = std::numeric_limits<int64_t>::max();
int64_t best_crossing_dist2;
std::vector<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> crossing_out_candidates = PolygonUtils::findClose(from, outside, comber.getOutsideLocToLine());
bool seen_close_enough_connection = false;
for (std::pair<ClosestPolygonPoint, ClosestPolygonPoint>& crossing_candidate : crossing_out_candidates)
{
int64_t crossing_dist2 = vSize2(crossing_candidate.first.location - crossing_candidate.second.location);
if (crossing_dist2 > comber.max_crossing_dist2 * 2)
{ // preliminary filtering
continue;
}
int64_t dist_to_start = vSize(crossing_candidate.second.location - estimated_start); // use outside location, so that the crossing direction is taken into account
int64_t dist_to_end = vSize(crossing_candidate.second.location - estimated_end);
int64_t detour_dist = dist_to_start + dist_to_end;
int64_t detour_score = crossing_dist2 + detour_dist * detour_dist / 1000; // prefer a closest connection over a detour
// The detour distance is generally large compared to the crossing distance.
// While the crossing is generally about 1mm across,
// the distance between an arbitrary point and the boundary may well be a couple of centimetres.
// So the crossing_dist2 is about 1.000.000 while the detour_dist_2 is in the order of 400.000.000
// In the end we just want to choose between two points which have the _same_ crossing distance, modulo rounding error.
if ((!seen_close_enough_connection && detour_score < best_detour_score) // keep the best as long as we havent seen one close enough (so that we may walk along the polygon to find a closer connection from it in the code below)
|| (!seen_close_enough_connection && crossing_dist2 <= comber.max_crossing_dist2) // make the one which is close enough the best as soon as we see one close enough
|| (seen_close_enough_connection && crossing_dist2 <= comber.max_crossing_dist2 && detour_score < best_detour_score)) // update to keep the best crossing which is close enough already
{
if (!seen_close_enough_connection && crossing_dist2 <= comber.max_crossing_dist2)
{
seen_close_enough_connection = true;
}
best_in = &crossing_candidate.first;
best_out = &crossing_candidate.second;
best_detour_score = detour_score;
best_crossing_dist2 = crossing_dist2;
}
}
if (best_detour_score == std::numeric_limits<int64_t>::max())
{ // i.e. if best_in == nullptr or if best_out == nullptr
return std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>>();
}
if (best_crossing_dist2 > comber.max_crossing_dist2)
{ // find closer point on line segments, rather than moving between vertices of the polygons only
PolygonUtils::walkToNearestSmallestConnection(*best_in, *best_out);
best_crossing_dist2 = vSize2(best_in->location - best_out->location);
if (best_crossing_dist2 > comber.max_crossing_dist2)
{
return std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>>();
}
}
return std::make_shared<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>>(*best_in, *best_out);
}
}//namespace cura
+179
Ver Arquivo
@@ -0,0 +1,179 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_COMB_H
#define PATH_PLANNING_COMB_H
#include <memory> // shared_ptr
#include "../utils/optional.h"
#include "../utils/polygon.h"
#include "../utils/SparsePointGridInclusive.h"
#include "../utils/polygonUtils.h"
#include "../utils/LazyInitialization.h"
#include "LinePolygonsCrossings.h"
#include "CombPath.h"
#include "CombPaths.h"
namespace cura
{
class SliceDataStorage;
/*!
* Class for generating a full combing actions from a travel move from a start point to an end point.
* A single Comb object is used for each layer.
*
* Comb::calc is the main function of this class.
*
* Typical output: A combing path to the boundary of the polygon + a move through air avoiding other parts in the layer + a combing path from the boundary of the ending polygon to the end point.
* Each of these three is a CombPath; the first and last are within Comb::boundary_inside while the middle is outside of Comb::boundary_outside.
* Between these there is a little gap where the nozzle crosses the boundary of an object approximately perpendicular to its boundary.
*
* As an optimization, the combing paths inside are calculated on specifically those PolygonsParts within which to comb, while the coundary_outside isn't split into outside parts,
* because generally there is only one outside part; encapsulated holes occur less often.
*/
class Comb
{
friend class LinePolygonsCrossings;
private:
/*!
* A crossing from the inside boundary to the outside boundary.
*
* 'dest' is either the startPoint or the endpoint of a whole combing move.
*/
class Crossing
{
public:
bool dest_is_inside; //!< Whether the startPoint or endPoint is inside the inside boundary
Point in_or_mid; //!< The point on the inside boundary, or in between the inside and outside boundary if the start/end point isn't inside the inside boudary
Point out; //!< The point on the outside boundary
PolygonsPart dest_part; //!< The assembled inside-boundary PolygonsPart in which the dest_point lies. (will only be initialized when Crossing::dest_is_inside holds)
std::optional<ConstPolygonRef> dest_crossing_poly; //!< The polygon of the part in which dest_point lies, which will be crossed (often will be the outside polygon)
const Polygons& boundary_inside; //!< The inside boundary as in \ref Comb::boundary_inside
const LocToLineGrid* inside_loc_to_line; //!< The loc to line grid \ref Comb::inside_loc_to_line
/*!
* Simple constructor
*
* \param dest_point Either the eventual startPoint or the eventual endPoint of this combing move.
* \param dest_is_inside Whether the startPoint or endPoint is inside the inside boundary.
* \param dest_part_idx The index into Comb:partsView_inside of the part in which the \p dest_point is.
* \param dest_part_boundary_crossing_poly_idx The index in \p boundary_inside of the polygon of the part in which dest_point lies, which will be crossed (often will be the outside polygon).
* \param boundary_inside The boundary within which to comb.
*/
Crossing(const Point& dest_point, const bool dest_is_inside, const unsigned int dest_part_idx, const unsigned int dest_part_boundary_crossing_poly_idx, const Polygons& boundary_inside, const LocToLineGrid* inside_loc_to_line);
/*!
* Find the not-outside location (Combing::in_or_mid) of the crossing between to the outside boundary
*
* \param partsView_inside Structured indices onto Comb::boundary_inside which shows which polygons belong to which part.
* \param close_to[in] Try to get a crossing close to this point
*/
void findCrossingInOrMid(const PartsView& partsView_inside, const Point close_to);
/*!
* Find the outside location (Combing::out)
*
* \param outside The outside boundary polygons
* \param close_to A point to get closer to when there are multiple candidates on the outside boundary which are almost equally close to the Crossing::in_or_mid
* \param fail_on_unavoidable_obstacles When moving over other parts is inavoidable, stop calculation early and return false.
* \param comber[in] The combing calculator which has references to the offsets and boundaries to use in combing.
*/
bool findOutside(const Polygons& outside, const Point close_to, const bool fail_on_unavoidable_obstacles, Comb& comber);
private:
const Point dest_point; //!< Either the eventual startPoint or the eventual endPoint of this combing move
unsigned int dest_part_idx; //!< The index into Comb:partsView_inside of the part in which the \p dest_point is.
/*!
* Find the best crossing from some inside polygon to the outside boundary.
*
* The detour from \p estimated_start to \p estimated_end is minimized.
*
* \param outside The outside boundary polygons
* \param from From which inside boundary the crossing to the outside starts or ends
* \param estimated_start The one point to which to stay close when evaluating crossings which cross about the same distance
* \param estimated_end The other point to which to stay close when evaluating crossings which cross about the same distance
* \param comber[in] The combing calculator which has references to the offsets and boundaries to use in combing.
* \return A pair of which the first is the crossing point on the inside boundary and the second the crossing point on the outside boundary
*/
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> findBestCrossing(const Polygons& outside, ConstPolygonRef from, Point estimated_start, Point estimated_end, Comb& comber);
};
const SliceDataStorage& storage; //!< The storage from which to compute the outside boundary, when needed.
const int layer_nr; //!< The layer number for the layer for which to compute the outside boundary, when needed.
const int64_t offset_from_outlines; //!< Offset from the boundary of a part to the comb path. (nozzle width / 2)
const int64_t max_moveInside_distance2; //!< Maximal distance of a point to the Comb::boundary_inside which is still to be considered inside. (very sharp corners not allowed :S)
const int64_t offset_from_outlines_outside; //!< Offset from the boundary of a part to a travel path which avoids it by this distance.
const int64_t offset_from_inside_to_outside; //!< The sum of the offsets for the inside and outside boundary Comb::offset_from_outlines and Comb::offset_from_outlines_outside
const int64_t max_crossing_dist2; //!< The maximal distance by which to cross the in_between area between inside and outside
static const int64_t max_moveOutside_distance2 = INT64_MAX; //!< Any point which is not inside should be considered outside.
static const int64_t offset_dist_to_get_from_on_the_polygon_to_outside = 40; //!< in order to prevent on-boundary vs crossing boundary confusions (precision thing)
static const int64_t offset_extra_start_end = 100; //!< Distance to move start point and end point toward eachother to extra avoid collision with the boundaries.
const bool avoid_other_parts; //!< Whether to perform inverse combing a.k.a. avoid parts.
Polygons boundary_inside; //!< The boundary within which to comb. (Will be reordered by the partsView_inside)
const PartsView partsView_inside; //!< Structured indices onto boundary_inside which shows which polygons belong to which part.
LocToLineGrid* inside_loc_to_line; //!< The SparsePointGridInclusive mapping locations to line segments of the inner boundary.
LazyInitialization<Polygons> boundary_outside; //!< The boundary outside of which to stay to avoid collision with other layer parts. This is a pointer cause we only compute it when we move outside the boundary (so not when there is only a single part in the layer)
LazyInitialization<LocToLineGrid, Comb*, const int64_t> outside_loc_to_line; //!< The SparsePointGridInclusive mapping locations to line segments of the outside boundary.
/*!
* Get the SparsePointGridInclusive mapping locations to line segments of the outside boundary. Calculate it when it hasn't been calculated yet.
*/
LocToLineGrid& getOutsideLocToLine();
/*!
* Get the boundary_outside, which is an offset from the outlines of all meshes in the layer. Calculate it when it hasn't been calculated yet.
*/
Polygons& getBoundaryOutside();
/*!
* Move the startPoint or endPoint inside when it should be inside
* \param is_inside[in] Whether the \p dest_point should be inside
* \param dest_point[in,out] The point to move
* \param start_inside_poly[out] The polygon in which the point has been moved
* \return Whether we have moved the point inside
*/
bool moveInside(bool is_inside, Point& dest_point, unsigned int& start_inside_poly);
public:
/*!
* Initializes the combing areas for every mesh in the layer (not support)
*
* \warning \ref Comb::calc changes the order of polygons in \p Comb::comb_boundary_inside
*
* \param storage Where the layer polygon data is stored
* \param layer_nr The number of the layer for which to generate the combing areas.
* \param comb_boundary_inside The comb boundary within which to comb within layer parts.
* \param offset_from_outlines The offset from the outline polygon, to create the combing boundary in case there is no second wall.
* \param travel_avoid_other_parts Whether to avoid other layer parts when traveling through air.
* \param travel_avoid_distance The distance by which to avoid other layer parts when traveling through air.
*/
Comb(const SliceDataStorage& storage, int layer_nr, const Polygons& comb_boundary_inside, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
~Comb();
/*!
* Calculate the comb paths (if any) - one for each polygon combed alternated with travel paths
*
* \warning Changes the order of polygons in \ref Comb::comb_boundary_inside
*
* \param startPoint Where to start moving from
* \param endPoint Where to move to
* \param combPoints Output parameter: The points along the combing path, excluding the \p startPoint (?) and \p endPoint
* \param startInside Whether we want to start inside the comb boundary
* \param endInside Whether we want to end up inside the comb boundary
* \param via_outside_makes_combing_fail When going through air is inavoidable, stop calculation early and return false.
* \param fail_on_unavoidable_obstacles When moving over other parts is inavoidable, stop calculation early and return false.
* \return Whether combing has succeeded; otherwise a retraction is needed.
*/
bool calc(Point startPoint, Point endPoint, CombPaths& combPaths, bool startInside, bool endInside, int64_t max_comb_distance_ignored, bool via_outside_makes_combing_fail, bool fail_on_unavoidable_obstacles);
};
}//namespace cura
#endif//PATH_PLANNING_COMB_H
+17
Ver Arquivo
@@ -0,0 +1,17 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_COMB_PATH_H
#define PATH_PLANNING_COMB_PATH_H
#include "../utils/intpoint.h"
namespace cura
{
struct CombPath : public std::vector<Point> //!< A single path either inside or outise the parts
{
bool cross_boundary = false; //!< Whether the path crosses a boundary.
};
}//namespace cura
#endif//PATH_PLANNING_COMB_PATH_H
+17
Ver Arquivo
@@ -0,0 +1,17 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef PATH_PLANNING_COMB_PATHS_H
#define PATH_PLANNING_COMB_PATHS_H
#include "CombPath.h"
namespace cura
{
struct CombPaths : public std::vector<CombPath> //!< A list of paths alternating between inside a part and outside a part
{
bool throughAir = false; //!< Whether the path is one which moves through air.
};
}//namespace cura
#endif//PATH_PLANNING_COMB_PATHS_H
+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:
const 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
+227
Ver Arquivo
@@ -0,0 +1,227 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "LinePolygonsCrossings.h"
#include <algorithm>
#include "../utils/polygonUtils.h"
#include "../sliceDataStorage.h"
#include "../utils/SVG.h"
namespace cura {
bool LinePolygonsCrossings::calcScanlineCrossings(bool fail_on_unavoidable_obstacles)
{
min_crossing_idx = NO_INDEX;
max_crossing_idx = NO_INDEX;
for(unsigned int poly_idx = 0; poly_idx < boundary.size(); poly_idx++)
{
PolyCrossings minMax(poly_idx);
PolygonRef poly = boundary[poly_idx];
Point p0 = transformation_matrix.apply(poly[poly.size() - 1]);
for(unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
{
Point p1 = transformation_matrix.apply(poly[point_idx]);
if ((p0.Y >= transformed_startPoint.Y && p1.Y <= transformed_startPoint.Y) || (p1.Y >= transformed_startPoint.Y && p0.Y <= transformed_startPoint.Y))
{ // if line segment crosses the line through the transformed start and end point (aka scanline)
if (p1.Y == p0.Y) //Line segment is parallel with the scanline. That means that both endpoints lie on the scanline, so they will have intersected with the adjacent line.
{
p0 = p1;
continue;
}
int64_t x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y); // intersection point between line segment and the scanline
if (x >= transformed_startPoint.X && x <= transformed_endPoint.X)
{
if (!((p1.Y == transformed_startPoint.Y && p1.Y < p0.Y) || (p0.Y == transformed_startPoint.Y && p0.Y < p1.Y)))
{ // perform edge case only for line segments on and below the scanline, not for line segments on and above.
// \/ will be no crossings and /\ two, but most importantly | will be one crossing.
minMax.n_crossings++;
}
if(x < minMax.min.x) //For the leftmost intersection, move x left to stay outside of the border.
//Note: The actual distance from the intersection to the border is almost always less than dist_to_move_boundary_point_outside, since it only moves along the direction of the scanline.
{
minMax.min.x = x;
minMax.min.point_idx = point_idx;
}
if(x > minMax.max.x) //For the rightmost intersection, move x right to stay outside of the border.
{
minMax.max.x = x;
minMax.max.point_idx = point_idx;
}
}
}
p0 = p1;
}
if (fail_on_unavoidable_obstacles && minMax.n_crossings % 2 == 1)
{ // if start area and end area are not the same
return false;
}
else if (minMax.min.point_idx != NO_INDEX) // then always also max.point_idx != NO_INDEX
{ // if this polygon crossed the scanline
if (min_crossing_idx == NO_INDEX || minMax.min.x < crossings[min_crossing_idx].min.x) { min_crossing_idx = crossings.size(); }
if (max_crossing_idx == NO_INDEX || minMax.max.x > crossings[max_crossing_idx].max.x) { max_crossing_idx = crossings.size(); }
crossings.push_back(minMax);
}
}
return true;
}
bool LinePolygonsCrossings::lineSegmentCollidesWithBoundary()
{
Point diff = endPoint - startPoint;
transformation_matrix = PointMatrix(diff);
transformed_startPoint = transformation_matrix.apply(startPoint);
transformed_endPoint = transformation_matrix.apply(endPoint);
for(PolygonRef poly : boundary)
{
Point p0 = transformation_matrix.apply(poly.back());
for(Point p1_ : poly)
{
Point p1 = transformation_matrix.apply(p1_);
// when the boundary just touches the line don't disambiguate between the boundary moving on to actually cross the line
// and the boundary bouncing back, resulting in not a real collision - to keep the algorithm simple.
//
// disregard overlapping line segments; probably the next or previous line segment is not overlapping, but will give a collision
// when the boundary line segment fully overlaps with the line segment this edge case is not viewed as a collision
if (p1.Y != p0.Y && ((p0.Y >= transformed_startPoint.Y && p1.Y <= transformed_startPoint.Y) || (p1.Y >= transformed_startPoint.Y && p0.Y <= transformed_startPoint.Y)))
{
int64_t x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y);
if (x > transformed_startPoint.X && x < transformed_endPoint.X)
{
return true;
}
}
p0 = p1;
}
}
return false;
}
bool LinePolygonsCrossings::getCombingPath(CombPath& combPath, int64_t max_comb_distance_ignored, bool fail_on_unavoidable_obstacles)
{
if (shorterThen(endPoint - startPoint, max_comb_distance_ignored) || !lineSegmentCollidesWithBoundary())
{
//We're not crossing any boundaries. So skip the comb generation.
combPath.push_back(startPoint);
combPath.push_back(endPoint);
return true;
}
bool success = calcScanlineCrossings(fail_on_unavoidable_obstacles);
if (!success)
{
return false;
}
CombPath basicPath;
getBasicCombingPath(basicPath);
optimizePath(basicPath, combPath);
// combPath = basicPath; // uncomment to disable comb path optimization
return true;
}
void LinePolygonsCrossings::getBasicCombingPath(CombPath& combPath)
{
for (PolyCrossings* crossing = getNextPolygonAlongScanline(transformed_startPoint.X)
; crossing != nullptr
; crossing = getNextPolygonAlongScanline(crossing->max.x))
{
getBasicCombingPath(*crossing, combPath);
}
combPath.push_back(endPoint);
}
void LinePolygonsCrossings::getBasicCombingPath(PolyCrossings& polyCrossings, CombPath& combPath)
{
PolygonRef poly = boundary[polyCrossings.poly_idx];
combPath.push_back(transformation_matrix.unapply(Point(polyCrossings.min.x - std::abs(dist_to_move_boundary_point_outside), transformed_startPoint.Y)));
if ( ( polyCrossings.max.point_idx - polyCrossings.min.point_idx + poly.size() ) % poly.size()
< poly.size() / 2 )
{ // follow the path in the same direction as the winding order of the boundary polygon
for(unsigned int point_idx = polyCrossings.min.point_idx
; point_idx != polyCrossings.max.point_idx
; point_idx = (point_idx < poly.size() - 1) ? (point_idx + 1) : (0))
{
combPath.push_back(PolygonUtils::getBoundaryPointWithOffset(poly, point_idx, dist_to_move_boundary_point_outside));
}
}
else
{ // follow the path in the opposite direction of the winding order of the boundary polygon
unsigned int min_idx = (polyCrossings.min.point_idx == 0)? poly.size() - 1: polyCrossings.min.point_idx - 1;
unsigned int max_idx = (polyCrossings.max.point_idx == 0)? poly.size() - 1: polyCrossings.max.point_idx - 1;
for(unsigned int point_idx = min_idx; point_idx != max_idx; point_idx = (point_idx > 0) ? (point_idx - 1) : (poly.size() - 1))
{
combPath.push_back(PolygonUtils::getBoundaryPointWithOffset(poly, point_idx, dist_to_move_boundary_point_outside));
}
}
combPath.push_back(transformation_matrix.unapply(Point(polyCrossings.max.x + std::abs(dist_to_move_boundary_point_outside), transformed_startPoint.Y)));
}
LinePolygonsCrossings::PolyCrossings* LinePolygonsCrossings::getNextPolygonAlongScanline(int64_t x)
{
PolyCrossings* ret = nullptr;
for(PolyCrossings& crossing : crossings)
{
if (crossing.min.x > x && (ret == nullptr || crossing.min.x < ret->min.x) )
{
ret = &crossing;
}
}
return ret;
}
bool LinePolygonsCrossings::optimizePath(CombPath& comb_path, CombPath& optimized_comb_path)
{
optimized_comb_path.push_back(startPoint);
for(unsigned int point_idx = 1; point_idx<comb_path.size(); point_idx++)
{
if(comb_path[point_idx] == comb_path[point_idx - 1]) //Two points are the same. Skip the second.
{
continue;
}
Point& current_point = optimized_comb_path.back();
if (PolygonUtils::polygonCollidesWithLineSegment(current_point, comb_path[point_idx], loc_to_line_grid))
{
if (PolygonUtils::polygonCollidesWithLineSegment(current_point, comb_path[point_idx - 1], loc_to_line_grid))
{
comb_path.cross_boundary = true;
}
optimized_comb_path.push_back(comb_path[point_idx - 1]);
}
else
{
// : dont add the newest point
// TODO: add the below extra optimization? (+/- 7% extra computation time, +/- 2% faster print for Dual_extrusion_support_generation.stl)
while (optimized_comb_path.size() > 1)
{
if (PolygonUtils::polygonCollidesWithLineSegment(optimized_comb_path[optimized_comb_path.size() - 2], comb_path[point_idx], loc_to_line_grid))
{
break;
}
else
{
optimized_comb_path.pop_back();
}
}
}
}
optimized_comb_path.push_back(comb_path.back());
return true;
}
}//namespace cura
@@ -1,20 +1,15 @@
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef COMB_H
#define COMB_H
#ifndef PATH_PLANNING_LINE_POLYGONS_CROSSINGS_H
#define PATH_PLANNING_LINE_POLYGONS_CROSSINGS_H
#include "utils/polygon.h"
#include "../utils/polygon.h"
#include "../utils/polygonUtils.h"
#include "../utils/SparseLineGrid.h"
#include "CombPath.h"
namespace cura
{
struct CombPath : public std::vector<Point> //!< A single path either inside or outise the parts
{
bool throughAir = false; //!< Whether the path is one which moves through air.
bool cross_boundary = false; //!< Whether the path crosses a boundary.
};
struct CombPaths : public std::vector<CombPath> //!< A list of paths alternating between inside a part and outside a part
{
};
/*!
* Class for generating a combing move action from point a to point b and avoiding collision with other parts when moving through air.
@@ -60,6 +55,7 @@ private:
unsigned int poly_idx; //!< The index of the polygon which crosses the scanline
Crossing min; //!< The point where the polygon first crosses the scanline.
Crossing max; //!< The point where the polygon last crosses the scanline.
int n_crossings; //!< The number of times the polygon crossed the scanline.
/*!
* Create a PolyCrossings with minimal initialization. PolyCrossings::min and PolyCrossings::max are not yet computed.
* \param poly_idx The index of the polygon in LinePolygonsCrossings::boundary
@@ -67,6 +63,7 @@ private:
PolyCrossings(unsigned int poly_idx)
: poly_idx(poly_idx)
, min(INT64_MAX, NO_INDEX), max(INT64_MIN, NO_INDEX)
, n_crossings(0)
{
}
};
@@ -85,14 +82,15 @@ private:
unsigned int max_crossing_idx; //!< The index into LinePolygonsCrossings::crossings to the crossing with the maximal PolyCrossings::max crossing of all PolyCrossings's.
Polygons& boundary; //!< The boundary not to cross during combing.
LocToLineGrid& loc_to_line_grid; //!< Mapping from locations to line segments of \ref LinePolygonsCrossings::boundary
Point startPoint; //!< The start point of the scanline.
Point endPoint; //!< The end point of the scanline.
int64_t dist_to_move_boundary_point_outside; //!< The distance used to move outside or inside so that a boundary point doesn't intersect with the boundary anymore. Neccesary due to computational rounding problems. Use negative value for insicde combing.
PointMatrix transformation_matrix; //!< The transformation which rotates everything such that the scanline is aligned with the x-axis.
Point transformed_startPoint; //!< The LinePolygonsCrossings::startPoint as transformed by Comb::transformation_matrix
Point transformed_endPoint; //!< The LinePolygonsCrossings::endPoint as transformed by Comb::transformation_matrix
Point transformed_startPoint; //!< The LinePolygonsCrossings::startPoint as transformed by Comb::transformation_matrix such that it has (roughly) the same Y as transformed_endPoint
Point transformed_endPoint; //!< The LinePolygonsCrossings::endPoint as transformed by Comb::transformation_matrix such that it has (roughly) the same Y as transformed_startPoint
/*!
@@ -105,15 +103,19 @@ private:
/*!
* Calculate Comb::crossings, Comb::min_crossing_idx and Comb::max_crossing_idx.
* \param fail_on_unavoidable_obstacles When moving over other parts is inavoidable, stop calculation early and return false.
* \return Whether combing succeeded, i.e. when fail_on_unavoidable_obstacles: we didn't cross any gaps/other parts
*/
void calcScanlineCrossings();
bool calcScanlineCrossings(bool fail_on_unavoidable_obstacles);
/*!
* Get the basic combing path and optimize it.
*
* \param combPath Output parameter: the points along the combing path.
* \param fail_on_unavoidable_obstacles When moving over other parts is inavoidable, stop calculation early and return false.
* \return Whether combing succeeded, i.e. we didn't cross any gaps/other parts
*/
void getCombingPath(CombPath& combPath, int64_t max_comb_distance_ignored = MM2INT(1.5));
bool getCombingPath(CombPath& combPath, int64_t max_comb_distance_ignored, bool fail_on_unavoidable_obstacles);
/*!
* Get the basic combing path, without shortcuts. The path goes straight toward the endPoint and follows the boundary when it hits it, until it passes the scanline again.
@@ -164,8 +166,12 @@ private:
* \param end the end point
* \param dist_to_move_boundary_point_outside Distance used to move a point from a boundary so that it doesn't intersect with it anymore. (Precision issue)
*/
LinePolygonsCrossings(Polygons& boundary, Point& start, Point& end, int64_t dist_to_move_boundary_point_outside)
: boundary(boundary), startPoint(start), endPoint(end), dist_to_move_boundary_point_outside(dist_to_move_boundary_point_outside)
LinePolygonsCrossings(Polygons& boundary, LocToLineGrid& loc_to_line_grid, Point& start, Point& end, int64_t dist_to_move_boundary_point_outside)
: boundary(boundary)
, loc_to_line_grid(loc_to_line_grid)
, startPoint(start)
, endPoint(end)
, dist_to_move_boundary_point_outside(dist_to_move_boundary_point_outside)
{
}
@@ -174,84 +180,20 @@ public:
/*!
* The main function of this class: calculate one combing path within the boundary.
* \param boundary The polygons to follow when calculating the basic combing path
* \param loc_to_line_grid A sparse grid mapping cells to all line segments of (at least) \p boundary in those cells
* \param startPoint From where to start the combing move.
* \param endPoint Where to end the combing move.
* \param combPath Output parameter: the combing path generated.
* \param fail_on_unavoidable_obstacles When moving over other parts is inavoidable, stop calculation early and return false.
* \return Whether combing succeeded, i.e. we didn't cross any gaps/other parts
*/
static void comb(Polygons& boundary, Point startPoint, Point endPoint, CombPath& combPath, int64_t dist_to_move_boundary_point_outside, int64_t max_comb_distance_ignored = MM2INT(1.5))
static bool comb(Polygons& boundary, LocToLineGrid& loc_to_line_grid, Point startPoint, Point endPoint, CombPath& combPath, int64_t dist_to_move_boundary_point_outside, int64_t max_comb_distance_ignored, bool fail_on_unavoidable_obstacles)
{
LinePolygonsCrossings linePolygonsCrossings(boundary, startPoint, endPoint, dist_to_move_boundary_point_outside);
linePolygonsCrossings.getCombingPath(combPath, max_comb_distance_ignored);
LinePolygonsCrossings linePolygonsCrossings(boundary, loc_to_line_grid, startPoint, endPoint, dist_to_move_boundary_point_outside);
return linePolygonsCrossings.getCombingPath(combPath, max_comb_distance_ignored, fail_on_unavoidable_obstacles);
};
};
class SliceDataStorage;
/*!
* Class for generating a full combing actions from a travel move from a start point to an end point.
* A single Comb object is used for each layer.
*
* Comb::calc is the main function of this class.
*
* Typical output: A combing path to the boundary of the polygon + a move through air avoiding other parts in the layer + a combing path from the boundary of the ending polygon to the end point.
* Each of these three is a CombPath; the first and last are within Comb::boundary_inside while the middle is outside of Comb::boundary_outside.
* Between these there is a little gap where the nozzle crosses the boundary of an object approximately perpendicular to its boundary.
*
* As an optimization, the combing paths inside are calculated on specifically those PolygonsParts within which to comb, while the coundary_outside isn't split into outside parts,
* because generally there is only one outside part; encapsulated holes occur less often.
*/
class Comb
{
friend class LinePolygonsCrossings;
private:
SliceDataStorage& storage; //!< The storage from which to compute the outside boundary, when needed.
int layer_nr; //!< The layer number for the layer for which to compute the outside boundary, when needed.
int64_t offset_from_outlines; //!< Offset from the boundary of a part to the comb path. (nozzle width / 2)
int64_t max_moveInside_distance2; //!< Maximal distance of a point to the Comb::boundary_inside which is still to be considered inside. (very sharp corners not allowed :S)
int64_t offset_from_outlines_outside; //!< Offset from the boundary of a part to a travel path which avoids it by this distance.
static const int64_t max_moveOutside_distance2 = INT64_MAX; //!< Any point which is not inside should be considered outside.
static const int64_t offset_dist_to_get_from_on_the_polygon_to_outside = 40; //!< in order to prevent on-boundary vs crossing boundary confusions (precision thing)
static const int64_t offset_extra_start_end = 100; //!< Distance to move start point and end point toward eachother to extra avoid collision with the boundaries.
bool avoid_other_parts; //!< Whether to perform inverse combing a.k.a. avoid parts.
Polygons& boundary_inside; //!< The boundary within which to comb.
Polygons* boundary_outside; //!< The boundary outside of which to stay to avoid collision with other layer parts. This is a pointer cause we only compute it when we move outside the boundary (so not when there is only a single part in the layer)
PartsView partsView_inside; //!< Structured indices onto boundary_inside which shows which polygons belong to which part.
/*!
* Get the boundary_outside, which is an offset from the outlines of all meshes in the layer. Calculate it when it hasn't been calculated yet.
*/
Polygons* getBoundaryOutside();
public:
/*!
* Initializes the combing areas for every mesh in the layer (not support)
* \param storage Where the layer polygon data is stored
* \param layer_nr The number of the layer for which to generate the combing areas.
* \param comb_boundary_inside The comb boundary within which to comb within layer parts.
* \param offset_from_outlines The offset from the outline polygon, to create the combing boundary in case there is no second wall.
* \param travel_avoid_other_parts Whether to avoid other layer parts when traveling through air.
* \param travel_avoid_distance The distance by which to avoid other layer parts when traveling through air.
*/
Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
~Comb();
/*!
* Calculate the comb paths (if any) - one for each polygon combed alternated with travel paths
*
* \param startPoint Where to start moving from
* \param endPoint Where to move to
* \param combPoints Output parameter: The points along the combing path, excluding the \p startPoint (?) and \p endPoint
* \param startInside Whether we want to start inside the comb boundary
* \param endInside Whether we want to end up inside the comb boundary
* \return Whether combing has succeeded; otherwise a retraction is needed.
*/
bool calc(Point startPoint, Point endPoint, CombPaths& combPaths, bool startInside = false, bool endInside = false, int64_t max_comb_distance_ignored = MM2INT(1.5));
};
}//namespace cura
#endif//COMB_H
#endif//PATH_PLANNING_LINE_POLYGONS_CROSSINGS_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

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais