feat: Add Z Anti-Aliasing (ZAA) contouring support

Port Z Anti-Aliasing from BambuStudio-ZAA (https://github.com/adob/BambuStudio-ZAA)
to OrcaSlicer. ZAA eliminates stair-stepping on curved and sloped top surfaces
by raycasting each extrusion point against the original 3D mesh and micro-adjusting
Z height to follow the actual surface geometry.

Key changes:
- Add ContourZ.cpp raycasting algorithm (~330 lines)
- Extend geometry with 3D support (Point3, Line3, Polyline3, MultiPoint3)
- Template arc fitting for 2D/3D compatibility
- Change ExtrusionPath::polyline from Polyline to Polyline3
- Add 5 ZAA config options (zaa_enabled, zaa_min_z, etc.)
- Add posContouring pipeline step in PrintObject
- Update GCode writer for 3D coordinate output
- Add ZAA settings UI in Print Settings > Quality
- Add docs/ZAA.md with usage and implementation details

ZAA is opt-in and disabled by default. When disabled, the slicing pipeline
is unchanged.
This commit is contained in:
Matthias Nott
2026-02-09 20:38:46 +01:00
parent cae1567726
commit 963f8d86b7
57 changed files with 1817 additions and 204 deletions

View File

@@ -119,18 +119,46 @@ class MultiPoint3
public:
Points3 points;
void append(const Vec3crd& point) { this->points.push_back(point); }
void append(const Point3& point) { this->points.push_back(point); }
void append(const Vec3crd& point) { this->points.push_back(Point3(point)); }
void translate(double x, double y);
void translate(const Point& vector);
void reverse() { std::reverse(this->points.begin(), this->points.end()); }
void rotate(double angle) { this->rotate(cos(angle), sin(angle)); }
void rotate(double cos_angle, double sin_angle);
void rotate(double angle, const Point3 &center);
Point3& first_point() { return this->points.front(); }
Point3& last_point() { return this->points.back(); }
const Point3& first_point() const { return this->points.front(); }
const Point3& last_point() const { return this->points.back(); }
size_t size() const { return this->points.size(); }
bool empty() const { return this->points.empty(); }
void clear() { this->points.clear(); }
auto begin() { return this->points.begin(); }
auto end() { return this->points.end(); }
auto begin() const { return this->points.begin(); }
auto end() const { return this->points.end(); }
virtual Lines3 lines() const = 0;
double length() const;
bool is_valid() const { return this->points.size() >= 2; }
BoundingBox3 bounding_box() const;
// Find a point in the points array
int find_point(const Point &point) const;
int find_point(const Point &point, const double scaled_epsilon) const;
int find_point(const Point3 &point) const;
int find_point(const Point3 &point, const double scaled_epsilon) const;
// Remove exact duplicates, return true if any duplicate has been removed.
bool remove_duplicate_points();
// Douglas-Peucker simplification
static Points3 _douglas_peucker(const Points3 &points, double tolerance);
};
extern BoundingBox get_extents(const MultiPoint &mp);