diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml new file mode 100644 index 0000000..fc261c2 --- /dev/null +++ b/.github/workflows/update_version.yml @@ -0,0 +1,51 @@ +name: Release via GitHub Tag (with dev versions) + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install tools + run: | + cargo install cargo-set-version + + - name: Extract version from tag + id: version + run: | + TAG=${GITHUB_REF_NAME} + VERSION=${TAG#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Detected version: $VERSION" + + - name: Set release version + run: | + VERSION=${{ steps.version.outputs.version }} + echo "Setting release version $VERSION" + cargo set-version $VERSION + + - name: Commit release version bump + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + BRANCH="${{ github.event.release.target_commitish }}" + git add Cargo.toml + git commit -m "chore: set release version v${{ steps.version.outputs.version }}" + git push origin HEAD:$BRANCH + + - name: Move release tag to new commit + run: | + TAG=${{ github.event.release.tag_name }} + git tag -fa "$TAG" -m "Release $TAG (after version bump)" + git push origin "$TAG" --force diff --git a/Cargo.toml b/Cargo.toml index 63555d3..d019d78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polyshell" -version = "0.1.0" +version = "0.0.2-test" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/algorithms/simplify_charshape.rs b/src/algorithms/simplify_charshape.rs index 6459124..43ea68c 100644 --- a/src/algorithms/simplify_charshape.rs +++ b/src/algorithms/simplify_charshape.rs @@ -92,27 +92,27 @@ fn characteristic_shape(orig: &Polygon, eps: T, max_len: usize) -> Polygon where T: GeoFloat + SpadeNum, { - let orig_len = orig.exterior().0.len(); - - if orig_len < 3 { + if orig.exterior().0.len() < 3 { return orig.clone(); } let eps_2 = eps * eps; // Construct Delaunay triangulation + let num_vertices = orig.exterior().0.len() - 1; + let vertices = orig .exterior_coords_iter() - .take(orig_len - 1) // duplicate points are removed + .take(num_vertices) // duplicate points are removed .map(|c| Point2::new(c.x, c.y)) .collect::>(); - let edges = (0..orig_len - 2) + let edges = (0..num_vertices) .map(|i| { if i == 0 { [vertices.len() - 1, i] } else { - [i, i + 1] + [i - 1, i] } }) .collect::>(); @@ -143,8 +143,7 @@ where continue; } - let [from, to] = largest.edge.vertices().map(|v| v.index()); - if (to == from + 1) || (from == to + 1) || (to + from + 2 == orig_len) { + if largest.edge.is_constraint_edge() { continue; }