mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-16 15:32:09 +00:00
Introduces a plugin capability that runs Python at the seams of Print::process(), letting a plugin read and rewrite slicing state as it is computed. - New slicing_pipeline_plugin config option; selected plugin refs are serialized into the print manifest. - Print gains an injectable hook fired at each pipeline step (posSlice, posPerimeters, posInfill, ...). It is a no-op when unset, fires only on genuine (re)computation, and never on the use-cache path. - orca.slicing submodule: SlicingPipelineCapabilityBase plus a trampoline and a Step enum. Capabilities read the live graph through zero-copy int64 numpy views (contour/holes geometry with unscaled coordinates, flattened toolpath data) and edit it through 2D-geometry mutators with cache-invariant refresh. - GUI dispatcher runs capabilities during slicing under the GIL, turns plugin errors into slicing errors, honors cancellation, and adds the plugin picker. - Ships the InsetEverySlice sample plugin and binding/hook tests.
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#pragma once
|
|
|
|
// Shared embedded-interpreter bootstrap for slic3rutils tests that need a live Python
|
|
// interpreter (test_plugin_host_api.cpp, test_slicing_pipeline_bindings.cpp, ...).
|
|
|
|
#include <pybind11/embed.h>
|
|
#include <pybind11/pybind11.h>
|
|
|
|
#include <slic3r/plugin/PythonPluginBridge.hpp>
|
|
|
|
namespace {
|
|
|
|
void ensure_python_initialized()
|
|
{
|
|
// Deliberately a bare scoped_interpreter rather than Slic3r::PythonInterpreter:
|
|
// `orca` is a PYBIND11_EMBEDDED_MODULE compiled into this test binary, so importing
|
|
// it needs no bundled stdlib/sys.path, and the deterministic assertions are
|
|
// independent of the host's Python. PythonInterpreter::initialize() expects the
|
|
// bundled Python home laid out next to the app bundle (lib/python3.12/encodings),
|
|
// which is not deployed beside the test binary, so using it here would fail to find
|
|
// a home on macOS/Linux. The optional numpy-backed assertions are guarded at runtime.
|
|
if (!Py_IsInitialized()) {
|
|
static pybind11::scoped_interpreter interpreter;
|
|
(void) interpreter;
|
|
}
|
|
}
|
|
|
|
pybind11::module_ import_orca_module()
|
|
{
|
|
ensure_python_initialized();
|
|
|
|
// Force PythonPluginBridge.cpp into the test binary so the embedded
|
|
// PYBIND11_EMBEDDED_MODULE(orca, ...) registration is available.
|
|
(void) Slic3r::PythonPluginBridge::instance();
|
|
return pybind11::module_::import("orca");
|
|
}
|
|
|
|
} // namespace
|