Skip to content
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

Adds CI for GNU testing #15

Merged
merged 4 commits into from
Jan 13, 2025
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
47 changes: 32 additions & 15 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
name: "Build and test"

on:
push:
branches:
- master
- dev
pull_request:
branches:
- main
- dev

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
builds-and-tests:
strategy:
matrix:
os: [windows-latest]
preset: [
{"os": windows-latest, "name": "msbuild"},
{"os": ubuntu-latest, "name": "gnu"}
]
build-type: ["Debug", "Release"]

name: ${{ matrix.os }}-${{ matrix.target }}

runs-on: ${{ matrix.os }}
fail-fast: false

name: ${{ matrix.preset.os }} / ${{matrix.preset.name}} / ${{matrix.build-type}}
runs-on: ${{ matrix.preset.os }}

steps:
- name: checkout repository
Expand All @@ -33,12 +37,25 @@ jobs:
with:
vcpkgJsonGlob: 'vcpkg.json'

- name: Configure and build
- name: Windows configure and build
if: matrix.preset.name=='msbuild'
run: |
cmake --preset "msbuild-vcpkg" -S . -B build
cmake --build build --config Release -j
cmake --preset ${{matrix.preset.name}} -S . -B build
cmake --build build --config ${{matrix.build-type}} -j

- name: Windows Run tests
if: matrix.preset.name=='msbuild'
run: build/bin/${{matrix.build-type}}/tessellator_tests.exe

- name: Ubuntu configure and build
if: matrix.preset.name=='gnu'
run: |
cmake --preset ${{matrix.preset.name}} -S . -B build
cmake --build build -j

- name: Ubuntu Run tests
if: matrix.preset.name=='gnu'
run: build/bin/tessellator_tests

- name: Run tests
run: build/bin/Release/tessellator_tests.exe


4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
out/*
build*/
build/
/obj/
/bin/
/doc/*/latex
Expand All @@ -14,4 +15,5 @@ src/*.json
.vscode/

testData/*_out.stl
*_out.stl
*_out.stl
CMakeUserPresets.json
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.20)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
Expand All @@ -10,20 +10,25 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

project(tessellator CXX)

option(TESSELLATOR_ENABLE_TESTS "Compile tests" ON)
option(TESSELLATOR_USE_CGAL "Compile using CGAL library" ON)
option(TESSELLATOR_ENABLE_CGAL "Compile using CGAL library" ON)
option(TESSELLATOR_EXECUTION_POLICIES OFF)

add_subdirectory(src/)

if (TESSELLATOR_USE_CGAL)
add_definitions("-DTESSELLATOR_USE_CGAL")
if(TESSELLATOR_ENABLE_CGAL)
list(APPEND VCPKG_MANIFEST_FEATURES "cgal")
endif()

if(TESSELLATOR_ENABLE_TESTS)
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
endif()

project(tessellator CXX)

add_subdirectory(src/)

if(TESSELLATOR_ENABLE_TESTS)
enable_testing()
enable_testing()
add_subdirectory(test/)
add_test(tessellator ${CMAKE_BINARY_DIR}/tessellator_tests)
endif()
41 changes: 18 additions & 23 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"version": 4,
"configurePresets": [
{
"name": "msbuild-vcpkg",
"displayName": "MSBuild (vcpkg toolchain) Configure Settings",
"description": "Configure with VS generators and with vcpkg toolchain",
"generator": "Visual Studio 17 2022",
"binaryDir": "build/${presetName}",
"architecture": {
"strategy": "set",
"value": "x64"
},
"name": "default",
"hidden": true,
"binaryDir": "build/",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
Expand All @@ -19,25 +13,26 @@
}
},
{
"name": "ninja-dbg",
"displayName": "ninja-dbg",
"name": "msbuild",
"displayName": "MSBuild Configure Settings",
"generator": "Visual Studio 17 2022",
"architecture": {
"strategy": "set",
"value": "x64"
},
"inherits": "default"
},
{
"name": "gnu",
"displayName": "GNU g++ compiler",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_MAKE_PROGRAM": "C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/Ninja/ninja.exe",
"CMAKE_CXX_COMPILER": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
"inherits": "default"
}
],
"buildPresets": [
{
"name": "msbuild-vcpkg",
"configurePreset": "msbuild-vcpkg",
"displayName": "Build MSBuild",
"description": "Build with MSBuild (VS)"
"name": "default",
"configurePreset": "default"
}
]
}
33 changes: 0 additions & 33 deletions CMakeSettings.json

This file was deleted.

24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![License](https://img.shields.io/badge/License-GPL_3.0-blue.svg)](https://opensource.org/licenses/gpl-3.0)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/mit)

[![Windows tests](https://github.com/OpenSEMBA/tessellator/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/OpenSEMBA/tessellator/actions/workflows/build-and-test.yml)
[![Build and test](https://github.com/OpenSEMBA/tessellator/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/OpenSEMBA/tessellator/actions/workflows/build-and-test.yml)

## Features

Expand All @@ -18,6 +18,28 @@ Tessellator is a mesher focused on generate meshes and data structures which are
## Compilation

When using presets, make sure to define the environment variable `VCPKG_ROOT` to your `vcpkg` installation.
This can be done using a `CMakeUserPreset.json` file, for example:

```json
{
"version": 4,

"include": ["CMakePresets.json"],
"configurePresets": [
{
"name": "gnu-local",
"displayName": "GNU local",
"environment": {
"VCPKG_ROOT": "~/workspace/vcpkg/"
},
"cacheVariables": {
"TESSELLATOR_ENABLE_CGAL": true
},
"inherits": "gnu"
}
]
}
```

## Contributing

Expand Down
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cmake_minimum_required(VERSION 3.20)

include_directories(".")

add_subdirectory(utils)

if (TESSELLATOR_USE_CGAL)
if (TESSELLATOR_ENABLE_CGAL)
add_subdirectory(cgal)
endif()

Expand Down
1 change: 1 addition & 0 deletions src/cgal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ add_library(tessellator-cgal
)

find_package(CGAL CONFIG REQUIRED)

target_link_libraries(tessellator-cgal CGAL::CGAL)
8 changes: 4 additions & 4 deletions src/cgal/filler/Filler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "utils/MeshTools.h"

#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_slicer.h>

Expand All @@ -25,12 +25,12 @@ using namespace tools;
namespace PMP = CGAL::Polygon_mesh_processing;

using Primitive = CGAL::AABB_face_graph_triangle_primitive<Polyhedron>;
using Traits = CGAL::AABB_traits<K, Primitive>;
using Traits = CGAL::AABB_traits_3<K, Primitive>;
using LineIntersectionsTree = CGAL::AABB_tree<Traits> ;
using LineE3_intersection = boost::optional< LineIntersectionsTree::Intersection_and_primitive_id<Line3>::Type > ;

using HGSP = CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron>;
using AABB_traits = CGAL::AABB_traits<K, HGSP>;
using AABB_traits = CGAL::AABB_traits_3<K, HGSP>;
using PMSlicerTree = CGAL::AABB_tree<AABB_traits>;
using PMSlicer = CGAL::Polygon_mesh_slicer<Polyhedron, K>;

Expand Down Expand Up @@ -297,7 +297,7 @@ Segments1 convertToSegments1(const std::list<LineE3_intersection>& inters, const

std::set<Segment1> segs;
for (auto it = inters.begin(); it != inters.end(); ++it) {
if (const auto& e = boost::get<Segment3>(&((*it)->first))) {
if (const auto& e = std::get_if<Segment3>(&((*it)->first))) {
segs.insert(
Segment1{
Point1{(*e)[0][(int)x]},
Expand Down
4 changes: 2 additions & 2 deletions src/cgal/filler/FillerTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ bool isCellCrossedByTriangle(const Triangle2& t, const ArrayIndex& idx)
return false;
}
if (CGAL::do_intersect(cF, t)) {
auto iP{ *CGAL::intersection(cF, t) };
if (!boost::get<Point2 >(&iP)) {
const auto iP{ CGAL::intersection(cF, t) };
if (iP && !std::get_if<Point2>(&*iP)) {
return true;
}
}
Expand Down
14 changes: 5 additions & 9 deletions src/cgal/filler/Slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

#include "cgal/Tools.h"

#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>

namespace meshlib::cgal::filler {

using Bbox2 = CGAL::Bbox_2;
Expand Down Expand Up @@ -85,8 +81,8 @@ bool isCellCrossedByPolylines(const Polylines2& pls, const ArrayIndex& idx)
for (auto it{ pl.begin() }; std::next(it) != pl.end(); ++it) {
Segment2 seg{ *it, *std::next(it) };
if (CGAL::do_intersect(cF, seg)) {
auto intersection{*CGAL::intersection(cF, seg)};
if (!boost::get<Point2 >(&intersection)) {
const auto result = CGAL::intersection(cF, seg);
if (result && !std::get_if<Point2>(&*result)) {
return true;
}
}
Expand Down Expand Up @@ -333,12 +329,12 @@ Polygon buildPolygonFromFaceTriIntersection(
return Polygon();
}
Polygon r;
if (const auto& t = boost::get<Triangle2>(&*intResult)) {
if (const auto& t = std::get_if<Triangle2>(&*intResult)) {
for (int i{ 0 }; i < 3; ++i) {
r.push_back(t->vertex(i));
}
}
else if (const auto& ps = boost::get<std::vector<Point2>>(&*intResult)) {
else if (const auto& ps = std::get_if<std::vector<Point2>>(&*intResult)) {
assert(ps->size() > 3);
for (std::size_t i{ 0 }; i < ps->size(); ++i) {
r.push_back((*ps)[i]);
Expand All @@ -358,7 +354,7 @@ Polyline2 buildCellLineIntersection(
if (!intResult) {
continue;
};
if (const auto& p = boost::get<Segment2>(&*intResult)) {
if (const auto& p = std::get_if<Segment2>(&*intResult)) {
if ((*p)[0] == (*p)[1]) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_library(tessellator-core
"Structurer.cpp"
)

if (TESSELLATOR_USE_CGAL)
if (TESSELLATOR_ENABLE_CGAL)
target_sources(tessellator-core PRIVATE
"Smoother.cpp"
"SmootherTools.cpp"
Expand Down
8 changes: 4 additions & 4 deletions src/core/Structurer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ bool Structurer::isPureDiagonal(const Element& edge, const Coordinates & coordin
return false;
}

auto& startPoint = coordinates[edge.vertices[0]];
auto& endPoint = coordinates[edge.vertices[1]];
auto& startCell = calculateStructuredCell(startPoint);
auto& endCell = calculateStructuredCell(endPoint);
const auto& startPoint = coordinates[edge.vertices[0]];
const auto& endPoint = coordinates[edge.vertices[1]];
auto startCell = calculateStructuredCell(startPoint);
auto endCell = calculateStructuredCell(endPoint);
std::size_t difference = calculateDifferenceBetweenCells(startCell, endCell);

if (difference != 3) {
Expand Down
Loading
Loading