diff --git a/.github/install.sh b/.github/install.sh
new file mode 100755
index 00000000000..047c539ff95
--- /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 zsh
+#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 f9ffde5ab1d..4956425db38 100644
--- a/.github/workflows/build_doc.yml
+++ b/.github/workflows/build_doc.yml
@@ -18,7 +18,11 @@ jobs:
if(asso == 'OWNER' || asso == 'MEMBER') {
const body = context.payload.comment.body
if(body.includes("build:")) {
- return body.replace('build:','')
+ const re = /\/build:(\w+)\s*/;
+ if(re.test(body)){
+ const res = re.exec(body)
+ return res[1];
+ }
}
}
return 'stop'
@@ -38,14 +42,16 @@ 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
if: steps.get_round.outputs.result != 'stop'
run: |
set -x
- sudo apt-get install -y graphviz ssh
- sudo pip install lxml pyquery
+ sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
+ sudo pip install lxml
+ sudo pip install 'pyquery==1.4.1' # it seems to be the last py2 compatible version
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen/build_1_8_13/bin/doxygen
sudo mv doxygen_exe /usr/bin/doxygen
sudo chmod +x /usr/bin/doxygen
@@ -56,10 +62,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
@@ -67,14 +72,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 -a -m "Add ${PR_NUMBER} $ROUND" && git push -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
@@ -84,7 +102,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/checks.yml b/.github/workflows/checks.yml
new file mode 100644
index 00000000000..a28adb0c684
--- /dev/null
+++ b/.github/workflows/checks.yml
@@ -0,0 +1,30 @@
+name: CMake Test Merge Branch
+
+on: [push, pull_request]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2.0.0
+ - name: install dependencies
+ run: |
+ .github/install.sh
+ set -x
+ sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
+ sudo pip install lxml
+ sudo pip install 'pyquery==1.4.1' # it seems to be the last py2 compatible version
+ wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen/build_1_8_13/bin/doxygen
+ sudo mv doxygen_exe /usr/bin/doxygen
+ sudo chmod +x /usr/bin/doxygen
+ git config --global user.email "maxime.gimeno@geometryfactory.com"
+ git config --global user.name "Maxime Gimeno"
+
+ - name: Run checks
+ run: |
+ zsh Scripts/developer_scripts/test_merge_of_branch HEAD
+ #test dependencies
+ bash Scripts/developer_scripts/cgal_check_dependencies.sh --check_headers /usr/bin/doxygen
+
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/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt
index c70c2ab611a..931f14adb53 100644
--- a/AABB_tree/doc/AABB_tree/PackageDescription.txt
+++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt
@@ -35,7 +35,7 @@
\cgalCRPSection{Primitives}
- `CGAL::AABB_triangle_primitive`
- `CGAL::AABB_segment_primitive`
-- `CGAL::AABB_primitive`
+- `CGAL::AABB_primitive`
- `CGAL::AABB_halfedge_graph_segment_primitive`
- `CGAL::AABB_face_graph_triangle_primitive`
*/
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_face_graph_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h
index 6657398435c..6d12a85adef 100644
--- a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h
+++ b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h
@@ -98,7 +98,7 @@ class AABB_face_graph_triangle_primitive
}
public:
- #ifdef DOXYGEN_RUNNING
+#ifdef DOXYGEN_RUNNING
/// \name Types
/// @{
/*!
@@ -122,18 +122,32 @@ public:
If `OneFaceGraphPerTree` is CGAL::Tag_true, constructs a `Shared_data` object from a reference to the polyhedon `graph`.
*/
static unspecified_type construct_shared_data( FaceGraph& graph );
- #else
+#else
typedef typename Base::Id Id;
- #endif
+#endif
typedef typename boost::graph_traits::face_descriptor face_descriptor;
// constructors
+
+#ifdef DOXYGEN_RUNNING
/*!
+ constructs a primitive.
+
\tparam Iterator an input iterator with `Id` as value type.
+
+ If `VertexPointPMap` is the default of the class, an additional constructor
+ is available with `vppm` set to `get(vertex_point, graph)`.
+ */
+ template
+ AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap vppm);
+
+ /*!
constructs a primitive.
If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `get(vertex_point, graph)`.
*/
+ AABB_face_graph_triangle_primitive(face_descriptor fd, const FaceGraph& graph, VertexPointPMap vppm);
+#else
template
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),
@@ -141,18 +155,12 @@ public:
Point_property_map(const_cast(&graph),vppm) )
{}
- /*!
- constructs a primitive.
- If `VertexPointPMap` is the default of the class, an additional constructor
- is available with `vppm` set to `get(vertex_point, graph)`.
- */
AABB_face_graph_triangle_primitive(face_descriptor fd, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(fd, graph, OneFaceGraphPerTree())),
Triangle_property_map(const_cast(&graph),vppm),
Point_property_map(const_cast(&graph),vppm) )
{}
-#ifndef DOXYGEN_RUNNING
template
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph)
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),
diff --git a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h
index 1138376df43..a86ba35caac 100644
--- a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h
+++ b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h
@@ -140,14 +140,27 @@ public:
#endif
typedef typename boost::graph_traits::edge_descriptor edge_descriptor;
+#ifdef DOXYGEN_RUNNING
/*!
constructs a primitive.
+
\tparam Iterator is an input iterator with `Id` as value type.
+
This \ref AABB_tree/AABB_halfedge_graph_edge_example.cpp "example" gives a way to call this constructor
using the insert-by-range method of the class `AABB_tree`.
If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/
+ template
+ AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap vppm);
+
+ /*!
+ constructs a primitive.
+ If `VertexPointPMap` is the default of the class, an additional constructor
+ is available with `vppm` set to `boost::get(vertex_point, graph)`.
+ */
+ AABB_halfedge_graph_segment_primitive(edge_descriptor ed, const HalfedgeGraph& graph, VertexPointPMap vppm);
+#else
template
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
@@ -155,18 +168,12 @@ public:
Point_property_map(const_cast(&graph), vppm) )
{}
- /*!
- constructs a primitive.
- If `VertexPointPMap` is the default of the class, an additional constructor
- is available with `vppm` set to `boost::get(vertex_point, graph)`.
- */
AABB_halfedge_graph_segment_primitive(edge_descriptor ed, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
Segment_property_map(const_cast(&graph), vppm),
Point_property_map(const_cast(&graph), vppm) )
{}
- #ifndef DOXYGEN_RUNNING
template
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph)
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
@@ -177,7 +184,7 @@ public:
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
Segment_property_map(const_cast(&graph)),
Point_property_map(const_cast(&graph)) ){}
- #endif
+#endif
/// \internal
typedef internal::Cstr_shared_data Cstr_shared_data;
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/package_info/Alpha_shapes_3/dependencies b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies
index d6667a72a3d..6a453cfa1e9 100644
--- a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies
+++ b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies
@@ -4,7 +4,6 @@ Arithmetic_kernel
Cartesian_kernel
Circulator
Filtered_kernel
-Geomview
Hash_map
Homogeneous_kernel
Installation
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/AlgebraicCurveInputDialog.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.cpp
new file mode 100644
index 00000000000..c25b21c6d43
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.cpp
@@ -0,0 +1,30 @@
+// Copyright (c) 2020 Tel-Aviv University (Israel).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+//
+// $URL$
+// $Id$
+// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
+
+#include "AlgebraicCurveInputDialog.h"
+#include "ui_AlgebraicCurveInputDialog.h"
+
+AlgebraicCurveInputDialog::AlgebraicCurveInputDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::AlgebraicCurveInputDialog)
+{
+ ui->setupUi(this);
+ ui->lineEdit->setFocus();
+}
+
+AlgebraicCurveInputDialog::~AlgebraicCurveInputDialog()
+{
+ delete ui;
+}
+
+std::string AlgebraicCurveInputDialog::getLineEditText()
+{
+ QString lineEditText = ui->lineEdit->text();
+ return lineEditText.toStdString();
+}
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.h
new file mode 100644
index 00000000000..780dc4c6645
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2020 Tel-Aviv University (Israel).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+//
+// $URL$
+// $Id$
+// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
+
+#ifndef ALGEBRAICCURVEINPUTDIALOG_H
+#define ALGEBRAICCURVEINPUTDIALOG_H
+
+#include
+
+namespace Ui
+{
+class AlgebraicCurveInputDialog;
+}
+
+class AlgebraicCurveInputDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit AlgebraicCurveInputDialog(QWidget *parent = 0);
+ ~AlgebraicCurveInputDialog();
+ std::string getLineEditText();
+ Ui::AlgebraicCurveInputDialog* getUi(){return this->ui;}
+
+private:
+ Ui::AlgebraicCurveInputDialog *ui;
+};
+
+#endif // ALGEBRAICCURVEINPUTDIALOG_H
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.ui b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.ui
new file mode 100644
index 00000000000..3450408f205
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveInputDialog.ui
@@ -0,0 +1,77 @@
+
+
+ AlgebraicCurveInputDialog
+
+
+
+ 0
+ 0
+ 448
+ 173
+
+
+
+ Dialog
+
+
+ -
+
+
+ -
+
+
+ 1
+
+
+ <html><head/><body><p align="justify">Enter the polynomial that represents the curve you would like to insert.</p><p align="justify">For example, to insert a circle of radius 10 centered at (10,10) enter:</p><p align="center"><span style=" color:#000000;">(x-10)^2+(y-10)^2=10^2</span></p></body></html>
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ AlgebraicCurveInputDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ AlgebraicCurveInputDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp
new file mode 100644
index 00000000000..19d3405bb9b
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.cpp
@@ -0,0 +1,174 @@
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+// You can redistribute it and/or modify it under the terms of the GNU
+// General Public License as published by the Free Software Foundation,
+// either version 3 of the License, or (at your option) any later version.
+//
+// Licensees holding a valid commercial license may use this file in
+// accordance with the commercial license agreement provided with the software.
+//
+// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// SPDX-License-Identifier: GPL-3.0+
+//
+// Author(s): Saurabh Singh
+// Ahmed Essam
+
+#include
+#include
+
+#include
+#include
+
+#include "AlgebraicCurveParser.h"
+
+namespace phx = boost::phoenix;
+namespace qi = boost::spirit::qi;
+namespace ascii = boost::spirit::ascii;
+
+template
+struct PolynomialParser : qi::grammar
+{
+ using Self = PolynomialParser;
+ using Traits = CGAL::Polynomial_traits_d;
+ using Coefficient = typename Traits::Innermost_coefficient_type;
+ using Innermost_leading_coefficient =
+ typename Traits::Innermost_leading_coefficient;
+ using Total_degree = typename Traits::Total_degree;
+
+ PolynomialParser() : PolynomialParser::base_type(start)
+ {
+ using qi::_val;
+ using qi::eps;
+
+ for (int i = 0; i < Traits::d; i++)
+ vars[i] = CGAL::shift(Polynomial_d(1), 1, i);
+
+ // { expr = expr } or { expr }
+ start = (expr >> '=' >> expr)[_val = qi::_1 - qi::_2] | expr[_val = qi::_1];
+ // addition and subtraction
+ expr = term[_val = qi::_1] >>
+ *('+' >> term[_val += qi::_1] | '-' >> term[_val -= qi::_1]);
+ // multiplication using *, and implied multiplication as in (x+y)(x+y)
+ term = factor[_val = qi::_1] >>
+ *(('*' >> factor[_val *= qi::_1]) | pow_expr[_val *= qi::_1]);
+ // uniary - and + operators
+ factor = qi::char_('-') >> pow_expr[_val = -qi::_1] |
+ -qi::char_('+') >> pow_expr[_val = qi::_1];
+ // power
+ pow_expr =
+ factor2[_val = qi::_1] >>
+ (('^' >> factor2[_val = phx::bind(&Self::raise, this, _val, qi::_1)]) |
+ eps);
+ // ( expr )
+ factor2 = (('(' >> expr >> ')') | factor3)[_val = qi::_1];
+ // coefficients and variables
+ factor3 =
+ coeff[_val = phx::construct(qi::_1)] | var[_val = qi::_1];
+ coeff = qi::as_string[qi::lexeme[+qi::digit]]
+ [_val = phx::construct(qi::_1)];
+ if (Traits::d == 1)
+ var = qi::char_('x')[_val = vars[0]];
+ else
+ var = qi::char_('x')[_val = vars[0]] | qi::char_('y')[_val = vars[1]];
+ }
+
+ Polynomial_d raise(const Polynomial_d& poly, const Polynomial_d& power)
+ {
+ if (total_degree(power) != 0)
+ {
+ this->error = true;
+ return {};
+ }
+
+ return CGAL::ipower(
+ poly, std::lround(CGAL::to_double(innermost_leading_coefficient(power))));
+ }
+
+ Innermost_leading_coefficient innermost_leading_coefficient;
+ Total_degree total_degree;
+
+ Polynomial_d vars[Traits::d];
+
+ qi::rule start;
+ qi::rule expr;
+ qi::rule term;
+ qi::rule pow_expr;
+ qi::rule factor;
+ qi::rule factor2;
+ qi::rule factor3;
+ qi::rule var;
+ qi::rule coeff;
+
+ bool error = false;
+};
+
+static bool hasValidChars2D(const std::string& expression)
+{
+ const char valid_chars[] = {'x', 'y', '+', '-', '*', '(', ')', '^', '='};
+ return std::all_of(expression.begin(), expression.end(), [&](char c) {
+ return std::isspace(c) || std::isdigit(c) ||
+ std::find(std::begin(valid_chars), std::end(valid_chars), c) !=
+ std::end(valid_chars);
+ });
+}
+
+static bool hasValidChars1D(const std::string& expression)
+{
+ const char valid_chars[] = {'x', '+', '-', '*', '(', ')', '^'};
+ return std::all_of(expression.begin(), expression.end(), [&](char c) {
+ return std::isspace(c) || std::isdigit(c) ||
+ std::find(std::begin(valid_chars), std::end(valid_chars), c) !=
+ std::end(valid_chars);
+ });
+}
+
+static inline bool hasValidChars(const std::string& expression, int dimension)
+{
+ if (dimension == 1)
+ return hasValidChars1D(expression);
+ else
+ return hasValidChars2D(expression);
+}
+
+template
+boost::optional
+AlgebraicCurveParser::operator()(const std::string& expression)
+{
+ using Traits = CGAL::Polynomial_traits_d;
+ using iterator_type = std::string::const_iterator;
+
+ if (!hasValidChars(expression, Traits::d)) return {};
+
+ PolynomialParser pparser;
+ std::string::const_iterator iter = expression.begin();
+ std::string::const_iterator end = expression.end();
+
+ // parsing goes on here
+ Polynomial_d poly;
+ bool r = qi::phrase_parse(iter, end, pparser, ascii::space, poly);
+
+ if (r && iter == end && !pparser.error)
+ return poly;
+ else
+ return {};
+}
+
+#ifdef CGAL_USE_CORE
+// don't want to include ArrangementTypes.h
+// makes compilation slower
+// template class
+// AlgebraicCurveParser;
+// AlgebraicCurveParser;
+#include
+#include
+
+template struct AlgebraicCurveParser<
+ CGAL::Arr_algebraic_segment_traits_2::Polynomial_2>;
+
+template struct AlgebraicCurveParser<
+ typename CGAL::Algebraic_kernel_d_1::Polynomial_1>;
+#endif
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.h
new file mode 100644
index 00000000000..e838f2e3c0d
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/AlgebraicCurveParser.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+// You can redistribute it and/or modify it under the terms of the GNU
+// General Public License as published by the Free Software Foundation,
+// either version 3 of the License, or (at your option) any later version.
+//
+// Licensees holding a valid commercial license may use this file in
+// accordance with the commercial license agreement provided with the software.
+//
+// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// SPDX-License-Identifier: GPL-3.0+
+//
+// Author(s): Saurabh Singh
+// Ahmed Essam
+
+#ifndef ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H
+#define ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H
+
+#include
+#include
+#include
+
+template
+struct AlgebraicCurveParser
+{
+ boost::optional operator()(const std::string& expression);
+};
+
+#endif //ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrTraitsAdaptor.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrTraitsAdaptor.h
new file mode 100644
index 00000000000..a248d8378e7
--- /dev/null
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrTraitsAdaptor.h
@@ -0,0 +1,108 @@
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+//
+// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
+//
+// Author(s): Alex Tsui
+// Ahmed Essam
+
+#ifndef CGAL_ARRANGEMENTS_ARR_TRAITS_ADAPTOR_H
+#define CGAL_ARRANGEMENTS_ARR_TRAITS_ADAPTOR_H
+
+#include "ForwardDeclarations.h"
+
+/**
+ * Support for new ArrTraits should specify types:
+ *
+ * Kernel - a not-necessarily-exact kernel to represent the arrangement
+ * graphically. We'll use the Point_2 type provided by this kernel for
+ * computing distances
+ * Point_2 - the point type used in the particular arrangement
+ * CoordinateType - the coordinate type used by the point type
+ */
+template
+class ArrTraitsAdaptor
+{
+};
+
+template
+class ArrTraitsAdaptor>
+{
+public:
+ typedef Kernel_ Kernel;
+ typedef CGAL::Arr_segment_traits_2 ArrTraits;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename Kernel::FT CoordinateType;
+};
+
+template
+class ArrTraitsAdaptor>
+{
+public:
+ typedef Kernel_ Kernel;
+ typedef CGAL::Arr_linear_traits_2 ArrTraits;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename Kernel::FT CoordinateType;
+};
+
+template
+class ArrTraitsAdaptor>
+{
+public:
+ typedef CGAL::Arr_polyline_traits_2 ArrTraits;
+ typedef typename SegmentTraits::Kernel Kernel;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename Kernel::FT CoordinateType;
+};
+
+template
+class ArrTraitsAdaptor>
+{
+public:
+ typedef CGAL::Arr_conic_traits_2 ArrTraits;
+ typedef AlgKernel Kernel;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename Kernel::FT CoordinateType;
+};
+
+template <
+ typename RatKernel, typename AlgKernel, typename NtTraits,
+ typename BoundingTraits>
+class ArrTraitsAdaptor>
+{
+public:
+ typedef CGAL::Arr_Bezier_curve_traits_2<
+ RatKernel, AlgKernel, NtTraits, BoundingTraits>
+ ArrTraits;
+ typedef RatKernel Kernel;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename Kernel::FT CoordinateType;
+};
+
+template
+class ArrTraitsAdaptor>
+{
+public:
+ typedef Coefficient_ Coefficient;
+ typedef typename CGAL::Arr_algebraic_segment_traits_2 ArrTraits;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename ArrTraits::Algebraic_real_1 CoordinateType;
+ typedef CGAL::Cartesian Kernel;
+};
+
+template
+class ArrTraitsAdaptor<
+ CGAL::Arr_rational_function_traits_2>
+{
+public:
+ typedef typename CGAL::Arr_rational_function_traits_2
+ ArrTraits;
+ typedef typename ArrTraits::Point_2 Point_2;
+ typedef typename ArrTraits::Algebraic_real_1 CoordinateType;
+ typedef CGAL::Cartesian Kernel;
+};
+
+#endif
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementCurveInputCallback.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementCurveInputCallback.h
deleted file mode 100644
index a628687f119..00000000000
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementCurveInputCallback.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
-// All rights reserved.
-//
-// This file is part of CGAL (www.cgal.org).
-//
-// $URL$
-// $Id$
-// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
-//
-// Author(s) : Alex Tsui
-
-#ifndef ARRANGEMENT_CURVE_INPUT_CALLBACK_H
-#define ARRANGEMENT_CURVE_INPUT_CALLBACK_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include "GraphicsViewCurveInput.h"
-#include "Utils.h"
-
-template
-class ArrangementCurveInputCallback:
- public CGAL::Qt::GraphicsViewCurveInput< typename Arr_::Geometry_traits_2 >
-{
-public:
- typedef Arr_ Arrangement;
- typedef ArrTraits Traits;
- typedef CGAL::Qt::GraphicsViewCurveInput< Traits > Superclass;
- typedef typename Arrangement::Vertex_iterator Vertex_iterator;
- typedef typename Traits::Curve_2 Curve_2;
- typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
- typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
- typedef typename Kernel::Point_2 Kernel_point_2;
- typedef typename ArrTraitsAdaptor< Traits >::Point_2 Point_2;
- typedef typename Kernel::Segment_2 Segment_2;
- typedef typename Kernel::FT FT;
-
- ArrangementCurveInputCallback( Arrangement* arrangement_, QObject* parent ):
- Superclass( parent ),
- arrangement( arrangement_ )
- {
- this->snapToVertexStrategy.setArrangement( arrangement_ );
-
- QObject::connect( this, SIGNAL( generate( CGAL::Object ) ),
- this, SLOT( processInput( CGAL::Object ) ) );
- }
-
- void processInput( CGAL::Object o )
- {
- Curve_2 curve;
- X_monotone_curve_2 xcurve;
- if ( CGAL::assign( curve, o ) )
- {
- CGAL::insert( *( this->arrangement ), curve );
- }
-#if 0
- else if ( CGAL::assign( xcurve, o ) )
- {
- std::vector< X_monotone_curve_2 > box;
- box.push_back( xcurve );
- CGAL::insert( *( this->arrangement ), box.begin( ), box.end( ) );
- }
-#endif
-
- Q_EMIT CGAL::Qt::GraphicsViewInput::modelChanged( );
- }
-
- void setScene( QGraphicsScene* scene )
- {
- this->Superclass::setScene( scene );
- this->snapToVertexStrategy.setScene( scene );
- this->snapToGridStrategy.setScene( scene );
- }
-
- void setArrangement( Arrangement* newArr )
- {
- this->arrangement = newArr;
- }
-
-protected:
- Point_2 snapPoint( QGraphicsSceneMouseEvent* event )
- {
- if ( this->snapToGridEnabled )
- {
- return this->snapToGridStrategy.snapPoint( event );
- }
- else if ( this->snappingEnabled )
- {
- return this->snapToVertexStrategy.snapPoint( event );
- }
- else
- {
- Kernel_point_2 p = this->convert( event->scenePos( ) );
- Point_2 res = this->toArrPoint( p );
- return res;
- }
- }
-
- Arrangement* arrangement;
- SnapToArrangementVertexStrategy< Arrangement > snapToVertexStrategy;
- SnapToGridStrategy< typename Arrangement::Geometry_traits_2 >
- snapToGridStrategy;
- Arr_construct_point_2< Traits > toArrPoint;
-}; // class ArrangementCurveInputCallback
-
-#endif // ARRANGEMENT_SEGMENT_INPUT_CALLBACK_H
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.cpp
index cc08513c55b..bc09e4708a5 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.cpp
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,114 +7,49 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#include "ArrangementDemoGraphicsView.h"
#include
+#include
#include
#include
+#include
+#include
+#include
+//! Member function to setup the viewport of the screen
+/*!
+ \param parent a Qwidget pointer to the class
+*/
ArrangementDemoGraphicsView::ArrangementDemoGraphicsView( QWidget* parent ) :
QGraphicsView( parent ),
- showGrid( false ),
- gridSize( 50 ),
- gridColor( ::Qt::black ),
- backgroundColor( ::Qt::white )
+ maxScale( 500000 ),
+ minScale( 0.0002 )
{
- QTransform m( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0 );
- this->setTransform( m );
- this->setBackgroundBrush( QBrush( backgroundColor ) );
+ this->resetTransform();
+ this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
+ this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ this->setMouseTracking( true );
+ this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ // TODO: Make options menu work
+ this->setRenderHint(QPainter::Antialiasing);
}
-void ArrangementDemoGraphicsView::setShowGrid( bool b )
+void ArrangementDemoGraphicsView::paintEvent(QPaintEvent* event)
{
- this->showGrid = b;
+ qreal scale = std::sqrt(std::abs(this->transform().determinant()));
+ if (scale > this->maxScale)
+ this->scale(this->maxScale / scale, this->maxScale / scale);
+ else if (scale < this->minScale)
+ this->scale(this->minScale / scale, this->minScale / scale);
+ QGraphicsView::paintEvent(event);
}
-bool ArrangementDemoGraphicsView::getShowGrid( ) const
+void ArrangementDemoGraphicsView::resetTransform()
{
- return this->showGrid;
-}
-
-void ArrangementDemoGraphicsView::setGridSize( int size )
-{
- this->gridSize = size;
-}
-
-int ArrangementDemoGraphicsView::getGridSize( ) const
-{
- return this->gridSize;
-}
-
-void ArrangementDemoGraphicsView::setGridColor( QColor color )
-{
- this->gridColor = color;
-}
-
-QColor ArrangementDemoGraphicsView::getGridColor( ) const
-{
- return this->gridColor;
-}
-
-void ArrangementDemoGraphicsView::setBackgroundColor( QColor color )
-{
- this->backgroundColor = color;
-}
-
-QColor ArrangementDemoGraphicsView::getBackgroundColor( ) const
-{
- return this->backgroundColor;
-}
-
-void ArrangementDemoGraphicsView::drawForeground( QPainter* painter,
- const QRectF& /* rect */)
-{
- QRectF viewportRect = this->getViewportRect( );
- if ( this->showGrid )
- {
- // compute integer-spaced grid lines
- QVarLengthArray< QLineF, 100 > linesX;
- QVarLengthArray< QLineF, 100 > linesY;
- qreal left =
- int(viewportRect.left()) - (int(viewportRect.left()) % this->gridSize);
- qreal top =
- int(viewportRect.top()) - (int(viewportRect.top()) % this->gridSize);
- for ( qreal x = left; x < viewportRect.right( ); x += this->gridSize )
- {
- linesX.append( QLineF(x, viewportRect.top(), x, viewportRect.bottom()));
- }
- for ( qreal y = top; y < viewportRect.bottom( ); y += this->gridSize )
- {
- linesY.append(QLineF(viewportRect.left( ), y, viewportRect.right(), y));
- }
-
- // set up the painter
- QPen savePen = painter->pen( );
- QPen gridPen( savePen );
- gridPen.setColor( this->gridColor );
- painter->setPen( gridPen );
-
- // draw the grid
- painter->drawLines( linesX.data( ), linesX.size( ) );
- painter->drawLines( linesY.data( ), linesY.size( ) );
-
- // revert the painter
- painter->setPen( savePen );
- }
-}
-
-QRectF ArrangementDemoGraphicsView::getViewportRect( ) const
-{
- QPointF p1 = this->mapToScene( 0, 0 );
- QPointF p2 = this->mapToScene( this->width( ), this->height( ) );
-
- double xmin = (std::min)( p1.x( ), p2.x( ) );
- double xmax = (std::max)( p1.x( ), p2.x( ) );
- double ymin = (std::min)( p1.y( ), p2.y( ) );
- double ymax = (std::max)( p1.y( ), p2.y( ) );
-
- QRectF res = QRectF( QPointF( xmin, ymin ), QPointF( xmax, ymax ) );
-
- return res;
+ this->setTransform({1.0, 0.0, 0.0, -1.0, 0.0, 0.0});
}
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.h
index 2979c911054..f0ec2b3ac1f 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.h
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoGraphicsView.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,7 +7,8 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#ifndef ARRANGEMENT_DEMO_GRAPHICS_VIEW_H
#define ARRANGEMENT_DEMO_GRAPHICS_VIEW_H
@@ -15,29 +16,22 @@
#include
#include
+class QPaintEvent;
+
class ArrangementDemoGraphicsView : public QGraphicsView
{
public:
ArrangementDemoGraphicsView( QWidget* parent = 0 );
- void setShowGrid( bool b );
- bool getShowGrid( ) const;
- void setGridSize( int size );
- int getGridSize( ) const;
- void setGridColor( QColor color );
- QColor getGridColor( ) const;
void setBackgroundColor( QColor color );
QColor getBackgroundColor( ) const;
-
+ void resetTransform();
protected:
- void drawForeground( QPainter* painter, const QRectF& rect );
- QRectF getViewportRect( ) const;
+ void paintEvent(QPaintEvent* event) override;
- bool showGrid;
- int gridSize;
- QColor gridColor;
- QColor backgroundColor;
+ qreal maxScale;
+ qreal minScale;
};
#endif // ARRANGEMENT_DEMO_GRAPHICS_VIEW_H
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.cpp
index d0d4ebf0538..271ceddc01c 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.cpp
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,19 +7,24 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#include "ArrangementDemoPropertiesDialog.h"
#include "ui_ArrangementDemoPropertiesDialog.h"
#include "ArrangementDemoWindow.h"
#include "PropertyValueDelegate.h"
-#include "DeleteCurveMode.h"
#include "ArrangementDemoGraphicsView.h"
+#include "VerticalRayShootCallback.h"
+#include "ArrangementGraphicsItem.h"
+#include "ArrangementDemoTab.h"
+#include "EnvelopeCallback.h"
+#include "GridGraphicsItem.h"
+
ArrangementDemoPropertiesDialog::
-ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_,
- Qt::WindowFlags f ) :
- QDialog( parent_, f ),
+ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ ) :
+ QDialog( parent_ ),
parent( parent_ ),
ui( new Ui::ArrangementDemoPropertiesDialog )
{
@@ -43,30 +48,14 @@ QVariant ArrangementDemoPropertiesDialog::property( int index )
// return user data, if it is set
QVariant myData = item->data( Qt::UserRole );
- /*
- if ( qVariantCanConvert< QColor >( myData ) ||
- qVariantCanConvert< DeleteCurveMode >( myData ) )
- {
- return myData;
- }
- else
- {
- res = item->data( Qt::DisplayRole );
- }
- */
+ res = item->data( Qt::DisplayRole );
- if ( myData.canConvert() ||
- myData.canConvert())
- {
- return myData;
- }
- else
- {
- res = item->data( Qt::DisplayRole );
- }
return res;
}
+//! function to setup the user interface that contains the buttons to draw and manipulate like segments and cones
+/*!
+*/
void ArrangementDemoPropertiesDialog::setupUi( )
{
this->ui->setupUi( this );
@@ -84,8 +73,6 @@ void ArrangementDemoPropertiesDialog::setupUi( )
QTableWidgetItem* envelopeVertexRadiusItem = new QTableWidgetItem;
QTableWidgetItem* verticalRayEdgeColorItem = new QTableWidgetItem;
QTableWidgetItem* verticalRayEdgeWidthItem = new QTableWidgetItem;
- QTableWidgetItem* deleteCurveModeItem = new QTableWidgetItem;
- QTableWidgetItem* gridSizeItem = new QTableWidgetItem;
QTableWidgetItem* gridColorItem = new QTableWidgetItem;
this->ui->tableWidget->setItem( int(EDGE_COLOR_KEY), 0, edgeColorItem );
@@ -93,33 +80,33 @@ void ArrangementDemoPropertiesDialog::setupUi( )
this->ui->tableWidget->setItem( int(EDGE_WIDTH_KEY), 0, edgeWidthItem );
this->ui->tableWidget->setItem( int(VERTEX_RADIUS_KEY), 0, vertexRadiusItem );
this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_COLOR_KEY), 0,
- envelopeEdgeColorItem );
+ envelopeEdgeColorItem );
this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_COLOR_KEY), 0,
- envelopeVertexColorItem );
+ envelopeVertexColorItem );
this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_WIDTH_KEY), 0,
- envelopeEdgeWidthItem );
+ envelopeEdgeWidthItem );
this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_RADIUS_KEY), 0,
- envelopeVertexRadiusItem );
+ envelopeVertexRadiusItem );
this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_COLOR_KEY), 0,
- verticalRayEdgeColorItem );
+ verticalRayEdgeColorItem );
this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_WIDTH_KEY), 0,
- verticalRayEdgeWidthItem );
- this->ui->tableWidget->setItem( int(DELETE_CURVE_MODE_KEY), 0,
- deleteCurveModeItem );
- this->ui->tableWidget->setItem( int(GRID_SIZE_KEY), 0, gridSizeItem );
+ verticalRayEdgeWidthItem );
this->ui->tableWidget->setItem( int(GRID_COLOR_KEY), 0, gridColorItem );
// fill in the items with data
this->updateUi( );
}
+//! Adding a new tab whenever the user creates a new file and updating the menu options accordingly
+/*!
+*/
void ArrangementDemoPropertiesDialog::updateUi( )
{
if ( this->parent == NULL )
{
return;
}
- ArrangementDemoTabBase* currentTab = this->parent->getCurrentTab( );
+ ArrangementDemoTab* currentTab = this->parent->getCurrentTab();
if ( currentTab == NULL )
{
return;
@@ -130,10 +117,10 @@ void ArrangementDemoPropertiesDialog::updateUi( )
return;
}
- ArrangementDemoGraphicsView* view = currentTab->getView( );
EnvelopeCallbackBase* envelopeCallback = currentTab->getEnvelopeCallback( );
VerticalRayShootCallbackBase* verticalRayShootCallback =
- currentTab->getVerticalRayShootCallback( );
+ currentTab->getVerticalRayShootCallback( );
+ GridGraphicsItem* gridGraphicsItem = currentTab->getGridGraphicsItem();
QPen vertexPen = agi->getVerticesPen( );
QPen edgePen = agi->getEdgesPen( );
@@ -143,42 +130,37 @@ void ArrangementDemoPropertiesDialog::updateUi( )
QColor edgeColor = edgePenBrush.color( );
unsigned int edgeWidth = edgePen.width( );
unsigned int vertexRadius = vertexPen.width( );
- unsigned int gridSize = view->getGridSize( );
- QColor gridColor = view->getGridColor( );
+ QColor gridColor = gridGraphicsItem->getAxesColor( );
unsigned int envelopeEdgeWidth = envelopeCallback->getEnvelopeEdgeWidth( );
unsigned int envelopeVertexRadius =
- envelopeCallback->getEnvelopeVertexRadius( );
+ envelopeCallback->getEnvelopeVertexRadius( );
QColor envelopeEdgeColor = envelopeCallback->getEnvelopeEdgeColor( );
QColor envelopeVertexColor = envelopeCallback->getEnvelopeVertexColor( );
unsigned int verticalRayEdgeWidth = verticalRayShootCallback->edgeWidth( );
QColor verticalRayEdgeColor = verticalRayShootCallback->edgeColor( );
QTableWidgetItem* edgeColorItem =
- this->ui->tableWidget->item( int(EDGE_COLOR_KEY), 0 );
+ this->ui->tableWidget->item( int(EDGE_COLOR_KEY), 0 );
QTableWidgetItem* edgeWidthItem =
- this->ui->tableWidget->item( int(EDGE_WIDTH_KEY), 0 );
+ this->ui->tableWidget->item( int(EDGE_WIDTH_KEY), 0 );
QTableWidgetItem* vertexColorItem =
- this->ui->tableWidget->item( int(VERTEX_COLOR_KEY), 0 );
+ this->ui->tableWidget->item( int(VERTEX_COLOR_KEY), 0 );
QTableWidgetItem* vertexRadiusItem =
- this->ui->tableWidget->item( int(VERTEX_RADIUS_KEY), 0 );
- QTableWidgetItem* deleteCurveModeItem =
- this->ui->tableWidget->item( int(DELETE_CURVE_MODE_KEY), 0 );
- QTableWidgetItem* gridSizeItem =
- this->ui->tableWidget->item( int( GRID_SIZE_KEY ), 0 );
+ this->ui->tableWidget->item( int(VERTEX_RADIUS_KEY), 0 );
QTableWidgetItem* gridColorItem =
- this->ui->tableWidget->item( int( GRID_COLOR_KEY ), 0 );
+ this->ui->tableWidget->item( int( GRID_COLOR_KEY ), 0 );
QTableWidgetItem* envelopeEdgeColorItem =
- this->ui->tableWidget->item( int(ENVELOPE_EDGE_COLOR_KEY), 0 );
+ this->ui->tableWidget->item( int(ENVELOPE_EDGE_COLOR_KEY), 0 );
QTableWidgetItem* envelopeEdgeWidthItem =
- this->ui->tableWidget->item( int(ENVELOPE_EDGE_WIDTH_KEY), 0 );
+ this->ui->tableWidget->item( int(ENVELOPE_EDGE_WIDTH_KEY), 0 );
QTableWidgetItem* envelopeVertexColorItem =
- this->ui->tableWidget->item( int(ENVELOPE_VERTEX_COLOR_KEY), 0 );
+ this->ui->tableWidget->item( int(ENVELOPE_VERTEX_COLOR_KEY), 0 );
QTableWidgetItem* envelopeVertexRadiusItem =
- this->ui->tableWidget->item( int(ENVELOPE_VERTEX_RADIUS_KEY), 0 );
+ this->ui->tableWidget->item( int(ENVELOPE_VERTEX_RADIUS_KEY), 0 );
QTableWidgetItem* verticalRayEdgeColorItem =
- this->ui->tableWidget->item( int(VERTICAL_RAY_EDGE_COLOR_KEY), 0 );
+ this->ui->tableWidget->item( int(VERTICAL_RAY_EDGE_COLOR_KEY), 0 );
QTableWidgetItem* verticalRayEdgeWidthItem =
- this->ui->tableWidget->item( int(VERTICAL_RAY_EDGE_WIDTH_KEY), 0 );
+ this->ui->tableWidget->item( int(VERTICAL_RAY_EDGE_WIDTH_KEY), 0 );
// arrangement properties
edgeColorItem->setData( Qt::DisplayRole, edgeColor );
@@ -197,14 +179,14 @@ void ArrangementDemoPropertiesDialog::updateUi( )
envelopeEdgeColorItem->setData( Qt::DisplayRole, envelopeEdgeColor );
envelopeEdgeColorItem->setData( Qt::DecorationRole, envelopeEdgeColor );
envelopeEdgeColorItem->setData( Qt::UserRole,
- QVariant::fromValue( envelopeEdgeColor ) );
+ QVariant::fromValue( envelopeEdgeColor ) );
envelopeEdgeWidthItem->setData( Qt::DisplayRole, envelopeEdgeWidth );
envelopeVertexColorItem->setData( Qt::DisplayRole, envelopeVertexColor );
envelopeVertexColorItem->setData( Qt::DecorationRole, envelopeVertexColor );
envelopeVertexColorItem->setData( Qt::UserRole,
- QVariant::fromValue(envelopeVertexColor));
+ QVariant::fromValue(envelopeVertexColor));
envelopeVertexRadiusItem->setData( Qt::DisplayRole, envelopeVertexRadius );
@@ -212,22 +194,12 @@ void ArrangementDemoPropertiesDialog::updateUi( )
verticalRayEdgeColorItem->setData( Qt::DisplayRole, verticalRayEdgeColor );
verticalRayEdgeColorItem->setData( Qt::DecorationRole, verticalRayEdgeColor );
verticalRayEdgeColorItem->setData( Qt::UserRole,
- QVariant::fromValue(verticalRayEdgeColor));
+ QVariant::fromValue(verticalRayEdgeColor));
verticalRayEdgeWidthItem->setData( Qt::DisplayRole, verticalRayEdgeWidth );
- // delete curve properties
- DeleteCurveMode deleteCurveMode;
- deleteCurveModeItem->setData( Qt::DisplayRole,
- DeleteCurveMode::ToString( deleteCurveMode ) );
- deleteCurveModeItem->setData( Qt::UserRole,
- QVariant::fromValue( deleteCurveMode ) );
-
// grid properties
- gridSizeItem->setData( Qt::DisplayRole, gridSize );
-
gridColorItem->setData( Qt::DisplayRole, gridColor );
gridColorItem->setData( Qt::DecorationRole, gridColor );
gridColorItem->setData( Qt::UserRole, QVariant::fromValue( gridColor ) );
-
}
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.h
index dd6158edd48..0db3916ef8f 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.h
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,7 +7,8 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#ifndef ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H
#define ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H
@@ -27,23 +28,20 @@ class ArrangementDemoPropertiesDialog : public QDialog
public:
// keep this in order with the ui layout
enum PropertyKey {
- EDGE_COLOR_KEY,
- EDGE_WIDTH_KEY,
- VERTEX_COLOR_KEY,
- VERTEX_RADIUS_KEY,
- ENVELOPE_EDGE_COLOR_KEY,
- ENVELOPE_EDGE_WIDTH_KEY,
- ENVELOPE_VERTEX_COLOR_KEY,
- ENVELOPE_VERTEX_RADIUS_KEY,
- VERTICAL_RAY_EDGE_COLOR_KEY,
- VERTICAL_RAY_EDGE_WIDTH_KEY,
- DELETE_CURVE_MODE_KEY,
- GRID_SIZE_KEY,
- GRID_COLOR_KEY
+ EDGE_COLOR_KEY, /*!< color key */
+ EDGE_WIDTH_KEY, /*!< width key */
+ VERTEX_COLOR_KEY, /*!< vertex color */
+ VERTEX_RADIUS_KEY, /*!< vertex radius */
+ ENVELOPE_EDGE_COLOR_KEY, /*!< envelope color */
+ ENVELOPE_EDGE_WIDTH_KEY, /*!< envelope size */
+ ENVELOPE_VERTEX_COLOR_KEY, /*!< envelope vertex color */
+ ENVELOPE_VERTEX_RADIUS_KEY, /*!< color key */
+ VERTICAL_RAY_EDGE_COLOR_KEY, /*!< shooting ray color */
+ VERTICAL_RAY_EDGE_WIDTH_KEY, /*!< shooting ray size */
+ GRID_COLOR_KEY /*!< color of the grid */
};
- ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ = 0,
- Qt::WindowFlags f = Qt::WindowType(0));
+ ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ = 0 );
QVariant property( int index );
protected:
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.ui b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.ui
index 825195306d2..e3808f40a2f 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.ui
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoPropertiesDialog.ui
@@ -78,16 +78,6 @@
Vertical Ray Edge Width
-
-
- Delete Curve Mode
-
-
-
-
- Grid Size
-
-
Grid Color
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp
index 83eb31ce518..80141270320 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,95 +7,400 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#include "ArrangementDemoTab.h"
+#include "ArrangementDemoGraphicsView.h"
+#include "ArrangementGraphicsItem.h"
+#include "DeleteCurveCallback.h"
+#include "EnvelopeCallback.h"
+#include "FillFaceCallback.h"
+#include "GraphicsViewCurveInput.h"
+#include "GridGraphicsItem.h"
+#include "MergeEdgeCallback.h"
+#include "PointLocationCallback.h"
+#include "PointSnapper.h"
+#include "SplitEdgeCallback.h"
+#include "Utils/Utils.h"
+#include "VerticalRayShootCallback.h"
+
+#include
#include
+#include
-ArrangementDemoTabBase::ArrangementDemoTabBase( QWidget* parent ) :
- QWidget( parent ),
- graphicsView( new ArrangementDemoGraphicsView( this ) ),
- scene( new QGraphicsScene( -100, -100, 100, 100 ) ),
- layout( new QGridLayout( this ) ),
- arrangementGraphicsItem( NULL ),
- curveInputCallback( NULL ),
- deleteCurveCallback( NULL ),
- pointLocationCallback( NULL ),
- verticalRayShootCallback( NULL ),
- mergeEdgeCallback( NULL ),
- splitEdgeCallback( NULL ),
- envelopeCallback( NULL ),
- fillFaceCallback( NULL )
+
+ArrangementDemoTab::ArrangementDemoTab(
+ QWidget* parent, demo_types::TraitsType tt, CGAL::Object arrangement_) :
+ QWidget(parent),
+ GraphicsSceneMixin(new QGraphicsScene()),
+ graphicsView(new ArrangementDemoGraphicsView(this)),
+ layout(new QGridLayout(this)),
+ navigation(std::make_unique()),
+ activeCallback(nullptr), arrangementGraphicsItem(nullptr),
+ gridGraphicsItem(nullptr), ttype(tt), arrangement(arrangement_)
{
- this->setupUi( );
+ this->setupUi();
+ if (!this->arrangement) this->initArrangement();
+ this->initComponents();
+ this->setupCallbacks();
}
-ArrangementDemoTabBase::~ArrangementDemoTabBase( )
+ArrangementDemoTab::~ArrangementDemoTab()
{
+ this->unhookCallbacks();
+ deleteArrangement(this->traitsType(), this->getArrangement());
}
-void ArrangementDemoTabBase::setupUi( )
+void ArrangementDemoTab::setupUi()
{
- this->layout->addWidget( this->graphicsView, 0, 0, 1, 1 );
- this->graphicsView->setScene( this->scene );
- this->graphicsView->setMouseTracking( true );
+ auto scene = this->getScene();
+
+ this->layout->addWidget(this->graphicsView, 0, 0);
+ this->graphicsView->setScene(scene);
+
+ double MAX_WIDTH = (std::numeric_limits::max)() / 1048576;
+
+ double xymin = -MAX_WIDTH / 2;
+ double wh = MAX_WIDTH;
+ scene->setSceneRect(xymin, xymin, wh, wh);
+
+ this->getView()->installEventFilter(this->navigation.get());
+ this->getView()->viewport()->installEventFilter(this->navigation.get());
}
-QGraphicsScene* ArrangementDemoTabBase::getScene( ) const
-{
- return this->scene;
-}
-
-ArrangementDemoGraphicsView* ArrangementDemoTabBase::getView( ) const
+QGraphicsView* ArrangementDemoTab::getView() const
{
return this->graphicsView;
}
CGAL::Qt::ArrangementGraphicsItemBase*
-ArrangementDemoTabBase::getArrangementGraphicsItem( ) const
+ArrangementDemoTab::getArrangementGraphicsItem() const
{
return this->arrangementGraphicsItem;
}
+GridGraphicsItem* ArrangementDemoTab::getGridGraphicsItem() const
+{
+ return this->gridGraphicsItem;
+}
+
+void ArrangementDemoTab::showGrid(bool val)
+{
+ this->gridGraphicsItem->setVisible(val);
+}
+
+void ArrangementDemoTab::setSnapToGrid(bool val)
+{
+ this->snapper->setSnapToGrid(val);
+}
+
+void ArrangementDemoTab::setSnapToArrangement(bool val)
+{
+ this->snapper->setSnapToArrangement(val);
+}
+
+bool ArrangementDemoTab::isSnapToGridEnabled()
+{
+ return this->snapper->isSnapToGridEnabled();
+}
+
+bool ArrangementDemoTab::isSnapToArrangementEnabled()
+{
+ return this->snapper->isSnapToArrangementEnabled();
+}
+
+bool ArrangementDemoTab::isGridVisible()
+{
+ return this->gridGraphicsItem->isVisible();
+}
+
CGAL::Qt::GraphicsViewCurveInputBase*
-ArrangementDemoTabBase::getCurveInputCallback( ) const
+ArrangementDemoTab::getCurveInputCallback() const
{
- return this->curveInputCallback;
+ return this->curveInputCallback.get();
}
-CGAL::Qt::Callback* ArrangementDemoTabBase::getDeleteCurveCallback( ) const
+CGAL::Qt::Callback* ArrangementDemoTab::getDeleteCurveCallback() const
{
- return this->deleteCurveCallback;
+ return this->deleteCurveCallback.get();
}
-CGAL::Qt::Callback* ArrangementDemoTabBase::getPointLocationCallback( ) const
+PointLocationCallbackBase*
+ArrangementDemoTab::getPointLocationCallback() const
{
- return this->pointLocationCallback;
+ return this->pointLocationCallback.get();
}
VerticalRayShootCallbackBase*
-ArrangementDemoTabBase::getVerticalRayShootCallback( ) const
+ArrangementDemoTab::getVerticalRayShootCallback() const
{
- return this->verticalRayShootCallback;
+ return this->verticalRayShootCallback.get();
}
-CGAL::Qt::Callback* ArrangementDemoTabBase::getMergeEdgeCallback( ) const
+MergeEdgeCallbackBase* ArrangementDemoTab::getMergeEdgeCallback() const
{
- return this->mergeEdgeCallback;
+ return this->mergeEdgeCallback.get();
}
-SplitEdgeCallbackBase* ArrangementDemoTabBase::getSplitEdgeCallback( ) const
+SplitEdgeCallbackBase* ArrangementDemoTab::getSplitEdgeCallback() const
{
- return this->splitEdgeCallback;
+ return this->splitEdgeCallback.get();
}
-EnvelopeCallbackBase* ArrangementDemoTabBase::getEnvelopeCallback( ) const
+EnvelopeCallbackBase* ArrangementDemoTab::getEnvelopeCallback() const
{
- return this->envelopeCallback;
+ return this->envelopeCallback.get();
}
-FillFaceCallbackBase* ArrangementDemoTabBase::getFillFaceCallback( ) const
+FillFaceCallbackBase* ArrangementDemoTab::getFillFaceCallback() const
{
- return this->fillFaceCallback;
+ return this->fillFaceCallback.get();
+}
+
+auto ArrangementDemoTab::getFillFaceColor() const -> QColor
+{
+ return this->fillFaceCallback->getColor();
+}
+
+void ArrangementDemoTab::setFillFaceColor(QColor color)
+{
+ this->fillFaceCallback->setColor(color);
+}
+
+CGAL::Qt::GraphicsViewNavigation*
+ArrangementDemoTab::getGraphicsViewNavigation() const
+{
+ return this->navigation.get();
+}
+
+void ArrangementDemoTab::activateCurveInputCallback(
+ CGAL::Qt::CurveType type)
+{
+ this->unhookCallbacks();
+
+ this->curveInputCallback->setCurveType(type);
+ this->getScene()->installEventFilter(this->curveInputCallback.get());
+ this->activeCallback = this->curveInputCallback.get();
+}
+
+void ArrangementDemoTab::showLowerEnvelope(bool show)
+{
+ this->envelopeCallback->showLowerEnvelope(show);
+ this->update();
+}
+
+void ArrangementDemoTab::showUpperEnvelope(bool show)
+{
+ this->envelopeCallback->showUpperEnvelope(show);
+ this->update();
+}
+
+bool ArrangementDemoTab::isUpperEnvelopeShown()
+{
+ return this->envelopeCallback->isUpperEnvelopeShown();
+}
+
+bool ArrangementDemoTab::isLowerEnvelopeShown()
+{
+ return this->envelopeCallback->isLowerEnvelopeShown();
+}
+
+void ArrangementDemoTab::unhookCallbacks()
+{
+ if (this->activeCallback)
+ {
+ this->getScene()->removeEventFilter(this->activeCallback);
+
+ activeCallback->reset();
+ this->activeCallback = nullptr;
+ }
+}
+
+void ArrangementDemoTab::unhookAndInstallEventFilter(
+ CGAL::Qt::Callback* obj)
+{
+ this->unhookCallbacks();
+ this->getScene()->installEventFilter(obj);
+ this->activeCallback = obj;
+}
+
+void ArrangementDemoTab::activateDeleteCurveCallback()
+{
+ // TODO: Create different button for modes of delete
+ if (
+ this->activeCallback ==
+ static_cast(this->deleteCurveCallback.get()))
+ {
+ auto deleteMode = this->deleteCurveCallback->getDeleteMode();
+ if (deleteMode == DeleteMode::DeleteOriginatingCuve)
+ this->deleteCurveCallback->setDeleteMode(DeleteMode::DeleteEdge);
+ else
+ this->deleteCurveCallback->setDeleteMode(
+ DeleteMode::DeleteOriginatingCuve);
+ }
+ else
+ {
+ this->unhookAndInstallEventFilter(this->deleteCurveCallback.get());
+ }
+}
+
+void ArrangementDemoTab::activatePointLocationCallback()
+{
+ this->unhookAndInstallEventFilter(this->pointLocationCallback.get());
+}
+
+void ArrangementDemoTab::activateVerticalRayShootCallback(bool shootingUp)
+{
+ this->verticalRayShootCallback->setShootingUp(shootingUp);
+ this->unhookAndInstallEventFilter(this->verticalRayShootCallback.get());
+}
+
+void ArrangementDemoTab::activateMergeEdgeCallback()
+{
+ this->unhookAndInstallEventFilter(this->mergeEdgeCallback.get());
+}
+
+void ArrangementDemoTab::activateSplitEdgeCallback()
+{
+ this->unhookAndInstallEventFilter(this->splitEdgeCallback.get());
+}
+
+void ArrangementDemoTab::activateFillFaceCallback()
+{
+ this->unhookAndInstallEventFilter(this->fillFaceCallback.get());
+}
+
+void ArrangementDemoTab::updatePreferences(const Preferences& pref)
+{
+ auto agi = this->getArrangementGraphicsItem();
+ auto envelopeCallback = this->getEnvelopeCallback();
+ auto verticalRayShootCallback = this->getVerticalRayShootCallback();
+ auto splitEdgeCallback = this->getSplitEdgeCallback();
+ auto gridGraphicsItem = this->getGridGraphicsItem();
+
+ QPen edgesPen(QBrush(pref.edgeColor), pref.edgeWidth);
+ edgesPen.setCosmetic(true);
+ QPen verticesPen(QBrush(pref.vertexColor), pref.vertexRadius);
+ verticesPen.setCosmetic(true);
+ agi->setEdgesPen(edgesPen);
+ agi->setVerticesPen(verticesPen);
+ gridGraphicsItem->setAxesColor(pref.axesColor);
+ gridGraphicsItem->setGridColor(pref.gridColor);
+ envelopeCallback->setEnvelopeEdgeColor(pref.envelopeEdgeColor);
+ envelopeCallback->setEnvelopeEdgeWidth(pref.envelopeEdgeWidth);
+ envelopeCallback->setEnvelopeVertexColor(pref.envelopeVertexColor);
+ envelopeCallback->setEnvelopeVertexRadius(pref.envelopeVertexRadius);
+ verticalRayShootCallback->setEdgeColor(pref.verticalRayEdgeColor);
+ verticalRayShootCallback->setEdgeWidth(pref.verticalRayEdgeWidth);
+ splitEdgeCallback->setColor(pref.edgeColor);
+
+ Q_EMIT modelChanged();
+}
+
+demo_types::TraitsType ArrangementDemoTab::traitsType() const
+{
+ return ttype;
+}
+
+void ArrangementDemoTab::initArrangement()
+{
+ this->arrangement = createArrangement(this->traitsType());
+}
+
+void ArrangementDemoTab::initComponents()
+{
+ auto scene = this->getScene();
+
+ this->gridGraphicsItem = new GridGraphicsItem();
+
+ this->snapper = std::unique_ptr(PointSnapperBase::create(
+ this->traitsType(), scene, this->gridGraphicsItem, this->getArrangement()));
+
+ this->curveInputCallback =
+ std::unique_ptr(
+ CGAL::Qt::GraphicsViewCurveInputBase::create(
+ this->traitsType(), this->getArrangement(), this, scene));
+ this->deleteCurveCallback =
+ std::unique_ptr(DeleteCurveCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->pointLocationCallback = std::unique_ptr(
+ PointLocationCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->verticalRayShootCallback =
+ std::unique_ptr(
+ VerticalRayShootCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->mergeEdgeCallback =
+ std::unique_ptr(MergeEdgeCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->splitEdgeCallback =
+ std::unique_ptr(SplitEdgeCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->envelopeCallback =
+ std::unique_ptr(EnvelopeCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->fillFaceCallback =
+ std::unique_ptr(FillFaceCallbackBase::create(
+ this->traitsType(), this->getArrangement(), this));
+ this->arrangementGraphicsItem = CGAL::Qt::ArrangementGraphicsItemBase::create(
+ this->traitsType(), this->getArrangement());
+
+ this->curveInputCallback->setPointSnapper(snapper.get());
+ this->splitEdgeCallback->setPointSnapper(snapper.get());
+
+ scene->addItem(this->arrangementGraphicsItem);
+ scene->addItem(this->gridGraphicsItem);
+
+ this->arrangementGraphicsItem->setScene(scene);
+ this->curveInputCallback->setScene(scene);
+ this->deleteCurveCallback->setScene(scene);
+ this->pointLocationCallback->setScene(scene);
+ this->verticalRayShootCallback->setScene(scene);
+ this->mergeEdgeCallback->setScene(scene);
+ this->splitEdgeCallback->setScene(scene);
+ this->envelopeCallback->setScene(scene);
+ this->fillFaceCallback->setScene(scene);
+}
+
+void ArrangementDemoTab::setupCallbacks()
+{
+ // set up callbacks
+ QObject::connect(
+ this->curveInputCallback.get(), SIGNAL(modelChanged()), this,
+ SIGNAL(modelChanged()));
+ QObject::connect(
+ this->deleteCurveCallback.get(), SIGNAL(modelChanged()), this,
+ SIGNAL(modelChanged()));
+ QObject::connect(
+ this->fillFaceCallback.get(), SIGNAL(modelChanged()), this,
+ SIGNAL(modelChanged()));
+ QObject::connect(
+ this, SIGNAL(modelChanged()), this->arrangementGraphicsItem,
+ SLOT(modelChanged()));
+ QObject::connect(
+ this, SIGNAL(modelChanged()), this->envelopeCallback.get(),
+ SLOT(slotModelChanged()));
+ QObject::connect(
+ this->splitEdgeCallback.get(), SIGNAL(modelChanged()), this,
+ SIGNAL(modelChanged()));
+ QObject::connect(
+ this->mergeEdgeCallback.get(), SIGNAL(modelChanged()), this,
+ SIGNAL(modelChanged()));
+}
+
+CGAL::Object ArrangementDemoTab::getArrangement() const
+{
+ return this->arrangement;
+}
+
+void ArrangementDemoTab::adjustViewport()
+{
+ this->graphicsView->resetTransform();
+ this->graphicsView->fitInView(
+ this->arrangementGraphicsItem->getInterestingViewport(),
+ Qt::KeepAspectRatio);
+
+ Q_EMIT modelChanged();
}
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.h
index aab9b72352c..54ece4964c2 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.h
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 Tel-Aviv University (Israel).
+// Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@@ -7,195 +7,148 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Alex Tsui
+// Author(s): Alex Tsui
+// Ahmed Essam
#ifndef ARRANGEMENT_DEMO_TAB_H
#define ARRANGEMENT_DEMO_TAB_H
+#include "GraphicsSceneMixin.h"
+#include
#include
+#include
+#include
-#include "ArrangementGraphicsItem.h"
-#include "ArrangementDemoGraphicsView.h"
-#include "ArrangementCurveInputCallback.h"
-#include "DeleteCurveCallback.h"
-#include "PointLocationCallback.h"
-#include "VerticalRayShootCallback.h"
-#include "MergeEdgeCallback.h"
-#include "SplitEdgeCallback.h"
-#include "EnvelopeCallback.h"
-#include "FillFaceCallback.h"
-
+class QGraphicsScene;
class QGridLayout;
+class ArrangementDemoGraphicsView;
+class VerticalRayShootCallbackBase;
+class EnvelopeCallbackBase;
+class FillFaceCallbackBase;
+class SplitEdgeCallbackBase;
+class MergeEdgeCallbackBase;
+class DeleteCurveCallbackBase;
+class PointLocationCallbackBase;
+class GridGraphicsItem;
+class PointSnapperBase;
-class ArrangementDemoTabBase : public QWidget
+namespace CGAL
+{
+namespace Qt
+{
+class Callback;
+class ArrangementGraphicsItemBase;
+class ArrangementGraphicsItemBase;
+class GraphicsViewCurveInputBase;
+class GraphicsViewNavigation;
+enum class CurveType;
+} // namespace Qt
+} // namespace CGAL
+
+namespace demo_types
+{
+enum class TraitsType;
+}
+
+class ArrangementDemoTab : public QWidget, public GraphicsSceneMixin
{
Q_OBJECT
- Q_SIGNALS:
+Q_SIGNALS:
void modelChanged( );
public:
- ArrangementDemoTabBase( QWidget* parent );
- virtual ~ArrangementDemoTabBase( );
+ ArrangementDemoTab(
+ QWidget* parent, demo_types::TraitsType tt, CGAL::Object arrangement_);
- virtual QGraphicsScene* getScene( ) const;
- virtual ArrangementDemoGraphicsView* getView( ) const;
+ virtual ~ArrangementDemoTab();
- virtual CGAL::Qt::ArrangementGraphicsItemBase* getArrangementGraphicsItem( )
- const;
- virtual CGAL::Qt::GraphicsViewCurveInputBase* getCurveInputCallback( ) const;
- virtual CGAL::Qt::Callback* getDeleteCurveCallback( ) const;
- virtual CGAL::Qt::Callback* getPointLocationCallback( ) const;
- virtual VerticalRayShootCallbackBase* getVerticalRayShootCallback( ) const;
- virtual CGAL::Qt::Callback* getMergeEdgeCallback( ) const;
- virtual SplitEdgeCallbackBase* getSplitEdgeCallback( ) const;
- virtual EnvelopeCallbackBase* getEnvelopeCallback( ) const;
- virtual FillFaceCallbackBase* getFillFaceCallback( ) const;
+ CGAL::Object getArrangement() const;
+ demo_types::TraitsType traitsType() const;
+
+ QGraphicsView* getView() const;
+ void showGrid(bool);
+ bool isGridVisible();
+ void setSnapToGrid(bool);
+ void setSnapToArrangement(bool);
+ bool isSnapToGridEnabled();
+ bool isSnapToArrangementEnabled();
+ void adjustViewport();
+
+ auto getArrangementGraphicsItem() const
+ -> CGAL::Qt::ArrangementGraphicsItemBase*;
+ auto getGridGraphicsItem() const -> GridGraphicsItem*;
+ auto getCurveInputCallback() const -> CGAL::Qt::GraphicsViewCurveInputBase*;
+ auto getDeleteCurveCallback() const -> CGAL::Qt::Callback*;
+ auto getPointLocationCallback() const -> PointLocationCallbackBase*;
+ auto getVerticalRayShootCallback() const -> VerticalRayShootCallbackBase*;
+ auto getMergeEdgeCallback() const -> MergeEdgeCallbackBase*;
+ auto getSplitEdgeCallback() const -> SplitEdgeCallbackBase*;
+ auto getEnvelopeCallback() const -> EnvelopeCallbackBase*;
+ auto getFillFaceCallback() const -> FillFaceCallbackBase*;
+ auto getGraphicsViewNavigation() const -> CGAL::Qt::GraphicsViewNavigation*;
+ auto getFillFaceColor() const -> QColor;
+ void setFillFaceColor(QColor);
+ void activateCurveInputCallback(CGAL::Qt::CurveType);
+ void activateDeleteCurveCallback();
+ void activatePointLocationCallback();
+ void activateVerticalRayShootCallback(bool);
+ void activateMergeEdgeCallback();
+ void activateSplitEdgeCallback();
+ void activateEnvelopeCallback();
+ void activateFillFaceCallback();
+ void activatePanCallback();
+ void showLowerEnvelope(bool);
+ void showUpperEnvelope(bool);
+ bool isUpperEnvelopeShown();
+ bool isLowerEnvelopeShown();
+ void unhookCallbacks();
+
+ struct Preferences
+ {
+ QColor edgeColor = {};
+ QColor vertexColor = {};
+ QColor envelopeEdgeColor = {};
+ QColor envelopeVertexColor = {};
+ QColor verticalRayEdgeColor = {};
+ QColor axesColor = {};
+ QColor gridColor = {};
+ uint32_t edgeWidth = 0;
+ uint32_t vertexRadius = 0;
+ uint32_t envelopeEdgeWidth = 0;
+ uint32_t envelopeVertexRadius = 0;
+ uint32_t verticalRayEdgeWidth = 0;
+ };
+ void updatePreferences(const Preferences&);
protected:
+ void initArrangement();
+ void initComponents();
+ void setupCallbacks();
+
virtual void setupUi( );
+ void unhookAndInstallEventFilter(CGAL::Qt::Callback*);
ArrangementDemoGraphicsView* graphicsView;
- QGraphicsScene* scene;
QGridLayout* layout;
- CGAL::Qt::ArrangementGraphicsItemBase* arrangementGraphicsItem;
- CGAL::Qt::GraphicsViewCurveInputBase* curveInputCallback;
- CGAL::Qt::Callback* deleteCurveCallback;
- CGAL::Qt::Callback* pointLocationCallback;
- VerticalRayShootCallbackBase* verticalRayShootCallback;
- CGAL::Qt::Callback* mergeEdgeCallback;
- SplitEdgeCallbackBase* splitEdgeCallback;
- EnvelopeCallbackBase* envelopeCallback;
- FillFaceCallbackBase* fillFaceCallback;
+ std::unique_ptr curveInputCallback;
+ std::unique_ptr deleteCurveCallback;
+ std::unique_ptr pointLocationCallback;
+ std::unique_ptr verticalRayShootCallback;
+ std::unique_ptr