Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into CURA-11360_test_wagyu…
Browse files Browse the repository at this point in the history
…_fix__dont_merge
  • Loading branch information
rburema committed Dec 7, 2023
2 parents 9eda366 + 92cea65 commit 12d8d1c
Show file tree
Hide file tree
Showing 113 changed files with 22,873 additions and 62 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/unit-test-post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: unit-test-post

on:
workflow_run:
workflows: [ "unit-test" ]
types: [ completed ]

jobs:
# FIXME: Use `main` instead of `CURA-10831` once merged
publish-test-results:
uses: ultimaker/cura-workflows/.github/workflows/unit-test-post.yml@CURA-10831
with:
event: ${{ github.event.workflow_run.event }}
conclusion: ${{ github.event.workflow_run.conclusion }}
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ option(ENABLE_BENCHMARKS "Build with Benchmarks" OFF)
option(EXTENSIVE_WARNINGS "Build with all warnings" ON)
option(ENABLE_PLUGINS "Build with plugins" ON)
option(ENABLE_REMOTE_PLUGINS "Build with all warnings" OFF)
option(ENABLE_SENTRY "Send crash data via Sentry" OFF)
option(ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS "Enable more optimization flags" ON)
option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF)
option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF)
Expand Down Expand Up @@ -201,6 +202,10 @@ find_package(range-v3 REQUIRED)
find_package(scripta REQUIRED)
find_package(semver REQUIRED)

if (ENABLE_SENTRY)
find_package(sentry REQUIRED)
endif ()

if (ENABLE_TESTING)
find_package(GTest REQUIRED)
endif ()
Expand Down Expand Up @@ -238,8 +243,14 @@ else ()
endif (NOT WIN32)

use_threads(CuraEngine)
target_link_libraries(CuraEngine PRIVATE _CuraEngine)
target_compile_definitions(CuraEngine PRIVATE VERSION=\"${CURA_ENGINE_VERSION}\")
target_link_libraries(CuraEngine PRIVATE
_CuraEngine
$<$<BOOL:${ENABLE_SENTRY}>:sentry::sentry>
)
target_compile_definitions(CuraEngine PRIVATE
$<$<BOOL:${ENABLE_SENTRY}>:SENTRY_URL=\"${SENTRY_URL}\">
VERSION=\"${CURA_ENGINE_VERSION}\"
)

# Compiling the test environment.
if (ENABLE_TESTING OR ENABLE_BENCHMARKS)
Expand Down
15 changes: 13 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from conan.tools.files import copy, mkdir
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


required_conan_version = ">=1.58.0 <2.0.0"

Expand All @@ -28,19 +29,22 @@ class CuraEngineConan(ConanFile):
"enable_benchmarks": [True, False],
"enable_extensive_warnings": [True, False],
"enable_plugins": [True, False],
"enable_sentry": [True, False],
"enable_remote_plugins": [True, False],
}
default_options = {
"enable_arcus": True,
"enable_benchmarks": False,
"enable_extensive_warnings": False,
"enable_plugins": True,
"enable_sentry": False,
"enable_remote_plugins": False,
}

def set_version(self):
if not self.version:
self.version = "5.7.0-alpha"
git = Git(self)
self.version = f"5.7.0-alpha+{git.get_commit()[:6]}"

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand All @@ -57,6 +61,8 @@ def export_sources(self):
def config_options(self):
if not self.options.enable_plugins:
del self.options.enable_remote_plugins
if self.conf.get("user.curaengine:sentry_url", "", check_type=str) == "":
del self.options.enable_sentry

def configure(self):
self.options["boost"].header_only = True
Expand Down Expand Up @@ -85,6 +91,8 @@ def build_requirements(self):
def requirements(self):
if self.options.enable_arcus:
self.requires("arcus/5.3.0")
if self.options.get_safe("enable_sentry", False):
self.requires("sentry-native/0.6.5")
self.requires("asio-grpc/2.6.0")
self.requires("grpc/1.50.1")
self.requires("curaengine_grpc_definitions/(latest)@ultimaker/testing")
Expand Down Expand Up @@ -112,6 +120,9 @@ def generate(self):
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14"
if self.options.get_safe("enable_sentry", False):
tc.variables["ENABLE_SENTRY"] = True
tc.variables["SENTRY_URL"] = self.conf.get("user.curaengine:sentry_url", "", check_type=str)
if self.options.enable_plugins:
tc.variables["ENABLE_PLUGINS"] = True
tc.variables["ENABLE_REMOTE_PLUGINS"] = self.options.enable_remote_plugins
Expand Down
47 changes: 47 additions & 0 deletions include/utils/format/filesystem_path.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2023 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H
#define CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H

#include <cstdlib>
#include <filesystem>

#include <fmt/core.h>

namespace fmt
{
template<>
struct formatter<std::filesystem::path> : formatter<string_view>
{
static std::string USERNAME;
static constexpr std::string_view OBFUSCATED_STRING = "*******";

[[nodiscard]] static std::string anonymizePath(const std::string& path)
{
std::string anonymized_path = path;
size_t pos = anonymized_path.find(USERNAME);
while (pos != std::string::npos)
{
anonymized_path.replace(pos, USERNAME.size(), OBFUSCATED_STRING);
pos = anonymized_path.find(USERNAME, pos + OBFUSCATED_STRING.size());
}
return anonymized_path;
}

template<typename FormatContext>
auto format(const std::filesystem::path& path, FormatContext& ctx)
{
return formatter<string_view>::format(anonymizePath(path.generic_string()), ctx);
}
};

#ifdef _WIN32
std::string fmt::formatter<std::filesystem::path>::USERNAME = std::getenv("USERNAME") != nullptr ? std::getenv("USERNAME") : "";
#else
std::string fmt::formatter<std::filesystem::path>::USERNAME = std::getenv("USER") != nullptr ? std::getenv("USER") : "";
#endif

} // namespace fmt

#endif // CURAENGINE_INCLUDE_UTILS_FORMAT_FILESYSTEM_PATH_H
2 changes: 1 addition & 1 deletion include/utils/polygonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class PolygonUtils
* \param max_dist2 The squared maximal allowed distance from the point to the nearest polygon.
* \return The index to the polygon onto which we have moved the point.
*/
static unsigned int moveInside(const Polygons& polygons, Point2LL& from, int distance = 0, int64_t max_dist2 = std::numeric_limits<int64_t>::max());
static size_t moveInside(const Polygons& polygons, Point2LL& from, int distance = 0, int64_t max_dist2 = std::numeric_limits<int64_t>::max());

/**
* \brief Moves the point \p from onto the nearest polygon or leaves the
Expand Down
17 changes: 9 additions & 8 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,8 +2283,8 @@ bool LayerPlan::writePathWithCoasting(

bool length_is_less_than_min_dist = true;

unsigned int acc_dist_idx_gt_coast_dist = NO_INDEX; // the index of the first point with accumulated_dist more than coasting_dist (= index into accumulated_dist_per_point)
// == the point printed BEFORE the start point for coasting
std::optional<size_t> acc_dist_idx_gt_coast_dist; // the index of the first point with accumulated_dist more than coasting_dist (= index into accumulated_dist_per_point)
// == the point printed BEFORE the start point for coasting

const Point2LL* last = &path.points[path.points.size() - 1];
for (unsigned int backward_point_idx = 1; backward_point_idx < path.points.size(); backward_point_idx++)
Expand All @@ -2294,7 +2294,7 @@ bool LayerPlan::writePathWithCoasting(
accumulated_dist += distance;
accumulated_dist_per_point.push_back(accumulated_dist);

if (acc_dist_idx_gt_coast_dist == NO_INDEX && accumulated_dist >= coasting_dist)
if (! acc_dist_idx_gt_coast_dist.has_value() && accumulated_dist >= coasting_dist)
{
acc_dist_idx_gt_coast_dist = backward_point_idx; // the newly added point
}
Expand All @@ -2321,22 +2321,23 @@ bool LayerPlan::writePathWithCoasting(
{
return false; // Skip coasting at all then.
}
for (acc_dist_idx_gt_coast_dist = 1; acc_dist_idx_gt_coast_dist < accumulated_dist_per_point.size(); acc_dist_idx_gt_coast_dist++)
for (acc_dist_idx_gt_coast_dist = 1; acc_dist_idx_gt_coast_dist.value() < accumulated_dist_per_point.size(); acc_dist_idx_gt_coast_dist.value()++)
{ // search for the correct coast_dist_idx
if (accumulated_dist_per_point[acc_dist_idx_gt_coast_dist] >= actual_coasting_dist)
if (accumulated_dist_per_point[acc_dist_idx_gt_coast_dist.value()] >= actual_coasting_dist)
{
break;
}
}
}

assert(acc_dist_idx_gt_coast_dist < accumulated_dist_per_point.size()); // something has gone wrong; coasting_min_dist < coasting_dist ?
assert(
acc_dist_idx_gt_coast_dist.has_value() && acc_dist_idx_gt_coast_dist < accumulated_dist_per_point.size()); // something has gone wrong; coasting_min_dist < coasting_dist ?

const size_t point_idx_before_start = path.points.size() - 1 - acc_dist_idx_gt_coast_dist;
const size_t point_idx_before_start = path.points.size() - 1 - acc_dist_idx_gt_coast_dist.value();

Point2LL start;
{ // computation of begin point of coasting
const coord_t residual_dist = actual_coasting_dist - accumulated_dist_per_point[acc_dist_idx_gt_coast_dist - 1];
const coord_t residual_dist = actual_coasting_dist - accumulated_dist_per_point[acc_dist_idx_gt_coast_dist.value() - 1];
const Point2LL& a = path.points[point_idx_before_start];
const Point2LL& b = path.points[point_idx_before_start + 1];
start = b + normal(a - b, residual_dist);
Expand Down
4 changes: 3 additions & 1 deletion src/gcodeExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,9 @@ void GCodeExport::writeFanCommand(double speed)
else if (speed > 0)
{
const bool should_scale_zero_to_one = Application::getInstance().current_slice_->scene.settings.get<bool>("machine_scale_fan_speed_zero_to_one");
*output_stream_ << "M106 S" << PrecisionedDouble{ (should_scale_zero_to_one ? 2u : 1u), (should_scale_zero_to_one ? speed : speed * 255) / 100 };
*output_stream_ << "M106 S"
<< PrecisionedDouble{ (should_scale_zero_to_one ? static_cast<uint8_t>(2) : static_cast<uint8_t>(1)),
(should_scale_zero_to_one ? speed : speed * 255) / 100 };
if (fan_number_)
{
*output_stream_ << " P" << fan_number_;
Expand Down
76 changes: 75 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Ultimaker B.V.
// Copyright (c) 2023 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#include <iostream> //To change the formatting of std::cerr.
Expand All @@ -7,6 +7,19 @@
#include <sys/resource.h> //For setpriority.
#endif

#ifdef SENTRY_URL
#include <filesystem>
#include <semver.hpp>
#include <sentry.h>
#include <string>

#include <range/v3/algorithm/contains.hpp>
#include <range/v3/range/conversion.hpp>

#include "utils/format/filesystem_path.h"
#endif
#include <cstdlib>

#include <spdlog/spdlog.h>

#include "Application.h"
Expand Down Expand Up @@ -37,7 +50,68 @@ int main(int argc, char** argv)
#endif
std::cerr << std::boolalpha;


// Want to set the sentry URL? Use '-c user.curaengine:sentry_url=<url> -o curaengine:enable_sentry=True' with conan install
#ifdef SENTRY_URL
bool use_sentry = true;
if (const char* use_sentry_env = std::getenv("use_sentry"))
{
if (std::strcmp(use_sentry_env, "0") == 0)
{
use_sentry = false;
}
}
if (use_sentry)
{
// Setup sentry error handling.
sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, std::string(SENTRY_URL).c_str());
spdlog::info("Sentry url: {}", std::string(SENTRY_URL).c_str());
// This is also the default-path. For further information and recommendations:
// https://docs.sentry.io/platforms/native/configuration/options/#database-path
#if defined(__linux__)
const auto config_path = std::filesystem::path(fmt::format("{}/.local/share/cura/.sentry-native", std::getenv("HOME")));
#elif defined(__APPLE__) && defined(__MACH__)
const auto config_path = std::filesystem::path(fmt::format("{}/Library/Application Support/cura/.sentry-native", std::getenv("HOME")));
#elif defined(_WIN64)
const auto config_path = std::filesystem::path(fmt::format("{}\\cura\\.sentry-native", std::getenv("APPDATA")));
#endif
spdlog::info("Sentry config path: {}", config_path);
sentry_options_set_database_path(options, std::filesystem::absolute(config_path).generic_string().c_str());
constexpr std::string_view cura_engine_version{ CURA_ENGINE_VERSION };
const auto version = semver::from_string(cura_engine_version.substr(0, cura_engine_version.find_first_of('+')));
if (ranges::contains(cura_engine_version, '+') || version.prerelease_type == semver::prerelease::alpha)
{
// Not a production build
sentry_options_set_environment(options, "development");
sentry_options_set_release(
options,
fmt::format(
"curaengine@{}.{}.{}-{}.{}",
version.major,
version.minor,
version.patch,
version.prerelease_type == semver::prerelease::alpha ? "alpha" : "beta",
version.prerelease_number)
.c_str());
}
else
{
sentry_options_set_environment(options, "production");
sentry_options_set_release(options, fmt::format("curaengine@{}", version.to_string()).c_str());
}
sentry_init(options);
}
#endif

cura::Application::getInstance().run(argc, argv);

#ifdef SENTRY_URL
if (use_sentry)
{
sentry_close();
}
#endif

return 0;
}
6 changes: 3 additions & 3 deletions src/utils/polygonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ ClosestPolygonPoint PolygonUtils::_moveInside2(const ClosestPolygonPoint& closes
/*
* Implementation assumes moving inside, but moving outside should just as well be possible.
*/
unsigned int PolygonUtils::moveInside(const Polygons& polygons, Point2LL& from, int distance, int64_t maxDist2)
size_t PolygonUtils::moveInside(const Polygons& polygons, Point2LL& from, int distance, int64_t maxDist2)
{
Point2LL ret = from;
int64_t bestDist2 = std::numeric_limits<int64_t>::max();
unsigned int bestPoly = NO_INDEX;
size_t bestPoly = NO_INDEX;
bool is_already_on_correct_side_of_boundary = false; // whether [from] is already on the right side of the boundary
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
for (size_t poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
ConstPolygonRef poly = polygons[poly_idx];
if (poly.size() < 2)
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/001.settings
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ mesh_position_y=0
infill_randomize_start_location=False
raft_base_jerk=12.5
speed_wall_x=65
time=17:54:18
machine_buildplate_type=glass
machine_nozzle_head_distance=3
support_brim_width=1.2000000000000002
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/002.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=12.5
support_brim_width=4
top_bottom_thickness=0.8
raft_jerk=8
time=18:43:21
machine_buildplate_type=glass
center_object=False
speed_print=50.0
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/003.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=12.5
support_brim_width=4
top_bottom_thickness=0.84
raft_jerk=8
time=18:49:06
machine_buildplate_type=glass
center_object=False
speed_print=50.0
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/004.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=12.5
support_brim_width=4
top_bottom_thickness=0.8
raft_jerk=8
time=18:50:45
machine_buildplate_type=glass
center_object=False
speed_print=50.0
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/005.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=12.5
support_brim_width=4
top_bottom_thickness=0.8
raft_jerk=8
time=18:54:59
machine_buildplate_type=glass
center_object=False
speed_print=50.0
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/006.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=12.5
support_brim_width=4
top_bottom_thickness=0.8
raft_jerk=8
time=18:56:12
machine_buildplate_type=glass
center_object=False
speed_print=50.0
Expand Down
1 change: 0 additions & 1 deletion stress_benchmark/resources/007.settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ bridge_skin_speed_2=20.0
support_brim_width=4
top_bottom_thickness=0.8
raft_jerk=8
time=19:00:31
machine_buildplate_type=glass
center_object=False
speed_print=80.0
Expand Down
Loading

0 comments on commit 12d8d1c

Please sign in to comment.