Skip to content

Commit

Permalink
Merge branch 'main' into feature_issue-15583_spiral_z-hop
Browse files Browse the repository at this point in the history
  • Loading branch information
jellespijker authored Feb 16, 2024
2 parents 671cfb0 + db1231e commit e5d0b4a
Show file tree
Hide file tree
Showing 168 changed files with 908 additions and 4,374 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:
output_file_path: "build/Release/benchmark_result.json"
data_dir: "dev/bench"
tool: "googlecpp"
alert_threshold: "125%"
alert_threshold: "150%"
alert_comment_cc_users: "@nallath, @jellespijker, @wawanbreton, @casperlamboo, @saumyaj3, @HellAholic"
secrets: inherit
7 changes: 4 additions & 3 deletions .github/workflows/gcodeanalyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
run: |
for file in `ls ../NightlyTestModels/*.stl`;
do
( time ./build/Release/CuraEngine slice --force-read-parent --force-read-nondefault -v -p -j ../Cura/resources/definitions/ultimaker_s3.def.json -l $file -o ../`basename $file .stl`.gcode ) 2> $file.time
( time ./build/Release/CuraEngine slice --force-read-parent --force-read-nondefault -v -p -j ../Cura/resources/definitions/ultimaker_s3.def.json -l $file -o ../`basename $file .stl`.gcode ) 2> ../`basename $file .stl`.time
done
working-directory: CuraEngine

Expand All @@ -205,8 +205,9 @@ jobs:
if ext.lower() != ".gcode":
continue
infilename = os.path.join(folder_path, filename)
with open(infilename + ".time", "r") as f:
timer = float(re.match(r"^.*?cpu (\d+\.\d+)", f.read())[1])
with open(infilename.rsplit(".", 1)[0] + ".time", "r") as f:
match = re.match(r"^.*?real\s+(\d+)m(\d+\.\d+)s", f.read())
timer = 0 if not match else float(match[1])
frame = GCodeAnalyzer.DataFrame(infilename)
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ else ()
)
endif ()
add_executable(CuraEngine src/main.cpp ${RES_FILES}) # ..., but don't forget the glitter!
if (ENABLE_SENTRY)
set_target_properties(CuraEngine PROPERTIES LINK_FLAGS "/DEBUG:FULL")
endif ()
endif (NOT WIN32)

use_threads(CuraEngine)
Expand Down
2 changes: 2 additions & 0 deletions Cura.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ message Slice
repeated EnginePlugin engine_plugins = 5;
string sentry_id = 6; // The anonymized Sentry user id that requested the slice
string cura_version = 7; // The version of Cura that requested the slice
optional string project_name = 8; // The name of the project that requested the slice
optional string user_name = 9; // The Digital Factory account name of the user that requested the slice
}

message Extruder
Expand Down
1 change: 1 addition & 0 deletions benchmark/holes.wkt

Large diffs are not rendered by default.

110 changes: 109 additions & 1 deletion benchmark/wall_benchmark.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef CURAENGINE_WALL_BENCHMARK_H
Expand All @@ -15,6 +15,11 @@
#include "sliceDataStorage.h"
#include "utils/polygon.h"

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

namespace cura
{
class WallTestFixture : public benchmark::Fixture
Expand Down Expand Up @@ -88,6 +93,67 @@ class WallTestFixture : public benchmark::Fixture
}
};

class HolesWallTestFixture : public benchmark::Fixture
{
public:
Settings settings{};
WallsComputation walls_computation{ settings, LayerIndex(100) };
Polygons shape;
Polygons ff_holes;
bool outer_to_inner;
SliceLayer layer;


void SetUp(const ::benchmark::State& state)
{
auto wkt_file = std::filesystem::path(__FILE__).parent_path().append("holes.wkt");
std::ifstream file{ wkt_file };

std::stringstream buffer;
buffer << file.rdbuf();
const auto wkt = buffer.str();

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

// Settings for a simple 2 walls, about as basic as possible.
settings.add("alternate_extra_perimeter", "false");
settings.add("fill_outline_gaps", "false");
settings.add("initial_layer_line_width_factor", "100");
settings.add("magic_spiralize", "false");
settings.add("meshfix_maximum_deviation", "0.1");
settings.add("meshfix_maximum_extrusion_area_deviation", "0.01");
settings.add("meshfix_maximum_resolution", "0.01");
settings.add("meshfix_fluid_motion_enabled", "false");
settings.add("min_wall_line_width", "0.3");
settings.add("min_bead_width", "0");
settings.add("min_feature_size", "0");
settings.add("wall_0_extruder_nr", "0");
settings.add("wall_0_inset", "0");
settings.add("wall_line_count", "2");
settings.add("wall_line_width_0", "0.4");
settings.add("wall_line_width_x", "0.4");
settings.add("min_even_wall_line_width", "0.34");
settings.add("min_odd_wall_line_width", "0.34");
settings.add("wall_transition_angle", "10");
settings.add("wall_transition_filter_distance", "1");
settings.add("wall_transition_filter_deviation", ".2");
settings.add("wall_transition_length", "1");
settings.add("wall_x_extruder_nr", "0");
settings.add("wall_distribution_count", "2");
settings.add("wall_line_count", std::to_string(state.range(0)));
outer_to_inner = false;
layer.parts.emplace_back();

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

void TearDown(const ::benchmark::State& state)
{
}
};

BENCHMARK_DEFINE_F(WallTestFixture, generateWalls)(benchmark::State& st)
{
for (auto _ : st)
Expand Down Expand Up @@ -130,5 +196,47 @@ BENCHMARK_DEFINE_F(WallTestFixture, InsetOrderOptimizer_getInsetOrder)(benchmark

BENCHMARK_REGISTER_F(WallTestFixture, InsetOrderOptimizer_getInsetOrder)->Arg(3)->Arg(15)->Arg(9999)->Unit(benchmark::kMillisecond);

BENCHMARK_DEFINE_F(HolesWallTestFixture, generateWalls)(benchmark::State& st)
{
for (auto _ : st)
{
walls_computation.generateWalls(&layer, SectionType::WALL);
}
}

BENCHMARK_REGISTER_F(HolesWallTestFixture, generateWalls)->Arg(3)->Arg(15)->Arg(9999)->Unit(benchmark::kMillisecond);

BENCHMARK_DEFINE_F(HolesWallTestFixture, InsetOrderOptimizer_getRegionOrder)(benchmark::State& st)
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
{
all_paths.emplace_back(line);
}
for (auto _ : st)
{
auto order = InsetOrderOptimizer::getRegionOrder(all_paths, outer_to_inner);
}
}

BENCHMARK_REGISTER_F(HolesWallTestFixture, InsetOrderOptimizer_getRegionOrder)->Arg(3)->Arg(15)->Arg(9999)->Unit(benchmark::kMillisecond);

BENCHMARK_DEFINE_F(HolesWallTestFixture, InsetOrderOptimizer_getInsetOrder)(benchmark::State& st)
{
walls_computation.generateWalls(&layer, SectionType::WALL);
std::vector<ExtrusionLine> all_paths;
for (auto& line : layer.parts.back().wall_toolpaths | ranges::views::join )
{
all_paths.emplace_back(line);
}
for (auto _ : st)
{
auto order = InsetOrderOptimizer::getInsetOrder(all_paths, outer_to_inner);
}
}

BENCHMARK_REGISTER_F(HolesWallTestFixture, InsetOrderOptimizer_getInsetOrder)->Arg(3)->Arg(15)->Arg(9999)->Unit(benchmark::kMillisecond);

} // namespace cura
#endif // CURAENGINE_WALL_BENCHMARK_H
6 changes: 3 additions & 3 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "5.7.0-alpha.0"
version: "5.7.0-alpha.1"
requirements:
- "arcus/5.3.0"
- "arcus/5.3.1"
- "curaengine_grpc_definitions/(latest)@ultimaker/testing"
- "scripta/0.1.0@ultimaker/testing"
- "scripta/0.1.0@ultimaker/testing"
73 changes: 57 additions & 16 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Copyright (c) 2023 UltiMaker
# Copyright (c) 2024 UltiMaker
# CuraEngine is released under the terms of the AGPLv3 or higher

from io import StringIO
from os import path
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy, mkdir, update_conandata
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.scm import Version, Git
from conans.tools import which

required_conan_version = ">=1.58.0 <2.0.0"

Expand Down Expand Up @@ -42,10 +44,12 @@ class CuraEngineConan(ConanFile):

def set_version(self):
if not self.version:
self.version = self.conan_data["version"]
build_meta = "" if self.develop else "+source"
self.version = self.conan_data["version"] + build_meta

def export(self):
update_conandata(self, {"version": self.version})
git = Git(self)
update_conandata(self, {"version": self.version, "commit": git.get_commit()})

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand Down Expand Up @@ -75,6 +79,8 @@ def configure(self):
self.options["openssl"].shared = True
if self.options.get_safe("enable_sentry", False):
self.options["sentry-native"].backend = "breakpad"
self.options["arcus"].enable_sentry = True
self.options["clipper"].enable_sentry = True

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
Expand All @@ -85,7 +91,8 @@ def validate(self):

def build_requirements(self):
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
self.test_requires("protobuf/3.21.9")
if self.options.enable_arcus or self.options.enable_plugins:
self.tool_requires("protobuf/3.21.9")
if not self.conf.get("tools.build:skip_test", False, check_type=bool):
self.test_requires("gtest/1.12.1")
if self.options.enable_benchmarks:
Expand All @@ -99,17 +106,18 @@ def requirements(self):
self.requires(req)
if self.options.get_safe("enable_sentry", False):
self.requires("sentry-native/0.6.5")
if self.options.enable_arcus or self.options.enable_plugins:
self.requires("protobuf/3.21.9")
self.requires("asio-grpc/2.6.0")
self.requires("grpc/1.50.1")
self.requires("clipper/6.4.2")
self.requires("clipper/6.4.2@ultimaker/stable")
self.requires("boost/1.82.0")
self.requires("rapidjson/1.1.0")
self.requires("stb/20200203")
self.requires("spdlog/1.12.0")
self.requires("fmt/10.1.1")
self.requires("range-v3/0.12.0")
self.requires("neargye-semver/0.3.0")
self.requires("protobuf/3.21.9")
self.requires("zlib/1.2.12")
self.requires("openssl/3.2.0")

Expand Down Expand Up @@ -140,15 +148,23 @@ def generate(self):
copy(self, "*.dll", dep.cpp_info.libdirs[0], self.build_folder)
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], self.build_folder)

folder_dists = []
if not self.conf.get("tools.build:skip_test", False, check_type=bool):
test_path = path.join(self.build_folder, "tests")
if not path.exists(test_path):
mkdir(self, test_path)
folder_dists.append("tests")
if self.options.enable_benchmarks:
folder_dists.append("benchmark")
folder_dists.append("stress_benchmark")

for dist_folder in folder_dists:
dist_path = path.join(self.build_folder, dist_folder)
if not path.exists(dist_path):
mkdir(self, dist_path)
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dll", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dylib", dep.cpp_info.libdirs[0], path.join(self.build_folder, dist_folder))
copy(self, "*.dll", dep.cpp_info.libdirs[0], path.join(self.build_folder, dist_folder))
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dll", dep.cpp_info.bindirs[0], path.join(self.build_folder, dist_folder))

def layout(self):
cmake_layout(self)
Expand All @@ -160,13 +176,38 @@ def build(self):
cmake.configure()
cmake.build()

if self.options.get_safe("enable_sentry", False):
# Upload debug symbols to sentry
sentry_project = self.conf.get("user.curaengine:sentry_project", "", check_type=str)
sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str)
if sentry_project == "" or sentry_org == "":
raise ConanInvalidConfiguration("sentry_project or sentry_org is not set")

if which("sentry-cli") is None:
self.output.warn("sentry-cli is not installed, skipping uploading debug symbols")
self.output.warn("sentry-cli is not installed, skipping release creation")
else:
if self.settings.os == "Linux":
self.output.info("Stripping debug symbols from binary")
self.run("objcopy --only-keep-debug --compress-debug-sections=zlib CuraEngine CuraEngine.debug")
self.run("objcopy --strip-debug --strip-unneeded CuraEngine")
self.run("objcopy --add-gnu-debuglink=CuraEngine.debug CuraEngine")

self.output.info("Uploading debug symbols to sentry")
build_source_dir = self.build_path.parent.parent.as_posix()
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}")

# create a sentry release and link it to the commit this is based upon
self.output.info(f"Creating a new release {self.version} in Sentry and linking it to the current commit {self.conan_data['commit']}")
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} releases new -o {sentry_org} -p {sentry_project} {self.version}")
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} releases set-commits -o {sentry_org} -p {sentry_project} --commit \"Ultimaker/CuraEngine@{self.conan_data['commit']}\" {self.version}")
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} releases finalize -o {sentry_org} -p {sentry_project} {self.version}")

def package(self):
ext = ".exe" if self.settings.os == "Windows" else ""
copy(self, f"CuraEngine{ext}", src=self.build_folder, dst=path.join(self.package_folder, "bin"))
copy(self, f"_CuraEngine.*", src=self.build_folder, dst=path.join(self.package_folder, "lib"))
copy(self, "LICENSE*", src=self.source_folder, dst=path.join(self.package_folder, "license"))
if self.settings.os == "Windows" and self.settings.build_type == "RelWithDebInfo":
copy(self, "CuraEngine.pdb", src=self.build_folder, dst=path.join(self.package_folder, "bin"))

def package_info(self):
ext = ".exe" if self.settings.os == "Windows" else ""
Expand Down
14 changes: 9 additions & 5 deletions include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Ultimaker B.V.
// Copyright (c) 2024 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef INSET_ORDER_OPTIMIZER_H
Expand Down Expand Up @@ -43,8 +43,10 @@ class InsetOrderOptimizer
LayerPlan& gcode_layer,
const Settings& settings,
const int extruder_nr,
const GCodePathConfig& inset_0_non_bridge_config,
const GCodePathConfig& inset_X_non_bridge_config,
const GCodePathConfig& inset_0_default_config,
const GCodePathConfig& inset_X_default_config,
const GCodePathConfig& inset_0_roofing_config,
const GCodePathConfig& inset_X_roofing_config,
const GCodePathConfig& inset_0_bridge_config,
const GCodePathConfig& inset_X_bridge_config,
const bool retract_before_outer_wall,
Expand Down Expand Up @@ -90,8 +92,10 @@ class InsetOrderOptimizer
LayerPlan& gcode_layer_;
const Settings& settings_;
const size_t extruder_nr_;
const GCodePathConfig& inset_0_non_bridge_config_;
const GCodePathConfig& inset_X_non_bridge_config_;
const GCodePathConfig& inset_0_default_config_;
const GCodePathConfig& inset_X_default_config_;
const GCodePathConfig& inset_0_roofing_config_;
const GCodePathConfig& inset_X_roofing_config_;
const GCodePathConfig& inset_0_bridge_config_;
const GCodePathConfig& inset_X_bridge_config_;
const bool retract_before_outer_wall_;
Expand Down
Loading

0 comments on commit e5d0b4a

Please sign in to comment.