mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-29 03:41:31 +00:00
Merge branch 'main' into feature/add-multi-variant
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
name: Daily OFL OTA Update
|
name: Daily OFL OTA Update
|
||||||
|
|
||||||
|
run-name: Daily OFL OTA Update [OFL barrier]
|
||||||
|
|
||||||
# This workflow is intended for creating and publishing the OrcaFilamentLibrary (OFL) OPC package to
|
# This workflow is intended for creating and publishing the OrcaFilamentLibrary (OFL) OPC package to
|
||||||
# https://github.com/OrcaSlicer/orcaslicer-profiles, which generates an OTA update.
|
# https://github.com/OrcaSlicer/orcaslicer-profiles, which generates an OTA update.
|
||||||
# This cronjob runs daily at 00:00 UTC every day and scans main plus every release/vX.Y.Z branch for
|
# This cronjob runs daily at 00:00 UTC every day and scans main plus every release/vX.Y.Z branch for
|
||||||
@@ -12,9 +14,9 @@ name: Daily OFL OTA Update
|
|||||||
# vendor-dispatch path is also what makes post_merge_profiles.yml call the OTA auto-publish API after
|
# vendor-dispatch path is also what makes post_merge_profiles.yml call the OTA auto-publish API after
|
||||||
# uploading - see post_merge_profiles.yml for both sides of that contract.
|
# uploading - see post_merge_profiles.yml for both sides of that contract.
|
||||||
#
|
#
|
||||||
# At the start of each run, the pending-publish table is cleared up to a captured
|
# Each run captures a timestamp, dispatches the needed OFL publishers, waits for
|
||||||
# timestamp (POST /api/v1/ota/ofl/pending/clear?timestamp=...). Changes merged after
|
# all of them to finish, then clears the pending-publish table once. Changes merged
|
||||||
# that timestamp remain pending for the next run.
|
# after that timestamp remain pending for the next run.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -34,32 +36,14 @@ jobs:
|
|||||||
if: ${{ github.repository == 'OrcaSlicer/OrcaSlicer' }}
|
if: ${{ github.repository == 'OrcaSlicer/OrcaSlicer' }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Capture start timestamp and clear OFL pending queue
|
- name: Capture start timestamp
|
||||||
id: start
|
id: start
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
|
||||||
OTA_API_BASE_URL: ${{ vars.OTA_API_BASE_URL }}
|
|
||||||
OTA_API_KEY: ${{ secrets.OFL_OTA_PUBLISH_KEY }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
[ -n "$OTA_API_BASE_URL" ] || { echo "::error::vars.OTA_API_BASE_URL is not set"; exit 1; }
|
|
||||||
[ -n "$OTA_API_KEY" ] || { echo "::error::secrets.OFL_OTA_PUBLISH_KEY is not set"; exit 1; }
|
|
||||||
|
|
||||||
timestamp="$(date -u +%s)"
|
timestamp="$(date -u +%s)"
|
||||||
echo "timestamp=$timestamp" >> "$GITHUB_OUTPUT"
|
echo "timestamp=$timestamp" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
resp_file="$RUNNER_TEMP/ota-pending-clear-response.json"
|
|
||||||
status="$(curl -sS -o "$resp_file" -w '%{http_code}' -X POST \
|
|
||||||
"${OTA_API_BASE_URL%/}/api/v1/ota/ofl/pending/clear?timestamp=$timestamp" \
|
|
||||||
-H "Authorization: Bearer $OTA_API_KEY")"
|
|
||||||
body="$(cat "$resp_file")"
|
|
||||||
echo "$body"
|
|
||||||
|
|
||||||
if [ "$status" != "200" ]; then
|
|
||||||
echo "::error::OTA pending-clear call failed with HTTP $status"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
@@ -84,27 +68,21 @@ jobs:
|
|||||||
| grep -E '^(main|release/v[0-9]+\.[0-9]+\.[0-9]+)$' | sort -u
|
| grep -E '^(main|release/v[0-9]+\.[0-9]+\.[0-9]+)$' | sort -u
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The cron run is the checkpoint: a successful run means every
|
||||||
|
# dispatched branch publisher completed and the pending queue was
|
||||||
|
# cleared. Manual or push-triggered post_merge_profiles runs are not
|
||||||
|
# checkpoints for this scan.
|
||||||
|
successful_cron_runs="$(gh api --method GET \
|
||||||
|
"repos/${{ github.repository }}/actions/workflows/ofl-ota-cronjob.yml/runs" \
|
||||||
|
-f status=success -f branch=main -f per_page=100 --paginate \
|
||||||
|
--jq '.workflow_runs[] | select((.display_title // "") | contains("[OFL barrier]"))')"
|
||||||
|
since="$(jq -rs 'sort_by(.run_started_at) | last.run_started_at // empty' <<< "$successful_cron_runs")"
|
||||||
|
|
||||||
for branch in "${branches[@]}"; do
|
for branch in "${branches[@]}"; do
|
||||||
echo "::group::$branch"
|
echo "::group::$branch"
|
||||||
|
|
||||||
# post_merge_profiles.yml's own run history, not this workflow's: this
|
|
||||||
# workflow only ever runs against main (schedule, or workflow_dispatch
|
|
||||||
# --ref main), so its head branch never varies - filtering ITS history
|
|
||||||
# by $branch would never match anything except main. post_merge_profiles.yml
|
|
||||||
# genuinely runs per-branch (this dispatch below sets --ref "$branch"),
|
|
||||||
# so its history is the real per-branch checkpoint. It also means a
|
|
||||||
# failed publish naturally gets retried tomorrow: the checkpoint only
|
|
||||||
# advances on a run that actually succeeded.
|
|
||||||
# --method GET is required, not cosmetic: gh api defaults to POST
|
|
||||||
# whenever -f fields are present unless a method is given
|
|
||||||
# explicitly, and POST on this list-runs endpoint 404s - confirmed
|
|
||||||
# on real Actions infrastructure, not just reasoned about.
|
|
||||||
since="$(gh api --method GET "repos/${{ github.repository }}/actions/workflows/post_merge_profiles.yml/runs" \
|
|
||||||
-f status=success -f branch="$branch" -f per_page=1 \
|
|
||||||
--jq '.workflow_runs[0].run_started_at // empty')"
|
|
||||||
|
|
||||||
if [ -z "$since" ]; then
|
if [ -z "$since" ]; then
|
||||||
echo "No prior successful run for $branch; checking OFL changes up to $SCAN_UNTIL."
|
echo "No prior successful OFL cron run; checking $branch through $SCAN_UNTIL."
|
||||||
changed_files="$(git log --until="$SCAN_UNTIL" --name-only --pretty=format: "origin/$branch" -- \
|
changed_files="$(git log --until="$SCAN_UNTIL" --name-only --pretty=format: "origin/$branch" -- \
|
||||||
resources/profiles/OrcaFilamentLibrary resources/profiles/OrcaFilamentLibrary.json \
|
resources/profiles/OrcaFilamentLibrary resources/profiles/OrcaFilamentLibrary.json \
|
||||||
| sed '/^$/d')"
|
| sed '/^$/d')"
|
||||||
@@ -124,16 +102,98 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$changed" = true ]; then
|
if [ "$changed" = true ]; then
|
||||||
# Tolerate a per-branch failure (e.g. a pre-existing release branch
|
dispatch_id="${GITHUB_RUN_ID}-${branch//\//-}"
|
||||||
# whose post_merge_profiles.yml predates the vendor/auto_publish
|
# Record successful dispatches for the barrier step below.
|
||||||
# inputs) rather than aborting the whole scan under set -e.
|
# Branches whose workflow predates workflow_dispatch are skipped
|
||||||
if ! gh workflow run post_merge_profiles.yml \
|
# with a warning, as they were before the barrier was added.
|
||||||
|
if gh workflow run post_merge_profiles.yml \
|
||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--ref "$branch" \
|
--ref "$branch" \
|
||||||
-f vendor="$VENDOR" -f auto_publish=true; then
|
-f vendor="$VENDOR" -f auto_publish=true \
|
||||||
echo "::warning::failed to dispatch post_merge_profiles.yml for $branch - its post_merge_profiles.yml at this ref may predate the vendor/auto_publish inputs"
|
-f ofl_cron_dispatch_id="$dispatch_id"; then
|
||||||
|
printf '%s\t%s\n' "$branch" "$dispatch_id" >> "$RUNNER_TEMP/ofl-dispatches.tsv"
|
||||||
|
else
|
||||||
|
echo "::warning::skipping $branch because post_merge_profiles.yml could not be dispatched at that ref"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
- name: Wait for OFL publishers
|
||||||
|
id: wait
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
DISPATCHES_FILE: ${{ runner.temp }}/ofl-dispatches.tsv
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ ! -s "$DISPATCHES_FILE" ]; then
|
||||||
|
echo "No OFL publisher workflows were dispatched; pending queue will not be cleared."
|
||||||
|
echo "publishers_dispatched=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
: > "$RUNNER_TEMP/ofl-run-ids.tsv"
|
||||||
|
while IFS=$'\t' read -r branch dispatch_id; do
|
||||||
|
[ -n "$branch" ] || continue
|
||||||
|
echo "Waiting for OFL publisher on $branch ($dispatch_id)"
|
||||||
|
|
||||||
|
run_id=""
|
||||||
|
for _ in {1..120}; do
|
||||||
|
runs_json="$(gh api --method GET \
|
||||||
|
"repos/${{ github.repository }}/actions/workflows/post_merge_profiles.yml/runs" \
|
||||||
|
-f branch="$branch" -f event=workflow_dispatch -f per_page=100)"
|
||||||
|
run_id="$(jq -r --arg marker "[OFL cron $dispatch_id]" \
|
||||||
|
'[.workflow_runs[] | select((.display_title // "") | contains($marker))] \
|
||||||
|
| sort_by(.created_at) | last | .id // empty' <<< "$runs_json")"
|
||||||
|
[ -n "$run_id" ] && break
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$run_id" ]; then
|
||||||
|
echo "::error::could not find dispatched post_merge_profiles run for $branch ($dispatch_id)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf '%s\t%s\n' "$branch" "$run_id" >> "$RUNNER_TEMP/ofl-run-ids.tsv"
|
||||||
|
done < "$DISPATCHES_FILE"
|
||||||
|
|
||||||
|
all_success=true
|
||||||
|
while IFS=$'\t' read -r branch run_id; do
|
||||||
|
[ -n "$run_id" ] || continue
|
||||||
|
echo "Watching OFL publisher run $run_id for $branch"
|
||||||
|
if ! gh run watch "$run_id" --repo "${{ github.repository }}" --exit-status; then
|
||||||
|
all_success=false
|
||||||
|
fi
|
||||||
|
done < "$RUNNER_TEMP/ofl-run-ids.tsv"
|
||||||
|
|
||||||
|
if [ "$all_success" != true ]; then
|
||||||
|
echo "::error::one or more OFL publisher workflows failed; pending queue will not be cleared"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "publishers_dispatched=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Clear OFL pending queue
|
||||||
|
if: steps.wait.outputs.publishers_dispatched == 'true'
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
OTA_API_BASE_URL: ${{ vars.OTA_API_BASE_URL }}
|
||||||
|
OTA_API_KEY: ${{ secrets.OFL_OTA_PUBLISH_KEY }}
|
||||||
|
TIMESTAMP: ${{ steps.start.outputs.timestamp }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
[ -n "$OTA_API_BASE_URL" ] || { echo "::error::vars.OTA_API_BASE_URL is not set"; exit 1; }
|
||||||
|
[ -n "$OTA_API_KEY" ] || { echo "::error::secrets.OFL_OTA_PUBLISH_KEY is not set"; exit 1; }
|
||||||
|
|
||||||
|
resp_file="$RUNNER_TEMP/ota-pending-clear-response.json"
|
||||||
|
status="$(curl -sS -o "$resp_file" -w '%{http_code}' -X POST \
|
||||||
|
"${OTA_API_BASE_URL%/}/api/v1/ota/ofl/pending/clear?timestamp=$TIMESTAMP" \
|
||||||
|
-H "Authorization: Bearer $OTA_API_KEY")"
|
||||||
|
body="$(cat "$resp_file")"
|
||||||
|
echo "$body"
|
||||||
|
|
||||||
|
if [ "$status" != "200" ]; then
|
||||||
|
echo "::error::OTA pending-clear call failed with HTTP $status"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
name: Post-merge profiles
|
name: Post-merge profiles
|
||||||
|
|
||||||
|
run-name: >-
|
||||||
|
Post-merge profiles${{
|
||||||
|
inputs.ofl_cron_dispatch_id != '' &&
|
||||||
|
inputs.vendor == 'OrcaFilamentLibrary' &&
|
||||||
|
(inputs.auto_publish == true || inputs.auto_publish == 'true') &&
|
||||||
|
format(' [OFL cron {0}]', inputs.ofl_cron_dispatch_id) ||
|
||||||
|
''
|
||||||
|
}}
|
||||||
|
|
||||||
# Push-triggered counterpart to check_profiles.yml (which only gates PRs). When a
|
# Push-triggered counterpart to check_profiles.yml (which only gates PRs). When a
|
||||||
# profile change lands on main or a release branch, rebuild the affected vendors'
|
# profile change lands on main or a release branch, rebuild the affected vendors'
|
||||||
# binary preset caches (<vendor>.opc) and publish each as a versioned ZIP asset on
|
# binary preset caches (<vendor>.opc) and publish each as a versioned ZIP asset on
|
||||||
@@ -59,6 +68,12 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
ofl_cron_dispatch_id:
|
||||||
|
description: >-
|
||||||
|
Unique marker supplied by the trusted OFL daily cron so it can find
|
||||||
|
and wait for this dispatched workflow run.
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"filament_id": "OFvgE0Zh",
|
"filament_id": "OFvgE0Zh",
|
||||||
"instantiation": "false",
|
"instantiation": "false",
|
||||||
"fan_cooling_layer_time": [
|
"fan_cooling_layer_time": [
|
||||||
"80"
|
"81"
|
||||||
],
|
],
|
||||||
"fan_min_speed": [
|
"fan_min_speed": [
|
||||||
"50"
|
"50"
|
||||||
|
|||||||
@@ -2673,10 +2673,10 @@ void CadDocument::apply_feature(TopoDS_Shape& result, bool& have_body,
|
|||||||
ridge = pipe.Shape();
|
ridge = pipe.Shape();
|
||||||
have_ridge = !ridge.IsNull();
|
have_ridge = !ridge.IsNull();
|
||||||
}
|
}
|
||||||
|
} catch (const Standard_Failure&) {
|
||||||
|
have_ridge = false; // OCCT failure — on OCCT >= 8 Standard_Failure derives from std::exception, so this handler must come first
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
have_ridge = false; // fall back to the bare cylinder/bore below
|
have_ridge = false; // fall back to the bare cylinder/bore below
|
||||||
} catch (const Standard_Failure&) {
|
|
||||||
have_ridge = false; // OCCT failure (not a std::exception) — must be caught here too
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f.thread_internal) {
|
if (f.thread_internal) {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopTools.hxx>
|
#include <TopTools.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
#include <Poly_Triangulation.hxx>
|
#include <Poly_Triangulation.hxx>
|
||||||
#include <gp_Ax2.hxx>
|
#include <gp_Ax2.hxx>
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "XCAFDoc_DocumentTool.hxx"
|
#include "XCAFDoc_DocumentTool.hxx"
|
||||||
#include "XCAFDoc_ShapeTool.hxx"
|
#include "XCAFDoc_ShapeTool.hxx"
|
||||||
#include "XCAFApp_Application.hxx"
|
#include "XCAFApp_Application.hxx"
|
||||||
|
#include "TDF_LabelSequence.hxx"
|
||||||
#include "TopoDS_Solid.hxx"
|
#include "TopoDS_Solid.hxx"
|
||||||
#include "TopoDS_Compound.hxx"
|
#include "TopoDS_Compound.hxx"
|
||||||
#include "TopoDS_Builder.hxx"
|
#include "TopoDS_Builder.hxx"
|
||||||
|
|||||||
+28
-23
@@ -7969,6 +7969,20 @@ double GCode::calc_max_volumetric_speed(const double layer_height, const double
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ORCA: Overlap at or below which the overhang fan switches on; negative when it does not depend on overlap
|
||||||
|
// (Overhang_threshold_none cools every external perimeter).
|
||||||
|
static float overhang_fan_overlap_threshold(int overhang_fan_threshold)
|
||||||
|
{
|
||||||
|
switch (overhang_fan_threshold) {
|
||||||
|
case (int) Overhang_threshold_1_4: return 0.9f;
|
||||||
|
case (int) Overhang_threshold_2_4: return 0.75f;
|
||||||
|
case (int) Overhang_threshold_3_4: return 0.5f;
|
||||||
|
case (int) Overhang_threshold_4_4: return 0.25f;
|
||||||
|
case (int) Overhang_threshold_bridge: return 0.05f;
|
||||||
|
default: return -1.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed)
|
std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed)
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
@@ -8311,6 +8325,13 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
|
|
||||||
ConfigOptionPercents overhang_overlap_levels({90, 75, 50, 25, 13, 0});
|
ConfigOptionPercents overhang_overlap_levels({90, 75, 50, 25, 13, 0});
|
||||||
|
|
||||||
|
// ORCA: Lets the path be split where the overhang fan switches, not only where the speed changes.
|
||||||
|
// Bridges and overhang perimeters are cooled regardless of overlap.
|
||||||
|
float fan_overlap_threshold = -1.f;
|
||||||
|
if (FILAMENT_CONFIG(enable_overhang_bridge_fan) && m_enable_cooling_markers && path.role() != erBridgeInfill &&
|
||||||
|
path.role() != erOverhangPerimeter)
|
||||||
|
fan_overlap_threshold = overhang_fan_overlap_threshold(FILAMENT_CONFIG(overhang_fan_threshold));
|
||||||
|
|
||||||
if (NOZZLE_CONFIG(slowdown_for_curled_perimeters)){
|
if (NOZZLE_CONFIG(slowdown_for_curled_perimeters)){
|
||||||
ConfigOptionFloatsOrPercents dynamic_overhang_speeds(
|
ConfigOptionFloatsOrPercents dynamic_overhang_speeds(
|
||||||
{FloatOrPercent{100, true},
|
{FloatOrPercent{100, true},
|
||||||
@@ -8331,7 +8352,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
FloatOrPercent{NOZZLE_CONFIG(overhang_4_4_speed).get_abs_value(ref_speed) * 100 / ref_speed, true}});
|
FloatOrPercent{NOZZLE_CONFIG(overhang_4_4_speed).get_abs_value(ref_speed) * 100 / ref_speed, true}});
|
||||||
|
|
||||||
new_points = m_extrusion_quality_estimator.estimate_extrusion_quality(path, overhang_overlap_levels, dynamic_overhang_speeds,
|
new_points = m_extrusion_quality_estimator.estimate_extrusion_quality(path, overhang_overlap_levels, dynamic_overhang_speeds,
|
||||||
ref_speed, speed, NOZZLE_CONFIG(slowdown_for_curled_perimeters));
|
ref_speed, speed, NOZZLE_CONFIG(slowdown_for_curled_perimeters),
|
||||||
|
fan_overlap_threshold);
|
||||||
}else{
|
}else{
|
||||||
ConfigOptionFloatsOrPercents dynamic_overhang_speeds(
|
ConfigOptionFloatsOrPercents dynamic_overhang_speeds(
|
||||||
{FloatOrPercent{100, true},
|
{FloatOrPercent{100, true},
|
||||||
@@ -8350,7 +8372,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
FloatOrPercent{NOZZLE_CONFIG(bridge_speed) * 100 / ref_speed, true}});
|
FloatOrPercent{NOZZLE_CONFIG(bridge_speed) * 100 / ref_speed, true}});
|
||||||
|
|
||||||
new_points = m_extrusion_quality_estimator.estimate_extrusion_quality(path, overhang_overlap_levels, dynamic_overhang_speeds,
|
new_points = m_extrusion_quality_estimator.estimate_extrusion_quality(path, overhang_overlap_levels, dynamic_overhang_speeds,
|
||||||
ref_speed, speed, NOZZLE_CONFIG(slowdown_for_curled_perimeters));
|
ref_speed, speed, NOZZLE_CONFIG(slowdown_for_curled_perimeters),
|
||||||
|
fan_overlap_threshold);
|
||||||
}
|
}
|
||||||
variable_speed = std::any_of(new_points.begin(), new_points.end(),
|
variable_speed = std::any_of(new_points.begin(), new_points.end(),
|
||||||
[speed](const ProcessedPoint &p) { return fabs(double(p.speed) - speed) > 1; }); // Ignore small speed variations (under 1mm/sec)
|
[speed](const ProcessedPoint &p) { return fabs(double(p.speed) - speed) > 1; }); // Ignore small speed variations (under 1mm/sec)
|
||||||
@@ -8502,28 +8525,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
if (role == erBridgeInfill || role == erOverhangPerimeter) { // ORCA: Split out bridge infill to internal and external to apply separate fan settings
|
if (role == erBridgeInfill || role == erOverhangPerimeter) { // ORCA: Split out bridge infill to internal and external to apply separate fan settings
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch (overhang_fan_threshold) {
|
if (overhang_fan_threshold == Overhang_threshold_none)
|
||||||
case (int)Overhang_threshold_1_4:
|
|
||||||
return overlap <= 0.9f;
|
|
||||||
break;
|
|
||||||
case (int)Overhang_threshold_2_4:
|
|
||||||
return overlap <= 0.75f;
|
|
||||||
break;
|
|
||||||
case (int)Overhang_threshold_3_4:
|
|
||||||
return overlap <= 0.5f;
|
|
||||||
break;
|
|
||||||
case (int)Overhang_threshold_4_4:
|
|
||||||
return overlap <= 0.25f;
|
|
||||||
break;
|
|
||||||
case (int)Overhang_threshold_bridge:
|
|
||||||
return overlap <= 0.05f;
|
|
||||||
break;
|
|
||||||
case (int)Overhang_threshold_none:
|
|
||||||
return is_external_perimeter(role);
|
return is_external_perimeter(role);
|
||||||
break;
|
const float overlap_threshold = overhang_fan_overlap_threshold(overhang_fan_threshold);
|
||||||
default:
|
return overlap_threshold >= 0.f && overlap <= overlap_threshold;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string comment;
|
std::string comment;
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ std::vector<ExtendedPoint<L::Dim>> estimate_points_properties(const POINTS&
|
|||||||
float flow_width,
|
float flow_width,
|
||||||
float max_line_length = -1.0f,
|
float max_line_length = -1.0f,
|
||||||
float min_distance = -1.0f,
|
float min_distance = -1.0f,
|
||||||
// Maps an overhang distance onto the speed it will be printed at. Interior sampling
|
// Speed an overhang distance prints at. Without it, interior sampling
|
||||||
// needs it to tell which of the points it could add would change the G-code, and is
|
// is skipped and every line over 4mm is split.
|
||||||
// skipped without it.
|
const std::function<float(float)>& distance_to_speed = {},
|
||||||
const std::function<float(float)>& distance_to_speed = {})
|
// Overlap (1 - distance / flow_width) at or below which the overhang
|
||||||
|
// fan switches on; negative when the fan does not depend on overlap.
|
||||||
|
float fan_overlap_threshold = -1.0f)
|
||||||
{
|
{
|
||||||
bool looped = input_points.front() == input_points.back();
|
bool looped = input_points.front() == input_points.back();
|
||||||
std::function<size_t(size_t,size_t)> get_prev_index = [](size_t idx, size_t count) {
|
std::function<size_t(size_t,size_t)> get_prev_index = [](size_t idx, size_t count) {
|
||||||
@@ -125,29 +127,43 @@ std::vector<ExtendedPoint<L::Dim>> estimate_points_properties(const POINTS&
|
|||||||
points.push_back(next_point);
|
points.push_back(next_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ORCA: How an overhang distance prints, which is what the passes below compare. A segment is printed at the lower
|
||||||
|
// of the speeds at its two ends, and with the overhang fan on if the overlap at either end turns it on. A point
|
||||||
|
// added to a path can therefore only change the G-code where it prints at a different speed or fan state from the
|
||||||
|
// points either side of it, and the passes below add points there and nowhere else.
|
||||||
|
const float width_inv = 1.f / flow_width;
|
||||||
|
// Whether an overhang distance turns the overhang fan on. The overlap test check_overhang_fan applies in GCode.cpp.
|
||||||
|
auto fan_on = [fan_overlap_threshold, width_inv](float distance) {
|
||||||
|
return fan_overlap_threshold >= 0.f && 1.f - distance * width_inv <= fan_overlap_threshold;
|
||||||
|
};
|
||||||
|
// Whether two overhang distances are interchangeable ie have the same speed (beyond a 1mm/sec threshold that gcode.cpp filters out on)
|
||||||
|
// and the same fan state.
|
||||||
|
auto same_speed_and_fan = [&distance_to_speed, &fan_on](float a, float b) {
|
||||||
|
return std::abs(distance_to_speed(a) - distance_to_speed(b)) <= 1.f && fan_on(a) == fan_on(b);
|
||||||
|
};
|
||||||
|
// Whether the first overhang distance prints slower than the second, beyond the 1mm/sec gcode.cpp tolerance, or turns the overhang
|
||||||
|
// fan on where the second does not. Against a supported point (overhang distance 0) it tells whether an end is
|
||||||
|
// affected by the overhang.
|
||||||
|
auto slower_or_cooled = [&distance_to_speed, &fan_on](float a, float b) {
|
||||||
|
return distance_to_speed(a) < distance_to_speed(b) - 1.f || (fan_on(a) && !fan_on(b));
|
||||||
|
};
|
||||||
|
|
||||||
// ORCA: Interior sampling
|
// ORCA: Interior sampling
|
||||||
// The passes below infer the support under a span from its endpoints alone, so an interior that is supported
|
// The passes below infer the support under a span from its endpoints alone, so a part that is supported
|
||||||
// differently from both ends is invisible to them: the outer perimeter of an overhang whose ends are caged by
|
// differently from both ends is invisible to them. The outer perimeter of an overhang whose ends are supported by
|
||||||
// full height walls reads as supported along its whole length. Probe the interior, keep the samples the
|
// reads as supported along its whole length. Probe the interior, keep the samples the endpoint interpolation fails to predict,
|
||||||
// endpoint interpolation fails to predict, and bisect either side of each one, so a span that is only partly
|
// and bisect either side of each one, so a span that is only partly unsupported gets points where its support actually changes
|
||||||
// unsupported gets points where its support actually changes instead of one reading spread across all of it.
|
// instead of one reading being spread across all of it.
|
||||||
if (PREV_LAYER_BOUNDARY_OFFSET && ADD_INTERSECTIONS && min_distance > 0 && distance_to_speed) {
|
// Skipped where there is nothing to find: min_distance <= 0 when no overhang can slow this path down, and
|
||||||
|
// fan_overlap_threshold < 0 when no overhang switches the fan on. It also needs distance_to_speed to tell which of
|
||||||
|
// the points it could add would change the G-code.
|
||||||
|
if (PREV_LAYER_BOUNDARY_OFFSET && ADD_INTERSECTIONS && distance_to_speed && (min_distance > 0 || fan_overlap_threshold >= 0.f)) {
|
||||||
// Probe at least this densely before treating matching samples as evidence that a span is uniform. The
|
// Probe at least this densely before treating matching samples as evidence that a span is uniform. The
|
||||||
// segmentation pass below only splits lines of 2mm or more, and every pass here drops points closer
|
// segmentation pass below only splits lines of 2mm or more, and every pass here drops points closer
|
||||||
// together than min_spacing, so finer discovery would not produce a more precise speed transition.
|
// together than min_spacing, so finer discovery would not produce a more precise transition.
|
||||||
const double max_probe_spacing = std::max(2., 4. * min_spacing);
|
const double max_probe_spacing = std::max(2., 4. * min_spacing);
|
||||||
// A backstop for that length test, which on a non-finite length would never be met.
|
// A backstop for that length test, which on a non-finite length would never be met.
|
||||||
constexpr int max_bisection_depth = 10;
|
constexpr int max_bisection_depth = 10;
|
||||||
// Whether two readings are interchangeable. A segment is printed at the lower of the speeds its ends
|
|
||||||
// read, so a sample that agrees on speed with what is already known cannot change the G-code, whatever
|
|
||||||
// its distance says. The distances themselves are far too coarse a stand-in for this: the speed sections
|
|
||||||
// interpolate, so readings a small fraction of min_distance apart can still be tens of mm/s apart.
|
|
||||||
// The tolerance matches the one GCode.cpp applies when it decides a path has a variable speed at all.
|
|
||||||
auto same_speed = [&distance_to_speed](float a, float b) {
|
|
||||||
return std::abs(distance_to_speed(a) - distance_to_speed(b)) <= 1.f;
|
|
||||||
};
|
|
||||||
// Whether the first reading is printed slower than the second, once they are known to differ.
|
|
||||||
auto prints_slower = [&distance_to_speed](float a, float b) { return distance_to_speed(a) < distance_to_speed(b); };
|
|
||||||
|
|
||||||
// Part of a segment still to bisect: its positions along the segment and bisections left.
|
// Part of a segment still to bisect: its positions along the segment and bisections left.
|
||||||
struct Subspan { double t0, t1; int depth; };
|
struct Subspan { double t0, t1; int depth; };
|
||||||
@@ -185,8 +201,8 @@ std::vector<ExtendedPoint<L::Dim>> estimate_points_properties(const POINTS&
|
|||||||
if (!interior.empty()) {
|
if (!interior.empty()) {
|
||||||
std::sort(interior.begin(), interior.end(),
|
std::sort(interior.begin(), interior.end(),
|
||||||
[](const std::pair<double, float>& l, const std::pair<double, float>& r) { return l.first < r.first; });
|
[](const std::pair<double, float>& l, const std::pair<double, float>& r) { return l.first < r.first; });
|
||||||
// Coarse probing keeps every sample it took until this pass can see which ones bracket a speed
|
// Coarse probing keeps every sample it took until this pass can see which ones bracket a speed or
|
||||||
// transition. Matching samples cannot be discarded during discovery: one may be the last
|
// fan transition. Matching samples cannot be discarded during discovery: one may be the last
|
||||||
// supported point before a narrow unsupported pocket found by a later probe.
|
// supported point before a narrow unsupported pocket found by a later probe.
|
||||||
size_t kept = 0;
|
size_t kept = 0;
|
||||||
for (size_t i = 0; i < interior.size(); ++i) {
|
for (size_t i = 0; i < interior.size(); ++i) {
|
||||||
@@ -195,15 +211,15 @@ std::vector<ExtendedPoint<L::Dim>> estimate_points_properties(const POINTS&
|
|||||||
const bool at_end = i + 1 == interior.size(); // And nothing follows the last sample but the segment's end
|
const bool at_end = i + 1 == interior.size(); // And nothing follows the last sample but the segment's end
|
||||||
const float before = at_start ? curr.distance : interior[kept - 1].second;
|
const float before = at_start ? curr.distance : interior[kept - 1].second;
|
||||||
const float after = at_end ? next.distance : interior[i + 1].second;
|
const float after = at_end ? next.distance : interior[i + 1].second;
|
||||||
// A sample is worth a point in the path only where it prints at a different speed from the
|
// A sample is worth a point in the path only where it prints differently, in speed or fan state,
|
||||||
// readings either side of it. Differing from one of the segment's own ends is not enough on
|
// from the points either side of it. Differing from one of the segment's own ends is not enough on
|
||||||
// its own where the sample is the faster of the two: the segmentation pass below already
|
// its own where the sample is not the slower or cooled of the two: the segmentation pass below
|
||||||
// ends the slowdown an end reads, at a distance taken from how far out that end is rather
|
// already confines the slowdown and cooling at an end, at a distance taken from how far out that
|
||||||
// than from wherever bisection happened to stop, and a point here would leave the span
|
// end is rather than from wherever bisection happened to stop, and a point here would leave the
|
||||||
// beside the end too short for that pass to run at all. Support an end cannot account for,
|
// span beside the end too short for that pass to run at all. Support an end cannot account for,
|
||||||
// where the interior is the slower reading, is exactly what this pass is here to find.
|
// where the interior is the slower or cooled of the two, is exactly what this pass is here to find.
|
||||||
const bool worth_before = !same_speed(sample, before) && (!at_start || prints_slower(sample, before));
|
const bool worth_before = !same_speed_and_fan(sample, before) && (!at_start || slower_or_cooled(sample, before));
|
||||||
const bool worth_after = !same_speed(sample, after) && (!at_end || prints_slower(sample, after));
|
const bool worth_after = !same_speed_and_fan(sample, after) && (!at_end || slower_or_cooled(sample, after));
|
||||||
if (worth_before || worth_after)
|
if (worth_before || worth_after)
|
||||||
interior[kept++] = interior[i];
|
interior[kept++] = interior[i];
|
||||||
}
|
}
|
||||||
@@ -239,51 +255,59 @@ std::vector<ExtendedPoint<L::Dim>> estimate_points_properties(const POINTS&
|
|||||||
(next.distance > -boundary_offset && next.distance < boundary_offset + 2.0f)) {
|
(next.distance > -boundary_offset && next.distance < boundary_offset + 2.0f)) {
|
||||||
double line_len = (next.position - curr.position).norm();
|
double line_len = (next.position - curr.position).norm();
|
||||||
|
|
||||||
// ORCA: Segment path to smaller lines by adding additional points only if the path has an overhang that
|
// ORCA: A line prints as slow as its slower end and is cooled if either end is, so an overhang at one
|
||||||
// will trigger a slowdown and the path is also reasonably large, i.e. 2mm in length or more
|
// end would otherwise slow down or cool the whole line. Split the line so that only the part beside
|
||||||
// If there is no overhang in the start/end point, dont segment it.
|
// that end prints that way, if the line is reasonably long (2mm or more) and at least one end prints
|
||||||
// Ignore this check if the control of segmentation for overhangs is disabled (min_distance=-1)
|
// slower or cooled compared with a supported point (overhang distance 0). Deciding on how the end
|
||||||
if ((min_distance > 0 && ((std::abs(curr.distance) > min_distance) || (std::abs(next.distance) > min_distance)) && line_len >= 2.f) ||
|
// prints, rather than on its overhang distance against min_distance, also catches an end whose overhang
|
||||||
(min_distance <= 0 && line_len > 4.0f)) {
|
// distance is exactly where the slowdown begins, such as an outline crossing at half a line width.
|
||||||
|
// Without distance_to_speed, split every line over 4mm.
|
||||||
|
const bool split_line = distance_to_speed ?
|
||||||
|
line_len >= 2.f && (slower_or_cooled(curr.distance, 0.f) || slower_or_cooled(next.distance, 0.f)) :
|
||||||
|
line_len > 4.0f;
|
||||||
|
if (split_line) {
|
||||||
|
// Each end's piece is that end's overhang distance plus 1.5 line widths (3 * boundary_offset) long:
|
||||||
|
// a0 ends the piece beside curr, a1 starts the piece beside next.
|
||||||
double a0 = std::clamp((curr.distance + 3 * boundary_offset) / line_len, 0.0, 1.0);
|
double a0 = std::clamp((curr.distance + 3 * boundary_offset) / line_len, 0.0, 1.0);
|
||||||
double a1 = std::clamp(1.0f - (next.distance + 3 * boundary_offset) / line_len, 0.0, 1.0);
|
double a1 = std::clamp(1.0f - (next.distance + 3 * boundary_offset) / line_len, 0.0, 1.0);
|
||||||
double t0 = std::min(a0, a1);
|
double t0 = std::min(a0, a1);
|
||||||
double t1 = std::max(a0, a1);
|
double t1 = std::max(a0, a1);
|
||||||
|
|
||||||
if (t0 < 1.0) {
|
// Up to two cut points, in order along the line. Each takes its own overhang distance, so every
|
||||||
Vec p0 = curr.position + t0 * (next.position - curr.position);
|
// piece prints by the overhang distances at its own two ends. t0 >= 1 or t1 <= 0 falls on the
|
||||||
auto [p0_dist, p0_near_l, p0_x] = unscaled_prev_layer.template distance_from_lines_extra<SIGNED_DISTANCE>(
|
// line's own end, so there is no cut. A cut closer than min_spacing to either end of the line is
|
||||||
p0.template cast<AABBScalar>());
|
// not meaningful and is filtered out (#6714).
|
||||||
ExtendedPoint<L::Dim> new_p{};
|
ExtendedPoint<L::Dim> cut[2]{};
|
||||||
new_p.position = p0;
|
bool keep[2] = {false, false};
|
||||||
new_p.distance = float(p0_dist + boundary_offset);
|
for (int k = 0; k < 2; ++k) {
|
||||||
// ORCA: only create a new point in the path if the new point overhang distance will be used to generate a speed change
|
const double t = k == 0 ? t0 : t1;
|
||||||
// or if this option is disabled (min_distance<=0)
|
if (k == 0 ? t >= 1.0 : t <= 0.0)
|
||||||
if( (std::abs(p0_dist) > min_distance) || (min_distance<=0)){
|
continue;
|
||||||
// ORCA: also filter out points that are introduced to the start of the path when their distance from the start point is
|
const Vec p = curr.position + t * (next.position - curr.position);
|
||||||
// not meaningful
|
auto [p_dist, p_near_l, p_x] = unscaled_prev_layer.template distance_from_lines_extra<SIGNED_DISTANCE>(
|
||||||
if ((p0 - curr.position).norm() > min_spacing && (next.position - p0).norm() > min_spacing) {
|
p.template cast<AABBScalar>());
|
||||||
new_points.push_back(new_p);
|
cut[k].position = p;
|
||||||
}
|
cut[k].distance = float(p_dist + boundary_offset);
|
||||||
}
|
keep[k] = (p - curr.position).norm() > min_spacing && (next.position - p).norm() > min_spacing;
|
||||||
}
|
|
||||||
if (t1 > 0.0) {
|
|
||||||
Vec p1 = curr.position + t1 * (next.position - curr.position);
|
|
||||||
auto [p1_dist, p1_near_l, p1_x] = unscaled_prev_layer.template distance_from_lines_extra<SIGNED_DISTANCE>(
|
|
||||||
p1.template cast<AABBScalar>());
|
|
||||||
ExtendedPoint<L::Dim> new_p{};
|
|
||||||
new_p.position = p1;
|
|
||||||
new_p.distance = float(p1_dist + boundary_offset);
|
|
||||||
// ORCA: only create a new point in the path if the new point overhang distance will be used to generate a speed change
|
|
||||||
// or if this option is disabled (min_distance<=0)
|
|
||||||
if( (std::abs(p1_dist) > min_distance) || (min_distance<=0)){
|
|
||||||
// ORCA: filter out points that are introduced to the end of the path when their distance from the end point is
|
|
||||||
// not meaningful
|
|
||||||
if ((p1 - curr.position).norm() > min_spacing && (next.position - p1).norm() > min_spacing) {
|
|
||||||
new_points.push_back(new_p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (distance_to_speed) {
|
||||||
|
// Only keep a cut that changes the G-code: one that prints differently from at least one of the
|
||||||
|
// points either side of it, which are the line's ends or the other cut where that is kept. A cut
|
||||||
|
// that prints like both would only split a move into two identical ones.
|
||||||
|
if (keep[0])
|
||||||
|
keep[0] = !same_speed_and_fan(cut[0].distance, curr.distance) ||
|
||||||
|
!same_speed_and_fan(cut[0].distance, keep[1] ? cut[1].distance : next.distance);
|
||||||
|
if (keep[1])
|
||||||
|
keep[1] = !same_speed_and_fan(cut[1].distance, keep[0] ? cut[0].distance : curr.distance) ||
|
||||||
|
!same_speed_and_fan(cut[1].distance, next.distance);
|
||||||
|
// Two cuts closer together than min_spacing would leave a micro segment between them, so only the
|
||||||
|
// first is kept.
|
||||||
|
if (keep[0] && keep[1] && (cut[1].position - cut[0].position).norm() <= min_spacing)
|
||||||
|
keep[1] = false;
|
||||||
}
|
}
|
||||||
|
for (int k = 0; k < 2; ++k)
|
||||||
|
if (keep[k])
|
||||||
|
new_points.push_back(cut[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_points.push_back(next);
|
new_points.push_back(next);
|
||||||
@@ -423,7 +447,10 @@ public:
|
|||||||
const ConfigOptionFloatsOrPercents &speeds,
|
const ConfigOptionFloatsOrPercents &speeds,
|
||||||
float ext_perimeter_speed,
|
float ext_perimeter_speed,
|
||||||
float original_speed,
|
float original_speed,
|
||||||
bool slowdown_for_curled_edges)
|
bool slowdown_for_curled_edges,
|
||||||
|
// Overlap at or below which the overhang fan switches on; negative when the fan
|
||||||
|
// does not depend on overlap.
|
||||||
|
float fan_overlap_threshold = -1.0f)
|
||||||
{
|
{
|
||||||
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
|
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
|
||||||
std::vector<std::pair<float, float>> speed_sections;
|
std::vector<std::pair<float, float>> speed_sections;
|
||||||
@@ -463,7 +490,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a meaningful (i.e. needing slowdown) overhang distance was not found, then we shouldn't split the lines
|
// If no overhang distance slows this path down, -1 turns interior sampling off unless the overhang fan can switch.
|
||||||
|
// Lines are only split where an end prints slower or cooled, so here only a fan switch splits them.
|
||||||
if (!found)
|
if (!found)
|
||||||
smallest_distance_with_lower_speed=-1.f;
|
smallest_distance_with_lower_speed=-1.f;
|
||||||
|
|
||||||
@@ -487,9 +515,17 @@ public:
|
|||||||
return round(final_speed);
|
return round(final_speed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ORCA: The speed sections are built from ext_perimeter_speed, which can be above the speed this path prints at
|
||||||
|
// (original_speed, e.g. held down by resonance avoidance). Every segment is capped at original_speed below, so
|
||||||
|
// overhang distances whose speeds differ only above it print the same and must not count as a speed change when
|
||||||
|
// the path is split.
|
||||||
|
auto effective_speed = [&calculate_speed, original_speed](float distance) {
|
||||||
|
return std::min(calculate_speed(distance), original_speed);
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<ExtendedPoint<3>> extended_points =
|
std::vector<ExtendedPoint<3>> extended_points =
|
||||||
estimate_points_properties<true, true, true, true>(path.polyline.points, prev_layer_boundaries[current_object], path.width, -1,
|
estimate_points_properties<true, true, true, true>(path.polyline.points, prev_layer_boundaries[current_object], path.width, -1,
|
||||||
smallest_distance_with_lower_speed, calculate_speed);
|
smallest_distance_with_lower_speed, effective_speed, fan_overlap_threshold);
|
||||||
const auto width_inv = 1.0f / path.width;
|
const auto width_inv = 1.0f / path.width;
|
||||||
std::vector<ProcessedPoint> processed_points;
|
std::vector<ProcessedPoint> processed_points;
|
||||||
processed_points.reserve(extended_points.size());
|
processed_points.reserve(extended_points.size());
|
||||||
|
|||||||
@@ -4862,13 +4862,13 @@ void DesignPanel::on_import_mesh()
|
|||||||
try {
|
try {
|
||||||
shape = GeometryEngine::mesh_to_brep(mesh.its, MESH_IMPORT_TOLERANCE,
|
shape = GeometryEngine::mesh_to_brep(mesh.its, MESH_IMPORT_TOLERANCE,
|
||||||
MESH_IMPORT_MERGE_ANGLE_DEG, stats);
|
MESH_IMPORT_MERGE_ANGLE_DEG, stats);
|
||||||
} catch (const std::exception& e) {
|
} catch (const Standard_Failure& e) { // on OCCT >= 8 Standard_Failure derives from std::exception — must precede that handler
|
||||||
fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(e.what()));
|
|
||||||
return;
|
|
||||||
} catch (const Standard_Failure& e) { // OCCT throws outside std::exception
|
|
||||||
fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(
|
fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(
|
||||||
e.GetMessageString() ? e.GetMessageString() : "OCCT error"));
|
e.GetMessageString() ? e.GetMessageString() : "OCCT error"));
|
||||||
return;
|
return;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(e.what()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (shape.IsNull()) { fail(_L("Mesh conversion produced no geometry")); return; }
|
if (shape.IsNull()) { fail(_L("Mesh conversion produced no geometry")); return; }
|
||||||
|
|
||||||
|
|||||||
@@ -1443,6 +1443,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const
|
|||||||
libvgcode::EGCodeExtrusionRole::SupportTransition, libvgcode::EGCodeExtrusionRole::Mixed
|
libvgcode::EGCodeExtrusionRole::SupportTransition, libvgcode::EGCodeExtrusionRole::Mixed
|
||||||
});
|
});
|
||||||
m_paths_bounding_box = BoundingBoxf3(libvgcode::convert(bbox[0]).cast<double>(), libvgcode::convert(bbox[1]).cast<double>());
|
m_paths_bounding_box = BoundingBoxf3(libvgcode::convert(bbox[0]).cast<double>(), libvgcode::convert(bbox[1]).cast<double>());
|
||||||
|
m_max_bounding_box = m_paths_bounding_box;
|
||||||
|
|
||||||
if (wxGetApp().is_editor())
|
if (wxGetApp().is_editor())
|
||||||
m_contained_in_bed = wxGetApp().plater()->build_volume().all_paths_inside(gcode_result, m_paths_bounding_box);
|
m_contained_in_bed = wxGetApp().plater()->build_volume().all_paths_inside(gcode_result, m_paths_bounding_box);
|
||||||
|
|||||||
@@ -244,6 +244,44 @@ float furthest_reading(const std::vector<ExtendedPoint<2>>& points)
|
|||||||
})->distance;
|
})->distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A wall along a supported edge of the previous layer, ending past or just short of the edge's end. Crossing the edge's
|
||||||
|
// end reads half a line width out.
|
||||||
|
constexpr double edge_run_length = 64.; // mm, wall start, measured from the end of the previous layer's edge
|
||||||
|
constexpr double edge_step = 0.384; // mm, how far this layer's contour extends past the previous layer's end
|
||||||
|
// The centreline is inset half a line width from the contour.
|
||||||
|
constexpr double edge_wall_end_past = edge_step - 0.5 * caged_wall_width;
|
||||||
|
constexpr double edge_wall_end_short = 0.05; // mm short of the edge, reading 0.21 - 0.05 = 0.16mm out
|
||||||
|
// Segmentation splits 1.5 line widths plus the end's reading from an end, so an end's slowdown and cooling stay within this.
|
||||||
|
constexpr double edge_affected_length = 3. * caged_wall_width;
|
||||||
|
|
||||||
|
std::vector<ExtendedPoint<2>> sampled_wall_along_edge(double wall_end_x,
|
||||||
|
const std::function<float(float)>& distance_to_speed,
|
||||||
|
float min_distance,
|
||||||
|
float fan_overlap_threshold)
|
||||||
|
{
|
||||||
|
const AABBTreeLines::LinesDistancer<Linef> prev_layer(std::vector<Linef>{
|
||||||
|
{{0., 0.}, {edge_run_length + 10., 0.}},
|
||||||
|
{{edge_run_length + 10., 0.}, {edge_run_length + 10., -10.}},
|
||||||
|
{{edge_run_length + 10., -10.}, {0., -10.}},
|
||||||
|
{{0., -10.}, {0., 0.}},
|
||||||
|
});
|
||||||
|
const double wall_y = -0.5 * caged_wall_width;
|
||||||
|
const Points wall{Point::new_scale(edge_run_length, wall_y), Point::new_scale(wall_end_x, wall_y)};
|
||||||
|
|
||||||
|
return estimate_points_properties<true, true, true, true>(wall, prev_layer, caged_wall_width, -1.f, min_distance,
|
||||||
|
distance_to_speed, fan_overlap_threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length printed with the overhang fan on: segments with either end's overlap at or below the threshold.
|
||||||
|
double cooled_length(const std::vector<ExtendedPoint<2>>& points, float fan_overlap_threshold)
|
||||||
|
{
|
||||||
|
double length = 0.;
|
||||||
|
for (size_t i = 0; i + 1 < points.size(); ++i)
|
||||||
|
if (1.f - std::max(points[i].distance, points[i + 1].distance) / float(caged_wall_width) <= fan_overlap_threshold)
|
||||||
|
length += (points[i + 1].position - points[i].position).norm();
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
DynamicPrintConfig caged_overhang_config(const char* wall_generator){
|
DynamicPrintConfig caged_overhang_config(const char* wall_generator){
|
||||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||||
config.set_deserialize_strict({
|
config.set_deserialize_strict({
|
||||||
@@ -431,6 +469,61 @@ TEST_CASE("A supported wall between overhanging corners is slowed no further tha
|
|||||||
REQUIRE(sampled <= unsampled);
|
REQUIRE(sampled <= unsampled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression: the line up to a step past the previous layer was not split, so the step's slowdown and cooling covered the
|
||||||
|
// whole wall. The split required an end reading beyond where the slowdown begins, and an edge crossing reads exactly
|
||||||
|
// there when the wall speed is held below the reference speed (e.g. resonance avoidance).
|
||||||
|
TEST_CASE("A wall stepping past the previous layer is slowed and cooled only beside the step", "[ExtrusionProcessor][Regression]")
|
||||||
|
{
|
||||||
|
const float crossing_reading = 0.5f * float(caged_wall_width);
|
||||||
|
const std::function<float(float)> distance_to_speed = [crossing_reading](float distance) {
|
||||||
|
return distance < crossing_reading ? 70.f : 15.f;
|
||||||
|
};
|
||||||
|
const float fan_overlap_threshold = 0.75f; // The fan switches on at a 25% overhang
|
||||||
|
|
||||||
|
const std::vector<ExtendedPoint<2>> points = sampled_wall_along_edge(-edge_wall_end_past, distance_to_speed, crossing_reading,
|
||||||
|
fan_overlap_threshold);
|
||||||
|
const double slowed = slowed_length(points, distance_to_speed);
|
||||||
|
const double cooled = cooled_length(points, fan_overlap_threshold);
|
||||||
|
|
||||||
|
REQUIRE(slowed > 0.);
|
||||||
|
REQUIRE(cooled > 0.);
|
||||||
|
REQUIRE(slowed < edge_affected_length);
|
||||||
|
REQUIRE(cooled < edge_affected_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regression: the fan can switch on at a smaller overhang than the first slowdown. Splitting only on speed changes left
|
||||||
|
// the whole wall cooled when its end read between the two.
|
||||||
|
TEST_CASE("A wall is split where only the overhang fan changes", "[ExtrusionProcessor][Regression]")
|
||||||
|
{
|
||||||
|
const float crossing_reading = 0.5f * float(caged_wall_width);
|
||||||
|
const std::function<float(float)> distance_to_speed = [crossing_reading](float distance) {
|
||||||
|
return distance < crossing_reading ? 70.f : 15.f;
|
||||||
|
};
|
||||||
|
// The end reads 0.16mm out (overlap 0.62): cooled at a 25% threshold, but not slowed.
|
||||||
|
const float fan_overlap_threshold = 0.75f;
|
||||||
|
|
||||||
|
const std::vector<ExtendedPoint<2>> points = sampled_wall_along_edge(edge_wall_end_short, distance_to_speed, crossing_reading,
|
||||||
|
fan_overlap_threshold);
|
||||||
|
const double cooled = cooled_length(points, fan_overlap_threshold);
|
||||||
|
|
||||||
|
REQUIRE_THAT(slowed_length(points, distance_to_speed), Catch::Matchers::WithinAbs(0., 1e-9));
|
||||||
|
REQUIRE(cooled > 0.);
|
||||||
|
REQUIRE(cooled < edge_affected_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// With one speed and a fan threshold no reading reaches, only the wall's ends and the edge crossing remain.
|
||||||
|
TEST_CASE("A wall is left whole where neither its speed nor its cooling changes", "[ExtrusionProcessor]")
|
||||||
|
{
|
||||||
|
const std::function<float(float)> distance_to_speed = [](float) { return 70.f; };
|
||||||
|
// 95% overhang; the step reads 0.384mm out (overlap 0.09).
|
||||||
|
const float fan_overlap_threshold = 0.05f;
|
||||||
|
|
||||||
|
const std::vector<ExtendedPoint<2>> points = sampled_wall_along_edge(-edge_wall_end_past, distance_to_speed, -1.f,
|
||||||
|
fan_overlap_threshold);
|
||||||
|
|
||||||
|
REQUIRE(points.size() == 3);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Benchmark caged overhang interior sampling", "[ExtrusionProcessor][!benchmark]"){
|
TEST_CASE("Benchmark caged overhang interior sampling", "[ExtrusionProcessor][!benchmark]"){
|
||||||
const char* wall_generator = GENERATE("classic", "arachne");
|
const char* wall_generator = GENERATE("classic", "arachne");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user