Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,13 @@ cargo add delaunay@0.7.8

Use `cargo add delaunay` instead if you want Cargo to select the newest published release.

`thiserror` is used in the example only to keep the local typed error wrapper compact; `delaunay` APIs
return concrete typed errors. Requirements:

- Rust 1.96.0 or newer, pinned by `Cargo.toml` and `rust-toolchain.toml`.
- `f64` coordinates for caller-facing construction, predicate, validation, and generator APIs.

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;

#[derive(Debug, thiserror::Error)]
enum ExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}
use delaunay::prelude::construction::{DelaunayResult, DelaunayTriangulationBuilder, vertex};

fn main() -> Result<(), ExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down
36 changes: 4 additions & 32 deletions docs/api_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,10 @@ For most use cases, the builder with default options is sufficient:

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
DelaunayResult, DelaunayTriangulationBuilder, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::insertion::InsertionError;
use delaunay::prelude::tds::InvariantError;

#[derive(Debug, thiserror::Error)]
enum ExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Insertion(#[from] InsertionError),
#[error(transparent)]
Topology(#[from] InvariantError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ExampleError> {
fn main() -> DelaunayResult<()> {
// Simple construction from vertices (Euclidean space, default options)
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -113,24 +98,11 @@ use `DelaunayTriangulationBuilder`:

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::insertion::InsertionError;
use delaunay::prelude::validation::ValidationPolicy;

#[derive(Debug, thiserror::Error)]
enum ExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Insertion(#[from] InsertionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ExampleError> {
fn main() -> DelaunayResult<()> {
// Canonicalized toroidal triangulation in 2D
let vertices = vec![
vertex![0.1, 0.1]?,
Expand Down
7 changes: 5 additions & 2 deletions docs/dev/tooling-alignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,11 @@ just verify-expect-counts
The `verify-expect-counts` recipe tracks only that remaining doctest baseline.
When extending the zero-tolerance Semgrep rule to doctests, prefer:

- `fn main() -> Result<(), ExampleError>` in examples, with local
`#[derive(thiserror::Error)]` enums that wrap the crate's typed errors.
- `fn main() -> DelaunayResult<()>` in examples whose fallible surface is
covered by `DelaunayError`.
- Local `#[derive(thiserror::Error)]` enums only when examples also need
workflow-specific typed errors such as convex-hull, flip, repair, or
delaunayize failures.
- Setup helpers returning typed `Result` values in benchmarks; Criterion entry
points may still abort setup explicitly, but benchmark bodies should not hide
fallible API calls behind panic-only setup.
Expand Down
15 changes: 2 additions & 13 deletions docs/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,9 @@ delaunay = { version = "...", features = ["diagnostics"] }
For most validation work, start with the always-available APIs:

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::construction::{DelaunayResult, DelaunayTriangulationBuilder, vertex};

#[derive(Debug, thiserror::Error)]
enum DiagnosticsExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), DiagnosticsExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down
74 changes: 11 additions & 63 deletions docs/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,11 @@ deviates from the happy-path and trips internal **suspicion flags**, e.g.:

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::validation::{ValidationConfigurationError, ValidationPolicy};

#[derive(Debug, thiserror::Error)]
enum ValidationExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
#[error(transparent)]
Configuration(#[from] ValidationConfigurationError),
}
use delaunay::prelude::validation::ValidationPolicy;

fn main() -> Result<(), ValidationExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -162,21 +150,11 @@ PL-manifoldness. You can trigger that final certification via

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::validation::ValidationPolicy;

#[derive(Debug, thiserror::Error)]
enum ValidationExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ValidationExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -323,21 +301,11 @@ Validates the combinatorial structure of the Triangulation Data Structure.

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::validation::ValidationPolicy;

#[derive(Debug, thiserror::Error)]
enum ValidationExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ValidationExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -417,21 +385,11 @@ Validates that the triangulation forms a valid topological manifold.

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::validation::ValidationPolicy;

#[derive(Debug, thiserror::Error)]
enum ValidationExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ValidationExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -498,21 +456,11 @@ Validates the geometric optimality of the triangulation.

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, TopologyGuarantee,
vertex,
DelaunayResult, DelaunayTriangulationBuilder, TopologyGuarantee, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::validation::ValidationPolicy;

#[derive(Debug, thiserror::Error)]
enum ValidationExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ValidationExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down
72 changes: 11 additions & 61 deletions docs/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,9 @@ snippets into an application.
For most use cases, construction is a single call:

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;

#[derive(Debug, thiserror::Error)]
enum ExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}
use delaunay::prelude::construction::{DelaunayResult, DelaunayTriangulationBuilder, vertex};

fn main() -> Result<(), ExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -183,20 +172,11 @@ detections, etc.).

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
DelaunayResult, DelaunayTriangulationBuilder, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::repair::DelaunayRepairError;

#[derive(Debug, thiserror::Error)]
enum RepairExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), RepairExampleError> {
fn main() -> DelaunayResult<()> {
let vertices = vec![
vertex![0.0, 0.0, 0.0]?,
vertex![1.0, 0.0, 0.0]?,
Expand Down Expand Up @@ -282,22 +262,10 @@ uses the image-point method to build a true periodic quotient in the validated

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, vertex,
DelaunayResult, DelaunayTriangulationBuilder, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::insertion::InsertionError;

#[derive(Debug, thiserror::Error)]
enum ToroidalExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Insertion(#[from] InsertionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), ToroidalExampleError> {
fn main() -> DelaunayResult<()> {
// 2D canonicalized toroidal triangulation with unit square domain
let vertices = vec![
vertex![0.1, 0.1]?,
Expand Down Expand Up @@ -338,19 +306,10 @@ accessor, and modified post-construction via `set_vertex_data` / `set_simplex_da

```rust
use delaunay::prelude::construction::{
DelaunayTriangulationBuilder, DelaunayTriangulationConstructionError, Vertex, vertex,
DelaunayResult, DelaunayTriangulationBuilder, Vertex, vertex,
};
use delaunay::prelude::geometry::CoordinateConversionError;

#[derive(Debug, thiserror::Error)]
enum DataExampleError {
#[error(transparent)]
Construction(#[from] DelaunayTriangulationConstructionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}

fn main() -> Result<(), DataExampleError> {
fn main() -> DelaunayResult<()> {
// Attach integer labels at construction time
let vertices: [Vertex<i32, 2>; 3] = [
vertex![0.0, 0.0; data = 10i32]?,
Expand Down Expand Up @@ -409,19 +368,10 @@ want to keep going after skipped vertices, use the explicitly best-effort
`insert_best_effort_with_statistics()`.

```rust
use delaunay::prelude::construction::{DelaunayTriangulation, vertex};
use delaunay::prelude::geometry::CoordinateConversionError;
use delaunay::prelude::insertion::{InsertionError, InsertionOutcome};

#[derive(Debug, thiserror::Error)]
enum InsertionStatsExampleError {
#[error(transparent)]
Insertion(#[from] InsertionError),
#[error(transparent)]
Coordinate(#[from] CoordinateConversionError),
}
use delaunay::prelude::construction::{DelaunayResult, DelaunayTriangulation, vertex};
use delaunay::prelude::insertion::InsertionOutcome;

fn main() -> Result<(), InsertionStatsExampleError> {
fn main() -> DelaunayResult<()> {
let mut dt: DelaunayTriangulation<_, (), (), 3> = DelaunayTriangulation::empty();

let (outcome, stats) = dt.insert_best_effort_with_statistics(vertex![0.5, 0.5, 0.5]?)?;
Expand Down
Loading
Loading