mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-12 02:11:39 +00:00
* CLI: --inspect-paint — dump per-facet paint state as JSON
Reads the per-facet enforcer/blocker/extruder/fuzzy-skin state stored
on every ModelVolume (supported_facets / seam_facets /
mmu_segmentation_facets / fuzzy_skin_facets) and emits a structured
JSON summary to stdout. Machine-readable alternative to opening the
paint gizmos.
Per (object, volume, layer, state): facet count, surface area in
mm², and mesh-local bounding box. Empty layers collapse to
{"empty": true}. Summary at the top level rolls up totals.
One correctness detail worth calling out: FacetsAnnotation::
get_facets_strict returns an indexed_triangle_set whose `vertices`
array is the whole source mesh — only `indices` are filtered to the
painted triangles. A naive bounding_box(its) would report the whole
mesh's bbox even when only a few facets are painted. The helper
its_referenced_bbox() walks only the vertices actually indexed by
the painted triangles, so `bbox` correctly localizes the painted
region.
Rationale: every paint-driven workflow — GUI-painted .3mf verified
in CI, AI agents planning support enforcers, MMU color layout checks
— needs to know what's already painted on a model. Today that's a
GUI-only read. --inspect-paint closes that loop for scripted callers.
New file src/slic3r/Utils/PaintCLI.{hpp,cpp} (~215 lines). Depends
only on Model, TriangleMesh, TriangleSelector, FacetsAnnotation, and
nlohmann::json — all already in tree. No new dependencies, no
signature changes, no behavior change when the flag is absent.
Registered as an action (parallel to --info) so it satisfies the
"needs an action" check and bypasses the GUI fallback; control falls
through the normal post-action path to a clean exit 0.
Verification:
unpainted STL: every layer {"empty": true}, summary zero
GUI-painted .3mf: enforcer count / area / bbox match painter
clean JSON: parseable via jq
* CLI --inspect-paint: exit after printing, reject conflicting actions
- Finish like the end of CLI::run once the JSON is written, as the
tooltip says. The callback manager is Linux-only, so its use is
guarded.
- Reject actions that would otherwise be skipped without notice
(--slice, --export-3mf, ...) before loading. Load-time options such as
--uptodate are still accepted.
- Replace invalid UTF-8 in object names and paths instead of throwing.
- Report every input file as sources; inputs are merged into one model
before actions run.
* CLI --inspect-paint: reject a run without input
Without an input file or --load-assemble-list there is nothing to
inspect, and the run printed nothing and exited 0. Reject it up front
with CLI_INVALID_PARAMS, next to the other invalid-parameter checks.
32 lines
1017 B
C++
32 lines
1017 B
C++
// PaintCLI.hpp — CLI paint-inspection primitives.
|
|
//
|
|
// Backs the --inspect-paint CLI action. Reads the per-facet enforcer /
|
|
// blocker / extruder / fuzzy-skin state that OrcaSlicer stores on every
|
|
// ModelVolume (supports, seam, MMU color, fuzzy-skin) and emits a
|
|
// structured JSON summary — facet count, surface area, and mesh-local
|
|
// bounding box per state — so CI / scripted / AI tooling can reason
|
|
// about existing paint on a .3mf without opening the GUI.
|
|
//
|
|
// Coordinates are mesh-local (each volume's own frame), matching the
|
|
// frame that the paint gizmos operate in.
|
|
#ifndef slic3r_PaintCLI_hpp_
|
|
#define slic3r_PaintCLI_hpp_
|
|
|
|
#include <iosfwd>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Slic3r {
|
|
class Model;
|
|
|
|
namespace PaintCLI {
|
|
|
|
// `source_paths` lists every input file; the CLI merges them into one Model.
|
|
void inspect_to_json(const Model &model, const std::vector<std::string> &source_paths,
|
|
std::ostream &out);
|
|
|
|
} // namespace PaintCLI
|
|
} // namespace Slic3r
|
|
|
|
#endif
|