fj_kernel/lib.rs
1//! # Fornjot CAD Kernel
2//!
3//! This library is part of the [Fornjot] ecosystem. Fornjot is an open-source,
4//! code-first CAD application; and collection of libraries that make up the CAD
5//! application, but can be used independently.
6//!
7//! This library is an internal component of Fornjot. It is not relevant to end
8//! users that just want to create CAD models.
9//!
10//! The CAD kernel is the core of Fornjot: the geometry, the topology, and the
11//! algorithms that handle them. It is separate from the CAD application, and
12//! could be used in other applications.
13//!
14//!
15//! ## Design Principle
16//!
17//! The CAD kernel follows the design principle of **robustness through
18//! explicitness**. This means that geometrical relationships must be expressed
19//! explicitly, or they are not accepted.
20//!
21//! It is important to understand that this principle defines the destination of
22//! CAD kernel development. It does not reflect the current reality.
23//!
24//! ### Motivation
25//!
26//! A problem that CAD kernels need to handle is the inherent fuzziness of
27//! geometric relationships. Is a point on a curve, or just close to it? Does a
28//! curve lie in a surface, or does it not? This is exacerbated by the limited
29//! precision of numerical representations in computers, and especially the
30//! inconvenient precision characteristics of floating-point numbers.
31//!
32//! These problems can be addressed by always comparing numbers using an epsilon
33//! value. Numbers that are very close together (their difference is smaller
34//! than epsilon) are considered equal.
35//!
36//! This approach has several problems:
37//! - If the epsilon value is chosen too high, then very small models can become
38//!   buggy, as distinct geometry is merged together.
39//! - If the epsilon value is chosen too low, then very large models can become
40//!   buggy, as geometry that is supposed to be identical is recognized as
41//!   distinct.
42//! - These epsilon comparisons need to be used everywhere where numbers are
43//!   handled. It can be easy to forget this. Using custom wrapper types is
44//!   possible, but either inflexible (because the epsilon value is hardcoded)
45//!   or inconvenient (because the epsilon value needs to be provided).
46//!
47//! Choosing an epsilon value that is suitable for *most* use cases is possible,
48//! at the cost of non-standard use cases breaking in unexpected and non-obvious
49//! ways. Fornjot has chosen a different approach.
50//!
51//! ### Explicitness
52//!
53//! By requiring geometric relationships to be *explicit*, we don't have to use
54//! error-prone heuristics to determine those relationships. That means, for
55//! example, two vertices that happen to be identical, or very close to each
56//! other, are not accepted.
57//!
58//! If vertex instances that refer to the same point are used in different
59//! places (for example, in two neighboring edges that share a vertex), then
60//! those vertex instances must be known by the system to refer to the same
61//! vertex. If a vertex lies on an edge or in a surface, then it must be defined
62//! in terms of its position on that edge or surface.
63//!
64//! This can have consequences for how users define models. For example, if the
65//! user moves two shapes close to each other, so they touch but don't
66//! intersect, this should lead to an error message, explaining to the user why
67//! what they did is a problem, and teaching them how to define their model in
68//! a different way, so the system knows the semantic relationships between
69//! geometrical objects.
70//!
71//! ### Validation
72//!
73//! These rules of explicitness must be validated, so the user can know if there
74//! is a problem in the model, and fix it. This is preferable to failing in
75//! unexpected ways later on.
76//!
77//! For the comparisons required for validation, an epsilon value must be used.
78//! This epsilon value can be derived from the size of the model, and should be
79//! chosen as high as possible, so any potential problems can be immediately
80//! reported as errors.
81//!
82//! If the user does something non-standard, they can override the epsilon value
83//! on a per-shape basis. Forcing the user to deal with these issues up-front
84//! should lead to less work overall.
85//!
86//! [Fornjot]: https://www.fornjot.app/
87
88#![warn(missing_docs)]
89
90pub mod algorithms;
91pub mod geometry;
92pub mod objects;
93pub mod operations;
94pub mod services;
95pub mod storage;
96pub mod validate;