diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 84d3f051d4..f0a5c35517 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -4,11 +4,9 @@ on: push: branches: - main - - hackathon/dev pull_request: branches: - main - - hackathon/dev env: CTEST_OUTPUT_ON_FAILURE: ON @@ -146,7 +144,7 @@ jobs: uses: actions/checkout@v1 with: fetch-depth: 10 - + - name: Configure and build shell: cmd run: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..c03973a2e9 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,79 @@ +name: Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + CTEST_OUTPUT_ON_FAILURE: ON + CTEST_PARALLEL_LEVEL: 2 + +jobs: + Linux: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + include: + - os: ubuntu-latest + name: Linux + steps: + - name: Checkout repository + uses: actions/checkout@v1 + with: + fetch-depth: 10 + + - name: Dependencies + run: | + sudo apt-get update + sudo apt-get -o Acquire::Retries=3 install \ + lcov \ + ccache + echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV" + + - name: Cache Build + id: cache-build + uses: actions/cache@v2 + with: + path: ${{ env.CACHE_PATH }} + key: ${{ runner.os }}-Release-${{ matrix.tbb }}-cache-${{ github.sha }} + restore-keys: ${{ runner.os }}-Release-${{ matrix.tbb }}-cache + + - name: Prepare ccache + run: | + ccache --max-size=1.0G + ccache -V && ccache --show-stats && ccache --zero-stats + + - name: Configure + run: | + mkdir -p build + cd build + cmake .. \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_BUILD_TYPE=Release \ + -DWMTK_CODE_COVERAGE=ON + + - name: Build + run: cd build; make -j2; ccache --show-stats + + - name: Run Coverage + run: | + cd build + ctest --verbose --output-on-failure + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '*tests/*.cpp' '*tests/*.hpp' --output-file coverage.info + + - name: Upload Coverage + uses: codecov/codecov-action@v3 + with: + flags: wildmeshing # optional + files: coverage.info + name: wildmeshing # optional + fail_ci_if_error: false # optional (default = false) + verbose: true # optional (default = false) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9061a57045..3dbcacd606 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,18 @@ project(WildMeshingToolkit DESCRIPTION "A mesh optimization toolkit" LANGUAGES C option(WMTK_BUILD_DOCS "Build doxygen" OFF) option (BUILD_SHARED_LIBS "Build Shared Libraries" OFF) # we globally want to disable this option due to use of TBB +option(WMTK_CODE_COVERAGE "Enable coverage reporting" OFF) + +add_library(wmtk_coverage_config INTERFACE) +if(WMTK_CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + # Add required flags (GCC & LLVM/Clang) + target_compile_options(wmtk_coverage_config INTERFACE + -g # generate debug info + --coverage # sets all required flags + ) + target_link_options(wmtk_coverage_config INTERFACE --coverage) +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/recipes/") @@ -88,6 +100,9 @@ lagrange_include_modules(bvh) # Core library add_library(wildmeshing_toolkit) add_library(wmtk::toolkit ALIAS wildmeshing_toolkit) +target_link_libraries(wildmeshing_toolkit PUBLIC wmtk_coverage_config) + + add_subdirectory(src) # Group source files for IDEs diff --git a/README.md b/README.md index 8206b63a82..0dda32f2a8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build](https://github.com/wildmeshing/wildmeshing-toolkit/actions/workflows/continuous.yml/badge.svg)](https://github.com/wildmeshing/wildmeshing-toolkit/actions/workflows/continuous.yml) +[![codecov](https://codecov.io/github/wildmeshing/wildmeshing-toolkit/graph/badge.svg?token=CSBKSLUQW6)](https://codecov.io/github/wildmeshing/wildmeshing-toolkit) + # Wildmeshing-toolkit: Declarative Specification for Unstructured Mesh Editing Algorithms @@ -43,7 +46,7 @@ invariants. These algorithms are readable and easy to customize for specific use This software library implements the abstractiona in our paper and providing automatic shared memory parallelization. -We will use the implementation of the shortest edge collapse algorithm as an example to introduce the framework and run through the basic software structures and APIs of the toolkit. All the code that is referenced below can be found under the `app` folder of the toolkit. +We will use the implementation of the shortest edge collapse algorithm as an example to introduce the framework and run through the basic software structures and APIs of the toolkit. All the code that is referenced below can be found under the `app` folder of the toolkit. ## Basic Algorithm The algorithm is after [Hoppe 1996] Progressive Meshes which performs a series of collapse operations prioritizing the shorter edges. The algorithm requires only one local operation, edge collapse. We terminate when the mesh reaches a desired number of mesh elements. For every collapsed edge, we generate a new vertex at the midpoint of the edge. @@ -64,7 +67,7 @@ the mesh that needs to be satisfied, such as avoiding triangle insertions or sel modification, and after the input is loaded is assumed by the toolkit. It is much easier to ensure correctness for the user, as the checks are handled transparently by the toolkit. -As an example of user-defined invariants, in our shortest edge collapse implementation, we created an envelope around the original surface and designated that any operation shall not cause any vertex to move outside of the envelop, so that during local operations we can roughly keep the shape of the input mesh and avoid self-intersection. +As an example of user-defined invariants, in our shortest edge collapse implementation, we created an envelope around the original surface and designated that any operation shall not cause any vertex to move outside of the envelop, so that during local operations we can roughly keep the shape of the input mesh and avoid self-intersection. ``` bool sec::ShortestEdgeCollapse::invariants(const std::vector& new_tris) @@ -84,8 +87,8 @@ bool sec::ShortestEdgeCollapse::invariants(const std::vector& new_tris) The envelope development is after [Exact and Efficient Polyhedral Envelope Containment Check](https://cims.nyu.edu/gcl/papers/2020-Fast-Envelope.pdf) -## Explicit Attribute Update -Opposed to the common practice of attaching mesh attributes to mesh elements we enable the users to only provide the rules on how to update attributes after local operations in a high-level specifications. The actual update is handled entirely by the toolkit. +## Explicit Attribute Update +Opposed to the common practice of attaching mesh attributes to mesh elements we enable the users to only provide the rules on how to update attributes after local operations in a high-level specifications. The actual update is handled entirely by the toolkit. This easy-to-write user-specified update rule is examplified in our shortest edge collapse as below ``` @@ -105,7 +108,7 @@ improve a given energy functional, such as mesh quality or element size. However, due to the discrete nature of the operations, it is not possible to use standard smooth optimization techniques, and instead the effect of the energy is evaluated before and after every -operation to measure its effect on the energy. If the user desires a certain property of the mesh for each operation, the desiderata can be easily coded up as a check in the after operation. +operation to measure its effect on the energy. If the user desires a certain property of the mesh for each operation, the desiderata can be easily coded up as a check in the after operation. If either the user specified invariants or the after operation check/update has failed, the toolkit will perform an operation rollback that restores the mesh configuration to before the operation. And our toolkit also handles the recovery of element attributes on this occasion. The rollback and attribute protection gurantee both topology and geometry consistency for the mesh. Users would not need to perform any manual updates were the operations to fail, thank to the rollback. @@ -148,7 +151,7 @@ The type and scheduling of local operations is crucial in mesh editing algorithm We provide a direct way of controlling the operations performed and how the queue is updated through our scheduler. The main purpose of the scheduler is to abstract the operation order and hide parallelization details from -the user. Our scheduler provides customizable callbacks, including, *Priority*, *Renew neighbor*, *Lock vertices*, *Stopping criterion*. +the user. Our scheduler provides customizable callbacks, including, *Priority*, *Renew neighbor*, *Lock vertices*, *Stopping criterion*. For shortest edge collapse, we want to attempt to collapse all edges, prioritizing the shortest ones, until we reach a fixed number of vertices. @@ -156,7 +159,7 @@ For shortest edge collapse, we want to attempt to collapse all edges, prioritizi for (auto& loc : get_edges()) collect_all_ops.emplace_back("edge_collapse", loc); ``` - We put here the example of our shortest edge collapse implementation of the *Priority* and *Renew neighbor*, and how they are used in scheduler. + We put here the example of our shortest edge collapse implementation of the *Priority* and *Renew neighbor*, and how they are used in scheduler. ``` auto renew = [](auto& m, auto op, auto& tris) { auto edges = m.new_edges_after(tris); @@ -192,11 +195,11 @@ cd build - ### Shortest Edge Collpase : [Progressive Meshes](https://hhoppe.com/pm.pdf) ``` -Usage:./app/sec_app input output [OPTIONS] +Usage:./app/sec_app input output [OPTIONS] Required: - input Input surface mesh INPUT in .off/.obj/.stl/.ply format. - output Output tetmesh OUTPUT in .obj format. + input Input surface mesh INPUT in .off/.obj/.stl/.ply format. + output Output tetmesh OUTPUT in .obj format. Options: -e,--envelope Relative envelope size. enveleope_size = diag_of_bbox * e. negative to disable. @@ -205,11 +208,11 @@ Options: ``` - ### Qslim : [Surface Simplification Using Quadric Error Metrics](https://dl.acm.org/doi/pdf/10.1145/258734.258849) ``` -Usage:./app/qslim_app input output [OPTIONS] +Usage:./app/qslim_app input output [OPTIONS] Required: - input Input surface mesh INPUT in .off/.obj/.stl/.ply format. - output Output tetmesh OUTPUT in .obj format. + input Input surface mesh INPUT in .off/.obj/.stl/.ply format. + output Output tetmesh OUTPUT in .obj format. Options: -e,--envelope Relative envelope size. enveleope_size = diag_of_bbox * e. negative to disable. @@ -218,11 +221,11 @@ Options: ``` - ### Isotropic Remeshing : [A Remeshing Approach to Multiresolution Modeling](https://ls7-gv.cs.tu-dortmund.de/downloads/publications/2004/sgp04.pdf) ``` -Usage:./app/remeshing_app input output [OPTIONS] +Usage:./app/remeshing_app input output [OPTIONS] Required: - input Input surface mesh INPUT in .off/.obj/.stl/.ply format. - output Output tetmesh OUTPUT in .obj format. + input Input surface mesh INPUT in .off/.obj/.stl/.ply format. + output Output tetmesh OUTPUT in .obj format. Options: -e,--envelope Relative envelope size. enveleope_size = diag_of_bbox * e negative to disable. @@ -236,11 +239,11 @@ Options: - ### Harmonic Triangulations : [Harmonic Triangulations](https://dl.acm.org/doi/pdf/10.1145/3306346.3322986) ``` Usage: -./app/harmonic_tet/wmtk_harmonic_tet_bin input output +./app/harmonic_tet/wmtk_harmonic_tet_bin input output Required: - input Input surface mesh INPUT in .off/.obj/.stl/.ply format. - output Output tetmesh OUTPUT in .msh format. + input Input surface mesh INPUT in .off/.obj/.stl/.ply format. + output Output tetmesh OUTPUT in .msh format. Options: -j, --thread thread Thread number. @@ -253,8 +256,8 @@ Usage: ./app/tetwild/tetwild -i input -o output Required: - input Input surface mesh INPUT in .off/.obj/.stl/.ply format. - output Output tetmesh OUTPUT in .msh format. + input Input surface mesh INPUT in .off/.obj/.stl/.ply format. + output Output tetmesh OUTPUT in .msh format. Options: -e,--epsr Relative envelope size. enveleope_size = diag_of_bbox * e negative to disable.