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
6 changes: 3 additions & 3 deletions iTriangle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "i_triangle"
version = "0.44.0"
version = "0.45.0"
edition = "2021"
authors = ["Nail Sharipov <nailxsharipov@gmail.com>"]
description = "Polygon Triangulation Library: Efficient Delaunay Triangulation for Complex Shapes."
Expand All @@ -24,8 +24,8 @@ serde = { version = "^1.0", default-features = false, features = ["derive"], opt
#i_tree = { path = "../../iTree" }
#i_key_sort = { path = "../../iKeySort/iKeySort" }

i_overlay = "^6.0.0"
i_tree = "~0.18.0"
i_overlay = "^7.0.0"
i_tree = "~0.19.0"
i_key_sort = "~0.10.3"


Expand Down
49 changes: 27 additions & 22 deletions iTriangle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,7 @@ iTriangle is a high-performance 2D polygon triangulation library for Rust. It so

## Architecture Overview

<img src="readme/architecture.png" width="700"/>

<details>
<summary>Mermaid source</summary>

```mermaid
flowchart TD
A[Input contours] --> B[Normalize and fix self-intersections]
B --> C[Sweep-line triangulation]
C --> D[Raw triangulation]
D -->|Delaunay| E[Delaunay triangulation]
D --> I[Triangles and indices]
E -->|Tessellation| F[Adaptive refinement]
F --> E
E --> G[Convex decomposition]
E --> H[Centroid net]
E --> I
```

</details>
<img src="readme/architecture.svg" width="700"/>

## Quick Start

Expand All @@ -93,6 +74,29 @@ let triangulation = vec![contour].triangulate().to_triangulation::<u16>();
println!("triangles: {}", triangulation.indices.len() / 3);
```

By default, float input is converted to the robust integer core using `i32`
coordinates. If your geometry needs a different integer precision, choose it
explicitly:

```rust
use i_triangle::float::triangulatable::Triangulatable;
use i_triangle::float::triangulator::Triangulator;

let shape = vec![vec![
[0.0, 0.0],
[10.0, 0.0],
[10.0, 10.0],
[0.0, 10.0],
]];

// One-shot triangulation with i64 integer coordinates.
let mesh = shape.triangulate_as::<i64>().to_triangulation::<u32>();

// Reusable triangulator: first generic is index type, second is coordinate type.
let mut triangulator = Triangulator::<u32, i64>::default();
let mesh = triangulator.triangulate(&shape);
```

## Documentation

- [Docs.rs](https://docs.rs/i_triangle)
Expand Down Expand Up @@ -192,6 +196,7 @@ let contours = vec![
vec![[5.0, 0.0], [9.0, 0.0], [9.0, 4.0], [5.0, 4.0]],
];

// Uses u32 triangle indices and the default i32 integer coordinate solver.
let mut triangulator = Triangulator::<u32>::default();

// Enable Delaunay refinement
Expand Down Expand Up @@ -256,8 +261,8 @@ let contours = vec![
],
];

let mut triangulator = IntTriangulator::<u32>::default();
let mut output = IntTriangulation::<u32>::default();
let mut triangulator = IntTriangulator::<i32, u32>::default();
let mut output = IntTriangulation::<i32, u32>::default();

for contour in &contours {
triangulator.triangulate_contour_into(contour.clone(), &mut output);
Expand Down
Binary file removed iTriangle/readme/architecture.png
Binary file not shown.
Loading
Loading