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
2 changes: 1 addition & 1 deletion iOverlay/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "i_overlay"
version = "7.0.0"
version = "7.0.1"
authors = ["Nail Sharipov <nailxsharipov@gmail.com>"]
edition = "2024"
rust-version = "1.88"
Expand Down
5 changes: 4 additions & 1 deletion iOverlay/src/core/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ where
points.clear();
points.push(start_data.begin);

let last_link_id =
GraphUtil::next_link(self.links, self.nodes, link_id, last_node_id, !clockwise, visited);

// Find a closed tour
while node_id != last_node_id {
while link_id != last_link_id {
link_id = GraphUtil::next_link(self.links, self.nodes, link_id, node_id, clockwise, visited);

let link = unsafe {
Expand Down
16 changes: 14 additions & 2 deletions iOverlay/src/core/extract_ogc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ where

visited.visit_edge(link_id, visited_state);

let last_link_id =
GraphUtil::next_link(self.links, self.nodes, link_id, last_node_id, !clockwise, visited);

// Find a closed tour
while node_id != last_node_id {
while link_id != last_link_id {
link_id = GraphUtil::next_link(self.links, self.nodes, link_id, node_id, clockwise, visited);

let link = unsafe {
Expand Down Expand Up @@ -237,10 +240,19 @@ where
global_visited.visit_edge(link_id, VisitState::HullVisited);
contour_visited.visit_edge(link_id, VisitState::Unvisited);

let last_link_id = GraphUtil::next_link(
self.links,
self.nodes,
link_id,
last_node_id,
!clockwise,
global_visited,
);

let mut original_contour_len = 1;

// Find a closed tour
while node_id != last_node_id {
while link_id != last_link_id {
link_id = GraphUtil::next_link(
self.links,
self.nodes,
Expand Down
33 changes: 32 additions & 1 deletion iOverlay/src/vector/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ where
store,
));

let last_link_id =
GraphUtil::next_link(self.links, self.nodes, link_id, last_node_id, !clockwise, visited);

// Find a closed tour
while node_id != last_node_id {
while link_id != last_link_id {
link_id = GraphUtil::next_link(self.links, self.nodes, link_id, node_id, clockwise, visited);

let link = unsafe {
Expand Down Expand Up @@ -532,4 +535,32 @@ mod tests {

debug_assert!(shapes.len() == 2);
}

#[test]
fn test_self_touching_contour_closes_by_edge() {
#[rustfmt::skip]
let subj = int_shape![
[[-5, 0], [0, 0], [0, 5]],
[[-3, 2], [-1, 2], [-1, 1]],
];

let mut buffer = Default::default();
let mut overlay = Overlay::with_contours(&subj, &[]);
overlay.options = IntOverlayOptions {
preserve_input_collinear: false,
output_direction: ContourDirection::CounterClockwise,
preserve_output_collinear: true,
min_output_area: 0u64,
ogc: false,
};

let shapes = overlay
.build_graph_view(FillRule::NonZero)
.unwrap()
.extract_vector_shapes(OverlayRule::Subject, &mut buffer);

assert_eq!(shapes.len(), 1);
assert_eq!(shapes[0].len(), 1);
assert_eq!(shapes[0][0].len(), 7);
}
}
10 changes: 5 additions & 5 deletions iOverlay/tests/boolean/test_138.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"fillRule": 1,
"subjPaths": [[[0, 0], [0, 80], [90, 80], [90, 0]], [[10, 10], [80, 10], [80, 50], [10, 50], [70, 20], [70, 40]], [[50, 60], [60, 60], [60, 70], [50, 70]]],
"clipPaths": [],
"subject": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"subject": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"clip": [[]],
"union": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"union": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"intersect": [[]],
"difference": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"difference": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"inverseDifference": [[]],
"xor": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]]
}
"xor": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]]
}
10 changes: 5 additions & 5 deletions iOverlay/tests/boolean/test_139.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"fillRule": 1,
"subjPaths": [[[0, 0], [0, 80], [90, 80], [90, 0]], [[10, 10], [80, 10], [80, 50], [10, 50], [70, 20], [70, 40]], [[20, 60], [30, 60], [30, 70], [20, 70]], [[50, 60], [60, 60], [60, 70], [50, 70]]],
"clipPaths": [],
"subject": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"subject": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"clip": [[]],
"union": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"union": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"intersect": [[]],
"difference": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]],
"difference": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]],
"inverseDifference": [[]],
"xor": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]], [[[50, 30], [70, 40], [70, 20]]]]]
}
"xor": [[[[[0, 0], [0, 80], [90, 80], [90, 0]], [[50, 30], [10, 10], [80, 10], [80, 50], [10, 50], [50, 30], [70, 40], [70, 20]], [[20, 70], [20, 60], [30, 60], [30, 70]], [[50, 70], [50, 60], [60, 60], [60, 70]]]]]
}
10 changes: 5 additions & 5 deletions iOverlay/tests/boolean/test_150.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"fillRule": 1,
"subjPaths": [[[0, 0], [4, -1], [4, 1]], [[0, 0], [5, 2], [5, -2]], [[0, 0], [6, -3], [6, 3]], [[0, 0], [7, 4], [7, -4]]],
"clipPaths": [],
"subject": [[[[[0, 0], [7, 4], [7, -4]], [[6, 3], [0, 0], [5, 2], [5, -2], [0, 0], [6, -3]], [[4, 1], [0, 0], [4, -1]]]]],
"subject": [[[[[0, 0], [7, 4], [7, -4], [0, 0], [6, -3], [6, 3]]], [[[0, 0], [5, 2], [5, -2], [0, 0], [4, -1], [4, 1]]]]],
"clip": [[]],
"union": [[[[[0, 0], [7, 4], [7, -4]], [[6, 3], [0, 0], [5, 2], [5, -2], [0, 0], [6, -3]], [[4, 1], [0, 0], [4, -1]]]]],
"union": [[[[[0, 0], [7, 4], [7, -4], [0, 0], [6, -3], [6, 3]]], [[[0, 0], [5, 2], [5, -2], [0, 0], [4, -1], [4, 1]]]]],
"intersect": [[]],
"difference": [[[[[0, 0], [7, 4], [7, -4]], [[6, 3], [0, 0], [5, 2], [5, -2], [0, 0], [6, -3]], [[4, 1], [0, 0], [4, -1]]]]],
"difference": [[[[[0, 0], [7, 4], [7, -4], [0, 0], [6, -3], [6, 3]]], [[[0, 0], [5, 2], [5, -2], [0, 0], [4, -1], [4, 1]]]]],
"inverseDifference": [[]],
"xor": [[[[[0, 0], [7, 4], [7, -4]], [[6, 3], [0, 0], [5, 2], [5, -2], [0, 0], [6, -3]], [[4, 1], [0, 0], [4, -1]]]]]
}
"xor": [[[[[0, 0], [7, 4], [7, -4], [0, 0], [6, -3], [6, 3]]], [[[0, 0], [5, 2], [5, -2], [0, 0], [4, -1], [4, 1]]]]]
}
61 changes: 6 additions & 55 deletions iOverlay/tests/boolean/test_151.json
Original file line number Diff line number Diff line change
@@ -1,61 +1,12 @@
{
"fillRule": 1,
"subjPaths": [
[[0, 0], [3, 3], [6, 0]],
[[0, 0], [3,-3], [0,-6]],
[[3,-3], [6, 0], [6,-6]],
[[3,-3], [5,-4], [5,-2]]
],
"subjPaths": [[[0, 0], [3, 3], [6, 0]], [[0, 0], [3, -3], [0, -6]], [[3, -3], [6, 0], [6, -6]], [[3, -3], [5, -4], [5, -2]]],
"clipPaths": [],
"subject": [[
[
[[0, -6], [0, 0], [3, -3]]
],
[
[[0, 0], [3, 3], [6, 0]]
],
[
[[3, -3], [6, 0], [6, -6]],
[[5, -2], [3, -3], [5, -4]]
]
]],
"subject": [[[[[0, -6], [0, 0], [3, -3]]], [[[0, 0], [3, 3], [6, 0]]], [[[3, -3], [6, 0], [6, -6], [3, -3], [5, -4], [5, -2]]]]],
"clip": [[]],
"union": [[
[
[[0, -6], [0, 0], [3, -3]]
],
[
[[0, 0], [3, 3], [6, 0]]
],
[
[[3, -3], [6, 0], [6, -6]],
[[5, -2], [3, -3], [5, -4]]
]
]],
"union": [[[[[0, -6], [0, 0], [3, -3]]], [[[0, 0], [3, 3], [6, 0]]], [[[3, -3], [6, 0], [6, -6], [3, -3], [5, -4], [5, -2]]]]],
"intersect": [[]],
"difference": [[
[
[[0, -6], [0, 0], [3, -3]]
],
[
[[0, 0], [3, 3], [6, 0]]
],
[
[[3, -3], [6, 0], [6, -6]],
[[5, -2], [3, -3], [5, -4]]
]
]],
"difference": [[[[[0, -6], [0, 0], [3, -3]]], [[[0, 0], [3, 3], [6, 0]]], [[[3, -3], [6, 0], [6, -6], [3, -3], [5, -4], [5, -2]]]]],
"inverseDifference": [[]],
"xor": [[
[
[[0, -6], [0, 0], [3, -3]]
],
[
[[0, 0], [3, 3], [6, 0]]
],
[
[[3, -3], [6, 0], [6, -6]],
[[5, -2], [3, -3], [5, -4]]
]
]]
}
"xor": [[[[[0, -6], [0, 0], [3, -3]]], [[[0, 0], [3, 3], [6, 0]]], [[[3, -3], [6, 0], [6, -6], [3, -3], [5, -4], [5, -2]]]]]
}
10 changes: 5 additions & 5 deletions iOverlay/tests/boolean/test_152.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"fillRule": 1,
"subjPaths": [[[0, 0], [3, 4], [3, 1]], [[0, 0], [2, 1], [2, 2]], [[0, 0], [3, -1], [3, -4]], [[0, 0], [2, -2], [2, -1]]],
"clipPaths": [],
"subject": [[[[[0, 0], [3, 4], [3, 1]], [[2, 2], [0, 0], [2, 1]]], [[[0, 0], [3, -1], [3, -4]], [[2, -1], [0, 0], [2, -2]]]]],
"subject": [[[[[0, 0], [3, 4], [3, 1], [0, 0], [2, 1], [2, 2]]], [[[0, 0], [3, -1], [3, -4], [0, 0], [2, -2], [2, -1]]]]],
"clip": [[]],
"union": [[[[[0, 0], [3, 4], [3, 1]], [[2, 2], [0, 0], [2, 1]]], [[[0, 0], [3, -1], [3, -4]], [[2, -1], [0, 0], [2, -2]]]]],
"union": [[[[[0, 0], [3, 4], [3, 1], [0, 0], [2, 1], [2, 2]]], [[[0, 0], [3, -1], [3, -4], [0, 0], [2, -2], [2, -1]]]]],
"intersect": [[]],
"difference": [[[[[0, 0], [3, 4], [3, 1]], [[2, 2], [0, 0], [2, 1]]], [[[0, 0], [3, -1], [3, -4]], [[2, -1], [0, 0], [2, -2]]]]],
"difference": [[[[[0, 0], [3, 4], [3, 1], [0, 0], [2, 1], [2, 2]]], [[[0, 0], [3, -1], [3, -4], [0, 0], [2, -2], [2, -1]]]]],
"inverseDifference": [[]],
"xor": [[[[[0, 0], [3, 4], [3, 1]], [[2, 2], [0, 0], [2, 1]]], [[[0, 0], [3, -1], [3, -4]], [[2, -1], [0, 0], [2, -2]]]]]
}
"xor": [[[[[0, 0], [3, 4], [3, 1], [0, 0], [2, 1], [2, 2]]], [[[0, 0], [3, -1], [3, -4], [0, 0], [2, -2], [2, -1]]]]]
}
Loading
Loading