├── .clang-format ├── .clang-tidy ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── benchmark.yml │ ├── gcodeanalyzer.yml │ ├── lint-formatter.yml │ ├── lint-poster.yml │ ├── lint-tidier.yml │ ├── package.yml │ ├── process-pull-request.yml │ ├── scorecard.yml │ ├── stress_benchmark.yml │ ├── unit-test-post.yml │ └── unit-test.yml ├── .gitignore ├── CMakeLists.txt ├── Cura.proto ├── CuraEngine.ico ├── CuraEngine.rc ├── FUNDING.yml ├── LICENSE ├── README.md ├── SECURITY.md ├── benchmark ├── CMakeLists.txt ├── holes.wkt ├── infill_benchmark.h ├── main.cpp ├── scoring_benchmark.h ├── simplify_benchmark.h └── wall_benchmark.h ├── conandata.yml ├── conanfile.py ├── doc └── gradual_overhang_speed.svg ├── include ├── Application.h ├── BeadingStrategy │ ├── BeadingStrategy.h │ ├── BeadingStrategyFactory.h │ ├── DistributedBeadingStrategy.h │ ├── LimitedBeadingStrategy.h │ ├── OuterWallInsetBeadingStrategy.h │ ├── RedistributeBeadingStrategy.h │ └── WideningBeadingStrategy.h ├── BoostInterface.hpp ├── ConicalOverhang.h ├── ExtruderPlan.h ├── ExtruderPrime.h ├── ExtruderTrain.h ├── ExtruderUse.h ├── FanSpeedLayerTime.h ├── FffGcodeWriter.h ├── FffPolygonGenerator.h ├── FffProcessor.h ├── GCodePathConfig.h ├── InsetOrderOptimizer.h ├── InterlockingGenerator.h ├── LayerPlan.h ├── LayerPlanBuffer.h ├── MeshGroup.h ├── Mold.h ├── PathAdapter.h ├── PathOrder.h ├── PathOrderMonotonic.h ├── PathOrderOptimizer.h ├── Preheat.h ├── PrimeTower.h ├── PrimeTower │ ├── PrimeTower.h │ ├── PrimeTowerInterleaved.h │ └── PrimeTowerNormal.h ├── PrintFeature.h ├── RetractionConfig.h ├── Scene.h ├── SkeletalTrapezoidation.h ├── SkeletalTrapezoidationEdge.h ├── SkeletalTrapezoidationGraph.h ├── SkeletalTrapezoidationJoint.h ├── SkirtBrim.h ├── Slice.h ├── SpaceFillType.h ├── SupportInfillPart.h ├── TopSurface.h ├── TreeModelVolumes.h ├── TreeSupport.h ├── TreeSupportBaseCircle.h ├── TreeSupportElement.h ├── TreeSupportEnums.h ├── TreeSupportSettings.h ├── TreeSupportTipGenerator.h ├── TreeSupportUtils.h ├── WallToolPaths.h ├── WallsComputation.h ├── WipeScriptConfig.h ├── bridge.h ├── communication │ ├── ArcusCommunication.h │ ├── ArcusCommunicationPrivate.h │ ├── CommandLine.h │ ├── Communication.h │ ├── EmscriptenCommunication.h │ ├── Listener.h │ └── SliceDataStruct.h ├── gcodeExport.h ├── geometry │ ├── ClosedLinesSet.h │ ├── ClosedPolyline.h │ ├── LinesSet.h │ ├── MixedLinesSet.h │ ├── OpenLinesSet.h │ ├── OpenPolyline.h │ ├── PartsView.h │ ├── Point2LL.h │ ├── Point3LL.h │ ├── Point3Matrix.h │ ├── PointMatrix.h │ ├── PointsSet.h │ ├── Polygon.h │ ├── Polyline.h │ ├── SegmentIterator.h │ ├── Shape.h │ └── SingleShape.h ├── gradual_flow │ ├── FlowLimitedPath.h │ ├── Processor.h │ └── Utils.h ├── infill.h ├── infill │ ├── DensityProvider.h │ ├── GyroidInfill.h │ ├── ImageBasedDensityProvider.h │ ├── LightningDistanceField.h │ ├── LightningGenerator.h │ ├── LightningLayer.h │ ├── LightningTreeNode.h │ ├── NoZigZagConnectorProcessor.h │ ├── SierpinskiFill.h │ ├── SierpinskiFillProvider.h │ ├── SubDivCube.h │ ├── UniformDensityProvider.h │ └── ZigzagConnectorProcessor.h ├── layerPart.h ├── mesh.h ├── multiVolumes.h ├── pathPlanning │ ├── Comb.h │ ├── CombPath.h │ ├── CombPaths.h │ ├── GCodePath.h │ ├── LinePolygonsCrossings.h │ ├── NozzleTempInsert.h │ ├── SpeedDerivatives.h │ └── TimeMaterialEstimates.h ├── path_ordering.h ├── plugins │ ├── broadcasts.h │ ├── converters.h │ ├── exception.h │ ├── metadata.h │ ├── pluginproxy.h │ ├── slotproxy.h │ ├── slots.h │ ├── types.h │ └── validator.h ├── progress │ ├── Progress.h │ ├── ProgressEstimator.h │ ├── ProgressEstimatorLinear.h │ └── ProgressStageEstimator.h ├── raft.h ├── settings │ ├── AdaptiveLayerHeights.h │ ├── EnumSettings.h │ ├── FlowTempGraph.h │ ├── MeshPathConfigs.h │ ├── PathConfigStorage.h │ ├── Settings.h │ ├── ZSeamConfig.h │ └── types │ │ ├── Angle.h │ │ ├── Duration.h │ │ ├── LayerIndex.h │ │ ├── Ratio.h │ │ ├── Temperature.h │ │ └── Velocity.h ├── skin.h ├── sliceDataStorage.h ├── slicer.h ├── support.h ├── timeEstimate.h └── utils │ ├── AABB.h │ ├── AABB3D.h │ ├── Coord_t.h │ ├── Date.h │ ├── ExtrusionJunction.h │ ├── ExtrusionLine.h │ ├── ExtrusionLineStitcher.h │ ├── ExtrusionSegment.h │ ├── HalfEdge.h │ ├── HalfEdgeGraph.h │ ├── HalfEdgeNode.h │ ├── LayerVector.h │ ├── ListPolyIt.h │ ├── Matrix4x3D.h │ ├── MinimumSpanningTree.h │ ├── MixedPolylineStitcher.h │ ├── NoCopy.h │ ├── OpenPolylineStitcher.h │ ├── PairHash.h │ ├── Point3D.h │ ├── Point3F.h │ ├── PolygonConnector.h │ ├── PolygonsPointIndex.h │ ├── PolygonsSegmentIndex.h │ ├── PolylineStitcher.h │ ├── SVG.h │ ├── Simplify.h │ ├── SparseGrid.h │ ├── SparseLineGrid.h │ ├── SparsePointGrid.h │ ├── SparsePointGridInclusive.h │ ├── SquareGrid.h │ ├── ThreadPool.h │ ├── ToolpathVisualizer.h │ ├── UnionFind.h │ ├── VoronoiUtils.h │ ├── VoxelUtils.h │ ├── actions │ └── smooth.h │ ├── algorithm.h │ ├── channel.h │ ├── format │ ├── filesystem_path.h │ └── thread_id.h │ ├── gettime.h │ ├── linearAlg2D.h │ ├── macros.h │ ├── math.h │ ├── orderOptimizer.h │ ├── polygonUtils.h │ ├── resources │ └── certificate.pem.h │ ├── scoring │ ├── BestElementFinder.h │ ├── CornerScoringCriterion.h │ ├── DistanceScoringCriterion.h │ ├── ExclusionAreaScoringCriterion.h │ ├── RandomScoringCriterion.h │ └── ScoringCriterion.h │ ├── section_type.h │ ├── string.h │ ├── types │ ├── arachne.h │ ├── char_range_literal.h │ ├── generic.h │ ├── geometry.h │ ├── get.h │ ├── graph.h │ ├── numeric_facade.h │ └── string_switch.h │ └── views │ ├── bounding_box.h │ ├── convert.h │ ├── dfs.h │ ├── get.h │ └── split_paths.h ├── src ├── Application.cpp ├── BeadingStrategy │ ├── BeadingStrategy.cpp │ ├── BeadingStrategyFactory.cpp │ ├── DistributedBeadingStrategy.cpp │ ├── LimitedBeadingStrategy.cpp │ ├── OuterWallInsetBeadingStrategy.cpp │ ├── RedistributeBeadingStrategy.cpp │ └── WideningBeadingStrategy.cpp ├── ConicalOverhang.cpp ├── ExtruderPlan.cpp ├── ExtruderTrain.cpp ├── FffGcodeWriter.cpp ├── FffPolygonGenerator.cpp ├── FffProcessor.cpp ├── GCodePathConfig.cpp ├── InsetOrderOptimizer.cpp ├── InterlockingGenerator.cpp ├── LayerPlan.cpp ├── LayerPlanBuffer.cpp ├── MeshGroup.cpp ├── Mold.cpp ├── PathAdapter.cpp ├── Preheat.cpp ├── PrimeTower.cpp ├── PrimeTower │ ├── PrimeTower.cpp │ ├── PrimeTowerInterleaved.cpp │ └── PrimeTowerNormal.cpp ├── Scene.cpp ├── SkeletalTrapezoidation.cpp ├── SkeletalTrapezoidationGraph.cpp ├── SkirtBrim.cpp ├── Slice.cpp ├── SupportInfillPart.cpp ├── TopSurface.cpp ├── TreeModelVolumes.cpp ├── TreeSupport.cpp ├── TreeSupportTipGenerator.cpp ├── WallToolPaths.cpp ├── WallsComputation.cpp ├── bridge.cpp ├── communication │ ├── ArcusCommunication.cpp │ ├── ArcusCommunicationPrivate.cpp │ ├── CommandLine.cpp │ ├── EmscriptenCommunication.cpp │ └── Listener.cpp ├── gcodeExport.cpp ├── geometry │ ├── ClosedPolyline.cpp │ ├── LinesSet.cpp │ ├── MixedLinesSet.cpp │ ├── PartsView.cpp │ ├── Point2LL.cpp │ ├── Point3LL.cpp │ ├── PointsSet.cpp │ ├── Polygon.cpp │ ├── Polyline.cpp │ ├── Shape.cpp │ └── SingleShape.cpp ├── infill.cpp ├── infill │ ├── GyroidInfill.cpp │ ├── ImageBasedDensityProvider.cpp │ ├── LightningDistanceField.cpp │ ├── LightningGenerator.cpp │ ├── LightningLayer.cpp │ ├── LightningTreeNode.cpp │ ├── NoZigZagConnectorProcessor.cpp │ ├── SierpinskiFill.cpp │ ├── SierpinskiFillProvider.cpp │ ├── SubDivCube.cpp │ └── ZigzagConnectorProcessor.cpp ├── layerPart.cpp ├── main.cpp ├── mesh.cpp ├── multiVolumes.cpp ├── pathPlanning │ ├── Comb.cpp │ ├── GCodePath.cpp │ ├── LinePolygonsCrossings.cpp │ ├── NozzleTempInsert.cpp │ └── SpeedDerivatives.cpp ├── path_ordering.cpp ├── plugins │ └── converters.cpp ├── progress │ ├── Progress.cpp │ └── ProgressStageEstimator.cpp ├── raft.cpp ├── settings │ ├── AdaptiveLayerHeights.cpp │ ├── FlowTempGraph.cpp │ ├── MeshPathConfigs.cpp │ ├── PathConfigStorage.cpp │ ├── Settings.cpp │ └── ZSeamConfig.cpp ├── skin.cpp ├── sliceDataStorage.cpp ├── slicer.cpp ├── support.cpp ├── timeEstimate.cpp └── utils │ ├── AABB.cpp │ ├── AABB3D.cpp │ ├── Date.cpp │ ├── ExtrusionJunction.cpp │ ├── ExtrusionLine.cpp │ ├── ExtrusionSegment.cpp │ ├── ListPolyIt.cpp │ ├── Matrix4x3D.cpp │ ├── MinimumSpanningTree.cpp │ ├── MixedPolylineStitcher.cpp │ ├── PolygonConnector.cpp │ ├── PolygonsPointIndex.cpp │ ├── PolygonsSegmentIndex.cpp │ ├── PolylineStitcher.cpp │ ├── SVG.cpp │ ├── Simplify.cpp │ ├── SquareGrid.cpp │ ├── ThreadPool.cpp │ ├── ToolpathVisualizer.cpp │ ├── VoronoiUtils.cpp │ ├── VoxelUtils.cpp │ ├── channel.cpp │ ├── gettime.cpp │ ├── linearAlg2D.cpp │ ├── polygonUtils.cpp │ └── scoring │ ├── BestElementFinder.cpp │ ├── CornerScoringCriterion.cpp │ ├── DistanceScoringCriterion.cpp │ ├── ExclusionAreaScoringCriterion.cpp │ └── RandomScoringCriterion.cpp ├── stress_benchmark ├── CMakeLists.txt ├── resources │ ├── 001.settings │ ├── 001.wkt │ ├── 002.settings │ ├── 002.wkt │ ├── 003.settings │ ├── 003.wkt │ ├── 004.settings │ ├── 004.wkt │ ├── 005.settings │ ├── 005.wkt │ ├── 006.settings │ ├── 006.wkt │ ├── 007.settings │ ├── 007.wkt │ ├── 008.settings │ ├── 008.wkt │ ├── 009.settings │ ├── 009.wkt │ ├── 010.settings │ ├── 010.wkt │ ├── 011.settings │ ├── 011.wkt │ ├── 012.settings │ ├── 012.wkt │ ├── 013.settings │ ├── 013.wkt │ ├── 014.settings │ ├── 014.wkt │ ├── 015.settings │ ├── 015.wkt │ ├── 016.settings │ ├── 016.wkt │ ├── 017.settings │ ├── 017.wkt │ ├── 018.settings │ ├── 018.wkt │ ├── 019.settings │ ├── 019.wkt │ ├── 020.settings │ ├── 020.wkt │ ├── 021.settings │ ├── 021.wkt │ ├── 022.settings │ ├── 022.wkt │ ├── 023.settings │ ├── 023.wkt │ ├── 024.settings │ ├── 024.wkt │ ├── 025.settings │ ├── 025.wkt │ ├── 026.settings │ ├── 026.wkt │ ├── 027.settings │ ├── 027.wkt │ ├── 028.settings │ ├── 028.wkt │ ├── 029.settings │ ├── 029.wkt │ ├── 030.settings │ ├── 030.wkt │ ├── 031.settings │ ├── 031.wkt │ ├── 032.settings │ ├── 032.wkt │ ├── 033.settings │ ├── 033.wkt │ ├── 034.settings │ ├── 034.wkt │ ├── 035.settings │ ├── 035.wkt │ ├── 036.settings │ ├── 036.wkt │ ├── 037.settings │ ├── 037.wkt │ ├── 038.settings │ ├── 038.wkt │ ├── 039.settings │ ├── 039.wkt │ ├── 040.settings │ ├── 040.wkt │ ├── 041.settings │ ├── 041.wkt │ ├── 042.settings │ ├── 042.wkt │ ├── 043.settings │ ├── 043.wkt │ ├── 044.settings │ ├── 044.wkt │ ├── 045.settings │ ├── 045.wkt │ ├── 046.settings │ ├── 046.wkt │ ├── 047.settings │ ├── 047.wkt │ ├── 048.settings │ ├── 048.wkt │ ├── 049.settings │ ├── 049.wkt │ ├── 050.settings │ ├── 050.wkt │ ├── 051.settings │ ├── 051.wkt │ ├── 052.settings │ ├── 052.wkt │ ├── 053.settings │ ├── 053.wkt │ ├── 055.settings │ ├── 055.wkt │ ├── 056.settings │ ├── 056.wkt │ ├── 058.settings │ ├── 058.wkt │ ├── 059.settings │ ├── 059.wkt │ ├── 060.settings │ ├── 060.wkt │ ├── 062.settings │ ├── 062.wkt │ ├── 065.settings │ ├── 065.wkt │ ├── 066.settings │ └── 066.wkt └── stress_benchmark.cpp ├── test_package └── conanfile.py └── tests ├── CMakeLists.txt ├── ClipperTest.cpp ├── ExtruderPlanTest.cpp ├── FffGcodeWriterTest.cpp ├── GCodeExportTest.cpp ├── InfillTest.cpp ├── LayerPlanTest.cpp ├── PathOrderMonotonicTest.cpp ├── PathOrderOptimizerTest.cpp ├── ReadTestPolygons.cpp ├── ReadTestPolygons.h ├── TimeEstimateCalculatorTest.cpp ├── WallsComputationTest.cpp ├── arcus ├── ArcusCommunicationPrivateTest.cpp ├── ArcusCommunicationTest.cpp ├── MockCommunication.h ├── MockSocket.cpp └── MockSocket.h ├── cube_vertices.txt ├── integration ├── SlicePhaseTest.cpp └── resources │ ├── cube.stl │ └── cylinder1000.stl ├── main.cpp ├── resources ├── polygon_concave.txt ├── polygon_concave_hole.txt ├── polygon_letter_y.txt ├── polygon_sawtooth.txt ├── polygon_slant_gap.txt ├── polygon_square.txt ├── polygon_square_hole.txt ├── polygon_triangle.txt ├── polygon_two_squares.txt ├── slice_polygon_1.txt ├── slice_polygon_2.txt ├── slice_polygon_3.txt └── slice_polygon_4.txt ├── runtest.py ├── settings └── SettingsTest.cpp ├── testModel.stl ├── test_default_settings.txt ├── test_global_settings.txt └── utils ├── AABB3DTest.cpp ├── AABBTest.cpp ├── IntPointTest.cpp ├── LinearAlg2DTest.cpp ├── MathTest.cpp ├── MinimumSpanningTreeTest.cpp ├── PolygonConnectorTest.cpp ├── PolygonTest.cpp ├── PolygonUtilsTest.cpp ├── SimplifyTest.cpp ├── SmoothTest.cpp ├── SparseGridTest.cpp ├── StringTest.cpp ├── UnionFindTest.cpp └── VoxelUtilsTest.cpp /.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: > 2 | *, 3 | -llvmlibc-*, 4 | -modernize-use-trailing-return-type, 5 | -altera-unroll-loops*, 6 | -readability-avoid-const-params-in-decls, 7 | -fuchsia-default-arguments-calls, 8 | -google-readability-todo, 9 | -altera-struct-pack-align, 10 | -android-*, 11 | -misc-non-private-member-variables-in-classes, 12 | -fuchsia-overloaded-operator, 13 | -cppcoreguidelines-avoid-capturing-lambda-coroutines, 14 | -llvm-header-guard, 15 | -bugprone-easily-swappable-parameters, 16 | -*-default-arguments-declarations 17 | WarningsAsErrors: '-*' 18 | HeaderFilterRegex: '' 19 | FormatStyle: none 20 | CheckOptions: 21 | - key: google-build-namespaces.HeaderFileExtensions 22 | value: h 23 | - key: readability-function-size.LineThreshold 24 | value: 100 25 | - key: readability-function-size.BranchThreshold 26 | value: 10 27 | - key: readability-function-size.ParameterThreshold 28 | value: 6 29 | - key: readability-function-size.NestingThreshold 30 | value: 4 31 | - key: readability-identifier-naming.NamespaceCase 32 | value: lower_case 33 | - key: readability-identifier-naming.MacroDefinitionCase 34 | value: UPPER_CASE 35 | - key: readability-identifier-naming.ClassCase 36 | value: CamelCase 37 | - key: readability-identifier-naming.FunctionCase 38 | value: camelBack 39 | - key: readability-identifier-naming.MethodCase 40 | value: camelBack 41 | - key: readability-identifier-naming.ParameterCase 42 | value: lower_case 43 | - key: readability-identifier-naming.VariableCase 44 | value: lower_case 45 | - key: readability-identifier-naming.ClassConstantCase 46 | value: UPPER_CASE 47 | - key: readability-identifier-naming.GlobalConstantCase 48 | value: lower_case 49 | - key: readability-identifier-naming.GlobalVariableCase 50 | value: UPPER_CASE 51 | - key: readability-identifier-length.IgnoredParameterNames 52 | value: 'p|p0|p1|i|j|k|x|X|y|Y|z|Z|a|A|b|B|c|C|d|D|ab|AB|ba|BA|bc|BC|cb|CB|cd|CD|dc|DC|ad|AD|da|DA|ip|os' 53 | - key: readability-identifier-length.IgnoredVariableNames 54 | value: '_p|p0|p1|i|j|k|x|X|y|Y|z|Z|a|A|b|B|c|C|d|D|ab|AB|ba|BA|bc|BC|cb|CB|cd|CD|dc|DC|ad|AD|da|DA|ip|os' 55 | - key: readability-identifier-length.IgnoredLoopCounterNames 56 | value: '_p|p0|p1|i|j|k|x|X|y|Y|z|Z|a|A|b|B|c|C|d|D|ab|AB|ba|BA|bc|BC|cb|CB|cd|CD|dc|DC|ad|AD|da|DA|ip|os' 57 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | **Application Version** 15 | 16 | 17 | **Platform** 18 | 19 | 20 | **Qt** 21 | 22 | 23 | **PyQt** 24 | 25 | 26 | **Display Driver** 27 | 28 | 29 | **Steps to Reproduce** 30 | 31 | 32 | **Actual Results** 33 | 34 | 35 | **Expected results** 36 | 37 | 38 | **Additional Information** 39 | 40 | 41 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | 7 | 8 | ## Type of change 9 | 10 | 11 | 12 | - [ ] Bug fix (non-breaking change which fixes an issue) 13 | - [ ] New feature (non-breaking change which adds functionality) 14 | 15 | # How Has This Been Tested? 16 | 17 | 18 | 19 | - [ ] Test A 20 | - [ ] Test B 21 | 22 | **Test Configuration**: 23 | * Operating System: 24 | 25 | # Checklist: 26 | 27 | - [ ] My code follows the style guidelines of this project as described in [UltiMaker Meta](https://github.com/Ultimaker/Meta) 28 | - [ ] I have read the [Contribution guide](https://github.com/Ultimaker/Cura/blob/main/contributing.md) 29 | - [ ] I have commented my code, particularly in hard-to-understand areas 30 | - [ ] I have uploaded any files required to test this change -------------------------------------------------------------------------------- /.github/workflows/benchmark.yml: -------------------------------------------------------------------------------- 1 | name: Benchmark 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'include/**' 7 | - 'src/**' 8 | - 'benchmark/**' 9 | - '.github/workflows/benchmark.yml' 10 | branches: 11 | - main 12 | 13 | pull_request: 14 | types: [ opened, reopened, synchronize ] 15 | paths: 16 | - 'include/**' 17 | - 'src/**' 18 | - 'benchmark/**' 19 | - '.github/workflows/benchmark.yml' 20 | branches: 21 | - main 22 | - 'CURA-*' 23 | - 'PP-*' 24 | - 'NP-*' 25 | - '[0-9]+.[0-9]+' 26 | 27 | permissions: 28 | contents: write 29 | deployments: write 30 | 31 | 32 | jobs: 33 | check_actor: 34 | uses: ultimaker/cura-workflows/.github/workflows/check-actor.yml@main 35 | secrets: inherit 36 | 37 | benchmark: 38 | uses: ultimaker/cura-workflows/.github/workflows/benchmark.yml@main 39 | with: 40 | conan_extra_args: "-c tools.build:skip_test=False -o \"curaengine/*:enable_benchmarks=True\"" 41 | benchmark_cmd: "benchmark/benchmarks --benchmark_format=json --benchmark_out=benchmark_result.json" 42 | name: "C++ Benchmark" 43 | output_file_path: "benchmark_result.json" 44 | data_dir: "dev/bench" 45 | tool: "googlecpp" 46 | alert_threshold: "150%" 47 | alert_comment_cc_users: "@nallath, @jellespijker, @wawanbreton, @casperlamboo, @saumyaj3, @HellAholic" 48 | secrets: inherit 49 | -------------------------------------------------------------------------------- /.github/workflows/lint-formatter.yml: -------------------------------------------------------------------------------- 1 | name: lint-formatter 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'include/**/*.h*' 7 | - 'src/**/*.c*' 8 | 9 | pull_request: 10 | types: [ opened ] 11 | paths: 12 | - 'include/**/*.h*' 13 | - 'src/**/*.c*' 14 | 15 | jobs: 16 | lint-formatter-job: 17 | uses: ultimaker/cura-workflows/.github/workflows/lint-formatter.yml@main 18 | with: 19 | file_patterns: +(include|src)/**/*.+(h|hpp|c|cpp) 20 | command: clang-format --verbose -i 21 | commit_message: "Apply clang-format" 22 | -------------------------------------------------------------------------------- /.github/workflows/lint-tidier.yml: -------------------------------------------------------------------------------- 1 | name: lint-tidier 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | pull_request: 7 | paths: 8 | - 'include/**/*.h*' 9 | - 'src/**/*.c*' 10 | 11 | jobs: 12 | lint-tidier-job: 13 | name: Auto-apply clang-tidy 14 | uses: ultimaker/cura-workflows/.github/workflows/lint-tidier.yml@main 15 | -------------------------------------------------------------------------------- /.github/workflows/package.yml: -------------------------------------------------------------------------------- 1 | name: package 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'include/**' 7 | - 'src/**' 8 | - 'test_package/**' 9 | - 'conanfile.py' 10 | - 'conandata.yml' 11 | - 'CMakeLists.txt' 12 | - '.github/workflows/package.yml' 13 | branches: 14 | - main 15 | - 'CURA-*' 16 | - 'PP-*' 17 | - 'NP-*' 18 | - '[0-9].[0-9]*' 19 | - '[0-9].[0-9][0-9]*' 20 | tags: 21 | - '[0-9]+.[0-9]+.[0-9]*' 22 | - '[0-9]+.[0-9]+.[0-9]' 23 | pull_request: 24 | types: [opened, reopened, synchronize] 25 | paths: 26 | - 'include/**' 27 | - 'src/**' 28 | - 'test_package/**' 29 | - 'conanfile.py' 30 | - 'conandata.yml' 31 | - 'CMakeLists.txt' 32 | - '.github/workflows/package.yml' 33 | branches: 34 | - main 35 | - 'CURA-*' 36 | - 'PP-*' 37 | - 'NP-*' 38 | - '[0-9].[0-9]*' 39 | - '[0-9].[0-9][0-9]*' 40 | 41 | jobs: 42 | conan-package: 43 | uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main 44 | with: 45 | platform_wasm: true 46 | secrets: inherit 47 | 48 | npm-package: 49 | needs: [ conan-package ] 50 | if: ${{ ((github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'NP-') || startsWith(github.ref_name, '5.'))) || (github.event_name == 'pull_request' && (github.base_ref == 'main' || startsWith(github.head_ref, '5.'))))}} # FIXME: have a more generic way to determine release branches 51 | uses: ultimaker/cura-workflows/.github/workflows/npm-package.yml@main 52 | with: 53 | package_version_full: ${{ needs.conan-package.outputs.package_version_full }} 54 | secrets: inherit 55 | -------------------------------------------------------------------------------- /.github/workflows/process-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: process-pull-request 2 | 3 | on: 4 | pull_request_target: 5 | types: [ opened, reopened, edited, synchronize, review_requested, ready_for_review, assigned ] 6 | 7 | jobs: 8 | add_label: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: actions-ecosystem/action-add-labels@v1 13 | if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} 14 | with: 15 | labels: 'PR: Community Contribution :crown:' 16 | -------------------------------------------------------------------------------- /.github/workflows/stress_benchmark.yml: -------------------------------------------------------------------------------- 1 | name: Stress Benchmark 2 | on: 3 | push: 4 | paths: 5 | - 'include/**' 6 | - 'src/**' 7 | - 'stress_benchmark/**' 8 | - '.github/workflows/stress_benchmark.yml' 9 | branches: 10 | - main 11 | 12 | pull_request: 13 | types: [ opened, reopened, synchronize ] 14 | paths: 15 | - 'include/**' 16 | - 'src/**' 17 | - 'stress_benchmark/**' 18 | - '.github/workflows/stress_benchmark.yml' 19 | branches: 20 | - main 21 | - 'CURA-*' 22 | - 'PP-*' 23 | - 'NP-*' 24 | - '[0-9]+.[0-9]+' 25 | 26 | permissions: 27 | contents: write 28 | deployments: write 29 | 30 | 31 | jobs: 32 | check_actor: 33 | uses: ultimaker/cura-workflows/.github/workflows/check-actor.yml@main 34 | secrets: inherit 35 | 36 | benchmark: 37 | uses: ultimaker/cura-workflows/.github/workflows/benchmark.yml@main 38 | with: 39 | conan_extra_args: "-c tools.build:skip_test=False -o \"curaengine/*:enable_benchmarks=True\"" 40 | benchmark_cmd: "stress_benchmark/stress_benchmark -o benchmark_result.json" 41 | name: "Stress Benchmark" 42 | output_file_path: "benchmark_result.json" 43 | data_dir: "dev/stress_bench" 44 | tool: "customSmallerIsBetter" 45 | secrets: inherit 46 | -------------------------------------------------------------------------------- /.github/workflows/unit-test-post.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests - publish 2 | 3 | on: 4 | workflow_run: 5 | workflows: [Unit tests - run] 6 | types: [completed] 7 | 8 | jobs: 9 | publish-test-results: 10 | uses: ultimaker/cura-workflows/.github/workflows/unit-test-post.yml@main 11 | with: 12 | workflow_run_json: ${{ toJSON(github.event.workflow_run) }} 13 | secrets: inherit 14 | -------------------------------------------------------------------------------- /.github/workflows/unit-test.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests - run 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'include/**' 7 | - 'src/**' 8 | - 'tests/**' 9 | - 'conanfile.py' 10 | - 'conandata.yml' 11 | - 'CMakeLists.txt' 12 | - '.github/workflows/unit-test.yml' 13 | - '.github/workflows/unit-test-post.yml' 14 | branches: 15 | - main 16 | - 'CURA-*' 17 | - 'PP-*' 18 | - 'NP-*' 19 | - '[0-9]+.[0-9]+' 20 | 21 | pull_request: 22 | types: [ opened, reopened, synchronize ] 23 | paths: 24 | - 'include/**' 25 | - 'src/**' 26 | - 'tests/**' 27 | - 'conanfile.py' 28 | - 'conandata.yml' 29 | - 'CMakeLists.txt' 30 | - '.github/workflows/unit-test.yml' 31 | - '.github/workflows/unit-test-post.yml' 32 | branches: 33 | - main 34 | - '[0-9]+.[0-9]+' 35 | 36 | permissions: 37 | contents: read 38 | 39 | jobs: 40 | testing: 41 | name: Run unit tests 42 | uses: ultimaker/cura-workflows/.github/workflows/unit-test.yml@main 43 | with: 44 | test_use_ctest: true 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## ignore such files 2 | *.tar.bz2 3 | *.tar.gz 4 | *.7z 5 | *.zip 6 | .DS_Store 7 | *~ 8 | *.bak 9 | NUL 10 | *.gcode 11 | 12 | ## Directories used for other stuff 13 | Trash/* 14 | output/* 15 | callgrind/* 16 | 17 | ## Building result. 18 | build/ 19 | tests/build/ 20 | test_package/build/ 21 | debug_build/* 22 | release_build/* 23 | cmake-build-* 24 | libs/stb 25 | *.pyc 26 | *.exe 27 | *.a 28 | *.o 29 | _bin 30 | _obj 31 | x64/* 32 | out/* 33 | 34 | ## CMake files 35 | cmake_install.cmake 36 | CMakeCache.txt 37 | CMakeFiles/ 38 | CPackSourceConfig.cmake 39 | 40 | # Visual Studio files generated by CMake 41 | *.vcxproj 42 | *.vcxproj.filters 43 | CuraEngine.sln 44 | 45 | # Makefile generated by CMake 46 | Makefile 47 | 48 | ## IDE project files. 49 | *.layout 50 | *.cbp 51 | *kdev* 52 | *.kate-swp 53 | nbproject/* 54 | .idea 55 | *.depend 56 | .*.swp 57 | .vs 58 | .cproject 59 | .project 60 | .settings 61 | 62 | ## Documentation. 63 | documentation/html/* 64 | documentation/latex/* 65 | 66 | ## Test results. 67 | tests/output.xml 68 | callgrind.out.* 69 | 70 | ## Conan 71 | CMakeUserPresets.json 72 | /conan_imports_manifest.txt 73 | conan.lock 74 | conanbuildinfo.txt 75 | conaninfo.txt 76 | graph_info.json 77 | build/* 78 | -------------------------------------------------------------------------------- /CuraEngine.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ultimaker/CuraEngine/ae38e6010d34f65493d3e2cc3c91a4c6f023145c/CuraEngine.ico -------------------------------------------------------------------------------- /CuraEngine.rc: -------------------------------------------------------------------------------- 1 | main ICON "CuraEngine.ico" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION 1,0,0,0 5 | PRODUCTVERSION 1,0,0,0 6 | BEGIN 7 | BLOCK "StringFileInfo" 8 | BEGIN 9 | BLOCK "080904E4" 10 | BEGIN 11 | VALUE "CompanyName", "Ultimaker BV." 12 | VALUE "FileDescription", "Slicing engine for Cura" 13 | VALUE "FileVersion", "1.0" 14 | VALUE "InternalName", "CuraEngine" 15 | VALUE "LegalCopyright", "Ultimaker BV." 16 | VALUE "OriginalFilename", "CuraEngine.exe" 17 | VALUE "ProductName", "CuraEngine" 18 | VALUE "ProductVersion", "1.0" 19 | END 20 | END 21 | BLOCK "VarFileInfo" 22 | BEGIN 23 | VALUE "Translation", 0x809, 1252 24 | END 25 | END 26 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [ultimaker] 2 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting vulnerabilities 2 | 3 | If you discover a vulnerability, please let us know as soon as possible via `security@ultimaker.com`. 4 | Please do not take advantage of the vulnerability and do not reveal the problem to others. 5 | To allow us to resolve the issue, please do provide us with sufficient information to reproduce the problem. 6 | -------------------------------------------------------------------------------- /benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Ultimaker B.V. 2 | # CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | message(STATUS "Building benchmarks...") 5 | 6 | find_package(benchmark REQUIRED) 7 | 8 | 9 | add_executable(benchmarks main.cpp) 10 | target_link_libraries(benchmarks PRIVATE _CuraEngine benchmark::benchmark test_helpers) 11 | target_include_directories(benchmarks PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/generated) -------------------------------------------------------------------------------- /benchmark/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2023 UltiMaker 3 | // CuraEngine is released under the terms of the AGPLv3 or higher 4 | #include "infill_benchmark.h" 5 | #include "wall_benchmark.h" 6 | #include "simplify_benchmark.h" 7 | #include 8 | 9 | // Run the benchmark 10 | BENCHMARK_MAIN(); -------------------------------------------------------------------------------- /conandata.yml: -------------------------------------------------------------------------------- 1 | version: "5.11.0-alpha.0" 2 | commit: "unknown" 3 | requirements: 4 | - "scripta/[>=1.1.0]@ultimaker/testing" 5 | requirements_arcus: 6 | - "arcus/5.10.0" 7 | requirements_plugins: 8 | - "curaengine_grpc_definitions/0.3.1" 9 | requirements_cura_resources: 10 | - "cura_resources/5.11.0-alpha.0@ultimaker/testing" 11 | -------------------------------------------------------------------------------- /include/BeadingStrategy/BeadingStrategyFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef BEADING_STRATEGY_FACTORY_H 5 | #define BEADING_STRATEGY_FACTORY_H 6 | 7 | #include 8 | 9 | #include "BeadingStrategy.h" 10 | #include "settings/types/Ratio.h" 11 | 12 | namespace cura 13 | { 14 | 15 | class BeadingStrategyFactory 16 | { 17 | public: 18 | static BeadingStrategyPtr makeStrategy( 19 | const coord_t preferred_bead_width_outer = MM2INT(0.5), 20 | const coord_t preferred_bead_width_inner = MM2INT(0.5), 21 | const coord_t preferred_transition_length = MM2INT(0.4), 22 | const double transitioning_angle = std::numbers::pi / 4.0, 23 | const bool print_thin_walls = false, 24 | const coord_t min_bead_width = 0, 25 | const coord_t min_feature_size = 0, 26 | const Ratio wall_split_middle_threshold = 0.5_r, 27 | const Ratio wall_add_middle_threshold = 0.5_r, 28 | const coord_t max_bead_count = 0, 29 | const coord_t outer_wall_offset = 0, 30 | const int inward_distributed_center_wall_count = 2, 31 | const Ratio minimum_variable_line_ratio = 0.5); 32 | }; 33 | 34 | } // namespace cura 35 | #endif // BEADING_STRATEGY_FACTORY_H 36 | -------------------------------------------------------------------------------- /include/BeadingStrategy/DistributedBeadingStrategy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef DISTRIBUTED_BEADING_STRATEGY_H 5 | #define DISTRIBUTED_BEADING_STRATEGY_H 6 | 7 | #include "../settings/types/Ratio.h" // For the wall transition threshold. 8 | #include "BeadingStrategy.h" 9 | 10 | namespace cura 11 | { 12 | 13 | /*! 14 | * This beading strategy chooses a wall count that would make the line width 15 | * deviate the least from the optimal line width, and then distributes the lines 16 | * evenly among the thickness available. 17 | */ 18 | class DistributedBeadingStrategy : public BeadingStrategy 19 | { 20 | protected: 21 | double one_over_distribution_radius_squared_; // (1 / distribution_radius)^2 22 | 23 | public: 24 | /*! 25 | * \param distribution_radius the radius (in number of beads) over which to distribute the discrepancy between the feature size and the optimal thickness 26 | */ 27 | DistributedBeadingStrategy( 28 | const coord_t optimal_width, 29 | const coord_t default_transition_length, 30 | const AngleRadians transitioning_angle, 31 | const Ratio wall_split_middle_threshold, 32 | const Ratio wall_add_middle_threshold, 33 | const int distribution_radius); 34 | 35 | virtual ~DistributedBeadingStrategy() override 36 | { 37 | } 38 | 39 | Beading compute(coord_t thickness, coord_t bead_count) const override; 40 | coord_t getOptimalBeadCount(coord_t thickness) const override; 41 | }; 42 | 43 | } // namespace cura 44 | #endif // DISTRIBUTED_BEADING_STRATEGY_H 45 | -------------------------------------------------------------------------------- /include/BeadingStrategy/LimitedBeadingStrategy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef LIMITED_BEADING_STRATEGY_H 5 | #define LIMITED_BEADING_STRATEGY_H 6 | 7 | #include "../utils/macros.h" 8 | #include "BeadingStrategy.h" 9 | 10 | namespace cura 11 | { 12 | 13 | /*! 14 | * This is a meta-strategy that can be applied on top of any other beading 15 | * strategy, which limits the thickness of the walls to the thickness that the 16 | * lines can reasonably print. 17 | * 18 | * The width of the wall is limited to the maximum number of contours times the 19 | * maximum width of each of these contours. 20 | * 21 | * If the width of the wall gets limited, this strategy outputs one additional 22 | * bead with 0 width. This bead is used to denote the limits of the walled area. 23 | * Other structures can then use this border to align their structures to, such 24 | * as to create correctly overlapping infill or skin, or to align the infill 25 | * pattern to any extra infill walls. 26 | */ 27 | class LimitedBeadingStrategy : public BeadingStrategy 28 | { 29 | public: 30 | LimitedBeadingStrategy(const coord_t max_bead_count, BeadingStrategyPtr parent); 31 | 32 | virtual ~LimitedBeadingStrategy() override = default; 33 | 34 | Beading compute(coord_t thickness, coord_t bead_count) const override; 35 | coord_t getOptimalThickness(coord_t bead_count) const override; 36 | coord_t getTransitionThickness(coord_t lower_bead_count) const override; 37 | coord_t getOptimalBeadCount(coord_t thickness) const override; 38 | std::string toString() const override; 39 | 40 | coord_t getTransitioningLength(coord_t lower_bead_count) const override; 41 | 42 | double getTransitionAnchorPos(coord_t lower_bead_count) const override; 43 | 44 | protected: 45 | const coord_t max_bead_count_; 46 | const BeadingStrategyPtr parent_; 47 | }; 48 | 49 | 50 | } // namespace cura 51 | #endif // LIMITED_DISTRIBUTED_BEADING_STRATEGY_H 52 | -------------------------------------------------------------------------------- /include/BeadingStrategy/OuterWallInsetBeadingStrategy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef OUTER_WALL_INSET_BEADING_STRATEGY_H 5 | #define OUTER_WALL_INSET_BEADING_STRATEGY_H 6 | 7 | #include "BeadingStrategy.h" 8 | 9 | namespace cura 10 | { 11 | /* 12 | * This is a meta strategy that allows for the outer wall to be inset towards the inside of the model. 13 | */ 14 | class OuterWallInsetBeadingStrategy : public BeadingStrategy 15 | { 16 | public: 17 | OuterWallInsetBeadingStrategy(coord_t outer_wall_offset, BeadingStrategyPtr parent); 18 | 19 | virtual ~OuterWallInsetBeadingStrategy() = default; 20 | 21 | Beading compute(coord_t thickness, coord_t bead_count) const override; 22 | 23 | coord_t getOptimalThickness(coord_t bead_count) const override; 24 | coord_t getTransitionThickness(coord_t lower_bead_count) const override; 25 | coord_t getOptimalBeadCount(coord_t thickness) const override; 26 | coord_t getTransitioningLength(coord_t lower_bead_count) const override; 27 | 28 | std::string toString() const override; 29 | 30 | private: 31 | BeadingStrategyPtr parent_; 32 | coord_t outer_wall_offset_; 33 | }; 34 | } // namespace cura 35 | #endif // OUTER_WALL_INSET_BEADING_STRATEGY_H 36 | -------------------------------------------------------------------------------- /include/BeadingStrategy/WideningBeadingStrategy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef WIDENING_BEADING_STRATEGY_H 5 | #define WIDENING_BEADING_STRATEGY_H 6 | 7 | #include "BeadingStrategy.h" 8 | 9 | namespace cura 10 | { 11 | 12 | /*! 13 | * This is a meta-strategy that can be applied on any other beading strategy. If 14 | * the part is thinner than a single line, this strategy adjusts the part so 15 | * that it becomes the minimum thickness of one line. 16 | * 17 | * This way, tiny pieces that are smaller than a single line will still be 18 | * printed. 19 | */ 20 | class WideningBeadingStrategy : public BeadingStrategy 21 | { 22 | public: 23 | /*! 24 | * Takes responsibility for deleting \param parent 25 | */ 26 | WideningBeadingStrategy(BeadingStrategyPtr parent, const coord_t min_input_width, const coord_t min_output_width); 27 | 28 | virtual ~WideningBeadingStrategy() override = default; 29 | 30 | Beading compute(coord_t thickness, coord_t bead_count) const override; 31 | coord_t getOptimalThickness(coord_t bead_count) const override; 32 | coord_t getTransitionThickness(coord_t lower_bead_count) const override; 33 | coord_t getOptimalBeadCount(coord_t thickness) const override; 34 | coord_t getTransitioningLength(coord_t lower_bead_count) const override; 35 | double getTransitionAnchorPos(coord_t lower_bead_count) const override; 36 | std::vector getNonlinearThicknesses(coord_t lower_bead_count) const override; 37 | std::string toString() const override; 38 | 39 | protected: 40 | BeadingStrategyPtr parent_; 41 | const coord_t min_input_width_; 42 | const coord_t min_output_width_; 43 | }; 44 | 45 | } // namespace cura 46 | #endif // WIDENING_BEADING_STRATEGY_H 47 | -------------------------------------------------------------------------------- /include/BoostInterface.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef BOOST_INTERFACE_HPP 5 | #define BOOST_INTERFACE_HPP 6 | 7 | #include 8 | #include 9 | 10 | #include "geometry/Point2LL.h" 11 | #include "geometry/Polygon.h" 12 | #include "utils/PolygonsSegmentIndex.h" 13 | 14 | 15 | using CSegment = cura::PolygonsSegmentIndex; 16 | using CPolygon = boost::polygon::polygon_data; 17 | using CPolygonSet = std::vector; 18 | 19 | namespace boost 20 | { 21 | namespace polygon 22 | { 23 | 24 | 25 | template<> 26 | struct geometry_concept 27 | { 28 | typedef point_concept type; 29 | }; 30 | 31 | template<> 32 | struct point_traits 33 | { 34 | typedef cura::coord_t coordinate_type; 35 | 36 | static inline coordinate_type get(const cura::Point2LL& point, orientation_2d orient) 37 | { 38 | return (orient == HORIZONTAL) ? point.X : point.Y; 39 | } 40 | }; 41 | 42 | template<> 43 | struct geometry_concept 44 | { 45 | typedef segment_concept type; 46 | }; 47 | 48 | template<> 49 | struct segment_traits 50 | { 51 | typedef cura::coord_t coordinate_type; 52 | typedef cura::Point2LL point_type; 53 | static inline point_type get(const CSegment& CSegment, direction_1d dir) 54 | { 55 | return dir.to_int() ? CSegment.p() : CSegment.next().p(); 56 | } 57 | }; 58 | 59 | 60 | } // namespace polygon 61 | } // namespace boost 62 | 63 | #endif // BOOST_INTERFACE_HPP 64 | -------------------------------------------------------------------------------- /include/ConicalOverhang.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2016 Tim Kuipers 2 | //Copyright (c) 2018 Ultimaker B.V. 3 | //CuraEngine is released under the terms of the AGPLv3 or higher. 4 | 5 | #ifndef CONICAL_OVERHANG_H 6 | #define CONICAL_OVERHANG_H 7 | 8 | namespace cura { 9 | 10 | class Mesh; 11 | class Slicer; 12 | 13 | /*! 14 | * A class for changing the geometry of a model such that it is printable without support - 15 | * Or at least with at least support as possible 16 | */ 17 | class ConicalOverhang 18 | { 19 | public: 20 | /*! 21 | * Change the slice data such that the model becomes more printable 22 | * 23 | * \param[in,out] slicer The slice data. 24 | * \param mesh The mesh to get the settings from. 25 | */ 26 | static void apply(Slicer* slicer, const Mesh& mesh); 27 | }; 28 | 29 | }//namespace cura 30 | 31 | #endif // CONICAL_OVERHANG_H 32 | -------------------------------------------------------------------------------- /include/ExtruderPrime.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef EXTRUDERPRIME_H 5 | #define EXTRUDERPRIME_H 6 | 7 | namespace cura 8 | { 9 | 10 | enum class ExtruderPrime 11 | { 12 | None, // Do not prime at all for this extruder on this layer 13 | Support, // Just extrude a sparse pattern which purpose is to support the upper parts of the prime tower 14 | Prime, // Do an actual prime 15 | }; 16 | 17 | } // namespace cura 18 | #endif // EXTRUDERPRIME_H 19 | -------------------------------------------------------------------------------- /include/ExtruderTrain.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef EXTRUDER_TRAIN_H 5 | #define EXTRUDER_TRAIN_H 6 | 7 | #include "settings/Settings.h" 8 | 9 | namespace cura 10 | { 11 | 12 | class ExtruderTrain 13 | { 14 | public: 15 | /* 16 | * \brief Creates a new extruder. This extruder will have no settings but 17 | * inherits everything from the global settings. 18 | */ 19 | ExtruderTrain(const size_t extruder_nr, Settings* parent_settings); 20 | 21 | /* 22 | * \brief The settings that this extruder overwrites. 23 | */ 24 | Settings settings_; 25 | 26 | /* 27 | * \brief The position of this extruder. 28 | * 29 | * This may be used by g-code commands such as T to indicate to which 30 | * tool we must switch. 31 | */ 32 | const size_t extruder_nr_; 33 | }; 34 | 35 | } // namespace cura 36 | #endif // EXTRUDER_TRAIN_H 37 | -------------------------------------------------------------------------------- /include/ExtruderUse.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef EXTRUDERUSE_H 5 | #define EXTRUDERUSE_H 6 | 7 | #include 8 | 9 | #include "ExtruderPrime.h" 10 | 11 | namespace cura 12 | { 13 | 14 | struct ExtruderUse 15 | { 16 | size_t extruder_nr; 17 | ExtruderPrime prime; 18 | }; 19 | 20 | } // namespace cura 21 | #endif // EXTRUDERUSE_H 22 | -------------------------------------------------------------------------------- /include/MeshGroup.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MESH_GROUP_H 5 | #define MESH_GROUP_H 6 | 7 | #include "mesh.h" 8 | #include "utils/NoCopy.h" 9 | 10 | namespace cura 11 | { 12 | 13 | class Matrix4x3D; 14 | 15 | /*! 16 | * A MeshGroup is a collection with 1 or more 3D meshes. 17 | * 18 | * One MeshGroup is a whole which is printed at once. 19 | * Generally there is one single MeshGroup, though when using one-at-a-time printing, multiple MeshGroups are processed consecutively. 20 | */ 21 | class MeshGroup 22 | { 23 | public: 24 | MeshGroup() = default; 25 | 26 | ~MeshGroup() = default; 27 | 28 | MeshGroup(MeshGroup&& other) noexcept = default; 29 | 30 | MeshGroup& operator=(MeshGroup&& other) noexcept = default; 31 | 32 | /* Copying a MeshGroup is not allowed */ 33 | MeshGroup(const MeshGroup& other) = delete; 34 | MeshGroup& operator=(const MeshGroup& other) = delete; 35 | 36 | std::vector meshes; 37 | Settings settings; 38 | 39 | Point3LL min() const; //! minimal corner of bounding box 40 | Point3LL max() const; //! maximal corner of bounding box 41 | 42 | void clear(); 43 | 44 | void finalize(); 45 | 46 | /*! 47 | * Scale the entire mesh group, with the bottom center as origin point. 48 | * 49 | * The mesh group is scaled around the bottom center of its bounding box. So 50 | * that's the center in the X and Y directions, but Z=0. This simulates the 51 | * shrinkage while sticking to the build plate. 52 | */ 53 | void scaleFromBottom(const Ratio factor_xy, const Ratio factor_z); 54 | }; 55 | 56 | /*! 57 | * Load a Mesh from file and store it in the \p meshgroup. 58 | * 59 | * \param meshgroup The meshgroup where to store the mesh 60 | * \param filename The filename of the mesh file 61 | * \param transformation The transformation applied to all vertices 62 | * \param object_parent_settings (optional) The parent settings object of the new mesh. Defaults to \p meshgroup if none is given. 63 | * \return whether the file could be loaded 64 | */ 65 | bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, const Matrix4x3D& transformation, Settings& object_parent_settings); 66 | 67 | } // namespace cura 68 | 69 | #endif // MESH_GROUP_H 70 | -------------------------------------------------------------------------------- /include/Mold.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MOLD_H 5 | #define MOLD_H 6 | 7 | #include 8 | 9 | namespace cura 10 | { 11 | 12 | class Slicer; 13 | 14 | /*! 15 | * Class for transforming the outlines of a model into a mold into which the model can be cast. 16 | */ 17 | class Mold 18 | { 19 | public: 20 | /*! 21 | * \brief Convert the polygons (and open polylines) of each mold mesh in 22 | * \p storage in order to make a mold with a cutout in the shape of the 23 | * outlines. 24 | * 25 | * The open polylines of the model are also used to cut out the shape inside 26 | * the mold. 27 | * 28 | * First the new outlines of all meshes on a layer are computed and then all 29 | * mold meshes are cut out. This prevents molds reaching through each others 30 | * casting cutout space. 31 | * 32 | * \param slicer_list The container for the sliced polygons (and open 33 | * polylines) of all meshes. 34 | * \param layer_height The overall layer height used (used to compute an 35 | * offset from the mold angle). 36 | */ 37 | static void process(std::vector& slicer_list); 38 | 39 | private: 40 | }; 41 | 42 | } // namespace cura 43 | 44 | #endif // MOLD_H 45 | -------------------------------------------------------------------------------- /include/PathAdapter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PATH_ADAPTER_H 5 | #define PATH_ADAPTER_H 6 | 7 | #include 8 | 9 | #include "geometry/Point2LL.h" 10 | #include "utils/Coord_t.h" 11 | 12 | namespace cura 13 | { 14 | 15 | /* Adapter class to allow extrusion-related functions to work with either an ExtrusionLine or a Polygon */ 16 | template 17 | class PathAdapter 18 | { 19 | public: 20 | /*! 21 | * \brief Base constructor 22 | * \param path The actual stored path 23 | * \param fixed_line_width The fixed line width in case the stored path doesn't handle information about a variable 24 | * line width. Can be omitted otherwise. 25 | */ 26 | PathAdapter(const PathType& path, coord_t fixed_line_width = 0) 27 | : path_(path) 28 | , fixed_line_width_(fixed_line_width) 29 | { 30 | } 31 | 32 | bool empty() const 33 | { 34 | return path_.empty(); 35 | } 36 | 37 | size_t size() const 38 | { 39 | return path_.size(); 40 | } 41 | 42 | coord_t length() const 43 | { 44 | return path_.length(); 45 | } 46 | 47 | const Point2LL& pointAt(size_t index) const; 48 | 49 | coord_t lineWidthAt(size_t index) const; 50 | 51 | const PathType& getPath() const 52 | { 53 | return path_; 54 | } 55 | 56 | private: 57 | const PathType& path_; 58 | const coord_t fixed_line_width_; 59 | }; 60 | 61 | } // namespace cura 62 | 63 | #endif // PATH_ADAPTER_H 64 | -------------------------------------------------------------------------------- /include/PrimeTower/PrimeTowerInterleaved.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PRIME_TOWER_INTERLEAVED_H 5 | #define PRIME_TOWER_INTERLEAVED_H 6 | 7 | #include "PrimeTower/PrimeTower.h" 8 | 9 | namespace cura 10 | { 11 | 12 | /*! 13 | * Specific prime tower implementation that generates interleaved priming paths. It is optimized to waste as few 14 | * filament as possible, while ensuring that the prime tower is still robust even if it gets very high. 15 | * When there is no actual priming required for extruders, it will create a kind of circular zigzag pattern that acts as 16 | * a sparse support. Otherwise it will create priming annuli, stacked on top of each other. 17 | * This is very effective when doing multi-color printing, however it can be used only if all the filaments properly 18 | * adhere to each other. Otherwise there is a high risk that the tower will collapse during the print. 19 | */ 20 | class PrimeTowerInterleaved : public PrimeTower 21 | { 22 | public: 23 | PrimeTowerInterleaved(); 24 | 25 | virtual ExtruderPrime getExtruderPrime( 26 | const std::vector& extruder_is_used_on_this_layer, 27 | size_t extruder_nr, 28 | size_t last_extruder, 29 | const SliceDataStorage& storage, 30 | const LayerIndex& layer_nr) const override; 31 | 32 | protected: 33 | virtual void polishExtrudersUses(LayerVector>& extruders_use, const size_t start_extruder) override; 34 | 35 | virtual std::map> generateToolPaths(const LayerVector>& extruders_use) override; 36 | }; 37 | 38 | } // namespace cura 39 | 40 | #endif // PRIME_TOWER_INTERLEAVED_H 41 | -------------------------------------------------------------------------------- /include/PrimeTower/PrimeTowerNormal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PRIME_TOWER_NORMAL_H 5 | #define PRIME_TOWER_NORMAL_H 6 | 7 | #include "PrimeTower/PrimeTower.h" 8 | 9 | namespace cura 10 | { 11 | 12 | /*! 13 | * Specific prime tower implementation that generates nested cylinders. Each layer, all the extruders will be used to 14 | * contribute to the prime tower, even if they don't actually need priming. In this case, a circular zigzag pattern will 15 | * be used to act as support for upper priming extrusions. 16 | * Although this method is not very efficient, it is required when using different materials that don't properly adhere 17 | * to each other. By nesting the cylinders, you make sure that the tower remains consistent and strong along the print. 18 | */ 19 | class PrimeTowerNormal : public PrimeTower 20 | { 21 | private: 22 | const std::vector used_extruders_; 23 | 24 | public: 25 | PrimeTowerNormal(const std::vector& used_extruders); 26 | 27 | virtual ExtruderPrime getExtruderPrime( 28 | const std::vector& extruder_is_used_on_this_layer, 29 | size_t extruder_nr, 30 | size_t last_extruder, 31 | const SliceDataStorage& storage, 32 | const LayerIndex& layer_nr) const override; 33 | 34 | protected: 35 | virtual std::map> generateToolPaths(const LayerVector>& extruders_use) override; 36 | }; 37 | 38 | } // namespace cura 39 | 40 | #endif // PRIME_TOWER_NORMAL_H 41 | -------------------------------------------------------------------------------- /include/PrintFeature.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINT_FEATURE 2 | #define PRINT_FEATURE 3 | 4 | namespace cura 5 | { 6 | 7 | enum class PrintFeatureType: unsigned char 8 | { 9 | NoneType = 0, // used to mark unspecified jumps in polygons. libArcus depends on it 10 | OuterWall = 1, 11 | InnerWall = 2, 12 | Skin = 3, 13 | Support = 4, 14 | SkirtBrim = 5, 15 | Infill = 6, 16 | SupportInfill = 7, 17 | MoveCombing = 8, 18 | MoveRetraction = 9, 19 | SupportInterface = 10, 20 | PrimeTower = 11, 21 | NumPrintFeatureTypes = 12 // this number MUST be the last one because other modules will 22 | // use this symbol to get the total number of types, which can 23 | // be used to create an array or so 24 | }; 25 | 26 | 27 | 28 | 29 | } // namespace cura 30 | 31 | #endif // PRINT_FEATURE 32 | -------------------------------------------------------------------------------- /include/RetractionConfig.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef RETRACTION_CONFIG_H 5 | #define RETRACTION_CONFIG_H 6 | 7 | #include "settings/types/Velocity.h" 8 | #include "utils/Coord_t.h" 9 | 10 | namespace cura 11 | { 12 | 13 | /*! 14 | * The retraction configuration used in the GCodePathConfig of each feature (and the travel config) 15 | */ 16 | class RetractionConfig 17 | { 18 | public: 19 | double distance; //!< The distance retracted (in mm) 20 | Velocity speed; //!< The speed with which to retract (in mm/s) 21 | Velocity primeSpeed; //!< the speed with which to unretract (in mm/s) 22 | double prime_volume; //!< the amount of material primed after unretracting (in mm^3) 23 | coord_t zHop; //!< the amount with which to lift the head during a retraction-travel 24 | coord_t retraction_min_travel_distance; //!< Minimal distance traversed to even consider retracting (in micron) 25 | double retraction_extrusion_window; //!< Window of mm extruded filament in which to limit the amount of retractions 26 | size_t retraction_count_max; //!< The maximum amount of retractions allowed to occur in the RetractionConfig::retraction_extrusion_window 27 | }; 28 | 29 | 30 | }//namespace cura 31 | 32 | #endif // RETRACTION_CONFIG_H 33 | -------------------------------------------------------------------------------- /include/SkeletalTrapezoidationJoint.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef SKELETAL_TRAPEZOIDATION_JOINT_H 5 | #define SKELETAL_TRAPEZOIDATION_JOINT_H 6 | 7 | #include // smart pointers 8 | 9 | #include "BeadingStrategy/BeadingStrategy.h" 10 | #include "geometry/Point2LL.h" 11 | 12 | namespace cura 13 | { 14 | 15 | class SkeletalTrapezoidationJoint 16 | { 17 | using Beading = BeadingStrategy::Beading; 18 | 19 | public: 20 | struct BeadingPropagation 21 | { 22 | Beading beading_; 23 | coord_t dist_to_bottom_source_; 24 | coord_t dist_from_top_source_; 25 | bool is_upward_propagated_only_; 26 | BeadingPropagation(const Beading& beading) 27 | : beading_(beading) 28 | , dist_to_bottom_source_(0) 29 | , dist_from_top_source_(0) 30 | , is_upward_propagated_only_(false) 31 | { 32 | } 33 | }; 34 | 35 | coord_t distance_to_boundary_; 36 | coord_t bead_count_; 37 | double transition_ratio_; //! The distance near the skeleton to leave free because this joint is in the middle of a transition, as a fraction of the inner bead width of the 38 | //! bead at the higher transition. 39 | SkeletalTrapezoidationJoint() 40 | : distance_to_boundary_(-1) 41 | , bead_count_(-1) 42 | , transition_ratio_(0) 43 | { 44 | } 45 | 46 | bool hasBeading() const 47 | { 48 | return beading_.use_count() > 0; 49 | } 50 | void setBeading(std::shared_ptr& storage) 51 | { 52 | beading_ = storage; 53 | } 54 | std::shared_ptr getBeading() const 55 | { 56 | return beading_.lock(); 57 | } 58 | 59 | private: 60 | std::weak_ptr beading_; 61 | }; 62 | 63 | } // namespace cura 64 | #endif // SKELETAL_TRAPEZOIDATION_JOINT_H 65 | -------------------------------------------------------------------------------- /include/Slice.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef SLICE_H 5 | #define SLICE_H 6 | 7 | #include "Scene.h" //To store the scene to slice. 8 | 9 | namespace cura 10 | { 11 | 12 | /* 13 | * \brief Represents a command to slice something. 14 | * 15 | * This contains a scene and all metadata of a slice. 16 | */ 17 | class Slice 18 | { 19 | public: 20 | /* 21 | * \brief Creates a new Slice instance. 22 | * \param num_mesh_groups How many mesh groups to allocate memory for. 23 | */ 24 | Slice(const size_t num_mesh_groups); 25 | 26 | /* 27 | * \brief The scene that must be sliced. 28 | */ 29 | Scene scene; 30 | 31 | /* 32 | * \brief Slice the scene, producing g-code output. 33 | * 34 | * The g-code output is sent through the currently active communication 35 | * channel. 36 | */ 37 | void compute(); 38 | 39 | /* 40 | * \brief Empty out the slice instance, restoring it as if it were a new 41 | * instance. 42 | * 43 | * Since you are not allowed to copy, move or assign slice objects, this is 44 | * the only way in which you can prepare for the next slice. 45 | */ 46 | void reset(); 47 | 48 | private: 49 | /* 50 | * \brief Disallow copying slice objects since they are heavyweight. 51 | * 52 | * The slice is dark and full of data. 53 | */ 54 | Slice(const Slice& other) = delete; 55 | 56 | /* 57 | * \brief Disallow copying slice objects. 58 | */ 59 | Slice& operator =(const Slice& other) = delete; 60 | }; 61 | 62 | } //namespace cura 63 | 64 | #endif //SLICE_H -------------------------------------------------------------------------------- /include/SpaceFillType.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef SPACE_FILL_TYPE 5 | #define SPACE_FILL_TYPE 6 | 7 | 8 | namespace cura 9 | { 10 | 11 | /*! 12 | * Enum class enumerating the strategies with which an area can be occupied with filament 13 | * 14 | * The walls/perimeters are Polygons 15 | * ZigZag infill is PolyLines, and so is following mesh surface mode for non-polygon surfaces 16 | * Grid, Triangles and lines infill is Lines 17 | */ 18 | enum class SpaceFillType 19 | { 20 | None, 21 | Polygons, 22 | PolyLines, 23 | Lines 24 | }; 25 | 26 | } // namespace cura 27 | 28 | #endif // SPACE_FILL_TYPE -------------------------------------------------------------------------------- /include/TreeSupportBaseCircle.h: -------------------------------------------------------------------------------- 1 | // CuraEngine is released under the terms of the AGPLv3 or higher. 2 | 3 | #ifndef TREESUPPORTCIRCLE_H 4 | #define TREESUPPORTCIRCLE_H 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "geometry/Polygon.h" 11 | #include "settings/types/Angle.h" 12 | #include "utils/Coord_t.h" 13 | 14 | namespace cura 15 | { 16 | 17 | class TreeSupportBaseCircle 18 | { 19 | protected: 20 | inline static Polygon base_circle; 21 | inline static std::once_flag flag; 22 | 23 | public: 24 | inline static constexpr int64_t base_radius = 50; 25 | 26 | static Polygon getBaseCircle() 27 | { 28 | std::call_once( 29 | flag, 30 | [&]() 31 | { 32 | constexpr auto support_tree_circle_resolution = 12; // The number of vertices in each circle. 33 | Polygon circle; 34 | for (const uint64_t i : ranges::views::iota(0, support_tree_circle_resolution)) 35 | { 36 | const AngleRadians angle = static_cast(i) / support_tree_circle_resolution * TAU; 37 | circle.emplace_back(static_cast(std::cos(angle) * base_radius), static_cast(std::sin(angle) * base_radius)); 38 | } 39 | base_circle = Polygon(circle); 40 | }); 41 | return base_circle; 42 | } 43 | }; 44 | 45 | } // namespace cura 46 | 47 | #endif // TREESUPPORTCIRCLE_H 48 | -------------------------------------------------------------------------------- /include/TreeSupportEnums.h: -------------------------------------------------------------------------------- 1 | // CuraEngine is released under the terms of the AGPLv3 or higher. 2 | #ifndef CURAENGINE_TREESUPPORTENUMS_H 3 | #define CURAENGINE_TREESUPPORTENUMS_H 4 | 5 | namespace cura 6 | { 7 | 8 | enum class InterfacePreference 9 | { 10 | INTERFACE_AREA_OVERWRITES_SUPPORT, 11 | SUPPORT_AREA_OVERWRITES_INTERFACE, 12 | INTERFACE_LINES_OVERWRITE_SUPPORT, 13 | SUPPORT_LINES_OVERWRITE_INTERFACE, 14 | NOTHING 15 | }; 16 | 17 | enum class RestPreference 18 | { 19 | BUILDPLATE, 20 | GRACEFUL 21 | }; 22 | 23 | enum class AvoidanceType 24 | { 25 | SLOW, 26 | FAST_SAFE, 27 | FAST, 28 | COLLISION 29 | }; 30 | 31 | } // namespace cura 32 | 33 | #endif // CURAENGINE_TREESUPPORTENUMS_H 34 | -------------------------------------------------------------------------------- /include/WipeScriptConfig.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef WIPE_SCRIPT_CONFIG_H 5 | #define WIPE_SCRIPT_CONFIG_H 6 | 7 | #include "utils/Coord_t.h" 8 | #include "RetractionConfig.h" 9 | #include "settings/types/Duration.h" 10 | #include "settings/types/Velocity.h" 11 | 12 | namespace cura 13 | { 14 | 15 | struct WipeScriptConfig 16 | { 17 | bool retraction_enable; // whether to retract the filament when the nozzle is moving over a non-printed area 18 | RetractionConfig retraction_config; 19 | 20 | Duration pause; // pause after the unretract, in seconds 21 | 22 | bool hop_enable; // whenever a retraction is done, the build plate is lowered to create clearance between the nozzle and the print 23 | coord_t hop_amount; // height difference when performing a Z Hop 24 | Velocity hop_speed; 25 | 26 | coord_t brush_pos_x; // X coordinate - location where wipe script will start 27 | size_t repeat_count; // number of times to move the nozzle across the brush 28 | coord_t move_distance; // distance to move the head back and forth across the brush 29 | Velocity move_speed; 30 | double max_extrusion_mm3; // maximum material that can be extruded before another nozzle wipe is initiated (in mm^3) 31 | bool clean_between_layers; // whether to include nozzle wipe g-code between layers 32 | }; 33 | 34 | struct RetractionAndWipeConfig 35 | { 36 | WipeScriptConfig wipe_config; 37 | 38 | RetractionConfig retraction_config; 39 | coord_t retraction_hop_after_extruder_switch; 40 | double switch_extruder_extra_prime_amount; 41 | RetractionConfig extruder_switch_retraction_config; 42 | }; 43 | 44 | }//namespace cura 45 | 46 | #endif // WIPE_SCRIPT_CONFIG_H 47 | -------------------------------------------------------------------------------- /include/bridge.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef BRIDGE_H 5 | #define BRIDGE_H 6 | 7 | namespace cura 8 | { 9 | 10 | class Shape; 11 | class Settings; 12 | class SliceDataStorage; 13 | class SupportLayer; 14 | 15 | /*! 16 | * \brief Computes the angle that lines have to take to bridge a certain shape 17 | * best. 18 | * 19 | * If the area should not be bridged, an angle of -1 is returned. 20 | * \param settings The settings container to get settings from. 21 | * \param skin_outline The shape to fill with lines. 22 | * \param storage The slice data storage where to find objects that the bridge 23 | * could rest on in previous layers. 24 | * \param layer_nr The layer currently being printed. 25 | * \param bridge_layer The bridge layer number (1, 2 or 3). 26 | * \param support_layer Support that the bridge could rest on. 27 | * \param supported_regions Pre-computed regions that the support layer would 28 | * support. 29 | */ 30 | double bridgeAngle( 31 | const Settings& settings, 32 | const Shape& skin_outline, 33 | const SliceDataStorage& storage, 34 | const unsigned layer_nr, 35 | const unsigned bridge_layer, 36 | const SupportLayer* support_layer, 37 | Shape& supported_regions); 38 | 39 | } // namespace cura 40 | 41 | #endif // BRIDGE_H 42 | -------------------------------------------------------------------------------- /include/communication/EmscriptenCommunication.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef EMSCRIPTENCOMMUNICATION_H 5 | #define EMSCRIPTENCOMMUNICATION_H 6 | #ifdef __EMSCRIPTEN__ 7 | 8 | #include "communication/CommandLine.h" 9 | 10 | namespace cura 11 | { 12 | 13 | /** 14 | * \class EmscriptenCommunication 15 | * \brief A class for handling communication in an Emscripten environment. 16 | * 17 | * This class extends the CommandLine class and provides specific implementations 18 | * for sending progress and handling slice information in an Emscripten environment. 19 | */ 20 | class EmscriptenCommunication : public CommandLine 21 | { 22 | private: 23 | std::string progress_handler_; ///< Handler for progress messages. 24 | std::string gcode_header_handler_; ///< Handler for getting the GCode handler. 25 | std::string slice_info_handler_; ///< Handler for slice information messages. 26 | std::string engine_info_handler_; ///< Handler for curaengine info : version and hash. 27 | /** 28 | * \brief Creates a message containing slice information. 29 | * \return A string containing the slice information message. 30 | */ 31 | [[nodiscard]] static std::string createSliceInfoMessage(); 32 | [[nodiscard]] static std::string createEngineInfoMessage(); 33 | 34 | 35 | public: 36 | /** 37 | * \brief Constructor for EmscriptenCommunication. 38 | * \param arguments A vector of strings containing the command line arguments. 39 | */ 40 | EmscriptenCommunication(const std::vector& arguments); 41 | 42 | /** 43 | * \brief Sends the progress of the current operation. 44 | * \param progress A double representing the progress percentage. 45 | */ 46 | void sendProgress(double progress) const override; 47 | 48 | /** 49 | * \brief Sends GcodeHeader 50 | */ 51 | void sendGCodePrefix(const std::string& prefix) const override; 52 | 53 | /** 54 | * \brief Indicate that we're beginning to send g-code. 55 | */ 56 | void beginGCode() override; 57 | 58 | /** 59 | * \brief Initiates the slicing of the next item. 60 | */ 61 | void sliceNext() override; 62 | 63 | bool isSequential() const override 64 | { 65 | return false; 66 | } 67 | }; 68 | 69 | } // namespace cura 70 | 71 | #endif // __EMSCRIPTEN__ 72 | #endif // EMSCRIPTENCOMMUNICATION_H 73 | -------------------------------------------------------------------------------- /include/communication/Listener.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef LISTENER_H 5 | #define LISTENER_H 6 | #ifdef ARCUS //Extends from Arcus::SocketListener, so only compile if we're using libArcus. 7 | 8 | #include //The class we're extending from. 9 | 10 | namespace cura 11 | { 12 | 13 | /* 14 | * Extension of Arcus' ``SocketListener`` class to specialise the message 15 | * handling for CuraEngine. 16 | */ 17 | class Listener : public Arcus::SocketListener 18 | { 19 | public: 20 | /* 21 | * Changes the ``stateChanged`` signal to do nothing. 22 | */ 23 | void stateChanged(Arcus::SocketState) override; 24 | 25 | /* 26 | * Changes the ``messageReceived`` signal to do nothing. 27 | */ 28 | void messageReceived() override; 29 | 30 | /* 31 | * Log an error when we get one from libArcus. 32 | */ 33 | void error(const Arcus::Error& error) override; 34 | }; 35 | 36 | } //namespace cura 37 | 38 | #endif //ARCUS 39 | #endif //LISTENER_H -------------------------------------------------------------------------------- /include/communication/SliceDataStruct.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef SLICEDATASTRUCT_H 5 | #define SLICEDATASTRUCT_H 6 | #ifdef ARCUS 7 | 8 | #include //To store pointers to slice data. 9 | #include //To store the slice data by layer. 10 | 11 | namespace cura 12 | { 13 | 14 | /*! 15 | * \brief A template structure used to store data to be sent to the front end. 16 | */ 17 | template 18 | class SliceDataStruct 19 | { 20 | //You are not allowed to copy this data, so no copy constructor or assignment operator. 21 | SliceDataStruct(const SliceDataStruct&) = delete; 22 | SliceDataStruct& operator=(const SliceDataStruct&) = delete; 23 | public: 24 | /* 25 | * \brief Creates a new, empty structure with slice data. 26 | */ 27 | SliceDataStruct() 28 | : sliced_objects(0) 29 | , current_layer_count(0) 30 | , current_layer_offset(0) 31 | { } 32 | 33 | size_t sliced_objects; //!< The number of sliced objects for this sliced object list. 34 | 35 | size_t current_layer_count; //!< Number of layers for which data has been buffered in slice_data so far. 36 | size_t current_layer_offset; //!< Offset to add to layer number for the current slice object when slicing one at a time. 37 | 38 | /* 39 | * The slice data itself, which can be of any type. 40 | */ 41 | std::unordered_map> slice_data; 42 | }; 43 | 44 | } 45 | 46 | #endif //ARCUS 47 | #endif //SLICEDATASTRUCT_H -------------------------------------------------------------------------------- /include/geometry/ClosedLinesSet.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef GEOMETRY_CLOSED_LINES_SET_H 5 | #define GEOMETRY_CLOSED_LINES_SET_H 6 | 7 | namespace cura 8 | { 9 | 10 | template 11 | class LinesSet; 12 | class ClosedPolyline; 13 | 14 | /*! 15 | * \brief Convenience definition for a container that can hold only closed polylines. This makes it 16 | * explicit what the lines actually represent. 17 | */ 18 | using ClosedLinesSet = LinesSet; 19 | 20 | } // namespace cura 21 | 22 | #endif // GEOMETRY_CLOSED_LINES_SET_H 23 | -------------------------------------------------------------------------------- /include/geometry/OpenLinesSet.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef GEOMETRY_OPEN_LINES_SET_H 5 | #define GEOMETRY_OPEN_LINES_SET_H 6 | 7 | namespace cura 8 | { 9 | 10 | template 11 | class LinesSet; 12 | class OpenPolyline; 13 | 14 | /*! 15 | * \brief Convenience definition for a container that can hold only open polylines. This makes it 16 | * explicit what the lines actually represent. 17 | */ 18 | using OpenLinesSet = LinesSet; 19 | 20 | } // namespace cura 21 | 22 | #endif // GEOMETRY_OPEN_LINES_SET_H 23 | -------------------------------------------------------------------------------- /include/geometry/SingleShape.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef GEOMETRY_SINGLE_SHAPE_H 5 | #define GEOMETRY_SINGLE_SHAPE_H 6 | 7 | #include "geometry/Shape.h" 8 | 9 | namespace cura 10 | { 11 | 12 | class Polygon; 13 | 14 | /*! 15 | * @brief A single area with holes. The first polygon is the outline, while the rest are holes within this outline. 16 | * @sa https://github.com/Ultimaker/CuraEngine/wiki/Geometric-Base-Types#singleshape 17 | * 18 | * This class has little more functionality than Shape, but serves to show that a specific instance 19 | * is ordered such that the first Polygon is the outline and the rest are holes. 20 | */ 21 | class SingleShape : public Shape 22 | { 23 | public: 24 | SingleShape() = default; 25 | 26 | explicit SingleShape(Shape&& shape) 27 | : Shape{ std::move(shape) } {}; 28 | 29 | Polygon& outerPolygon(); 30 | 31 | [[nodiscard]] const Polygon& outerPolygon() const; 32 | 33 | /*! 34 | * Tests whether the given point is inside this polygon part. 35 | * \param p The point to test whether it is insisinglehde. 36 | * \param border_result If the point is exactly on the border, this will be 37 | * returned instead. 38 | */ 39 | [[nodiscard]] bool inside(const Point2LL& p, bool border_result = false) const; 40 | }; 41 | 42 | } // namespace cura 43 | 44 | #endif // GEOMETRY_SINGLE_SHAPE_H 45 | -------------------------------------------------------------------------------- /include/gradual_flow/Utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef GRADUAL_FLOW_UTILS_H 5 | #define GRADUAL_FLOW_UTILS_H 6 | 7 | 8 | namespace cura::gradual_flow::utils 9 | { 10 | 11 | enum Direction 12 | { 13 | Forward, 14 | Backward, 15 | }; 16 | 17 | /* 18 | * \brief Converts HSV values to RGB values. 19 | * 20 | * \param H Hue value in range [0, 360] 21 | * \param S Saturation value in range [0, 100] 22 | * \param V Value value in range [0, 100] 23 | * 24 | * \return A tuple containing the RGB values in range [0, 255] 25 | */ 26 | std::tuple hsvToRgb(double H, double S, double V) 27 | { 28 | // Code taken from https://www.codespeedy.com/hsv-to-rgb-in-cpp/ and slightly modified 29 | if (H > 360. || H < 0. || S > 100. || S < 0. || V > 100. || V < 0.) 30 | { 31 | throw std::invalid_argument("The given HSV values are not in valid range"); 32 | } 33 | auto s = S * .01; 34 | auto v = V * .01; 35 | auto C = s * v; 36 | auto X = C * (1. - abs(fmod(H / 60.0, 2.) - 1.)); 37 | auto m = v - C; 38 | auto r = 0., g = 0., b = 0.; 39 | if (H >= 0. && H < 60.) 40 | { 41 | r = C; 42 | g = X; 43 | b = 0.; 44 | } 45 | else if (H >= 60. && H < 120.) 46 | { 47 | r = X; 48 | g = C; 49 | b = 0.; 50 | } 51 | else if (H >= 120. && H < 180.) 52 | { 53 | r = 0.; 54 | g = C; 55 | b = X; 56 | } 57 | else if (H >= 180. && H < 240.) 58 | { 59 | r = 0.; 60 | g = X; 61 | b = C; 62 | } 63 | else if (H >= 240. && H < 300.) 64 | { 65 | r = X; 66 | g = 0.; 67 | b = C; 68 | } 69 | else 70 | { 71 | r = C; 72 | g = 0.; 73 | b = X; 74 | } 75 | 76 | int R = (r + m) * 255.; 77 | int G = (g + m) * 255.; 78 | int B = (b + m) * 255.; 79 | 80 | return std::make_tuple(R, G, B); 81 | } 82 | 83 | } // namespace cura::gradual_flow::utils 84 | 85 | #endif // GRADUAL_FLOW_UTILS_H 86 | -------------------------------------------------------------------------------- /include/infill/DensityProvider.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Tim Kuipers 2 | // Copyright (c) 2018 Ultimaker B.V. 3 | // CuraEngine is released under the terms of the AGPLv3 or higher. 4 | 5 | #ifndef INFILL_DENSITY_PROVIDER_H 6 | #define INFILL_DENSITY_PROVIDER_H 7 | 8 | namespace cura 9 | { 10 | 11 | struct AABB3D; 12 | 13 | /*! 14 | * Parent class of function objects which return the density required for a given region. 15 | * 16 | * This density requirement can be based on user input, distance to the 3d model shell, Z distance to top skin, etc. 17 | */ 18 | class DensityProvider 19 | { 20 | public: 21 | /*! 22 | * \return the approximate required density of a cube 23 | */ 24 | virtual double operator()(const AABB3D& aabb) const = 0; 25 | virtual ~DensityProvider() 26 | { 27 | } 28 | }; 29 | 30 | } // namespace cura 31 | 32 | 33 | #endif // INFILL_DENSITY_PROVIDER_H 34 | -------------------------------------------------------------------------------- /include/infill/GyroidInfill.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/LinesSet.h" 5 | #include "geometry/OpenLinesSet.h" 6 | #include "utils/Coord_t.h" 7 | 8 | namespace cura 9 | { 10 | class Shape; 11 | 12 | class GyroidInfill 13 | { 14 | public: 15 | GyroidInfill(); 16 | 17 | ~GyroidInfill(); 18 | 19 | /*! 20 | * Generate the Gyroid infill pattern within a certain outline. 21 | * 22 | * This is a 3D infill pattern which has one single permeable volume (excellent for casting or soluble support), 23 | * very consistent low stiffness in all directions. Fairly high toughness due to the low stiffness. 24 | * 25 | * The pattern generates a sine-wave in two directions that varies across the Z coordinate, gradually changing 26 | * between the X and Y directions. This is a 2D pattern, but by supplying a Z coordinate the pattern will vary 27 | * across different heights, producing a 3D pattern. 28 | * \param result_lines Output variable to store the resulting polyline segments in. 29 | * \param zig_zaggify Whether to connect the polylines at their endpoints, forming one single polyline or at least 30 | * very few interruptions in the material flow. 31 | * \param line_distance Distance between adjacent curves. This determines the density of the pattern (when printed 32 | * at a fixed line width). 33 | * \param in_outline The outline in which to print the pattern. The input shape, so to say. 34 | * \param z The Z coordinate of this layer. Different Z coordinates cause the pattern to vary, producing a 3D 35 | * pattern. 36 | */ 37 | static void generateTotalGyroidInfill(OpenLinesSet& result_lines, bool zig_zaggify, coord_t line_distance, const Shape& in_outline, coord_t z); 38 | 39 | private: 40 | }; 41 | } // namespace cura 42 | -------------------------------------------------------------------------------- /include/infill/ImageBasedDensityProvider.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Tim Kuipers 2 | // Copyright (c) 2018 Ultimaker B.V. 3 | // CuraEngine is released under the terms of the AGPLv3 or higher. 4 | 5 | #ifndef INFILL_IMAGE_BASED_DENSITY_PROVIDER_H 6 | #define INFILL_IMAGE_BASED_DENSITY_PROVIDER_H 7 | 8 | #include "../utils/AABB.h" 9 | #include "DensityProvider.h" 10 | #include "geometry/Point3LL.h" 11 | 12 | namespace cura 13 | { 14 | 15 | struct AABB3D; 16 | 17 | class ImageBasedDensityProvider : public DensityProvider 18 | { 19 | public: 20 | ImageBasedDensityProvider(const std::string filename, const AABB aabb); 21 | 22 | virtual ~ImageBasedDensityProvider(); 23 | 24 | virtual double operator()(const AABB3D& aabb) const; 25 | 26 | protected: 27 | Point3LL image_size; //!< dimensions of the image. Third dimension is the amount of channels. 28 | unsigned char* image = nullptr; //!< image data: rows of channel data per pixel. 29 | 30 | AABB print_aabb; //!< bounding box of print coordinates in which to apply the image 31 | }; 32 | 33 | } // namespace cura 34 | 35 | 36 | #endif // INFILL_IMAGE_BASED_DENSITY_PROVIDER_H 37 | -------------------------------------------------------------------------------- /include/infill/NoZigZagConnectorProcessor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H 5 | #define INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H 6 | 7 | #include "ZigzagConnectorProcessor.h" 8 | #include "geometry/OpenLinesSet.h" 9 | 10 | namespace cura 11 | { 12 | 13 | class OpenPolyline; 14 | 15 | template 16 | class LinesSet; 17 | 18 | /*! 19 | * This processor adds no connection. This is for line infill pattern. 20 | */ 21 | class NoZigZagConnectorProcessor : public ZigzagConnectorProcessor 22 | { 23 | public: 24 | NoZigZagConnectorProcessor(const PointMatrix& rotation_matrix, OpenLinesSet& result) 25 | : ZigzagConnectorProcessor( 26 | rotation_matrix, 27 | result, 28 | false, 29 | false, // settings for zig-zag end pieces, no use here 30 | false, 31 | 0) // settings for skipping some zags, no use here 32 | { 33 | } 34 | 35 | void registerVertex(const Point2LL& vertex); 36 | void registerScanlineSegmentIntersection(const Point2LL& intersection, int scanline_index, coord_t min_distance_to_scanline); 37 | void registerPolyFinished(); 38 | }; 39 | 40 | 41 | } // namespace cura 42 | 43 | 44 | #endif // INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H 45 | -------------------------------------------------------------------------------- /include/infill/SierpinskiFillProvider.h: -------------------------------------------------------------------------------- 1 | //Copyright (C) 2017 Tim Kuipers 2 | //Copyright (c) 2018 Ultimaker B.V. 3 | //CuraEngine is released under the terms of the AGPLv3 or higher. 4 | 5 | #ifndef INFILL_SIERPINSKI_FILL_PROVIDER_H 6 | #define INFILL_SIERPINSKI_FILL_PROVIDER_H 7 | 8 | #include 9 | 10 | #include "SierpinskiFill.h" 11 | #include "../settings/EnumSettings.h" //For EFillMethod. 12 | 13 | namespace cura 14 | { 15 | 16 | struct AABB3D; 17 | class DensityProvider; 18 | 19 | /*! 20 | * Class for generating infill patterns using the SierpinskiFill class. 21 | * 22 | * This class handles determining the maximum recursion depth, the initial triangle 23 | * and in general the configuration the SierpinskiFill class requires to be used as fill pattern. 24 | * 25 | * This class also handles the density provider which is used to determine the local density at each location - if there is one. 26 | */ 27 | class SierpinskiFillProvider 28 | { 29 | static constexpr bool get_constructor = true; 30 | static constexpr bool use_dithering = true; // !< Whether to employ dithering and error propagation 31 | protected: 32 | //! Basic parameters from which to start constructing the sierpinski fractal 33 | struct FractalConfig 34 | { 35 | int depth; //!< max recursion depth 36 | AABB aabb; //!< The bounding box of the initial Triangles in the Sierpinski curve 37 | }; 38 | public: 39 | FractalConfig fractal_config; 40 | DensityProvider* density_provider; //!< The object which determines the requested density at each region 41 | std::optional fill_pattern_for_all_layers; //!< The fill pattern if one and the same pattern is used on all layers 42 | 43 | SierpinskiFillProvider(const AABB3D aabb_3d, coord_t min_line_distance, const coord_t line_width); 44 | 45 | SierpinskiFillProvider(const AABB3D aabb_3d, coord_t min_line_distance, coord_t line_width, std::string cross_subdisivion_spec_image_file); 46 | 47 | Polygon generate(EFillMethod pattern, coord_t z, coord_t line_width, coord_t pocket_size) const; 48 | 49 | ~SierpinskiFillProvider(); 50 | protected: 51 | /*! 52 | * Get the parameters with which to generate a sierpinski fractal for this object 53 | */ 54 | FractalConfig getFractalConfig(const AABB3D aabb_3d, coord_t min_line_distance); 55 | }; 56 | } // namespace cura 57 | 58 | 59 | #endif // INFILL_SIERPINSKI_FILL_PROVIDER_H 60 | -------------------------------------------------------------------------------- /include/infill/UniformDensityProvider.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef INFILL_UNIFORM_DENSITY_PROVIDER_H 5 | #define INFILL_UNIFORM_DENSITY_PROVIDER_H 6 | 7 | #include "DensityProvider.h" 8 | 9 | namespace cura 10 | { 11 | 12 | struct AABB3D; 13 | 14 | class UniformDensityProvider : public DensityProvider 15 | { 16 | public: 17 | UniformDensityProvider(double density) 18 | : density_(density) 19 | { 20 | } 21 | 22 | virtual ~UniformDensityProvider() 23 | { 24 | } 25 | 26 | virtual double operator()(const AABB3D&) const 27 | { 28 | return density_; 29 | } 30 | 31 | protected: 32 | double density_; 33 | }; 34 | 35 | } // namespace cura 36 | 37 | 38 | #endif // INFILL_UNIFORM_DENSITY_PROVIDER_H 39 | -------------------------------------------------------------------------------- /include/layerPart.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef LAYERPART_H 5 | #define LAYERPART_H 6 | 7 | /* 8 | The layer-part creation step is the first step in creating actual useful data for 3D printing. 9 | It takes the result of the Slice step, which is an unordered list of polygons, and makes groups of polygons, 10 | each of these groups is called a "part", which sometimes are also known as "islands". These parts represent 11 | isolated areas in the 2D layer with possible holes. 12 | 13 | Creating "parts" is an important step, as all elements in a single part should be printed before going to another part. 14 | And all every bit inside a single part can be printed without the nozzle leaving the boundary of this part. 15 | 16 | It's also the first step that stores the result in the "data storage" so all other steps can access it. 17 | */ 18 | 19 | namespace cura 20 | { 21 | 22 | class Settings; 23 | class SliceLayer; 24 | class Slicer; 25 | class SlicerLayer; 26 | class SliceMeshStorage; 27 | 28 | /*! 29 | * \brief Split a layer into parts. 30 | * \param settings The settings to get the settings from (whether to union or 31 | * not). 32 | * \param storageLayer Where to store the parts. 33 | * \param layer The layer to split. 34 | */ 35 | void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, SlicerLayer* layer); 36 | 37 | /*! 38 | * \brief Split all layers into parts. 39 | * \param mesh The mesh of which to split the layers into parts. 40 | * \param slicer The slicer to get the layers from. 41 | */ 42 | void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer); 43 | 44 | }//namespace cura 45 | 46 | #endif//LAYERPART_H 47 | -------------------------------------------------------------------------------- /include/multiVolumes.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MULTIVOLUMES_H 5 | #define MULTIVOLUMES_H 6 | 7 | #include 8 | 9 | /* This file contains code to help fixing up and changing layers that are built from multiple volumes. */ 10 | namespace cura 11 | { 12 | 13 | class Mesh; 14 | class Slicer; 15 | 16 | void carveMultipleVolumes(std::vector &meshes); 17 | 18 | /*! 19 | * Expand each layer a bit and then keep the extra overlapping parts that overlap with other volumes. 20 | * This generates some overlap in dual extrusion, for better bonding in touching parts. 21 | */ 22 | void generateMultipleVolumesOverlap(std::vector &meshes); 23 | 24 | class MultiVolumes 25 | { 26 | public: 27 | /*! 28 | * Carve all cutting meshes. 29 | * 30 | * Make a cutting mesh limited to within the volume of all other meshes 31 | * and carve this volume from those meshes. 32 | * 33 | * Don't carve other cutting meshes. 34 | * 35 | * \warning Overlapping cutting meshes result in overlapping volumes. \ref carveMultipleVolumes still needs to be called 36 | * 37 | * \param[in,out] volumes The outline data of each mesh 38 | * \param meshes The meshes which contain the settings for each volume 39 | */ 40 | static void carveCuttingMeshes(std::vector& volumes, const std::vector& meshes); 41 | }; 42 | 43 | }//namespace cura 44 | 45 | #endif//MULTIVOLUMES_H 46 | -------------------------------------------------------------------------------- /include/pathPlanning/CombPath.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PATH_PLANNING_COMB_PATH_H 5 | #define PATH_PLANNING_COMB_PATH_H 6 | 7 | #include "geometry/Point2LL.h" 8 | 9 | namespace cura 10 | { 11 | 12 | class CombPath : public std::vector //!< A single path either inside or outise the parts 13 | { 14 | public: 15 | bool cross_boundary = false; //!< Whether the path crosses a boundary. 16 | }; 17 | 18 | } // namespace cura 19 | 20 | #endif // PATH_PLANNING_COMB_PATH_H 21 | -------------------------------------------------------------------------------- /include/pathPlanning/CombPaths.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PATH_PLANNING_COMB_PATHS_H 5 | #define PATH_PLANNING_COMB_PATHS_H 6 | 7 | #include "CombPath.h" 8 | 9 | namespace cura 10 | { 11 | 12 | class CombPaths : public std::vector //!< A list of paths alternating between inside a part and outside a part 13 | { 14 | public: 15 | bool throughAir = false; //!< Whether the path is one which moves through air. 16 | }; 17 | 18 | }//namespace cura 19 | 20 | #endif//PATH_PLANNING_COMB_PATHS_H 21 | -------------------------------------------------------------------------------- /include/pathPlanning/NozzleTempInsert.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef PATH_PLANNING_NOZZLE_TEMP_INSERT_H 5 | #define PATH_PLANNING_NOZZLE_TEMP_INSERT_H 6 | 7 | #include 8 | #include 9 | 10 | namespace cura 11 | { 12 | 13 | class GCodeExport; 14 | 15 | /*! 16 | * A gcode command to insert before a specific path. 17 | * 18 | * Currently only used for preheat commands 19 | */ 20 | struct NozzleTempInsert 21 | { 22 | size_t path_idx{}; //!< The path before which to insert this command 23 | size_t extruder{}; //!< The extruder for which to set the temp 24 | double temperature{}; //!< The temperature of the temperature command to insert 25 | bool wait{}; //!< Whether to wait for the temperature to be reached 26 | double time_after_path_start{ 0.0 }; //!< The time after the start of the path, before which to insert the command 27 | 28 | constexpr std::partial_ordering operator<=>(const NozzleTempInsert& other) const 29 | { 30 | if (path_idx == other.path_idx) 31 | { 32 | return time_after_path_start <=> other.time_after_path_start; 33 | } 34 | return path_idx <=> other.path_idx; 35 | } 36 | 37 | /*! 38 | * Write the temperature command at the current position in the gcode. 39 | * \param gcode The actual gcode writer 40 | */ 41 | void write(GCodeExport& gcode); 42 | 43 | }; 44 | 45 | } // namespace cura 46 | 47 | #endif // PATH_PLANNING_NOZZLE_TEMP_INSERT_H 48 | -------------------------------------------------------------------------------- /include/pathPlanning/SpeedDerivatives.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef PATHPLANNING_SPEEDDERIVATIVES_H 5 | #define PATHPLANNING_SPEEDDERIVATIVES_H 6 | 7 | #include "settings/types/LayerIndex.h" 8 | #include "settings/types/Velocity.h" 9 | 10 | namespace cura 11 | { 12 | 13 | struct SpeedDerivatives 14 | { 15 | Velocity speed{}; //!< movement speed (mm/s) 16 | Acceleration acceleration{}; //!< acceleration of head movement (mm/s^2) 17 | Velocity jerk{}; //!< jerk of the head movement (around stand still) as instantaneous speed change (mm/s) 18 | 19 | constexpr bool operator==(const SpeedDerivatives& other) const noexcept = default; 20 | constexpr auto operator<=>(const SpeedDerivatives& other) const noexcept = default; 21 | 22 | /*! 23 | * Set the speed to somewhere between the speed of @p first_layer_config and the iconic speed. 24 | * 25 | * \warning This functions should not be called with @p layer_nr > @p max_speed_layer ! 26 | * 27 | * \warning Calling this function twice will smooth the speed more toward \p first_layer_config 28 | * 29 | * \param first_layer_config The speed settings at layer zero 30 | * \param layer_nr The layer number 31 | * \param max_speed_layer The layer number for which the speed_iconic should be used. 32 | */ 33 | void smoothSpeed(const SpeedDerivatives& first_layer_config, const LayerIndex layer_nr, const LayerIndex max_speed_layer_nr); 34 | }; 35 | 36 | } // namespace cura 37 | 38 | #endif // PATHPLANNING_SPEEDDERIVATIVES_H 39 | -------------------------------------------------------------------------------- /include/plugins/broadcasts.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef PLUGINS_BROADCAST_H 5 | #define PLUGINS_BROADCAST_H 6 | 7 | #include "cura/plugins/slots/broadcast/v0/broadcast.grpc.pb.h" 8 | #include "cura/plugins/v0/slot_id.pb.h" 9 | #include "plugins/converters.h" 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace cura::plugins::details 17 | { 18 | 19 | template 20 | struct is_broadcast_channel 21 | { 22 | inline static constexpr bool value{ T1 == T2 }; 23 | }; 24 | 25 | template 26 | inline constexpr bool is_broadcast_channel_v = is_broadcast_channel::value; 27 | 28 | template 29 | struct broadcast_stub 30 | { 31 | using derived_type = T; 32 | friend derived_type; 33 | 34 | constexpr auto operator()(auto&&... args) 35 | { 36 | return request_(std::forward(args)...); 37 | } 38 | 39 | private: 40 | C request_{}; 41 | }; 42 | 43 | template 44 | requires is_broadcast_channel_v 45 | struct broadcast_rpc : public broadcast_stub, broadcast_settings_request> 46 | { 47 | using ClientRPC = agrpc::ClientRPC<&Stub::PrepareAsyncBroadcastSettings>; 48 | }; 49 | 50 | 51 | } // namespace cura::plugins::details 52 | 53 | #endif // PLUGINS_BROADCAST_H -------------------------------------------------------------------------------- /include/plugins/metadata.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef CURAENGINE_INCLUDE_PLUGINS_METADATA_H 5 | #define CURAENGINE_INCLUDE_PLUGINS_METADATA_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "cura/plugins/v0/slot_id.pb.h" 16 | #include "plugins/types.h" 17 | 18 | namespace cura::plugins 19 | { 20 | 21 | struct plugin_metadata 22 | { 23 | std::string slot_version_range; 24 | std::string plugin_name; 25 | std::string plugin_version; 26 | std::string peer; 27 | std::set broadcast_subscriptions; 28 | }; 29 | 30 | struct slot_metadata 31 | { 32 | plugins::v0::SlotID slot_id; 33 | std::string_view version; 34 | std::string_view engine_uuid; 35 | }; 36 | 37 | } // namespace cura::plugins 38 | 39 | namespace cura::plugins::v0 40 | { 41 | 42 | constexpr auto format_as(SlotID id) 43 | { 44 | return fmt::underlying(id); 45 | } 46 | 47 | } // namespace cura::plugins::v0 48 | 49 | #endif // CURAENGINE_INCLUDE_PLUGINS_METADATA_H 50 | -------------------------------------------------------------------------------- /include/plugins/types.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef PLUGINS_TYPES_H 5 | #define PLUGINS_TYPES_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "cura/plugins/v0/slot_id.pb.h" 14 | 15 | namespace fmt 16 | { 17 | // Custom formatter for humanreadable slot_id's 18 | template<> 19 | struct formatter 20 | { 21 | template 22 | auto format(cura::plugins::v0::SlotID slot_id, FormatContext& ctx) const 23 | { 24 | std::string slot_name; 25 | 26 | switch (slot_id) 27 | { 28 | case cura::plugins::v0::SlotID::SETTINGS_BROADCAST: 29 | slot_name = "SettingsBroadcastService"; 30 | break; 31 | case cura::plugins::v0::SlotID::SIMPLIFY_MODIFY: 32 | slot_name = "SimplifyService"; 33 | break; 34 | case cura::plugins::v0::SlotID::POSTPROCESS_MODIFY: 35 | slot_name = "PostprocessService"; 36 | break; 37 | case cura::plugins::v0::SlotID::INFILL_MODIFY: 38 | slot_name = "InfillModifyService"; 39 | break; 40 | case cura::plugins::v0::SlotID::GCODE_PATHS_MODIFY: 41 | slot_name = "GcodePathsModifyService"; 42 | break; 43 | case cura::plugins::v0::SlotID::INFILL_GENERATE: 44 | slot_name = "InfillGenerateService"; 45 | break; 46 | default: 47 | slot_name = "Unknown"; 48 | break; 49 | } 50 | 51 | return fmt::format_to(ctx.out(), "{}", slot_name); 52 | } 53 | 54 | template 55 | auto parse(ParseContext& ctx) 56 | { 57 | return ctx.begin(); 58 | } 59 | }; 60 | 61 | template<> 62 | struct formatter 63 | { 64 | constexpr auto parse(format_parse_context& ctx) 65 | { 66 | return ctx.end(); 67 | } 68 | 69 | template 70 | auto format(const grpc::string_ref& str, FormatContext& ctx) const 71 | { 72 | return format_to(ctx.out(), "{}", std::string_view{ str.data(), str.size() }); 73 | } 74 | }; 75 | 76 | } // namespace fmt 77 | #endif // PLUGINS_TYPES_H 78 | -------------------------------------------------------------------------------- /include/plugins/validator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef PLUGINS_VALIDATOR_H 5 | #define PLUGINS_VALIDATOR_H 6 | 7 | #include "plugins/metadata.h" 8 | #include "plugins/types.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace cura::plugins 16 | { 17 | 18 | class Validator 19 | { 20 | bool include_prerelease_{ true }; ///< Flag indicating whether to include prerelease versions. 21 | bool valid_{ false }; ///< Flag indicating the validity of the version. 22 | 23 | public: 24 | /** 25 | * @brief Default constructor. 26 | */ 27 | constexpr Validator() noexcept = default; 28 | 29 | /** 30 | * @brief Constructor that sets the version to validate. 31 | * 32 | * @param version The version to validate. 33 | */ 34 | Validator(const slot_metadata& slot_info, const plugin_metadata& plugin_info) 35 | { 36 | auto slot_range = semver::range::detail::range(plugin_info.slot_version_range); 37 | auto slot_version = semver::from_string(slot_info.version); 38 | valid_ = slot_range.satisfies(slot_version, include_prerelease_); 39 | }; 40 | 41 | /** 42 | * @brief Conversion operator to bool. 43 | * 44 | * @return True if the version is valid, false otherwise. 45 | */ 46 | constexpr operator bool() const noexcept 47 | { 48 | return valid_; 49 | } 50 | }; 51 | 52 | } // namespace cura::plugins 53 | 54 | #endif // PLUGINS_VALIDATOR_H 55 | -------------------------------------------------------------------------------- /include/progress/ProgressEstimator.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PROGRESS_PROGRESS_ESTIMATOR_H 5 | #define PROGRESS_PROGRESS_ESTIMATOR_H 6 | 7 | #include 8 | 9 | namespace cura 10 | { 11 | /* 12 | * ProgressEstimator is a finger-tree with ProgressEstimatorLinear as leaves. 13 | * 14 | * Each (non-leaf) node consists of a ProgressStageEstimator which consists of several stages. 15 | * 16 | * The structure of this tree is an oversimplification of the call graph of CuraEngine. 17 | * 18 | */ 19 | 20 | class ProgressEstimator 21 | { 22 | public: 23 | virtual double progress(int current_step) = 0; 24 | virtual ~ProgressEstimator() 25 | { 26 | } 27 | }; 28 | 29 | } // namespace cura 30 | 31 | #endif // PROGRESS_PROGRESS_ESTIMATOR_H -------------------------------------------------------------------------------- /include/progress/ProgressEstimatorLinear.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PROGRESS_PROGRESS_ESTIMATOR_LINEAR_H 5 | #define PROGRESS_PROGRESS_ESTIMATOR_LINEAR_H 6 | 7 | #include 8 | 9 | #include "ProgressEstimator.h" 10 | 11 | namespace cura 12 | { 13 | 14 | 15 | class ProgressEstimatorLinear : public ProgressEstimator 16 | { 17 | unsigned int total_steps_; 18 | 19 | public: 20 | ProgressEstimatorLinear(unsigned int total_steps) 21 | : total_steps_(total_steps) 22 | { 23 | } 24 | double progress(int current_step) 25 | { 26 | return double(current_step) / double(total_steps_); 27 | } 28 | }; 29 | 30 | } // namespace cura 31 | 32 | #endif // PROGRESS_PROGRESS_ESTIMATOR_LINEAR_H 33 | -------------------------------------------------------------------------------- /include/progress/ProgressStageEstimator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef PROGRESS_PROGRESS_STAGE_ESTIMATOR_H 5 | #define PROGRESS_PROGRESS_STAGE_ESTIMATOR_H 6 | 7 | #include 8 | 9 | #include "ProgressEstimator.h" 10 | 11 | namespace cura 12 | { 13 | 14 | /*! 15 | * A staged progress estimator which estimates each stage to have different times. 16 | */ 17 | class ProgressStageEstimator : public ProgressEstimator 18 | { 19 | struct ProgressStage 20 | { 21 | double relative_estimated_time_; 22 | ProgressEstimator* stage_; 23 | 24 | ProgressStage(double relative_estimated_time) 25 | : relative_estimated_time_(relative_estimated_time) 26 | , stage_(nullptr) 27 | { 28 | } 29 | }; 30 | 31 | protected: 32 | std::vector stages_; 33 | double total_estimated_time_; 34 | 35 | private: 36 | double accumulated_estimate_; 37 | int current_stage_idx_; 38 | 39 | public: 40 | ProgressStageEstimator(std::vector& relative_time_estimates); 41 | 42 | double progress(int current_step); 43 | 44 | /*! 45 | * 46 | * \warning This class is responsible for deleting the \p stage 47 | * 48 | */ 49 | void nextStage(ProgressEstimator* stage); 50 | 51 | ~ProgressStageEstimator(); 52 | }; 53 | 54 | } // namespace cura 55 | 56 | #endif // PROGRESS_PROGRESS_STAGE_ESTIMATOR_H 57 | -------------------------------------------------------------------------------- /include/settings/FlowTempGraph.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef FLOW_TEMP_GRAPH 5 | #define FLOW_TEMP_GRAPH 6 | 7 | #include 8 | #include 9 | 10 | #include "types/Temperature.h" 11 | 12 | namespace cura 13 | { 14 | 15 | /*! 16 | * Class representing a graph matching a flow to a temperature. 17 | * The graph generally consists of several linear line segments between points at which the temperature and flow are matched. 18 | */ 19 | class FlowTempGraph 20 | { 21 | public: 22 | struct Datum 23 | { 24 | const double flow_; //!< The flow in mm^3/s 25 | const Temperature temp_; //!< The temperature in *C 26 | Datum(const double flow, const Temperature temp) 27 | : flow_(flow) 28 | , temp_(temp) 29 | { 30 | } 31 | }; 32 | 33 | std::vector data_; //!< The points of the graph between which the graph is linearly interpolated 34 | 35 | /*! 36 | * Get the temperature corresponding to a specific flow. 37 | * 38 | * For flows outside of the chart, the temperature at the minimal or maximal flow is returned. 39 | * When the graph is empty, the @p material_print_temperature is returned. 40 | * 41 | * \param flow the flow in mm^3/s 42 | * \param material_print_temperature The default printing temp (backward compatibility for when the graph fails) 43 | * \return the corresponding temp 44 | */ 45 | double getTemp(const double flow, const Temperature material_print_temperature, const bool flow_dependent_temperature) const; 46 | }; 47 | 48 | } // namespace cura 49 | 50 | #endif // FLOW_TEMP_GRAPH 51 | -------------------------------------------------------------------------------- /include/settings/MeshPathConfigs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef SETTINGS_TYPES_MESHPATHCONFIGS_H 5 | #define SETTINGS_TYPES_MESHPATHCONFIGS_H 6 | 7 | #include "GCodePathConfig.h" 8 | #include "settings/types/LayerIndex.h" 9 | #include "settings/types/Ratio.h" 10 | #include "sliceDataStorage.h" 11 | 12 | namespace cura 13 | { 14 | struct MeshPathConfigs 15 | { 16 | GCodePathConfig inset0_config{}; 17 | GCodePathConfig insetX_config{}; 18 | GCodePathConfig inset0_roofing_config{}; 19 | GCodePathConfig insetX_roofing_config{}; 20 | GCodePathConfig inset0_flooring_config{}; 21 | GCodePathConfig insetX_flooring_config{}; 22 | GCodePathConfig bridge_inset0_config{}; 23 | GCodePathConfig bridge_insetX_config{}; 24 | GCodePathConfig skin_config{}; 25 | GCodePathConfig bridge_skin_config{}; // used for first bridge layer 26 | GCodePathConfig bridge_skin_config2{}; // used for second bridge layer 27 | GCodePathConfig bridge_skin_config3{}; // used for third bridge layer 28 | GCodePathConfig roofing_config{}; 29 | GCodePathConfig flooring_config{}; 30 | std::vector infill_config{}; 31 | GCodePathConfig ironing_config{}; 32 | 33 | MeshPathConfigs(const SliceMeshStorage& mesh, const coord_t layer_thickness, const LayerIndex layer_nr, const std::vector& line_width_factor_per_extruder); 34 | void smoothAllSpeeds(const SpeedDerivatives& first_layer_config, const LayerIndex layer_nr, const LayerIndex max_speed_layer); 35 | }; 36 | 37 | } // namespace cura 38 | 39 | #endif // SETTINGS_TYPES_MESHPATHCONFIGS_H 40 | -------------------------------------------------------------------------------- /include/settings/ZSeamConfig.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef ZSEAMCONFIG_H 5 | #define ZSEAMCONFIG_H 6 | 7 | #include "EnumSettings.h" //For EZSeamType and EZSeamCornerPrefType. 8 | #include "geometry/Point2LL.h" //To store the preferred seam position. 9 | 10 | namespace cura 11 | { 12 | 13 | /*! 14 | * Helper class that encapsulates the various criteria that define the location 15 | * of the z-seam. 16 | * Instances of this are passed to the PathOrderOptimizer to specify where the 17 | * seam is to be located. 18 | */ 19 | struct ZSeamConfig 20 | { 21 | /*! 22 | * Strategy to place the seam (user-specified, shortest distance, sharpest 23 | * corner, etc.). 24 | */ 25 | EZSeamType type_; 26 | 27 | /*! 28 | * When using a user-specified position for the seam, this is the position 29 | * that the user specified. 30 | */ 31 | Point2LL pos_; 32 | 33 | /*! 34 | * Corner preference type, if using the sharpest corner strategy. 35 | */ 36 | EZSeamCornerPrefType corner_pref_; 37 | 38 | /*! 39 | * Prevent 'smoothed out' corners (corners that are spread over multiple, very close together vertices), 40 | * by simplifying the polygon that the corners are detected on by this ammount. 41 | * This does _not_ influence the path, the simplified polygon is a temporary constructed within the algorithm. 42 | */ 43 | coord_t simplify_curvature_; 44 | 45 | /*! 46 | * Create a seam configuration with a custom configuration. 47 | * \param type The strategy to place the seam. 48 | * \param pos The position of a user-specified seam. 49 | * \param corner_pref The corner preference, when using the sharpest corner strategy. 50 | * \param by how much to simplify the curvature (when detecting corners), as otherwise 'smooth' corners are penalized. 51 | */ 52 | ZSeamConfig( 53 | const EZSeamType type = EZSeamType::SHORTEST, 54 | const Point2LL pos = Point2LL(0, 0), 55 | const EZSeamCornerPrefType corner_pref = EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE, 56 | const coord_t simplify_curvature = 0); 57 | }; 58 | 59 | } // namespace cura 60 | 61 | #endif // ZSEAMCONFIG_H 62 | -------------------------------------------------------------------------------- /include/settings/types/Ratio.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef RATIO_H 5 | #define RATIO_H 6 | 7 | #include "utils/types/numeric_facade.h" 8 | 9 | 10 | namespace cura 11 | { 12 | 13 | /* 14 | * \brief Represents a ratio between two numbers. 15 | * 16 | * This is a facade. It behaves like a double. 17 | */ 18 | struct Ratio : public utils::NumericFacade 19 | { 20 | using base_type = utils::NumericFacade; 21 | using base_type::NumericFacade; 22 | 23 | constexpr Ratio(const base_type& base) noexcept 24 | : base_type{ base } {}; 25 | 26 | /*! 27 | * Create the Ratio with a numerator and a divisor from arbitrary types 28 | * \param numerator the numerator of the ratio 29 | * \param divisor the divisor of the ratio 30 | */ 31 | constexpr Ratio(const utils::numeric auto numerator, const utils::numeric auto divisor) 32 | : base_type{ static_cast(numerator) / static_cast(divisor) } {}; 33 | }; 34 | 35 | constexpr Ratio operator""_r(const long double ratio) 36 | { 37 | return { ratio }; 38 | } 39 | 40 | } // namespace cura 41 | 42 | #endif // RATIO_H 43 | -------------------------------------------------------------------------------- /include/settings/types/Temperature.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2018 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef TEMPERATURE_H 5 | #define TEMPERATURE_H 6 | 7 | namespace cura 8 | { 9 | 10 | /* 11 | * \brief Represents a temperature in degrees Celsius. 12 | * 13 | * This is a facade. It behaves like a double. 14 | */ 15 | struct Temperature 16 | { 17 | /* 18 | * \brief Default constructor setting the temperature to 0. 19 | */ 20 | Temperature() : value(0.0) {}; 21 | 22 | /* 23 | * \brief Casts a double to a Temperature instance. 24 | */ 25 | Temperature(double value_t) : value(value_t) {}; 26 | 27 | /* 28 | * \brief Casts the Temperature instance to a double. 29 | */ 30 | operator double() const 31 | { 32 | return value; 33 | } 34 | 35 | /* 36 | * Some operators to do arithmetic with Temperatures. 37 | */ 38 | Temperature operator +(const Temperature& other) const 39 | { 40 | return Temperature(value + other.value); 41 | }; 42 | Temperature operator -(const Temperature& other) const 43 | { 44 | return Temperature(value - other.value); 45 | }; 46 | Temperature& operator +=(const Temperature& other) 47 | { 48 | value += other.value; 49 | return *this; 50 | } 51 | Temperature& operator -=(const Temperature& other) 52 | { 53 | value -= other.value; 54 | return *this; 55 | } 56 | 57 | /* 58 | * \brief The actual temperature, as a double. 59 | */ 60 | double value = 0; 61 | }; 62 | 63 | } 64 | 65 | #endif //TEMPERATURE_H 66 | -------------------------------------------------------------------------------- /include/settings/types/Velocity.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef VELOCITY_H 5 | #define VELOCITY_H 6 | 7 | #include "utils/types/numeric_facade.h" 8 | 9 | namespace cura 10 | { 11 | 12 | /* 13 | * Represents a velocity in millimetres per second. 14 | * 15 | * This is a facade. It behaves like a double, only it can't be negative. 16 | */ 17 | struct Velocity : public utils::NumericFacade 18 | { 19 | using base_type = utils::NumericFacade; 20 | using base_type::NumericFacade; 21 | 22 | constexpr Velocity(const base_type& base) noexcept 23 | : base_type{ base } {}; 24 | }; 25 | 26 | struct Acceleration : public utils::NumericFacade 27 | { 28 | using base_type = utils::NumericFacade; 29 | using base_type::NumericFacade; 30 | 31 | constexpr Acceleration(const base_type& base) noexcept 32 | : base_type{ base } {}; 33 | }; 34 | 35 | } // namespace cura 36 | 37 | #endif // VELOCITY_H -------------------------------------------------------------------------------- /include/utils/Coord_t.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_COORD_T_H 5 | #define UTILS_COORD_T_H 6 | 7 | 8 | // Include Clipper to get the ClipperLib::IntPoint definition, which we reuse as Point definition. 9 | #include 10 | #include 11 | 12 | #include "utils/types/generic.h" 13 | 14 | namespace cura 15 | { 16 | 17 | using coord_t = ClipperLib::cInt; 18 | 19 | static inline coord_t operator""_mu(unsigned long long i) 20 | { 21 | return static_cast(i); 22 | } 23 | 24 | #define INT2MM(n) (static_cast(n) / 1000.0) 25 | #define INT2MM2(n) (static_cast(n) / 1000000.0) 26 | #define MM2INT(n) (static_cast((n) * 1000 + 0.5 * (((n) > 0) - ((n) < 0)))) 27 | #define MM2_2INT(n) (static_cast((n) * 1000000 + 0.5 * (((n) > 0) - ((n) < 0)))) 28 | #define MM3_2INT(n) (static_cast((n) * 1000000000 + 0.5 * (((n) > 0) - ((n) < 0)))) 29 | 30 | #define INT2MICRON(n) ((n) / 1) 31 | #define MICRON2INT(n) ((n) * 1) 32 | 33 | template 34 | [[nodiscard]] inline coord_t lerp(coord_t a, coord_t b, FactorType t) 35 | { 36 | return std::llrint(std::lerp(static_cast(a), static_cast(b), t)); 37 | } 38 | 39 | } // namespace cura 40 | 41 | 42 | #endif // UTILS_COORD_T_H 43 | -------------------------------------------------------------------------------- /include/utils/Date.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_DATE_H 5 | #define UTILS_DATE_H 6 | 7 | #include 8 | 9 | namespace cura 10 | { 11 | 12 | /*! 13 | * Simple class to represent a year, month and day. 14 | */ 15 | class Date 16 | { 17 | public: 18 | Date(int year, int month, int day); //!< Simple constructor 19 | static Date getDate(); //!< Get the current date (compile time) 20 | std::string toStringDashed(); //!< Get a formatted string: yyyy-mm-dd 21 | 22 | protected: 23 | int year_; //!< Year, e.g. 2016 24 | int month_; //!< Month, e.g. 12, i.e. starting at 1 25 | int day_; //!< Day, e.g. 31, i.e. starting at 1 26 | 27 | private: 28 | Date(); //!< Simple constructor initializing all to -1 29 | }; 30 | 31 | } // namespace cura 32 | 33 | #endif // UTILS_DATE_H 34 | -------------------------------------------------------------------------------- /include/utils/ExtrusionJunction.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | 5 | #ifndef UTILS_EXTRUSION_JUNCTION_H 6 | #define UTILS_EXTRUSION_JUNCTION_H 7 | 8 | #include "geometry/Point2LL.h" 9 | 10 | namespace cura 11 | { 12 | 13 | /*! 14 | * This struct represents one vertex in an extruded path. 15 | * 16 | * It contains information on how wide the extruded path must be at this point, 17 | * and which perimeter it represents. 18 | */ 19 | struct ExtrusionJunction 20 | { 21 | /*! 22 | * The position of the centreline of the path when it reaches this junction. 23 | * This is the position that should end up in the g-code eventually. 24 | */ 25 | Point2LL p_; 26 | 27 | /*! 28 | * The width of the extruded path at this junction. 29 | */ 30 | coord_t w_; 31 | 32 | /*! 33 | * Which perimeter this junction is part of. 34 | * 35 | * Perimeters are counted from the outside inwards. The outer wall has index 36 | * 0. 37 | */ 38 | size_t perimeter_index_; 39 | 40 | ExtrusionJunction(const Point2LL p, const coord_t w, const coord_t perimeter_index); 41 | 42 | bool operator==(const ExtrusionJunction& other) const; 43 | }; 44 | 45 | inline Point2LL operator-(const ExtrusionJunction& a, const ExtrusionJunction& b) 46 | { 47 | return a.p_ - b.p_; 48 | } 49 | 50 | // Identity function, used to be able to make templated algorithms that do their operations on 'point-like' input. 51 | inline const Point2LL& make_point(const ExtrusionJunction& ej) 52 | { 53 | return ej.p_; 54 | } 55 | 56 | using LineJunctions = std::vector; //; 14 | 15 | } // namespace cura 16 | #endif // UTILS_EXTRUSION_LINE_STITCHER_H 17 | -------------------------------------------------------------------------------- /include/utils/HalfEdge.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_HALF_EDGE_H 5 | #define UTILS_HALF_EDGE_H 6 | 7 | #include 8 | #include 9 | 10 | #include "Coord_t.h" 11 | #include "geometry/Point2LL.h" 12 | 13 | namespace cura 14 | { 15 | 16 | template 17 | class HalfEdge 18 | { 19 | using edge_t = derived_edge_t; 20 | using node_t = derived_node_t; 21 | 22 | public: 23 | edge_data_t data_; 24 | edge_t* twin_ = nullptr; 25 | edge_t* next_ = nullptr; 26 | edge_t* prev_ = nullptr; 27 | node_t* from_ = nullptr; 28 | node_t* to_ = nullptr; 29 | 30 | HalfEdge(edge_data_t data) 31 | : data_(data) 32 | { 33 | } 34 | 35 | bool operator==(const edge_t& other) 36 | { 37 | return this == &other; 38 | } 39 | }; 40 | 41 | 42 | } // namespace cura 43 | #endif // UTILS_HALF_EDGE_H 44 | -------------------------------------------------------------------------------- /include/utils/HalfEdgeGraph.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_HALF_EDGE_GRAPH_H 5 | #define UTILS_HALF_EDGE_GRAPH_H 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | 13 | #include "HalfEdge.h" 14 | #include "HalfEdgeNode.h" 15 | #include "SVG.h" 16 | 17 | namespace cura 18 | { 19 | using namespace cura; 20 | 21 | template // types of data contained in nodes and edges 22 | class HalfEdgeGraph 23 | { 24 | public: 25 | using edge_t = derived_edge_t; 26 | using node_t = derived_node_t; 27 | std::list edges; 28 | std::list nodes; 29 | }; 30 | 31 | } // namespace cura 32 | #endif // UTILS_HALF_EDGE_GRAPH_H 33 | -------------------------------------------------------------------------------- /include/utils/HalfEdgeNode.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_HALF_EDGE_NODE_H 5 | #define UTILS_HALF_EDGE_NODE_H 6 | 7 | #include 8 | 9 | #include "geometry/Point2LL.h" 10 | 11 | namespace cura 12 | { 13 | 14 | template 15 | class HalfEdgeNode 16 | { 17 | using edge_t = derived_edge_t; 18 | using node_t = derived_node_t; 19 | 20 | public: 21 | node_data_t data_; 22 | Point2LL p_; 23 | edge_t* incident_edge_ = nullptr; 24 | 25 | HalfEdgeNode(node_data_t data, Point2LL p) 26 | : data_(data) 27 | , p_(p) 28 | { 29 | } 30 | 31 | bool operator==(const node_t& other) 32 | { 33 | return this == &other; 34 | } 35 | }; 36 | 37 | 38 | } // namespace cura 39 | #endif // UTILS_HALF_EDGE_NODE_H 40 | -------------------------------------------------------------------------------- /include/utils/Matrix4x3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MATRIX4X3D_H 5 | #define MATRIX4X3D_H 6 | 7 | #include "settings/types/Ratio.h" 8 | 9 | namespace cura 10 | { 11 | 12 | class Point3D; 13 | class Point3LL; 14 | 15 | /*! 16 | * A 4x3 affine transformation matrix. 17 | * 18 | * This matrix behaves as if it's a 4x4 transformation matrix, but the bottom 19 | * row is always identity. 20 | */ 21 | class Matrix4x3D 22 | { 23 | public: 24 | /*! 25 | * Create a scaling matrix with a uniform scale. 26 | * \param scale The scale factor that this matrix should apply. 27 | * \param origin The coordinate origin to apply the scale from. If the scale 28 | * is reduced, all coordinates will go towards this origin. If the scale is 29 | * increased, all coordinates will go away from this origin. 30 | */ 31 | static Matrix4x3D scale(const Ratio scale, const Point3LL origin); 32 | static Matrix4x3D scale(const Ratio scale_x, const Ratio scale_y, const Ratio scale_z, const Point3LL origin); 33 | 34 | /*! 35 | * The matrix data, row-endian. 36 | * 37 | * The first index is the column. The second index is the row. 38 | */ 39 | double m[4][3]; 40 | 41 | /*! 42 | * Construct an identity matrix. 43 | */ 44 | Matrix4x3D(); 45 | 46 | /*! 47 | * Apply this transformation to a coordinate. 48 | * 49 | * The result will also be converted to an integer-based coordinate 50 | * (``Point3``). 51 | * \param p The coordinate to transform. 52 | * \return A transformed coordinate. 53 | */ 54 | Point3LL apply(const Point3D& p) const; 55 | 56 | /*! 57 | * Apply this transformation to a coordinate. 58 | * \param p The coordinate to transform. 59 | * \return A transformed coordinate. 60 | */ 61 | Point3LL apply(const Point3LL& p) const; 62 | }; 63 | 64 | } // namespace cura 65 | #endif // MATRIX4X3D_H 66 | -------------------------------------------------------------------------------- /include/utils/MinimumSpanningTree.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MINIMUMSPANNINGTREE_H 5 | #define MINIMUMSPANNINGTREE_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "geometry/Point2LL.h" 12 | 13 | namespace cura 14 | { 15 | 16 | /*! 17 | * \brief Implements Prim's algorithm to compute Minimum Spanning Trees (MST). 18 | * 19 | * The minimum spanning tree is always computed from a clique of vertices. 20 | */ 21 | class MinimumSpanningTree 22 | { 23 | /*! 24 | * \brief Represents an edge of the tree. 25 | * 26 | * While edges are meant to be undirected, these do have a start and end 27 | * point. 28 | */ 29 | struct Edge 30 | { 31 | /** 32 | * The point at which this edge starts. 33 | */ 34 | const Point2LL start; 35 | 36 | /** 37 | * The point at which this edge ends. 38 | */ 39 | const Point2LL end; 40 | }; 41 | 42 | public: 43 | MinimumSpanningTree() = default; 44 | /*! 45 | * \brief Constructs a minimum spanning tree that spans all given vertices. 46 | */ 47 | MinimumSpanningTree(std::vector vertices); 48 | 49 | /*! 50 | * \brief Gets the nodes that are adjacent to the specified node. 51 | * \return A list of nodes that are adjacent. 52 | */ 53 | std::vector adjacentNodes(Point2LL node) const; 54 | 55 | /*! 56 | * \brief Gets the leaves of the tree. 57 | * \return A list of nodes that are all leaves of the tree. 58 | */ 59 | std::vector leaves() const; 60 | 61 | /*! 62 | * \brief Gets all vertices of the tree. 63 | * \return A list of vertices of the tree. 64 | */ 65 | std::vector vertices() const; 66 | 67 | private: 68 | using AdjacencyGraph_t = std::unordered_map>; 69 | AdjacencyGraph_t adjacency_graph; 70 | 71 | /*! 72 | * \brief Computes the edges of a minimum spanning tree using Prim's 73 | * algorithm. 74 | * 75 | * \param vertices The vertices to span. 76 | * \return An adjacency graph with for each point one or more edges. 77 | */ 78 | AdjacencyGraph_t prim(std::vector vertices) const; 79 | }; 80 | 81 | } // namespace cura 82 | 83 | #endif /* MINIMUMSPANNINGTREE_H */ 84 | -------------------------------------------------------------------------------- /include/utils/MixedPolylineStitcher.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_MIXED_POLYLINE_STITCHER_H 5 | #define UTILS_MIXED_POLYLINE_STITCHER_H 6 | 7 | #include "PolylineStitcher.h" 8 | #include "geometry/ClosedLinesSet.h" 9 | #include "geometry/LinesSet.h" 10 | #include "geometry/OpenLinesSet.h" 11 | 12 | namespace cura 13 | { 14 | 15 | class MixedLinesSet; 16 | 17 | class MixedPolylineStitcher : public PolylineStitcher 18 | { 19 | public: 20 | static void stitch(const OpenLinesSet& lines, MixedLinesSet& result, coord_t max_stitch_distance = MM2INT(0.1), coord_t snap_distance = 10); 21 | }; 22 | 23 | } // namespace cura 24 | #endif // UTILS_MIXED_POLYLINE_STITCHER_H 25 | -------------------------------------------------------------------------------- /include/utils/NoCopy.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_NO_COPY_H 5 | #define UTILS_NO_COPY_H 6 | 7 | /*! 8 | * Util class to base other objects off which should never be copied. 9 | * Is needed because C++ has an implicit copy constructor and assign operator when none are defined. 10 | */ 11 | class NoCopy 12 | { 13 | protected: 14 | NoCopy() {} 15 | 16 | private: 17 | /*! 18 | * Private copy constructor. 19 | * Cannot be called because it is private. 20 | */ 21 | NoCopy(const NoCopy&); 22 | 23 | /*! 24 | * Private assign operator. 25 | * Cannot be called because it is private. 26 | */ 27 | NoCopy& operator =(const NoCopy&); 28 | }; 29 | 30 | #endif // UTILS_NO_COPY_H -------------------------------------------------------------------------------- /include/utils/OpenPolylineStitcher.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_OPEN_POLYLINE_STITCHER_H 5 | #define UTILS_OPEN_POLYLINE_STITCHER_H 6 | 7 | #include "PolylineStitcher.h" 8 | #include "geometry/LinesSet.h" 9 | #include "geometry/OpenLinesSet.h" 10 | #include "geometry/Shape.h" 11 | 12 | namespace cura 13 | { 14 | 15 | using OpenPolylineStitcher = PolylineStitcher; 16 | 17 | } // namespace cura 18 | #endif // UTILS_OPEN_POLYLINE_STITCHER_H 19 | -------------------------------------------------------------------------------- /include/utils/PairHash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_PAIRHASH_H 5 | #define UTILS_PAIRHASH_H 6 | 7 | #include 8 | #include 9 | 10 | namespace std 11 | { 12 | 13 | template 14 | struct hash> 15 | { 16 | size_t operator()(const std::pair& pair) const 17 | { 18 | return 31 * std::hash()(pair.first) + 59 * std::hash()(pair.second); 19 | } 20 | }; 21 | 22 | } // namespace std 23 | 24 | #endif // UTILS_PAIRHASH_H 25 | -------------------------------------------------------------------------------- /include/utils/Point3F.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef POINT3F_H 5 | #define POINT3F_H 6 | 7 | #include 8 | #include 9 | 10 | #include "Point3D.h" 11 | #include "geometry/Point2LL.h" 12 | 13 | 14 | namespace cura 15 | { 16 | 17 | /* 18 | Floating point 3D points are used during model loading as 3D vectors. 19 | They represent millimeters in 3D space. 20 | This class should not be used for geometric computation. Use Point3d for this purpose. 21 | */ 22 | class Point3F 23 | { 24 | public: 25 | float x_, y_, z_; 26 | 27 | Point3F() 28 | { 29 | } 30 | 31 | Point3F(float x, float y, float z) 32 | : x_(x) 33 | , y_(y) 34 | , z_(z) 35 | { 36 | } 37 | 38 | Point3D toPoint3d() const 39 | { 40 | return Point3D(static_cast(x_), static_cast(y_), static_cast(z_)); 41 | } 42 | }; 43 | 44 | } // namespace cura 45 | #endif // POINT3F_H 46 | -------------------------------------------------------------------------------- /include/utils/PolygonsSegmentIndex.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_POLYGONS_SEGMENT_INDEX_H 5 | #define UTILS_POLYGONS_SEGMENT_INDEX_H 6 | 7 | #include 8 | 9 | #include "PolygonsPointIndex.h" 10 | 11 | namespace cura 12 | { 13 | 14 | /*! 15 | * A class for iterating over the points in one of the polygons in a \ref Polygons object 16 | */ 17 | class PolygonsSegmentIndex : public PolygonsPointIndex 18 | { 19 | public: 20 | PolygonsSegmentIndex(); 21 | PolygonsSegmentIndex(const Shape* polygons, unsigned int poly_idx, unsigned int point_idx); 22 | 23 | Point2LL from() const; 24 | 25 | Point2LL to() const; 26 | }; 27 | 28 | 29 | } // namespace cura 30 | 31 | 32 | #endif // UTILS_POLYGONS_SEGMENT_INDEX_H 33 | -------------------------------------------------------------------------------- /include/utils/ToolpathVisualizer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Ultimaker B.V. 2 | #ifndef TOOLPATH_VISUALIZER_H 3 | #define TOOLPATH_VISUALIZER_H 4 | 5 | #include "ExtrusionSegment.h" 6 | #include "SVG.h" 7 | #include "geometry/Polygon.h" 8 | 9 | namespace cura 10 | { 11 | using namespace cura; 12 | 13 | /*! 14 | * Get statistics of the resulting toolpaths 15 | */ 16 | class ToolpathVisualizer 17 | { 18 | public: 19 | ToolpathVisualizer(SVG& svg) 20 | : svg_(svg) 21 | { 22 | } 23 | 24 | void outline(const Shape& input); 25 | void toolpaths(const std::vector& all_segments, bool rounded_visualization = true); 26 | void underfill(const Shape& underfills); 27 | void overfill(const Shape& overfills, const Shape& double_overfills = Shape()); 28 | void width_legend(const Shape& input, coord_t nozzle_size, coord_t max_dev, coord_t min_w, bool rounded_visualization); 29 | void widths(const std::vector& all_segments, coord_t nozzle_size, coord_t max_dev, coord_t min_w, bool rounded_visualization, bool exaggerate_widths = false); 30 | 31 | private: 32 | SVG& svg_; 33 | }; 34 | 35 | } // namespace cura 36 | #endif // TOOLPATH_VISUALIZER_H 37 | -------------------------------------------------------------------------------- /include/utils/algorithm.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2021 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_ALGORITHM_H 5 | #define UTILS_ALGORITHM_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // extensions to algorithm.h from the standard library 12 | 13 | namespace cura 14 | { 15 | 16 | /*! 17 | * Get the order of a vector: the sorted indices of a vector 18 | * 19 | * {1.6, 1.8, 1.7} returns {1, 3, 2} meaning {in[1], in[3], in[2]} is a sorted 20 | * vector 21 | * 22 | * Thanks to Lukasz Wiklendt 23 | * 24 | * \param in The vector for which to get the order 25 | * \return An ordered vector of indices into \p in 26 | */ 27 | template 28 | std::vector order(const std::vector &in) 29 | { 30 | // initialize original index locations 31 | std::vector order(in.size()); 32 | std::iota(order.begin(), order.end(), 0); // fill vector with 1, 2, 3,.. etc 33 | 34 | // sort indexes based on comparing values in v 35 | std::sort(order.begin(), order.end(), 36 | [&in](size_t i1, size_t i2) 37 | { 38 | return in[i1] < in[i2]; 39 | } 40 | ); 41 | 42 | return order; 43 | } 44 | 45 | 46 | } // namespace cura 47 | 48 | #endif // UTILS_ALGORITHM_H 49 | 50 | -------------------------------------------------------------------------------- /include/utils/channel.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef CHANNEL_H 5 | #define CHANNEL_H 6 | 7 | #ifdef ENABLE_PLUGINS 8 | #include 9 | #include 10 | #include 11 | 12 | #ifndef ENABLE_REMOTE_PLUGINS 13 | #define ENABLE_REMOTE_PLUGINS false 14 | #endif 15 | 16 | namespace cura::utils 17 | { 18 | struct ChannelSetupConfiguration 19 | { 20 | public: 21 | std::string host; 22 | uint64_t port; 23 | uint64_t shibolet = 0UL; // TODO: Either get from startup (server would receive this as well) or remove completely. 24 | }; 25 | 26 | std::shared_ptr createChannel(const ChannelSetupConfiguration& config = { "localhost", 50010UL }); 27 | 28 | } // namespace cura::utils 29 | 30 | #endif // ENABLE_PLUGINS 31 | #endif // CHANNEL_H 32 | -------------------------------------------------------------------------------- /include/utils/format/filesystem_path.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H 5 | #define CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace fmt 13 | { 14 | template<> 15 | struct formatter : formatter 16 | { 17 | static std::string USERNAME; 18 | static constexpr std::string_view OBFUSCATED_STRING = "*******"; 19 | 20 | [[nodiscard]] static std::string anonymizePath(const std::string& path) 21 | { 22 | std::string anonymized_path = path; 23 | size_t pos = anonymized_path.find(USERNAME); 24 | while (pos != std::string::npos) 25 | { 26 | anonymized_path.replace(pos, USERNAME.size(), OBFUSCATED_STRING); 27 | pos = anonymized_path.find(USERNAME, pos + OBFUSCATED_STRING.size()); 28 | } 29 | return anonymized_path; 30 | } 31 | 32 | template 33 | auto format(const std::filesystem::path& path, FormatContext& ctx) const 34 | { 35 | return formatter::format(anonymizePath(path.generic_string()), ctx); 36 | } 37 | }; 38 | 39 | #ifdef _WIN32 40 | inline std::string fmt::formatter::USERNAME = std::getenv("USERNAME") != nullptr ? std::getenv("USERNAME") : ""; 41 | #else 42 | inline std::string fmt::formatter::USERNAME = std::getenv("USER") != nullptr ? std::getenv("USER") : ""; 43 | #endif 44 | 45 | } // namespace fmt 46 | 47 | #endif // CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H 48 | -------------------------------------------------------------------------------- /include/utils/format/thread_id.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_FORMAT_THREAD_ID_H 5 | #define UTILS_FORMAT_THREAD_ID_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace fmt 14 | { 15 | template<> 16 | struct formatter : formatter 17 | { 18 | template 19 | auto format(std::thread::id thread_id, FormatContext& ctx) const 20 | { 21 | std::ostringstream oss; 22 | oss << thread_id; 23 | return formatter::format(oss.str(), ctx); 24 | } 25 | }; 26 | 27 | } // namespace fmt 28 | #endif // UTILS_FORMAT_THREAD_ID_H 29 | -------------------------------------------------------------------------------- /include/utils/gettime.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef GETTIME_H 5 | #define GETTIME_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace cura 14 | { 15 | 16 | class TimeKeeper 17 | { 18 | public: 19 | struct RegisteredTime 20 | { 21 | std::string stage; 22 | double duration; 23 | }; 24 | 25 | using RegisteredTimes = std::vector; 26 | 27 | private: 28 | spdlog::stopwatch watch; 29 | double start_time; 30 | RegisteredTimes registered_times; 31 | 32 | public: 33 | TimeKeeper(); 34 | 35 | double restart(); 36 | 37 | void registerTime(const std::string& stage, double threshold = 0.01); 38 | 39 | const RegisteredTimes& getRegisteredTimes() const 40 | { 41 | return registered_times; 42 | } 43 | }; 44 | 45 | } // namespace cura 46 | #endif // GETTIME_H 47 | -------------------------------------------------------------------------------- /include/utils/macros.h: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2020 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_MACROS_H 5 | #define UTILS_MACROS_H 6 | 7 | #include 8 | 9 | // macro to suppress unused parameter warnings from the compiler 10 | #define UNUSED_PARAM(param) (void)(param) 11 | 12 | // simple function to be used to reduce the number of times an error is logged 13 | // no guarantees in a mutli-threaded context 14 | #define RUN_ONCE(runcode) \ 15 | { \ 16 | static std::atomic code_ran = false; \ 17 | if(!code_ran){ \ 18 | bool expected = false; \ 19 | if(code_ran.compare_exchange_strong(expected, true)) \ 20 | { runcode; }\ 21 | } \ 22 | } 23 | 24 | 25 | #endif // UTILS_MACROS_H 26 | -------------------------------------------------------------------------------- /include/utils/scoring/DistanceScoringCriterion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef DISTANCESCORINGCRITERION_H 5 | #define DISTANCESCORINGCRITERION_H 6 | 7 | #include "geometry/Point2LL.h" 8 | #include "utils/scoring/ScoringCriterion.h" 9 | 10 | namespace cura 11 | { 12 | class PointsSet; 13 | 14 | /*! 15 | * Criterion that will give a score according to the distance from the point to a target point. Closer points will get 16 | * a higher score. 17 | */ 18 | class DistanceScoringCriterion : public ScoringCriterion 19 | { 20 | public: 21 | enum class DistanceType 22 | { 23 | Euclidian, // Classic euclidian distance between the points 24 | XOnly, // Only difference on X coordinate 25 | YOnly, // Only difference on Y coordinate 26 | }; 27 | 28 | private: 29 | const PointsSet& points_; 30 | const Point2LL& target_pos_; 31 | const DistanceType distance_type_; 32 | 33 | /*! 34 | * Fixed divider for shortest distances computation. The divider should be set so that the minimum encountered 35 | * distance gives a score very close to 1.0, and a medium-far distance gives a score close to 0.5 36 | */ 37 | const double distance_divider_; 38 | 39 | public: 40 | explicit DistanceScoringCriterion( 41 | const PointsSet& points, 42 | const Point2LL& target_pos, 43 | DistanceType distance_type = DistanceType::Euclidian, 44 | const double distance_divider = 20.0); 45 | 46 | virtual double computeScore(const size_t candidate_index) const override; 47 | }; 48 | 49 | } // namespace cura 50 | 51 | #endif // DISTANCESCORINGCRITERION_H 52 | -------------------------------------------------------------------------------- /include/utils/scoring/ExclusionAreaScoringCriterion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef EXCLUSIONAREASCORINGCRITERION_H 5 | #define EXCLUSIONAREASCORINGCRITERION_H 6 | 7 | #include 8 | 9 | #include "utils/scoring/ScoringCriterion.h" 10 | 11 | namespace cura 12 | { 13 | class PointsSet; 14 | class Shape; 15 | 16 | /*! 17 | * Criterion that will give a score according to whether the point is located inside or outside of an exclusion area. 18 | * This is currently a binary test and the score will be either 0 or 1. 19 | */ 20 | class ExclusionAreaScoringCriterion : public ScoringCriterion 21 | { 22 | private: 23 | const PointsSet& points_; 24 | const Shape& exclusion_area_; 25 | 26 | public: 27 | explicit ExclusionAreaScoringCriterion(const PointsSet& points, const Shape& exclusion_area); 28 | 29 | virtual double computeScore(const size_t candidate_index) const override; 30 | }; 31 | 32 | } // namespace cura 33 | 34 | #endif // EXCLUSIONAREASCORINGCRITERION_H 35 | -------------------------------------------------------------------------------- /include/utils/scoring/RandomScoringCriterion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef RANDOMSCORINGCRITERION_H 5 | #define RANDOMSCORINGCRITERION_H 6 | 7 | #include 8 | 9 | #include "utils/scoring/ScoringCriterion.h" 10 | 11 | namespace cura 12 | { 13 | 14 | /*! 15 | * Criterion that will give a random score whatever the element is. 16 | */ 17 | class RandomScoringCriterion : public ScoringCriterion 18 | { 19 | public: 20 | explicit RandomScoringCriterion(); 21 | 22 | virtual double computeScore(const size_t candidate_index) const override; 23 | }; 24 | 25 | } // namespace cura 26 | 27 | #endif // RANDOMSCORINGCRITERION_H 28 | -------------------------------------------------------------------------------- /include/utils/scoring/ScoringCriterion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef UTILS_SCORING_SCORINGCRITERION_H 5 | #define UTILS_SCORING_SCORINGCRITERION_H 6 | 7 | #include 8 | 9 | namespace cura 10 | { 11 | 12 | /*! 13 | * Base class for implementing a selection criterion when calculating a multi-criteria score to select the best element 14 | * amongst a list. 15 | */ 16 | class ScoringCriterion 17 | { 18 | public: 19 | ScoringCriterion() = default; 20 | 21 | virtual ~ScoringCriterion() = default; 22 | 23 | /*! 24 | * \brief Computes the score of an element regarding this criterion. To ensure a proper selection, this value must 25 | * be contained in [0.0, 1.0] and the different given scores must be evenly distributed in this range. 26 | * \param candidate_index The index of the candidate of the original list 27 | * \return The raw score of the element regarding this criterion 28 | */ 29 | virtual double computeScore(const size_t candidate_index) const = 0; 30 | }; 31 | 32 | } // namespace cura 33 | 34 | #endif // UTILS_SCORING_SCORINGCRITERION_H 35 | -------------------------------------------------------------------------------- /include/utils/section_type.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef INCLUDE_UTILS_SECTION_TYPE_H 5 | #define INCLUDE_UTILS_SECTION_TYPE_H 6 | 7 | namespace cura 8 | { 9 | enum class SectionType : int 10 | { 11 | NA = -1, 12 | WALL = 1, 13 | INFILL = 2, 14 | SKIN = 3, 15 | SUPPORT = 4, 16 | ADHESION = 5, 17 | IRONING = 6, 18 | MESH = 7, 19 | DOTS = 8, 20 | CONCENTRIC_INFILL = 9 21 | }; 22 | } // namespace cura 23 | 24 | #endif // INCLUDE_UTILS_SECTION_TYPE_H 25 | -------------------------------------------------------------------------------- /include/utils/types/char_range_literal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_TYPES_CHAR_RANGE_LITERAL_H 5 | #define UTILS_TYPES_CHAR_RANGE_LITERAL_H 6 | 7 | #include 8 | 9 | 10 | namespace cura::utils 11 | { 12 | template 13 | struct CharRangeLiteral 14 | { 15 | constexpr CharRangeLiteral(const char (&str)[N]) noexcept 16 | { 17 | std::copy_n(str, N, value); 18 | } 19 | 20 | char value[N]; 21 | }; 22 | 23 | } // namespace cura::utils 24 | 25 | #endif // UTILS_TYPES_CHAR_RANGE_LITERAL_H -------------------------------------------------------------------------------- /include/utils/types/generic.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef CURAENGINE_GENERIC_H 5 | #define CURAENGINE_GENERIC_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace cura::utils 14 | { 15 | // clang-format off 16 | template 17 | concept hashable = requires(T value) 18 | { 19 | { std::hash{}(value) } -> concepts::convertible_to; 20 | }; 21 | 22 | template 23 | concept grpc_convertable = requires(T value) 24 | { 25 | requires ranges::semiregular; 26 | requires ranges::semiregular; 27 | requires ranges::semiregular; 28 | }; 29 | 30 | #ifdef OLDER_APPLE_CLANG 31 | 32 | // std::integral and std::floating_point are not implemented in older Apple Clang versions < 13 33 | // https://stackoverflow.com/questions/71818683/stdintegral-not-found-in-clang13-c20-error 34 | template 35 | concept integral = 36 | std::is_same_v || 37 | std::is_same_v || 38 | std::is_same_v || 39 | std::is_same_v || 40 | std::is_same_v || 41 | std::is_same_v || 42 | std::is_same_v || 43 | std::is_same_v || 44 | std::is_same_v || 45 | std::is_same_v || 46 | std::is_same_v || 47 | std::is_same_v || 48 | std::is_same_v || 49 | std::is_same_v || 50 | std::is_same_v || 51 | std::is_same_v; 52 | 53 | template 54 | concept floating_point = std::is_same_v || std::is_same_v || std::is_same_v; 55 | #else 56 | template 57 | concept integral = std::integral; 58 | 59 | template 60 | concept floating_point = std::floating_point; 61 | #endif 62 | // clang-format on 63 | 64 | template 65 | concept numeric = std::is_arithmetic_v>; 66 | 67 | template 68 | concept multipliable = requires(T a, T b) 69 | { 70 | { a * b }; 71 | }; 72 | } // namespace cura::utils 73 | 74 | #endif // CURAENGINE_GENERIC_H 75 | -------------------------------------------------------------------------------- /include/utils/types/graph.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_CONCEPTS_GRAPH_H 5 | #define UTILS_CONCEPTS_GRAPH_H 6 | 7 | #include "utils/types/generic.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace cura::utils 13 | { 14 | // clang-format off 15 | 16 | /* # nodable 17 | * Describing the basic requirement for a node in a graph. 18 | */ 19 | template 20 | concept nodeable = hashable; 21 | 22 | /* # graphable 23 | * Describing the basic requirement for a directed graph, namely that it is a map, where the `key_type` and the `mapped_type` 24 | * exist and are of the same type. 25 | */ 26 | template 27 | concept graphable = 28 | nodeable && (std::is_same>::value || std::is_same>::value); 29 | 30 | /* # setable 31 | * Describing the basic requirement for a set. 32 | */ 33 | template 34 | concept setable = nodeable 35 | && (std::is_same>::value || std::is_same>::value || std::is_same>::value); 36 | 37 | // clang-format off 38 | } // namespace cura 39 | 40 | #endif // UTILS_CONCEPTS_GRAPH_H 41 | -------------------------------------------------------------------------------- /include/utils/types/string_switch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_TYPES_STRING_SWITCH_H 5 | #define UTILS_TYPES_STRING_SWITCH_H 6 | 7 | #include 8 | 9 | namespace cura::utils 10 | { 11 | 12 | // Source: https://learnmoderncpp.com/2020/06/01/strings-as-switch-case-labels/ 13 | constexpr inline uint64_t hash_djb2a(const std::string_view value) 14 | { 15 | uint64_t hash{ 5381 }; 16 | for (unsigned char c : value) 17 | { 18 | hash = ((hash << 5) + hash) ^ c; 19 | } 20 | return hash; 21 | } 22 | 23 | constexpr inline uint64_t hash_enum(const std::string_view value) 24 | { 25 | constexpr uint64_t plugin_namespace_sep_location{ 6 }; 26 | if (value.size() > plugin_namespace_sep_location && value.at(plugin_namespace_sep_location) == ':') 27 | { 28 | return hash_djb2a("plugin"); 29 | } 30 | return hash_djb2a(value); 31 | } 32 | 33 | constexpr inline auto operator""_sw(const char* str, size_t len) 34 | { 35 | return hash_enum(std::string_view{ str, len }); 36 | } 37 | 38 | 39 | } // namespace cura::utils 40 | 41 | #endif // UTILS_TYPES_STRING_SWITCH_H 42 | -------------------------------------------------------------------------------- /include/utils/views/bounding_box.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_VIEWS_BOUNDING_BOX_H 5 | #define UTILS_VIEWS_BOUNDING_BOX_H 6 | 7 | #include 8 | 9 | #include "utils/AABB.h" 10 | #include "utils/views/convert.h" 11 | 12 | 13 | namespace cura::views 14 | { 15 | /* # cura::views::bounding_box 16 | * The convert view converts an input range of `T` into an output range of `U` by calling the Projection on every element of the input range. 17 | * and convert them to `V` 18 | * 19 | * ## Syntax 20 | * ```cpp 21 | * std::vector input_range { ... }; 22 | * auto output_range = input_range | ranges::views::convert(&ExtrusionLine::toPolygon); 23 | * ``` 24 | * or 25 | * ```cpp 26 | * std::vector input_range { ... }; 27 | * auto output_range = input_range | ranges::views::convert(ranges::identity{}); 28 | * ``` 29 | * 30 | * ## Parameters 31 | * \param proj Projection used to obtain the elements 32 | * 33 | * \returns a transformed view with elements of type `AABB` 34 | */ 35 | constexpr auto bounding_box(auto&& proj) 36 | { 37 | return convert(std::forward(proj)); 38 | } 39 | } // namespace cura::views 40 | 41 | #endif // UTILS_VIEWS_BOUNDING_BOX_H -------------------------------------------------------------------------------- /include/utils/views/convert.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_VIEWS_CONVERT_H 5 | #define UTILS_VIEWS_CONVERT_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace cura::views 13 | { 14 | /* # cura::views::convert 15 | * The convert view converts an input range of `T` into an output range of `U` by calling the Projection on every element of the input range. 16 | * and convert them to `V` 17 | * 18 | * ## Syntax 19 | * ```cpp 20 | * std::vector input_range { ... }; 21 | * auto output_range = input_range | ranges::views::convert(&ExtrusionLine::toPolygon); 22 | * ``` 23 | * or 24 | * ```cpp 25 | * std::vector input_range { ... }; 26 | * auto output_range = input_range | ranges::views::convert(ranges::identity{}); 27 | * ``` 28 | * 29 | * ## Parameters 30 | * \param proj Projection used to obtain the elements 31 | * 32 | * \returns a transformed view with elements of type `V` 33 | */ 34 | template 35 | constexpr auto convert(auto&& proj) 36 | { 37 | return ranges::make_view_closure(ranges::views::transform([proj](auto item) { return V { std::invoke(proj, item) }; })); 38 | } 39 | } // namespace cura::views 40 | 41 | #endif // UTILS_VIEWS_CONVERT_H 42 | -------------------------------------------------------------------------------- /include/utils/views/get.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef UTILS_VIEWS_GET_H 5 | #define UTILS_VIEWS_GET_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace cura::views 13 | { 14 | /* # cura::views::get 15 | * The convert view converts an input range of `T` into an output range of `U` by calling the Projection on every element of the input range. 16 | * 17 | * ## Syntax 18 | * ```cpp 19 | * std::vector input_range { ... }; 20 | * auto output_range = input_range | ranges::views::get(&ExtrusionLine::toPolygon); 21 | * // Note: in this case it will get a range of ClipperLib::IntPoint 22 | * ``` 23 | * or 24 | * ```cpp 25 | * struct NamedAABB 26 | * { 27 | * AABB box; 28 | * std::string name; 29 | * }; 30 | * 31 | * std::vector input_range { ... }; 32 | * auto output_range = input_range | ranges::views::get(&NamedAABB::box); 33 | * ``` 34 | * 35 | * ## Parameters 36 | * \param proj Projection used to obtain the elements 37 | * 38 | * \returns a transformed view with elements of type `T::value_type` 39 | */ 40 | constexpr auto get(auto&& proj) 41 | { 42 | return ranges::make_view_closure(ranges::views::transform([proj](auto&& item) { return std::invoke(proj, std::forward(item)); })); 43 | } 44 | } // namespace cura::views 45 | 46 | #endif // UTILS_VIEWS_GET_H 47 | -------------------------------------------------------------------------------- /include/utils/views/split_paths.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifndef CURAENGINE_SPLIT_PATHS_H 5 | #define CURAENGINE_SPLIT_PATHS_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace cura::views 14 | { 15 | namespace details 16 | { 17 | #ifdef _WIN32 18 | constexpr auto path_sep = ';'; 19 | #else 20 | constexpr auto path_sep = ':'; 21 | #endif 22 | } // namespace details 23 | 24 | inline static constexpr auto split_paths = ranges::views::split(details::path_sep) 25 | | ranges::views::transform( 26 | [](auto&& rng) 27 | { 28 | return std::string_view(&*rng.begin(), ranges::distance(rng)); 29 | }); 30 | 31 | } // namespace cura::views 32 | 33 | #endif // CURAENGINE_SPLIT_PATHS_H 34 | -------------------------------------------------------------------------------- /src/BeadingStrategy/OuterWallInsetBeadingStrategy.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "BeadingStrategy/OuterWallInsetBeadingStrategy.h" 5 | 6 | #include 7 | 8 | namespace cura 9 | { 10 | OuterWallInsetBeadingStrategy::OuterWallInsetBeadingStrategy(coord_t outer_wall_offset, BeadingStrategyPtr parent) 11 | : BeadingStrategy(*parent) 12 | , parent_(std::move(parent)) 13 | , outer_wall_offset_(outer_wall_offset) 14 | { 15 | name_ = "OuterWallOfsetBeadingStrategy"; 16 | } 17 | 18 | 19 | coord_t OuterWallInsetBeadingStrategy::getOptimalThickness(coord_t bead_count) const 20 | { 21 | return parent_->getOptimalThickness(bead_count); 22 | } 23 | 24 | coord_t OuterWallInsetBeadingStrategy::getTransitionThickness(coord_t lower_bead_count) const 25 | { 26 | return parent_->getTransitionThickness(lower_bead_count); 27 | } 28 | 29 | coord_t OuterWallInsetBeadingStrategy::getOptimalBeadCount(coord_t thickness) const 30 | { 31 | return parent_->getOptimalBeadCount(thickness); 32 | } 33 | 34 | coord_t OuterWallInsetBeadingStrategy::getTransitioningLength(coord_t lower_bead_count) const 35 | { 36 | return parent_->getTransitioningLength(lower_bead_count); 37 | } 38 | 39 | std::string OuterWallInsetBeadingStrategy::toString() const 40 | { 41 | return std::string("OuterWallOfsetBeadingStrategy+") + parent_->toString(); 42 | } 43 | 44 | BeadingStrategy::Beading OuterWallInsetBeadingStrategy::compute(coord_t thickness, coord_t bead_count) const 45 | { 46 | Beading ret = parent_->compute(thickness, bead_count); 47 | 48 | // Actual count and thickness as represented by extant walls. Don't count any potential zero-width 'signaling' walls. 49 | bead_count = std::count_if( 50 | ret.bead_widths.begin(), 51 | ret.bead_widths.end(), 52 | [](const coord_t width) 53 | { 54 | return width > 0; 55 | }); 56 | 57 | // No need to apply any inset if there is just a single wall. 58 | if (bead_count < 2) 59 | { 60 | return ret; 61 | } 62 | 63 | // Actually move the outer wall inside. Ensure that the outer wall never goes beyond the middle line. 64 | ret.toolpath_locations[0] = std::min(ret.toolpath_locations[0] + outer_wall_offset_, thickness / 2); 65 | return ret; 66 | } 67 | 68 | } // namespace cura 69 | -------------------------------------------------------------------------------- /src/ExtruderTrain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "ExtruderTrain.h" 5 | 6 | namespace cura 7 | { 8 | 9 | ExtruderTrain::ExtruderTrain(const size_t extruder_nr, Settings* parent_settings) 10 | : extruder_nr_(extruder_nr) 11 | { 12 | settings_.setParent(parent_settings); 13 | } 14 | 15 | } // namespace cura 16 | -------------------------------------------------------------------------------- /src/FffProcessor.cpp: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2021 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "FffProcessor.h" 5 | 6 | namespace cura 7 | { 8 | 9 | FffProcessor FffProcessor::instance; // definition must be in cpp 10 | 11 | bool FffProcessor::setTargetFile(const char* filename) 12 | { 13 | return gcode_writer.setTargetFile(filename); 14 | } 15 | 16 | void FffProcessor::setTargetStream(std::ostream* stream) 17 | { 18 | return gcode_writer.setTargetStream(stream); 19 | } 20 | 21 | double FffProcessor::getTotalFilamentUsed(int extruder_nr) 22 | { 23 | return gcode_writer.getTotalFilamentUsed(extruder_nr); 24 | } 25 | 26 | std::vector FffProcessor::getTotalPrintTimePerFeature() 27 | { 28 | return gcode_writer.getTotalPrintTimePerFeature(); 29 | } 30 | 31 | void FffProcessor::finalize() 32 | { 33 | gcode_writer.finalize(); 34 | } 35 | 36 | } // namespace cura 37 | -------------------------------------------------------------------------------- /src/GCodePathConfig.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "GCodePathConfig.h" 5 | 6 | #include "geometry/Point2LL.h" // INT2MM 7 | 8 | namespace cura 9 | { 10 | 11 | [[nodiscard]] double GCodePathConfig::getExtrusionMM3perMM() const noexcept 12 | { 13 | return extrusion_mm3_per_mm; 14 | } 15 | 16 | [[nodiscard]] Velocity GCodePathConfig::getSpeed() const noexcept 17 | { 18 | return speed_derivatives.speed; 19 | } 20 | 21 | [[nodiscard]] Acceleration GCodePathConfig::getAcceleration() const noexcept 22 | { 23 | return speed_derivatives.acceleration; 24 | } 25 | 26 | [[nodiscard]] Velocity GCodePathConfig::getJerk() const noexcept 27 | { 28 | return speed_derivatives.jerk; 29 | } 30 | 31 | [[nodiscard]] coord_t GCodePathConfig::getLineWidth() const noexcept 32 | { 33 | return line_width; 34 | } 35 | 36 | [[nodiscard]] coord_t GCodePathConfig::getLayerThickness() const noexcept 37 | { 38 | return layer_thickness; 39 | } 40 | 41 | [[nodiscard]] PrintFeatureType GCodePathConfig::getPrintFeatureType() const noexcept 42 | { 43 | return type; 44 | } 45 | 46 | [[nodiscard]] bool GCodePathConfig::isTravelPath() const noexcept 47 | { 48 | return line_width == 0; 49 | } 50 | 51 | [[nodiscard]] bool GCodePathConfig::isBridgePath() const noexcept 52 | { 53 | return is_bridge_path; 54 | } 55 | 56 | [[nodiscard]] double GCodePathConfig::getFanSpeed() const noexcept 57 | { 58 | return fan_speed; 59 | } 60 | 61 | [[nodiscard]] Ratio GCodePathConfig::getFlowRatio() const noexcept 62 | { 63 | return flow; 64 | } 65 | 66 | [[nodiscard]] double GCodePathConfig::calculateExtrusion() const noexcept 67 | { 68 | return INT2MM(line_width) * INT2MM(layer_thickness) * double(flow); 69 | } 70 | 71 | 72 | } // namespace cura 73 | -------------------------------------------------------------------------------- /src/PathAdapter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "PathAdapter.h" 5 | 6 | #include "utils/ExtrusionLine.h" 7 | 8 | namespace cura 9 | { 10 | 11 | template<> 12 | const Point2LL& PathAdapter::pointAt(size_t index) const 13 | { 14 | return path_.junctions_.at(index).p_; 15 | } 16 | 17 | template<> 18 | coord_t PathAdapter::lineWidthAt(size_t index) const 19 | { 20 | return path_.junctions_.at(index).w_; 21 | } 22 | 23 | template<> 24 | const Point2LL& PathAdapter::pointAt(size_t index) const 25 | { 26 | return path_.at(index); 27 | } 28 | 29 | template<> 30 | coord_t PathAdapter::lineWidthAt(size_t /*index*/) const 31 | { 32 | return fixed_line_width_; 33 | } 34 | 35 | } // namespace cura 36 | -------------------------------------------------------------------------------- /src/Slice.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "Slice.h" 5 | 6 | #include 7 | #ifdef SENTRY_URL 8 | #include 9 | #endif 10 | 11 | #include "ExtruderTrain.h" 12 | 13 | namespace cura 14 | { 15 | 16 | Slice::Slice(const size_t num_mesh_groups) 17 | : scene(num_mesh_groups) 18 | { 19 | } 20 | 21 | void Slice::compute() 22 | { 23 | spdlog::info("All settings: {}", scene.getAllSettingsString()); 24 | #ifdef SENTRY_URL 25 | { 26 | sentry_set_tag("cura.machine_name", scene.settings.get("machine_name").c_str()); 27 | } 28 | #endif 29 | 30 | for (std::vector::iterator mesh_group = scene.mesh_groups.begin(); mesh_group != scene.mesh_groups.end(); mesh_group++) 31 | { 32 | scene.current_mesh_group = mesh_group; 33 | for (ExtruderTrain& extruder : scene.extruders) 34 | { 35 | extruder.settings_.setParent(&scene.current_mesh_group->settings); 36 | } 37 | scene.processMeshGroup(*mesh_group); 38 | } 39 | } 40 | 41 | void Slice::reset() 42 | { 43 | scene.extruders.clear(); 44 | scene.mesh_groups.clear(); 45 | scene.settings = Settings(); 46 | } 47 | 48 | } // namespace cura 49 | -------------------------------------------------------------------------------- /src/SupportInfillPart.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "SupportInfillPart.h" 5 | 6 | #include "support.h" 7 | 8 | using namespace cura; 9 | 10 | 11 | SupportInfillPart::SupportInfillPart(const SingleShape& outline, coord_t support_line_width, bool use_fractional_config, int inset_count_to_generate, coord_t custom_line_distance) 12 | : outline_(outline) 13 | , outline_boundary_box_(outline) 14 | , support_line_width_(support_line_width) 15 | , inset_count_to_generate_(inset_count_to_generate) 16 | , custom_line_distance_(custom_line_distance) 17 | , use_fractional_config_(use_fractional_config) 18 | { 19 | infill_area_per_combine_per_density_.clear(); 20 | } 21 | -------------------------------------------------------------------------------- /src/communication/Listener.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #ifdef ARCUS 5 | 6 | #include //To process error codes. 7 | #include 8 | 9 | #include "communication/Listener.h" 10 | 11 | namespace cura 12 | { 13 | 14 | void Listener::stateChanged(Arcus::SocketState) 15 | { 16 | // Do nothing. 17 | } 18 | 19 | void Listener::messageReceived() 20 | { 21 | // Do nothing. 22 | } 23 | 24 | void Listener::error(const Arcus::Error& error) 25 | { 26 | if (error.getErrorCode() == Arcus::ErrorCode::Debug) 27 | { 28 | spdlog::debug("{}", error.getErrorMessage()); 29 | } 30 | else 31 | { 32 | spdlog::error("{}", error.getErrorMessage()); 33 | } 34 | } 35 | 36 | } // namespace cura 37 | 38 | #endif // ARCUS -------------------------------------------------------------------------------- /src/geometry/ClosedPolyline.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/ClosedPolyline.h" 5 | 6 | #include 7 | 8 | #include "geometry/OpenPolyline.h" 9 | 10 | namespace cura 11 | { 12 | 13 | size_t ClosedPolyline::segmentsCount() const 14 | { 15 | if (explicitely_closed_) 16 | { 17 | return size() >= 3 ? size() - 1 : 0; 18 | } 19 | return size() >= 2 ? size() : 0; 20 | } 21 | 22 | bool ClosedPolyline::isValid() const 23 | { 24 | return size() >= (explicitely_closed_ ? 4 : 3); 25 | } 26 | 27 | bool ClosedPolyline::inside(const Point2LL& p, bool border_result) const 28 | { 29 | int res = ClipperLib::PointInPolygon(p, getPoints()); 30 | if (res == -1) 31 | { 32 | return border_result; 33 | } 34 | return res == 1; 35 | } 36 | 37 | bool ClosedPolyline::inside(const ClipperLib::Path& polygon) const 38 | { 39 | return ranges::all_of( 40 | *this, 41 | [&polygon](const auto& point) 42 | { 43 | return ClipperLib::PointInPolygon(point, polygon); 44 | }); 45 | } 46 | 47 | OpenPolyline ClosedPolyline::toPseudoOpenPolyline() const 48 | { 49 | OpenPolyline open_polyline(getPoints()); 50 | if (hasClosingSegment()) 51 | { 52 | open_polyline.push_back(open_polyline.getPoints().front()); 53 | } 54 | return open_polyline; 55 | } 56 | 57 | } // namespace cura 58 | -------------------------------------------------------------------------------- /src/geometry/PartsView.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/PartsView.h" 5 | 6 | #include 7 | #include 8 | 9 | #include "geometry/Polygon.h" 10 | #include "geometry/SingleShape.h" 11 | 12 | namespace cura 13 | { 14 | 15 | size_t PartsView::getPartContaining(size_t poly_idx, size_t* boundary_poly_idx) const 16 | { 17 | const PartsView& partsView = *this; 18 | for (size_t part_idx_now = 0; part_idx_now < partsView.size(); part_idx_now++) 19 | { 20 | const std::vector& partView = partsView[part_idx_now]; 21 | if (partView.size() == 0) 22 | { 23 | continue; 24 | } 25 | std::vector::const_iterator result = std::find(partView.begin(), partView.end(), poly_idx); 26 | if (result != partView.end()) 27 | { 28 | if (boundary_poly_idx) 29 | { 30 | *boundary_poly_idx = partView[0]; 31 | } 32 | return part_idx_now; 33 | } 34 | } 35 | return NO_INDEX; 36 | } 37 | 38 | SingleShape PartsView::assemblePart(size_t part_idx) const 39 | { 40 | const PartsView& partsView = *this; 41 | SingleShape ret; 42 | if (part_idx != NO_INDEX) 43 | { 44 | for (size_t poly_idx_ff : partsView[part_idx]) 45 | { 46 | ret.push_back(polygons_[poly_idx_ff]); 47 | } 48 | } 49 | return ret; 50 | } 51 | 52 | SingleShape PartsView::assemblePartContaining(size_t poly_idx, size_t* boundary_poly_idx) const 53 | { 54 | SingleShape ret; 55 | size_t part_idx = getPartContaining(poly_idx, boundary_poly_idx); 56 | if (part_idx != NO_INDEX) 57 | { 58 | return assemblePart(part_idx); 59 | } 60 | return ret; 61 | } 62 | 63 | } // namespace cura 64 | -------------------------------------------------------------------------------- /src/geometry/Point2LL.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/Point2LL.h" //The headers we're implementing. 5 | 6 | #include "geometry/Point3LL.h" 7 | 8 | namespace cura 9 | { 10 | 11 | Point2LL operator+(const Point2LL& p2, const Point3LL& p3) 12 | { 13 | return { p3.x_ + p2.X, p3.y_ + p2.Y }; 14 | } 15 | 16 | Point3LL operator+(const Point3LL& p3, const Point2LL& p2) 17 | { 18 | return { p3.x_ + p2.X, p3.y_ + p2.Y, p3.z_ }; 19 | } 20 | 21 | Point3LL& operator+=(Point3LL& p3, const Point2LL& p2) 22 | { 23 | p3.x_ += p2.X; 24 | p3.y_ += p2.Y; 25 | return p3; 26 | } 27 | 28 | Point3LL operator-(const Point3LL& p3, const Point2LL& p2) 29 | { 30 | return { p3.x_ - p2.X, p3.y_ - p2.Y, p3.z_ }; 31 | } 32 | 33 | Point3LL& operator-=(Point3LL& p3, const Point2LL& p2) 34 | { 35 | p3.x_ -= p2.X; 36 | p3.y_ -= p2.Y; 37 | return p3; 38 | } 39 | 40 | Point2LL operator-(const Point2LL& p2, const Point3LL& p3) 41 | { 42 | return { p2.X - p3.x_, p2.Y - p3.y_ }; 43 | } 44 | 45 | } // namespace cura 46 | -------------------------------------------------------------------------------- /src/geometry/Point3LL.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/Point3LL.h" //The headers we're implementing. 5 | 6 | namespace cura 7 | { 8 | 9 | Point3LL::Point3LL(const Point2LL& point, const coord_t z) 10 | : x_(point.X) 11 | , y_(point.Y) 12 | , z_(z) 13 | { 14 | } 15 | 16 | Point3LL Point3LL::operator+(const Point3LL& p) const 17 | { 18 | return Point3LL(x_ + p.x_, y_ + p.y_, z_ + p.z_); 19 | } 20 | 21 | Point3LL Point3LL::operator-() const 22 | { 23 | return Point3LL(-x_, -y_, -z_); 24 | } 25 | 26 | Point3LL Point3LL::operator-(const Point3LL& p) const 27 | { 28 | return Point3LL(x_ - p.x_, y_ - p.y_, z_ - p.z_); 29 | } 30 | 31 | Point3LL Point3LL::operator*(const Point3LL& p) const 32 | { 33 | return Point3LL(x_ * p.x_, y_ * p.y_, z_ * p.z_); 34 | } 35 | 36 | Point3LL Point3LL::operator/(const Point3LL& p) const 37 | { 38 | return Point3LL(x_ / p.x_, y_ / p.y_, z_ / p.z_); 39 | } 40 | 41 | Point3LL& Point3LL::operator+=(const Point3LL& p) 42 | { 43 | x_ += p.x_; 44 | y_ += p.y_; 45 | z_ += p.z_; 46 | return *this; 47 | } 48 | 49 | Point3LL& Point3LL::operator-=(const Point3LL& p) 50 | { 51 | x_ -= p.x_; 52 | y_ -= p.y_; 53 | z_ -= p.z_; 54 | return *this; 55 | } 56 | 57 | Point3LL& Point3LL::operator*=(const Point3LL& p) 58 | { 59 | x_ *= p.x_; 60 | y_ *= p.y_; 61 | z_ *= p.z_; 62 | return *this; 63 | } 64 | 65 | Point3LL& Point3LL::operator/=(const Point3LL& p) 66 | { 67 | x_ /= p.x_; 68 | y_ /= p.y_; 69 | z_ /= p.z_; 70 | return *this; 71 | } 72 | 73 | Point2LL Point3LL::toPoint2LL() const 74 | { 75 | return Point2LL(x_, y_); 76 | } 77 | 78 | Point3LL Point3LL::resized(coord_t length) const 79 | { 80 | const coord_t actual_length = vSize(); 81 | if (actual_length < 1) 82 | { 83 | return { length, 0, 0 }; 84 | } 85 | return ((*this) * length) / actual_length; 86 | } 87 | 88 | } // namespace cura 89 | -------------------------------------------------------------------------------- /src/geometry/PointsSet.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/PointsSet.h" 5 | 6 | #include "geometry/Point3Matrix.h" 7 | #include "geometry/PointMatrix.h" 8 | 9 | namespace cura 10 | { 11 | 12 | PointsSet::PointsSet(const std::initializer_list& initializer) 13 | : points_(initializer) 14 | { 15 | } 16 | 17 | PointsSet::PointsSet(const ClipperLib::Path& points) 18 | : points_(points) 19 | { 20 | } 21 | 22 | PointsSet::PointsSet(ClipperLib::Path&& points) 23 | : points_(std::move(points)) 24 | { 25 | } 26 | 27 | void PointsSet::applyMatrix(const PointMatrix& matrix) 28 | { 29 | for (Point2LL& point : points_) 30 | { 31 | point = matrix.apply(point); 32 | } 33 | } 34 | 35 | void PointsSet::applyMatrix(const Point3Matrix& matrix) 36 | { 37 | for (Point2LL& point : points_) 38 | { 39 | point = matrix.apply(point); 40 | } 41 | } 42 | 43 | void PointsSet::translate(const Point2LL& translation) 44 | { 45 | for (Point2LL& point : points_) 46 | { 47 | point += translation; 48 | } 49 | } 50 | 51 | } // namespace cura 52 | -------------------------------------------------------------------------------- /src/geometry/SingleShape.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "geometry/SingleShape.h" 5 | 6 | #include "geometry/Polygon.h" 7 | 8 | namespace cura 9 | { 10 | 11 | bool SingleShape::inside(const Point2LL& p, bool border_result) const 12 | { 13 | if (size() < 1) 14 | { 15 | return false; 16 | } 17 | 18 | if (! (*this)[0].inside(p, border_result)) 19 | { 20 | return false; 21 | } 22 | 23 | for (unsigned int n = 1; n < size(); n++) 24 | { 25 | if ((*this)[n].inside(p, border_result)) 26 | { 27 | return false; 28 | } 29 | } 30 | return true; 31 | } 32 | 33 | Polygon& SingleShape::outerPolygon() 34 | { 35 | return front(); 36 | } 37 | 38 | const Polygon& SingleShape::outerPolygon() const 39 | { 40 | return front(); 41 | } 42 | 43 | } // namespace cura 44 | -------------------------------------------------------------------------------- /src/infill/NoZigZagConnectorProcessor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "infill/NoZigZagConnectorProcessor.h" 5 | 6 | #include "utils/macros.h" 7 | 8 | 9 | namespace cura 10 | { 11 | 12 | void NoZigZagConnectorProcessor::registerVertex(const Point2LL&) 13 | { 14 | // No need to add anything. 15 | } 16 | 17 | void NoZigZagConnectorProcessor::registerScanlineSegmentIntersection(const Point2LL&, int, coord_t) 18 | { 19 | // No need to add anything. 20 | } 21 | 22 | void NoZigZagConnectorProcessor::registerPolyFinished() 23 | { 24 | // No need to add anything. 25 | } 26 | 27 | } // namespace cura 28 | -------------------------------------------------------------------------------- /src/pathPlanning/GCodePath.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "pathPlanning/GCodePath.h" 5 | 6 | namespace cura 7 | { 8 | 9 | [[nodiscard]] bool GCodePath::isTravelPath() const noexcept 10 | { 11 | return config.isTravelPath(); 12 | } 13 | 14 | [[nodiscard]] double GCodePath::getExtrusionMM3perMM() const noexcept 15 | { 16 | return flow * width_factor * config.getExtrusionMM3perMM(); 17 | } 18 | 19 | [[nodiscard]] coord_t GCodePath::getLineWidthForLayerView() const noexcept 20 | { 21 | return static_cast(flow * width_factor * static_cast(config.getLineWidth()) * config.getFlowRatio()); 22 | } 23 | 24 | void GCodePath::setFanSpeed(const double fanspeed) noexcept 25 | { 26 | fan_speed = fanspeed; 27 | } 28 | 29 | [[nodiscard]] double GCodePath::getFanSpeed() const noexcept 30 | { 31 | return (fan_speed >= 0 && fan_speed <= 100) ? fan_speed : config.getFanSpeed(); 32 | } 33 | 34 | } // namespace cura 35 | -------------------------------------------------------------------------------- /src/pathPlanning/NozzleTempInsert.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "gcodeExport.h" 5 | #include "pathPlanning/NozzleTempInsert.h" 6 | 7 | namespace cura 8 | { 9 | 10 | void NozzleTempInsert::write(GCodeExport& gcode) 11 | { 12 | gcode.writeTemperatureCommand(extruder, temperature, wait); 13 | } 14 | 15 | } // namespace cura -------------------------------------------------------------------------------- /src/pathPlanning/SpeedDerivatives.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "pathPlanning/SpeedDerivatives.h" 5 | 6 | namespace cura 7 | { 8 | 9 | void SpeedDerivatives::smoothSpeed(const SpeedDerivatives& first_layer_config, const LayerIndex layer_nr, const LayerIndex max_speed_layer_nr) 10 | { 11 | const auto max_speed_layer = static_cast(max_speed_layer_nr); 12 | const auto first_layer_speed = std::min(speed, first_layer_config.speed); 13 | const auto first_layer_acceleration = std::min(acceleration, first_layer_config.acceleration); 14 | const auto first_layer_jerk = std::min(jerk, first_layer_config.jerk); 15 | speed = (speed * static_cast(layer_nr)) / max_speed_layer + (first_layer_speed * (max_speed_layer - static_cast(layer_nr)) / max_speed_layer); 16 | acceleration 17 | = (acceleration * static_cast(layer_nr)) / max_speed_layer + (first_layer_acceleration * (max_speed_layer - static_cast(layer_nr)) / max_speed_layer); 18 | jerk = (jerk * static_cast(layer_nr)) / max_speed_layer + (first_layer_jerk * (max_speed_layer - static_cast(layer_nr)) / max_speed_layer); 19 | } 20 | 21 | } // namespace cura -------------------------------------------------------------------------------- /src/path_ordering.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "path_ordering.h" //The definitions we're implementing here. 5 | 6 | #include "WallToolPaths.h" 7 | #include "geometry/OpenPolyline.h" 8 | #include "sliceDataStorage.h" //For SliceLayerPart. 9 | 10 | namespace cura 11 | { 12 | 13 | template 14 | const PointsSet& PathOrdering::getVertexData() 15 | { 16 | return *vertices_; 17 | } 18 | 19 | template<> 20 | const PointsSet& PathOrdering::getVertexData() 21 | { 22 | return vertices_->outline.outerPolygon(); 23 | } 24 | 25 | template<> 26 | const PointsSet& PathOrdering::getVertexData() 27 | { 28 | return vertices_->outline.outerPolygon(); 29 | } 30 | 31 | template<> 32 | const PointsSet& PathOrdering::getVertexData() 33 | { 34 | return vertices_->outline.outerPolygon(); 35 | } 36 | 37 | template<> 38 | const PointsSet& PathOrdering::getVertexData() 39 | { 40 | return vertices_->outline_.outerPolygon(); 41 | } 42 | template<> 43 | const PointsSet& PathOrdering::getVertexData() 44 | { 45 | if (! cached_vertices_) 46 | { 47 | cached_vertices_ = vertices_->toPolygon(); 48 | } 49 | return *cached_vertices_; 50 | } 51 | 52 | template const PointsSet& PathOrdering::getVertexData(); 53 | template const PointsSet& PathOrdering::getVertexData(); 54 | template const PointsSet& PathOrdering::getVertexData(); 55 | template const PointsSet& PathOrdering::getVertexData(); 56 | template const PointsSet& PathOrdering::getVertexData(); 57 | template const PointsSet& PathOrdering::getVertexData(); 58 | 59 | } // namespace cura 60 | -------------------------------------------------------------------------------- /src/progress/ProgressStageEstimator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "progress/ProgressStageEstimator.h" 5 | 6 | 7 | namespace cura 8 | { 9 | 10 | 11 | ProgressStageEstimator::ProgressStageEstimator(std::vector& relative_time_estimates) 12 | : total_estimated_time_(0) 13 | , accumulated_estimate_(0) 14 | , current_stage_idx_(-1) 15 | { 16 | stages_.reserve(relative_time_estimates.size()); 17 | for (double relative_estimated_time : relative_time_estimates) 18 | { 19 | stages_.emplace_back(relative_estimated_time); 20 | total_estimated_time_ += relative_estimated_time; 21 | } 22 | } 23 | 24 | ProgressStageEstimator::~ProgressStageEstimator() 25 | { 26 | for (ProgressStage& stage : stages_) 27 | { 28 | delete stage.stage_; 29 | } 30 | } 31 | 32 | double ProgressStageEstimator::progress(int current_step) 33 | { 34 | ProgressStage& current_stage = stages_[current_stage_idx_]; 35 | return (accumulated_estimate_ + current_stage.stage_->progress(current_step) * current_stage.relative_estimated_time_) / total_estimated_time_; 36 | } 37 | 38 | void ProgressStageEstimator::nextStage(ProgressEstimator* stage) 39 | { 40 | if (current_stage_idx_ >= int(stages_.size()) - 1) 41 | { 42 | return; 43 | } 44 | if (current_stage_idx_ >= 0) 45 | { 46 | ProgressStage& current_stage = stages_[current_stage_idx_]; 47 | accumulated_estimate_ += current_stage.relative_estimated_time_; 48 | } 49 | current_stage_idx_++; 50 | stages_[current_stage_idx_].stage_ = stage; 51 | } 52 | 53 | 54 | } // namespace cura 55 | -------------------------------------------------------------------------------- /src/settings/FlowTempGraph.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | #include "settings/FlowTempGraph.h" 5 | 6 | #include 7 | 8 | namespace cura 9 | { 10 | 11 | double FlowTempGraph::getTemp(const double flow, const Temperature material_print_temperature, const bool flow_dependent_temperature) const 12 | { 13 | if (! flow_dependent_temperature || data_.size() == 0) 14 | { 15 | return material_print_temperature; 16 | } 17 | if (data_.size() == 1) 18 | { 19 | return data_.front().temp_; 20 | } 21 | if (flow < data_.front().flow_) 22 | { 23 | spdlog::warn("Warning! Flow too low!"); 24 | return data_.front().temp_; 25 | } 26 | const Datum* last_datum = &data_.front(); 27 | for (unsigned int datum_idx = 1; datum_idx < data_.size(); datum_idx++) 28 | { 29 | const Datum& datum = data_[datum_idx]; 30 | if (datum.flow_ >= flow) 31 | { 32 | return last_datum->temp_ + Temperature((datum.temp_ - last_datum->temp_) * (flow - last_datum->flow_) / (datum.flow_ - last_datum->flow_)); 33 | } 34 | last_datum = &datum; 35 | } 36 | 37 | spdlog::warn("Warning! Flow too high!"); 38 | return data_.back().temp_; 39 | } 40 | 41 | } // namespace cura 42 | -------------------------------------------------------------------------------- /src/settings/ZSeamConfig.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "settings/ZSeamConfig.h" //The definitions we're implementing. 5 | 6 | namespace cura 7 | { 8 | 9 | ZSeamConfig::ZSeamConfig(const EZSeamType type, const Point2LL pos, const EZSeamCornerPrefType corner_pref, const coord_t simplify_curvature) 10 | : type_(type) 11 | , pos_(pos) 12 | , corner_pref_(corner_pref) 13 | , simplify_curvature_(simplify_curvature) 14 | { 15 | } 16 | 17 | } // namespace cura 18 | -------------------------------------------------------------------------------- /src/utils/Date.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/Date.h" 5 | 6 | #include // sscanf 7 | #include // strstr 8 | #include // setw, setfill 9 | #include 10 | 11 | namespace cura 12 | { 13 | 14 | Date::Date(int year, int month, int day) 15 | : year_(year) 16 | , month_(month) 17 | , day_(day) 18 | { 19 | } 20 | 21 | std::string Date::toStringDashed() 22 | { 23 | std::ostringstream str; 24 | str << std::setfill('0') << std::setw(4) << year_ << "-" << std::setfill('0') << std::setw(2) << month_ << "-" << std::setfill('0') << std::setw(2) << day_; 25 | return str.str(); 26 | } 27 | 28 | Date::Date() 29 | : year_(-1) 30 | , month_(-1) 31 | , day_(-1) 32 | { 33 | } 34 | 35 | Date Date::getDate() 36 | { 37 | Date ret; 38 | // code adapted from http://stackoverflow.com/a/1765088/2683223 Jerry Coffin 39 | const char* build_date = __DATE__; 40 | char s_month[5]; 41 | static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; 42 | 43 | std::sscanf(build_date, "%s %d %d", s_month, &ret.day_, &ret.year_); 44 | 45 | ret.month_ = (strstr(month_names, s_month) - month_names) / 3; 46 | 47 | ret.month_++; // humans count Jan as month 1, not zero 48 | return ret; 49 | } 50 | 51 | 52 | } // namespace cura 53 | -------------------------------------------------------------------------------- /src/utils/ExtrusionJunction.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/ExtrusionJunction.h" 5 | 6 | namespace cura 7 | { 8 | 9 | bool ExtrusionJunction::operator==(const ExtrusionJunction& other) const 10 | { 11 | return p_ == other.p_ && w_ == other.w_ && perimeter_index_ == other.perimeter_index_; 12 | } 13 | 14 | ExtrusionJunction::ExtrusionJunction(const Point2LL p, const coord_t w, const coord_t perimeter_index) 15 | : p_(p) 16 | , w_(w) 17 | , perimeter_index_(perimeter_index) 18 | { 19 | } 20 | 21 | } // namespace cura 22 | -------------------------------------------------------------------------------- /src/utils/ExtrusionLine.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/ExtrusionLine.h" 5 | 6 | #include 7 | 8 | #include "utils/Simplify.h" 9 | #include "utils/linearAlg2D.h" 10 | 11 | namespace cura 12 | { 13 | 14 | 15 | coord_t ExtrusionLine::length() const 16 | { 17 | if (junctions_.empty()) 18 | { 19 | return 0; 20 | } 21 | coord_t len = 0; 22 | ExtrusionJunction prev = junctions_.front(); 23 | for (const ExtrusionJunction& next : junctions_) 24 | { 25 | len += vSize(next.p_ - prev.p_); 26 | prev = next; 27 | } 28 | if (is_closed_) 29 | { 30 | len += vSize(front().p_ - back().p_); 31 | } 32 | return len; 33 | } 34 | 35 | coord_t ExtrusionLine::getMinimalWidth() const 36 | { 37 | return std::min_element( 38 | junctions_.cbegin(), 39 | junctions_.cend(), 40 | [](const ExtrusionJunction& l, const ExtrusionJunction& r) 41 | { 42 | return l.w_ < r.w_; 43 | }) 44 | ->w_; 45 | } 46 | 47 | bool ExtrusionLine::shorterThan(const coord_t check_length) const 48 | { 49 | const ExtrusionJunction* p0 = &back(); 50 | int64_t length = 0; 51 | for (const ExtrusionJunction& p1 : (*this)) 52 | { 53 | length += vSize(*p0 - p1); 54 | if (length >= check_length) 55 | { 56 | return false; 57 | } 58 | p0 = &p1; 59 | } 60 | return true; 61 | } 62 | 63 | } // namespace cura 64 | -------------------------------------------------------------------------------- /src/utils/ListPolyIt.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/ListPolyIt.h" 5 | 6 | #include 7 | #include // isfinite 8 | #include // ostream 9 | 10 | #include "geometry/Polygon.h" 11 | #include "utils/AABB.h" // for debug output svg html 12 | #include "utils/SVG.h" 13 | 14 | namespace cura 15 | { 16 | 17 | 18 | void ListPolyIt::convertPolygonsToLists(const Shape& shape, ListPolygons& result) 19 | { 20 | for (const Polygon& poly : shape) 21 | { 22 | result.emplace_back(); 23 | convertPolygonToList(poly, result.back()); 24 | } 25 | } 26 | 27 | void ListPolyIt::convertPolygonToList(const Polygon& poly, ListPolygon& result) 28 | { 29 | #ifdef DEBUG 30 | Point2LL last = poly.back(); 31 | #endif // DEBUG 32 | for (const Point2LL& p : poly) 33 | { 34 | result.push_back(p); 35 | #ifdef DEBUG 36 | // usually polygons shouldn't have such degenerate verts. It is 37 | // required to not have degenerate verts, because verts are mapped 38 | // to links, but if two different verts are at the same place the mapping fails. 39 | assert(p != last); 40 | last = p; 41 | #endif // DEBUG 42 | } 43 | } 44 | 45 | 46 | void ListPolyIt::convertListPolygonsToPolygons(const ListPolygons& list_polygons, Shape& polygons) 47 | { 48 | for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++) 49 | { 50 | polygons[poly_idx].clear(); 51 | convertListPolygonToPolygon(list_polygons[poly_idx], polygons[poly_idx]); 52 | } 53 | } 54 | 55 | void ListPolyIt::convertListPolygonToPolygon(const ListPolygon& list_polygon, Polygon& polygon) 56 | { 57 | for (const Point2LL& p : list_polygon) 58 | { 59 | polygon.push_back(p); 60 | } 61 | } 62 | 63 | ListPolyIt ListPolyIt::insertPointNonDuplicate(const ListPolyIt before, const ListPolyIt after, const Point2LL to_insert) 64 | { 65 | if (to_insert == before.p()) 66 | { 67 | return before; 68 | } 69 | else if (to_insert == after.p()) 70 | { 71 | return after; 72 | } 73 | else 74 | { 75 | ListPolygon& poly = *after.poly_; 76 | return ListPolyIt(poly, poly.insert(after.it_, to_insert)); 77 | } 78 | } 79 | 80 | 81 | } // namespace cura 82 | -------------------------------------------------------------------------------- /src/utils/Matrix4x3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/Matrix4x3D.h" //The definitions we're implementing. 5 | 6 | #include "geometry/Point2LL.h" //Conversion directly into integer-based coordinates. 7 | #include "settings/types/Ratio.h" //Scale factor. 8 | #include "utils/Point3D.h" //This matrix gets applied to floating point coordinates. 9 | 10 | namespace cura 11 | { 12 | 13 | Matrix4x3D Matrix4x3D::scale(const Ratio scale, const Point3LL origin) 14 | { 15 | return Matrix4x3D::scale(scale, scale, scale, origin); 16 | } 17 | 18 | Matrix4x3D Matrix4x3D::scale(const Ratio scale_x, const Ratio scale_y, const Ratio scale_z, const Point3LL origin) 19 | { 20 | Matrix4x3D result; 21 | result.m[0][0] = scale_x; // X scale. 22 | result.m[1][1] = scale_y; // Y scale. 23 | result.m[2][2] = scale_z; // Z scale. 24 | 25 | // Apply a transformation to scale it away from the origin. 26 | result.m[3][0] = (scale_x - 1.0) * -origin.x_; // Arrived at by manually applying an inverse move, the scale, then a move. 27 | result.m[3][1] = (scale_y - 1.0) * -origin.y_; 28 | result.m[3][2] = (scale_z - 1.0) * -origin.z_; 29 | 30 | return result; 31 | } 32 | 33 | Matrix4x3D::Matrix4x3D() 34 | { 35 | m[0][0] = 1.0; 36 | m[1][0] = 0.0; 37 | m[2][0] = 0.0; 38 | m[3][0] = 0.0; 39 | m[0][1] = 0.0; 40 | m[1][1] = 1.0; 41 | m[2][1] = 0.0; 42 | m[3][1] = 0.0; 43 | m[0][2] = 0.0; 44 | m[1][2] = 0.0; 45 | m[2][2] = 1.0; 46 | m[3][2] = 0.0; 47 | } 48 | 49 | Point3LL Matrix4x3D::apply(const Point3D& p) const 50 | { 51 | return Point3LL( 52 | MM2INT(p.x_ * m[0][0] + p.y_ * m[1][0] + p.z_ * m[2][0] + m[3][0]), 53 | MM2INT(p.x_ * m[0][1] + p.y_ * m[1][1] + p.z_ * m[2][1] + m[3][1]), 54 | MM2INT(p.x_ * m[0][2] + p.y_ * m[1][2] + p.z_ * m[2][2] + m[3][2])); 55 | } 56 | 57 | Point3LL Matrix4x3D::apply(const Point3LL& p) const 58 | { 59 | return Point3LL( 60 | m[0][0] * p.x_ + m[1][0] * p.y_ + m[2][0] * p.z_ + m[3][0], 61 | m[0][1] * p.x_ + m[1][1] * p.y_ + m[2][1] * p.z_ + m[3][1], 62 | m[0][2] * p.x_ + m[1][2] * p.y_ + m[2][2] * p.z_ + m[3][2]); 63 | } 64 | 65 | } // namespace cura 66 | -------------------------------------------------------------------------------- /src/utils/MixedPolylineStitcher.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/MixedPolylineStitcher.h" 5 | 6 | #include "geometry/MixedLinesSet.h" 7 | #include "geometry/OpenPolyline.h" 8 | #include "geometry/Polygon.h" 9 | #include "geometry/Shape.h" 10 | 11 | 12 | namespace cura 13 | { 14 | 15 | void MixedPolylineStitcher::stitch(const OpenLinesSet& lines, MixedLinesSet& result, coord_t max_stitch_distance, coord_t snap_distance) 16 | { 17 | OpenLinesSet open_lines; 18 | ClosedLinesSet closed_lines; 19 | 20 | PolylineStitcher::stitch(lines, open_lines, closed_lines, max_stitch_distance, snap_distance); 21 | 22 | result.push_back(std::move(open_lines)); 23 | 24 | for (ClosedPolyline& closed_line : closed_lines) 25 | { 26 | // Base stitch method will create explicitely closed polylines, but won't tag them as such 27 | // because it is a generic algorithm. Tag them now. 28 | closed_line.setExplicitelyClosed(true); 29 | } 30 | 31 | result.push_back(std::move(closed_lines)); 32 | } 33 | 34 | } // namespace cura 35 | -------------------------------------------------------------------------------- /src/utils/PolygonsPointIndex.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/PolygonsPointIndex.h" 5 | 6 | #include "geometry/Shape.h" 7 | 8 | namespace cura 9 | { 10 | 11 | template<> 12 | const Polygon& PathsPointIndex::getPolygon() const 13 | { 14 | return (*polygons_)[poly_idx_]; 15 | } 16 | 17 | std::pair PolygonsPointIndexSegmentLocator::operator()(const PolygonsPointIndex& val) const 18 | { 19 | const Polygon& poly = (*val.polygons_)[val.poly_idx_]; 20 | Point2LL start = poly[val.point_idx_]; 21 | size_t next_point_idx = (val.point_idx_ + 1ul) % poly.size(); 22 | Point2LL end = poly[next_point_idx]; 23 | return std::pair(start, end); 24 | } 25 | 26 | } // namespace cura 27 | -------------------------------------------------------------------------------- /src/utils/PolygonsSegmentIndex.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/PolygonsSegmentIndex.h" 5 | 6 | namespace cura 7 | { 8 | 9 | PolygonsSegmentIndex::PolygonsSegmentIndex() 10 | : PolygonsPointIndex() 11 | { 12 | } 13 | 14 | PolygonsSegmentIndex::PolygonsSegmentIndex(const Shape* polygons, unsigned int poly_idx, unsigned int point_idx) 15 | : PolygonsPointIndex(polygons, poly_idx, point_idx) 16 | { 17 | } 18 | 19 | Point2LL PolygonsSegmentIndex::from() const 20 | { 21 | return PolygonsPointIndex::p(); 22 | } 23 | 24 | Point2LL PolygonsSegmentIndex::to() const 25 | { 26 | return PolygonsSegmentIndex::next().p(); 27 | } 28 | 29 | } // namespace cura 30 | -------------------------------------------------------------------------------- /src/utils/ThreadPool.cpp: -------------------------------------------------------------------------------- 1 | //Copyright (c) 2022 Ultimaker B.V. 2 | //CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/ThreadPool.h" 5 | 6 | namespace cura 7 | { 8 | 9 | ThreadPool::ThreadPool(size_t nthreads) 10 | : wait_for_new_tasks(true) 11 | { 12 | for (size_t i = 0 ; i < nthreads; i++) 13 | { 14 | threads.emplace_back(&ThreadPool::worker, this); 15 | } 16 | } 17 | 18 | void ThreadPool::worker() 19 | { 20 | lock_t lock = get_lock(); 21 | work_while(lock, [this, &lock]() 22 | { 23 | while(tasks.empty() && wait_for_new_tasks) 24 | { // Wait for a task. Signaled by ThreadPool::push() and ThreadPool::join() 25 | condition.wait(lock); 26 | } 27 | // Returns false if the queue is empty and the pool is being disposed 28 | return !tasks.empty() || wait_for_new_tasks; 29 | }); 30 | } 31 | 32 | void ThreadPool::join() 33 | { 34 | { // Joinning thread becomes a worker while there is remaining tasks 35 | lock_t lock = get_lock(); 36 | wait_for_new_tasks = false; 37 | condition.notify_all(); 38 | work_while(lock, []{ return true; }); 39 | } 40 | assert(tasks.empty()); 41 | for (auto& thread : threads) 42 | { 43 | thread.join(); 44 | } 45 | threads.clear(); 46 | } 47 | 48 | } //Cura namespace. 49 | -------------------------------------------------------------------------------- /src/utils/channel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | #ifdef ENABLE_PLUGINS 4 | 5 | #include "utils/channel.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "utils/resources/certificate.pem.h" 11 | 12 | namespace cura::utils 13 | { 14 | namespace details 15 | { 16 | inline constexpr static bool ALLOW_REMOTE_CHANNELS = ENABLE_REMOTE_PLUGINS; 17 | } // namespace details 18 | 19 | std::shared_ptr createChannel(const ChannelSetupConfiguration& config) 20 | { 21 | constexpr auto create_credentials = [](const ChannelSetupConfiguration& actual_config) 22 | { 23 | if (actual_config.host == "localhost" || actual_config.host == "127.0.0.1") 24 | { 25 | spdlog::info("Create local channel on port {}.", actual_config.port); 26 | return grpc::InsecureChannelCredentials(); 27 | } 28 | if (details::ALLOW_REMOTE_CHANNELS) 29 | { 30 | spdlog::info("Create local channel on port {}.", actual_config.port); 31 | auto creds_config = grpc::SslCredentialsOptions(); 32 | creds_config.pem_root_certs = resources::certificate; 33 | return grpc::SslCredentials(creds_config); 34 | } 35 | // Create empty credentials, so it'll make a dummy channel where all operations fail. 36 | // This is consistent with creating a channel with the wrong credentials as it where. 37 | spdlog::warn("Remote plugins where disabled, will not connect to {}:{}.", actual_config.host, actual_config.port); 38 | return std::shared_ptr(); 39 | }; 40 | grpc::ChannelArguments args; 41 | args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, 200 * 1000 /*200 sec*/); 42 | args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 100 * 1000 /*100 sec*/); 43 | args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); 44 | 45 | return grpc::CreateCustomChannel(fmt::format("{}:{}", config.host, config.port), create_credentials(config), args); 46 | } 47 | 48 | } // namespace cura::utils 49 | 50 | #endif // ENABLE_PLUGINS -------------------------------------------------------------------------------- /src/utils/gettime.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/gettime.h" 5 | 6 | #include 7 | 8 | namespace cura 9 | { 10 | 11 | TimeKeeper::TimeKeeper() 12 | { 13 | } 14 | 15 | double TimeKeeper::restart() 16 | { 17 | double ret = watch.elapsed().count(); 18 | watch.reset(); 19 | return ret; 20 | } 21 | 22 | void TimeKeeper::registerTime(const std::string& stage, double threshold) 23 | { 24 | double duration = restart(); 25 | if (duration >= threshold) 26 | { 27 | registered_times.emplace_back(RegisteredTime{ stage, duration }); 28 | } 29 | } 30 | 31 | } // namespace cura 32 | -------------------------------------------------------------------------------- /src/utils/scoring/DistanceScoringCriterion.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/scoring/DistanceScoringCriterion.h" 5 | 6 | #include "geometry/PointsSet.h" 7 | 8 | 9 | namespace cura 10 | { 11 | 12 | DistanceScoringCriterion::DistanceScoringCriterion(const PointsSet& points, const Point2LL& target_pos, DistanceType distance_type, const double distance_divider) 13 | : points_(points) 14 | , target_pos_(target_pos) 15 | , distance_type_(distance_type) 16 | , distance_divider_(distance_divider) 17 | { 18 | } 19 | 20 | double DistanceScoringCriterion::computeScore(const size_t candidate_index) const 21 | { 22 | const Point2LL& candidate_position = points_.at(candidate_index); 23 | 24 | double distance = 0.0; 25 | switch (distance_type_) 26 | { 27 | case DistanceType::Euclidian: 28 | // Use actual (non-squared) distance to ensure a proper scoring distribution 29 | distance = vSizeMM(candidate_position - target_pos_); 30 | break; 31 | case DistanceType::XOnly: 32 | distance = INT2MM(std::abs(candidate_position.X - target_pos_.X)); 33 | break; 34 | case DistanceType::YOnly: 35 | distance = INT2MM(std::abs(candidate_position.Y - target_pos_.Y)); 36 | break; 37 | } 38 | 39 | // Use reciprocal function to normalize distance score decreasingly 40 | return 1.0 / (1.0 + (distance / distance_divider_)); 41 | } 42 | 43 | } // namespace cura 44 | -------------------------------------------------------------------------------- /src/utils/scoring/ExclusionAreaScoringCriterion.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/scoring/ExclusionAreaScoringCriterion.h" 5 | 6 | #include "geometry/Shape.h" 7 | 8 | 9 | namespace cura 10 | { 11 | 12 | ExclusionAreaScoringCriterion::ExclusionAreaScoringCriterion(const PointsSet& points, const Shape& exclusion_area) 13 | : points_(points) 14 | , exclusion_area_(exclusion_area) 15 | { 16 | } 17 | 18 | double ExclusionAreaScoringCriterion::computeScore(const size_t candidate_index) const 19 | { 20 | const Point2LL& candidate_position = points_.at(candidate_index); 21 | return exclusion_area_.inside(candidate_position, true) ? 0.0 : 1.0; 22 | } 23 | 24 | } // namespace cura 25 | -------------------------------------------------------------------------------- /src/utils/scoring/RandomScoringCriterion.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "utils/scoring/RandomScoringCriterion.h" 5 | 6 | #include "utils/math.h" 7 | 8 | namespace cura 9 | { 10 | 11 | RandomScoringCriterion::RandomScoringCriterion() 12 | { 13 | } 14 | 15 | double RandomScoringCriterion::computeScore(const size_t /*candidate_index*/) const 16 | { 17 | return cura::randf(); 18 | } 19 | 20 | } // namespace cura 21 | -------------------------------------------------------------------------------- /stress_benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Ultimaker B.V. 2 | # CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | message(STATUS "Building stress benchmarks...") 5 | 6 | find_package(docopt REQUIRED) 7 | 8 | add_executable(stress_benchmark stress_benchmark.cpp) 9 | target_link_libraries(stress_benchmark PRIVATE _CuraEngine test_helpers spdlog::spdlog boost::boost rapidjson docopt_s) 10 | target_include_directories(stress_benchmark PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/generated) -------------------------------------------------------------------------------- /stress_benchmark/resources/006.wkt: -------------------------------------------------------------------------------- 1 | MultiPolygon (((147845 114697, 79916 114698, 79356 114263, 78887 113180, 78804 112804, 78579 111059, 78578 108942, 78804 107197, 78886 106821, 79356 105737, 79916 105303, 147845 105302))) -------------------------------------------------------------------------------- /stress_benchmark/resources/009.wkt: -------------------------------------------------------------------------------- 1 | MultiPolygon (((273309 86663, 273171 86933, 272905 87016, 272763 86930, 273101 86650))) -------------------------------------------------------------------------------- /stress_benchmark/resources/021.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((177889 97484, 178963 98582, 180026 99763, 180835 100714, 181606 101663, 182372 102644, 183111 103632, 184234 105213, 185288 106773, 186272 108309, 187170 109769, 187982 111152, 188762 112509, 189519 113859, 190270 115255, 191531 117669, 192150 118889, 193358 121356, 194528 123828, 195895 126814, 197454 130332, 198899 133686, 200251 136869, 205262 148813, 205263 148813, 206731 152368, 207615 154523, 207611 154523, 208479 156683, 209333 158837, 210354 161475, 211358 164120, 211354 164120, 212161 166302, 212968 168534, 212969 168534, 213765 170805, 214523 173044, 215185 175067, 215833 177127, 215832 177127, 216457 179201, 216758 180244, 217210 181869, 217645 183572, 217732 183641, 216888 183642, 216039 180958, 216037 180958, 215295 178759, 214559 176689, 213973 175123, 213976 175123, 212957 172524, 212152 170566, 211007 167889, 210055 165766, 209043 163584, 209043 163583, 208353 162136, 207638 160682, 206851 159120, 206096 157649, 205317 156171, 204522 154697, 203658 153135, 202830 151673, 201988 150218, 201170 148839, 201171 148835, 200224 147282, 199355 145876, 198480 144500, 197601 143142, 197601 143137, 196662 141720, 195778 140404, 194894 139113, 193951 137760, 192173 135264, 190405 132851, 188670 130540, 186962 128316, 185285 126175, 184437 125114, 182004 122112, 180485 120275, 178163 117529, 176687 115821, 174583 113427, 174575 113418, 173219 111904, 171262 109756, 176562 96208, 177889 97484)), ((165739 91654, 166407 91847, 167042 92164, 167767 92713, 168311 93433, 168630 94069, 168819 94740, 168884 95485, 168820 96215, 168627 96882, 168311 97517, 167760 98243, 167042 98786, 166404 99107, 165729 99295, 164988 99360, 164257 99296, 163595 99107, 162957 98786, 162232 98237, 161688 97517, 161368 96878, 161179 96203, 161115 95476, 161181 94728, 161372 94068, 161688 93433, 162239 92707, 162957 92164, 163595 91843, 164269 91655, 165012 91590, 165739 91654)), ((152763 77567, 153342 77793, 153935 78164, 154617 78773, 155288 79483, 156009 80374, 156587 81138, 157597 82505, 157599 82503, 158151 83231, 158857 84102, 159658 85013, 154573 90610, 153522 88778, 152886 87503, 152885 87503, 152401 86408, 151993 85342, 151662 84348, 151392 83334, 151182 82322, 151036 81240, 151016 80221, 151077 79444, 151231 78706, 151548 78004, 151815 77707, 152185 77540, 152763 77567))) -------------------------------------------------------------------------------- /stress_benchmark/resources/023.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((-30982 -26911, -30986 -25821, -30913 -25649, -39879 -25649, -40000 -25817, -40000 -26973, -31031 -26973, -30982 -26911)), ((39999 -25822, 39884 -25651, 31226 -25649, 31272 -25829, 31272 -26970, 39999 -26973, 39999 -25822))) -------------------------------------------------------------------------------- /stress_benchmark/resources/027.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((165176 119605, 165191 119612, 165809 119528, 165814 119526, 166113 119374, 165603 119864, 165598 119875, 165593 120336, 165253 120350, 165240 120359, 165003 120937, 165002 120942, 164985 121273, 164816 120588, 164809 120579, 164413 120346, 164568 120044, 164567 120028, 164186 119536, 164182 119532, 163901 119349, 164580 119545, 164591 119544, 164992 119317, 165176 119605))) -------------------------------------------------------------------------------- /stress_benchmark/resources/035.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((105538 100642, 105460 100865, 105332 100671, 105324 100395, 105538 100642))) -------------------------------------------------------------------------------- /stress_benchmark/resources/042.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((179969 66896, 100031 66896, 100000 66756, 180000 66755, 179969 66896))) -------------------------------------------------------------------------------- /stress_benchmark/resources/043.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((116557 108997, 116571 109003, 116623 108979, 116612 109036, 116622 109048, 116681 109050, 116647 109098, 116650 109113, 116701 109140, 116651 109165, 116647 109180, 116682 109228, 116623 109230, 116613 109242, 116624 109299, 116571 109275, 116557 109281, 116542 109339, 116505 109295, 116489 109295, 116453 109339, 116437 109282, 116423 109276, 116369 109299, 116380 109243, 116370 109231, 116311 109229, 116347 109181, 116343 109166, 116291 109140, 116344 109113, 116347 109098, 116311 109050, 116370 109048, 116380 109036, 116369 108980, 116423 109003, 116437 108997, 116452 108940, 116489 108984, 116505 108984, 116541 108940, 116557 108997))) -------------------------------------------------------------------------------- /stress_benchmark/resources/046.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((110044 85277, 110072 85286, 110079 85299, 110063 85329, 110019 85734, 109934 85891, 109885 86013, 109904 86228, 109784 86283, 109721 86258, 109628 86250, 109536 86203, 109391 86107, 109325 86033, 109323 86000, 109285 85941, 109308 85859, 109612 85364, 109753 85277, 109893 85263, 110004 85229, 110044 85277))) -------------------------------------------------------------------------------- /stress_benchmark/resources/047.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((106032 105050, 106062 105402, 105490 106002, 105085 106091, 104982 105403, 105068 105298, 105825 104922, 106032 105050))) -------------------------------------------------------------------------------- /stress_benchmark/resources/049.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((117969 83306, 118266 83540, 118465 83841, 118650 84265, 118676 84997, 118624 85323, 118493 85579, 118125 86063, 117970 86152, 117516 86283, 117283 86263, 117053 86172, 116697 85881, 116522 85610, 116327 85193, 116343 84382, 116448 84020, 116614 83691, 117008 83299, 117252 83184, 117540 83126, 117969 83306))) -------------------------------------------------------------------------------- /stress_benchmark/resources/052.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((109686 134536, 110121 134814, 110298 135133, 110200 135485, 110046 135493, 109381 134967, 109147 134698, 109303 134480, 109686 134536)), ((120122 134632, 120345 134758, 120510 134935, 120548 135030, 120509 135169, 119847 135094, 119796 135068, 119486 135018, 119099 134934, 119177 134715, 119344 134639, 119746 134569, 120122 134632)), ((100620 129691, 100943 129932, 101187 130371, 101216 130615, 101170 130827, 100902 130979, 100786 130956, 100302 129995, 100240 129702, 100359 129629, 100620 129691)), ((129246 129822, 129409 129941, 129444 130214, 128289 130485, 128125 130464, 128095 130254, 128342 130035, 128585 129866, 128933 129788, 129246 129822)), ((95134 121371, 95310 121876, 95325 122158, 95174 122609, 94896 122722, 94706 122567, 94658 122101, 94649 121537, 94706 121335, 94858 121231, 95134 121371)), ((134942 121391, 135047 121583, 134511 122036, 134133 122480, 134012 122494, 133981 122130, 134176 121632, 134669 121339, 134942 121391)), ((135939 111231, 136020 111393, 136015 111732, 135790 112410, 135661 112592, 135439 112519, 135364 112406, 135292 112050, 135402 111476, 135714 111197, 135939 111231)), ((94025 111307, 94132 111642, 93957 112231, 93671 112538, 93573 112583, 93391 112589, 93193 112351, 93223 112052, 93382 111679, 93669 111305, 93920 111234, 94025 111307)), ((132189 101709, 132349 101945, 132537 102911, 132475 103105, 132390 103133, 132141 103099, 132018 103012, 131743 102506, 131681 102019, 131986 101678, 132059 101647, 132189 101709)), ((97784 101951, 97823 102204, 97533 102675, 97221 102899, 96920 102942, 96780 102887, 96589 102635, 96684 102462, 96895 102195, 97331 101927, 97653 101854, 97784 101951)), ((124763 95326, 125080 95729, 125243 95968, 125187 96177, 124878 96244, 124543 96174, 124273 95957, 124021 95528, 124016 95219, 124128 95099, 124409 95051, 124763 95326)), ((105426 95274, 105542 95448, 105508 95702, 105341 95875, 105153 95990, 104872 96059, 104486 96084, 104239 95944, 104087 95679, 104183 95492, 104464 95310, 104881 95222, 105322 95222, 105426 95274)), ((114616 92779, 114903 92893, 115025 92959, 115297 93068, 115410 93207, 115430 93451, 115302 93573, 114903 93688, 114352 93557, 114071 93247, 114038 92946, 114340 92758, 114616 92779))) -------------------------------------------------------------------------------- /stress_benchmark/resources/053.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((112612 86866, 113832 86959, 113832 86958, 114807 87070, 115782 87222, 116744 87411, 116744 87412, 117704 87641, 118647 87906, 119586 88211, 119586 88210, 120505 88550, 121413 88928, 122309 89343, 123184 89791, 124248 90392, 124248 90393, 125506 91206, 126484 91925, 127251 92534, 127994 93178, 128714 93853, 129584 94737, 130386 95654, 131001 96418, 131587 97208, 132141 98020, 132662 98854, 133149 99708, 133604 100584, 134020 101471, 134499 102605, 134907 103764, 135197 104703, 135516 105903, 135756 107095, 135913 108067, 136031 109043, 136030 109043, 136107 110025, 136147 111006, 136147 112231, 136057 113735, 135913 114930, 135757 115901, 135516 117096, 135198 118294, 134908 119233, 134498 120396, 134020 121530, 133604 122417, 133151 123289, 132664 124143, 132143 124977, 131589 125789, 131001 126582, 130386 127346, 129739 128086, 129063 128800, 128152 129686, 127251 130466, 126484 131076, 125491 131805, 124246 132609, 124246 132610, 123184 133209, 122309 133657, 121413 134072, 120505 134450, 119586 134790, 119586 134789, 118647 135094, 117704 135359, 116744 135588, 116744 135589, 115782 135778, 114554 135969, 113340 136083, 112358 136138, 111377 136153, 110395 136128, 109413 136064, 108431 135961, 107214 135784, 105753 135480, 104585 135163, 103646 134869, 102720 134537, 101812 134169, 100912 133764, 100035 133325, 99175 132851, 98330 132341, 97509 131799, 96511 131081, 95557 130305, 94630 129487, 93763 128624, 93095 127903, 92301 126976, 91553 125990, 90995 125184, 90462 124353, 89837 123282, 89183 121991, 88688 120848, 88332 119930, 88014 119000, 87734 118057, 87491 117104, 87287 116142, 87122 115173, 86995 114201, 86907 113218, 86858 112237, 86846 111014, 86907 109781, 86995 108798, 87122 107827, 87287 106858, 87491 105896, 87734 104943, 88014 104000, 88333 103069, 88688 102152, 89183 101009, 89837 99718, 90579 98445, 91420 97186, 92298 96027, 93095 95096, 93765 94376, 94645 93499, 95558 92695, 96509 91920, 97509 91201, 98330 90659, 99175 90148, 100035 89674, 100912 89235, 101812 88830, 102720 88463, 103646 88131, 104585 87837, 105533 87580, 106496 87361, 106496 87360, 107459 87180, 108431 87039, 109413 86936, 110395 86872, 111377 86847, 112612 86866))) -------------------------------------------------------------------------------- /stress_benchmark/resources/055.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((1536 -3019, 1607 -2843, 1801 -2796, 2138 -2394, 2179 -2003, 2330 -1927, 2384 -1793, 2151 -1361, 1550 -1273, 1528 -1498, 1222 -1686, 1202 -1789, 1065 -1927, 1240 -2309, 1383 -2780, 1248 -3220, 1506 -3507, 1536 -3019)), ((-161 -2857, -136 -2927, -2 -2639, 123 -2650, 244 -2812, 365 -2732, 554 -2793, 686 -2662, 777 -2898, 612 -1891, 459 -1852, 355 -1932, 333 -2108, 270 -2093, 136 -2160, 113 -2072, -10 -2292, -74 -2211, -182 -2318, -293 -2784, -283 -2953, -161 -2857)), ((851 -2133, 762 -2062, 1018 -2719, 851 -2133)), ((1156 -4291, 1222 -4049, 1158 -3801, 1119 -3279, 967 -3206, 963 -3493, 719 -3539, 521 -3831, 271 -3964, 165 -4229, 332 -4224, 924 -4613, 1002 -4616, 1156 -4291))) -------------------------------------------------------------------------------- /stress_benchmark/resources/058.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((91317 121314, 90263 123129, 89646 123124, 89562 123156, 89223 123187, 89257 123154, 88871 123236, 88861 123093, 87422 123266, 87172 123070, 86120 123132, 85755 122947, 85416 122823, 85100 122761, 84807 122761, 84542 122822, 84307 122944, 84103 123127, 83190 123076, 82531 123090, 82061 123117, 79799 123129, 78743 121312, 91317 121314))) -------------------------------------------------------------------------------- /stress_benchmark/resources/062.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((117731 159004, 118355 159216, 119096 159772, 119579 160364, 119988 161000, 120285 161602, 120591 162374, 120839 163186, 121007 164009, 121112 164827, 121135 165660, 121123 166475, 121064 167310, 120920 168160, 120772 168872, 120505 169745, 120087 170769, 119554 171662, 119032 172264, 118534 172693, 117932 172994, 117761 173021, 117503 172994, 117246 173022, 117075 172993, 116473 172692, 115948 172236, 115276 171409, 114901 170662, 114564 169932, 114256 168983, 114043 167998, 113942 167317, 113869 166505, 113867 165659, 113914 164837, 113997 164018, 114180 163180, 114413 162375, 114719 161603, 115020 161002, 115428 160366, 115903 159780, 116650 159212, 117241 158991, 117731 159004))) -------------------------------------------------------------------------------- /stress_benchmark/resources/065.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((274498 215057, 273516 215059, 273386 154809, 274368 154807, 274498 215057))) -------------------------------------------------------------------------------- /stress_benchmark/resources/066.wkt: -------------------------------------------------------------------------------- 1 | MULTIPOLYGON (((165244 101743, 166738 102904, 168150 104230, 169007 105191, 169408 105703, 170133 106774, 170747 107915, 171234 109121, 171233 109121, 171566 110378, 171739 111665, 171739 112964, 171566 114255, 171420 114890, 171007 116119, 170456 117295, 170134 117856, 169408 118928, 169007 119437, 168148 120402, 166736 121725, 165241 122886, 163055 124308, 160799 125534, 159056 126359, 154895 128035, 151213 129265, 151213 127699, 154394 126638, 158466 124997, 158467 124997, 160131 124206, 162297 123030, 162298 123029, 164381 121675, 165773 120594, 165775 120593, 167084 119362, 167868 118486, 167869 118485, 168206 118053, 168874 117070, 168875 117069, 169138 116606, 169627 115567, 169627 115565, 169988 114484, 170105 113988, 170106 113986, 170256 112867, 170256 111761, 170108 110664, 170108 110662, 169823 109589, 169822 109588, 169403 108545, 169403 108544, 168863 107543, 168862 107542, 168206 106577, 167869 106146, 167868 106145, 167083 105265, 165773 104035, 165772 104034, 164378 102952, 163199 102179, 163200 100401, 165244 101743))) -------------------------------------------------------------------------------- /test_package/conanfile.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Ultimaker B.V. 2 | # CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | from conan import ConanFile 5 | from conan.tools.env import VirtualRunEnv 6 | from conan.tools.build import can_run 7 | 8 | 9 | class CuraEngineTestConan(ConanFile): 10 | settings = "os", "compiler", "build_type", "arch" 11 | test_type = "explicit" 12 | 13 | def requirements(self): 14 | self.requires(self.tested_reference_str) 15 | 16 | def generate(self): 17 | venv = VirtualRunEnv(self) 18 | venv.generate() 19 | 20 | def test(self): 21 | if can_run(self): 22 | self.run("CuraEngine help", env = "conanrun") 23 | -------------------------------------------------------------------------------- /tests/ReadTestPolygons.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef READ_TEST_POLYGONS_H 5 | #define READ_TEST_POLYGONS_H 6 | 7 | #include "geometry/Polygon.h" 8 | #include 9 | #include 10 | 11 | /* A reader for a very simple 2D polygon format, usefull for tests. 12 | * It's currently uesd to read all the './tests/resources/polygon_*.txt' files. 13 | * 14 | * The format of a file needs to be as follows: 15 | * - specify the next vertex in the smae loop with "v \n" 16 | * each subsequent vertex is assumed to be connected to the last with a line-segment 17 | * unless the loop is closed by the following: 18 | * - specify the end of a loop within the same polygon with "x\n" 19 | * this is useful if you need to make polygons with holes, or 'polygons' that otherwise have multiple parts 20 | * - specify the end of a polygon with '&\n' 21 | * - specify the end of the file with '#\n' 22 | * 23 | * A small example: 24 | v 10000 10000 25 | v 10000 50000 26 | v 50000 50000 27 | # 28 | * 29 | * Note that: 30 | * - loops don't have to be closed with a vertex identical to the last, a loop is assumed to be closed. 31 | * - the file-end will also close both the polygon and the loop, and the polygon-end will close loops as well. 32 | * - comments can be added after the 'end' of the file. 33 | */ 34 | 35 | namespace cura 36 | { 37 | bool readTestPolygons(const std::vector& filenames, std::vector& polygons_out); 38 | bool readTestPolygons(const std::string& filename, std::vector& polygons_out); 39 | } // namespace cura 40 | 41 | #endif // READ_TEST_POLYGONS_H 42 | -------------------------------------------------------------------------------- /tests/arcus/MockCommunication.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MOCKCOMMUNICATION_H 5 | #define MOCKCOMMUNICATION_H 6 | 7 | #include 8 | 9 | #include "communication/Communication.h" //The interface we're implementing. 10 | #include "geometry/Polygon.h" //In the signature of Communication. 11 | #include "geometry/Shape.h" 12 | #include "settings/types/LayerIndex.h" 13 | #include "utils/Coord_t.h" 14 | 15 | namespace cura 16 | { 17 | 18 | /* 19 | * No-op implementation of Communication. 20 | */ 21 | class MockCommunication : public Communication 22 | { 23 | public: 24 | MOCK_CONST_METHOD0(hasSlice, bool()); 25 | MOCK_CONST_METHOD0(isSequential, bool()); 26 | MOCK_CONST_METHOD1(sendProgress, void(double progress)); 27 | MOCK_METHOD3(sendLayerComplete, void(const LayerIndex::value_type& layer_nr, const coord_t& z, const coord_t& thickness)); 28 | MOCK_METHOD5(sendLineTo, void(const PrintFeatureType& type, const Point3LL& to, const coord_t& line_width, const coord_t& line_thickness, const Velocity& velocity)); 29 | MOCK_METHOD1(sendCurrentPosition, void(const Point3LL& position)); 30 | MOCK_METHOD1(setExtruderForSend, void(const ExtruderTrain& extruder)); 31 | MOCK_METHOD1(setLayerForSend, void(const LayerIndex::value_type& layer_nr)); 32 | MOCK_METHOD0(sendOptimizedLayerData, void()); 33 | MOCK_CONST_METHOD0(sendPrintTimeMaterialEstimates, void()); 34 | MOCK_METHOD0(beginGCode, void()); 35 | MOCK_METHOD0(flushGCode, void()); 36 | MOCK_CONST_METHOD1(sendGCodePrefix, void(const std::string& prefix)); 37 | MOCK_CONST_METHOD1(sendSliceUUID, void(const std::string& slice_uuid)); 38 | MOCK_CONST_METHOD0(sendFinishedSlicing, void()); 39 | MOCK_METHOD0(sliceNext, void()); 40 | }; 41 | 42 | } // namespace cura 43 | 44 | #endif // MOCKCOMMUNICATION_H 45 | -------------------------------------------------------------------------------- /tests/arcus/MockSocket.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include "MockSocket.h" 5 | 6 | namespace cura 7 | { 8 | 9 | MockSocket::MockSocket() = default; 10 | 11 | void MockSocket::connect(const std::string& address, int port) 12 | { /* Do nothing. */ 13 | } 14 | void MockSocket::listen(const std::string& address, int port) 15 | { /* Do nothing. */ 16 | } 17 | void MockSocket::close() 18 | { /* Do nothing. */ 19 | } 20 | void MockSocket::reset() 21 | { /* Do nothing. */ 22 | } 23 | 24 | bool MockSocket::sendMessage(Arcus::MessagePtr message) 25 | { 26 | sent_messages.push_back(message); 27 | return true; 28 | } 29 | 30 | Arcus::MessagePtr MockSocket::takeNextMessage() 31 | { 32 | Arcus::MessagePtr result = received_messages.front(); 33 | received_messages.pop_front(); 34 | return result; 35 | } 36 | 37 | void MockSocket::pushMessageToReceivedQueue(Arcus::MessagePtr message) 38 | { 39 | received_messages.push_back(message); 40 | } 41 | 42 | Arcus::MessagePtr MockSocket::popMessageFromSendQueue() 43 | { 44 | Arcus::MessagePtr result = sent_messages.front(); 45 | sent_messages.pop_front(); 46 | return result; 47 | } 48 | 49 | } // namespace cura 50 | -------------------------------------------------------------------------------- /tests/arcus/MockSocket.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #ifndef MOCKSOCKET_H 5 | #define MOCKSOCKET_H 6 | 7 | #include //History of sent and received messages. 8 | 9 | #include //Inheriting from this to be able to swap this socket in the tested class. 10 | 11 | namespace cura 12 | { 13 | 14 | /* 15 | * \brief Mocks a socket connection from libArcus such that we can test with it 16 | * without creating an actual connection. 17 | */ 18 | // NOLINTBEGIN(misc-non-private-member-variables-in-classes) 19 | class MockSocket : public Arcus::Socket 20 | { 21 | public: 22 | MockSocket(); 23 | 24 | // These functions are overridden to be no-op. 25 | void connect(const std::string& address, int port) override; 26 | void listen(const std::string& address, int port) override; 27 | void close() override; 28 | void reset() override; 29 | 30 | // Catch these functions so that we can see whether they are called. 31 | bool sendMessage(Arcus::MessagePtr message) override; 32 | Arcus::MessagePtr takeNextMessage() override; 33 | 34 | // Helpers to store send and received messages. 35 | void pushMessageToReceivedQueue(Arcus::MessagePtr message); 36 | Arcus::MessagePtr popMessageFromSendQueue(); 37 | std::deque sent_messages; 38 | std::deque received_messages; 39 | }; 40 | // NOLINTEND(misc-non-private-member-variables-in-classes) 41 | } // namespace cura 42 | 43 | #endif // MOCKSOCKET_H 44 | -------------------------------------------------------------------------------- /tests/cube_vertices.txt: -------------------------------------------------------------------------------- 1 | -4.95 4.95 9.9 2 | 4.95 -4.95 9.9 3 | 4.95 4.95 9.9 4 | 4.95 -4.95 9.9 5 | -4.95 4.95 9.9 6 | -4.95 -4.95 9.9 7 | -4.95 -4.95 0. 8 | 4.95 4.95 0. 9 | 4.95 -4.95 0. 10 | 4.95 4.95 0. 11 | -4.95 -4.95 0. 12 | -4.95 4.95 0. 13 | -4.95 -4.95 0. 14 | 4.95 -4.95 9.9 15 | -4.95 -4.95 9.9 16 | 4.95 -4.95 9.9 17 | -4.95 -4.95 0. 18 | 4.95 -4.95 0. 19 | 4.95 -4.95 9.9 20 | 4.95 4.95 0. 21 | 4.95 4.95 9.9 22 | 4.95 4.95 0. 23 | 4.95 -4.95 9.9 24 | 4.95 -4.95 0. 25 | 4.95 4.95 0. 26 | -4.95 4.95 9.9 27 | 4.95 4.95 9.9 28 | -4.95 4.95 9.9 29 | 4.95 4.95 0. 30 | -4.95 4.95 0. 31 | -4.95 -4.95 0. 32 | -4.95 4.95 9.9 33 | -4.95 4.95 0. 34 | -4.95 4.95 9.9 35 | -4.95 -4.95 0. 36 | -4.95 -4.95 9.9 37 | -------------------------------------------------------------------------------- /tests/integration/resources/cube.stl: -------------------------------------------------------------------------------- 1 | solid 10mmCube 2 | facet normal -0 0 1 3 | outer loop 4 | vertex 0 10 10 5 | vertex 10 0 10 6 | vertex 10 10 10 7 | endloop 8 | endfacet 9 | facet normal 0 0 1 10 | outer loop 11 | vertex 10 0 10 12 | vertex 0 10 10 13 | vertex 0 0 10 14 | endloop 15 | endfacet 16 | facet normal 0 0 -1 17 | outer loop 18 | vertex 0 0 0 19 | vertex 10 10 0 20 | vertex 10 0 0 21 | endloop 22 | endfacet 23 | facet normal -0 0 -1 24 | outer loop 25 | vertex 10 10 0 26 | vertex 0 0 0 27 | vertex 0 10 0 28 | endloop 29 | endfacet 30 | facet normal 0 -1 0 31 | outer loop 32 | vertex 0 0 0 33 | vertex 10 0 10 34 | vertex 0 0 10 35 | endloop 36 | endfacet 37 | facet normal 0 -1 -0 38 | outer loop 39 | vertex 10 0 10 40 | vertex 0 0 0 41 | vertex 10 0 0 42 | endloop 43 | endfacet 44 | facet normal 1 -0 0 45 | outer loop 46 | vertex 10 0 10 47 | vertex 10 10 0 48 | vertex 10 10 10 49 | endloop 50 | endfacet 51 | facet normal 1 0 0 52 | outer loop 53 | vertex 10 10 0 54 | vertex 10 0 10 55 | vertex 10 0 0 56 | endloop 57 | endfacet 58 | facet normal 0 1 -0 59 | outer loop 60 | vertex 10 10 0 61 | vertex 0 10 10 62 | vertex 10 10 10 63 | endloop 64 | endfacet 65 | facet normal 0 1 0 66 | outer loop 67 | vertex 0 10 10 68 | vertex 10 10 0 69 | vertex 0 10 0 70 | endloop 71 | endfacet 72 | facet normal -1 0 0 73 | outer loop 74 | vertex 0 0 0 75 | vertex 0 10 10 76 | vertex 0 10 0 77 | endloop 78 | endfacet 79 | facet normal -1 -0 0 80 | outer loop 81 | vertex 0 10 10 82 | vertex 0 0 0 83 | vertex 0 0 10 84 | endloop 85 | endfacet 86 | endsolid 10mmCube 87 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include 5 | 6 | /*! 7 | * \brief Runs the test cases. 8 | */ 9 | int main(int argc, char** argv) 10 | { 11 | testing::InitGoogleTest(&argc, argv); 12 | return RUN_ALL_TESTS(); 13 | } -------------------------------------------------------------------------------- /tests/resources/polygon_concave.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 12000 30000 3 | v 10000 50000 4 | v 30000 48000 5 | v 50000 50000 6 | v 48000 30000 7 | v 50000 10000 8 | v 30000 12000 9 | # 10 | 11 | A 'square' with an extra inner corner along each edge, creating a concave shape. 12 | -------------------------------------------------------------------------------- /tests/resources/polygon_concave_hole.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 12000 30000 3 | v 10000 50000 4 | v 30000 48000 5 | v 50000 50000 6 | v 48000 30000 7 | v 50000 10000 8 | v 30000 12000 9 | x 10 | v 25000 25000 11 | v 35000 35000 12 | v 25000 35000 13 | # 14 | 15 | Same as 'polygon_concave.txt', but with a triangular hole in it. 16 | -------------------------------------------------------------------------------- /tests/resources/polygon_letter_y.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 15000 18000 3 | v 20000 10000 4 | v 35000 50000 5 | v 50000 10000 6 | v 55000 18000 7 | v 60000 10000 8 | v 50000 60000 9 | v 50000 90000 10 | v 35000 70000 11 | v 15000 90000 12 | v 15000 80000 13 | v 20000 80000 14 | v 20000 60000 15 | # 16 | 17 | A letter y shape with some embelishments, a tree. 18 | -------------------------------------------------------------------------------- /tests/resources/polygon_sawtooth.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 90000 3 | v 90000 90000 4 | v 80000 60000 5 | v 70000 80000 6 | v 60000 60000 7 | v 50000 80000 8 | v 40000 60000 9 | v 30000 80000 10 | v 30000 20000 11 | v 40000 40000 12 | v 50000 20000 13 | v 60000 40000 14 | v 70000 20000 15 | v 80000 40000 16 | v 90000 10000 17 | # 18 | 19 | A sawtooth figure (in the concave hole of a square) with teeth opposing each other. 20 | -------------------------------------------------------------------------------- /tests/resources/polygon_slant_gap.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 50000 3 | v 90000 50000 4 | v 90000 10000 5 | x 6 | v 15000 15000 7 | v 85000 40000 8 | v 85000 40500 9 | v 15000 15500 10 | # 11 | 12 | A square with a very askew gap. 13 | -------------------------------------------------------------------------------- /tests/resources/polygon_square.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 50000 3 | v 50000 50000 4 | v 50000 10000 5 | # 6 | 7 | Just a simple square. 8 | -------------------------------------------------------------------------------- /tests/resources/polygon_square_hole.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 50000 3 | v 50000 50000 4 | v 50000 10000 5 | x 6 | v 25000 25000 7 | v 35000 35000 8 | v 25000 35000 9 | # 10 | 11 | Same as 'polygon_square.txt', but with a triangular hole in it. 12 | -------------------------------------------------------------------------------- /tests/resources/polygon_triangle.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 50000 3 | v 50000 50000 4 | # 5 | 6 | Just a simple triangle. 7 | -------------------------------------------------------------------------------- /tests/resources/polygon_two_squares.txt: -------------------------------------------------------------------------------- 1 | v 10000 10000 2 | v 10000 50000 3 | v 50000 50000 4 | v 50000 10000 5 | x 6 | v 60000 60000 7 | v 60000 90000 8 | v 90000 90000 9 | v 90000 60000 10 | # 11 | 12 | Two simple squares. 13 | -------------------------------------------------------------------------------- /tests/resources/slice_polygon_1.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 UltiMaker 2 | // CuraEngine is released under the terms of the AGPLv3 or higher 3 | 4 | v 127470 164447 5 | v 127806 164494 6 | v 128024 164722 7 | v 128075 165037 8 | v 127933 165382 9 | v 127468 165831 10 | v 127067 165975 11 | v 126530 165890 12 | v 126607 166299 13 | v 126462 166638 14 | v 126341 166754 15 | v 126682 167110 16 | v 126822 167452 17 | v 126776 167780 18 | v 126558 168001 19 | v 126227 168048 20 | v 125897 167909 21 | v 125594 167606 22 | v 125323 167879 23 | v 124886 168043 24 | v 124559 167994 25 | v 124316 167776 26 | v 124258 167468 27 | v 124401 167144 28 | v 124774 166786 29 | v 124586 166599 30 | v 124446 166266 31 | v 124497 165952 32 | v 124714 165719 33 | v 125045 165671 34 | v 125396 165812 35 | v 125532 165952 36 | v 125628 165856 37 | v 125980 165724 38 | v 126520 165797 39 | v 126442 165399 40 | v 126576 165081 41 | v 126726 164935 42 | v 126756 164822 43 | v 126986 164538 44 | v 127314 164412 45 | # 46 | 47 | A polygon from a real world example. This polygon is generated from tree support 48 | -------------------------------------------------------------------------------- /tests/testModel.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ultimaker/CuraEngine/ae38e6010d34f65493d3e2cc3c91a4c6f023145c/tests/testModel.stl -------------------------------------------------------------------------------- /tests/utils/IntPointTest.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Ultimaker B.V. 2 | // CuraEngine is released under the terms of the AGPLv3 or higher. 3 | 4 | #include 5 | 6 | #include "geometry/Point2LL.h" 7 | #include "geometry/Point3Matrix.h" 8 | #include "geometry/PointMatrix.h" 9 | 10 | // NOLINTBEGIN(*-magic-numbers) 11 | namespace cura 12 | { 13 | TEST(IntPointTest, TestRotationMatrix) 14 | { 15 | PointMatrix rot2d(90); 16 | Point3Matrix rot_homogeneous(rot2d); 17 | Point2LL a(20, 10); 18 | Point2LL b(30, 20); 19 | Point2LL translated = Point3Matrix::translate(-a).apply(b); 20 | Point2LL rotated = rot_homogeneous.apply(translated); 21 | Point2LL rotated_in_place = Point3Matrix::translate(a).apply(rotated); 22 | 23 | Point3Matrix all_in_one = Point3Matrix::translate(a).compose(rot_homogeneous).compose(Point3Matrix::translate(-a)); 24 | Point2LL rotated_in_place_2 = all_in_one.apply(b); 25 | 26 | ASSERT_EQ(rotated_in_place, rotated_in_place_2) << "Matrix composition with translate and rotate failed."; 27 | } 28 | 29 | TEST(IntPointTest, TestSize) 30 | { 31 | ASSERT_EQ(sizeof(Point2LL::X), sizeof(coord_t)); 32 | ASSERT_LE(sizeof(coord_t), sizeof(int64_t)); 33 | } 34 | 35 | } // namespace cura 36 | // NOLINTEND(*-magic-numbers) 37 | --------------------------------------------------------------------------------