-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive geometry algorithms and examples #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd0f1eb
4a4e122
8863f79
b3b795d
9e162e8
95914a2
a0b3061
18097d2
fe7f669
772570d
7195a7a
cafac53
2becf83
0112954
f764f96
a790c30
d4d13ff
d17da42
3487d96
94ab0e8
022d0f6
d635f31
b50cda9
a1005b9
fb1abdf
bf83d41
58c3538
3dea283
ef8c8ff
57b25ef
0033eea
478baf3
88fb47a
d26dbfb
d738bd2
356ffa3
3ad1d45
e9daae7
1707f05
accc903
5ff2dcc
1bf7fad
3c1bb0c
15d9261
1f3357e
2a2900f
1b739e5
161c245
c5fbc21
b938c0c
b6e83e7
edad54e
e896b0c
e1e5838
c7b17c7
861288b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -185,16 +185,20 @@ jobs: | |||
|
|
||||
| - name: Test | ||||
| run: | | ||||
| mkdir -p build/test_artifacts/golden_svg | ||||
| export ALEPH_TEST_GOLDEN_DIR="$PWD/build/test_artifacts/golden_svg" | ||||
| ctest --test-dir build --output-on-failure --parallel 2 --timeout 600 | ||||
|
|
||||
| - name: Upload test logs on failure | ||||
| if: failure() | ||||
| uses: actions/upload-artifact@v4 | ||||
| with: | ||||
| name: ctest-logs-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }} | ||||
| if-no-files-found: ignore | ||||
| path: | | ||||
| build/Testing/Temporary/LastTest.log | ||||
| build/CMakeCache.txt | ||||
| build/test_artifacts/golden_svg | ||||
|
|
||||
| coverage: | ||||
| name: coverage (ubuntu-24.04, gcc, Debug) | ||||
|
|
@@ -275,6 +279,8 @@ jobs: | |||
|
|
||||
| - name: Test | ||||
| run: | | ||||
| mkdir -p build-coverage/test_artifacts/golden_svg | ||||
| export ALEPH_TEST_GOLDEN_DIR="$PWD/build-coverage/test_artifacts/golden_svg" | ||||
| # Exclude this benchmark from coverage runs because instrumentation | ||||
| # changes timing characteristics and can make this test flaky. | ||||
| ctest --test-dir build-coverage --output-on-failure --parallel 2 --timeout 600 \ | ||||
|
|
@@ -292,7 +298,7 @@ jobs: | |||
| --gcov-ignore-errors source_not_found | ||||
| --gcov-ignore-errors no_working_dir_found | ||||
| --gcov-ignore-errors output_error | ||||
| --gcov-ignore-parse-errors negative_hits.warn | ||||
| --gcov-ignore-parse-errors all | ||||
|
||||
| --gcov-ignore-parse-errors all |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,30 +1,22 @@ | ||||||
| name: Coverity Scan | ||||||
|
|
||||||
| on: | ||||||
| # Trigger on push to workflow file and relevant source/build files | ||||||
| push: | ||||||
| paths: | ||||||
| - '.github/workflows/coverity.yml' | ||||||
| - 'src/**' | ||||||
| - 'include/**' | ||||||
| - '**/*.c' | ||||||
| - '**/*.cc' | ||||||
| - '**/*.cpp' | ||||||
| - '**/*.cxx' | ||||||
| - 'CMakeLists.txt' | ||||||
| # Weekly automatic scan on the default branch only. GitHub cron schedules run in UTC. | ||||||
| # Currently aligned to run at 06:00 UTC on Sunday, intended to be ~4 hours after the full_analysis workflow (02:00 UTC). | ||||||
| schedule: | ||||||
| - cron: '0 6 * * 0' | ||||||
| # Manual trigger - can select any branch from GitHub Actions UI | ||||||
| workflow_dispatch: | ||||||
| # Optional trigger for Pull Requests via label | ||||||
| pull_request: | ||||||
| types: [labeled] | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
|
|
||||||
| jobs: | ||||||
| coverity: | ||||||
| name: Coverity Static Analysis | ||||||
| # Only run if manually triggered or if the 'run-coverity' label was added to a PR | ||||||
| if: | | ||||||
| github.event_name == 'workflow_dispatch' || | ||||||
| (github.event_name == 'pull_request' && github.event.label.name == 'run-coverity') | ||||||
|
lrleon marked this conversation as resolved.
lrleon marked this conversation as resolved.
|
||||||
| (github.event_name == 'pull_request' && github.event.label.name == 'run-coverity') | |
| (github.event_name == 'pull_request' && github.event.action == 'labeled' && contains(github.event.pull_request.labels.*.name, 'run-coverity')) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| /* | ||
| Aleph_w | ||
|
|
||
| Data structures & Algorithms | ||
| version 2.0.0b | ||
| https://github.com/lrleon/Aleph-w | ||
|
|
||
| This file is part of Aleph-w library | ||
|
|
||
| Copyright (c) 2002-2026 Leandro Rabindranath Leon | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
| */ | ||
|
|
||
| /// @file chaikin_smoothing_example.cc | ||
| /// @brief Demonstrates Chaikin corner-cutting polygon smoothing with TikZ output. | ||
|
|
||
| # include <tikzgeom_algorithms.H> | ||
| # include <cassert> | ||
| # include <cmath> | ||
| # include <iostream> | ||
| # include <fstream> | ||
|
|
||
| using namespace std; | ||
| using namespace Aleph; | ||
|
|
||
| /// Build a 5-pointed star polygon centered at the origin. | ||
| static Polygon make_star(double outer_r = 10.0, double inner_r = 4.0) | ||
| { | ||
| Polygon poly; | ||
| for (int i = 0; i < 10; ++i) | ||
| { | ||
| double angle = M_PI / 2.0 + 2.0 * M_PI * i / 10.0; | ||
|
||
| double r = (i % 2 == 0) ? outer_r : inner_r; | ||
| poly.add_vertex(Point(r * cos(angle), r * sin(angle))); | ||
| } | ||
| poly.close(); | ||
| return poly; | ||
| } | ||
|
|
||
| /// Build an L-shaped polygon. | ||
| static Polygon make_L_shape() | ||
| { | ||
| Polygon poly; | ||
| poly.add_vertex(Point(0, 0)); | ||
| poly.add_vertex(Point(6, 0)); | ||
| poly.add_vertex(Point(6, 3)); | ||
| poly.add_vertex(Point(3, 3)); | ||
| poly.add_vertex(Point(3, 8)); | ||
| poly.add_vertex(Point(0, 8)); | ||
| poly.close(); | ||
| return poly; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| // 1. Star polygon | ||
| Polygon star = make_star(); | ||
| auto star_verts = GeomPolygonUtils::extract_vertices(star); | ||
| cout << "Star: " << star_verts.size() << " vertices" << endl; | ||
|
|
||
| // Smooth at 1..4 iterations | ||
| for (size_t k = 1; k <= 4; ++k) | ||
| { | ||
| Polygon smoothed = ChaikinSmoothing::smooth_polygon(star, k); | ||
| auto sv = GeomPolygonUtils::extract_vertices(smoothed); | ||
| cout << " iter " << k << ": " << sv.size() << " vertices" << endl; | ||
| } | ||
|
|
||
| // 2. L-shaped polygon | ||
| Polygon lshape = make_L_shape(); | ||
| auto l_verts = GeomPolygonUtils::extract_vertices(lshape); | ||
| cout << "L-shape: " << l_verts.size() << " vertices" << endl; | ||
|
|
||
| for (size_t k = 1; k <= 3; ++k) | ||
| { | ||
| Polygon smoothed = ChaikinSmoothing::smooth_polygon(lshape, k); | ||
| auto sv = GeomPolygonUtils::extract_vertices(smoothed); | ||
| cout << " iter " << k << ": " << sv.size() << " vertices" << endl; | ||
| } | ||
|
|
||
| // 3. TikZ output | ||
| ofstream tex("chaikin_smoothing_output.tex"); | ||
| tex << "\\documentclass[border=5mm]{standalone}\n" | ||
| << "\\usepackage{tikz}\n" | ||
| << "\\usepackage{subcaption}\n" | ||
| << "\\begin{document}\n" | ||
| << "\\begin{figure}\n"; | ||
|
|
||
| auto draw_subfig = [&](const char * caption, const Polygon & original, | ||
| const Polygon & smoothed) | ||
| { | ||
| Tikz_Plane plane(60, 60); | ||
| put_smoothing_result(plane, original, smoothed); | ||
| tex << "\\begin{minipage}{0.45\\textwidth}\\centering\n"; | ||
| plane.draw(tex); | ||
| tex << "\\captionof{subfigure}{" << caption << "}\n" | ||
| << "\\end{minipage}\\hfill\n"; | ||
| }; | ||
|
|
||
| // Star: original, 1, 2, 4 iterations | ||
| draw_subfig("Star original", star, star); | ||
| Polygon star1 = ChaikinSmoothing::smooth_polygon(star, 1); | ||
| draw_subfig("Star iter=1", star, star1); | ||
| tex << "\n\\medskip\n\n"; | ||
| Polygon star2 = ChaikinSmoothing::smooth_polygon(star, 2); | ||
| draw_subfig("Star iter=2", star, star2); | ||
| Polygon star4 = ChaikinSmoothing::smooth_polygon(star, 4); | ||
| draw_subfig("Star iter=4", star, star4); | ||
|
|
||
| tex << "\n\\bigskip\n\n"; | ||
|
|
||
| // L-shape: original, 1, 2, 3 iterations | ||
| draw_subfig("L-shape original", lshape, lshape); | ||
| Polygon l1 = ChaikinSmoothing::smooth_polygon(lshape, 1); | ||
| draw_subfig("L-shape iter=1", lshape, l1); | ||
| tex << "\n\\medskip\n\n"; | ||
| Polygon l2 = ChaikinSmoothing::smooth_polygon(lshape, 2); | ||
| draw_subfig("L-shape iter=2", lshape, l2); | ||
| Polygon l3 = ChaikinSmoothing::smooth_polygon(lshape, 3); | ||
| draw_subfig("L-shape iter=3", lshape, l3); | ||
|
|
||
| tex << "\\end{figure}\n" | ||
| << "\\end{document}\n"; | ||
|
|
||
| cout << "TikZ output written to chaikin_smoothing_output.tex" << endl; | ||
|
|
||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.