Skip to content

Commit 2484aef

Browse files
authored
Merge pull request #1 from radevgit/restructure_modules
Implement new algo for the cycle detection.
2 parents 47626f0 + 6af2be9 commit 2484aef

26 files changed

Lines changed: 10128 additions & 2335 deletions

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
## [0.1.0] - 2025-09-24
4+
- Implemented graph-based cycle detection algorithm
5+
- Added arc reconnection system for offset segments
6+
- Migrated to Togo library for improved geometry handling
7+
8+
## [v0.05] - 2024
9+
- Refactored offset configuration with SVG output flags
10+
- Added `offset_arcline` example
11+
- Renamed examples for clarity (`offset_simple``offset_polyline`)
12+
- Improved benchmark organization
13+
14+
## [v0.0.2] - 2024
15+
- Initial release with basic offset functionality

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
[package]
22
name = "offroad"
3-
version = "0.0.6"
3+
version = "0.1.0"
44
description = "2D offsetting for arc polylines/polygons."
55
rust-version = "1.88"
66
edition = "2024"
77
categories = ["algorithms", "data-structures", "graphics", "mathematics"]
88
keywords = ["offset", "arc", "polyline", "cnc", "polygon"]
99
license = "MIT"
10+
homepage = "https://github.com/radevgit/offroad"
1011
repository = "https://github.com/radevgit/offroad"
12+
documentation = "https://docs.rs/offroad"
1113
readme = "README.md"
1214

1315

1416

1517
[dependencies]
16-
geom = { package = "basegeom", version = "0.2.4" }
18+
togo = "0.4.0"
1719
robust = "1.2.0"
1820

1921
[lib]
@@ -23,6 +25,12 @@ crate-type = ["lib"]
2325
rand = "0.9.2"
2426
divan = "0.1.21"
2527

28+
[profile.release]
29+
lto = true
30+
codegen-units = 1
31+
panic = "abort"
32+
opt-level = 3
33+
2634
[[bench]]
2735
name = "bench_offset_multiple"
2836
harness = false

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To use the Offroad library in your project, add the following to your `Cargo.tom
77

88
```toml
99
[dependencies]
10-
offroad = "0.0.5"
10+
offroad = "0.1.0"
1111
```
1212

1313
## 2D offsetting for arc polylines/polygons
@@ -16,5 +16,42 @@ offroad = "0.0.5"
1616

1717
## Examples
1818

19-
Check "examples" directory for more usage examples.
19+
### Offsetting Arc Lines
20+
21+
```rust
22+
use togo::prelude::*;
23+
use offroad::{offset::offset_arcline_to_arcline, prelude::OffsetCfg};
24+
25+
fn main() {
26+
// Configuration for offsetting
27+
let mut cfg = OffsetCfg::default();
28+
let mut svg = SVG::new(300.0, 300.0, Some("/tmp/arcline.svg"));
29+
cfg.svg = Some(&mut svg);
30+
// Show original arcline in SVG output
31+
cfg.svg_orig = true;
32+
// Show final offset arclines in SVG output
33+
cfg.svg_final = true;
34+
35+
let arc0 = arc_circle_parametrization(point(40.0, 100.0), point(140.0, 200.0), 0.0);
36+
let arc1 = arc_circle_parametrization(point(140.0, 200.0), point(240.0, 100.0), 0.5);
37+
let arc2 = arc_circle_parametrization(point(240.0, 100.0), point(40.0, 100.0), 1.3);
38+
let arcs_orig = vec![arc0, arc1, arc2];
39+
40+
// External offsetting
41+
let offset_arclines = offset_arcline_to_arcline(&arcs_orig, 15.0, &mut cfg);
42+
43+
println!("Input arcline has {} vertices", arcs_orig.len());
44+
println!("Output has {} arclines", offset_arclines.len());
45+
for (i, arcline) in offset_arclines.iter().enumerate() {
46+
println!("Arcline {}: {} vertices", i, arcline.len());
47+
}
48+
49+
if let Some(svg) = cfg.svg.as_deref_mut() {
50+
// Write svg to file
51+
svg.write_stroke_width(0.1);
52+
}
53+
}
54+
```
55+
56+
2057

benches/bench_offset_multiple.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// https://nikolaivazquez.com/blog/divan/
22
//
33

4-
use geom::prelude::*;
4+
use togo::prelude::*;
55
use offroad::{offset::{offset_polyline_to_polyline, pline_01, OffsetCfg}};
66

77

@@ -34,15 +34,15 @@ fn bench_offset_polyline_to_polyline(off: f64) {
3434
Timer precision: 20 ns
3535
bench_offset_multiple fastest │ slowest │ median │ mean │ samples │ iters
3636
╰─ bench_offset_polyline_to_polyline │ │ │ │ │
37-
├─ 1 368.7 µs │ 384.5 µs │ 376.3 µs │ 376 µs │ 142800
38-
├─ 2 373.6 µs │ 413.5 µs │ 380.6 µs │ 384.6 µs │ 142800
39-
├─ 4 373.7 µs │ 409.5 µs │ 375.2 µs │ 379.3 µs │ 142800
40-
├─ 8 372 µs │ 440.5 µs │ 379 µs │ 383.8 µs │ 142800
41-
├─ 16 439.9 µs │ 1.033 ms541.8 µs │ 606.1 µs │ 9 │ 1800
42-
├─ 32 628 µs │ 908 µs │ 706.4 µs │ 730.5 µs │ 7 │ 1400
43-
├─ 64 679.9 µs │ 708 µs │ 687.6 µs │ 689.7 µs │ 8 │ 1600
44-
├─ 128 614.9 µs │ 635.9 µs │ 616 µs │ 620.7 µs │ 9 │ 1800
45-
╰─ 256 719.6 µs │ 742.2 µs │ 739.8 µs │ 736.8 µs │ 7 │ 1400
37+
├─ 1 328.7 µs │ 389.7 µs │ 330.2 µs │ 339.9 µs │ 153000
38+
├─ 2 329 µs │ 332.8 µs │ 329.9 µs │ 330.3 µs │ 163200
39+
├─ 4 328.7 µs │ 332.5 µs │ 330.2 µs │ 330.2 µs │ 163200
40+
├─ 8 329.2 µs │ 342.7 µs │ 329.9 µs │ 331.6 µs │ 163200
41+
├─ 16 333 µs │ 335.7 µs333.6 µs │ 333.9 µs │ 15 │ 3000
42+
├─ 32 346 µs │ 359.1 µs │ 347.1 µs │ 348.2 µs │ 15 │ 3000
43+
├─ 64 428.8 µs │ 430.9 µs │ 429.5 µs │ 429.7 µs │ 12 │ 2400
44+
├─ 128 410.3 µs │ 414.3 µs │ 411.1 µs │ 411.5 µs │ 13 │ 2600
45+
╰─ 256 502.3 µs │ 505 µs │ 503.5 µs │ 503.6 µs │ 10 │ 2000
4646
4747
4848
*/

0 commit comments

Comments
 (0)