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
4 changes: 2 additions & 2 deletions iOverlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ If you need more control, use `FloatPointAdapter::with_scale` and `FloatOverlay:

### 4. How do I enable OGC-valid output?

Set the `ocg` flag in `OverlayOptions`.
Set the `ogc` flag in `OverlayOptions`.

```rust
use i_overlay::core::fill_rule::FillRule;
Expand Down Expand Up @@ -478,7 +478,7 @@ let clip = vec![
vec![[2.0, 1.0], [2.0, 2.0], [3.0, 2.0], [3.0, 3.0], [4.0, 3.0], [4.0, 1.0]],
];

let options = OverlayOptions::<f64>::ocg();
let options = OverlayOptions::<f64>::ogc();
let mut overlay = FloatOverlay::with_subj_and_clip_custom(&subj, &clip, options, Default::default());
let result = overlay.overlay(OverlayRule::Difference, FillRule::EvenOdd);

Expand Down
4 changes: 2 additions & 2 deletions iOverlay/src/core/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl OverlayGraph<'_> {
buffer: &mut BooleanExtractionBuffer,
) -> IntShapes {
self.links.filter_by_overlay_into(overlay_rule, &mut buffer.visited);
if self.options.ocg {
self.extract_ocg(overlay_rule, buffer)
if self.options.ogc {
self.extract_ogc(overlay_rule, buffer)
} else {
self.extract(overlay_rule, buffer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use i_shape::int::shape::IntShapes;
use i_shape::util::reserve::Reserve;

impl OverlayGraph<'_> {
pub(crate) fn extract_ocg(
pub(crate) fn extract_ogc(
&self,
overlay_rule: OverlayRule,
buffer: &mut BooleanExtractionBuffer,
Expand Down
14 changes: 7 additions & 7 deletions iOverlay/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub mod overlay;
pub mod solver;
pub mod graph;
pub mod overlay_rule;
pub mod divide;
mod extract_ogc;
pub mod extract;
pub mod fill_rule;
pub mod simplify;
pub mod graph;
pub(crate) mod link;
pub(crate) mod nearest_vector;
pub mod divide;
mod exract_ocg;
pub mod overlay;
pub mod overlay_rule;
pub mod simplify;
pub mod solver;
12 changes: 6 additions & 6 deletions iOverlay/src/core/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct IntOverlayOptions {
pub min_output_area: u64,

/// If true, extract OGC-valid shapes.
pub ocg: bool,
pub ogc: bool,
}

/// Specifies the type of shape being processed, influencing how the shape participates in Boolean operations.
Expand Down Expand Up @@ -382,7 +382,7 @@ impl Default for IntOverlayOptions {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
}
}
}
Expand All @@ -394,7 +394,7 @@ impl IntOverlayOptions {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
}
}
pub fn keep_output_points() -> Self {
Expand All @@ -403,16 +403,16 @@ impl IntOverlayOptions {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
}
}
pub fn ocg() -> Self {
pub fn ogc() -> Self {
Self {
preserve_input_collinear: false,
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: true,
ogc: true,
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions iOverlay/src/float/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct OverlayOptions<T: FloatNumber> {
pub min_output_area: T,

/// If true, extract OGC-valid shapes.
pub ocg: bool,
pub ogc: bool,

/// If true, the result will be cleaned from precision-related issues
/// such as duplicate or nearly identical points. Especially useful for `f32` coordinates.
Expand Down Expand Up @@ -329,7 +329,7 @@ impl<T: FloatNumber> Default for OverlayOptions<T> {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: T::from_float(0.0),
ocg: false,
ogc: false,
clean_result,
}
}
Expand All @@ -342,7 +342,7 @@ impl<T: FloatNumber> OverlayOptions<T> {
output_direction: self.output_direction,
preserve_output_collinear: self.preserve_output_collinear,
min_output_area: adapter.sqr_float_to_int(self.min_output_area),
ocg: self.ocg,
ogc: self.ogc,
}
}

Expand All @@ -352,19 +352,19 @@ impl<T: FloatNumber> OverlayOptions<T> {
output_direction: self.output_direction,
preserve_output_collinear: self.preserve_output_collinear,
min_output_area: 0,
ocg: self.ocg,
ogc: self.ogc,
}
}

pub fn ocg() -> Self {
pub fn ogc() -> Self {
// f32 precision is not enough to cover i32
let clean_result = T::bit_width() <= 32;
Self {
preserve_input_collinear: false,
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: T::from_float(0.0),
ocg: true,
ogc: true,
clean_result,
}
}
Expand Down
8 changes: 4 additions & 4 deletions iOverlay/tests/direction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
};

let op1 = IntOverlayOptions {
preserve_input_collinear: false,
output_direction: ContourDirection::Clockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
};

let r0 = &path.simplify(FillRule::NonZero, op0)[0][0];
Expand Down Expand Up @@ -61,15 +61,15 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
};

let op1 = IntOverlayOptions {
preserve_input_collinear: false,
output_direction: ContourDirection::Clockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
};

let r0 = &path.simplify(FillRule::NonZero, op0)[0];
Expand Down
2 changes: 1 addition & 1 deletion iOverlay/tests/float_overlay_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: false,
min_output_area: 0.0,
ocg: false,
ogc: false,
clean_result: false,
};

Expand Down
10 changes: 5 additions & 5 deletions iOverlay/tests/ocg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod tests {
let mut overlay = Overlay::with_contours_custom(
&subj_paths,
&clip_paths,
IntOverlayOptions::ocg(),
IntOverlayOptions::ogc(),
Default::default(),
);

Expand Down Expand Up @@ -74,7 +74,7 @@ mod tests {
let mut overlay = Overlay::with_contours_custom(
&subj_paths,
&clip_paths,
IntOverlayOptions::ocg(),
IntOverlayOptions::ogc(),
Default::default(),
);

Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {
let mut overlay = Overlay::with_contours_custom(
&subj_paths,
&clip_paths,
IntOverlayOptions::ocg(),
IntOverlayOptions::ogc(),
Default::default(),
);

Expand Down Expand Up @@ -204,7 +204,7 @@ mod tests {
let mut overlay = Overlay::with_contours_custom(
&subj_paths,
&[],
IntOverlayOptions::ocg(),
IntOverlayOptions::ogc(),
Default::default(),
);

Expand Down Expand Up @@ -269,7 +269,7 @@ mod tests {
let mut overlay = Overlay::with_contours_custom(
&subj_paths,
&[],
IntOverlayOptions::ocg(),
IntOverlayOptions::ogc(),
Default::default(),
);

Expand Down
2 changes: 1 addition & 1 deletion iOverlay/tests/overlay_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod tests {
output_direction: ContourDirection::Clockwise,
preserve_output_collinear: false,
min_output_area: 0,
ocg: false,
ogc: false,
};

fn overlay(test: &BooleanTest, options: IntOverlayOptions, solver: Solver) -> Overlay {
Expand Down
8 changes: 4 additions & 4 deletions iOverlay/tests/simplify_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
};

let simplified = paths.simplify(FillRule::NonZero, op);
Expand Down Expand Up @@ -53,7 +53,7 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
};

let simplified = paths.simplify(FillRule::NonZero, op);
Expand Down Expand Up @@ -81,7 +81,7 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
};

let simplified = shapes.simplify(FillRule::NonZero, op);
Expand Down Expand Up @@ -148,7 +148,7 @@ mod tests {
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0,
ocg: false,
ogc: false,
};

let simple = paths.simplify(FillRule::NonZero, op);
Expand Down