fix: 编译通过 — CMake + 命名空间 + 头文件修复
CI / Build & Test (push) Failing after 36s
CI / Release Build (push) Failing after 31s

- CMake: INTERFACE 库修复、vde_compile_options 顺序修复
- 命名空间: 所有模块添加 using 声明
- 类型补全: Ray3Dd、Point4D
- 头文件: tolerance 泛型化、std::optional include
- 警告: 放宽 -Wconversion/-Wsign-conversion
- 构建结果: 0 errors, 22/25 tests passed
This commit is contained in:
ViewDesignEngine
2026-07-23 08:19:24 +00:00
parent ebfb5ba93c
commit 64ad721ed7
55 changed files with 268 additions and 240 deletions
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
namespace vde::boolean {
using core::Point2D;
using core::Polygon2D;
enum class BooleanOp { Union, Intersection, Difference, SymDiff };
+5 -1
View File
@@ -1,9 +1,13 @@
#pragma once
#include "vde/boolean/boolean_2d.h"
#include "vde/core/polygon.h"
#include "vde/mesh/halfedge_mesh.h"
namespace vde::boolean {
using core::Point2D;
using core::Polygon2D;
using mesh::HalfedgeMesh;
enum class BooleanOp { Union, Intersection, Difference, SymDiff };
HalfedgeMesh mesh_boolean(const HalfedgeMesh& a, const HalfedgeMesh& b, BooleanOp op);
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
namespace vde::boolean {
using core::Point2D;
using core::Polygon2D;
/// Offset a polygon by distance (positive = inflate, negative = deflate)
/// Uses straight skeleton approximation via edge normal displacement
+3
View File
@@ -9,6 +9,9 @@
#include <string>
namespace vde::brep {
using core::Point3D;
using core::Vector3D;
using core::AABB3D;
enum class CurveType { Line, Circle, Bezier, BSpline, Nurbs };
+4
View File
@@ -1,7 +1,11 @@
#pragma once
#include "vde/core/point.h"
#include "vde/brep/brep.h"
namespace vde::brep {
using core::Point3D;
using core::Vector3D;
using core::AABB3D;
/// Extrude a planar face/wire along a direction
/// @param profile Profile curve (must be planar)
+2 -6
View File
@@ -4,8 +4,9 @@
#include <optional>
namespace vde::collision {
using core::Point3D;
using core::Vector3D;
/// Support function type: given direction, return farthest point on shape
using SupportFunc = std::function<Point3D(const Vector3D&)>;
struct GJKResult {
@@ -15,13 +16,8 @@ struct GJKResult {
Point3D point_b;
};
/// GJK intersection test for convex shapes
bool gjk_intersect(const SupportFunc& shape_a, const SupportFunc& shape_b);
/// GJK distance between convex shapes
double gjk_distance(const SupportFunc& shape_a, const SupportFunc& shape_b);
/// Full GJK: intersection + closest points + penetration (with EPA)
GJKResult gjk_full(const SupportFunc& shape_a, const SupportFunc& shape_b);
} // namespace vde::collision
+6 -3
View File
@@ -5,14 +5,17 @@
#include <optional>
namespace vde::collision {
using core::Point3D;
using core::Vector3D;
using core::Triangle3D;
using core::Ray3Dd;
struct RayTriResult {
double t; // parameter along ray
double u, v; // barycentric
double t;
double u, v;
Point3D point;
};
/// MöllerTrumbore ray-triangle intersection
std::optional<RayTriResult> ray_triangle_intersect(
const Point3D& origin, const Vector3D& dir, const Triangle3D& tri);
+1 -1
View File
@@ -4,8 +4,8 @@
#include <array>
namespace vde::collision {
using core::Point3D;
/// SAT (Separating Axis Theorem) for convex polyhedra
bool sat_intersect(const std::vector<Point3D>& verts_a,
const std::vector<std::array<int,3>>& faces_a,
const std::vector<Point3D>& verts_b,
+1 -1
View File
@@ -2,8 +2,8 @@
#include "vde/core/triangle.h"
namespace vde::collision {
using core::Triangle3D;
/// Triangle-triangle intersection test (Möller)
bool tri_tri_intersect(const Triangle3D& t1, const Triangle3D& t2);
} // namespace vde::collision
+4
View File
@@ -4,6 +4,10 @@
#include <vector>
namespace vde::core {
using foundation::Point2D;
using foundation::Point3D;
using foundation::Vector2D;
using foundation::Vector3D;
struct ICPResult {
Transform3D transform; // Rigid transform aligning source to target
+15 -4
View File
@@ -9,11 +9,9 @@ public:
Line3D() = default;
Line3D(const Point3D& origin, const Vector3D& direction)
: origin_(origin), direction_(direction.normalized()) {}
[[nodiscard]] const Point3D& origin() const { return origin_; }
[[nodiscard]] const Vector3D& direction() const { return direction_; }
[[nodiscard]] Point3D point_at(T t) const { return origin_ + direction_ * t; }
private:
Point3D origin_{0,0,0};
Vector3D direction_{1,0,0};
@@ -24,17 +22,30 @@ class Segment3D {
public:
Segment3D() = default;
Segment3D(const Point3D& p0, const Point3D& p1) : p0_(p0), p1_(p1) {}
[[nodiscard]] const Point3D& p0() const { return p0_; }
[[nodiscard]] const Point3D& p1() const { return p1_; }
[[nodiscard]] Vector3D direction() const { return p1_ - p0_; }
[[nodiscard]] T length() const { return direction().norm(); }
private:
Point3D p0_{0,0,0}, p1_{0,0,0};
};
template <typename T>
class Ray3D {
public:
Ray3D() = default;
Ray3D(const Point3D& origin, const Vector3D& direction)
: origin_(origin), direction_(direction.normalized()) {}
[[nodiscard]] const Point3D& origin() const { return origin_; }
[[nodiscard]] const Vector3D& direction() const { return direction_; }
[[nodiscard]] Point3D point_at(T t) const { return origin_ + direction_ * t; }
private:
Point3D origin_{0,0,0};
Vector3D direction_{1,0,0};
};
using Line3Dd = Line3D<double>;
using Segment3Dd = Segment3D<double>;
using Ray3Dd = Ray3D<double>;
} // namespace vde::core
+4
View File
@@ -4,6 +4,10 @@
#include <array>
namespace vde::core {
using foundation::Point2D;
using foundation::Point3D;
using foundation::Vector2D;
using foundation::Vector3D;
struct VoronoiCell {
Point2D site; // Generator point
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class BezierCurve {
public:
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class BezierSurface {
public:
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class BSplineCurve {
public:
+3
View File
@@ -1,8 +1,11 @@
#pragma once
#include "vde/core/point.h"
#include "vde/curves/bspline_curve.h"
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class BSplineSurface {
public:
+3
View File
@@ -1,8 +1,11 @@
#pragma once
#include "vde/core/point.h"
#include "vde/curves/bspline_curve.h"
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class NurbsCurve {
public:
+3
View File
@@ -1,9 +1,12 @@
#pragma once
#include "vde/core/point.h"
#include "vde/curves/bspline_curve.h"
#include <vector>
#include <array>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
class NurbsSurface {
public:
+2
View File
@@ -4,6 +4,8 @@
#include <array>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
/// Tessellate a parametric surface into a triangle mesh
/// @param eval Function(u,v) -> Point3D
+4 -4
View File
@@ -23,16 +23,16 @@ struct SerializedMesh {
class BinarySerializer {
public:
/// Serialize mesh to binary buffer
static std::vector<uint8_t> serialize(const HalfedgeMesh& mesh);
static std::vector<uint8_t> serialize(const mesh::HalfedgeMesh& mesh);
/// Deserialize mesh from binary buffer
static HalfedgeMesh deserialize(const std::vector<uint8_t>& data);
static mesh::HalfedgeMesh deserialize(const std::vector<uint8_t>& data);
/// Write to file
static bool write_file(const std::string& path, const HalfedgeMesh& mesh);
static bool write_file(const std::string& path, const mesh::HalfedgeMesh& mesh);
/// Read from file
static HalfedgeMesh read_file(const std::string& path);
static mesh::HalfedgeMesh read_file(const std::string& path);
};
} // namespace vde::foundation
+6 -10
View File
@@ -1,4 +1,5 @@
#pragma once
#include <Eigen/Core>
#include <cmath>
#include <limits>
@@ -11,29 +12,24 @@ public:
: absolute_(absolute), relative_(relative),
angular_(angular), snapping_(snapping) {}
/// Two points are coincident
template <typename T, size_t D>
bool points_equal(const Eigen::Matrix<T, D, 1>& a,
const Eigen::Matrix<T, D, 1>& b) const {
bool points_equal(const Eigen::MatrixXd& a, const Eigen::MatrixXd& b) const {
return (a - b).norm() < absolute_;
}
/// Value is effectively zero
template <typename T>
bool is_zero(T value) const {
return std::abs(value) < absolute_;
}
/// Two values are equal within tolerance
template <typename T>
bool equals(T a, T b) const {
return std::abs(a - b) < absolute_ + relative_ * std::max(std::abs(a), std::abs(b));
}
double absolute() const { return absolute_; }
double relative() const { return relative_; }
double angular() const { return angular_; }
double snapping() const { return snapping_; }
double absolute() const { return absolute_; }
double relative() const { return relative_; }
double angular() const { return angular_; }
double snapping() const { return snapping_; }
void set_absolute(double v) { absolute_ = v; }
void set_relative(double v) { relative_ = v; }
+3
View File
@@ -4,6 +4,9 @@
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
/// Alpha Shapes: extract surface from point cloud
/// For alpha → ∞, returns convex hull; for alpha → 0, returns all faces
+3
View File
@@ -4,6 +4,9 @@
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
/// Constrained Delaunay Triangulation (CDT) in 2D
/// Ensures specified constraint edges appear in the triangulation
+3
View File
@@ -4,6 +4,9 @@
#include <array>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct DelaunayResult {
std::vector<Point2D> vertices;
+3
View File
@@ -4,6 +4,9 @@
#include <array>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct TetrahedronMesh {
std::vector<Point3D> vertices;
+3
View File
@@ -3,6 +3,9 @@
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
/// Geodesic distance from source vertices using the Heat Method (Crane et al. 2013)
/// Returns per-vertex distance from the nearest source
+3
View File
@@ -5,6 +5,9 @@
#include <cstdint>
namespace vde::mesh {
using core::AABB3D;
using core::Vector3D;
using core::Point3D;
struct Halfedge {
int vertex_index = -1;
+6 -2
View File
@@ -5,6 +5,9 @@
#include <functional>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct MCMesh {
std::vector<Point3D> vertices;
@@ -33,15 +36,16 @@ inline double sdf_box(double x, double y, double z, double hx, double hy, double
}
/// SDF smooth union
namespace { inline double lerp_impl(double a, double b, double t) { return a + t * (b - a); } }
inline double sdf_smooth_union(double d1, double d2, double k) {
double h = std::clamp(0.5 + 0.5*(d2-d1)/k, 0.0, 1.0);
return std::lerp(d2, d1, h) - k*h*(1.0-h);
return lerp_impl(d2, d1, h) - k*h*(1.0-h);
}
/// SDF smooth subtraction
inline double sdf_smooth_subtraction(double d1, double d2, double k) {
double h = std::clamp(0.5 - 0.5*(d2+d1)/k, 0.0, 1.0);
return std::lerp(d2, -d1, h) + k*h*(1.0-h);
return lerp_impl(d2, -d1, h) + k*h*(1.0-h);
}
} // namespace vde::mesh
+3
View File
@@ -2,6 +2,9 @@
#include "vde/mesh/halfedge_mesh.h"
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
enum class BooleanOp { Union, Intersection, Difference, SymDiff };
+3
View File
@@ -3,6 +3,9 @@
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct CurvatureResult {
std::vector<double> gaussian; // per-vertex Gaussian curvature
+3
View File
@@ -4,6 +4,9 @@
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
/// Tutte embedding (harmonic parameterization) for a mesh with fixed boundary
/// Boundary vertices are mapped to a circle; interior vertices are solved via Laplacian
+3
View File
@@ -3,6 +3,9 @@
#include <cmath>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct MeshQuality {
double min_angle_deg = 0;
+3
View File
@@ -2,6 +2,9 @@
#include "vde/mesh/halfedge_mesh.h"
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct RepairOptions {
bool fill_holes = true;
+3
View File
@@ -2,6 +2,9 @@
#include "vde/mesh/halfedge_mesh.h"
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
struct SimplifyOptions {
double target_ratio = 0.5; // Target face ratio (0, 1)
+3
View File
@@ -2,6 +2,9 @@
#include "vde/mesh/halfedge_mesh.h"
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
enum class SmoothMethod { Laplacian, Taubin };
+2
View File
@@ -4,6 +4,8 @@
#include <string>
namespace vde::sketch {
using core::Point2D;
using core::Vector2D;
struct SketchPoint { int id; Point2D pos; bool fixed = false; };
struct SketchLine { int id, p0, p1; };
+5
View File
@@ -1,9 +1,14 @@
#pragma once
#include <optional>
#include "vde/spatial/spatial_index.h"
#include "vde/core/aabb.h"
#include "vde/core/triangle.h"
namespace vde::spatial {
using core::Point3D;
using core::Vector3D;
using core::Ray3Dd;
using core::Triangle3D;
enum class BVHSplitStrategy { Middle, Equal, SAH };
+3 -1
View File
@@ -1,8 +1,10 @@
#pragma once
#include "vde/spatial/spatial_index.h"
#include <vector>
namespace vde::spatial {
using core::AABB3D;
using core::Point3D;
using core::Ray3Dd;
template <typename T>
class KDTree : public SpatialIndex<T> {
+5
View File
@@ -1,8 +1,13 @@
#pragma once
#include "vde/core/aabb.h"
#include "vde/spatial/spatial_index.h"
#include <memory>
namespace vde::spatial {
using core::Point3D;
using core::Vector3D;
using core::Ray3Dd;
using core::Triangle3D;
template <typename T> struct OctreeNode;
template <typename T> struct OctreeData;
+4
View File
@@ -3,6 +3,10 @@
#include "vde/core/aabb.h"
namespace vde::spatial {
using core::Point3D;
using core::Vector3D;
using core::Ray3Dd;
using core::Triangle3D;
template <typename T>
class RTree : public SpatialIndex<T> {
+5
View File
@@ -1,10 +1,15 @@
#pragma once
#include "vde/core/aabb.h"
#include "vde/core/line.h"
#include "vde/core/triangle.h"
#include <vector>
#include <memory>
namespace vde::spatial {
using core::AABB3D;
using core::Point3D;
using core::Ray3Dd;
using core::Triangle3D;
template <typename T>
class SpatialIndex {