Something went wrong. Try again.
Builds CAD models from 3d scan data
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970// surface.hpp — selected-region tensor-product cubic B-spline fitting.#pragma once
#include <limits>#include <string>#include <vector>
#include "geom.hpp"#include "mesh.hpp"
namespace surface {
struct Params { int nu = 10; int nv = 10; double smooth = 0.3; double extend = 0.08; bool automatic = false; double tol = 0.05;};
struct Preview { int nu = 0, nv = 0; std::vector<geom::Vec3> positions; // NaN means the extended skirt has no nearby scan support. std::vector<double> deviations;};
struct Fit { bool ok = false; std::string error; int nu = 0, nv = 0; int degree = 3; int npts = 0; double rms = 0; double max = 0; double pctWithin = 0; double extend = 0; double lambda = 0;
// Poles are row-major in u: poles[iv * nu + iu]. std::vector<geom::Vec3> poles; // Full clamped knot vectors, including repeated end knots. std::vector<double> knotsU, knotsV;
// The unexpanded minimum-area data rectangle. The natural surface domain // [0,1]^2 extends it by `extend` of each side length on every side. geom::Vec3 rectOrigin; geom::Vec3 axisU, axisV, planeNormal; double dataWidth = 0, dataHeight = 0; Preview preview;};
// Fits the active vertex selection. Preview-to-scan deviations use triangles// having at least one selected vertex.Fit fit(const mesh::Mesh& scan, const std::vector<int>& selected, const Params& params = {});
// Point-only fitting is useful for callers without topology. Its preview// deviations are NaN because no scan triangles are available.Fit fitPoints(const std::vector<geom::Vec3>& points, const std::vector<geom::Vec3>& normals, const Params& params = {});
geom::Vec3 evaluate(const Fit& fit, double u, double v);bool writeSTEP(const Fit& fit, const std::string& path, std::string* error = nullptr);
} // namespace surface