ViewDesignEngine  3.1.0
高性能 CAD 计算几何引擎
predicates.h
浏览该文件的文档.
1 #pragma once
3 #ifdef VDE_USE_GMP
5 #endif
6 
7 namespace vde::foundation {
8 
17 struct Predicates {
18 #ifdef VDE_USE_GMP
20  using Backend = exact::GmpExact;
21 #else
23  using Backend = exact::AdaptiveDouble;
24 #endif
25 
31  static exact::Orientation orient_2d(const Point2D& a, const Point2D& b, const Point2D& c) {
32  return Backend::orient_2d(a, b, c);
33  }
39  static exact::Orientation orient_3d(const Point3D& a, const Point3D& b,
40  const Point3D& c, const Point3D& d) {
41  return Backend::orient_3d(a, b, c, d);
42  }
49  static exact::CircleTest in_circle(const Point2D& a, const Point2D& b,
50  const Point2D& c, const Point2D& d) {
51  return Backend::in_circle(a, b, c, d);
52  }
53 };
54 
55 // ── Convenience wrappers (preferred API) ──
56 
74 inline exact::Orientation orient(const Point2D& a, const Point2D& b, const Point2D& c) {
75  return Predicates::orient_2d(a, b, c);
76 }
77 
87 inline exact::Orientation orient(const Point3D& a, const Point3D& b, const Point3D& c, const Point3D& d) {
88  return Predicates::orient_3d(a, b, c, d);
89 }
90 
100 inline exact::CircleTest in_circle(const Point2D& a, const Point2D& b, const Point2D& c, const Point2D& d) {
101  return Predicates::in_circle(a, b, c, d);
102 }
103 
104 } // namespace vde::foundation
exact::CircleTest in_circle(const Point2D &a, const Point2D &b, const Point2D &c, const Point2D &d)
圆内测试便捷封装
Definition: predicates.h:100
exact::Orientation orient(const Point2D &a, const Point2D &b, const Point2D &c)
二维定向测试便捷封装
Definition: predicates.h:74
Orientation orient_3d(const Point3D &a, const Point3D &b, const Point3D &c, const Point3D &d)
自适应精度三维定向测试
Orientation orient_2d(const Point2D &a, const Point2D &b, const Point2D &c)
自适应精度二维定向测试(Shewchuk 算法)
Orientation
二维定向测试结果
CircleTest
圆测试结果
自适应双精度谓词后端(默认)
Definition: error_codes.h:4
Point< double, 2 > Point2D
双精度二维点
Definition: math_types.h:41
Point< double, 3 > Point3D
双精度三维点
Definition: math_types.h:43
统一谓词接口 — 编译时选择 GMP 或自适应双精度后端
Definition: predicates.h:17
static exact::CircleTest in_circle(const Point2D &a, const Point2D &b, const Point2D &c, const Point2D &d)
圆内测试
Definition: predicates.h:49
static exact::Orientation orient_3d(const Point3D &a, const Point3D &b, const Point3D &c, const Point3D &d)
三维定向测试
Definition: predicates.h:39
exact::AdaptiveDouble Backend
使用自适应双精度算术(Shewchuk 算法,默认)
Definition: predicates.h:23
static exact::Orientation orient_2d(const Point2D &a, const Point2D &b, const Point2D &c)
二维定向测试
Definition: predicates.h:31