Something went wrong. Try again.
Builds CAD models from 3d scan data
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687// align.hpp — sequential datum (3-2-1) frame construction.#pragma once
#include <array>#include <string>#include <vector>
#include "geom.hpp"#include "mesh.hpp"
namespace align {
using Mat3 = std::array<double, 9>;
enum class FeatureKind { Plane, LineLike, PointLike,};
struct Feature { int id = -1; FeatureKind kind = FeatureKind::PointLike; geom::Vec3 anchor; geom::Vec3 direction;};
struct Slot { int primId = -1; std::string target; bool flip = false;};
struct Result { bool ok = false; std::string error; Mat3 R{1, 0, 0, 0, 1, 0, 0, 0, 1}; geom::Vec3 t; std::array<bool, 3> rotLocked{false, false, false}; std::array<bool, 3> transLocked{false, false, false}; bool fullyDefined = false; std::vector<std::string> overconstrained; geom::Vec3 origin; std::array<geom::Vec3, 3> axes{};};
// Features form the registry; slots select them by id and impose target roles.// `translate` is applied last, in the newly constructed frame.Result buildFrame(const std::vector<Feature>& features, const std::vector<Slot>& slots, geom::Vec3 translate = {0, 0, 0});
// Point-based 3-2-1 (ZEISS INSPECT style). `rule` "AAA-BB-C" names the axis// each group sets a coordinate on: three plane points get A = values[0..2]// (so the plane is perpendicular to A when those are equal), two line points// get B = values[3..4] (the line then runs along C), one point gets// C = values[5]. Solved exactly, unequal values included. Accepts 3, 5, or 6// points for a partially constrained frame.// "Plane positive" (flipPlane = false): +A points to the `planeHint` side// (out of the picked face), or follows right-hand pick order without a hint.// "Line positive" (flipLine = false): +C runs from the 1st to the 2nd line point.struct PointsSpec { std::vector<geom::Vec3> points; std::string rule = "ZZZ-YY-X"; std::array<double, 6> values{}; bool flipPlane = false; bool flipLine = false; geom::Vec3 planeHint;};
Result buildFrameFromPoints(const PointsSpec& spec, geom::Vec3 translate = {0, 0, 0});
// A given rigid move (proper rotation R, then translation t) packaged as a// fully defined Result, for direct edits like "move the planes 5 mm".Result fromRigid(const Mat3& R, const geom::Vec3& t);
// 90-degree rotation about world X, Y, or Z ("X"/"Y"/"Z"; anything else = I).Mat3 rot90(const std::string& axis);
geom::Vec3 transformPoint(const Mat3& R, const geom::Vec3& t, const geom::Vec3& p);geom::Vec3 transformDirection(const Mat3& R, const geom::Vec3& d);void applyTo(mesh::Mesh& mesh, const Mat3& R, const geom::Vec3& t);
} // namespace align