Skip to content

Commit

Permalink
CURA-9830 consolidate polygon classes (#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
HellAholic authored May 17, 2024
2 parents 8a3debd + bab08d1 commit 09dfa73
Show file tree
Hide file tree
Showing 213 changed files with 8,751 additions and 7,339 deletions.
5 changes: 3 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Checks: >
-fuchsia-overloaded-operator,
-cppcoreguidelines-avoid-capturing-lambda-coroutines,
-llvm-header-guard,
-bugprone-easily-swappable-parameters
-bugprone-easily-swappable-parameters,
-*-default-arguments-declarations
WarningsAsErrors: '-*'
HeaderFilterRegex: ''
FormatStyle: none
Expand Down Expand Up @@ -52,4 +53,4 @@ CheckOptions:
- key: readability-identifier-length.IgnoredVariableNames
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'
- key: readability-identifier-length.IgnoredLoopCounterNames
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'
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'
23 changes: 20 additions & 3 deletions .github/workflows/conan-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ on:
tags:
- '[0-9]+.[0-9]+.[0-9]*'
- '[0-9]+.[0-9]+.[0-9]'
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'include/**'
- 'src/**'
- 'test_package/**'
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- '.github/workflows/conan-package.yml'
branches:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9].[0-9]*'
- '[0-9].[0-9][0-9]*'

jobs:
conan-recipe-version:
Expand All @@ -37,23 +54,23 @@ jobs:

conan-package-create-macos:
needs: [ conan-recipe-version, conan-package-export ]
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
if: ${{ ((github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || github.event_name == 'pull_request') }}
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-macos.yml@main
with:
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
secrets: inherit

conan-package-create-windows:
needs: [ conan-recipe-version, conan-package-export ]
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
if: ${{ ((github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || github.event_name == 'pull_request') }}
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-windows.yml@main
with:
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
secrets: inherit

conan-package-create-linux:
needs: [ conan-recipe-version, conan-package-export ]
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
if: ${{ ((github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || github.event_name == 'pull_request') }}
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-linux.yml@main
with:
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
Expand Down
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ set(engine_SRCS # Except main.cpp.
src/MeshGroup.cpp
src/Mold.cpp
src/multiVolumes.cpp
src/PathOrderPath.cpp
src/path_ordering.cpp
src/Preheat.cpp
src/PrimeTower.cpp
src/raft.cpp
Expand Down Expand Up @@ -135,7 +135,7 @@ set(engine_SRCS # Except main.cpp.
src/utils/ExtrusionLine.cpp
src/utils/ExtrusionSegment.cpp
src/utils/gettime.cpp
src/utils/LinearAlg2D.cpp
src/utils/linearAlg2D.cpp
src/utils/ListPolyIt.cpp
src/utils/Matrix4x3D.cpp
src/utils/MinimumSpanningTree.cpp
Expand All @@ -144,7 +144,6 @@ set(engine_SRCS # Except main.cpp.
src/utils/PolygonsPointIndex.cpp
src/utils/PolygonsSegmentIndex.cpp
src/utils/polygonUtils.cpp
src/utils/polygon.cpp
src/utils/PolylineStitcher.cpp
src/utils/Simplify.cpp
src/utils/SVG.cpp
Expand All @@ -153,6 +152,17 @@ set(engine_SRCS # Except main.cpp.
src/utils/ToolpathVisualizer.cpp
src/utils/VoronoiUtils.cpp
src/utils/VoxelUtils.cpp
src/utils/MixedPolylineStitcher.cpp

src/geometry/Polygon.cpp
src/geometry/Shape.cpp
src/geometry/PointsSet.cpp
src/geometry/SingleShape.cpp
src/geometry/PartsView.cpp
src/geometry/LinesSet.cpp
src/geometry/Polyline.cpp
src/geometry/ClosedPolyline.cpp
src/geometry/MixedLinesSet.cpp
)

add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS})
Expand Down
48 changes: 26 additions & 22 deletions benchmark/infill_benchmark.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef CURAENGINE_INFILL_BENCHMARK_H
#define CURAENGINE_INFILL_BENCHMARK_H

#include <benchmark/benchmark.h>

#include "geometry/OpenLinesSet.h"
#include "geometry/OpenPolyline.h"
#include "geometry/LinesSet.h"
#include "infill.h"

namespace cura
Expand All @@ -14,14 +17,14 @@ class InfillTest : public benchmark::Fixture
{
public:
Settings settings{};
Polygons square_shape;
Polygons ff_holes;
Shape square_shape;
Shape ff_holes;


std::vector<ExtrusionLine> all_paths;


Polygons outline_polygons;
Shape outline_polygons;
EFillMethod pattern{ EFillMethod::LINES };
bool zig_zagify{ true };
bool connect_polygons{ true };
Expand Down Expand Up @@ -58,8 +61,8 @@ class InfillTest : public benchmark::Fixture
ff_holes.back().emplace_back(MM2INT(60), MM2INT(40));
ff_holes.back().emplace_back(MM2INT(90), MM2INT(25));

outline_polygons.add(square_shape);
outline_polygons.add(ff_holes);
outline_polygons.push_back(square_shape);
outline_polygons.push_back(ff_holes);

settings.add("fill_outline_gaps", "false");
settings.add("meshfix_maximum_deviation", "0.1");
Expand Down Expand Up @@ -93,29 +96,30 @@ class InfillTest : public benchmark::Fixture

BENCHMARK_DEFINE_F(InfillTest, Infill_generate_connect)(benchmark::State& st)
{
Infill infill(pattern,
zig_zagify,
connect_polygons,
outline_polygons,
INFILL_LINE_WIDTH,
line_distance,
INFILL_OVERLAP,
INFILL_MULTIPLIER,
FILL_ANGLE,
Z,
SHIFT,
MAX_RESOLUTION,
MAX_DEVIATION); // There are some optional parameters, but these will do for now (future improvement?).
Infill infill(
pattern,
zig_zagify,
connect_polygons,
outline_polygons,
INFILL_LINE_WIDTH,
line_distance,
INFILL_OVERLAP,
INFILL_MULTIPLIER,
FILL_ANGLE,
Z,
SHIFT,
MAX_RESOLUTION,
MAX_DEVIATION); // There are some optional parameters, but these will do for now (future improvement?).

for (auto _ : st)
{
std::vector<VariableWidthLines> result_paths;
Polygons result_polygons;
Polygons result_lines;
Shape result_polygons;
OpenLinesSet result_lines;
infill.generate(result_paths, result_polygons, result_lines, settings, 0, SectionType::INFILL, nullptr, nullptr);
}
}

BENCHMARK_REGISTER_F(InfillTest, Infill_generate_connect)->ArgsProduct({{true, false}, {400, 800, 1200}})->Unit(benchmark::kMillisecond);
BENCHMARK_REGISTER_F(InfillTest, Infill_generate_connect)->ArgsProduct({ { true, false }, { 400, 800, 1200 } })->Unit(benchmark::kMillisecond);
} // namespace cura
#endif // CURAENGINE_INFILL_BENCHMARK_H
6 changes: 3 additions & 3 deletions benchmark/simplify_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SimplifyTestFixture : public benchmark::Fixture
std::filesystem::path(__FILE__).parent_path().append("tests/resources/slice_polygon_3.txt").string(),
std::filesystem::path(__FILE__).parent_path().append("tests/resources/slice_polygon_4.txt").string() };

std::vector<Polygons> shapes;
std::vector<Shape> shapes;

void SetUp(const ::benchmark::State& state)
{
Expand All @@ -51,7 +51,7 @@ BENCHMARK_DEFINE_F(SimplifyTestFixture, simplify_local)(benchmark::State& st)
Simplify simplify(MM2INT(0.25), MM2INT(0.025), 50000);
for (auto _ : st)
{
Polygons simplified;
Shape simplified;
for (const auto& polys : shapes)
{
benchmark::DoNotOptimize(simplified = simplify.polygon(polys));
Expand All @@ -66,7 +66,7 @@ BENCHMARK_DEFINE_F(SimplifyTestFixture, simplify_slot_noplugin)(benchmark::State
{
for (auto _ : st)
{
Polygons simplified;
Shape simplified;
for (const auto& polys : shapes)
{
benchmark::DoNotOptimize(simplified = slots::instance().modify<plugins::v0::SlotID::SIMPLIFY_MODIFY>(polys, MM2INT(0.25), MM2INT(0.025), 50000));
Expand Down
35 changes: 17 additions & 18 deletions benchmark/wall_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
#ifndef CURAENGINE_WALL_BENCHMARK_H
#define CURAENGINE_WALL_BENCHMARK_H

#include <benchmark/benchmark.h>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>

#include <benchmark/benchmark.h>
#include <range/v3/view/join.hpp>
#include <spdlog/spdlog.h>

#include "InsetOrderOptimizer.h"
#include "WallsComputation.h"
#include "geometry/Polygon.h"
#include "settings/Settings.h"
#include "sliceDataStorage.h"
#include "utils/polygon.h"

#include <filesystem>
#include <fstream>
#include <iostream>
#include <spdlog/spdlog.h>

namespace cura
{
Expand All @@ -27,8 +26,8 @@ class WallTestFixture : public benchmark::Fixture
public:
Settings settings{};
WallsComputation walls_computation{ settings, LayerIndex(100) };
Polygons square_shape;
Polygons ff_holes;
Shape square_shape;
Shape ff_holes;
bool outer_to_inner;
SliceLayer layer;

Expand Down Expand Up @@ -85,7 +84,7 @@ class WallTestFixture : public benchmark::Fixture
layer.parts.emplace_back();

SliceLayerPart& part = layer.parts.back();
part.outline.add(ff_holes);
part.outline.push_back(ff_holes);
}

void TearDown(const ::benchmark::State& state)
Expand All @@ -98,8 +97,8 @@ class HolesWallTestFixture : public benchmark::Fixture
public:
Settings settings{};
WallsComputation walls_computation{ settings, LayerIndex(100) };
Polygons shape;
Polygons ff_holes;
Shape shape;
Shape ff_holes;
bool outer_to_inner;
SliceLayer layer;

Expand All @@ -113,7 +112,7 @@ class HolesWallTestFixture : public benchmark::Fixture
buffer << file.rdbuf();
const auto wkt = buffer.str();

const auto shape = Polygons::fromWkt(buffer.str());
const auto shape = Shape::fromWkt(buffer.str());

// Settings for a simple 2 walls, about as basic as possible.
settings.add("alternate_extra_perimeter", "false");
Expand Down Expand Up @@ -145,7 +144,7 @@ class HolesWallTestFixture : public benchmark::Fixture
layer.parts.emplace_back();

SliceLayerPart& part = layer.parts.back();
part.outline.add(shape.paths.front());
part.outline.push_back(shape.front());
part.print_outline = shape;
}

Expand All @@ -168,7 +167,7 @@ BENCHMARK_DEFINE_F(WallTestFixture, InsetOrderOptimizer_getRegionOrder)(benchmar
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join)
{
all_paths.emplace_back(line);
}
Expand All @@ -184,7 +183,7 @@ BENCHMARK_DEFINE_F(WallTestFixture, InsetOrderOptimizer_getInsetOrder)(benchmark
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join)
{
all_paths.emplace_back(line);
}
Expand All @@ -210,7 +209,7 @@ BENCHMARK_DEFINE_F(HolesWallTestFixture, InsetOrderOptimizer_getRegionOrder)(ben
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join)
{
all_paths.emplace_back(line);
}
Expand All @@ -226,7 +225,7 @@ BENCHMARK_DEFINE_F(HolesWallTestFixture, InsetOrderOptimizer_getInsetOrder)(benc
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join)
{
all_paths.emplace_back(line);
}
Expand Down
13 changes: 6 additions & 7 deletions include/BeadingStrategy/BeadingStrategy.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright (c) 2022 Ultimaker B.V.
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef BEADING_STRATEGY_H
#define BEADING_STRATEGY_H

#include <memory>
#include <numbers>

#include "../settings/types/Angle.h"
#include "../settings/types/Ratio.h" //For the wall transition threshold.
#include "../utils/Point2LL.h"
#include "geometry/Point2LL.h"
#include "settings/types/Angle.h"
#include "settings/types/Ratio.h" //For the wall transition threshold.

namespace cura
{
Expand Down Expand Up @@ -45,9 +46,7 @@ class BeadingStrategy

BeadingStrategy(const BeadingStrategy& other);

virtual ~BeadingStrategy()
{
}
virtual ~BeadingStrategy() = default;

/*!
* Retrieve the bead widths with which to cover a given thickness.
Expand Down
6 changes: 4 additions & 2 deletions include/BeadingStrategy/BeadingStrategyFactory.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) 2022 Ultimaker B.V.
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef BEADING_STRATEGY_FACTORY_H
#define BEADING_STRATEGY_FACTORY_H

#include "../settings/types/Ratio.h"
#include <numbers>

#include "BeadingStrategy.h"
#include "settings/types/Ratio.h"

namespace cura
{
Expand Down
Loading

0 comments on commit 09dfa73

Please sign in to comment.