8ae4b86e08
新增: - include/vde/foundation/exact_predicates_gmp.h: GMP 精确谓词 - orient_2d/3d, in_circle 完全精确(mpq_class 有理数) - 零舍入误差,任意精度 - include/vde/foundation/predicates.h: 统一谓词接口 - Predicates<T> 编译期选择后端 - VDE_USE_GMP=ON → GMP, OFF → 自适应 double - 便捷函数: orient(), in_circle() - cmake/FindGMP.cmake: GMP 查找模块 - CMake: -DVDE_USE_GMP=ON 启用 GMP 精确模式 - AdaptiveDouble 包装器: 统一后端接口 使用: cmake -DVDE_USE_GMP=ON .. # 完全精确模式
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
#pragma once
|
|
#include "vde/foundation/exact_predicates.h"
|
|
#ifdef VDE_USE_GMP
|
|
#include "vde/foundation/exact_predicates_gmp.h"
|
|
#endif
|
|
|
|
namespace vde::foundation {
|
|
|
|
/// Unified predicate interface — selects GMP or adaptive double at compile time
|
|
struct Predicates {
|
|
#ifdef VDE_USE_GMP
|
|
using Backend = exact::GmpExact;
|
|
#else
|
|
using Backend = exact::AdaptiveDouble;
|
|
#endif
|
|
|
|
static exact::Orientation orient_2d(const Point2D& a, const Point2D& b, const Point2D& c) {
|
|
return Backend::orient_2d(a, b, c);
|
|
}
|
|
static exact::Orientation orient_3d(const Point3D& a, const Point3D& b,
|
|
const Point3D& c, const Point3D& d) {
|
|
return Backend::orient_3d(a, b, c, d);
|
|
}
|
|
static exact::CircleTest in_circle(const Point2D& a, const Point2D& b,
|
|
const Point2D& c, const Point2D& d) {
|
|
return Backend::in_circle(a, b, c, d);
|
|
}
|
|
};
|
|
|
|
// ── Convenience wrappers (preferred API) ──
|
|
inline exact::Orientation orient(const Point2D& a, const Point2D& b, const Point2D& c) {
|
|
return Predicates::orient_2d(a, b, c);
|
|
}
|
|
inline exact::Orientation orient(const Point3D& a, const Point3D& b, const Point3D& c, const Point3D& d) {
|
|
return Predicates::orient_3d(a, b, c, d);
|
|
}
|
|
inline exact::CircleTest in_circle(const Point2D& a, const Point2D& b, const Point2D& c, const Point2D& d) {
|
|
return Predicates::in_circle(a, b, c, d);
|
|
}
|
|
|
|
} // namespace vde::foundation
|