diff --git a/.github/install.sh b/.github/install.sh new file mode 100755 index 00000000000..f4e3c5f6410 --- /dev/null +++ b/.github/install.sh @@ -0,0 +1,12 @@ +#!/bin/bash +sudo add-apt-repository ppa:mikhailnov/pulseeffects -y +sudo apt-get update +sudo apt-get install -y libmpfr-dev \ + libeigen3-dev qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev \ + libqt5svg5-dev qttools5-dev qttools5-dev-tools libboost1.72-dev +#update cmake to 3.18.4 +sudo apt purge --auto-remove cmake +cd /tmp +wget https://cmake.org/files/v3.18/cmake-3.18.4-Linux-x86_64.sh +sudo sh cmake-3.18.4-Linux-x86_64.sh --skip-license --prefix=/usr/local +rm cmake-3.18.4-Linux-x86_64.sh diff --git a/.github/test.sh b/.github/test.sh new file mode 100755 index 00000000000..a744f6d5b08 --- /dev/null +++ b/.github/test.sh @@ -0,0 +1,13 @@ +#!/bin/bash +/usr/local/bin/cmake --version +FACTOR=$1 +set -ex +cd Polyhedron/demo +LIST_OF_PLUGINS=$(/usr/local/bin/cmake --build . -t help | egrep 'plugin$' |& cut -d\ -f2) +PLUGINS_ARRAY=(${LIST_OF_PLUGINS}); +NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]} +DEL=$(($NB_OF_PLUGINS / 4)) +mkdir build +cd build +/usr/local/bin/cmake -DCGAL_DIR=$2 ../Polyhedron +make -j2 ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))} diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 5378f637349..12bbd688af9 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -42,6 +42,7 @@ jobs: repository: ${{ github.repository }} ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge token: ${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }} + fetch-depth: 2 - name: install dependencies @@ -60,10 +61,9 @@ jobs: if: steps.get_round.outputs.result != 'stop' run: | set -ex - git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git --depth=5 mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc - - name: Upload Doc + - name: Build and Upload Doc if: steps.get_round.outputs.result != 'stop' run: | set -ex @@ -71,14 +71,27 @@ jobs: ROUND=${{ steps.get_round.outputs.result }} wget --no-verbose cgal.github.io -O tmp.html if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html; then - mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND + #list impacted packages + LIST_OF_PKGS=$(git diff --name-only HEAD^1 HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true) + if [ "$LIST_OF_PKGS" = "" ]; then + exit 1 + fi cd build_doc && make -j2 doc && make -j2 doc_with_postprocessing - cp -r ./doc_output/* ../cgal.github.io/${PR_NUMBER}/$ROUND - cd ../cgal.github.io - egrep -v " ${PR_NUMBER}\." index.html > tmp.html + cd .. + git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git + mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND + for f in $LIST_OF_PKGS + do + if [ -d ./build_doc/doc_output/$f ]; then + cp -r ./build_doc/doc_output/$f ./cgal.github.io/${PR_NUMBER}/$ROUND + fi + done + cp -r ./build_doc/doc_output/Manual ./cgal.github.io/${PR_NUMBER}/$ROUND + cd ./cgal.github.io + egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true echo "
  • Manual for PR ${PR_NUMBER} ($ROUND).
  • " >> ./tmp.html mv tmp.html index.html - git add ${PR_NUMBER}/$ROUND && git commit -q -a -m "Add ${PR_NUMBER} $ROUND" && git push -q -u origin master + git add ${PR_NUMBER}/$ROUND && git commit -q --amend -m "base commit" && git push -q -f -u origin master else exit 1 fi @@ -88,7 +101,7 @@ jobs: if: steps.get_round.outputs.result != 'stop' with: script: | - const address = "The documentation is built. You can find it here : https://cgal.github.io/${{ steps.get_pr_number.outputs.result }}/${{ steps.get_round.outputs.result }}/Manual/index.html" + const address = "The documentation is built. It will be available, after a few minutes, here : https://cgal.github.io/${{ steps.get_pr_number.outputs.result }}/${{ steps.get_round.outputs.result }}/Manual/index.html" github.issues.createComment({ owner: "CGAL", repo: "cgal", diff --git a/.github/workflows/delete_doc.yml b/.github/workflows/delete_doc.yml index c1152d37ca9..1304a7895c9 100644 --- a/.github/workflows/delete_doc.yml +++ b/.github/workflows/delete_doc.yml @@ -18,10 +18,15 @@ jobs: git clone https://maxGimeno:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git --depth=5 PR_NUMBER=$(python -c "import json; import os; y = json.load(open(os.environ['GITHUB_EVENT_PATH'])); print(y[\"number\"])") cd cgal.github.io/ - egrep -v " ${PR_NUMBER}\." index.html > tmp.html + egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true if [ -n "$(diff -q ./index.html ./tmp.html)" ]; then mv tmp.html index.html - #git rm -r ${PR_NUMBER} && git commit -a -m "Remove ${PR_NUMBER}" && git push -u origin master - git commit -a -m "Remove ${PR_NUMBER}" && git push -u origin master + fi + if [ -d ${PR_NUMBER} ]; then + git rm -r ${PR_NUMBER} + fi + #git diff exits with 1 if there is a diff + if !git diff --quiet; then + git commit -a --amend -m"base commit" && git push -f -u origin master fi diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 00000000000..6d1ff88629f --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,37 @@ +name: Test Polyhedron Demo + +on: [pull_request] + +jobs: + batch_1: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.0.0 + - name: install dependencies + run: .github/install.sh + - name: run1 + run: ./.github/test.sh 0 ${{ github.workspace }} + batch_2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.0.0 + - name: install dependencies + run: .github/install.sh + - name: run2 + run: ./.github/test.sh 1 ${{ github.workspace }} + batch_3: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.0.0 + - name: install dependencies + run: .github/install.sh + - name: run3 + run: ./.github/test.sh 2 ${{ github.workspace }} + batch_4: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.0.0 + - name: install dependencies + run: .github/install.sh + - name: run4 + run: ./.github/test.sh 3 ${{ github.workspace }} diff --git a/.gitignore b/.gitignore index 95de0b03ae9..07f7e4fc0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ /*build* /*/*/*/build +/*/*/*/VC* +/*/*/*/GCC AABB_tree/demo/AABB_tree/AABB_demo AABB_tree/demo/AABB_tree/Makefile AABB_tree/examples/AABB_tree/*.kdev* diff --git a/.travis/build_package.sh b/.travis/build_package.sh index 12f6082c922..dc41aa16dd1 100755 --- a/.travis/build_package.sh +++ b/.travis/build_package.sh @@ -7,30 +7,6 @@ CXX_FLAGS="-DCGAL_NDEBUG -ftemplate-backtrace-limit=0" function mytime { /usr/bin/time -f "Spend time of %C: %E (real)" "$@" } - -function build_examples { - mkdir -p build-travis - cd build-travis - mytime cmake -DCGAL_DIR="/usr/local/lib/cmake/CGAL" -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" .. - mytime make -j2 VERBOSE=1 -} - -function build_tests { - build_examples -} - -function build_demo { - mkdir -p build-travis - cd build-travis - EXTRA_CXX_FLAGS= - case "$CC" in - clang*) - EXTRA_CXX_FLAGS="-Werror=inconsistent-missing-override" - ;; - esac - mytime cmake -DCGAL_DIR="/usr/local/lib/cmake/CGAL" -DCGAL_DONT_OVERRIDE_CMAKE_FLAGS:BOOL=ON -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${EXTRA_CXX_FLAGS}" .. - mytime make -j2 VERBOSE=1 -} old_IFS=$IFS IFS=$' ' ROOT="$PWD/.." @@ -93,6 +69,25 @@ cd $ROOT exit 1 fi echo "Matrix is up to date." + #check if non standard cgal installation works + cd $ROOT + mkdir build_test + cd build_test + mytime cmake -DCMAKE_INSTALL_PREFIX=install/ -DCGAL_BUILD_THREE_DOC=TRUE .. + mytime make install + # test install with minimal downstream example + mkdir installtest + cd installtest + touch main.cpp + mkdir build + echo 'project(Example)' >> CMakeLists.txt + echo 'set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/main.cpp)' >> CMakeLists.txt + echo 'find_package(CGAL REQUIRED)' >> CMakeLists.txt + echo 'add_executable(${PROJECT_NAME} ${PROJECT_SRCS})' >> CMakeLists.txt + echo 'target_link_libraries(${PROJECT_NAME} CGAL::CGAL)' >> CMakeLists.txt + echo '#include "CGAL/remove_outliers.h"' >> main.cpp + cd build + mytime cmake -DCMAKE_INSTALL_PREFIX=../../install -DCGAL_BUILD_THREE_DOC=TRUE .. exit 0 fi @@ -116,7 +111,7 @@ cd $ROOT IFS=$old_IFS - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$ARG" != Polyhedron_demo ]; then + if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ]; then DO_IGNORE=FALSE . $ROOT/.travis/test_package.sh "$ROOT" "$ARG" echo "DO_IGNORE is $DO_IGNORE" @@ -125,67 +120,22 @@ cd $ROOT fi fi IFS=$' ' - EXAMPLES="$ARG/examples/$ARG" - TEST="$ARG/test/$ARG" - DEMOS=$ROOT/$ARG/demo/* - - if [ -d "$ROOT/$EXAMPLES" ] - then - cd $ROOT/$EXAMPLES - if [ -f ./CMakeLists.txt ]; then - build_examples - else - for dir in ./* - do - if [ -f $dir/CMakeLists.txt ]; then - cd $ROOT/$EXAMPLES/$dir - build_examples - fi - done - fi - elif [ "$ARG" != Polyhedron_demo ]; then - echo "No example found for $ARG" + mkdir -p build-travis + cd build-travis + WITHDEMOS=ON + if [ "$ARG" = "Polyhedron" ]; then + WITHDEMOS=OFF fi + EXTRA_CXX_FLAGS= + case "$CC" in + clang*) + EXTRA_CXX_FLAGS="-Werror=inconsistent-missing-override" + ;; + esac - if [ -d "$ROOT/$TEST" ] - then - cd $ROOT/$TEST - if [ -f ./CMakeLists.txt ]; then - build_tests - else - for dir in ./* - do - if [ -f $dir/CMakeLists.txt ]; then - cd $ROOT/$TEST/$dir - build_tests - fi - done - fi - elif [ "$ARG" != Polyhedron_demo ]; then - echo "No test found for $ARG" - fi - #Packages like Periodic_3_triangulation_3 contain multiple demos - for DEMO in $DEMOS; do - DEMO=${DEMO#"$ROOT"} - echo $DEMO - #If there is no demo subdir, try in GraphicsView - if [ ! -d "$ROOT/$DEMO" ] || [ ! -f "$ROOT/$DEMO/CMakeLists.txt" ]; then - DEMO="GraphicsView/demo/$ARG" - fi - if [ "$ARG" != Polyhedron ] && [ -d "$ROOT/$DEMO" ] - then - cd $ROOT/$DEMO - build_demo - elif [ "$ARG" != Polyhedron_demo ]; then - echo "No demo found for $ARG" - fi - done - if [ "$ARG" = Polyhedron_demo ]; then - DEMO=Polyhedron/demo/Polyhedron - cd "$ROOT/$DEMO" - build_demo - fi + mytime cmake -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${EXTRA_CXX_FLAGS}" -DCGAL_DONT_OVERRIDE_CMAKE_FLAGS:BOOL=ON -DBUILD_TESTING=ON -DWITH_tests=ON -DWITH_examples=ON -DWITH_demos=$WITHDEMOS .. + mytime ctest -j2 -L $ARG'([_][A-Z]|$)' -E execution___of__ --output-on-failure done IFS=$old_IFS # Local Variables: diff --git a/AABB_tree/benchmark/AABB_tree/CMakeLists.txt b/AABB_tree/benchmark/AABB_tree/CMakeLists.txt index 1a0f49a76f4..615266f1106 100644 --- a/AABB_tree/benchmark/AABB_tree/CMakeLists.txt +++ b/AABB_tree/benchmark/AABB_tree/CMakeLists.txt @@ -2,10 +2,16 @@ # This is the CMake script for compiling a CGAL application. cmake_minimum_required(VERSION 3.1...3.14) -project( AABB_traits_benchmark ) +project(AABB_traits_benchmark) -find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core ) +find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core) -create_single_source_cgal_program( "test.cpp" ) -create_single_source_cgal_program( "tree_construction.cpp" ) +# google benchmark +find_package(benchmark) +if (benchmark_FOUND) + create_single_source_cgal_program("tree_creation.cpp") + target_link_libraries(tree_creation benchmark::benchmark) +endif() +create_single_source_cgal_program("test.cpp") +create_single_source_cgal_program("tree_construction.cpp") diff --git a/AABB_tree/benchmark/AABB_tree/tree_creation.cpp b/AABB_tree/benchmark/AABB_tree/tree_creation.cpp new file mode 100644 index 00000000000..aa58d5545f2 --- /dev/null +++ b/AABB_tree/benchmark/AABB_tree/tree_creation.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Surface_mesh Surface_mesh; +typedef CGAL::AABB_face_graph_triangle_primitive Primitive; +typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_tree Tree; +typedef K::Segment_3 Segment; +typedef K::Point_3 Point_3; + + +Surface_mesh mesh; + +static void BM_TreeCreation(benchmark::State& state) +{ + for (auto _ : state) + { + benchmark::DoNotOptimize([]() { + Tree tree{mesh.faces_begin(), mesh.faces_end(), mesh}; + tree.build(); + return 0; + }()); + } +} +BENCHMARK(BM_TreeCreation); + +static void BM_Intersections(benchmark::State& state) +{ + Point_3 p(-0.5, 0.03, 0.04); + Point_3 q(-0.5, 0.04, 0.06); + + Tree tree{mesh.faces_begin(), mesh.faces_end(), mesh}; + tree.accelerate_distance_queries(); + + Segment segment_query(p, q); + for (auto _ : state) + { + benchmark::DoNotOptimize([&]() { + tree.number_of_intersected_primitives(segment_query); + Point_3 point_query(2.0, 2.0, 2.0); + Point_3 closest = tree.closest_point(point_query); + return 0; + }()); + } +} +BENCHMARK(BM_Intersections); + + +int main(int argc, char** argv) +{ + const char* default_file = "data/handle.off"; + const char* filename = argc > 2? argv[2] : default_file; + + { + std::ifstream input(filename); + input >> mesh; + } + + ::benchmark::Initialize(&argc, argv); + ::benchmark::RunSpecifiedBenchmarks(); + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/demo/AABB_tree/CMakeLists.txt b/AABB_tree/demo/AABB_tree/CMakeLists.txt index 0200865f89e..7c006dec292 100644 --- a/AABB_tree/demo/AABB_tree/CMakeLists.txt +++ b/AABB_tree/demo/AABB_tree/CMakeLists.txt @@ -1,7 +1,7 @@ # This is the CMake script for compiling the AABB tree demo. cmake_minimum_required(VERSION 3.1...3.15) -project( AABB_tree_Demo ) +project(AABB_tree_Demo) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -17,58 +17,56 @@ if(POLICY CMP0071) endif() # Include this package's headers first -include_directories( BEFORE ./ ./include ) +include_directories(BEFORE ./ ./include) # Find CGAL and CGAL Qt5 -find_package(CGAL COMPONENTS Qt5) +find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Find Qt5 itself find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Gui Svg) -if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND) +if(CGAL_Qt5_FOUND AND Qt5_FOUND) - qt5_wrap_ui( UI_FILES MainWindow.ui ) + qt5_wrap_ui(UI_FILES MainWindow.ui) include(AddFileDependencies) - qt5_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" ) - add_file_dependencies( MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h" ) + qt5_generate_moc("MainWindow.h" + "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp") + add_file_dependencies(MainWindow_moc.cpp + "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h") - qt5_generate_moc( "Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" ) - add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" ) + qt5_generate_moc("Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp") + add_file_dependencies(Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h") - qt5_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" ) - add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" ) + qt5_generate_moc("Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp") + add_file_dependencies(Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h") - qt5_add_resources ( CGAL_Qt5_RESOURCE_FILES AABB_demo.qrc ) + qt5_add_resources(CGAL_Qt5_RESOURCE_FILES AABB_demo.qrc) - add_file_dependencies( AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" ) + add_file_dependencies( + AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" + "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" + "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp") - add_executable ( AABB_demo AABB_demo.cpp ${UI_FILES} ${CGAL_Qt5_RESOURCE_FILES} + add_executable( + AABB_demo AABB_demo.cpp ${UI_FILES} ${CGAL_Qt5_RESOURCE_FILES} #${CGAL_Qt5_MOC_FILES} - ) + ) # Link with Qt libraries - target_link_libraries( AABB_demo PRIVATE - Qt5::OpenGL Qt5::Gui Qt5::Xml - CGAL::CGAL - CGAL::CGAL_Qt5 - ) + target_link_libraries(AABB_demo PRIVATE Qt5::OpenGL Qt5::Gui Qt5::Xml + CGAL::CGAL CGAL::CGAL_Qt5) - add_to_cached_list( CGAL_EXECUTABLE_TARGETS AABB_demo ) + add_to_cached_list(CGAL_EXECUTABLE_TARGETS AABB_demo) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(AABB_demo) -else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND) +else(CGAL_Qt5_FOUND + AND Qt5_FOUND) set(AABB_MISSING_DEPS "") - if(NOT CGAL_FOUND) - set(AABB_MISSING_DEPS "the CGAL library, ${AABB_MISSING_DEPS}") - endif() - if(NOT CGAL_Qt5_FOUND) set(AABB_MISSING_DEPS "CGAL_Qt5, ${AABB_MISSING_DEPS}") endif() @@ -77,6 +75,11 @@ else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND) set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}") endif() - message(STATUS "NOTICE: This demo requires ${AABB_MISSING_DEPS}and will not be compiled.") + message( + STATUS + "NOTICE: This demo requires ${AABB_MISSING_DEPS}and will not be compiled." + ) -endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND ) +endif( + CGAL_Qt5_FOUND + AND Qt5_FOUND) diff --git a/AABB_tree/examples/AABB_tree/CMakeLists.txt b/AABB_tree/examples/AABB_tree/CMakeLists.txt index b66f7ec5f15..9f11b3ae5c0 100644 --- a/AABB_tree/examples/AABB_tree/CMakeLists.txt +++ b/AABB_tree/examples/AABB_tree/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( AABB_tree_Examples ) +project(AABB_tree_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 03a6dab8354..5f0521e219f 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -13,6 +13,8 @@ #ifndef CGAL_AABB_TREE_H #define CGAL_AABB_TREE_H +#include + #include #include @@ -62,6 +64,7 @@ namespace CGAL { typedef std::vector Primitives; typedef internal::Primitive_helper Helper; + typedef AABB_tree Self; public: typedef AABBTraits AABB_traits; @@ -113,6 +116,15 @@ namespace CGAL { /// class using `traits`. AABB_tree(const AABBTraits& traits = AABBTraits()); + /// move constructor + AABB_tree(Self&&) noexcept; + /// assignment operator + Self& operator=(Self&&) noexcept; + + // Disabled copy constructor & assignment operator + AABB_tree(const Self&) = delete; + Self& operator=(const Self&) = delete; + /** * @brief Builds the datastructure from a sequence of primitives. * @param first iterator over first primitive to insert @@ -475,10 +487,7 @@ public: // clear nodes void clear_nodes() { - if( size() > 1 ) { - delete [] m_p_root_node; - } - m_p_root_node = nullptr; + m_nodes.clear(); } // clears internal KD tree @@ -491,8 +500,7 @@ public: #endif { CGAL_assertion( m_p_search_tree!=nullptr ); - delete m_p_search_tree; - m_p_search_tree = nullptr; + m_p_search_tree.reset(); #ifdef CGAL_HAS_THREADS m_atomic_search_tree_constructed.store(false, std::memory_order_relaxed); #else @@ -522,6 +530,22 @@ public: private: typedef AABB_node Node; + /** + * @brief Builds the tree by recursive expansion. + * @param first the first primitive to insert + * @param last the last primitive to insert + * @param range the number of primitive of the range + * + * [first,last[ is the range of primitives to be added to the tree. + */ + template + void expand(Node& node, + ConstPrimitiveIterator first, + ConstPrimitiveIterator beyond, + const std::size_t range, + const ComputeBbox& compute_bbox, + const SplitPrimitives& split_primitives, + const AABBTraits&); public: // returns a point which must be on one primitive @@ -573,8 +597,8 @@ public: AABBTraits m_traits; // set of input primitives Primitives m_primitives; - // single root node - Node* m_p_root_node = nullptr; + // tree nodes. first node is the root node + std::vector m_nodes; #ifdef CGAL_HAS_THREADS mutable CGAL_MUTEX build_mutex; // mutex used to protect const calls inducing build() and build_kd_tree() #endif @@ -594,7 +618,13 @@ public: #endif const_cast< AABB_tree* >(this)->build(); } - return m_p_root_node; + return std::addressof(m_nodes[0]); + } + + Node& new_node() + { + m_nodes.emplace_back(); + return m_nodes.back(); } private: const Primitive& singleton_data() const { @@ -603,7 +633,7 @@ public: } // search KD-tree - const Search_tree* m_p_search_tree = nullptr; + mutable std::unique_ptr m_p_search_tree; bool m_use_default_search_tree = true; // indicates whether the internal kd-tree should be built #ifdef CGAL_HAS_THREADS std::atomic m_atomic_need_build; @@ -613,11 +643,6 @@ public: mutable bool m_search_tree_constructed = false; #endif - private: - // Disabled copy constructor & assignment operator - typedef AABB_tree Self; - AABB_tree(const Self& src); - Self& operator=(const Self& src); }; // end class AABB_tree @@ -632,6 +657,30 @@ public: #endif {} + template + typename AABB_tree::Self& AABB_tree::operator=(Self&& tree) noexcept + { + m_traits = std::move(tree.m_traits); + m_primitives = std::move(tree.m_primitives); + m_nodes = std::move(tree.m_nodes); + m_p_search_tree = std::move(tree.m_p_search_tree); + m_use_default_search_tree = std::exchange(tree.m_use_default_search_tree, true); +#ifdef CGAL_HAS_THREADS + m_atomic_need_build = tree.m_atomic_need_build.load(std::memory_order_relaxed); + m_atomic_search_tree_constructed = tree.m_atomic_search_tree_constructed.load(std::memory_order_relaxed); +#else + m_need_build = std::exchange(tree.m_need_build, false); + m_search_tree_constructed = std::exchange(tree.m_search_tree_constructed, false); +#endif + return *this; + } + + template + AABB_tree::AABB_tree(Self&& tree) noexcept + { + *this = std::move(tree); + } + template template AABB_tree::AABB_tree(ConstPrimitiveIterator first, @@ -704,6 +753,41 @@ public: #endif } + template + template + void + AABB_tree::expand(Node& node, + ConstPrimitiveIterator first, + ConstPrimitiveIterator beyond, + const std::size_t range, + const ComputeBbox& compute_bbox, + const SplitPrimitives& split_primitives, + const Tr& traits) + { + node.set_bbox(compute_bbox(first, beyond)); + + // sort primitives along longest axis aabb + split_primitives(first, beyond, node.bbox()); + + switch(range) + { + case 2: + node.set_children(*first, *(first+1)); + break; + case 3: + node.set_children(*first, new_node()); + expand(node.right_child(), first+1, beyond, 2, compute_bbox, split_primitives, traits); + break; + default: + const std::size_t new_range = range/2; + node.set_children(new_node(), new_node()); + expand(node.left_child(), first, first + new_range, new_range, compute_bbox, split_primitives, traits); + expand(node.right_child(), first + new_range, beyond, range - new_range, compute_bbox, split_primitives, traits); + } + } + + + // Build the data structure, after calls to insert(..) template void AABB_tree::build() { @@ -719,24 +803,19 @@ public: const SplitPrimitives& split_primitives) { clear_nodes(); + if(m_primitives.size() > 1) { // allocates tree nodes - m_p_root_node = new Node[m_primitives.size()-1](); - if(m_p_root_node == nullptr) - { - std::cerr << "Unable to allocate memory for AABB tree" << std::endl; - CGAL_assertion(m_p_root_node != nullptr); - m_primitives.clear(); - clear(); - } + m_nodes.reserve(m_primitives.size()-1); // constructs the tree - m_p_root_node->expand(m_primitives.begin(), m_primitives.end(), - m_primitives.size(), - compute_bbox, - split_primitives, - m_traits); + expand(new_node(), + m_primitives.begin(), m_primitives.end(), + m_primitives.size(), + compute_bbox, + split_primitives, + m_traits); } #ifdef CGAL_HAS_THREADS m_atomic_need_build.store(false, std::memory_order_release); // in case build() is triggered by a call to root_node() @@ -768,22 +847,13 @@ public: ConstPointIterator beyond) { clear_search_tree(); - m_p_search_tree = new Search_tree(first, beyond); - - if(m_p_search_tree != nullptr) - { + m_p_search_tree = std::make_unique(first, beyond); #ifdef CGAL_HAS_THREADS m_atomic_search_tree_constructed.store(true, std::memory_order_release); // in case build_kd_tree() is triggered by a call to best_hint() #else m_search_tree_constructed = true; #endif return true; - } - else - { - std::cerr << "Unable to allocate memory for accelerating distance queries" << std::endl; - return false; - } } template @@ -793,7 +863,6 @@ public: m_use_default_search_tree = false; } - // constructs the search KD tree from internal primitives template bool AABB_tree::accelerate_distance_queries() diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h index 6fcfef9ede8..d8edaa91d35 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h @@ -32,6 +32,9 @@ namespace CGAL { template class AABB_node { +private: + typedef AABB_node Self; + public: typedef typename AABBTraits::Bounding_box Bounding_box; @@ -41,29 +44,15 @@ public: , m_p_left_child(nullptr) , m_p_right_child(nullptr) { }; - /// Non virtual Destructor - /// Do not delete children because the tree hosts and delete them - ~AABB_node() { }; + AABB_node(Self&& node) = default; + + // Disabled copy constructor & assignment operator + AABB_node(const Self& src) = delete; + Self& operator=(const Self& src) = delete; /// Returns the bounding box of the node const Bounding_box& bbox() const { return m_bbox; } - /** - * @brief Builds the tree by recursive expansion. - * @param first the first primitive to insert - * @param last the last primitive to insert - * @param range the number of primitive of the range - * - * [first,last[ is the range of primitives to be added to the tree. - */ - template - void expand(ConstPrimitiveIterator first, - ConstPrimitiveIterator beyond, - const std::size_t range, - const ComputeBbox& compute_bbox, - const SplitPrimitives& split_primitives, - const AABBTraits&); - /** * @brief General traversal query * @param query the query @@ -95,8 +84,17 @@ public: { return *static_cast(m_p_left_child); } const Primitive& right_data() const { return *static_cast(m_p_right_child); } + template + void set_children(Left& l, Right& r) + { + m_p_left_child = static_cast(std::addressof(l)); + m_p_right_child = static_cast(std::addressof(r)); + } + void set_bbox(const Bounding_box& bbox) + { + m_bbox = bbox; + } -private: Node& left_child() { return *static_cast(m_p_left_child); } Node& right_child() { return *static_cast(m_p_right_child); } Primitive& left_data() { return *static_cast(m_p_left_child); } @@ -111,49 +109,8 @@ private: void *m_p_left_child; void *m_p_right_child; -private: - // Disabled copy constructor & assignment operator - typedef AABB_node Self; - AABB_node(const Self& src); - Self& operator=(const Self& src); - }; // end class AABB_node -template -template -void -AABB_node::expand(ConstPrimitiveIterator first, - ConstPrimitiveIterator beyond, - const std::size_t range, - const ComputeBbox& compute_bbox, - const SplitPrimitives& split_primitives, - const Tr& traits) -{ - m_bbox = compute_bbox(first, beyond); - - // sort primitives along longest axis aabb - split_primitives(first, beyond, m_bbox); - - switch(range) - { - case 2: - m_p_left_child = &(*first); - m_p_right_child = &(*(++first)); - break; - case 3: - m_p_left_child = &(*first); - m_p_right_child = static_cast(this)+1; - right_child().expand(first+1, beyond, 2, compute_bbox, split_primitives, traits); - break; - default: - const std::size_t new_range = range/2; - m_p_left_child = static_cast(this) + 1; - m_p_right_child = static_cast(this) + new_range; - left_child().expand(first, first + new_range, new_range, compute_bbox, split_primitives, traits); - right_child().expand(first + new_range, beyond, range - new_range, compute_bbox, split_primitives, traits); - } -} - template template diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_search_tree.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_search_tree.h index 96f08168671..9ba3cf2481b 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_search_tree.h @@ -83,7 +83,7 @@ namespace CGAL typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search; typedef typename Neighbor_search::Tree Tree; private: - Tree* m_p_tree; + Tree m_tree; Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p) @@ -98,30 +98,22 @@ namespace CGAL public: template AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond) - : m_p_tree(nullptr) + : m_tree{} { - typedef typename Add_decorated_point::Point_3 Decorated_point; + typedef typename Add_decorated_point::Point_3 Decorated_point; std::vector points; while(begin != beyond) { Point_and_primitive_id pp = get_p_and_p(*begin); - points.push_back(Decorated_point(pp.first,pp.second)); + points.emplace_back(pp.first, pp.second); ++begin; } - m_p_tree = new Tree(points.begin(), points.end()); - if(m_p_tree != nullptr) - m_p_tree->build(); - else - std::cerr << "unable to build the search tree!" << std::endl; + m_tree.insert(points.begin(), points.end()); + m_tree.build(); } - ~AABB_search_tree() { - delete m_p_tree; - } - - Point_and_primitive_id closest_point(const Point& query) const { - Neighbor_search search(*m_p_tree, query, 1); + Neighbor_search search(m_tree, query, 1); return Point_and_primitive_id(static_cast(search.begin()->first), search.begin()->first.id()); } }; diff --git a/AABB_tree/test/AABB_tree/CMakeLists.txt b/AABB_tree/test/AABB_tree/CMakeLists.txt index 997be1089d0..47c63198ba2 100644 --- a/AABB_tree/test/AABB_tree/CMakeLists.txt +++ b/AABB_tree/test/AABB_tree/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( AABB_tree_Tests ) +project(AABB_tree_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - include( ${CGAL_USE_FILE} ) # Kept to test the old behaviour. - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include(${CGAL_USE_FILE}) # Kept to test the old behaviour. +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp new file mode 100644 index 00000000000..bd2ccdabb80 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp @@ -0,0 +1,207 @@ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class TestCase +{ +}; + +// test 0 is from "aabb_test_singleton_tree" +template <> +class TestCase<0> +{ + typedef CGAL::Simple_cartesian K; + typedef K::FT FT; + typedef K::Point_3 Point; + typedef K::Plane_3 Plane; + typedef K::Segment_3 Segment; + typedef K::Triangle_3 Triangle; + typedef std::vector::iterator Iterator; + typedef CGAL::AABB_segment_primitive Primitive; + typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_tree Tree; + +public: + Tree create_tree() + { + return Tree(segments.begin(), segments.end()); + } + + void init_tree(Tree&) {} + + bool test_tree(Tree& tree) + { + Plane plane_query(a, b, d); + Triangle triangle_query(a, b, c); + + // Test calls to all functions + CGAL::Emptyset_iterator devnull; + tree.all_intersections(triangle_query, devnull); + tree.all_intersected_primitives(triangle_query, devnull); + assert(tree.any_intersected_primitive(triangle_query)); + assert(tree.any_intersection(triangle_query)); + const CGAL::Bbox_3 bbox = tree.bbox(); + assert(bbox == CGAL::Bbox_3(0, 0, 0, 2, 2, 2)); + tree.clear(); + tree.insert(segments.begin(), segments.end()); + tree.build(); + assert(tree.closest_point(Point(-0.1, -0.1, -0.1)) == Point(0, 0, 0)); + assert(tree.closest_point(Point(-0.1, -0.1, -0.1), Point(0, 0, 0)) == + Point(0, 0, 0)); + assert(tree.closest_point_and_primitive(Point(-0.1, -0.1, -0.1)).second == + segments.begin()); + assert(tree.do_intersect(plane_query) == true); + assert(tree.do_intersect(triangle_query) == true); + assert(!tree.empty()); + assert(tree.size() == 1); + tree.clear(); + assert(tree.size() == 0); + tree.insert(segments.begin(), segments.end()); + assert(tree.size() == 1); + assert(tree.number_of_intersected_primitives(plane_query) == 1); + tree.rebuild(segments.begin(), segments.end()); + assert(tree.size() == 1); + assert(tree.number_of_intersected_primitives(triangle_query) == 1); + assert(tree.squared_distance(Point(0, 0, 0)) == 0); + return true; + } + +private: + Point a = {1.0, 0.0, 0.0}; + Point b = {0.0, 1.0, 0.0}; + Point c = {0.0, 0.0, 1.0}; + Point d = {0.0, 0.0, 0.0}; + std::vector segments = {Segment(Point(0, 0, 0), Point(2, 2, 2))}; +}; + +// test 1 is from "aabb_test_all_intersected_primitives" +template <> +class TestCase<1> +{ + typedef CGAL::Epick K; + typedef K::FT FT; + typedef K::Point_3 Point; + typedef K::Vector_3 Vector; + typedef K::Segment_3 Segment; + typedef K::Ray_3 Ray; + typedef CGAL::Surface_mesh> Mesh; + typedef CGAL::AABB_halfedge_graph_segment_primitive + S_Primitive; + typedef CGAL::AABB_face_graph_triangle_primitive + T_Primitive; + typedef CGAL::AABB_traits T_Traits; + typedef CGAL::AABB_traits S_Traits; + typedef CGAL::AABB_tree T_Tree; + typedef CGAL::AABB_tree S_Tree; + typedef T_Tree::Primitive_id T_Primitive_id; + typedef S_Tree::Primitive_id S_Primitive_id; + typedef std::pair TreePair; + +public: + TreePair create_tree() + { + static CGAL::Surface_mesh> m1 = {}; + static CGAL::Surface_mesh> m2 = {}; + static bool mesh_loaded = false; + if (!mesh_loaded) { + std::ifstream in("data/cube.off"); + assert(in); + in >> m1; + in.close(); + in.open("data/tetrahedron.off"); + assert(in); + in >> m2; + in.close(); + mesh_loaded = true; + } + return std::make_pair(T_Tree{faces(m1).first, faces(m1).second, m1}, + S_Tree{edges(m2).first, edges(m2).second, m2}); + } + + void init_tree(TreePair& trees) + { + trees.first.build(); + trees.second.build(); + } + + bool test_tree(TreePair& trees) + { + auto &cube_tree = trees.first; + auto &tet_tree = trees.second; + + std::list t_primitives; + std::list s_primitives; + cube_tree.all_intersected_primitives(tet_tree, + std::back_inserter(t_primitives)); + CGAL_assertion(t_primitives.size() == 6); + tet_tree.all_intersected_primitives(cube_tree, + std::back_inserter(s_primitives)); + CGAL_assertion(s_primitives.size() == 6); + CGAL_assertion(tet_tree.do_intersect(cube_tree)); + CGAL_assertion(cube_tree.do_intersect(tet_tree)); + + std::vector all_primitives; + cube_tree.all_intersected_primitives(tet_tree, + std::back_inserter(all_primitives)); + bool found_f5 = false; + for (auto prim : all_primitives) { + if ((int)prim.first == 5) + found_f5 = true; + } + CGAL_assertion(found_f5); + CGAL_USE(found_f5); + return true; + } +}; + + +template +bool run_test() +{ + TestCase test_case; + + // create_tree should return prvalue for guaranteed copy elision + auto tree_1 = test_case.create_tree(); + test_case.init_tree(tree_1); + + auto tree_2 = test_case.create_tree(); + test_case.init_tree(tree_2); + + auto tree_3 = test_case.create_tree(); + test_case.init_tree(tree_3); + + decltype(tree_1) tree_ctor{std::move(tree_2)}; + decltype(tree_1) tree_assig{}; + tree_assig = std::move(tree_3); + + bool normal = test_case.test_tree(tree_1); + bool move_ctor = test_case.test_tree(tree_ctor); + bool move_ass = + test_case.test_tree(tree_assig); // test move assignment operator + + if (!normal) + std::cout << "Test " << test_number << "failed on the original tree\n"; + if (!move_ctor) + std::cout << "Test " << test_number << "failed on move constructed tree\n"; + if (!move_ass) + std::cout << "Test " << test_number << "failed on move assigned tree\n"; + return normal && move_ctor && move_ass; +} + +int main() { return (run_test<0>() && run_test<1>()) ? 0 : 1; } diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt index e62cfe0689a..d494c037fae 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Advancing_front_surface_reconstruction_Examples ) +project(Advancing_front_surface_reconstruction_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt b/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt index 07b424ed360..c16decef5c2 100644 --- a/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt +++ b/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Advancing_front_surface_reconstruction_Tests ) +project(Advancing_front_surface_reconstruction_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt b/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt index c616d6befdc..b86aa4c60bc 100644 --- a/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt +++ b/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_foundations_Examples ) +project(Algebraic_foundations_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt b/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt index 682fa668f93..a2286014e09 100644 --- a/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt +++ b/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_foundations_Tests ) +project(Algebraic_foundations_Tests) +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core) - -if ( CGAL_FOUND ) - - include(${CGAL_USE_FILE}) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include(${CGAL_USE_FILE}) +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt b/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt index 02f1ac1c563..63cf6965333 100644 --- a/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt +++ b/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt @@ -1,28 +1,27 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_kernel_d_Examples ) +project(Algebraic_kernel_d_Examples) +find_package(CGAL REQUIRED COMPONENTS Core) +find_package(MPFI QUIET) -find_package(CGAL QUIET COMPONENTS Core) +if(MPFI_FOUND) -if ( CGAL_FOUND ) - find_package(MPFI QUIET) -endif() + include(${CGAL_USE_FILE}) + include(${MPFI_USE_FILE}) + include(CGAL_VersionUtils) -if( CGAL_FOUND AND MPFI_FOUND) - - include( ${CGAL_USE_FILE} ) - include( ${MPFI_USE_FILE} ) - include( CGAL_VersionUtils ) - - create_single_source_cgal_program( "Compare_1.cpp" ) - create_single_source_cgal_program( "Construct_algebraic_real_1.cpp" ) - create_single_source_cgal_program( "Isolate_1.cpp" ) - create_single_source_cgal_program( "Sign_at_1.cpp" ) - create_single_source_cgal_program( "Solve_1.cpp" ) + create_single_source_cgal_program("Compare_1.cpp") + create_single_source_cgal_program("Construct_algebraic_real_1.cpp") + create_single_source_cgal_program("Isolate_1.cpp") + create_single_source_cgal_program("Sign_at_1.cpp") + create_single_source_cgal_program("Solve_1.cpp") else() - message(STATUS "This program requires the CGAL library and MPFI, and will not be compiled.") + message( + STATUS + "This program requires the CGAL library and MPFI, and will not be compiled." + ) endif() diff --git a/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt b/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt index 73b7294442b..b48f6a7e334 100644 --- a/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt +++ b/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt @@ -1,67 +1,65 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_kernel_d_Tests ) - - +project(Algebraic_kernel_d_Tests) # CGAL and its components -find_package( CGAL QUIET COMPONENTS Core) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() +find_package(CGAL REQUIRED COMPONENTS Core) find_package(RS3 QUIET) if(MPFI_FOUND) - include( ${MPFI_USE_FILE} ) + include(${MPFI_USE_FILE}) endif() if(RS3_FOUND) - include( ${RS3_USE_FILE} ) + include(${RS3_USE_FILE}) endif() # Boost and its components -find_package( Boost ) +find_package(Boost) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() endif() # include for local directory -include_directories( BEFORE include ) +include_directories(BEFORE include) -include( ${CGAL_USE_FILE} ) +include(${CGAL_USE_FILE}) # Creating entries for all .cpp/.C files with "main" routine # ########################################################## -create_single_source_cgal_program( "cyclic.cpp" ) -create_single_source_cgal_program( "Algebraic_curve_kernel_2.cpp" ) -create_single_source_cgal_program( "algebraic_curve_kernel_2_tools.cpp" ) -create_single_source_cgal_program( "Algebraic_kernel_d_1_LEDA.cpp" ) +create_single_source_cgal_program("cyclic.cpp") +create_single_source_cgal_program("Algebraic_curve_kernel_2.cpp") +create_single_source_cgal_program("algebraic_curve_kernel_2_tools.cpp") +create_single_source_cgal_program("Algebraic_kernel_d_1_LEDA.cpp") -create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_Integer_rational.cpp" ) -create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtII_rational.cpp" ) -create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtRI_rational.cpp" ) -create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtRR_rational.cpp" ) +create_single_source_cgal_program( + "Algebraic_kernel_d_1_CORE_Integer_rational.cpp") +create_single_source_cgal_program( + "Algebraic_kernel_d_1_CORE_SqrtII_rational.cpp") +create_single_source_cgal_program( + "Algebraic_kernel_d_1_CORE_SqrtRI_rational.cpp") +create_single_source_cgal_program( + "Algebraic_kernel_d_1_CORE_SqrtRR_rational.cpp") -create_single_source_cgal_program( "Algebraic_kernel_d_1_GMP.cpp" ) -create_single_source_cgal_program( "Algebraic_kernel_d_2.cpp" ) -create_single_source_cgal_program( "Algebraic_real_d_1.cpp" ) -create_single_source_cgal_program( "Bitstream_descartes.cpp" ) -create_single_source_cgal_program( "Curve_analysis_2.cpp" ) -create_single_source_cgal_program( "Curve_pair_analysis_2.cpp" ) -create_single_source_cgal_program( "Descartes.cpp" ) -create_single_source_cgal_program( "Real_embeddable_traits_extension.cpp" ) +create_single_source_cgal_program("Algebraic_kernel_d_1_GMP.cpp") +create_single_source_cgal_program("Algebraic_kernel_d_2.cpp") +create_single_source_cgal_program("Algebraic_real_d_1.cpp") +create_single_source_cgal_program("Bitstream_descartes.cpp") +create_single_source_cgal_program("Curve_analysis_2.cpp") +create_single_source_cgal_program("Curve_pair_analysis_2.cpp") +create_single_source_cgal_program("Descartes.cpp") +create_single_source_cgal_program("Real_embeddable_traits_extension.cpp") if(RS_FOUND) - create_single_source_cgal_program( "Algebraic_kernel_rs_gmpq_d_1.cpp" ) - create_single_source_cgal_program( "Algebraic_kernel_rs_gmpz_d_1.cpp" ) + create_single_source_cgal_program("Algebraic_kernel_rs_gmpq_d_1.cpp") + create_single_source_cgal_program("Algebraic_kernel_rs_gmpz_d_1.cpp") else() - message(STATUS "NOTICE: Some tests require the RS library, and will not be compiled.") + message( + STATUS + "NOTICE: Some tests require the RS library, and will not be compiled.") endif() diff --git a/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt b/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt index c02ce4ff14d..006778479a8 100644 --- a/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt +++ b/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_kernel_for_circles_Tests ) +project(Algebraic_kernel_for_circles_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - include_directories (BEFORE "include") - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include_directories(BEFORE "include") +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt b/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt index 284554d7787..48dbc34d1d6 100644 --- a/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt +++ b/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Algebraic_kernel_for_spheres_Tests ) +project(Algebraic_kernel_for_spheres_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - include_directories (BEFORE "include") - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include_directories(BEFORE "include") +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt b/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt index 318bbe1dcc3..aa0182a2fc3 100644 --- a/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt +++ b/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Alpha_shapes_2_Examples ) +project(Alpha_shapes_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt b/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt index 5b6cea7e446..a14ae249da7 100644 --- a/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt +++ b/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Alpha_shapes_2_Tests ) +project(Alpha_shapes_2_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt index 15a15504881..ede9b5e1367 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt @@ -2,7 +2,7 @@ # This is the CMake script for compiling a CGAL application. cmake_minimum_required(VERSION 3.1...3.15) -project (Alpha_shapes_3_Demo) +project(Alpha_shapes_3_Demo) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -16,35 +16,38 @@ if(POLICY CMP0071) cmake_policy(SET CMP0071 NEW) endif() -find_package(CGAL COMPONENTS Qt5) +find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg) -if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND ) +if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) - # include(${QT_USE_FILE}) - include_directories (BEFORE ./ ) + # include(${QT_USE_FILE}) + include_directories(BEFORE ./) # ui file, created wih Qt Designer - qt5_wrap_ui( uis MainWindow.ui ) + qt5_wrap_ui(uis MainWindow.ui) # qrc files (resources files, that contain icons, at least) - qt5_add_resources ( CGAL_Qt5_RESOURCE_FILES ./Alpha_shape_3.qrc ) + qt5_add_resources(CGAL_Qt5_RESOURCE_FILES ./Alpha_shape_3.qrc) - add_executable ( Alpha_shape_3 Alpha_shape_3.cpp MainWindow.cpp Viewer.cpp ${uis} ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES}) - add_to_cached_list( CGAL_EXECUTABLE_TARGETS Alpha_shape_3 ) + add_executable( + Alpha_shape_3 Alpha_shape_3.cpp MainWindow.cpp Viewer.cpp ${uis} + ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES}) + add_to_cached_list(CGAL_EXECUTABLE_TARGETS Alpha_shape_3) - target_link_libraries( Alpha_shape_3 PRIVATE - CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::OpenGL Qt5::Gui ) + target_link_libraries(Alpha_shape_3 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 + Qt5::OpenGL Qt5::Gui) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Alpha_shape_3) else() - message(STATUS "NOTICE: This demo requires CGAL, and Qt5, and will not be compiled.") + message( + STATUS "NOTICE: This demo requires CGAL, and Qt5, and will not be compiled." + ) endif() diff --git a/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt index bd91f6c8705..b059a33c683 100644 --- a/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Alpha_shapes_3_Examples ) +project(Alpha_shapes_3_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt index 98bae1eaab9..31551f22a36 100644 --- a/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Alpha_shapes_3_Tests ) +project(Alpha_shapes_3_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - include_directories (BEFORE "include") - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include_directories(BEFORE "include") +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt index 86194af24b3..9486b94e36d 100644 --- a/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Apollonius_graph_2_Examples ) +project(Apollonius_graph_2_Examples) +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core ) - -if ( CGAL_FOUND ) - - include(${CGAL_USE_FILE}) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include(${CGAL_USE_FILE}) +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt index 8a0318d270d..f67cd40b98a 100644 --- a/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt +++ b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Apollonius_graph_2_Tests ) +project(Apollonius_graph_2_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - include_directories (BEFORE "include") - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include_directories(BEFORE "include") +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt b/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt index 82660d4b397..1568cf2d61c 100644 --- a/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt +++ b/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt @@ -1,56 +1,53 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Arithmetic_kernel_Tests ) +project(Arithmetic_kernel_Tests) - - - -find_package(CGAL QUIET COMPONENTS Core) +find_package(CGAL REQUIRED COMPONENTS Core) find_package(GMP QUIET) -if ( CGAL_FOUND AND GMP_FOUND ) +if(GMP_FOUND) include(${CGAL_USE_FILE}) - include( CGAL_VersionUtils ) + include(CGAL_VersionUtils) - get_dependency_version( GMP ) + get_dependency_version(GMP) - IS_VERSION_LESS("${GMP_VERSION}" "4.2.0" _IS_GMP_VERSION_TO_LOW) + is_version_less("${GMP_VERSION}" "4.2.0" _IS_GMP_VERSION_TO_LOW) include_directories(include) - find_package( MPFI ) + find_package(MPFI) - if( MPFI_FOUND ) - include( ${MPFI_USE_FILE} ) + if(MPFI_FOUND) + include(${MPFI_USE_FILE}) # for the testsuite, the version of MPFI shipped with RS is used; this # version needs GMP>=4.2, so we require this dependency only here and # not in FindMPFI.cmake - if( _IS_GMP_VERSION_TO_LOW ) - message( STATUS - "MPFI tests need GMP>=4.2, some of the tests will not be compiled" ) - else( _IS_GMP_VERSION_TO_LOW ) - include( ${MPFI_USE_FILE} ) - create_single_source_cgal_program( "GMP_arithmetic_kernel.cpp" ) - endif( _IS_GMP_VERSION_TO_LOW ) - else( MPFI_FOUND ) - message( STATUS - "MPFI is not present, some of the tests will not be compiled." ) - endif( MPFI_FOUND ) + if(_IS_GMP_VERSION_TO_LOW) + message( + STATUS + "MPFI tests need GMP>=4.2, some of the tests will not be compiled") + else(_IS_GMP_VERSION_TO_LOW) + include(${MPFI_USE_FILE}) + create_single_source_cgal_program("GMP_arithmetic_kernel.cpp") + endif(_IS_GMP_VERSION_TO_LOW) + else(MPFI_FOUND) + message( + STATUS "MPFI is not present, some of the tests will not be compiled.") + endif(MPFI_FOUND) - create_single_source_cgal_program( "Arithmetic_kernel.cpp" ) - create_single_source_cgal_program( "LEDA_arithmetic_kernel.cpp" ) - create_single_source_cgal_program( "CORE_arithmetic_kernel.cpp" ) - create_single_source_cgal_program( "Get_arithmetic_kernel.cpp" ) + create_single_source_cgal_program("Arithmetic_kernel.cpp") + create_single_source_cgal_program("LEDA_arithmetic_kernel.cpp") + create_single_source_cgal_program("CORE_arithmetic_kernel.cpp") + create_single_source_cgal_program("Get_arithmetic_kernel.cpp") else() - message(STATUS "This program requires the CGAL library, and will not be compiled.") + message( + STATUS "This program requires the CGAL library, and will not be compiled.") endif() - diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.cpp index 919ec55f2a1..0e9e2833ed4 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.cpp @@ -280,9 +280,9 @@ void ArrangementDemoWindow::updateInputType(QAction* a) tab->activateCurveInputCallback(curveType); } -#ifdef CGAL_USE_CORE void ArrangementDemoWindow::on_actionAddAlgebraicCurve_triggered() { +#ifdef CGAL_USE_CORE AlgebraicCurveInputDialog newDialog; if (newDialog.exec() == QDialog::Accepted) @@ -312,10 +312,12 @@ void ArrangementDemoWindow::on_actionAddAlgebraicCurve_triggered() algCurveInputCallback->generate(cv); if (is_first_curve) currentTab->adjustViewport(); } +#endif } void ArrangementDemoWindow::on_actionAddRationalCurve_triggered() { +#ifdef CGAL_USE_CORE RationalCurveInputDialog newDialog; if (newDialog.exec() == QDialog::Accepted) @@ -346,8 +348,8 @@ void ArrangementDemoWindow::on_actionAddRationalCurve_triggered() algCurveInputCallback->generate(cv); if (is_first_curve) currentTab->adjustViewport(); } -} #endif +} void ArrangementDemoWindow::on_actionQuit_triggered() { qApp->exit(); } diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.h index 5b124de65ff..4c338e2a838 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.h +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoWindow.h @@ -78,10 +78,8 @@ public Q_SLOTS: void on_actionMerge_toggled(bool); void on_actionSplit_toggled(bool); void on_actionFill_toggled(bool); -#ifdef CGAL_USE_CORE void on_actionAddAlgebraicCurve_triggered(); void on_actionAddRationalCurve_triggered(); -#endif Q_SIGNALS: void modelChanged(); diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt index 08279ffce0f..f7ab51dc7cc 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt @@ -1,7 +1,7 @@ # This is the CMake script for compiling a CGAL application. cmake_minimum_required(VERSION 3.1...3.15) -project( Arrangement_on_surface_2_Demo ) +project(Arrangement_on_surface_2_Demo) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) @@ -134,7 +134,6 @@ else() if(NOT Qt5_FOUND) set(MISSING_DEPS "Qt5, ${MISSING_DEPS}") endif() - message(STATUS "NOTICE: This demo requires ${MISSING_DEPS} and will not be compiled.") endif() diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/RationalTypes.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/RationalTypes.h index 43d40a55072..8cbca1c1949 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/RationalTypes.h +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/RationalTypes.h @@ -12,10 +12,10 @@ #ifndef ARRANGEMENT_DEMO_RATIONAL_TYPES_H #define ARRANGEMENT_DEMO_RATIONAL_TYPES_H +#include +#include #ifdef CGAL_USE_CORE #include - #include - #include #else #include #endif diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt index 86ff8829a38..226e1c6fab2 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Arrangement_on_surface_2_Examples ) +project(Arrangement_on_surface_2_Examples) +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core) - -if ( CGAL_FOUND ) - - include(${CGAL_USE_FILE}) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include(${CGAL_USE_FILE}) +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h index 16befc318ee..16a15d7ea56 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h @@ -91,6 +91,11 @@ public: /*! Destructor. */ virtual ~Arr_vertex_base() {} + // Access/modification for pointer squatting + void* inc() const { return p_inc; } + void set_inc(void * inc) const + { const_cast(*this).p_inc = inc; } + /*! Check if the point pointer is nullptr. */ bool has_null_point() const { return (p_pt == nullptr); } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h index e4c739c8c23..393958f3424 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h @@ -40,6 +40,89 @@ namespace CGAL { +template +class Indexed_sweep_accessor +{ + const Arr1& arr1; + const Arr2& arr2; + mutable std::vector backup_inc; + +public: + + Indexed_sweep_accessor (const Arr1& arr1, const Arr2& arr2) + : arr1(arr1), arr2(arr2) { } + + std::size_t nb_vertices() const + { + return arr1.number_of_vertices() + arr2.number_of_vertices(); + } + + std::size_t min_end_index (const Curve& c) const + { + if (c.red_halfedge_handle() != typename Curve::HH_red()) + return reinterpret_cast(c.red_halfedge_handle()->target()->inc()); + // else + CGAL_assertion (c.blue_halfedge_handle() != typename Curve::HH_blue()); + return reinterpret_cast(c.blue_halfedge_handle()->target()->inc()); + } + + std::size_t max_end_index (const Curve& c) const + { + if (c.red_halfedge_handle() != typename Curve::HH_red()) + return reinterpret_cast(c.red_halfedge_handle()->source()->inc()); + // else + CGAL_assertion (c.blue_halfedge_handle() != typename Curve::HH_blue()); + return reinterpret_cast(c.blue_halfedge_handle()->source()->inc()); + } + + const Curve& curve (const Curve& c) const + { + return c; + } + + // Initializes indices by squatting Vertex::inc(); + void before_init() const + { + std::size_t idx = 0; + backup_inc.resize (nb_vertices()); + for (typename Arr1::Vertex_const_iterator vit = arr1.vertices_begin(); + vit != arr1.vertices_end(); ++vit, ++idx) + { + CGAL_assertion (idx < backup_inc.size()); + backup_inc[idx] = vit->inc(); + vit->set_inc (reinterpret_cast(idx)); + } + for (typename Arr2::Vertex_const_iterator vit = arr2.vertices_begin(); + vit != arr2.vertices_end(); ++vit, ++idx) + { + CGAL_assertion (idx < backup_inc.size()); + backup_inc[idx] = vit->inc(); + vit->set_inc (reinterpret_cast(idx)); + } + } + + // Restores state of arrangements before index squatting + void after_init() const + { + std::size_t idx = 0; + for (typename Arr1::Vertex_const_iterator vit = arr1.vertices_begin(); + vit != arr1.vertices_end(); ++vit, ++idx) + { + CGAL_assertion (idx < backup_inc.size()); + vit->set_inc (backup_inc[idx]); + } + for (typename Arr2::Vertex_const_iterator vit = arr2.vertices_begin(); + vit != arr2.vertices_end(); ++vit, ++idx) + { + CGAL_assertion (idx < backup_inc.size()); + vit->set_inc (backup_inc[idx]); + } + } + +private: + +}; + /*! Compute the overlay of two input arrangements. * \tparam GeometryTraitsA_2 the geometry traits of the first arrangement. * \tparam GeometryTraitsB_2 the geometry traits of the second arrangement. @@ -183,7 +266,14 @@ overlay(const Arrangement_on_surface_2& arr1 if (total_iso_verts == 0) { // Clear the result arrangement and perform the sweep to construct it. arr.clear(); - surface_sweep.sweep(xcvs_vec.begin(), xcvs_vec.end()); + if (std::is_same::value) + surface_sweep.sweep (xcvs_vec.begin(), xcvs_vec.end()); + else + surface_sweep.indexed_sweep (xcvs_vec, + Indexed_sweep_accessor + + (arr1, arr2)); xcvs_vec.clear(); return; } @@ -215,8 +305,16 @@ overlay(const Arrangement_on_surface_2& arr1 // Clear the result arrangement and perform the sweep to construct it. arr.clear(); - surface_sweep.sweep(xcvs_vec.begin(), xcvs_vec.end(), - pts_vec.begin(), pts_vec.end()); + if (std::is_same::value) + surface_sweep.sweep(xcvs_vec.begin(), xcvs_vec.end(), + pts_vec.begin(), pts_vec.end()); + else + surface_sweep.indexed_sweep (xcvs_vec, + Indexed_sweep_accessor + + (arr1, arr2), + pts_vec.begin(), pts_vec.end()); xcvs_vec.clear(); pts_vec.clear(); } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h index 7e732f09a65..6e26162ea0a 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h @@ -716,14 +716,19 @@ public: Comparison_result dir1 = cmp_seg_endpts(cv1[0]); Comparison_result dir2 = cmp_seg_endpts(cv2[0]); + std::vector ocv; // Used to represent overlaps. + const bool invert_ocv = ((dir1 == LARGER) && (dir2 == LARGER)); + const bool consistent = (dir1 == dir2); +#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT + CGAL_assertion(consistent); +#endif + const std::size_t n1 = cv1.number_of_subcurves(); const std::size_t n2 = cv2.number_of_subcurves(); std::size_t i1 = (dir1 == SMALLER) ? 0 : n1-1; std::size_t i2 = (dir2 == SMALLER) ? 0 : n2-1; - X_monotone_curve_2 ocv; // Used to represent overlaps. - auto compare_xy = m_poly_traits.compare_xy_2_object(); Comparison_result left_res = compare_xy(cv1[i1], ARR_MIN_END, cv2[i2], ARR_MIN_END); @@ -825,8 +830,7 @@ public: boost::get(&xection); if (subcv_p != nullptr) { ocv.push_back(*subcv_p); - *oi++ = Intersection_result(ocv); - ocv.clear(); + oi = output_ocv (ocv, invert_ocv, oi); continue; } @@ -848,10 +852,16 @@ public: boost::get(&item); if (x_seg != nullptr) { X_monotone_subcurve_2 seg = *x_seg; - - // If for some reason the subcurve intersection - // results in left oriented curve. - if (cmp_seg_endpts(seg) == LARGER) seg = construct_opposite(seg); + // We maintain the variant that if the input curves have opposite + // directions (! consistent), the overalpping curves are directed + // left=>right. This, however, is not guaranteed for the + // subcurves. Therefore, we need to enforce it. That is, we make + // sure the subcurves are also directed left=>right in this case. + if (! consistent && (cmp_seg_endpts(seg) == LARGER)) + seg = construct_opposite(seg); +#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT + CGAL_assertion(cmp_seg_endpts(seg) == SMALLER); +#endif ocv.push_back(seg); } @@ -876,9 +886,8 @@ public: if (left_overlap) { // An overlap occurred at the previous iteration: // Output the overlapping polycurve. - CGAL_assertion(ocv.number_of_subcurves() > 0); - *oi++ = Intersection_result(ocv); - ocv.clear(); + CGAL_assertion(ocv.size() > 0); + oi = output_ocv (ocv, invert_ocv, oi); } else { // The left point of the current subcurve of one @@ -923,8 +932,8 @@ public: } // END of while loop // Output the remaining overlapping polycurve, if necessary. - if (ocv.number_of_subcurves() > 0) { - *oi++ = Intersection_result(ocv); + if (ocv.size() > 0) { + oi = output_ocv (ocv, invert_ocv, oi); } else if (right_coincides) { typedef std::pair return_point; @@ -974,6 +983,27 @@ public: } } + return oi; + } + + private: + + template + inline OutputIterator output_ocv + (std::vector& ocv, bool invert_ocv, OutputIterator oi) const + { + typedef std::pair Intersection_point; + typedef boost::variant + Intersection_result; + X_monotone_curve_2 curve; + if (invert_ocv) + std::reverse (ocv.begin(), ocv.end()); + for (X_monotone_subcurve_2& sc : ocv) + curve.push_back (sc); + *(oi ++) = Intersection_result(curve); + + ocv.clear(); + return oi; } }; diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h index 575f797d293..6ce3ad5edbf 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h @@ -82,12 +82,13 @@ public: typedef typename Kernel::Point_2 Point_2; protected: - Line_2 m_l; // the line that supports the segment. - Point_2 m_ps; // the source point of the segment. - Point_2 m_pt; // the target point of the segment. - bool m_is_directed_right; // is (lexicographically) directed left to right. - bool m_is_vert; // is this a vertical segment. - bool m_is_degen; // is the segment degenerate (a single point). + mutable Line_2 m_l; // the line that supports the segment. + Point_2 m_ps; // the source point of the segment. + Point_2 m_pt; // the target point of the segment. + bool m_is_directed_right; // is (lexicographically) directed left to right. + mutable bool m_is_vert; // is this a vertical segment. + mutable bool m_is_computed; // is the support line computed. + bool m_is_degen; // is the segment degenerate (a single point). public: @@ -1170,13 +1171,16 @@ template Arr_segment_traits_2::_Segment_cached_2::_Segment_cached_2() : m_is_directed_right(false), m_is_vert(false), + m_is_computed(false), m_is_degen(true) {} //! \brief constructs a segment from a Kernel segment. template Arr_segment_traits_2:: -_Segment_cached_2::_Segment_cached_2(const Segment_2& seg) +_Segment_cached_2::_Segment_cached_2(const Segment_2& seg) : + m_is_vert(false), + m_is_computed(false) { Kernel kernel; auto vertex_ctr = kernel.construct_vertex_2_object(); @@ -1189,9 +1193,6 @@ _Segment_cached_2::_Segment_cached_2(const Segment_2& seg) m_is_directed_right = (res == SMALLER); CGAL_precondition_msg(! m_is_degen, "Cannot construct a degenerate segment."); - - m_l = kernel.construct_line_2_object()(seg); - m_is_vert = kernel.is_vertical_2_object()(seg); } //! \brief Constructs a segment from two endpoints. @@ -1200,7 +1201,9 @@ Arr_segment_traits_2:: _Segment_cached_2::_Segment_cached_2(const Point_2& source, const Point_2& target) : m_ps(source), - m_pt(target) + m_pt(target), + m_is_vert(false), + m_is_computed(false) { Kernel kernel; @@ -1209,9 +1212,6 @@ _Segment_cached_2::_Segment_cached_2(const Point_2& source, m_is_directed_right = (res == SMALLER); CGAL_precondition_msg(! m_is_degen, "Cannot construct a degenerate segment."); - - m_l = kernel.construct_line_2_object()(source, target); - m_is_vert = kernel.is_vertical_2_object()(m_l); } //! \brief constructs a segment from two endpoints on a supporting line. @@ -1233,6 +1233,7 @@ _Segment_cached_2::_Segment_cached_2(const Line_2& line, Has_exact_division())); m_is_vert = kernel.is_vertical_2_object()(m_l); + m_is_computed = true; Comparison_result res = kernel.compare_xy_2_object()(m_ps, m_pt); m_is_degen = (res == EQUAL); @@ -1252,6 +1253,7 @@ _Segment_cached_2(const Line_2& line, m_pt(target), m_is_directed_right(is_directed_right), m_is_vert(is_vert), + m_is_computed(true), m_is_degen(is_degen) {} @@ -1274,6 +1276,7 @@ Arr_segment_traits_2::_Segment_cached_2::operator=(const Segment_2& seg) m_l = kernel.construct_line_2_object()(seg); m_is_vert = kernel.is_vertical_2_object()(seg); + m_is_computed = true; return (*this); } @@ -1283,12 +1286,26 @@ Arr_segment_traits_2::_Segment_cached_2::operator=(const Segment_2& seg) //! \brief obtains the supporting line. template const typename Kernel::Line_2& -Arr_segment_traits_2::_Segment_cached_2::line() const { return m_l; } +Arr_segment_traits_2::_Segment_cached_2::line() const +{ + if (!m_is_computed) { + Kernel kernel; + m_l = kernel.construct_line_2_object()(m_ps, m_pt); + m_is_vert = kernel.is_vertical_2_object()(m_l); + m_is_computed = true; + } + return m_l; +} //! \brief determines whether the curve is vertical. template bool Arr_segment_traits_2::_Segment_cached_2::is_vertical() const -{ return m_is_vert; } +{ + // Force computation of line is orientation is still unknown + if (! m_is_computed) line(); + CGAL_precondition(!m_is_degen); + return m_is_vert; +} //! \brief determines whether the curve is degenerate. template @@ -1447,12 +1464,7 @@ public: /*! Create a bounding box for the segment. */ - Bbox_2 bbox() const - { - Kernel kernel; - auto construct_bbox = kernel.construct_bbox_2_object(); - return construct_bbox(this->m_ps) + construct_bbox(this->m_pt); - } + Bbox_2 bbox() const; }; //! \brief constructs default. @@ -1506,6 +1518,15 @@ Arr_segment_2 Arr_segment_2::flip() const this->is_degenerate()); } +//! \brief creates a bounding box for the segment. +template +Bbox_2 Arr_segment_2::bbox() const +{ + Kernel kernel; + auto construct_bbox = kernel.construct_bbox_2_object(); + return construct_bbox(this->m_ps) + construct_bbox(this->m_pt); +} + /*! Exporter for the segment class used by the traits-class. */ template diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h index 48815d767f6..3243890c1be 100644 --- a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h @@ -133,6 +133,8 @@ public: class Ex_x_monotone_curve_2 { public: typedef Base_x_monotone_curve_2 Base; + typedef Halfedge_handle_red HH_red; + typedef Halfedge_handle_blue HH_blue; protected: Base m_base_xcv; // The base curve. diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt index 0ffdc893571..bc3f1b89e7a 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt @@ -1,35 +1,28 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Arrangement_on_surface_2_Tests ) +project(Arrangement_on_surface_2_Tests) enable_testing() +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core) - -if ( CGAL_FOUND ) - - include(${CGAL_USE_FILE}) - - if(COMMAND target_compile_options) - # Since CMake-2.8.12: New CMake script, that defines the targets and - # the CTest test cases. - include( ${CMAKE_CURRENT_SOURCE_DIR}/cgal_test.cmake ) - else() - # If CMake version is <= 2.8.11, use the usual CMake script. - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - endif() +include(${CGAL_USE_FILE}) +if(COMMAND target_compile_options) + # Since CMake-2.8.12: New CMake script, that defines the targets and + # the CTest test cases. + include(${CMAKE_CURRENT_SOURCE_DIR}/cgal_test.cmake) else() + # If CMake version is <= 2.8.11, use the usual CMake script. - message(STATUS "This program requires the CGAL library, and will not be compiled.") - + # create a target per cppfile + file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) + foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") + endforeach() endif() diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake index 7fd18c6944b..d6ae0f045bb 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake @@ -911,7 +911,7 @@ function(test_polycurve_conic_traits) compile_test_with_flags(test_traits conic_polycurve "${flags}") # The input arguments for the execute_commands_new_structure, - # 1. Polycurve_conics is the directory name in "data" + # 1. polycurve_conics is the directory name in "data" # 2. polycurve_conic_traits is a string # Execute_command_new_structure will only run the test on functors provided as the third, fourth and so on arguments. # To see how the input data directory should be structured for each functor, check the execute_commands_new_structure function in this file. @@ -947,7 +947,7 @@ function(test_polycurve_circular_arc_traits) compile_test_with_flags(test_traits circular_arc_polycurve "${flags}") - execute_commands_new_structure(Polycurves_circular_arcs polycurve_circular_arc_traits + execute_commands_new_structure(polycurves_circular_arcs polycurve_circular_arc_traits COMPARE_Y_AT_X EQUAL IS_VERTICAL @@ -981,7 +981,7 @@ function(test_polycurve_bezier_traits) compile_test_with_flags(test_traits bezier_polycurve "${flags}") - execute_commands_new_structure(Polycurves_bezier test_polycurve_bezier_traits + execute_commands_new_structure(polycurves_bezier test_polycurve_bezier_traits MERGE EQUAL IS_VERTICAL @@ -1422,3 +1422,5 @@ compile_and_run(test_spherical_removal) compile_and_run(test_io) compile_and_run(test_sgm) + +compile_and_run(test_polycurve_intersection) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake index 78c93619658..c1183a846d8 100755 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake @@ -1127,7 +1127,7 @@ test_polycurve_conic_traits() if [ -n "${SUCCESS}" ] ; then # The input arguments for the execute_commands_new_structure, - # 1. Polycurve_conics is the directory name in "data" + # 1. polycurve_conics is the directory name in "data" # 2. polycurve_conic_traits is a string # Execute_command_new_structure will only run the test on functors provided as the third, fourth and so on arguments. # To see how the input data directory should be structured for each functor, check the execute_commands_new_structure function in this file. @@ -1168,7 +1168,7 @@ test_polycurve_circular_arc_traits() compile_test_with_flags test_traits circular_arc_polycurve "$flags" if [ -n "${SUCCESS}" ] ; then - execute_commands_new_structure Polycurves_circular_arcs polycurve_circular_arc_traits \ + execute_commands_new_structure polycurves_circular_arcs polycurve_circular_arc_traits \ COMPARE_Y_AT_X \ EQUAL \ IS_VERTICAL \ @@ -1208,7 +1208,7 @@ test_polycurve_bezier_traits() compile_test_with_flags test_traits bezier_polycurve "$flags" if [ -n "${SUCCESS}" ] ; then - execute_commands_new_structure Polycurves_bezier test_polycurve_bezier_traits \ + execute_commands_new_structure polycurves_bezier test_polycurve_bezier_traits \ MERGE \ EQUAL \ IS_VERTICAL \ @@ -1751,6 +1751,8 @@ compile_and_run test_io compile_and_run test_sgm +compile_and_run test_polycurve_intersection + # if any error occurred then append the full error description file to error file if [ -f $FULL_ERROR_DESCRIPTION_FILE ] ; then diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/are_mergeable b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/are_mergeable similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/are_mergeable rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/are_mergeable diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_endpoints_xy b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_endpoints_xy similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_endpoints_xy rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_endpoints_xy diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_x b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_x similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_x rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_x diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_xy b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_xy similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_xy rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_xy diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x_left b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x_left similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x_left rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x_left diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x_right b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x_right similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/compare_y_at_x_right rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/compare_y_at_x_right diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/construct_opposite b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/construct_opposite similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/construct_opposite rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/construct_opposite diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/curves b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/curves similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/curves rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/curves diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/equal b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/equal similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/equal rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/equal diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/intersect b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/intersect similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/intersect rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/intersect diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/is_vertical b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/is_vertical similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/is_vertical rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/is_vertical diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/make_x_monotone b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/make_x_monotone similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/make_x_monotone rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/make_x_monotone diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/merge b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/merge similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/merge rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/merge diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/number_of_points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/number_of_points similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/number_of_points rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/number_of_points diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/points rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/push_back b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/push_back similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/push_back rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/push_back diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/push_front b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/push_front similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/push_front rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/push_front diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/split b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/split similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/split rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/split diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/trim b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/trim similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/trim rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/trim diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/vertex b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/vertex similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/vertex rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/vertex diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/xcurves b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/xcurves similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_bezier/xcurves rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/xcurves diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/are_mergeable b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/are_mergeable similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/are_mergeable rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/are_mergeable diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_endpoints_xy b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_endpoints_xy similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_endpoints_xy rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_endpoints_xy diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_x b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_x similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_x rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_x diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_xy b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_xy similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_xy rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_xy diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x_left b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x_left similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x_left rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x_left diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x_right b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x_right similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/compare_y_at_x_right rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/compare_y_at_x_right diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/construct_opposite b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/construct_opposite similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/construct_opposite rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/construct_opposite diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/curves b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/curves similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/curves rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/curves diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/equal b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/equal similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/equal rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/equal diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/intersect b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/intersect similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/intersect rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/intersect diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/is_vertical b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/is_vertical similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/is_vertical rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/is_vertical diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/make_x_monotone b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/make_x_monotone similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/make_x_monotone rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/make_x_monotone diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/merge b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/merge similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/merge rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/merge diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/number_of_points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/number_of_points similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/number_of_points rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/number_of_points diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/points similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/points rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/points diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/push_back b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/push_back similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/push_back rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/push_back diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/push_front b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/push_front similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/push_front rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/push_front diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/split b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/split similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/split rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/split diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/trim b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/trim similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/trim rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/trim diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/vertex b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/vertex similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/vertex rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/vertex diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/xcurves b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/xcurves similarity index 100% rename from Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/Polycurves_circular_arcs/xcurves rename to Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_circular_arcs/xcurves diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp new file mode 100644 index 00000000000..5cfd7a64f2e --- /dev/null +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_polycurve_intersection.cpp @@ -0,0 +1,94 @@ +#include +#include +#include +#include + +#include + +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; +typedef CGAL::Arr_segment_traits_2 Segment_traits_2; +typedef CGAL::Arr_polyline_traits_2 Geom_traits_2; + +typedef Geom_traits_2::Point_2 Point_2; +typedef Geom_traits_2::Segment_2 Segment_2; +typedef Geom_traits_2::Curve_2 Polyline_2; +typedef CGAL::Arrangement_2 Arrangement_2; +typedef Geom_traits_2::X_monotone_curve_2 X_monotone_polyline; +typedef Geom_traits_2::X_monotone_subcurve_2 X_monotone_subcurve; + +struct Test_functor +{ + const X_monotone_polyline* reference; + + Test_functor (const X_monotone_polyline& reference) + : reference (&reference) { } + + void operator() (const CGAL::Object& obj) const + { + const X_monotone_polyline* poly + = CGAL::object_cast(&obj); + CGAL_assertion_msg (poly != nullptr, "Intersection is not a polyline"); + + typename X_monotone_polyline::Point_const_iterator + itref = reference->points_begin(), + itpoly = poly->points_begin(); + + for (; itref != reference->points_end() + && itpoly != poly->points_end(); + ++ itref, ++ itpoly) + CGAL_assertion (*itref == *itpoly); + } +}; + +void test (const X_monotone_polyline& a, const X_monotone_polyline& b, + const X_monotone_polyline& reference) +{ + Geom_traits_2 traits; + Geom_traits_2::Intersect_2 intersect_2 = + traits.intersect_2_object(); + + std::cerr << " * Polyline A = " << a << std::endl + << " * Polyline B = " << b << std::endl; + + intersect_2 + (a, b, boost::make_function_output_iterator (Test_functor(reference))); +} + +int main() +{ + Geom_traits_2 traits; + Arrangement_2 arr(&traits); + + Geom_traits_2::Construct_x_monotone_curve_2 x_mono_polyline_construct = + traits.construct_x_monotone_curve_2_object(); + + std::array r2l + = { Segment_2(Point_2(1, 0), Point_2(0, 1)), + Segment_2(Point_2(0, 1), Point_2(-1, 0)) }; + + std::array l2r + = { Segment_2(Point_2(-1, 0), Point_2(0, 1)), + Segment_2(Point_2(0, 1), Point_2(1, 0)), }; + + X_monotone_polyline p0l2r + = x_mono_polyline_construct (l2r.begin(), l2r.end()); + X_monotone_polyline p1l2r + = x_mono_polyline_construct (l2r.begin(), l2r.end()); + X_monotone_polyline p0r2l + = x_mono_polyline_construct (r2l.begin(), r2l.end()); + X_monotone_polyline p1r2l + = x_mono_polyline_construct (r2l.begin(), r2l.end()); + + std::cerr << "Testing intersection left-to-right / left-to-right" << std::endl; + test (p0l2r, p1l2r, p0l2r); + std::cerr << "Testing intersection left-to-right / right-to-left" << std::endl; + test (p0l2r, p1r2l, p0l2r); + std::cerr << "Testing intersection right-to-left / left-to-right" << std::endl; + test (p0r2l, p1l2r, p0l2r); + std::cerr << "Testing intersection right-to-left / right-to-left" << std::endl; + test (p0r2l, p1r2l, p0r2l); + + return EXIT_SUCCESS; +} diff --git a/BGL/doc/BGL/Concepts/FaceGraph.h b/BGL/doc/BGL/Concepts/FaceGraph.h index 08501700261..40346595ac6 100644 --- a/BGL/doc/BGL/Concepts/FaceGraph.h +++ b/BGL/doc/BGL/Concepts/FaceGraph.h @@ -25,7 +25,7 @@ A face descriptor must be `DefaultConstructible`, `Assignable`, `EqualityCompara \sa \link PkgBGLConcepts Graph Concepts \endlink */ class FaceGraph { - /// Returns a special `boost::graph_traits::face_descriptor` object which + /// Returns a special `boost::graph_traits::%face_descriptor` object which /// does not refer to any face of graph object which type is `FaceGraph`. static boost::graph_traits::halfedge_descriptor null_face(); }; diff --git a/BGL/doc/BGL/Concepts/HalfedgeGraph.h b/BGL/doc/BGL/Concepts/HalfedgeGraph.h index b69cbb20447..3769db82e16 100644 --- a/BGL/doc/BGL/Concepts/HalfedgeGraph.h +++ b/BGL/doc/BGL/Concepts/HalfedgeGraph.h @@ -44,7 +44,7 @@ A model of `HalfedgeGraph` must have the interior property `vertex_point` attach \sa \link PkgBGLConcepts Graph Concepts \endlink */ class HalfedgeGraph { - /// Returns a special `boost::graph_traits::halfedge_descriptor` object which + /// Returns a special `boost::graph_traits::%halfedge_descriptor` object which /// does not refer to any halfedge of graph object which type is `HalfedgeGraph`. static boost::graph_traits::halfedge_descriptor null_halfedge(); }; diff --git a/BGL/examples/BGL_LCC/CMakeLists.txt b/BGL/examples/BGL_LCC/CMakeLists.txt index fea37899fae..0c2bc149e12 100644 --- a/BGL/examples/BGL_LCC/CMakeLists.txt +++ b/BGL/examples/BGL_LCC/CMakeLists.txt @@ -2,26 +2,18 @@ # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_LCC_Examples ) - - +project(BGL_LCC_Examples) # CGAL and its components -find_package( CGAL QUIET COMPONENTS ) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() +find_package(CGAL REQUIRED) # Boost and its components -find_package( Boost REQUIRED ) +find_package(Boost REQUIRED) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() @@ -33,7 +25,10 @@ endif() # ########################################################## # create a target per cppfile -file(GLOB_RECURSE cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) +file( + GLOB_RECURSE cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + *.cpp) foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}") endforeach() diff --git a/BGL/examples/BGL_OpenMesh/CMakeLists.txt b/BGL/examples/BGL_OpenMesh/CMakeLists.txt index 685f9bc7367..e23d15c960a 100644 --- a/BGL/examples/BGL_OpenMesh/CMakeLists.txt +++ b/BGL/examples/BGL_OpenMesh/CMakeLists.txt @@ -2,38 +2,31 @@ # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_OpenMesh_Examples ) - - +project(BGL_OpenMesh_Examples) # CGAL and its components -find_package( CGAL QUIET COMPONENTS ) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() +find_package(CGAL REQUIRED) # Boost and its components -find_package( Boost REQUIRED ) +find_package(Boost REQUIRED) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() endif() -find_package( OpenMesh QUIET ) +find_package(OpenMesh QUIET) -if ( OpenMesh_FOUND ) -include( UseOpenMesh ) +if(OpenMesh_FOUND) + include(UseOpenMesh) else() - message(STATUS "NOTICE: These examples require OpenMesh and will not be compiled.") + message( + STATUS "NOTICE: These examples require OpenMesh and will not be compiled.") return() endif() @@ -46,7 +39,6 @@ endif() # ########################################################## if(OpenMesh_FOUND) - create_single_source_cgal_program( "TriMesh.cpp" ) - target_link_libraries( TriMesh PRIVATE ${OPENMESH_LIBRARIES} ) + create_single_source_cgal_program("TriMesh.cpp") + target_link_libraries(TriMesh PRIVATE ${OPENMESH_LIBRARIES}) endif() - diff --git a/BGL/examples/BGL_arrangement_2/CMakeLists.txt b/BGL/examples/BGL_arrangement_2/CMakeLists.txt index 31b9e348019..b4a1dcb0228 100644 --- a/BGL/examples/BGL_arrangement_2/CMakeLists.txt +++ b/BGL/examples/BGL_arrangement_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_arrangement_2_Examples ) +project(BGL_arrangement_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/BGL/examples/BGL_graphcut/CMakeLists.txt b/BGL/examples/BGL_graphcut/CMakeLists.txt index 56ee0be7a92..0119b961465 100644 --- a/BGL/examples/BGL_graphcut/CMakeLists.txt +++ b/BGL/examples/BGL_graphcut/CMakeLists.txt @@ -3,26 +3,18 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_graphcut_Examples ) - +project(BGL_graphcut_Examples) # CGAL and its components -find_package( CGAL QUIET COMPONENTS ) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() - +find_package(CGAL REQUIRED) # Boost and its components -find_package( Boost REQUIRED ) +find_package(Boost REQUIRED) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() @@ -32,12 +24,9 @@ endif() # include for local package - # Creating entries for all C++ files with "main" routine # ########################################################## - -create_single_source_cgal_program( "alpha_expansion_example.cpp" ) -create_single_source_cgal_program( "face_selection_borders_regularization_example.cpp" ) - - +create_single_source_cgal_program("alpha_expansion_example.cpp") +create_single_source_cgal_program( + "face_selection_borders_regularization_example.cpp") diff --git a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt index 01378916001..7052dc314bb 100644 --- a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt +++ b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt @@ -2,46 +2,38 @@ # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_polyhedron_3_Examples ) - - +project(BGL_polyhedron_3_Examples) # CGAL and its components -find_package( CGAL QUIET COMPONENTS ) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() +find_package(CGAL REQUIRED) # Boost and its components -find_package( Boost REQUIRED ) +find_package(Boost REQUIRED) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() endif() -find_package( OpenMesh QUIET ) +find_package(OpenMesh QUIET) -if ( OpenMesh_FOUND ) - include( UseOpenMesh ) - add_definitions( -DCGAL_USE_OPENMESH ) +if(OpenMesh_FOUND) + include(UseOpenMesh) + add_definitions(-DCGAL_USE_OPENMESH) else() message(STATUS "Examples that use OpenMesh will not be compiled.") endif() -find_package( METIS ) +find_package(METIS) -if( METIS_FOUND ) - include_directories(${METIS_INCLUDE_DIRS} ) +if(METIS_FOUND) + include_directories(${METIS_INCLUDE_DIRS}) else() - message( STATUS "Examples that use the METIS library will not be compiled." ) + message(STATUS "Examples that use the METIS library will not be compiled.") endif() # include for local directory @@ -51,28 +43,27 @@ endif() # Creating entries for all C++ files with "main" routine # ########################################################## -create_single_source_cgal_program( "distance.cpp" ) +create_single_source_cgal_program("distance.cpp") -create_single_source_cgal_program( "incident_vertices.cpp" ) +create_single_source_cgal_program("incident_vertices.cpp") -create_single_source_cgal_program( "kruskal.cpp" ) +create_single_source_cgal_program("kruskal.cpp") -create_single_source_cgal_program( "kruskal_with_stored_id.cpp" ) +create_single_source_cgal_program("kruskal_with_stored_id.cpp") -create_single_source_cgal_program( "normals.cpp" ) +create_single_source_cgal_program("normals.cpp") -create_single_source_cgal_program( "range.cpp" ) +create_single_source_cgal_program("range.cpp") -create_single_source_cgal_program( "transform_iterator.cpp" ) +create_single_source_cgal_program("transform_iterator.cpp") -create_single_source_cgal_program( "copy_polyhedron.cpp" ) +create_single_source_cgal_program("copy_polyhedron.cpp") if(OpenMesh_FOUND) - target_link_libraries( copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES} ) + target_link_libraries(copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES}) endif() -if( METIS_FOUND ) - create_single_source_cgal_program( "polyhedron_partition.cpp" ) - target_link_libraries( polyhedron_partition PRIVATE ${METIS_LIBRARIES} ) +if(METIS_FOUND) + create_single_source_cgal_program("polyhedron_partition.cpp") + target_link_libraries(polyhedron_partition PRIVATE ${METIS_LIBRARIES}) endif() - diff --git a/BGL/examples/BGL_surface_mesh/CMakeLists.txt b/BGL/examples/BGL_surface_mesh/CMakeLists.txt index 13ba8575799..92d4c226359 100644 --- a/BGL/examples/BGL_surface_mesh/CMakeLists.txt +++ b/BGL/examples/BGL_surface_mesh/CMakeLists.txt @@ -1,31 +1,24 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_surface_mesh_Examples ) +project(BGL_surface_mesh_Examples) - -find_package( CGAL QUIET ) - -if ( NOT CGAL_FOUND ) - message( STATUS "This project requires the CGAL library, and will not be compiled." ) - return() -endif() +find_package(CGAL REQUIRED) # include for local package -create_single_source_cgal_program( "prim.cpp" ) -create_single_source_cgal_program( "gwdwg.cpp" ) -create_single_source_cgal_program( "seam_mesh.cpp" ) -create_single_source_cgal_program( "write_inp.cpp" ) -create_single_source_cgal_program( "surface_mesh_dual.cpp" ) -create_single_source_cgal_program( "connected_components.cpp" ) +create_single_source_cgal_program("prim.cpp") +create_single_source_cgal_program("gwdwg.cpp") +create_single_source_cgal_program("seam_mesh.cpp") +create_single_source_cgal_program("write_inp.cpp") +create_single_source_cgal_program("surface_mesh_dual.cpp") +create_single_source_cgal_program("connected_components.cpp") -find_package( METIS ) +find_package(METIS) -if( METIS_FOUND ) - include_directories(${METIS_INCLUDE_DIRS} ) +if(METIS_FOUND) + include_directories(${METIS_INCLUDE_DIRS}) - create_single_source_cgal_program( "surface_mesh_partition.cpp" ) - target_link_libraries( surface_mesh_partition PRIVATE ${METIS_LIBRARIES} ) + create_single_source_cgal_program("surface_mesh_partition.cpp") + target_link_libraries(surface_mesh_partition PRIVATE ${METIS_LIBRARIES}) else() - message( STATUS "Examples that use the METIS library will not be compiled." ) + message(STATUS "Examples that use the METIS library will not be compiled.") endif() - diff --git a/BGL/examples/BGL_triangulation_2/CMakeLists.txt b/BGL/examples/BGL_triangulation_2/CMakeLists.txt index 55eb169ecff..9fa3903f234 100644 --- a/BGL/examples/BGL_triangulation_2/CMakeLists.txt +++ b/BGL/examples/BGL_triangulation_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_triangulation_2_Examples ) +project(BGL_triangulation_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/BGL/include/CGAL/boost/graph/Seam_mesh.h b/BGL/include/CGAL/boost/graph/Seam_mesh.h index 4919c73b42c..c74accc8586 100644 --- a/BGL/include/CGAL/boost/graph/Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/Seam_mesh.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ namespace CGAL { #ifndef DOXYGEN_RUNNING + template class Seam_mesh_halfedge_descriptor { @@ -86,8 +88,92 @@ public: return 2 * hash_value(hd.tmhd) + static_cast(hd.seam); } }; + +template +class Seam_mesh_vertex_descriptor +{ +public: + Seam_mesh_halfedge_descriptor hd; + + Seam_mesh_vertex_descriptor() { } + + Seam_mesh_vertex_descriptor(const Seam_mesh_halfedge_descriptor& h) + : hd(h) + { } + + bool operator==(const Seam_mesh_vertex_descriptor& other) const + { + return (hd == other.hd); + } + + bool operator!=(const Seam_mesh_vertex_descriptor& other) const + { + return (hd != other.hd); + } + + bool operator<(const Seam_mesh_vertex_descriptor& other) const + { + return hd < other.hd; + } + + operator HD() const + { + return hd; + } + +#ifdef CGAL_SEAM_MESH_INSERT_OPERATOR + friend std::ostream& operator<<(std::ostream& os, const Seam_mesh_vertex_descriptor vd) + { + os << "seam mesh vertex: " << vd.hd; + return os; + } #endif + friend std::size_t hash_value(const Seam_mesh_vertex_descriptor& vd) + { + return hash_value(vd.hd.tmhd); + } +}; + +template +class Seam_mesh_edge_descriptor +{ +public: + Seam_mesh_halfedge_descriptor hd; + const SM* mesh_; + + Seam_mesh_edge_descriptor() : mesh_(nullptr) { } + + Seam_mesh_edge_descriptor(const Seam_mesh_halfedge_descriptor& hd, const SM* m) + : hd(hd), mesh_(m) + {} + + friend bool operator==(Seam_mesh_edge_descriptor e1, Seam_mesh_edge_descriptor e2) + { + return (e1.hd == e2.hd) || (e1.hd == e2.mesh_->opposite(e2.hd)); + } + + friend bool operator!=(Seam_mesh_edge_descriptor e1, Seam_mesh_edge_descriptor e2) + { + return ! (e1 == e2); + } + +#ifdef CGAL_SEAM_MESH_INSERT_OPERATOR + friend std::ostream& operator<<(std::ostream& os, const Seam_mesh_edge_descriptor& ed) + { + os << ed.hd; + return os; + } +#endif + + friend std::size_t hash_value(const Seam_mesh_edge_descriptor& ed) + { + return hash_value((std::min)(ed.hd, ed.mesh_->opposite(ed.hd))); + } +}; + +#endif // DOXYGEN_RUNNING + /// \ingroup PkgBGLAdaptors /// /// This class is a data structure that takes a triangle mesh, further refered @@ -112,6 +198,10 @@ class Seam_mesh typedef Seam_mesh Self; public: + /// The underlying mesh type + typedef TM Triangle_mesh; + + // backward compatibility typedef TM TriangleMesh; public: @@ -187,23 +277,15 @@ public: class halfedge_descriptor { public: - TM_halfedge_descriptor tmhd; - bool seam; - /// %Default constructor - halfedge_descriptor() : tmhd(), seam(false) { } + halfedge_descriptor(); - halfedge_descriptor(TM_halfedge_descriptor tmhd, bool seam = false) - : tmhd(tmhd), seam(seam) - { } + /// Constructor from a halfedge of the underlying mesh + halfedge_descriptor(TM_halfedge_descriptor tmhd, bool seam = false); #ifdef CGAL_SEAM_MESH_INSERT_OPERATOR /// Print the halfedge and if it is on a seam. - friend std::ostream& operator<<(std::ostream& os, const halfedge_descriptor& hd) - { - os << hd.tmhd << ((hd.seam)?" on seam":""); - return os; - } + friend std::ostream& operator<<(std::ostream& os, const halfedge_descriptor& hd); #endif }; #else @@ -265,13 +347,13 @@ public: return halfedge_descriptor(*hd, seam); } }; -#endif +#endif // DOXYGEN_RUNNING +#ifdef DOXYGEN_RUNNING /// This class represents a vertex of the seam mesh. /// /// Implementation note: to properly duplicate vertices that are on seams, - /// a vertex_descriptor is in fact represented as a halfedge of the underlying - /// mesh. + /// a vertex_descriptor is in fact represented as a halfedge of the seam mesh. /// /// \cgalModels `Descriptor` /// \cgalModels `LessThanComparable` @@ -280,48 +362,20 @@ public: class vertex_descriptor { public: - halfedge_descriptor hd; - /// %Default constructor - vertex_descriptor() { } + vertex_descriptor(); - vertex_descriptor(const halfedge_descriptor& h) - : hd(h) - { } - - bool operator==(const vertex_descriptor& other) const - { - return (hd == other.hd); - } - - bool operator!=(const vertex_descriptor& other) const - { - return (hd != other.hd); - } - - bool operator<(const vertex_descriptor& other) const - { - return hd < other.hd; - } - - operator TM_halfedge_descriptor() const - { - return hd; - } + /// Constructor from a seam mesh halfedge + vertex_descriptor(const halfedge_descriptor& h); #ifdef CGAL_SEAM_MESH_INSERT_OPERATOR - friend std::ostream& operator<<(std::ostream& os, const vertex_descriptor vd) - { - os << "seam mesh vertex: " << vd.hd; - return os; - } + /// Print the seam mesh vertex. + friend std::ostream& operator<<(std::ostream& os, const vertex_descriptor vd); #endif - - friend std::size_t hash_value(const vertex_descriptor& vd) - { - return hash_value(vd.hd.tmhd); - } }; +#else + typedef Seam_mesh_vertex_descriptor vertex_descriptor; +#endif // iterator #ifndef DOXYGEN_RUNNING @@ -403,48 +457,24 @@ public: }; #endif +#ifdef DOXYGEN_RUNNING /// This class represents an edge of the seam mesh. /// /// \cgalModels `Descriptor` + /// \cgalModels `Hashable` /// class edge_descriptor { - public: - halfedge_descriptor hd; - const Self* mesh_; + /// %Default constructor + edge_descriptor(); #ifdef CGAL_SEAM_MESH_INSERT_OPERATOR - friend - std::ostream& operator<<(std::ostream& os, const edge_descriptor& ed) - { - os << ed.hd; - return os; - } + friend std::ostream& operator<<(std::ostream& os, const edge_descriptor& ed); #endif - - edge_descriptor() - : mesh_(nullptr) - {} - - edge_descriptor(const halfedge_descriptor& hd, const Self* m) - : hd(hd), mesh_(m) - {} - - friend bool operator==(edge_descriptor e1, edge_descriptor e2) - { - return (e1.hd == e2.hd) || (e1.hd == e2.mesh_->opposite(e2.hd)); - } - - friend bool operator!=(edge_descriptor e1, edge_descriptor e2) - { - return ! (e1 == e2); - } - - friend std::size_t hash_value(const edge_descriptor& ed) - { - return hash_value((std::min)(ed.hd, ed.mesh_->opposite(ed.hd))); - } }; +#else + typedef Seam_mesh_edge_descriptor edge_descriptor; +#endif #ifndef DOXYGEN_RUNNING // iterator @@ -1120,6 +1150,46 @@ public: } // namespace CGAL +#ifndef CGAL_CFG_NO_STD_HASH + +namespace std { + +template +struct hash > + : public CGAL::cpp98::unary_function, std::size_t> +{ + std::size_t operator()(const CGAL::Seam_mesh_vertex_descriptor& v) const + { + return hash_value(v); + } +}; + +template +struct hash > + : public CGAL::cpp98::unary_function, std::size_t> +{ + std::size_t operator()(const CGAL::Seam_mesh_halfedge_descriptor& h) const + { + return hash_value(h); + } +}; + +template +struct hash > + : public CGAL::cpp98::unary_function, std::size_t> +{ + std::size_t operator()(const CGAL::Seam_mesh_edge_descriptor& e) const + { + return hash_value(e); + } +}; + +// Seam_mesh::face_descriptor is equal to TM_face_descriptor so nothing to do + +} // namespace std + +#endif // CGAL_CFG_NO_STD_HASH + #include #endif //CGAL_SEAM_MESH_H diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index c735823a0fa..a1842b8148a 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -135,7 +135,7 @@ struct Index_map_initializer void operator()(const PropertyTag, IndexPropertyMap, const Graph&) { // The property map is not writable; should never be here. - CGAL_assertion_msg(false, "You are trying to initialize a non-writable property map"); + CGAL_assertion_msg(false, "Initialization of a non-writable property map is impossible"); } }; @@ -171,7 +171,7 @@ IndexMap get_initialized_index_map_const(const IndexMap index_map, CGAL_USE(g); CGAL_USE(p); - // If you are passing a pmap via NPs, it must be initialized + // If a pmap is passed via NPs, it must be initialized CGAL_assertion(is_index_map_valid(p, index_map, g)); return index_map; @@ -185,7 +185,7 @@ IndexMap get_initialized_index_map(const IndexMap index_map, CGAL_USE(g); CGAL_USE(p); - // If you are passing a pmap via NPs, it must be initialized + // If a pmap is passed via NPs, it must be initialized CGAL_assertion(is_index_map_valid(p, index_map, g)); return index_map; diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index 776df8125f4..de168a93dfb 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -102,6 +102,7 @@ CGAL_add_named_parameter(halfedges_keeper_t, halfedges_keeper, halfedges_keeper) CGAL_add_named_parameter(volume_threshold_t, volume_threshold, volume_threshold) CGAL_add_named_parameter(dry_run_t, dry_run, dry_run) CGAL_add_named_parameter(do_not_modify_t, do_not_modify, do_not_modify) +CGAL_add_named_parameter(allow_self_intersections_t, allow_self_intersections, allow_self_intersections) // List of named parameters that we use in the package 'Surface Mesh Simplification' CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) @@ -113,6 +114,7 @@ CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map) CGAL_add_named_parameter(random_seed_t, random_seed, random_seed) CGAL_add_named_parameter(do_lock_mesh_t, do_lock_mesh, do_lock_mesh) CGAL_add_named_parameter(do_simplify_border_t, do_simplify_border, do_simplify_border) +CGAL_add_named_parameter(algorithm_t, algorithm, algorithm) //internal CGAL_add_named_parameter(weight_calculator_t, weight_calculator, weight_calculator) @@ -151,6 +153,8 @@ CGAL_add_named_parameter(inspector_t, inspector, inspector) CGAL_add_named_parameter(logger_t, logger, logger) CGAL_add_named_parameter(pointmatcher_config_t, pointmatcher_config, pointmatcher_config) CGAL_add_named_parameter(adjacencies_t, adjacencies, adjacencies) +CGAL_add_named_parameter(scan_angle_t, scan_angle_map, scan_angle_map) +CGAL_add_named_parameter(scanline_id_t, scanline_id_map, scanline_id_map) // List of named parameters used in Surface_mesh_approximation package CGAL_add_named_parameter(verbose_level_t, verbose_level, verbose_level) diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index dfe324a32af..42f84501ba2 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -2,119 +2,108 @@ # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.15) -project( BGL_Tests ) - - - - +project(BGL_Tests) # CGAL and its components -find_package( CGAL QUIET COMPONENTS ) - -if ( NOT CGAL_FOUND ) - - message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() - -endif() +find_package(CGAL REQUIRED) # Boost and its components -find_package( Boost ) +find_package(Boost) -if ( NOT Boost_FOUND ) - message(STATUS "This project requires the Boost library, and will not be compiled.") +if(NOT Boost_FOUND) + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() endif() -find_package( OpenMesh QUIET ) +find_package(OpenMesh QUIET) -if ( OpenMesh_FOUND ) - include( UseOpenMesh ) - add_definitions( -DCGAL_USE_OPENMESH ) +if(OpenMesh_FOUND) + include(UseOpenMesh) + add_definitions(-DCGAL_USE_OPENMESH) else() message(STATUS "Examples that use OpenMesh will not be compiled.") endif() - - # include for local package # Creating entries for all .cpp/.C files with "main" routine # ########################################################## if(OpenMesh_FOUND) - create_single_source_cgal_program( "graph_concept_OpenMesh.cpp" ) - target_link_libraries( graph_concept_OpenMesh PRIVATE ${OPENMESH_LIBRARIES} ) + create_single_source_cgal_program("graph_concept_OpenMesh.cpp") + target_link_libraries(graph_concept_OpenMesh PRIVATE ${OPENMESH_LIBRARIES}) endif() -create_single_source_cgal_program( "next.cpp" ) +create_single_source_cgal_program("next.cpp") -create_single_source_cgal_program( "test_circulator.cpp" ) +create_single_source_cgal_program("test_circulator.cpp") -create_single_source_cgal_program( "test_Gwdwg.cpp" ) +create_single_source_cgal_program("test_Gwdwg.cpp") -create_single_source_cgal_program( "test_bgl_dual.cpp" ) +create_single_source_cgal_program("test_bgl_dual.cpp") -create_single_source_cgal_program( "graph_concept_Polyhedron_3.cpp" ) +create_single_source_cgal_program("graph_concept_Polyhedron_3.cpp") -create_single_source_cgal_program( "graph_concept_Dual.cpp" ) +create_single_source_cgal_program("graph_concept_Dual.cpp") -create_single_source_cgal_program( "graph_concept_Triangulation_2.cpp" ) +create_single_source_cgal_program("graph_concept_Triangulation_2.cpp") -create_single_source_cgal_program( "graph_concept_Surface_mesh.cpp" ) +create_single_source_cgal_program("graph_concept_Surface_mesh.cpp") -create_single_source_cgal_program( "graph_concept_Seam_mesh_Surface_mesh.cpp" ) +create_single_source_cgal_program("graph_concept_Seam_mesh_Surface_mesh.cpp") -create_single_source_cgal_program( "graph_concept_Gwdwg_Surface_mesh.cpp" ) +create_single_source_cgal_program("graph_concept_Gwdwg_Surface_mesh.cpp") -create_single_source_cgal_program( "graph_concept_Linear_cell_complex.cpp" ) +create_single_source_cgal_program("graph_concept_Linear_cell_complex.cpp") -create_single_source_cgal_program( "graph_concept_Arrangement_2.cpp" ) +create_single_source_cgal_program("graph_concept_Arrangement_2.cpp") create_single_source_cgal_program( "graph_concept_Derived.cpp" ) create_single_source_cgal_program( "test_clear.cpp" ) -create_single_source_cgal_program( "test_helpers.cpp" ) +create_single_source_cgal_program("test_helpers.cpp") -create_single_source_cgal_program( "test_Has_member_clear.cpp" ) +create_single_source_cgal_program("test_Has_member_clear.cpp") -create_single_source_cgal_program( "test_Has_member_id.cpp" ) +create_single_source_cgal_program("test_Has_member_id.cpp") -create_single_source_cgal_program( "test_cgal_bgl_named_params.cpp" ) +create_single_source_cgal_program("test_cgal_bgl_named_params.cpp") -create_single_source_cgal_program( "test_bgl_read_write.cpp" ) +create_single_source_cgal_program("test_bgl_read_write.cpp") -create_single_source_cgal_program( "graph_concept_Face_filtered_graph.cpp" ) +create_single_source_cgal_program("graph_concept_Face_filtered_graph.cpp") -create_single_source_cgal_program( "test_Manifold_face_removal.cpp") +create_single_source_cgal_program("test_Manifold_face_removal.cpp") -create_single_source_cgal_program( "test_Regularize_face_selection_borders.cpp") +create_single_source_cgal_program("test_Regularize_face_selection_borders.cpp") -create_single_source_cgal_program( "test_Face_filtered_graph.cpp" ) +create_single_source_cgal_program("test_Face_filtered_graph.cpp") -create_single_source_cgal_program( "test_Euler_operations.cpp" ) +create_single_source_cgal_program("test_Euler_operations.cpp") create_single_source_cgal_program( "test_test_face.cpp" ) create_single_source_cgal_program( "test_Collapse_edge.cpp" ) -create_single_source_cgal_program( "test_graph_traits.cpp" ) +create_single_source_cgal_program("test_graph_traits.cpp") -create_single_source_cgal_program( "test_Properties.cpp" ) +create_single_source_cgal_program("test_Properties.cpp") -create_single_source_cgal_program( "test_wrl.cpp" ) +create_single_source_cgal_program("test_wrl.cpp") -create_single_source_cgal_program( "bench_read_from_stream_vs_add_face_and_add_faces.cpp" ) +create_single_source_cgal_program( + "bench_read_from_stream_vs_add_face_and_add_faces.cpp") create_single_source_cgal_program( "graph_traits_inheritance.cpp" ) if(OpenMesh_FOUND) - target_link_libraries( test_clear PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_graph_traits PRIVATE ${OPENMESH_LIBRARIES} ) - target_link_libraries( test_Properties PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_graph_traits PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_Properties PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES}) endif() diff --git a/BGL/test/BGL/test_cgal_bgl_named_params.cpp b/BGL/test/BGL/test_cgal_bgl_named_params.cpp index 1a2c89555b7..18db63159e4 100644 --- a/BGL/test/BGL/test_cgal_bgl_named_params.cpp +++ b/BGL/test/BGL/test_cgal_bgl_named_params.cpp @@ -98,6 +98,7 @@ void test(const NamedParameters& np) assert(get_parameter(np, CGAL::internal_np::halfedges_keeper).v == 62); assert(get_parameter(np, CGAL::internal_np::do_simplify_border).v == 64); assert(get_parameter(np, CGAL::internal_np::do_not_modify).v == 65); + assert(get_parameter(np, CGAL::internal_np::allow_self_intersections).v == 66); assert(get_parameter(np, CGAL::internal_np::maximum_number_of_faces).v == 78910); // Named parameters that we use in the package 'Surface Mesh Simplification' @@ -186,6 +187,7 @@ void test(const NamedParameters& np) check_same_type<55>(get_parameter(np, CGAL::internal_np::use_Delaunay_flips)); check_same_type<56>(get_parameter(np, CGAL::internal_np::use_safety_constraints)); check_same_type<65>(get_parameter(np, CGAL::internal_np::do_not_modify)); + check_same_type<66>(get_parameter(np, CGAL::internal_np::allow_self_intersections)); check_same_type<12340>(get_parameter(np, CGAL::internal_np::do_self_intersection_tests)); check_same_type<12341>(get_parameter(np, CGAL::internal_np::do_orientation_tests)); @@ -219,6 +221,7 @@ void test(const NamedParameters& np) check_same_type<36>(get_parameter(np, CGAL::internal_np::face_normal)); check_same_type<37>(get_parameter(np, CGAL::internal_np::random_seed)); check_same_type<38>(get_parameter(np, CGAL::internal_np::do_project)); + check_same_type<456>(get_parameter(np, CGAL::internal_np::algorithm)); // Internal named parameters check_same_type<39>(get_parameter(np, CGAL::internal_np::weight_calculator)); @@ -265,6 +268,8 @@ void test(const NamedParameters& np) check_same_type<9032>(get_parameter(np, CGAL::internal_np::inspector)); check_same_type<9033>(get_parameter(np, CGAL::internal_np::logger)); check_same_type<9034>(get_parameter(np, CGAL::internal_np::maximum_normal_deviation)); + check_same_type<9035>(get_parameter(np, CGAL::internal_np::scan_angle_map)); + check_same_type<9036>(get_parameter(np, CGAL::internal_np::scanline_id_map)); } int main() @@ -318,6 +323,7 @@ int main() .face_normal_map(A<36>(36)) .random_seed(A<37>(37)) .do_project(A<38>(38)) + .algorithm(A<456>(456)) .weight_calculator(A<39>(39)) .preserve_genus(A<40>(40)) .verbosity_level(A<41>(41)) @@ -356,6 +362,7 @@ int main() .use_convex_hull(A<63>(63)) .do_simplify_border(A<64>(64)) .do_not_modify(A<65>(65)) + .allow_self_intersections(A<66>(66)) .point_map(A<9000>(9000)) .query_point_map(A<9001>(9001)) .normal_map(A<9002>(9002)) @@ -391,6 +398,8 @@ int main() .inspector(A<9032>(9032)) .logger(A<9033>(9033)) .maximum_normal_deviation(A<9034>(9034)) + .scan_angle_map(A<9035>(9035)) + .scanline_id_map(A<9036>(9036)) .maximum_number_of_faces(A<78910>(78910)) ); return EXIT_SUCCESS; diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt index fe29d09d8af..dd081fc1f23 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Barycentric_coordinates_2_Examples ) +project(Barycentric_coordinates_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt index 1e5b96696b2..3af8199b60a 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Barycentric_coordinates_2_Tests ) +project(Barycentric_coordinates_2_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt b/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt index dac559d6846..b02cec7624c 100644 --- a/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt +++ b/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt @@ -2,42 +2,49 @@ # This is the CMake script for compiling a CGAL application. cmake_minimum_required(VERSION 3.1...3.15) -project( Boolean_set_operations_2_GraphicsView_Demo ) +project(Boolean_set_operations_2_GraphicsView_Demo) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) endif() -find_package(CGAL COMPONENTS Qt5 Core ) +find_package(CGAL COMPONENTS Qt5 Core) -set( QT_USE_QTMAIN TRUE ) +set(QT_USE_QTMAIN TRUE) find_package(Qt5 QUIET COMPONENTS Widgets Script Svg) -include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include ) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include) -if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND CGAL_Core_FOUND ) -set(CMAKE_AUTOMOC ON) +if(CGAL_Qt5_FOUND + AND Qt5_FOUND + AND CGAL_Core_FOUND) + set(CMAKE_AUTOMOC ON) # UI files (Qt Designer files) - qt5_wrap_ui( CDT_UI_FILES boolean_operations_2.ui ) + qt5_wrap_ui(CDT_UI_FILES boolean_operations_2.ui) # qrc files (resources files, that contain icons, at least) - qt5_add_resources ( CGAL_Qt5_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/boolean_operations_2.qrc ) + qt5_add_resources(CGAL_Qt5_RESOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/boolean_operations_2.qrc) # use the Qt MOC preprocessor on classes that derives from QObject - # The executable itself. - add_executable ( boolean_operations_2 ${CMAKE_CURRENT_SOURCE_DIR}/boolean_operations_2.cpp ${CGAL_Qt5_MOC_FILES} ${CDT_UI_FILES} ${CGAL_Qt5_RESOURCE_FILES} ) + add_executable( + boolean_operations_2 + ${CMAKE_CURRENT_SOURCE_DIR}/boolean_operations_2.cpp ${CGAL_Qt5_MOC_FILES} + ${CDT_UI_FILES} ${CGAL_Qt5_RESOURCE_FILES}) # Link with Qt libraries - target_link_libraries( boolean_operations_2 Qt5::Widgets Qt5::Script Qt5::Svg ) + target_link_libraries(boolean_operations_2 Qt5::Widgets Qt5::Script Qt5::Svg) # Link with CGAL - target_link_libraries( boolean_operations_2 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}) + target_link_libraries(boolean_operations_2 ${CGAL_LIBRARIES} + ${CGAL_3RD_PARTY_LIBRARIES}) else() - message(STATUS "NOTICE: This demo requires CGAL and Qt5, and will not be compiled.") + message( + STATUS "NOTICE: This demo requires CGAL and Qt5, and will not be compiled.") endif() diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt b/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt index f3a59f95641..38c8d696c74 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt @@ -1,26 +1,18 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Boolean_set_operations_2_Examples ) +project(Boolean_set_operations_2_Examples) +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core) - -if ( CGAL_FOUND ) - - include(${CGAL_USE_FILE}) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() +include(${CGAL_USE_FILE}) +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h index 833f9afd571..0da7fcd55f3 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h @@ -52,7 +52,7 @@ public: typedef Polygon_ Polygon; - typedef typename Polygon::Edge_const_iterator Edge_const_iterator; + typedef typename Polygon::Vertex_pair_iterator Edge_const_iterator; typedef typename Edge_const_iterator::difference_type difference_type; private: @@ -78,7 +78,7 @@ public: X_monotone_curve_2 operator*() { - return X_monotone_curve_2(*m_curr_edge); + return X_monotone_curve_2(m_curr_edge->first, m_curr_edge->second); } Polygon_2_curve_ptr operator->() diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index af6aa17c22e..3704f08aa67 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -103,8 +103,8 @@ public: std::pair operator()(const General_polygon_2& pgn) const { - Curve_const_iterator c_begin(&pgn, pgn.edges_begin()); - Curve_const_iterator c_end(&pgn, pgn.edges_end()); + Curve_const_iterator c_begin(&pgn, pgn.vertex_pairs_begin()); + Curve_const_iterator c_end(&pgn, pgn.vertex_pairs_end()); return (std::make_pair(c_begin, c_end)); } diff --git a/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt b/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt index f346e2183ec..166a39cef9a 100644 --- a/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt +++ b/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Boolean_set_operations_2_Tests ) +project(Boolean_set_operations_2_Tests) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt b/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt index 9c066bd6cf4..08e699ac285 100644 --- a/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt @@ -1,31 +1,25 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Approximate_min_ellipsoid_d_Examples ) +project(Approximate_min_ellipsoid_d_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) +# Use Eigen +find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) +include(CGAL_Eigen_support) -if ( CGAL_FOUND ) - - # Use Eigen - find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) - include(CGAL_Eigen_support) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - if(NOT (${cppfile} STREQUAL "ellipsoid.cpp") OR TARGET CGAL::Eigen_support) - get_filename_component(target ${cppfile} NAME_WE) - add_executable(${target} ${cppfile}) - if (TARGET CGAL::Eigen_support) - target_link_libraries(${target} CGAL::CGAL CGAL::Eigen_support) - else() - target_link_libraries(${target} CGAL::CGAL) - endif() +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + if(NOT (${cppfile} STREQUAL "ellipsoid.cpp") OR TARGET CGAL::Eigen_support) + get_filename_component(target ${cppfile} NAME_WE) + add_executable(${target} ${cppfile}) + if(TARGET CGAL::Eigen_support) + target_link_libraries(${target} CGAL::CGAL CGAL::Eigen_support) + else() + target_link_libraries(${target} CGAL::CGAL) endif() - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() + endif() +endforeach() diff --git a/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt b/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt index d6c37a90755..ad8fe4ddf0b 100644 --- a/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_annulus_d_Examples ) +project(Min_annulus_d_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt b/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt index 5de341bd9de..2ff0b1cff21 100644 --- a/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_circle_2_Examples ) +project(Min_circle_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt b/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt index 2cd8f3660b5..6d361aa34df 100644 --- a/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_ellipse_2_Examples ) +project(Min_ellipse_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt b/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt index ff63e20a54e..c953eb3cd15 100644 --- a/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_quadrilateral_2_Examples ) +project(Min_quadrilateral_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt b/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt index d6192ef5da1..bbf53300d8c 100644 --- a/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_sphere_d_Examples ) +project(Min_sphere_d_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt b/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt index 1e04215d3b6..de68529c5cd 100644 --- a/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Min_sphere_of_spheres_d_Examples ) +project(Min_sphere_of_spheres_d_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt b/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt index 52756958264..0e43e5b4e8b 100644 --- a/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt @@ -1,20 +1,13 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Rectangular_p_center_2_Examples ) +project(Rectangular_p_center_2_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt b/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt index 5a29e19f887..54875af2ee2 100644 --- a/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt +++ b/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt @@ -1,37 +1,31 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Bounding_volumes_Tests ) +project(Bounding_volumes_Tests) +find_package(CGAL REQUIRED COMPONENTS Core) -find_package(CGAL QUIET COMPONENTS Core ) +include(${CGAL_USE_FILE}) -if ( CGAL_FOUND ) +# Use Eigen +find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) +include(CGAL_Eigen_support) - include(${CGAL_USE_FILE}) - - # Use Eigen - find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) - include(CGAL_Eigen_support) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - if(NOT (${cppfile} STREQUAL "Approximate_min_ellipsoid_d.cpp") OR TARGET CGAL::Eigen_support) - get_filename_component(target ${cppfile} NAME_WE) - add_executable(${target} ${cppfile}) - if (TARGET CGAL::Eigen_support) - target_link_libraries(${target} CGAL::CGAL CGAL::Eigen_support) - else() - target_link_libraries(${target} CGAL::CGAL) - endif() +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + if(NOT (${cppfile} STREQUAL "Approximate_min_ellipsoid_d.cpp") + OR TARGET CGAL::Eigen_support) + get_filename_component(target ${cppfile} NAME_WE) + add_executable(${target} ${cppfile}) + if(TARGET CGAL::Eigen_support) + target_link_libraries(${target} CGAL::CGAL CGAL::Eigen_support) + else() + target_link_libraries(${target} CGAL::CGAL) endif() - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() + endif() +endforeach() diff --git a/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt b/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt index 6b17fe83e29..8c14f8e3813 100644 --- a/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt +++ b/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt @@ -1,24 +1,16 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Box_intersection_d_Examples ) +project(Box_intersection_d_Examples) +find_package(CGAL REQUIRED) -find_package(CGAL QUIET) - -if ( CGAL_FOUND ) - - # create a target per cppfile - file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) - endforeach() - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() - +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt b/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt index de7955c4208..5d214d0151d 100644 --- a/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt +++ b/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt @@ -1,27 +1,22 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. - cmake_minimum_required(VERSION 3.1...3.15) -project( Box_intersection_d_Tests ) +project(Box_intersection_d_Tests) -find_package( CGAL QUIET ) +find_package(CGAL REQUIRED) -find_package( TBB ) +find_package(TBB) include(CGAL_TBB_support) -if ( CGAL_FOUND ) +create_single_source_cgal_program("automated_test.cpp") +create_single_source_cgal_program("benchmark_box_intersection.cpp") +create_single_source_cgal_program("random_set_test.cpp") +create_single_source_cgal_program("test_box_grid.cpp") - create_single_source_cgal_program( "automated_test.cpp" ) - create_single_source_cgal_program( "benchmark_box_intersection.cpp" ) - create_single_source_cgal_program( "random_set_test.cpp" ) - create_single_source_cgal_program( "test_box_grid.cpp" ) - - if(TARGET CGAL::TBB_support) - target_link_libraries(test_box_grid PUBLIC CGAL::TBB_support) - else() - message( STATUS "NOTICE: Intel TBB was not found. Sequential code will be used." ) - endif() +if(TARGET CGAL::TBB_support) + target_link_libraries(test_box_grid PUBLIC CGAL::TBB_support) else() - message(STATUS "This program requires the CGAL library, and will not be compiled.") + message( + STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.") endif() diff --git a/CGAL_Core/examples/Core/CMakeLists.txt b/CGAL_Core/examples/Core/CMakeLists.txt index 1ff71a69b29..96bf8fcbfde 100644 --- a/CGAL_Core/examples/Core/CMakeLists.txt +++ b/CGAL_Core/examples/Core/CMakeLists.txt @@ -1,26 +1,25 @@ cmake_minimum_required(VERSION 3.1...3.15) -project( Core_Examples ) - - - - +project(Core_Examples) # CGAL and its components -find_package( CGAL QUIET COMPONENTS Core ) +find_package(CGAL REQUIRED COMPONENTS Core) -if ( NOT CGAL_Core_FOUND ) +if(NOT CGAL_Core_FOUND) - message(STATUS "This project requires the CGAL_Core library, and will not be compiled.") + message( + STATUS + "This project requires the CGAL_Core library, and will not be compiled.") return() endif() # Boost and its components -find_package( Boost ) +find_package(Boost) -if ( NOT Boost_FOUND ) +if(NOT Boost_FOUND) - message(STATUS "This project requires the Boost library, and will not be compiled.") + message( + STATUS "This project requires the Boost library, and will not be compiled.") return() @@ -34,4 +33,4 @@ include(${CGAL_USE_FILE}) # Creating entries for all .cpp/.C files with "main" routine # ########################################################## -create_single_source_cgal_program( "delaunay.cpp" ) +create_single_source_cgal_program("delaunay.cpp") diff --git a/CGAL_Core/src/CGAL_Core/CMakeLists.txt b/CGAL_Core/src/CGAL_Core/CMakeLists.txt index 0ce25c586ca..182b102f6b6 100644 --- a/CGAL_Core/src/CGAL_Core/CMakeLists.txt +++ b/CGAL_Core/src/CGAL_Core/CMakeLists.txt @@ -11,8 +11,7 @@ if(CGAL_Core_FOUND) set(keyword PUBLIC) endif() - CGAL_setup_CGAL_Core_dependencies(CGAL_Core ${keyword}) + cgal_setup_cgal_core_dependencies(CGAL_Core ${keyword}) message("libCGAL_Core is configured") endif() - diff --git a/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt b/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt index cebf419d28a..08e42e919b7 100644 --- a/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt +++ b/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt @@ -6,24 +6,21 @@ if(NOT POLICY CMP0070 AND POLICY CMP0053) cmake_policy(SET CMP0053 OLD) endif() - set(PACKAGE_ROOT ../..) # Add several CGAL packages to the include and link paths, # if they lie in ${PACKAGE_ROOT}/. -foreach(INC_DIR ${PACKAGE_ROOT}/include - ${PACKAGE_ROOT}/../CGAL_ImageIO/include ) +foreach(INC_DIR ${PACKAGE_ROOT}/include ${PACKAGE_ROOT}/../CGAL_ImageIO/include) if(EXISTS ${INC_DIR}) - include_directories (BEFORE ${INC_DIR}) + include_directories(BEFORE ${INC_DIR}) endif() endforeach() foreach(LIB_DIR ${PACKAGE_ROOT}/../CGAL_ImageIO/src/CGAL_ImageIO) - if (EXISTS ${LIB_DIR}) - link_directories (${LIB_DIR}) + if(EXISTS ${LIB_DIR}) + link_directories(${LIB_DIR}) endif() endforeach() - find_package(CGAL REQUIRED ImageIO) find_package(VTK QUIET NO_MODULE) @@ -35,19 +32,24 @@ if(VTK_FOUND) include(${VTK_USE_FILE}) find_package(Qt${VTK_QT_VERSION} COMPONENTS QtGui) if(NOT TARGET Qt${VTK_QT_VERSION}::QtGui) - message(STATUS "NOTICE: vtkRenderingQt needs Qt${VTK_QT_VERSION}, and will not be compiled.") + message( + STATUS + "NOTICE: vtkRenderingQt needs Qt${VTK_QT_VERSION}, and will not be compiled." + ) return() endif() - add_executable( image_to_vtk_viewer image_to_vtk_viewer.cpp ) - add_to_cached_list( CGAL_EXECUTABLE_TARGETS image_to_vtk_viewer ) + add_executable(image_to_vtk_viewer image_to_vtk_viewer.cpp) + add_to_cached_list(CGAL_EXECUTABLE_TARGETS image_to_vtk_viewer) - target_link_libraries( image_to_vtk_viewer - ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} - ${VTK_LIBRARIES} Qt${VTK_QT_VERSION}::QtGui - ) + target_link_libraries( + image_to_vtk_viewer ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} + ${VTK_LIBRARIES} Qt${VTK_QT_VERSION}::QtGui) else() - message(STATUS "NOTICE: This demo needs vtkRenderingQt and vtkFiltersModeling, and will not be compiled.") + message( + STATUS + "NOTICE: This demo needs vtkRenderingQt and vtkFiltersModeling, and will not be compiled." + ) endif() else() message(STATUS "NOTICE: This demo needs VTK, and will not be compiled.") diff --git a/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt b/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt index 06327048deb..388320a6938 100644 --- a/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt +++ b/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt @@ -2,21 +2,23 @@ # This is the CMake script for compiling a CGAL application. cmake_minimum_required(VERSION 3.1...3.15) -project( CGALimageIO_Examples ) - +project(CGALimageIO_Examples) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() -find_package(CGAL QUIET COMPONENTS ImageIO ) +find_package(CGAL REQUIRED COMPONENTS ImageIO) if(CGAL_ImageIO_FOUND) include(${CGAL_USE_FILE}) - create_single_source_cgal_program( "convert_raw_image_to_inr.cpp" ) - create_single_source_cgal_program( "test_imageio.cpp" ) - create_single_source_cgal_program( "extract_a_sub_image.cpp" ) + create_single_source_cgal_program("convert_raw_image_to_inr.cpp") + create_single_source_cgal_program("test_imageio.cpp") + create_single_source_cgal_program("extract_a_sub_image.cpp") else() - message(STATUS "NOTICE: This demo needs the CGAL ImageIO library, and will not be compiled.") + message( + STATUS + "NOTICE: This demo needs the CGAL ImageIO library, and will not be compiled." + ) endif() diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h index 1154d6b361a..1c326b6fa1f 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h @@ -33,17 +33,18 @@ /** Magic header for ANALYZE files written in big endian format */ #define ANALYZE_BE_MAGIC "\134\001\000\000" -#define DT_NONE 0 -#define DT_UNKNOWN 0 /*Unknown data type*/ -#define DT_BINARY 1 /*Binary (1 bit per voxel)*/ -#define DT_UNSIGNED_CHAR 2 /*Unsigned character (8 bits per voxel)*/ -#define DT_SIGNED_SHORT 4 /*Signed short (16 bits per voxel)*/ -#define DT_SIGNED_INT 8 /*Signed integer (32 bits per voxel)*/ -#define DT_FLOAT 16 /*Floating point (32 bits per voxel)*/ -#define DT_COMPLEX 32 /*Complex (64 bits per voxel; 2 floating point numbers) */ -#define DT_DOUBLE 64 /*Double precision (64 bits per voxel)*/ -#define DT_RGB 128 /* */ -#define DT_ALL 255 /* */ +//use prefix CGAL_analyze_impl_ to avoid clashing and breaking dirent.h +#define CGAL_analyze_impl_DT_NONE 0 +#define CGAL_analyze_impl_DT_UNKNOWN 0 /*Unknown data type*/ +#define CGAL_analyze_impl_DT_BINARY 1 /*Binary (1 bit per voxel)*/ +#define CGAL_analyze_impl_DT_UNSIGNED_CHAR 2 /*Unsigned character (8 bits per voxel)*/ +#define CGAL_analyze_impl_DT_SIGNED_SHORT 4 /*Signed short (16 bits per voxel)*/ +#define CGAL_analyze_impl_DT_SIGNED_INT 8 /*Signed integer (32 bits per voxel)*/ +#define CGAL_analyze_impl_DT_FLOAT 16 /*Floating point (32 bits per voxel)*/ +#define CGAL_analyze_impl_DT_COMPLEX 32 /*Complex (64 bits per voxel; 2 floating point numbers) */ +#define CGAL_analyze_impl_DT_DOUBLE 64 /*Double precision (64 bits per voxel)*/ +#define CGAL_analyze_impl_DT_RGB 128 /* */ +#define CGAL_analyze_impl_DT_ALL 255 /* */ #include @@ -373,17 +374,17 @@ int _readAnalyzeHeader( _image* im, const char* name, switch(analyzeHeader->dime.datatype) { - case DT_BINARY: - case DT_UNSIGNED_CHAR: - case DT_SIGNED_SHORT: - case DT_SIGNED_INT: - case DT_FLOAT: - case DT_COMPLEX: - case DT_DOUBLE: + case CGAL_analyze_impl_DT_BINARY: + case CGAL_analyze_impl_DT_UNSIGNED_CHAR: + case CGAL_analyze_impl_DT_SIGNED_SHORT: + case CGAL_analyze_impl_DT_SIGNED_INT: + case CGAL_analyze_impl_DT_FLOAT: + case CGAL_analyze_impl_DT_COMPLEX: + case CGAL_analyze_impl_DT_DOUBLE: im->vdim = 1; break ; - case DT_RGB: + case CGAL_analyze_impl_DT_RGB: im->vdim = 3; break ; @@ -396,17 +397,17 @@ int _readAnalyzeHeader( _image* im, const char* name, switch(analyzeHeader->dime.datatype) { - case DT_BINARY: - case DT_UNSIGNED_CHAR: - case DT_SIGNED_SHORT: - case DT_SIGNED_INT: - case DT_RGB: + case CGAL_analyze_impl_DT_BINARY: + case CGAL_analyze_impl_DT_UNSIGNED_CHAR: + case CGAL_analyze_impl_DT_SIGNED_SHORT: + case CGAL_analyze_impl_DT_SIGNED_INT: + case CGAL_analyze_impl_DT_RGB: im->wordKind = WK_FIXED; break ; - case DT_FLOAT: - case DT_COMPLEX: - case DT_DOUBLE: + case CGAL_analyze_impl_DT_FLOAT: + case CGAL_analyze_impl_DT_COMPLEX: + case CGAL_analyze_impl_DT_DOUBLE: im->wordKind = WK_FLOAT; break ; @@ -419,17 +420,17 @@ int _readAnalyzeHeader( _image* im, const char* name, switch(analyzeHeader->dime.datatype) { - case DT_BINARY: - case DT_UNSIGNED_CHAR: - case DT_RGB: + case CGAL_analyze_impl_DT_BINARY: + case CGAL_analyze_impl_DT_UNSIGNED_CHAR: + case CGAL_analyze_impl_DT_RGB: im->sign = SGN_UNSIGNED; break ; - case DT_SIGNED_SHORT: - case DT_SIGNED_INT: - case DT_FLOAT: - case DT_COMPLEX: - case DT_DOUBLE: + case CGAL_analyze_impl_DT_SIGNED_SHORT: + case CGAL_analyze_impl_DT_SIGNED_INT: + case CGAL_analyze_impl_DT_FLOAT: + case CGAL_analyze_impl_DT_COMPLEX: + case CGAL_analyze_impl_DT_DOUBLE: im->sign = SGN_SIGNED; break ; @@ -441,7 +442,7 @@ int _readAnalyzeHeader( _image* im, const char* name, } im->wdim = analyzeHeader->dime.bitpix; - if( analyzeHeader->dime.datatype == DT_RGB ) + if( analyzeHeader->dime.datatype == CGAL_analyze_impl_DT_RGB ) { im->wdim /= 3 ; } @@ -612,10 +613,10 @@ writeAnalyzeHeader( const _image* im ) if( im->wdim == 1 ) { if ( im->vdim == 1 ) { - hdr.dime.datatype = DT_UNSIGNED_CHAR ; + hdr.dime.datatype = CGAL_analyze_impl_DT_UNSIGNED_CHAR ; } else if ( im->vdim == 3 ) { - hdr.dime.datatype = DT_RGB ; + hdr.dime.datatype = CGAL_analyze_impl_DT_RGB ; } else { fprintf( stderr, "%s: unsupported image type\n", proc ); @@ -643,7 +644,7 @@ writeAnalyzeHeader( const _image* im ) if ( imin > *buf ) imin = *buf; } if ( imax < 32768 ) { - hdr.dime.datatype = DT_SIGNED_SHORT ; + hdr.dime.datatype = CGAL_analyze_impl_DT_SIGNED_SHORT ; } else { fprintf( stderr, "%s: conversion from unsigned short to short impossible, max=%d\n", proc, imax ); @@ -676,7 +677,7 @@ writeAnalyzeHeader( const _image* im ) if ( imax < *buf ) imax = *buf; if ( imin > *buf ) imin = *buf; } - hdr.dime.datatype = DT_SIGNED_SHORT ; + hdr.dime.datatype = CGAL_analyze_impl_DT_SIGNED_SHORT ; } else if( im->wdim == 4 ) { int *buf = (int*)im->data; @@ -686,7 +687,7 @@ writeAnalyzeHeader( const _image* im ) if ( imax < *buf ) imax = *buf; if ( imin > *buf ) imin = *buf; } - hdr.dime.datatype = DT_SIGNED_INT ; + hdr.dime.datatype = CGAL_analyze_impl_DT_SIGNED_INT ; } else { fprintf( stderr, "%s: unsupported image type\n", proc ); @@ -699,10 +700,10 @@ writeAnalyzeHeader( const _image* im ) return -1; } if( im->wdim == 4 ) { - hdr.dime.datatype = DT_FLOAT ; + hdr.dime.datatype = CGAL_analyze_impl_DT_FLOAT ; } else if( im->wdim == 8 ) { - hdr.dime.datatype = DT_DOUBLE ; + hdr.dime.datatype = CGAL_analyze_impl_DT_DOUBLE ; } else { fprintf( stderr, "%s: unsupported image type\n", proc ); diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/gif_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/gif_impl.h index 61cdcd701b3..119b6e2d515 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/gif_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/gif_impl.h @@ -60,7 +60,7 @@ typedef unsigned char byte; #define COLORMAPMASK 0x80 -#define DEBUG 0 +#define CGAL_GIF_IMPL_DEBUG 0 //FILE *fp; //int gif89 = 0; @@ -219,7 +219,7 @@ int gif89 = 0; if (aspect) { if (!gif89) return(GifError("corrupt GIF file (screen descriptor)")); else normaspect = (float) (aspect + 15) / 64.0f; /* gif89 aspect ratio */ - if (DEBUG) fprintf(stderr,"GIF89 aspect = %f\n", normaspect); + if (CGAL_GIF_IMPL_DEBUG) fprintf(stderr,"GIF89 aspect = %f\n", normaspect); } @@ -268,7 +268,7 @@ int gif89 = 0; /* read extension block */ fn = NEXTBYTE; - if (DEBUG) fprintf(stderr,"GIF extension type 0x%02x\n", fn); + if (CGAL_GIF_IMPL_DEBUG) fprintf(stderr,"GIF extension type 0x%02x\n", fn); if (fn == 'R') { /* GIF87 aspect extension */ blocksize = NEXTBYTE; @@ -279,7 +279,7 @@ int gif89 = 0; normaspect = (float) aspnum / (float) aspden; else { normaspect = 1.0; aspnum = aspden = 1; } - if (DEBUG) fprintf(stderr,"GIF87 aspect extension: %d:%d = %f\n\n", + if (CGAL_GIF_IMPL_DEBUG) fprintf(stderr,"GIF87 aspect extension: %d:%d = %f\n\n", aspnum, aspden,normaspect); } else { @@ -290,16 +290,16 @@ int gif89 = 0; else if (fn == 0xFE) { /* Comment Extension. just eat it */ int ch, j, sbsize; - if (DEBUG) fprintf(stderr,"Comment extension: "); + if (CGAL_GIF_IMPL_DEBUG) fprintf(stderr,"Comment extension: "); /* read (and ignore) data sub-blocks */ do { j = 0; sbsize = NEXTBYTE; while (j #include #include +#include #include -typedef CGAL::Parallel_if_available_tag Concurrency_tag; - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef Kernel::Iso_cuboid_3 Iso_cuboid_3; @@ -84,9 +83,7 @@ int main (int argc, char** argv) std::cerr << "Computing features" << std::endl; Feature_set features; -#ifdef CGAL_LINKED_WITH_TBB - features.begin_parallel_additions(); -#endif + features.begin_parallel_additions(); // No effect in sequential mode Feature_handle distance_to_plane = features.add (pts, Pmap(), eigen); Feature_handle dispersion = features.add (pts, Pmap(), grid, @@ -94,9 +91,7 @@ int main (int argc, char** argv) Feature_handle elevation = features.add (pts, Pmap(), grid, radius_dtm); -#ifdef CGAL_LINKED_WITH_TBB - features.end_parallel_additions(); -#endif + features.end_parallel_additions(); // No effect in sequential mode //! [Features] /////////////////////////////////////////////////////////////////// @@ -105,9 +100,15 @@ int main (int argc, char** argv) //! [Labels] Label_set labels; + + // Init name only Label_handle ground = labels.add ("ground"); - Label_handle vegetation = labels.add ("vegetation"); - Label_handle roof = labels.add ("roof"); + + // Init name and color + Label_handle vegetation = labels.add ("vegetation", CGAL::Color(0,255,0)); + + // Init name, Color and standard index (here, ASPRS building index) + Label_handle roof = labels.add ("roof", CGAL::Color (255, 0, 0), 6); //! [Labels] /////////////////////////////////////////////////////////////////// @@ -146,7 +147,7 @@ int main (int argc, char** argv) CGAL::Real_timer t; t.start(); - Classification::classify (pts, labels, classifier, label_indices); + Classification::classify (pts, labels, classifier, label_indices); t.stop(); std::cerr << "Raw classification performed in " << t.time() << " second(s)" << std::endl; t.reset(); @@ -156,7 +157,7 @@ int main (int argc, char** argv) /////////////////////////////////////////////////////////////////// //! [Smoothing] t.start(); - Classification::classify_with_local_smoothing + Classification::classify_with_local_smoothing (pts, Pmap(), labels, classifier, neighborhood.sphere_neighbor_query(radius_neighbors), label_indices); @@ -169,7 +170,7 @@ int main (int argc, char** argv) /////////////////////////////////////////////////////////////////// //! [Graph_cut] t.start(); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (pts, Pmap(), labels, classifier, neighborhood.k_neighbor_query(12), 0.2f, 4, label_indices); @@ -180,36 +181,43 @@ int main (int argc, char** argv) // Save the output in a colored PLY format - std::ofstream f ("classification.ply"); - f << "ply" << std::endl - << "format ascii 1.0" << std::endl - << "element vertex " << pts.size() << std::endl - << "property float x" << std::endl - << "property float y" << std::endl - << "property float z" << std::endl - << "property uchar red" << std::endl - << "property uchar green" << std::endl - << "property uchar blue" << std::endl - << "end_header" << std::endl; + std::vector red, green, blue; + red.reserve(pts.size()); + green.reserve(pts.size()); + blue.reserve(pts.size()); for (std::size_t i = 0; i < pts.size(); ++ i) { - f << pts[i] << " "; - Label_handle label = labels[std::size_t(label_indices[i])]; + unsigned r = 0, g = 0, b = 0; if (label == ground) - f << "245 180 0" << std::endl; - else if (label == vegetation) - f << "0 255 27" << std::endl; - else if (label == roof) - f << "255 0 170" << std::endl; - else { - f << "0 0 0" << std::endl; - std::cerr << "Error: unknown classification label" << std::endl; + r = 245; g = 180; b = 0; } + else if (label == vegetation) + { + r = 0; g = 255; b = 27; + } + else if (label == roof) + { + r = 255; g = 0; b = 170; + } + red.push_back(r); + green.push_back(g); + blue.push_back(b); } + std::ofstream f ("classification.ply"); + + CGAL::write_ply_points_with_properties + (f, CGAL::make_range (boost::counting_iterator(0), + boost::counting_iterator(pts.size())), + CGAL::make_ply_point_writer (CGAL::make_property_map(pts)), + std::make_pair(CGAL::make_property_map(red), CGAL::PLY_property("red")), + std::make_pair(CGAL::make_property_map(green), CGAL::PLY_property("green")), + std::make_pair(CGAL::make_property_map(blue), CGAL::PLY_property("blue"))); + + std::cerr << "All done" << std::endl; return EXIT_SUCCESS; } diff --git a/Classification/examples/Classification/example_cluster_classification.cpp b/Classification/examples/Classification/example_cluster_classification.cpp index 3c4b08f60e6..1573a0fc1ad 100644 --- a/Classification/examples/Classification/example_cluster_classification.cpp +++ b/Classification/examples/Classification/example_cluster_classification.cpp @@ -18,8 +18,6 @@ #include #include -typedef CGAL::Parallel_if_available_tag Concurrency_tag; - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef Kernel::Iso_cuboid_3 Iso_cuboid_3; @@ -37,6 +35,7 @@ typedef CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region Region_growing; namespace Classification = CGAL::Classification; +namespace Feature = CGAL::Classification::Feature; typedef Classification::Label_handle Label_handle; typedef Classification::Feature_handle Feature_handle; @@ -50,7 +49,7 @@ typedef Classification::Cluster Clu int main (int argc, char** argv) { std::string filename = "data/b9.ply"; - std::string filename_config = "data/b9_clusters_config.gz"; + std::string filename_config = "data/b9_clusters_config.bin"; if (argc > 1) filename = argv[1]; @@ -67,7 +66,7 @@ int main (int argc, char** argv) CGAL::Real_timer t; t.start(); pts.add_normal_map(); - CGAL::jet_estimate_normals (pts, 12); + CGAL::jet_estimate_normals (pts, 12); t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; t.reset(); @@ -151,50 +150,38 @@ int main (int argc, char** argv) Feature_set features; -#ifdef CGAL_LINKED_WITH_TBB - features.begin_parallel_additions(); -#endif - // First, compute means of features. - for (std::size_t i = 0; i < pointwise_features.size(); ++ i) - features.add (clusters, pointwise_features[i]); - -#ifdef CGAL_LINKED_WITH_TBB - features.end_parallel_additions(); features.begin_parallel_additions(); -#endif + for (Feature_handle fh : pointwise_features) + features.add (clusters, fh); + features.end_parallel_additions(); // Then, compute variances of features (and remaining cluster features). + features.begin_parallel_additions(); for (std::size_t i = 0; i < pointwise_features.size(); ++ i) - features.add (clusters, - pointwise_features[i], // i^th feature - features[i]); // mean of i^th feature + features.add (clusters, + pointwise_features[i], // i^th feature + features[i]); // mean of i^th feature - features.add (clusters); - features.add (clusters); + features.add (clusters); + features.add (clusters); for (std::size_t i = 0; i < 3; ++ i) - features.add (clusters, eigen, (unsigned int)(i)); + features.add (clusters, eigen, (unsigned int)(i)); -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif //! [Features] /////////////////////////////////////////////////////////////////// t.stop(); - // Add types. - Label_set labels; - Label_handle ground = labels.add ("ground"); - Label_handle vegetation = labels.add ("vegetation"); - Label_handle roof = labels.add ("roof"); + Label_set labels = { "ground", "vegetation", "roof" }; std::vector label_indices(clusters.size(), -1); std::cerr << "Using ETHZ Random Forest Classifier" << std::endl; - Classification::ETHZ_random_forest_classifier classifier (labels, features); + Classification::ETHZ::Random_forest_classifier classifier (labels, features); std::cerr << "Loading configuration" << std::endl; std::ifstream in_config (filename_config, std::ios_base::in | std::ios_base::binary); @@ -203,7 +190,7 @@ int main (int argc, char** argv) std::cerr << "Classifying" << std::endl; t.reset(); t.start(); - Classification::classify (clusters, labels, classifier, label_indices); + Classification::classify (clusters, labels, classifier, label_indices); t.stop(); std::cerr << "Classification done in " << t.time() << " second(s)" << std::endl; diff --git a/Classification/examples/Classification/example_deprecated_conversion.cpp b/Classification/examples/Classification/example_deprecated_conversion.cpp new file mode 100644 index 00000000000..d63080d93af --- /dev/null +++ b/Classification/examples/Classification/example_deprecated_conversion.cpp @@ -0,0 +1,20 @@ +#include + +#include +#include + +int main (int argc, char** argv) +{ + if (argc != 3) + std::cerr << "Usage: " << argv[0] << " input.gz output.bin" << std::endl; + else + { + std::ifstream ifile (argv[1], std::ios_base::binary); + std::ofstream ofile (argv[2], std::ios_base::binary); + + CGAL::Classification::ETHZ::Random_forest_classifier:: + convert_deprecated_configuration_to_new_format(ifile, ofile); + } + + return EXIT_SUCCESS; +} diff --git a/Classification/examples/Classification/example_ethz_random_forest.cpp b/Classification/examples/Classification/example_ethz_random_forest.cpp index bfacdd4e047..b0333f58ec4 100644 --- a/Classification/examples/Classification/example_ethz_random_forest.cpp +++ b/Classification/examples/Classification/example_ethz_random_forest.cpp @@ -49,18 +49,13 @@ int main (int argc, char** argv) Imap label_map; bool lm_found = false; - boost::tie (label_map, lm_found) = pts.property_map ("label"); + std::tie (label_map, lm_found) = pts.property_map ("label"); if (!lm_found) { std::cerr << "Error: \"label\" property not found in input file." << std::endl; return EXIT_FAILURE; } - std::vector ground_truth; - ground_truth.reserve (pts.size()); - std::copy (pts.range(label_map).begin(), pts.range(label_map).end(), - std::back_inserter (ground_truth)); - Feature_set features; std::cerr << "Generating features" << std::endl; @@ -69,25 +64,23 @@ int main (int argc, char** argv) Feature_generator generator (pts, pts.point_map(), 5); // using 5 scales -#ifdef CGAL_LINKED_WITH_TBB features.begin_parallel_additions(); -#endif - generator.generate_point_based_features (features); - -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - // Add types + // Add labels Label_set labels; Label_handle ground = labels.add ("ground"); Label_handle vegetation = labels.add ("vegetation"); Label_handle roof = labels.add ("roof"); + // Check if ground truth is valid for this label set + if (!labels.is_valid_ground_truth (pts.range(label_map), true)) + return EXIT_FAILURE; + std::vector label_indices(pts.size(), -1); std::cerr << "Using ETHZ Random Forest Classifier" << std::endl; @@ -96,13 +89,13 @@ int main (int argc, char** argv) std::cerr << "Training" << std::endl; t.reset(); t.start(); - classifier.train (ground_truth); + classifier.train (pts.range(label_map)); t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; t.reset(); t.start(); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (pts, pts.point_map(), labels, classifier, generator.neighborhood().k_neighbor_query(12), 0.2f, 1, label_indices); @@ -111,15 +104,15 @@ int main (int argc, char** argv) std::cerr << "Classification with graphcut done in " << t.time() << " second(s)" << std::endl; std::cerr << "Precision, recall, F1 scores and IoU:" << std::endl; - Classification::Evaluation evaluation (labels, ground_truth, label_indices); + Classification::Evaluation evaluation (labels, pts.range(label_map), label_indices); - for (std::size_t i = 0; i < labels.size(); ++ i) + for (Label_handle l : labels) { - std::cerr << " * " << labels[i]->name() << ": " - << evaluation.precision(labels[i]) << " ; " - << evaluation.recall(labels[i]) << " ; " - << evaluation.f1_score(labels[i]) << " ; " - << evaluation.intersection_over_union(labels[i]) << std::endl; + std::cerr << " * " << l->name() << ": " + << evaluation.precision(l) << " ; " + << evaluation.recall(l) << " ; " + << evaluation.f1_score(l) << " ; " + << evaluation.intersection_over_union(l) << std::endl; } std::cerr << "Accuracy = " << evaluation.accuracy() << std::endl @@ -136,21 +129,16 @@ int main (int argc, char** argv) label_map[i] = label_indices[i]; // update label map with computed classification Label_handle label = labels[label_indices[i]]; - - if (label == ground) - { - red[i] = 245; green[i] = 180; blue[i] = 0; - } - else if (label == vegetation) - { - red[i] = 0; green[i] = 255; blue[i] = 27; - } - else if (label == roof) - { - red[i] = 255; green[i] = 0; blue[i] = 170; - } + const CGAL::Color& color = label->color(); + red[i] = color.red(); + green[i] = color.green(); + blue[i] = color.blue(); } + // Save configuration for later use + std::ofstream fconfig ("ethz_random_forest.bin", std::ios_base::binary); + classifier.save_configuration(fconfig); + // Write result std::ofstream f ("classification.ply"); f.precision(18); diff --git a/Classification/examples/Classification/example_feature.cpp b/Classification/examples/Classification/example_feature.cpp index 4f77c18d941..68128ba08e8 100644 --- a/Classification/examples/Classification/example_feature.cpp +++ b/Classification/examples/Classification/example_feature.cpp @@ -115,7 +115,7 @@ int main (int argc, char** argv) std::cerr << "Classifying" << std::endl; std::vector label_indices(pts.size(), -1); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (pts, Pmap(), labels, classifier, neighborhood.k_neighbor_query(12), 0.5, 1, label_indices); diff --git a/Classification/examples/Classification/example_generation_and_training.cpp b/Classification/examples/Classification/example_generation_and_training.cpp index 2a34076ef77..cb911262b32 100644 --- a/Classification/examples/Classification/example_generation_and_training.cpp +++ b/Classification/examples/Classification/example_generation_and_training.cpp @@ -46,18 +46,13 @@ int main (int argc, char** argv) Imap label_map; bool lm_found = false; - boost::tie (label_map, lm_found) = pts.property_map ("label"); + std::tie (label_map, lm_found) = pts.property_map ("label"); if (!lm_found) { std::cerr << "Error: \"label\" property not found in input file." << std::endl; return EXIT_FAILURE; } - std::vector ground_truth; - ground_truth.reserve (pts.size()); - std::copy (pts.range(label_map).begin(), pts.range(label_map).end(), - std::back_inserter (ground_truth)); - std::cerr << "Generating features" << std::endl; CGAL::Real_timer t; t.start(); @@ -70,15 +65,9 @@ int main (int argc, char** argv) std::size_t number_of_scales = 5; Feature_generator generator (pts, pts.point_map(), number_of_scales); -#ifdef CGAL_LINKED_WITH_TBB features.begin_parallel_additions(); -#endif - generator.generate_point_based_features (features); - -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif //! [Generator] /////////////////////////////////////////////////////////////////// @@ -86,25 +75,21 @@ int main (int argc, char** argv) t.stop(); std::cerr << features.size() << " feature(s) generated in " << t.time() << " second(s)" << std::endl; - // Add types - Label_set labels; - Label_handle ground = labels.add ("ground"); - Label_handle vegetation = labels.add ("vegetation"); - Label_handle roof = labels.add ("roof"); + Label_set labels = { "ground", "vegetation", "roof" }; Classifier classifier (labels, features); std::cerr << "Training" << std::endl; t.reset(); t.start(); - classifier.train (ground_truth, 800); + classifier.train (pts.range(label_map), 800); t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; t.reset(); t.start(); std::vector label_indices(pts.size(), -1); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (pts, pts.point_map(), labels, classifier, generator.neighborhood().k_neighbor_query(12), 0.2f, 10, label_indices); @@ -112,15 +97,15 @@ int main (int argc, char** argv) std::cerr << "Classification with graphcut done in " << t.time() << " second(s)" << std::endl; std::cerr << "Precision, recall, F1 scores and IoU:" << std::endl; - Classification::Evaluation evaluation (labels, ground_truth, label_indices); + Classification::Evaluation evaluation (labels, pts.range(label_map), label_indices); - for (std::size_t i = 0; i < labels.size(); ++ i) + for (Label_handle l : labels) { - std::cerr << " * " << labels[i]->name() << ": " - << evaluation.precision(labels[i]) << " ; " - << evaluation.recall(labels[i]) << " ; " - << evaluation.f1_score(labels[i]) << " ; " - << evaluation.intersection_over_union(labels[i]) << std::endl; + std::cerr << " * " << l->name() << ": " + << evaluation.precision(l) << " ; " + << evaluation.recall(l) << " ; " + << evaluation.f1_score(l) << " ; " + << evaluation.intersection_over_union(l) << std::endl; } std::cerr << "Accuracy = " << evaluation.accuracy() << std::endl diff --git a/Classification/examples/Classification/example_mesh_classification.cpp b/Classification/examples/Classification/example_mesh_classification.cpp index 465b3a4bfcd..1d081e869fa 100644 --- a/Classification/examples/Classification/example_mesh_classification.cpp +++ b/Classification/examples/Classification/example_mesh_classification.cpp @@ -32,7 +32,7 @@ typedef Classification::Mesh_feature_generator int main (int argc, char** argv) { std::string filename = "data/b9_mesh.off"; - std::string filename_config = "data/b9_mesh_config.gz"; + std::string filename_config = "data/b9_mesh_config.bin"; if (argc > 1) filename = argv[1]; @@ -59,16 +59,10 @@ int main (int argc, char** argv) std::size_t number_of_scales = 5; Feature_generator generator (mesh, face_point_map, number_of_scales); -#ifdef CGAL_LINKED_WITH_TBB features.begin_parallel_additions(); -#endif - generator.generate_point_based_features (features); // Features that consider the mesh as a point set generator.generate_face_based_features (features); // Features computed directly on mesh faces - -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif //! [Generator] /////////////////////////////////////////////////////////////////// @@ -76,11 +70,7 @@ int main (int argc, char** argv) t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - // Add types - Label_set labels; - Label_handle ground = labels.add ("ground"); - Label_handle vegetation = labels.add ("vegetation"); - Label_handle roof = labels.add ("roof"); + Label_set labels = { "ground", "vegetation", "roof" }; std::vector label_indices(mesh.number_of_faces(), -1); @@ -94,7 +84,7 @@ int main (int argc, char** argv) std::cerr << "Classifying with graphcut" << std::endl; t.reset(); t.start(); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (mesh.faces(), Face_with_bbox_map(&mesh), labels, classifier, generator.neighborhood().n_ring_neighbor_query(2), 0.2f, 1, label_indices); diff --git a/Classification/examples/Classification/example_opencv_random_forest.cpp b/Classification/examples/Classification/example_opencv_random_forest.cpp index e0cd90e51f0..2491e05d0a7 100644 --- a/Classification/examples/Classification/example_opencv_random_forest.cpp +++ b/Classification/examples/Classification/example_opencv_random_forest.cpp @@ -49,18 +49,13 @@ int main (int argc, char** argv) Imap label_map; bool lm_found = false; - boost::tie (label_map, lm_found) = pts.property_map ("label"); + std::tie (label_map, lm_found) = pts.property_map ("label"); if (!lm_found) { std::cerr << "Error: \"label\" property not found in input file." << std::endl; return EXIT_FAILURE; } - std::vector ground_truth; - ground_truth.reserve (pts.size()); - std::copy (pts.range(label_map).begin(), pts.range(label_map).end(), - std::back_inserter (ground_truth)); - Feature_set features; std::cerr << "Generating features" << std::endl; @@ -69,19 +64,14 @@ int main (int argc, char** argv) Feature_generator generator (pts, pts.point_map(), 5); // using 5 scales -#ifdef CGAL_LINKED_WITH_TBB features.begin_parallel_additions(); -#endif - generator.generate_point_based_features (features); -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - // Add types + // Add labels Label_set labels; Label_handle ground = labels.add ("ground"); Label_handle vegetation = labels.add ("vegetation"); @@ -95,13 +85,13 @@ int main (int argc, char** argv) std::cerr << "Training" << std::endl; t.reset(); t.start(); - classifier.train (ground_truth); + classifier.train (pts.range(label_map)); t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; t.reset(); t.start(); - Classification::classify_with_graphcut + Classification::classify_with_graphcut (pts, pts.point_map(), labels, classifier, generator.neighborhood().k_neighbor_query(12), 0.2f, 1, label_indices); @@ -110,15 +100,15 @@ int main (int argc, char** argv) std::cerr << "Classification with graphcut done in " << t.time() << " second(s)" << std::endl; std::cerr << "Precision, recall, F1 scores and IoU:" << std::endl; - Classification::Evaluation evaluation (labels, ground_truth, label_indices); + Classification::Evaluation evaluation (labels, pts.range(label_map), label_indices); - for (std::size_t i = 0; i < labels.size(); ++ i) + for (Label_handle l : labels) { - std::cerr << " * " << labels[i]->name() << ": " - << evaluation.precision(labels[i]) << " ; " - << evaluation.recall(labels[i]) << " ; " - << evaluation.f1_score(labels[i]) << " ; " - << evaluation.intersection_over_union(labels[i]) << std::endl; + std::cerr << " * " << l->name() << ": " + << evaluation.precision(l) << " ; " + << evaluation.recall(l) << " ; " + << evaluation.f1_score(l) << " ; " + << evaluation.intersection_over_union(l) << std::endl; } std::cerr << "Accuracy = " << evaluation.accuracy() << std::endl @@ -135,19 +125,10 @@ int main (int argc, char** argv) label_map[i] = label_indices[i]; // update label map with computed classification Label_handle label = labels[label_indices[i]]; - - if (label == ground) - { - red[i] = 245; green[i] = 180; blue[i] = 0; - } - else if (label == vegetation) - { - red[i] = 0; green[i] = 255; blue[i] = 27; - } - else if (label == roof) - { - red[i] = 255; green[i] = 0; blue[i] = 170; - } + const CGAL::Color& color = label->color(); + red[i] = color.red(); + green[i] = color.green(); + blue[i] = color.blue(); } // Write result diff --git a/Classification/examples/Classification/example_tensorflow_neural_network.cpp b/Classification/examples/Classification/example_tensorflow_neural_network.cpp index 01fd4f1cac2..6a454360285 100644 --- a/Classification/examples/Classification/example_tensorflow_neural_network.cpp +++ b/Classification/examples/Classification/example_tensorflow_neural_network.cpp @@ -49,18 +49,13 @@ int main (int argc, char** argv) Imap label_map; bool lm_found = false; - boost::tie (label_map, lm_found) = pts.property_map ("label"); + std::tie (label_map, lm_found) = pts.property_map ("label"); if (!lm_found) { std::cerr << "Error: \"label\" property not found in input file." << std::endl; return EXIT_FAILURE; } - std::vector ground_truth; - ground_truth.reserve (pts.size()); - std::copy (pts.range(label_map).begin(), pts.range(label_map).end(), - std::back_inserter (ground_truth)); - Feature_set features; std::cerr << "Generating features" << std::endl; @@ -69,20 +64,14 @@ int main (int argc, char** argv) Feature_generator generator (pts, pts.point_map(), 5); // using 5 scales -#ifdef CGAL_LINKED_WITH_TBB features.begin_parallel_additions(); -#endif - generator.generate_point_based_features (features); - -#ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions(); -#endif t.stop(); std::cerr << "Done in " << t.time() << " second(s)" << std::endl; - // Add types + // Add labels Label_set labels; Label_handle ground = labels.add ("ground"); Label_handle vegetation = labels.add ("vegetation"); @@ -96,7 +85,7 @@ int main (int argc, char** argv) std::cerr << "Training" << std::endl; t.reset(); t.start(); - classifier.train (ground_truth, + classifier.train (pts.range(ground_truth), true, // restart from scratch 100); // 100 iterations t.stop(); @@ -113,15 +102,15 @@ int main (int argc, char** argv) std::cerr << "Classification with graphcut done in " << t.time() << " second(s)" << std::endl; std::cerr << "Precision, recall, F1 scores and IoU:" << std::endl; - Classification::Evaluation evaluation (labels, ground_truth, label_indices); + Classification::Evaluation evaluation (labels, pts.range(ground_truth), label_indices); - for (std::size_t i = 0; i < labels.size(); ++ i) + for (Label_handle l : labels) { - std::cerr << " * " << labels[i]->name() << ": " - << evaluation.precision(labels[i]) << " ; " - << evaluation.recall(labels[i]) << " ; " - << evaluation.f1_score(labels[i]) << " ; " - << evaluation.intersection_over_union(labels[i]) << std::endl; + std::cerr << " * " << l->name() << ": " + << evaluation.precision(l) << " ; " + << evaluation.recall(l) << " ; " + << evaluation.f1_score(l) << " ; " + << evaluation.intersection_over_union(l) << std::endl; } std::cerr << "Accuracy = " << evaluation.accuracy() << std::endl @@ -138,19 +127,10 @@ int main (int argc, char** argv) label_map[i] = label_indices[i]; // update label map with computed classification Label_handle label = labels[label_indices[i]]; - - if (label == ground) - { - red[i] = 245; green[i] = 180; blue[i] = 0; - } - else if (label == vegetation) - { - red[i] = 0; green[i] = 255; blue[i] = 27; - } - else if (label == roof) - { - red[i] = 255; green[i] = 0; blue[i] = 170; - } + const CGAL::Color& color = label->color(); + red[i] = color.red(); + green[i] = color.green(); + blue[i] = color.blue(); } // Write result diff --git a/Classification/include/CGAL/Classification/Cluster.h b/Classification/include/CGAL/Classification/Cluster.h index 4b8b002c3b5..a0d0f209602 100644 --- a/Classification/include/CGAL/Classification/Cluster.h +++ b/Classification/include/CGAL/Classification/Cluster.h @@ -46,7 +46,7 @@ class Cluster { public: - typedef typename ItemMap::value_type Item; + using Item = typename boost::property_traits::value_type; /// \cond SKIP_IN_MANUAL struct Neighbor_query @@ -64,9 +64,9 @@ public: class Point_idx_to_point_unary_function { public: - typedef std::size_t argument_type; - typedef typename ItemMap::reference result_type; - typedef boost::readable_property_map_tag category; + using argument_type = std::size_t; + using result_type = typename boost::property_traits::reference; + using category = boost::readable_property_map_tag; const ItemRange* m_range; ItemMap m_item_map; @@ -105,9 +105,9 @@ public: \param item_map property map to access the input items. */ Cluster (const ItemRange& range, ItemMap item_map) - : neighbors (new std::vector()) + : neighbors (std::make_shared >()) , m_range (&range), m_item_map (item_map) - , m_inliers (new std::vector()) + , m_inliers (std::make_shared >()) , m_training(-1), m_label(-1) { } diff --git a/Classification/include/CGAL/Classification/ETHZ/Random_forest_classifier.h b/Classification/include/CGAL/Classification/ETHZ/Random_forest_classifier.h index e2f831b5aca..6b22c41ad00 100644 --- a/Classification/include/CGAL/Classification/ETHZ/Random_forest_classifier.h +++ b/Classification/include/CGAL/Classification/ETHZ/Random_forest_classifier.h @@ -73,7 +73,7 @@ class Random_forest_classifier const Label_set& m_labels; const Feature_set& m_features; - Forest* m_rfc; + std::shared_ptr m_rfc; public: @@ -81,16 +81,16 @@ public: /// @{ /*! - \brief Instantiates the classifier using the sets of `labels` and `features`. + \brief instantiates the classifier using the sets of `labels` and `features`. */ Random_forest_classifier (const Label_set& labels, const Feature_set& features) - : m_labels (labels), m_features (features), m_rfc (nullptr) + : m_labels (labels), m_features (features) { } /*! - \brief Copies the `other` classifier's configuration using another + \brief copies the `other` classifier's configuration using another set of `features`. This constructor can be used to apply a trained random forest to @@ -105,7 +105,7 @@ public: defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION)) Random_forest_classifier (const Random_forest_classifier& other, const Feature_set& features) - : m_labels (other.m_labels), m_features (features), m_rfc (nullptr) + : m_labels (other.m_labels), m_features (features) { std::stringstream stream; other.save_configuration(stream); @@ -113,14 +113,6 @@ public: } #endif - /// \cond SKIP_IN_MANUAL - ~Random_forest_classifier () - { - if (m_rfc != nullptr) - delete m_rfc; - } - /// \endcond - /// @} /// \name Training @@ -138,7 +130,7 @@ public: /// \endcond /*! - \brief Runs the training algorithm. + \brief runs the training algorithm. From the set of provided ground truth, this algorithm estimates sets up the random trees that produce the most accurate result @@ -179,6 +171,8 @@ public: std::size_t num_trees = 25, std::size_t max_depth = 20) { + CGAL_precondition (m_labels.is_valid_ground_truth (ground_truth)); + CGAL::internal::liblearning::RandomForest::ForestParams params; params.n_trees = num_trees; params.max_depth = max_depth; @@ -186,32 +180,40 @@ public: std::vector gt; std::vector ft; - std::size_t idx = 0; - for (const auto& ig : ground_truth) +#ifdef CGAL_CLASSIFICATION_VERBOSE + std::vector count (m_labels.size(), 0); +#endif + + std::size_t i = 0; + for (const auto& gt_value : ground_truth) { - int g = int(ig); + int g = int(gt_value); if (g != -1) { for (std::size_t f = 0; f < m_features.size(); ++ f) - ft.push_back(m_features[f]->value(idx)); + ft.push_back(m_features[f]->value(i)); gt.push_back(g); +#ifdef CGAL_CLASSIFICATION_VERBOSE + count[std::size_t(g)] ++; +#endif } - ++ idx; + ++ i; } - CGAL_CLASSIFICATION_CERR << "Using " << gt.size() << " inliers" << std::endl; + CGAL_CLASSIFICATION_CERR << "Using " << gt.size() << " inliers:" << std::endl; +#ifdef CGAL_CLASSIFICATION_VERBOSE + for (std::size_t i = 0; i < m_labels.size(); ++ i) + std::cerr << " * " << m_labels[i]->name() << ": " << count[i] << " inlier(s)" << std::endl; +#endif CGAL::internal::liblearning::DataView2D label_vector (&(gt[0]), gt.size(), 1); CGAL::internal::liblearning::DataView2D feature_vector(&(ft[0]), gt.size(), ft.size() / gt.size()); - if (m_rfc != nullptr && reset_trees) - { - delete m_rfc; - m_rfc = nullptr; - } + if (m_rfc && reset_trees) + m_rfc.reset(); - if (m_rfc == nullptr) - m_rfc = new Forest (params); + if (!m_rfc) + m_rfc = std::make_shared (params); CGAL::internal::liblearning::RandomForest::AxisAlignedRandomSplitGenerator generator; @@ -245,7 +247,7 @@ public: /// @{ /*! - \brief Computes, for each feature, how many nodes in the forest + \brief computes, for each feature, how many nodes in the forest uses it as a split criterion. Each tree of the random forest recursively splits the training @@ -280,35 +282,37 @@ public: /// @{ /*! - \brief Saves the current configuration in the stream `output`. + \brief saves the current configuration in the stream `output`. This allows to easily save and recover a specific classification configuration. - The output file is written in an GZIP container that is readable - by the `load_configuration()` method. + The output file is written in a binary format that is readable by + the `load_configuration()` method. */ #if defined(DOXYGEN_RUNNING) || \ (defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \ defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION)) void save_configuration (std::ostream& output) const { - boost::iostreams::filtering_ostream outs; - outs.push(boost::iostreams::gzip_compressor()); - outs.push(output); - boost::archive::text_oarchive oas(outs); - oas << BOOST_SERIALIZATION_NVP(*m_rfc); + m_rfc->write(output); } #endif /*! - \brief Loads a configuration from the stream `input`. + \brief loads a configuration from the stream `input`. - The input file should be a GZIP container written by the + The input file should be a binary file written by the `save_configuration()` method. The feature set of the classifier should contain the exact same features in the exact same order as the ones present when the file was generated using `save_configuration()`. + + \warning If the file you are trying to load was saved using CGAL + 5.1 or earlier, you have to convert it first using + `convert_deprecated_configuration_to_new_format()` as the exchange + format for ETHZ Random Forest changed in CGAL 5.2. + */ #if defined(DOXYGEN_RUNNING) || \ (defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \ @@ -316,9 +320,51 @@ public: void load_configuration (std::istream& input) { CGAL::internal::liblearning::RandomForest::ForestParams params; - if (m_rfc != nullptr) - delete m_rfc; - m_rfc = new Forest (params); + m_rfc = std::make_shared (params); + + m_rfc->read(input); + } +#endif + + /// @} + + /// \name Deprecated Input/Output + /// @{ + + /*! + \brief converts a deprecated configuration (in compressed ASCII + format) to a new configuration (in binary format). + + The input file should be a GZIP container written by the + `save_configuration()` method from CGAL 5.1 and earlier. The + output is a valid configuration for CGAL 5.2 and later. + + \note This function depends on the Boost libraries + [Serialization](https://www.boost.org/libs/serialization) and + [IO Streams](https://www.boost.org/libs/iostreams) (compiled with the GZIP dependency). + */ +#if defined(DOXYGEN_RUNNING) || \ + (defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \ + defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION)) + static void convert_deprecated_configuration_to_new_format (std::istream& input, std::ostream& output) + { + Label_set dummy_labels; + Feature_set dummy_features; + Random_forest_classifier classifier (dummy_labels, dummy_features); + classifier.load_deprecated_configuration(input); + classifier.save_configuration(output); + } +#endif + +/// @} + + /// \cond SKIP_IN_MANUAL +#if defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \ + defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION) + void load_deprecated_configuration (std::istream& input) + { + CGAL::internal::liblearning::RandomForest::ForestParams params; + m_rfc = std::make_shared (params); boost::iostreams::filtering_istream ins; ins.push(boost::iostreams::gzip_decompressor()); @@ -327,8 +373,8 @@ public: ias >> BOOST_SERIALIZATION_NVP(*m_rfc); } #endif + /// \endcond -/// @} }; diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp index 97e13f532ce..e2fdfd42c87 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/common-libraries.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,30 @@ struct ForestParams { ar & BOOST_SERIALIZATION_NVP(sample_reduction); } #endif + + void write (std::ostream& os) + { + I_Binary_write_size_t_into_uinteger32 (os, n_classes); + I_Binary_write_size_t_into_uinteger32 (os, n_features); + I_Binary_write_size_t_into_uinteger32 (os, n_samples); + I_Binary_write_size_t_into_uinteger32 (os, n_in_bag_samples); + I_Binary_write_size_t_into_uinteger32 (os, max_depth); + I_Binary_write_size_t_into_uinteger32 (os, n_trees); + I_Binary_write_size_t_into_uinteger32 (os, min_samples_per_node); + I_Binary_write_float32 (os, sample_reduction); + } + + void read (std::istream& is) + { + I_Binary_read_size_t_from_uinteger32 (is, n_classes); + I_Binary_read_size_t_from_uinteger32 (is, n_features); + I_Binary_read_size_t_from_uinteger32 (is, n_samples); + I_Binary_read_size_t_from_uinteger32 (is, n_in_bag_samples); + I_Binary_read_size_t_from_uinteger32 (is, max_depth); + I_Binary_read_size_t_from_uinteger32 (is, n_trees); + I_Binary_read_size_t_from_uinteger32 (is, min_samples_per_node); + I_Binary_read_float32 (is, sample_reduction); + } }; struct QuadraticSplitter { @@ -248,6 +273,18 @@ struct AxisAlignedSplitter { ar & BOOST_SERIALIZATION_NVP(threshold); } #endif + + void write (std::ostream& os) + { + os.write((char*)(&feature), sizeof(int)); + os.write((char*)(&threshold), sizeof(FeatureType)); + } + + void read (std::istream& is) + { + is.read((char*)(&feature), sizeof(int)); + is.read((char*)(&threshold), sizeof(FeatureType)); + } }; struct AxisAlignedRandomSplitGenerator { diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/forest.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/forest.hpp index 6ffe0e0b719..4611becf711 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/forest.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/forest.hpp @@ -31,7 +31,7 @@ #endif #include - +#include #include #ifdef CGAL_LINKED_WITH_TBB @@ -164,10 +164,10 @@ public: f (seed_start, sample_idxes, trees, samples, labels, params.n_in_bag_samples, split_generator); #ifndef CGAL_LINKED_WITH_TBB - CGAL_static_assertion_msg (!(boost::is_convertible::value), + CGAL_static_assertion_msg (!(std::is_convertible::value), "Parallel_tag is enabled but TBB is unavailable."); #else - if (boost::is_convertible::value) + if (std::is_convertible::value) { tbb::parallel_for(tbb::blocked_range(nb_trees, nb_trees + params.n_trees), f); } @@ -232,6 +232,28 @@ public: } #endif + void write (std::ostream& os) + { + params.write(os); + + I_Binary_write_size_t_into_uinteger32 (os, trees.size()); + for (std::size_t i_tree = 0; i_tree < trees.size(); ++i_tree) + trees[i_tree].write(os); + } + + void read (std::istream& is) + { + params.read(is); + + std::size_t nb_trees; + I_Binary_read_size_t_from_uinteger32 (is, nb_trees); + for (std::size_t i = 0; i < nb_trees; ++ i) + { + trees.push_back (new TreeType(¶ms)); + trees.back().read(is); + } + } + void get_feature_usage (std::vector& count) const { for (std::size_t i_tree = 0; i_tree < trees.size(); ++i_tree) diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/node.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/node.hpp index f510119a557..75ecc1037e6 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/node.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/node.hpp @@ -22,6 +22,8 @@ #include "../dataview.h" #include "common-libraries.hpp" +#include + #if defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION) #include #include @@ -253,9 +255,46 @@ public: } #endif + void write (std::ostream& os) + { + I_Binary_write_bool (os, is_leaf); + I_Binary_write_size_t_into_uinteger32 (os, n_samples); + I_Binary_write_size_t_into_uinteger32 (os, depth); + splitter.write(os); + + for (const float& f : node_dist) + I_Binary_write_float32 (os, f); + + if (!is_leaf) + { + left->write(os); + right->write(os); + } + } + + void read (std::istream& is) + { + I_Binary_read_bool (is, is_leaf); + I_Binary_read_size_t_from_uinteger32 (is, n_samples); + I_Binary_read_size_t_from_uinteger32 (is, depth); + splitter.read(is); + + node_dist.resize(params->n_classes, 0.0f); + for (std::size_t i = 0; i < node_dist.size(); ++ i) + I_Binary_read_float32 (is, node_dist[i]); + + if (!is_leaf) + { + left.reset(new Derived(depth + 1, params)); + right.reset(new Derived(depth + 1, params)); + left->read(is); + right->read(is); + } + } + void get_feature_usage (std::vector& count) const { - if (!is_leaf) + if (!is_leaf && splitter.feature != -1) { count[std::size_t(splitter.feature)] ++; left->get_feature_usage(count); diff --git a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/tree.hpp b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/tree.hpp index c8a07f020d7..ba75c6e2f98 100644 --- a/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/tree.hpp +++ b/Classification/include/CGAL/Classification/ETHZ/internal/random-forest/tree.hpp @@ -129,6 +129,17 @@ public: } #endif + void write (std::ostream& os) + { + root_node->write(os); + } + + void read (std::istream& is) + { + root_node.reset(new NodeT(0, params)); + root_node->read(is); + } + void get_feature_usage (std::vector& count) const { root_node->get_feature_usage(count); diff --git a/Classification/include/CGAL/Classification/Evaluation.h b/Classification/include/CGAL/Classification/Evaluation.h index 071f6ab8c9f..eeff26f73d6 100644 --- a/Classification/include/CGAL/Classification/Evaluation.h +++ b/Classification/include/CGAL/Classification/Evaluation.h @@ -17,9 +17,10 @@ #include #include -#include #include +#include + #include #include // for std::isnan @@ -27,6 +28,7 @@ namespace CGAL { namespace Classification { + /*! \ingroup PkgClassificationDataStructures @@ -35,98 +37,103 @@ namespace Classification { */ class Evaluation { - mutable std::map m_map_labels; - - std::vector m_precision; - std::vector m_recall; - std::vector m_iou; // intersection over union - float m_accuracy; - float m_mean_iou; - float m_mean_f1; + const Label_set& m_labels; + std::vector > m_confusion; // confusion matrix public: - /// \name Constructor + /// \name Constructors /// @{ + /*! + \brief instantiates an empty evaluation object. -/*! + \param labels labels used. + */ + Evaluation (const Label_set& labels) + : m_labels (labels) + { + init(); + } - \brief Instantiates an evaluation object and computes all - measurements. + /*! - \param labels labels used. + \brief instantiates an evaluation object and computes all + measurements. - \param ground_truth vector of label indices: it should contain the - index of the corresponding label in the `Label_set` provided in the - constructor. Input items that do not have a ground truth information - should be given the value `-1`. + \param labels labels used. - \param result similar to `ground_truth` but contained the result of - a classification. + \param ground_truth vector of label indices: it should contain the + index of the corresponding label in the `Label_set` provided in the + constructor. Input items that do not have a ground truth information + should be given the value `-1`. -*/ + \param result similar to `ground_truth` but contained the result of + a classification. + + */ template Evaluation (const Label_set& labels, const GroundTruthIndexRange& ground_truth, const ResultIndexRange& result) - : m_precision (labels.size()), - m_recall (labels.size()), - m_iou (labels.size()) + : m_labels (labels) { - for (std::size_t i = 0; i < labels.size(); ++ i) - m_map_labels[labels[i]] = i; + init(); + append(ground_truth, result); + } - std::vector true_positives (labels.size()); - std::vector false_positives (labels.size()); - std::vector false_negatives (labels.size()); + /// \cond SKIP_IN_MANUAL + void init() + { + m_confusion.resize (m_labels.size()); + for (std::size_t i = 0; i < m_confusion.size(); ++ i) + m_confusion[i].resize (m_labels.size(), 0); + } - std::size_t sum_true_positives = 0; - std::size_t total = 0; + bool label_has_ground_truth (std::size_t label_idx) const + { + for (std::size_t i = 0; i < m_labels.size(); ++ i) + if (m_confusion[i][label_idx] != 0) + return true; + return false; + } + /// \endcond - for (const auto& zip : CGAL::make_range (boost::make_zip_iterator - (boost::make_tuple(ground_truth.begin(), result.begin())), - boost::make_zip_iterator - (boost::make_tuple(ground_truth.end(), result.end())))) + /// @} + + /// \name Modification + /// @{ + + /*! + \brief appends more items to the evaluation object. + + \param ground_truth vector of label indices: it should contain the + index of the corresponding label in the `Label_set` provided in the + constructor. Input items that do not have a ground truth information + should be given the value `-1`. + + \param result similar to `ground_truth` but contained the result of + a classification. + + */ + template + void append (const GroundTruthIndexRange& ground_truth, + const ResultIndexRange& result) + { + CGAL_precondition (m_labels.is_valid_ground_truth (ground_truth)); + CGAL_precondition (m_labels.is_valid_ground_truth (result)); + + for (const auto& p : CGAL::make_range + (boost::make_zip_iterator(boost::make_tuple(ground_truth.begin(), result.begin())), + boost::make_zip_iterator(boost::make_tuple(ground_truth.end(), result.end())))) { - int gt = static_cast(boost::get<0>(zip)); - int res = static_cast(boost::get<1>(zip)); + int gt = static_cast(boost::get<0>(p)); + int res = static_cast(boost::get<1>(p)); if (gt == -1 || res == -1) continue; - ++ total; - if (gt == res) - { - ++ true_positives[gt]; - ++ sum_true_positives; - continue; - } - ++ false_positives[res]; - ++ false_negatives[gt]; + + ++ m_confusion[std::size_t(res)][std::size_t(gt)]; } - - m_mean_iou = 0.; - m_mean_f1 = 0.; - - std::size_t correct_labels = 0; - - for (std::size_t j = 0; j < labels.size(); ++ j) - { - m_precision[j] = true_positives[j] / float(true_positives[j] + false_positives[j]); - m_recall[j] = true_positives[j] / float(true_positives[j] + false_negatives[j]); - m_iou[j] = true_positives[j] / float(true_positives[j] + false_positives[j] + false_negatives[j]); - - if (std::isnan(m_iou[j])) - continue; - - ++ correct_labels; - m_mean_iou += m_iou[j]; - m_mean_f1 += 2.f * (m_precision[j] * m_recall[j]) - / (m_precision[j] + m_recall[j]); - } - - m_mean_iou /= correct_labels; - m_mean_f1 /= correct_labels; - m_accuracy = sum_true_positives / float(total); } /// @} @@ -134,10 +141,20 @@ public: /// \name Label Evaluation /// @{ + /*! + \brief returns the number of items whose ground truth is + `ground_truth` and which were classified as `result`. + */ + std::size_t confusion (Label_handle ground_truth, Label_handle result) + { + std::size_t idx_gt = ground_truth->index(); + std::size_t idx_r = result->index(); + return m_confusion[idx_gt][idx_r]; + } /*! - \brief Returns the precision of the training for the given label. + \brief returns the precision of the training for the given label. Precision is the number of true positives divided by the sum of the true positives and the false positives. @@ -145,12 +162,23 @@ public: */ float precision (Label_handle label) const { - return m_precision[m_map_labels[label]]; + std::size_t idx = label->index(); + if (!label_has_ground_truth(idx)) + return std::numeric_limits::quiet_NaN(); + + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + total += m_confusion[idx][i]; + + if (total == 0) + return 0.f; + + return m_confusion[idx][idx] / float(total); } /*! - \brief Returns the recall of the training for the given label. + \brief returns the recall of the training for the given label. Recall is the number of true positives divided by the sum of the true positives and the false negatives. @@ -158,12 +186,19 @@ public: */ float recall (Label_handle label) const { - return m_recall[m_map_labels[label]]; + std::size_t idx = label->index(); + if (!label_has_ground_truth(idx)) + return std::numeric_limits::quiet_NaN(); + + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + total += m_confusion[i][idx]; + return m_confusion[idx][idx] / float(total); } /*! - \brief Returns the \f$F_1\f$ score of the training for the given label. + \brief returns the \f$F_1\f$ score of the training for the given label. \f$F_1\f$ score is the harmonic mean of `precision()` and `recall()`: @@ -174,13 +209,17 @@ public: */ float f1_score (Label_handle label) const { - std::size_t label_idx = m_map_labels[label]; - return 2.f * (m_precision[label_idx] * m_recall[label_idx]) - / (m_precision[label_idx] + m_recall[label_idx]); + float p = precision(label); + float r = recall(label); + + if (p == 0.f && r == 0.f) + return 0.f; + + return 2.f * p * r / (p + r); } /*! - \brief Returns the intersection over union of the training for the + \brief returns the intersection over union of the training for the given label. Intersection over union is the number of true positives divided by @@ -189,7 +228,17 @@ public: */ float intersection_over_union (Label_handle label) const { - return m_iou[m_map_labels[label]]; + std::size_t idx = label->index(); + + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + { + total += m_confusion[i][idx]; + if (i != idx) + total += m_confusion[idx][i]; + } + + return m_confusion[idx][idx] / float(total); } /// @} @@ -197,26 +246,226 @@ public: /// \name Global Evaluation /// @{ + /*! + \brief returns the number of misclassified items. + */ + std::size_t number_of_misclassified_items() const + { + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + for (std::size_t j = 0; j < m_labels.size(); ++ j) + if (i != j) + total += m_confusion[i][j]; + return total; + } /*! - \brief Returns the accuracy of the training. + \brief returns the total number of items used for evaluation. + */ + std::size_t number_of_items() const + { + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + for (std::size_t j = 0; j < m_labels.size(); ++ j) + total += m_confusion[i][j]; + return total; + } + + /*! + \brief returns the accuracy of the training. Accuracy is the total number of true positives divided by the total number of provided inliers. */ - float accuracy() const { return m_accuracy; } + float accuracy() const + { + std::size_t true_positives = 0; + std::size_t total = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + { + true_positives += m_confusion[i][i]; + for (std::size_t j = 0; j < m_labels.size(); ++ j) + total += m_confusion[i][j]; + } + return true_positives / float(total); + } /*! - \brief Returns the mean \f$F_1\f$ score of the training over all + \brief returns the mean \f$F_1\f$ score of the training over all labels (see `f1_score()`). */ - float mean_f1_score() const { return m_mean_f1; } + float mean_f1_score() const + { + float mean = 0; + std::size_t nb = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + if (label_has_ground_truth(i)) + { + mean += f1_score(m_labels[i]); + ++ nb; + } + return mean / nb; + } /*! - \brief Returns the mean intersection over union of the training + \brief returns the mean intersection over union of the training over all labels (see `intersection_over_union()`). */ - float mean_intersection_over_union() const { return m_mean_iou; } + float mean_intersection_over_union() const + { + float mean = 0; + std::size_t nb = 0; + for (std::size_t i = 0; i < m_labels.size(); ++ i) + { + float iou = intersection_over_union(m_labels[i]); + if (!std::isnan(iou)) + { + mean += iou; + ++ nb; + } + } + return mean / nb; + } + + /// @} + + /// \name Output Formatting Functions + /// @{ + + /*! + \brief outputs the evaluation in a simple ASCII format to the stream `os`. + */ + friend std::ostream& operator<< (std::ostream& os, const Evaluation& evaluation) + { + os << "Evaluation of classification:" << std::endl; + os << " * Global results:" << std::endl; + os << " - " << evaluation.number_of_misclassified_items() + << " misclassified item(s) out of " << evaluation.number_of_items() << std::endl + << " - Accuracy = " << evaluation.accuracy() << std::endl + << " - Mean F1 score = " << evaluation.mean_f1_score() << std::endl + << " - Mean IoU = " << evaluation.mean_intersection_over_union() << std::endl; + os << " * Detailed results:" << std::endl; + for (std::size_t i = 0; i < evaluation.m_labels.size(); ++ i) + { + os << " - \"" << evaluation.m_labels[i]->name() << "\": "; + if (evaluation.label_has_ground_truth(i)) + os << "Precision = " << evaluation.precision(evaluation.m_labels[i]) << " ; " + << "Recall = " << evaluation.recall(evaluation.m_labels[i]) << " ; " + << "F1 score = " << evaluation.f1_score(evaluation.m_labels[i]) << " ; " + << "IoU = " << evaluation.intersection_over_union(evaluation.m_labels[i]) << std::endl; + else + os << "(no ground truth)" << std::endl; + } + return os; + } + + /*! + \brief outputs the evaluation as an HTML page to the stream `os`. + */ + static std::ostream& output_to_html (std::ostream& os, const Evaluation& evaluation) + { + os << "" << std::endl + << "" << std::endl + << "" << std::endl + << "" << std::endl + << "Evaluation of CGAL Classification results" << std::endl + << "" << std::endl + << "" << std::endl + << "

    Evaluation of CGAL Classification results

    " << std::endl; + + os << "

    Global Results

    " << std::endl + << "
      " << std::endl + << "
    • " << evaluation.number_of_misclassified_items() + << " misclassified item(s) out of " << evaluation.number_of_items() << "
    • " << std::endl + << "
    • Accuracy = " << evaluation.accuracy() << "
    • " << std::endl + << "
    • Mean F1 score = " << evaluation.mean_f1_score() << "
    • " << std::endl + << "
    • Mean IoU = " << evaluation.mean_intersection_over_union() << "
    • " << std::endl + << "
    " << std::endl; + + const Label_set& labels = evaluation.m_labels; + + os << "

    Detailed Results

    " << std::endl + << "" << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl; + for (std::size_t i = 0; i < labels.size(); ++ i) + if (evaluation.label_has_ground_truth(i)) + os << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl; + else + os << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl + << " " << std::endl; + + os << "
    LabelPrecisionRecallF1 scoreIoU
    " << labels[i]->name() << "" << evaluation.precision(labels[i]) << "" << evaluation.recall(labels[i]) << "" << evaluation.f1_score(labels[i]) << "" << evaluation.intersection_over_union(labels[i]) << "
    " << labels[i]->name() << "(no ground truth)
    " << std::endl; + + os << "

    Confusion Matrix

    " << std::endl + << "" << std::endl + << " " << std::endl + << " " << std::endl; + for (std::size_t i = 0; i < labels.size(); ++ i) + os << " " << std::endl; + os << " " << std::endl; + os << " " << std::endl; + + std::vector sums (labels.size(), 0); + for (std::size_t i = 0; i < labels.size(); ++ i) + { + os << " " << std::endl + << " " << std::endl; + std::size_t sum = 0; + for (std::size_t j = 0; j < labels.size(); ++ j) + { + if (i == j) + os << " " << std::endl; + else + os << " " << std::endl; + sum += evaluation.m_confusion[i][j]; + sums[j] += evaluation.m_confusion[i][j]; + } + os << " " << std::endl; + os << " " << std::endl; + } + + os << " " << std::endl + << " " << std::endl; + std::size_t total = 0; + for (std::size_t j = 0; j < labels.size(); ++ j) + { + os << " " << std::endl; + total += sums[j]; + } + os << " " << std::endl + << " " << std::endl + << "
    " << labels[i]->name() << "PREDICTIONS
    " << labels[i]->name() << "" << evaluation.m_confusion[i][j] << "" << evaluation.m_confusion[i][j] << "" << sum << "
    GROUND TRUTH" << sums[j] << "" << total << "
    " << std::endl + << "

    This page was generated by the CGAL \ +Classification package.

    " << std::endl + << "" << std::endl + << "" << std::endl; + + return os; + } /// @} diff --git a/Classification/include/CGAL/Classification/Feature/Cluster_mean_of_feature.h b/Classification/include/CGAL/Classification/Feature/Cluster_mean_of_feature.h index 0a3846fe2aa..4f39bcfaf62 100644 --- a/Classification/include/CGAL/Classification/Feature/Cluster_mean_of_feature.h +++ b/Classification/include/CGAL/Classification/Feature/Cluster_mean_of_feature.h @@ -40,7 +40,7 @@ class Cluster_mean_of_feature : public CGAL::Classification::Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \tparam ClusterRange model of `ConstRange`. Its iterator type is `RandomAccessIterator` and its value type is the key type of diff --git a/Classification/include/CGAL/Classification/Feature/Cluster_size.h b/Classification/include/CGAL/Classification/Feature/Cluster_size.h index 52f8fac9d3d..772c87b8fa9 100644 --- a/Classification/include/CGAL/Classification/Feature/Cluster_size.h +++ b/Classification/include/CGAL/Classification/Feature/Cluster_size.h @@ -37,7 +37,7 @@ class Cluster_size : public CGAL::Classification::Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \tparam ClusterRange model of `ConstRange`. Its iterator type is `RandomAccessIterator` and its value type is the key type of diff --git a/Classification/include/CGAL/Classification/Feature/Cluster_variance_of_feature.h b/Classification/include/CGAL/Classification/Feature/Cluster_variance_of_feature.h index dfa4bfe5891..30817fef411 100644 --- a/Classification/include/CGAL/Classification/Feature/Cluster_variance_of_feature.h +++ b/Classification/include/CGAL/Classification/Feature/Cluster_variance_of_feature.h @@ -40,7 +40,7 @@ class Cluster_variance_of_feature : public CGAL::Classification::Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \tparam ClusterRange model of `ConstRange`. Its iterator type is `RandomAccessIterator` and its value type is the key type of diff --git a/Classification/include/CGAL/Classification/Feature/Cluster_vertical_extent.h b/Classification/include/CGAL/Classification/Feature/Cluster_vertical_extent.h index ed977c52da6..07d3a2214a5 100644 --- a/Classification/include/CGAL/Classification/Feature/Cluster_vertical_extent.h +++ b/Classification/include/CGAL/Classification/Feature/Cluster_vertical_extent.h @@ -40,7 +40,7 @@ class Cluster_vertical_extent : public CGAL::Classification::Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \tparam ClusterRange model of `ConstRange`. Its iterator type is `RandomAccessIterator` and its value type is the key type of diff --git a/Classification/include/CGAL/Classification/Feature/Color_channel.h b/Classification/include/CGAL/Classification/Feature/Color_channel.h index 8dfaa93c97c..b0296d191bb 100644 --- a/Classification/include/CGAL/Classification/Feature/Color_channel.h +++ b/Classification/include/CGAL/Classification/Feature/Color_channel.h @@ -80,7 +80,7 @@ private: public: /*! - \brief Constructs a feature based on the given color channel. + \brief constructs a feature based on the given color channel. \param input point range. \param color_map property map to access the colors of the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h b/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h index 19b6b83a959..46adeec1b41 100644 --- a/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h +++ b/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h @@ -46,8 +46,7 @@ namespace Feature { template class Distance_to_plane : public Feature_base { - - typedef typename CGAL::Kernel_traits::Kernel Kernel; + using Kernel = typename CGAL::Kernel_traits::Kernel; #ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES std::vector distance_to_plane_feature; @@ -59,7 +58,7 @@ class Distance_to_plane : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Echo_scatter.h b/Classification/include/CGAL/Classification/Feature/Echo_scatter.h index b2206910102..9fb63252d6e 100644 --- a/Classification/include/CGAL/Classification/Feature/Echo_scatter.h +++ b/Classification/include/CGAL/Classification/Feature/Echo_scatter.h @@ -52,9 +52,9 @@ template Grid; + using Grid = Classification::Planimetric_grid; private: - typedef Classification::Image Image_cfloat; + using Image_cfloat = Classification::Image; const Grid& grid; Image_cfloat Scatter; @@ -62,7 +62,7 @@ private: public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param echo_map property map to access the echo values of the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Elevation.h b/Classification/include/CGAL/Classification/Feature/Elevation.h index 1205c757403..175b20b6a44 100644 --- a/Classification/include/CGAL/Classification/Feature/Elevation.h +++ b/Classification/include/CGAL/Classification/Feature/Elevation.h @@ -50,11 +50,9 @@ namespace Feature { template class Elevation : public Feature_base { - typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; - - typedef Image Image_float; - typedef Image Image_cfloat; - typedef Planimetric_grid Grid; + using Image_float = Image; + using Image_cfloat = Image; + using Grid = Planimetric_grid; const PointRange& input; PointMap point_map; @@ -66,7 +64,7 @@ class Elevation : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Height_above.h b/Classification/include/CGAL/Classification/Feature/Height_above.h index 62eac6f20e2..b59b108c1ac 100644 --- a/Classification/include/CGAL/Classification/Feature/Height_above.h +++ b/Classification/include/CGAL/Classification/Feature/Height_above.h @@ -49,10 +49,8 @@ namespace Feature { template class Height_above : public Feature_base { - typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; - - typedef Image Image_float; - typedef Planimetric_grid Grid; + using Image_float = Image; + using Grid = Planimetric_grid; const PointRange& input; PointMap point_map; @@ -62,7 +60,7 @@ class Height_above : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Height_below.h b/Classification/include/CGAL/Classification/Feature/Height_below.h index 0eae37370f6..22371934155 100644 --- a/Classification/include/CGAL/Classification/Feature/Height_below.h +++ b/Classification/include/CGAL/Classification/Feature/Height_below.h @@ -49,8 +49,6 @@ namespace Feature { template class Height_below : public Feature_base { - typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; - typedef Image Image_float; typedef Planimetric_grid Grid; @@ -62,7 +60,7 @@ class Height_below : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Simple_feature.h b/Classification/include/CGAL/Classification/Feature/Simple_feature.h index 12efb1563be..8dd5f59168c 100644 --- a/Classification/include/CGAL/Classification/Feature/Simple_feature.h +++ b/Classification/include/CGAL/Classification/Feature/Simple_feature.h @@ -42,7 +42,7 @@ class Simple_feature : public Feature_base public: /*! - \brief Constructs the feature using an input range and a property map. + \brief constructs the feature using an input range and a property map. \param input point range. \param property_map property map to access scalar field. diff --git a/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h b/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h index c173f70acca..2a5c8e6e9c7 100644 --- a/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h +++ b/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h @@ -56,8 +56,8 @@ namespace Feature { template class Vertical_dispersion : public Feature_base { - typedef Classification::Image Image_cfloat; - typedef Classification::Planimetric_grid Grid; + using Image_cfloat = Classification::Image; + using Grid = Classification::Planimetric_grid; const Grid& grid; Image_cfloat Dispersion; @@ -65,7 +65,7 @@ class Vertical_dispersion : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Vertical_range.h b/Classification/include/CGAL/Classification/Feature/Vertical_range.h index 95fc5042e18..45b9c98d3ee 100644 --- a/Classification/include/CGAL/Classification/Feature/Vertical_range.h +++ b/Classification/include/CGAL/Classification/Feature/Vertical_range.h @@ -49,10 +49,8 @@ namespace Feature { template class Vertical_range : public Feature_base { - typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; - - typedef Image Image_float; - typedef Planimetric_grid Grid; + using Image_float = Image; + using Grid = Planimetric_grid; const PointRange& input; PointMap point_map; @@ -62,7 +60,7 @@ class Vertical_range : public Feature_base public: /*! - \brief Constructs the feature. + \brief constructs the feature. \param input point range. \param point_map property map to access the input points. diff --git a/Classification/include/CGAL/Classification/Feature/Verticality.h b/Classification/include/CGAL/Classification/Feature/Verticality.h index 8bfe7537bc1..2ef8cac6376 100644 --- a/Classification/include/CGAL/Classification/Feature/Verticality.h +++ b/Classification/include/CGAL/Classification/Feature/Verticality.h @@ -46,7 +46,7 @@ class Verticality : public Feature_base public: /*! - \brief Constructs the feature using local eigen analysis. + \brief constructs the feature using local eigen analysis. \tparam InputRange model of `ConstRange`. Its iterator type is `RandomAccessIterator`. @@ -64,7 +64,7 @@ public: /*! - \brief Constructs the feature using provided normals of points. + \brief constructs the feature using provided normals of points. \tparam PointRange model of `ConstRange`. Its iterator type is `RandomAccessIterator` and its value type is the key type of diff --git a/Classification/include/CGAL/Classification/Feature_base.h b/Classification/include/CGAL/Classification/Feature_base.h index 469bf079bc9..89ba6e60384 100644 --- a/Classification/include/CGAL/Classification/Feature_base.h +++ b/Classification/include/CGAL/Classification/Feature_base.h @@ -14,8 +14,8 @@ #include -#include - +#include +#include #include namespace CGAL { @@ -42,18 +42,18 @@ public: /// \endcond /*! - \brief Returns the name of the feature (initialized to + \brief returns the name of the feature (initialized to `abstract_feature` for `Feature_base`). */ const std::string& name() const { return m_name; } /*! - \brief Changes the name of the feature. + \brief changes the name of the feature. */ void set_name (const std::string& name) { m_name = name; } /*! - \brief Returns the value taken by the feature for at the item for + \brief returns the value taken by the feature for at the item for the item at position `index`. This method must be implemented by inherited classes. */ @@ -72,7 +72,6 @@ public: */ class Feature_handle { }; #else -//typedef boost::shared_ptr Feature_handle; class Feature_set; @@ -80,19 +79,23 @@ class Feature_handle { friend Feature_set; - boost::shared_ptr > m_base; + using Feature_base_ptr = std::unique_ptr; + std::shared_ptr m_base; - template - Feature_handle (Feature* f) : m_base (new boost::shared_ptr(f)) { } - - template - void attach (Feature* f) const + template + Feature_handle (Feature_ptr f) + : m_base (std::make_shared(std::move(f))) { - *m_base = boost::shared_ptr(f); + } + + template + void attach (Feature_ptr f) + { + *m_base = std::move(f); } public: - Feature_handle() : m_base (new boost::shared_ptr()) { } + Feature_handle() : m_base (std::make_shared()) { } Feature_base& operator*() { return **m_base; } @@ -107,6 +110,17 @@ public: #endif +/*! + \ingroup PkgClassificationFeature + + \brief casts a feature handle to a specialized feature pointer. +*/ +template +FeatureType* feature_cast (Feature_handle fh) +{ + return dynamic_cast(&*(fh)); +} + } // namespace Classification diff --git a/Classification/include/CGAL/Classification/Feature_set.h b/Classification/include/CGAL/Classification/Feature_set.h index 13fb59840e5..2573c3abde6 100644 --- a/Classification/include/CGAL/Classification/Feature_set.h +++ b/Classification/include/CGAL/Classification/Feature_set.h @@ -16,15 +16,14 @@ #include -#include - #ifdef CGAL_LINKED_WITH_TBB -#include #include #endif // CGAL_LINKED_WITH_TBB #include +#include #include +#include namespace CGAL { @@ -40,7 +39,7 @@ the addition and the deletion of features. */ class Feature_set { - typedef std::vector Base; + using Base = std::vector; Base m_features; struct Compare_name @@ -54,42 +53,35 @@ class Feature_set }; #ifdef CGAL_LINKED_WITH_TBB - tbb::task_group* m_tasks; + std::unique_ptr m_tasks; #endif // CGAL_LINKED_WITH_TBB public: +#ifdef DOXYGEN_RUNNING + using const_iterator = unspecified_type; ///< A random access constant iterator with value type `Feature_handle`. + using iterator = unspecified_type; ///< A random access iterator with value type `Feature_handle`. +#else + using const_iterator = std::vector::const_iterator; + using iterator = std::vector::iterator; +#endif + /// \name Constructor /// @{ /*! - \brief Creates an empty feature set. + \brief creates an empty feature set. */ Feature_set() -#ifdef CGAL_LINKED_WITH_TBB - : m_tasks(nullptr) -#endif { } /// @} - /// \cond SKIP_IN_MANUAL - virtual ~Feature_set() - { -#ifdef CGAL_LINKED_WITH_TBB - if (m_tasks != nullptr) - delete m_tasks; - for (std::size_t i = 0; i < m_adders.size(); ++ i) - delete m_adders[i]; -#endif - } - /// \endcond - /// \name Modifications /// @{ /*! - \brief Instantiates a new feature and adds it to the set. + \brief instantiates a new feature and adds it to the set. If several calls of `add()` are surrounded by `begin_parallel_additions()` and `end_parallel_additions()`, they @@ -113,20 +105,21 @@ public: Feature_handle add (T&& ... t) { #ifdef CGAL_LINKED_WITH_TBB - if (m_tasks != nullptr) + if (m_tasks) { m_features.push_back (Feature_handle()); - Parallel_feature_adder* adder - = new Parallel_feature_adder(m_features.back(), std::forward(t)...); - - m_adders.push_back (adder); + Parallel_feature_adder_ptr adder + = std::make_unique > + (m_features.back(), std::forward(t)...); m_tasks->run (*adder); + + m_adders.emplace_back (std::move (adder)); } else #endif { - m_features.push_back (Feature_handle (new Feature(std::forward(t)...))); + m_features.push_back (Feature_handle (std::make_unique(std::forward(t)...))); } return m_features.back(); } @@ -136,20 +129,21 @@ public: Feature_handle add_with_scale_id (std::size_t i, T&& ... t) { #ifdef CGAL_LINKED_WITH_TBB - if (m_tasks != nullptr) + if (m_tasks) { m_features.push_back (Feature_handle()); - Parallel_feature_adder* adder - = new Parallel_feature_adder(i, m_features.back(), std::forward(t)...); - - m_adders.push_back (adder); + Parallel_feature_adder_ptr adder + = std::make_unique > + (i, m_features.back(), std::forward(t)...); m_tasks->run (*adder); + + m_adders.emplace_back (std::move (adder)); } else #endif { - m_features.push_back (Feature_handle (new Feature(std::forward(t)...))); + m_features.push_back (Feature_handle (std::make_unique(std::forward(t)...))); m_features.back()->set_name (m_features.back()->name() + "_" + std::to_string(i)); } return m_features.back(); @@ -158,7 +152,7 @@ public: /*! - \brief Removes a feature. + \brief removes a feature. \param feature the handle to feature type that must be removed. @@ -177,7 +171,7 @@ public: } /*! - \brief Removes all features. + \brief removes all features. */ void clear () { @@ -190,16 +184,15 @@ public: /// @{ -#if defined(CGAL_LINKED_WITH_TBB) || defined(DOXYGEN_RUNNING) - /*! - \brief Initializes structures to compute features in parallel. + \brief initializes structures to compute features in parallel. If the user wants to add features in parallel, this function should be called before making several calls of `add()`. After the calls of `add()`, `end_parallel_additions()` should be called. - \note This function requires \ref thirdpartyTBB. + \note If \ref thirdpartyTBB is not available, this function does + nothing. \warning As arguments of `add()` are passed by reference and that new threads are started if `begin_parallel_additions()` is used, it is @@ -212,33 +205,33 @@ public: */ void begin_parallel_additions() { - m_tasks = new tbb::task_group; +#ifdef CGAL_LINKED_WITH_TBB + m_tasks = std::make_unique(); +#endif } /*! - \brief Waits for the end of parallel feature computation and + \brief waits for the end of parallel feature computation and clears dedicated data structures afterwards. If the user wants to add features in parallel, this function should be called after `begin_parallel_additions()` and several calls of `add()`. - \note This function requires \ref thirdpartyTBB. + \note If \ref thirdpartyTBB is not available, this function does + nothing. \sa `begin_parallel_additions()` */ void end_parallel_additions() { +#ifdef CGAL_LINKED_WITH_TBB m_tasks->wait(); - delete m_tasks; - m_tasks = nullptr; - - for (std::size_t i = 0; i < m_adders.size(); ++ i) - delete m_adders[i]; + m_tasks.release(); m_adders.clear(); - } #endif + } /// @} @@ -246,8 +239,13 @@ public: /// \name Access /// @{ + const_iterator begin() const { return m_features.begin(); } + iterator begin() { return m_features.begin(); } + const_iterator end() const { return m_features.end(); } + iterator end() { return m_features.end(); } + /*! - \brief Returns how many features are defined. + \brief returns how many features are defined. */ std::size_t size() const { @@ -256,7 +254,7 @@ public: /*! - \brief Returns the \f$i^{th}\f$ feature. + \brief returns the \f$i^{th}\f$ feature. */ Feature_handle operator[](std::size_t i) const { @@ -293,18 +291,18 @@ private: { std::size_t scale; mutable Feature_handle fh; - boost::shared_ptr > args; + std::shared_ptr > args; Parallel_feature_adder (Feature_handle fh, T&& ... t) : scale (std::size_t(-1)), fh (fh) { - args = boost::make_shared >(std::forward(t)...); + args = std::make_shared >(std::forward(t)...); } Parallel_feature_adder (std::size_t scale, Feature_handle fh, T&& ... t) : scale(scale), fh (fh) { - args = boost::make_shared >(std::forward(t)...); + args = std::make_shared >(std::forward(t)...); } template @@ -325,7 +323,7 @@ private: template void add_feature (Tuple& t, seq) const { - fh.attach (new Feature (std::forward(std::get(t))...)); + fh.attach (std::make_unique (std::forward(std::get(t))...)); if (scale != std::size_t(-1)) fh->set_name (fh->name() + "_" + std::to_string(scale)); } @@ -337,7 +335,11 @@ private: }; - std::vector m_adders; + using Abstract_parallel_feature_adder_ptr = std::unique_ptr; + template + using Parallel_feature_adder_ptr = std::unique_ptr >; + + std::vector m_adders; /// \endcond }; diff --git a/Classification/include/CGAL/Classification/Image.h b/Classification/include/CGAL/Classification/Image.h index 45759ed219d..924e39bde24 100644 --- a/Classification/include/CGAL/Classification/Image.h +++ b/Classification/include/CGAL/Classification/Image.h @@ -14,8 +14,8 @@ #include -#include #include +#include #define CGAL_CLASSIFICATION_IMAGE_SIZE_LIMIT 100000000 @@ -27,15 +27,15 @@ namespace Classification { template class Image { - typedef std::vector Vector; - typedef std::map Map; + using Vector = std::vector; + using Map = std::map; std::size_t m_width; std::size_t m_height; std::size_t m_depth; - boost::shared_ptr m_raw; - boost::shared_ptr m_sparse; + std::shared_ptr m_raw; + std::shared_ptr m_sparse; Type m_default; // Forbid using copy constructor @@ -45,7 +45,7 @@ class Image public: - Image () : m_width(0), m_height(0), m_depth(0), m_raw (nullptr) + Image () : m_width(0), m_height(0), m_depth(0) { } @@ -57,9 +57,9 @@ public: if (m_width * m_height * m_depth > 0) { if (m_width * m_height * m_depth < CGAL_CLASSIFICATION_IMAGE_SIZE_LIMIT) - m_raw = boost::shared_ptr (new Vector(m_width * m_height * m_depth)); + m_raw = std::make_shared (m_width * m_height * m_depth); else - m_sparse = boost::shared_ptr (new Map()); + m_sparse = std::make_shared (); } } @@ -69,8 +69,8 @@ public: void free() { - m_raw = boost::shared_ptr(); - m_sparse = boost::shared_ptr(); + m_raw.reset(); + m_sparse.reset(); } Image& operator= (const Image& other) @@ -94,7 +94,7 @@ public: Type& operator() (const std::size_t& x, const std::size_t& y, const std::size_t& z = 0) { - if (m_raw == boost::shared_ptr()) // sparse case + if (!m_raw) // sparse case { typename Map::iterator inserted = m_sparse->insert (std::make_pair (coord(x,y,z), Type())).first; @@ -105,7 +105,7 @@ public: } const Type& operator() (const std::size_t& x, const std::size_t& y, const std::size_t& z = 0) const { - if (m_raw == boost::shared_ptr()) // sparse case + if (!m_raw) // sparse case { typename Map::iterator found = m_sparse->find (coord(x,y,z)); if (found != m_sparse->end()) diff --git a/Classification/include/CGAL/Classification/Label.h b/Classification/include/CGAL/Classification/Label.h index 45b2545803c..6a21b630768 100644 --- a/Classification/include/CGAL/Classification/Label.h +++ b/Classification/include/CGAL/Classification/Label.h @@ -13,38 +13,89 @@ #define CGAL_CLASSIFICATION_LABEL_H #include +#include -#include +#include namespace CGAL { namespace Classification { +/// \cond SKIP_IN_MANUAL +class Label_set; +/// \endcond + /*! \ingroup PkgClassificationLabel -\brief %Classification label (for example: vegetation, ground, etc.) -defined as a set of relationships with classification features. +\brief %Classification label (for example: vegetation, ground, etc.). +\note Labels should always be constructed from a `CGAL::Classification::Label_set` object. */ class Label { private: std::string m_name; + std::size_t m_index; + std::size_t m_standard_index; + CGAL::Color m_color; + + friend Label_set; public: - /*! - \param name name of the classification label (e.g. vegetation). - */ - Label (std::string name) : m_name (name) { } + /// \cond SKIP_IN_MANUAL + // Undocumented: Labels should be created by the set + Label (std::string name, std::size_t index, std::size_t standard_index, + const CGAL::Color& color) + : m_name (name), m_index (index), m_standard_index (standard_index) + , m_color (color) + { } + /// \endcond + /// \name Access + /// @{ + + /*! + returns the name of the classification label (\a e.g. vegetation). + */ const std::string& name() const { return m_name; } - /// \cond SKIP_IN_MANUAL + /*! + returns the index of the classification label in the label set. + + \note This index cannot be changed by the user and is handled directly by the label set. + */ + std::size_t index() const { return m_index; } + + /*! + returns the standard index of the classification label (\a e.g. index in the ASPRS standard). + + \note This index is purely user-oriented and is not used by the classification algorithms. + */ + std::size_t standard_index() const { return m_standard_index; } + + /*! + returns the color used to represent the label. + + \note The color is purely user-oriented and is not used by the + classification algorithms. It is not to be confused with a color + attribute embedded in a data set which _can_ be used (see + `Color_channel`). + */ + const CGAL::Color& color() const { return m_color; } + + /// @} + + /// \name Modification + /// @{ + void set_name (const std::string& name) { m_name = name; } - /// \endcond + void set_standard_index(std::size_t idx) { m_standard_index = idx; } + void set_color (const Color& color) { m_color = color; } + + /// @} }; #ifdef DOXYGEN_RUNNING @@ -57,7 +108,7 @@ public: */ class Label_handle { }; #else -typedef boost::shared_ptr