Merge branch 'master' into gsoc2020-Surface_mesh_topology-Simplicity-johnmave126

This commit is contained in:
Guillaume Damiand 2021-01-18 11:24:33 +01:00
commit 3ef8ea445c
2062 changed files with 182941 additions and 52390 deletions

12
.github/install.sh vendored Executable file
View File

@ -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

13
.github/test.sh vendored Executable file
View File

@ -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))}

111
.github/workflows/build_doc.yml vendored Normal file
View File

@ -0,0 +1,111 @@
name: Documentation
on:
issue_comment:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
id: get_round
with:
result-encoding: string
script: |
const asso = context.payload.comment.author_association
if(asso == 'OWNER' || asso == 'MEMBER') {
const body = context.payload.comment.body
if(body.includes("build:")) {
const re = /\/build:(\w+)\s*/;
if(re.test(body)){
const res = re.exec(body)
return res[1];
}
}
}
return 'stop'
- uses: actions/github-script@v3
if: steps.get_round.outputs.result != 'stop'
id: get_pr_number
with:
result-encoding: string
script: |
//get pullrequest url
const pr_number = context.payload.issue.number
return pr_number
- uses: actions/checkout@v2
name: "checkout branch"
if: steps.get_round.outputs.result != 'stop'
with:
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 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: configure all
if: steps.get_round.outputs.result != 'stop'
run: |
set -ex
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
- name: Build and Upload Doc
if: steps.get_round.outputs.result != 'stop'
run: |
set -ex
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
ROUND=${{ steps.get_round.outputs.result }}
wget --no-verbose cgal.github.io -O tmp.html
if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html; then
#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
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 "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
mv tmp.html index.html
git add ${PR_NUMBER}/$ROUND && git commit -q --amend -m "base commit" && git push -q -f -u origin master
else
exit 1
fi
- name: Post address
uses: actions/github-script@v3
if: steps.get_round.outputs.result != 'stop'
with:
script: |
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",
issue_number: ${{ github.event.issue.number }},
body: address
});

30
.github/workflows/checks.yml vendored Normal file
View File

@ -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

32
.github/workflows/delete_doc.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Documentation Removal
on:
pull_request_target:
types: [closed, removed]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.0.0
- name: delete directory
run: |
set -x
git config --global user.email "maxime.gimeno@geometryfactory.com"
git config --global user.name "Maxime Gimeno"
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 || true
if [ -n "$(diff -q ./index.html ./tmp.html)" ]; then
mv tmp.html index.html
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

37
.github/workflows/demo.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Test Polyhedron Demo
on: [push, 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 }}

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
/*build* /*build*
/*/*/*/build /*/*/*/build
/*/*/*/VC*
/*/*/*/GCC
AABB_tree/demo/AABB_tree/AABB_demo AABB_tree/demo/AABB_tree/AABB_demo
AABB_tree/demo/AABB_tree/Makefile AABB_tree/demo/AABB_tree/Makefile
AABB_tree/examples/AABB_tree/*.kdev* AABB_tree/examples/AABB_tree/*.kdev*

View File

@ -1,5 +1,5 @@
language: cpp language: cpp
dist: xenial dist: bionic
sudo: required sudo: required
git: git:
depth: 3 depth: 3
@ -23,42 +23,41 @@ env:
- PACKAGE='Homogeneous_kernel Hyperbolic_triangulation_2 Inscribed_areas ' - PACKAGE='Homogeneous_kernel Hyperbolic_triangulation_2 Inscribed_areas '
- PACKAGE='Installation Interpolation Intersections_2 ' - PACKAGE='Installation Interpolation Intersections_2 '
- PACKAGE='Intersections_3 Interval_skip_list Interval_support ' - PACKAGE='Intersections_3 Interval_skip_list Interval_support '
- PACKAGE='Inventor Jet_fitting_3 Kernel_23 ' - PACKAGE='Jet_fitting_3 Kernel_23 Kernel_d '
- PACKAGE='Kernel_d LEDA Linear_cell_complex ' - PACKAGE='LEDA Linear_cell_complex MacOSX '
- PACKAGE='MacOSX Maintenance Matrix_search ' - PACKAGE='Maintenance Matrix_search Mesh_2 '
- PACKAGE='Mesh_2 Mesh_3 Mesher_level ' - PACKAGE='Mesh_3 Mesher_level Minkowski_sum_2 '
- PACKAGE='Minkowski_sum_2 Minkowski_sum_3 Modifier ' - PACKAGE='Minkowski_sum_3 Modifier Modular_arithmetic '
- PACKAGE='Modular_arithmetic Nef_2 Nef_3 ' - PACKAGE='Nef_2 Nef_3 Nef_S2 '
- PACKAGE='Nef_S2 NewKernel_d Number_types ' - PACKAGE='NewKernel_d Number_types OpenNL '
- PACKAGE='OpenNL Optimal_bounding_box Optimal_transportation_reconstruction_2 ' - PACKAGE='Optimal_bounding_box Optimal_transportation_reconstruction_2 Optimisation_basic '
- PACKAGE='Optimisation_basic Partition_2 Periodic_2_triangulation_2 ' - PACKAGE='Partition_2 Periodic_2_triangulation_2 Periodic_3_mesh_3 '
- PACKAGE='Periodic_3_mesh_3 Periodic_3_triangulation_3 Periodic_4_hyperbolic_triangulation_2 ' - PACKAGE='Periodic_3_triangulation_3 Periodic_4_hyperbolic_triangulation_2 Point_set_2 '
- PACKAGE='Point_set_2 Point_set_3 Point_set_processing_3 ' - PACKAGE='Point_set_3 Point_set_processing_3 Poisson_surface_reconstruction_3 '
- PACKAGE='Poisson_surface_reconstruction_3 Polygon Polygon_mesh_processing ' - PACKAGE='Polygon Polygon_mesh_processing Polygonal_surface_reconstruction '
- PACKAGE='Polygonal_surface_reconstruction Polyhedron Polyhedron_IO ' - PACKAGE='Polyhedron Polyline_simplification_2 Polynomial '
- PACKAGE='Polyline_simplification_2 Polynomial Polytope_distance_d ' - PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL '
- PACKAGE='Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools ' - PACKAGE='Profiling_tools Property_map QP_solver '
- PACKAGE='Property_map QP_solver Random_numbers ' - PACKAGE='Random_numbers Ridges_3 STL_Extension '
- PACKAGE='Ridges_3 STL_Extension Scale_space_reconstruction_3 ' - PACKAGE='Scale_space_reconstruction_3 Scripts SearchStructures '
- PACKAGE='Scripts SearchStructures Segment_Delaunay_graph_2 ' - PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 '
- PACKAGE='Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 Shape_detection ' - PACKAGE='Shape_detection Skin_surface_3 Snap_rounding_2 '
- PACKAGE='Skin_surface_3 Snap_rounding_2 Solver_interface ' - PACKAGE='Solver_interface Spatial_searching Spatial_sorting '
- PACKAGE='Spatial_searching Spatial_sorting Straight_skeleton_2 ' - PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support '
- PACKAGE='Stream_lines_2 Stream_support Subdivision_method_3 ' - PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_approximation '
- PACKAGE='Surface_mesh Surface_mesh_approximation Surface_mesh_deformation ' - PACKAGE='Surface_mesh_deformation Surface_mesh_parameterization Surface_mesh_segmentation '
- PACKAGE='Surface_mesh_parameterization Surface_mesh_segmentation Surface_mesh_shortest_path ' - PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization '
- PACKAGE='Surface_mesh_simplification Surface_mesh_skeletonization Surface_mesh_topology ' - PACKAGE='Surface_mesh_topology Surface_mesher Surface_sweep_2 '
- PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 ' - PACKAGE='TDS_2 TDS_3 Testsuite '
- PACKAGE='TDS_3 Testsuite Tetrahedral_remeshing ' - PACKAGE='Tetrahedral_remeshing Three Triangulation '
- PACKAGE='Three Triangulation Triangulation_2 ' - PACKAGE='Triangulation_2 Triangulation_3 Union_find '
- PACKAGE='Triangulation_3 Union_find Visibility_2 ' - PACKAGE='Visibility_2 Voronoi_diagram_2 wininst '
- PACKAGE='Voronoi_diagram_2 wininst '
compiler: clang compiler: clang
install: install:
- echo "$PWD" - echo "$PWD"
- if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi
- /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh
- export CXX=clang++ CC=clang; - export CXX=clang++-10 CC=clang-10;
before_script: before_script:
- wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe - wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe
- sudo mv doxygen_exe /usr/bin/doxygen - sudo mv doxygen_exe /usr/bin/doxygen

View File

@ -7,30 +7,6 @@ CXX_FLAGS="-DCGAL_NDEBUG -ftemplate-backtrace-limit=0"
function mytime { function mytime {
/usr/bin/time -f "Spend time of %C: %E (real)" "$@" /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}" -DCGAL_BUILD_THREE_DOC=TRUE ..
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 old_IFS=$IFS
IFS=$' ' IFS=$' '
ROOT="$PWD/.." ROOT="$PWD/.."
@ -41,6 +17,7 @@ do
continue continue
fi fi
cd $ROOT cd $ROOT
#install openmesh only if necessary #install openmesh only if necessary
if [ "$ARG" = "CHECK" ] || [ "$ARG" = BGL ] || [ "$ARG" = Convex_hull_3 ] ||\ if [ "$ARG" = "CHECK" ] || [ "$ARG" = BGL ] || [ "$ARG" = Convex_hull_3 ] ||\
[ "$ARG" = Polygon_mesh_processing ] || [ "$ARG" = Property_map ] ||\ [ "$ARG" = Polygon_mesh_processing ] || [ "$ARG" = Property_map ] ||\
@ -92,7 +69,7 @@ cd $ROOT
exit 1 exit 1
fi fi
echo "Matrix is up to date." echo "Matrix is up to date."
#check if non standard cgal installation works #check if non standard cgal installation works
cd $ROOT cd $ROOT
mkdir build_test mkdir build_test
cd build_test cd build_test
@ -111,12 +88,30 @@ cd $ROOT
echo '#include "CGAL/remove_outliers.h"' >> main.cpp echo '#include "CGAL/remove_outliers.h"' >> main.cpp
cd build cd build
mytime cmake -DCMAKE_INSTALL_PREFIX=../../install -DCGAL_BUILD_THREE_DOC=TRUE .. mytime cmake -DCMAKE_INSTALL_PREFIX=../../install -DCGAL_BUILD_THREE_DOC=TRUE ..
cd ..
exit 0 exit 0
fi fi
if [ "$ARG" = "Installation" ]
then
mkdir build_dir
cd build_dir
cmake -DWITH_tests=ON -DBUILD_TESTING=ON ..
ctest -j2 -L CGAL_cmake_testsuite --output-on-failure
cd ..
rm -rf ./build_dir
#==-- configure all CGAL with -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON, and then launch CTest on a few labels. --==
mkdir config_dir
cd config_dir
cmake -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON -DBUILD_TESTING=ON ..
ctest -j2 -L AABB_tree --output-on-failure
cd ..
rm -rf ./config_dir
exit 0
fi
IFS=$old_IFS IFS=$old_IFS
if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$ARG" != Polyhedron_demo ]; then if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ]; then
DO_IGNORE=FALSE DO_IGNORE=FALSE
. $ROOT/.travis/test_package.sh "$ROOT" "$ARG" . $ROOT/.travis/test_package.sh "$ROOT" "$ARG"
echo "DO_IGNORE is $DO_IGNORE" echo "DO_IGNORE is $DO_IGNORE"
@ -125,66 +120,22 @@ cd $ROOT
fi fi
fi fi
IFS=$' ' IFS=$' '
EXAMPLES="$ARG/examples/$ARG" mkdir -p build-travis
TEST="$ARG/test/$ARG" cd build-travis
DEMOS=$ROOT/$ARG/demo/* 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/$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"
fi
if [ -d "$ROOT/$TEST" ] 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 ..
then mytime ctest -j2 -L $ARG'([_][A-Z]|$)' -E execution___of__ --output-on-failure
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
done done
IFS=$old_IFS IFS=$old_IFS
# Local Variables: # Local Variables:

View File

@ -2,14 +2,15 @@
[ -n "$CGAL_DEBUG_TRAVIS" ] && set -x [ -n "$CGAL_DEBUG_TRAVIS" ] && set -x
DONE=0 DONE=0
sudo add-apt-repository ppa:mikhailnov/pulseeffects -y
sudo apt-get update sudo apt-get update
while [ $DONE = 0 ] while [ $DONE = 0 ]
do do
DONE=1 && sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install clang zsh \ DONE=1 && sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install clang-10 zsh \
flex bison cmake graphviz libgmp-dev libmpfr-dev libmpfi-dev zlib1g-dev libeigen3-dev libboost-dev \ flex bison cmake graphviz libgmp-dev libmpfr-dev libmpfi-dev zlib1g-dev libeigen3-dev \
libboost-system-dev libboost-program-options-dev libboost-thread-dev libboost-iostreams-dev \
qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev libqt5svg5-dev qttools5-dev qttools5-dev-tools qml-module-qtgraphicaleffects libopencv-dev mesa-common-dev libmetis-dev libglu1-mesa-dev \ qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev libqt5svg5-dev qttools5-dev qttools5-dev-tools qml-module-qtgraphicaleffects libopencv-dev mesa-common-dev libmetis-dev libglu1-mesa-dev \
|| DONE=0 && sudo apt-get update libboost1.72-dev || DONE=0 && sudo apt-get update
done done
exit 0 exit 0

View File

@ -49,7 +49,6 @@ Intersections_2
Intersections_3 Intersections_3
Interval_skip_list Interval_skip_list
Interval_support Interval_support
Inventor
Jet_fitting_3 Jet_fitting_3
Kernel_23 Kernel_23
Kernel_d Kernel_d
@ -87,7 +86,6 @@ Polygon
Polygon_mesh_processing Polygon_mesh_processing
Polygonal_surface_reconstruction Polygonal_surface_reconstruction
Polyhedron Polyhedron
Polyhedron_IO
Polyline_simplification_2 Polyline_simplification_2
Polynomial Polynomial
Polytope_distance_d Polytope_distance_d

View File

@ -1,5 +1,5 @@
language: cpp language: cpp
dist: xenial dist: bionic
sudo: required sudo: required
git: git:
depth: 3 depth: 3
@ -12,7 +12,7 @@ install:
- echo "$PWD" - echo "$PWD"
- if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi
- /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh
- export CXX=clang++ CC=clang; - export CXX=clang++-10 CC=clang-10;
before_script: before_script:
- wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe - wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe
- sudo mv doxygen_exe /usr/bin/doxygen - sudo mv doxygen_exe /usr/bin/doxygen

View File

@ -2,10 +2,16 @@
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.14) 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" ) # google benchmark
create_single_source_cgal_program( "tree_construction.cpp" ) 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")

View File

@ -0,0 +1,69 @@
#include <benchmark/benchmark.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <fstream>
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Surface_mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Surface_mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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;
}

View File

@ -1,7 +1,7 @@
# This is the CMake script for compiling the AABB tree demo. # This is the CMake script for compiling the AABB tree demo.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( AABB_tree_Demo ) project(AABB_tree_Demo)
# Find includes in corresponding build directories # Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -17,58 +17,56 @@ if(POLICY CMP0071)
endif() endif()
# Include this package's headers first # Include this package's headers first
include_directories( BEFORE ./ ./include ) include_directories(BEFORE ./ ./include)
# Find CGAL and CGAL Qt5 # Find CGAL and CGAL Qt5
find_package(CGAL COMPONENTS Qt5) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
# Find Qt5 itself # Find Qt5 itself
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Gui Svg) 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) include(AddFileDependencies)
qt5_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" ) qt5_generate_moc("MainWindow.h"
add_file_dependencies( MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/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" ) qt5_generate_moc("Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp")
add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" ) add_file_dependencies(Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h")
qt5_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" ) qt5_generate_moc("Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp")
add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" ) 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" add_file_dependencies(
"${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/Scene_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} #${CGAL_Qt5_MOC_FILES}
) )
# Link with Qt libraries # Link with Qt libraries
target_link_libraries( AABB_demo PRIVATE target_link_libraries(AABB_demo PRIVATE Qt5::OpenGL Qt5::Gui Qt5::Xml
Qt5::OpenGL Qt5::Gui Qt5::Xml CGAL::CGAL CGAL::CGAL_Qt5)
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) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(AABB_demo) 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 "") set(AABB_MISSING_DEPS "")
if(NOT CGAL_FOUND)
set(AABB_MISSING_DEPS "the CGAL library, ${AABB_MISSING_DEPS}")
endif()
if(NOT CGAL_Qt5_FOUND) if(NOT CGAL_Qt5_FOUND)
set(AABB_MISSING_DEPS "CGAL_Qt5, ${AABB_MISSING_DEPS}") set(AABB_MISSING_DEPS "CGAL_Qt5, ${AABB_MISSING_DEPS}")
endif() endif()
@ -77,6 +75,11 @@ else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND)
set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}") set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}")
endif() 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)

View File

@ -35,7 +35,7 @@
\cgalCRPSection{Primitives} \cgalCRPSection{Primitives}
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>` - `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>` - `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>` - `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,ExternalPropertyMaps,CacheDatum>`
- `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,Vpm,OneHalfedgeGraphPerTree,CacheDatum>` - `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,Vpm,OneHalfedgeGraphPerTree,CacheDatum>`
- `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,Vpm,OneFaceGraphPerTree,CacheDatum>` - `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,Vpm,OneFaceGraphPerTree,CacheDatum>`
*/ */

View File

@ -1,7 +1,5 @@
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
#include <CGAL/Polyhedron_3.h> #include <CGAL/Polyhedron_3.h>
@ -9,6 +7,9 @@
#include <CGAL/AABB_face_graph_triangle_primitive.h> #include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Timer.h> #include <CGAL/Timer.h>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT; typedef K::FT FT;
typedef K::Point_3 Point_3; typedef K::Point_3 Point_3;
@ -26,8 +27,12 @@ void triangle_mesh(const char* fname)
typedef CGAL::AABB_tree<Traits> Tree; typedef CGAL::AABB_tree<Traits> Tree;
TriangleMesh tmesh; TriangleMesh tmesh;
std::ifstream in(fname); if(!CGAL::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
in >> tmesh; {
std::cerr << "Invalid input." << std::endl;
return;
}
Timer t; Timer t;
t.start(); t.start();
Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh); Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh);
@ -36,7 +41,6 @@ void triangle_mesh(const char* fname)
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl; std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
} }
Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd, Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
const Surface_mesh& p) const Surface_mesh& p)
{ {
@ -47,7 +51,6 @@ Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
return res; return res;
} }
void surface_mesh_cache_bbox(const char* fname) void surface_mesh_cache_bbox(const char* fname)
{ {
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor; typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
@ -64,9 +67,9 @@ void surface_mesh_cache_bbox(const char* fname)
t.start(); t.start();
Bbox_pmap bb = tmesh.add_property_map<face_descriptor,Bbox_3>("f:bbox",Bbox_3()).first; Bbox_pmap bb = tmesh.add_property_map<face_descriptor,Bbox_3>("f:bbox",Bbox_3()).first;
for(face_descriptor fd : faces(tmesh)){ for(face_descriptor fd : faces(tmesh))
put(bb, fd, bbox(fd,tmesh)); put(bb, fd, bbox(fd,tmesh));
}
Traits traits(bb); Traits traits(bb);
Tree tree(traits); Tree tree(traits);
tree.insert(faces(tmesh).first, faces(tmesh).second, tmesh); tree.insert(faces(tmesh).first, faces(tmesh).second, tmesh);
@ -77,7 +80,6 @@ void surface_mesh_cache_bbox(const char* fname)
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl; std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
std::cout << "Polyhedron_3" << std::endl; std::cout << "Polyhedron_3" << std::endl;

View File

@ -1,14 +1,15 @@
#include <iostream>
#include <fstream>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h> #include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h> #include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/orientation.h> #include <CGAL/Polygon_mesh_processing/orientation.h>
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> K; typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT; typedef K::FT FT;
typedef K::Point_3 Point; typedef K::Point_3 Point;
@ -24,8 +25,8 @@ typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree; typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection; typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
struct Skip
struct Skip { {
face_descriptor fd; face_descriptor fd;
Skip(const face_descriptor fd) Skip(const face_descriptor fd)
@ -44,14 +45,20 @@ struct Skip {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off"; const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off";
std::ifstream input(filename);
Mesh mesh; Mesh mesh;
input >> mesh; if(!CGAL::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Tree tree(faces(mesh).first, faces(mesh).second, mesh); Tree tree(faces(mesh).first, faces(mesh).second, mesh);
double d = CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)?-1:1; double d = CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)?-1:1;
for(face_descriptor fd : faces(mesh)){ for(face_descriptor fd : faces(mesh))
{
halfedge_descriptor hd = halfedge(fd,mesh); halfedge_descriptor hd = halfedge(fd,mesh);
Point p = CGAL::centroid(mesh.point(source(hd,mesh)), Point p = CGAL::centroid(mesh.point(source(hd,mesh)),
mesh.point(target(hd,mesh)), mesh.point(target(hd,mesh)),
@ -61,13 +68,16 @@ int main(int argc, char* argv[])
Ray ray(p,d * v); Ray ray(p,d * v);
Skip skip(fd); Skip skip(fd);
Ray_intersection intersection = tree.first_intersection(ray, skip); Ray_intersection intersection = tree.first_intersection(ray, skip);
if(intersection){ if(intersection)
{
if(boost::get<Point>(&(intersection->first))){ if(boost::get<Point>(&(intersection->first))){
const Point* p = boost::get<Point>(&(intersection->first) ); const Point* p = boost::get<Point>(&(intersection->first) );
std::cout << *p << std::endl; std::cout << *p << std::endl;
} }
} }
} }
std::cerr << "done" << std::endl; std::cerr << "done" << std::endl;
return 0; return 0;
} }

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( AABB_tree_Examples ) project(AABB_tree_Examples)
find_package(CGAL REQUIRED)
find_package(CGAL QUIET) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -98,7 +98,7 @@ class AABB_face_graph_triangle_primitive
} }
public: public:
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
/// \name Types /// \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`. 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 ); static unspecified_type construct_shared_data( FaceGraph& graph );
#else #else
typedef typename Base::Id Id; typedef typename Base::Id Id;
#endif #endif
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor; typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
// constructors // constructors
#ifdef DOXYGEN_RUNNING
/*! /*!
constructs a primitive.
\tparam Iterator an input iterator with `Id` as value type. \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 <class Iterator>
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap vppm);
/*!
constructs a primitive. constructs a primitive.
If `VertexPointPMap` is the default of the class, an additional constructor If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `get(vertex_point, graph)`. 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 <class Iterator> template <class Iterator>
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap_ vppm) AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())), : Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),
@ -141,18 +155,12 @@ public:
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) ) Point_property_map(const_cast<FaceGraph*>(&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) AABB_face_graph_triangle_primitive(face_descriptor fd, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(fd, graph, OneFaceGraphPerTree())), : Base( Id_(make_id(fd, graph, OneFaceGraphPerTree())),
Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm), Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm),
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) ) Point_property_map(const_cast<FaceGraph*>(&graph),vppm) )
{} {}
#ifndef DOXYGEN_RUNNING
template <class Iterator> template <class Iterator>
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph) AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph)
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())), : Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),

View File

@ -140,14 +140,27 @@ public:
#endif #endif
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor edge_descriptor; typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor edge_descriptor;
#ifdef DOXYGEN_RUNNING
/*! /*!
constructs a primitive. constructs a primitive.
\tparam Iterator is an input iterator with `Id` as value type. \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 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<Traits>`. using the insert-by-range method of the class `AABB_tree<Traits>`.
If `VertexPointPMap` is the default of the class, an additional constructor If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `boost::get(vertex_point, graph)`. is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/ */
template <class Iterator>
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 <class Iterator> template <class Iterator>
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap_ vppm) AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())), : Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
@ -155,18 +168,12 @@ public:
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) ) Point_property_map(const_cast<HalfedgeGraph*>(&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) AABB_halfedge_graph_segment_primitive(edge_descriptor ed, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())), : Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm), Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm),
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) ) Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) )
{} {}
#ifndef DOXYGEN_RUNNING
template <class Iterator> template <class Iterator>
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph) AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph)
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())), : Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
@ -177,7 +184,7 @@ public:
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())), : Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
Segment_property_map(const_cast<HalfedgeGraph*>(&graph)), Segment_property_map(const_cast<HalfedgeGraph*>(&graph)),
Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ){} Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ){}
#endif #endif
/// \internal /// \internal
typedef internal::Cstr_shared_data<HalfedgeGraph, Base, Segment_property_map, Point_property_map, OneHalfedgeGraphPerTree> Cstr_shared_data; typedef internal::Cstr_shared_data<HalfedgeGraph, Base, Segment_property_map, Point_property_map, OneHalfedgeGraphPerTree> Cstr_shared_data;

View File

@ -13,6 +13,8 @@
#ifndef CGAL_AABB_TREE_H #ifndef CGAL_AABB_TREE_H
#define CGAL_AABB_TREE_H #define CGAL_AABB_TREE_H
#include <memory>
#include <CGAL/license/AABB_tree.h> #include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h> #include <CGAL/disable_warnings.h>
@ -62,6 +64,7 @@ namespace CGAL {
typedef std::vector<typename AABBTraits::Primitive> Primitives; typedef std::vector<typename AABBTraits::Primitive> Primitives;
typedef internal::Primitive_helper<AABBTraits> Helper; typedef internal::Primitive_helper<AABBTraits> Helper;
typedef AABB_tree<AABBTraits> Self;
public: public:
typedef AABBTraits AABB_traits; typedef AABBTraits AABB_traits;
@ -113,6 +116,15 @@ namespace CGAL {
/// class using `traits`. /// class using `traits`.
AABB_tree(const AABBTraits& traits = AABBTraits()); 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. * @brief Builds the datastructure from a sequence of primitives.
* @param first iterator over first primitive to insert * @param first iterator over first primitive to insert
@ -475,10 +487,7 @@ public:
// clear nodes // clear nodes
void clear_nodes() void clear_nodes()
{ {
if( size() > 1 ) { m_nodes.clear();
delete [] m_p_root_node;
}
m_p_root_node = nullptr;
} }
// clears internal KD tree // clears internal KD tree
@ -491,8 +500,7 @@ public:
#endif #endif
{ {
CGAL_assertion( m_p_search_tree!=nullptr ); CGAL_assertion( m_p_search_tree!=nullptr );
delete m_p_search_tree; m_p_search_tree.reset();
m_p_search_tree = nullptr;
#ifdef CGAL_HAS_THREADS #ifdef CGAL_HAS_THREADS
m_atomic_search_tree_constructed.store(false, std::memory_order_relaxed); m_atomic_search_tree_constructed.store(false, std::memory_order_relaxed);
#else #else
@ -522,6 +530,22 @@ public:
private: private:
typedef AABB_node<AABBTraits> Node; typedef AABB_node<AABBTraits> 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<typename ConstPrimitiveIterator, typename ComputeBbox, typename SplitPrimitives>
void expand(Node& node,
ConstPrimitiveIterator first,
ConstPrimitiveIterator beyond,
const std::size_t range,
const ComputeBbox& compute_bbox,
const SplitPrimitives& split_primitives,
const AABBTraits&);
public: public:
// returns a point which must be on one primitive // returns a point which must be on one primitive
@ -573,12 +597,12 @@ public:
AABBTraits m_traits; AABBTraits m_traits;
// set of input primitives // set of input primitives
Primitives m_primitives; Primitives m_primitives;
// single root node // tree nodes. first node is the root node
Node* m_p_root_node = nullptr; std::vector<Node> m_nodes;
#ifdef CGAL_HAS_THREADS #ifdef CGAL_HAS_THREADS
mutable CGAL_MUTEX build_mutex; // mutex used to protect const calls inducing build() and build_kd_tree() mutable CGAL_MUTEX build_mutex; // mutex used to protect const calls inducing build() and build_kd_tree()
#endif #endif
public:
const Node* root_node() const { const Node* root_node() const {
CGAL_assertion(size() > 1); CGAL_assertion(size() > 1);
@ -594,16 +618,22 @@ public:
#endif #endif
const_cast< AABB_tree<AABBTraits>* >(this)->build(); const_cast< AABB_tree<AABBTraits>* >(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 { const Primitive& singleton_data() const {
CGAL_assertion(size() == 1); CGAL_assertion(size() == 1);
return *m_primitives.begin(); return *m_primitives.begin();
} }
// search KD-tree // search KD-tree
const Search_tree* m_p_search_tree = nullptr; mutable std::unique_ptr<const Search_tree> m_p_search_tree;
bool m_use_default_search_tree = true; // indicates whether the internal kd-tree should be built bool m_use_default_search_tree = true; // indicates whether the internal kd-tree should be built
#ifdef CGAL_HAS_THREADS #ifdef CGAL_HAS_THREADS
std::atomic<bool> m_atomic_need_build; std::atomic<bool> m_atomic_need_build;
@ -613,11 +643,6 @@ public:
mutable bool m_search_tree_constructed = false; mutable bool m_search_tree_constructed = false;
#endif #endif
private:
// Disabled copy constructor & assignment operator
typedef AABB_tree<AABBTraits> Self;
AABB_tree(const Self& src);
Self& operator=(const Self& src);
}; // end class AABB_tree }; // end class AABB_tree
@ -632,6 +657,30 @@ public:
#endif #endif
{} {}
template <typename Tr>
typename AABB_tree<Tr>::Self& AABB_tree<Tr>::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<typename Tr>
AABB_tree<Tr>::AABB_tree(Self&& tree) noexcept
{
*this = std::move(tree);
}
template<typename Tr> template<typename Tr>
template<typename ConstPrimitiveIterator, typename ... T> template<typename ConstPrimitiveIterator, typename ... T>
AABB_tree<Tr>::AABB_tree(ConstPrimitiveIterator first, AABB_tree<Tr>::AABB_tree(ConstPrimitiveIterator first,
@ -704,6 +753,41 @@ public:
#endif #endif
} }
template<typename Tr>
template<typename ConstPrimitiveIterator, typename ComputeBbox, typename SplitPrimitives>
void
AABB_tree<Tr>::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<typename Tr> template<typename Tr>
void AABB_tree<Tr>::build() void AABB_tree<Tr>::build()
{ {
@ -719,24 +803,19 @@ public:
const SplitPrimitives& split_primitives) const SplitPrimitives& split_primitives)
{ {
clear_nodes(); clear_nodes();
if(m_primitives.size() > 1) { if(m_primitives.size() > 1) {
// allocates tree nodes // allocates tree nodes
m_p_root_node = new Node[m_primitives.size()-1](); m_nodes.reserve(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();
}
// constructs the tree // constructs the tree
m_p_root_node->expand(m_primitives.begin(), m_primitives.end(), expand(new_node(),
m_primitives.size(), m_primitives.begin(), m_primitives.end(),
compute_bbox, m_primitives.size(),
split_primitives, compute_bbox,
m_traits); split_primitives,
m_traits);
} }
#ifdef CGAL_HAS_THREADS #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() 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) ConstPointIterator beyond)
{ {
clear_search_tree(); clear_search_tree();
m_p_search_tree = new Search_tree(first, beyond); m_p_search_tree = std::make_unique<const Search_tree>(first, beyond);
if(m_p_search_tree != nullptr)
{
#ifdef CGAL_HAS_THREADS #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() 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 #else
m_search_tree_constructed = true; m_search_tree_constructed = true;
#endif #endif
return true; return true;
}
else
{
std::cerr << "Unable to allocate memory for accelerating distance queries" << std::endl;
return false;
}
} }
template<typename Tr> template<typename Tr>
@ -793,7 +863,6 @@ public:
m_use_default_search_tree = false; m_use_default_search_tree = false;
} }
// constructs the search KD tree from internal primitives // constructs the search KD tree from internal primitives
template<typename Tr> template<typename Tr>
bool AABB_tree<Tr>::accelerate_distance_queries() bool AABB_tree<Tr>::accelerate_distance_queries()

View File

@ -32,6 +32,9 @@ namespace CGAL {
template<typename AABBTraits> template<typename AABBTraits>
class AABB_node class AABB_node
{ {
private:
typedef AABB_node<AABBTraits> Self;
public: public:
typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Bounding_box Bounding_box;
@ -41,29 +44,15 @@ public:
, m_p_left_child(nullptr) , m_p_left_child(nullptr)
, m_p_right_child(nullptr) { }; , m_p_right_child(nullptr) { };
/// Non virtual Destructor AABB_node(Self&& node) = default;
/// Do not delete children because the tree hosts and delete them
~AABB_node() { }; // Disabled copy constructor & assignment operator
AABB_node(const Self& src) = delete;
Self& operator=(const Self& src) = delete;
/// Returns the bounding box of the node /// Returns the bounding box of the node
const Bounding_box& bbox() const { return m_bbox; } 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<typename ConstPrimitiveIterator, typename ComputeBbox, typename SplitPrimitives>
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 * @brief General traversal query
* @param query the query * @param query the query
@ -95,8 +84,17 @@ public:
{ return *static_cast<Primitive*>(m_p_left_child); } { return *static_cast<Primitive*>(m_p_left_child); }
const Primitive& right_data() const const Primitive& right_data() const
{ return *static_cast<Primitive*>(m_p_right_child); } { return *static_cast<Primitive*>(m_p_right_child); }
template <class Left, class Right>
void set_children(Left& l, Right& r)
{
m_p_left_child = static_cast<void*>(std::addressof(l));
m_p_right_child = static_cast<void*>(std::addressof(r));
}
void set_bbox(const Bounding_box& bbox)
{
m_bbox = bbox;
}
private:
Node& left_child() { return *static_cast<Node*>(m_p_left_child); } Node& left_child() { return *static_cast<Node*>(m_p_left_child); }
Node& right_child() { return *static_cast<Node*>(m_p_right_child); } Node& right_child() { return *static_cast<Node*>(m_p_right_child); }
Primitive& left_data() { return *static_cast<Primitive*>(m_p_left_child); } Primitive& left_data() { return *static_cast<Primitive*>(m_p_left_child); }
@ -111,49 +109,8 @@ private:
void *m_p_left_child; void *m_p_left_child;
void *m_p_right_child; void *m_p_right_child;
private:
// Disabled copy constructor & assignment operator
typedef AABB_node<AABBTraits> Self;
AABB_node(const Self& src);
Self& operator=(const Self& src);
}; // end class AABB_node }; // end class AABB_node
template<typename Tr>
template<typename ConstPrimitiveIterator, typename ComputeBbox, typename SplitPrimitives>
void
AABB_node<Tr>::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<Node*>(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<Node*>(this) + 1;
m_p_right_child = static_cast<Node*>(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<typename Tr> template<typename Tr>
template<class Traversal_traits, class Query> template<class Traversal_traits, class Query>

View File

@ -83,7 +83,7 @@ namespace CGAL
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search; typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
typedef typename Neighbor_search::Tree Tree; typedef typename Neighbor_search::Tree Tree;
private: private:
Tree* m_p_tree; Tree m_tree;
Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p) Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p)
@ -98,30 +98,22 @@ namespace CGAL
public: public:
template <class ConstPointIterator> template <class ConstPointIterator>
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond) AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
: m_p_tree(nullptr) : m_tree{}
{ {
typedef typename Add_decorated_point<Traits, typename Traits::Primitive::Id>::Point_3 Decorated_point; typedef typename Add_decorated_point<Traits,typename Traits::Primitive::Id>::Point_3 Decorated_point;
std::vector<Decorated_point> points; std::vector<Decorated_point> points;
while(begin != beyond) { while(begin != beyond) {
Point_and_primitive_id pp = get_p_and_p(*begin); 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; ++begin;
} }
m_p_tree = new Tree(points.begin(), points.end()); m_tree.insert(points.begin(), points.end());
if(m_p_tree != nullptr) m_tree.build();
m_p_tree->build();
else
std::cerr << "unable to build the search tree!" << std::endl;
} }
~AABB_search_tree() {
delete m_p_tree;
}
Point_and_primitive_id closest_point(const Point& query) const 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<Point>(search.begin()->first), search.begin()->first.id()); return Point_and_primitive_id(static_cast<Point>(search.begin()->first), search.begin()->first.id());
} }
}; };

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( AABB_tree_Tests ) project(AABB_tree_Tests)
find_package(CGAL REQUIRED)
find_package(CGAL QUIET) include(${CGAL_USE_FILE}) # Kept to test the old behaviour.
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()
# 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()

View File

@ -0,0 +1,207 @@
#include <iostream>
#include <list>
#include <utility>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/assertions.h>
#include <fstream>
template <int test_number>
class TestCase
{
};
// test 0 is from "aabb_test_singleton_tree"
template <>
class TestCase<0>
{
typedef CGAL::Simple_cartesian<double> 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<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Segment> 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<CGAL::Point_3<CGAL::Epick>> Mesh;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Mesh, CGAL::Default,
CGAL::Tag_false>
S_Primitive;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh, CGAL::Default,
CGAL::Tag_false>
T_Primitive;
typedef CGAL::AABB_traits<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits<K, S_Primitive> S_Traits;
typedef CGAL::AABB_tree<T_Traits> T_Tree;
typedef CGAL::AABB_tree<S_Traits> S_Tree;
typedef T_Tree::Primitive_id T_Primitive_id;
typedef S_Tree::Primitive_id S_Primitive_id;
typedef std::pair<T_Tree, S_Tree> TreePair;
public:
TreePair create_tree()
{
static CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick>> m1 = {};
static CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick>> 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_Tree::Primitive::Id> t_primitives;
std::list<S_Tree::Primitive::Id> 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<T_Tree::Primitive::Id> 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 <int test_number>
bool run_test()
{
TestCase<test_number> 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; }

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -9,7 +9,7 @@
#include <CGAL/Delaunay_triangulation_3.h> #include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h> #include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/Advancing_front_surface_reconstruction.h> #include <CGAL/Advancing_front_surface_reconstruction.h>
#include <CGAL/IO/read_xyz_points.h> #include <CGAL/IO/read_points.h>
#include <CGAL/disable_warnings.h> #include <CGAL/disable_warnings.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -113,13 +113,10 @@ int main (int argc, char* argv[])
const char* fname = (argc>1) ? argv[1] : "data/cube.pwn"; const char* fname = (argc>1) ? argv[1] : "data/cube.pwn";
// Loading point set from a file. // Loading point set from a file.
std::ifstream stream(fname);
if (!stream || if (!CGAL::read_points(fname, std::back_inserter(points),
!CGAL::read_xyz_points(stream, CGAL::parameters::point_map(Point_map()).
std::back_inserter(points), normal_map(Normal_map())))
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map())))
{ {
std::cerr << "Error: cannot read file" << std::endl; std::cerr << "Error: cannot read file" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -1,10 +1,10 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <array>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Advancing_front_surface_reconstruction.h> #include <CGAL/Advancing_front_surface_reconstruction.h>
#include <CGAL/Surface_mesh.h> #include <CGAL/Surface_mesh.h>
#include <CGAL/array.h>
#include <CGAL/disable_warnings.h> #include <CGAL/disable_warnings.h>
typedef std::array<std::size_t,3> Facet; typedef std::array<std::size_t,3> Facet;

View File

@ -21,9 +21,9 @@ Modular_arithmetic
Number_types Number_types
Polygon Polygon
Polyhedron Polyhedron
Polyhedron_IO
Profiling_tools Profiling_tools
Property_map Property_map
Random_numbers
STL_Extension STL_Extension
Spatial_sorting Spatial_sorting
Stream_support Stream_support

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( Algebraic_foundations_Examples ) project(Algebraic_foundations_Examples)
find_package(CGAL REQUIRED)
find_package(CGAL QUIET) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -14,7 +14,7 @@
/*! \file CGAL/Algebraic_extension_traits.h /*! \file CGAL/Algebraic_extension_traits.h
* \brief Defines traits class CGAL::Algebraic_extension_traits. * \brief defines traits class CGAL::Algebraic_extension_traits.
*/ */
#ifndef CGAL_ALGEBRAIC_NUMBER_TRAITS_H #ifndef CGAL_ALGEBRAIC_NUMBER_TRAITS_H

View File

@ -13,7 +13,7 @@
// ============================================================================= // =============================================================================
/*! \file NiX/Coercion_traits.h /*! \file NiX/Coercion_traits.h
* \brief Defines class NiX::Coercion_traits. * \brief defines class NiX::Coercion_traits.
* *
* Provides the general definition of the \c Coercion_traits<A,B> class, with * Provides the general definition of the \c Coercion_traits<A,B> class, with
* specializations for the builtin number types. * specializations for the builtin number types.

View File

@ -17,7 +17,7 @@
// they may be wrong now. // they may be wrong now.
/*! \file NiX/Fraction_traits.h /*! \file NiX/Fraction_traits.h
\brief Defines class NiX::Fraction_traits. \brief defines class NiX::Fraction_traits.
Provides dependent types and function objects for all the functions Provides dependent types and function objects for all the functions
beyond operators with specializations of the \c Fraction_traits<NT> beyond operators with specializations of the \c Fraction_traits<NT>

View File

@ -27,7 +27,7 @@ namespace CGAL {
class Parens_as_product_tag {}; class Parens_as_product_tag {};
/*! \ingroup NiX_io_parens /*! \ingroup NiX_io_parens
* \brief Decides whether this number requires parentheses * \brief decides whether this number requires parentheses
* in case it appears within a produkt. * in case it appears within a produkt.
*/ */
template <class NT> template <class NT>
@ -36,7 +36,7 @@ struct Needs_parens_as_product{
}; };
/*! \ingroup NiX_io_parens /*! \ingroup NiX_io_parens
* \brief Decides whether this number requires parentheses * \brief decides whether this number requires parentheses
* in case it appears within a produkt. * in case it appears within a produkt.
*/ */
template <class NT> template <class NT>

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) include(${CGAL_USE_FILE})
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()
# 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()

View File

@ -1,28 +1,27 @@
cmake_minimum_required(VERSION 3.1...3.15) 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 ) include(${CGAL_USE_FILE})
find_package(MPFI QUIET) include(${MPFI_USE_FILE})
endif() include(CGAL_VersionUtils)
if( CGAL_FOUND AND MPFI_FOUND) create_single_source_cgal_program("Compare_1.cpp")
create_single_source_cgal_program("Construct_algebraic_real_1.cpp")
include( ${CGAL_USE_FILE} ) create_single_source_cgal_program("Isolate_1.cpp")
include( ${MPFI_USE_FILE} ) create_single_source_cgal_program("Sign_at_1.cpp")
include( CGAL_VersionUtils ) 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() 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() endif()

View File

@ -180,13 +180,13 @@ public:
} }
} }
/*! \brief Refines the isolating interval. */ /*! \brief refines the isolating interval. */
void refine() const{ this->ptr()->refine(); } void refine() const{ this->ptr()->refine(); }
/*! \brief Bisects the isolating interval. */ /*! \brief Bisects the isolating interval. */
void bisect() const{ this->ptr()->bisect(); } void bisect() const{ this->ptr()->bisect(); }
/*! \brief Refines the isolating interval until \a m is outside /*! \brief refines the isolating interval until \a m is outside
* the \c closed interval * the \c closed interval
*/ */
template < class NTX > template < class NTX >

View File

@ -375,7 +375,7 @@ public:
} }
/*! /*!
* \brief Gives an opportunity to process the nodes after * \brief gives an opportunity to process the nodes after
* the subdivision steps are finished * the subdivision steps are finished
* *
* This method must be specialised by derived classes, but can * This method must be specialised by derived classes, but can
@ -386,7 +386,7 @@ public:
return; return;
} }
/*! \brief Returns whether the \c i th root is definitely a simple root /*! \brief returns whether the \c i th root is definitely a simple root
* of the isolated polynomial * of the isolated polynomial
* *
* Must be specialised by derived class * Must be specialised by derived class
@ -396,7 +396,7 @@ public:
return false; return false;
} }
/*! \brief Returns whether the \c i th root is definitely a multiple root /*! \brief returns whether the \c i th root is definitely a multiple root
* of the isolated polynomial * of the isolated polynomial
* *
* Must be specialised by derived class * Must be specialised by derived class
@ -1040,7 +1040,7 @@ public:
} }
/*! \brief Returns whether the \c i th root is definitely a simple root /*! \brief returns whether the \c i th root is definitely a simple root
* of the isolated polynomial * of the isolated polynomial
* *
*/ */
@ -1048,7 +1048,7 @@ public:
return false; return false;
} }
/*! \brief Returns whether the \c i th root is definitely /*! \brief returns whether the \c i th root is definitely
* a multiple root * a multiple root
* of the isolated polynomial * of the isolated polynomial
* *
@ -1372,7 +1372,7 @@ public:
bool is_exact_root(int) const { return false; } bool is_exact_root(int) const { return false; }
/*! /*!
* \brief Returns true if the <tt>i</tt>th root is known to be a simple * \brief returns true if the <tt>i</tt>th root is known to be a simple
* root of the curve. * root of the curve.
*/ */
bool is_certainly_simple_root(int i) const { bool is_certainly_simple_root(int i) const {
@ -1381,7 +1381,7 @@ public:
} }
/*! /*!
* \brief Returns true if the <tt>i</tt>th root is known to be a multiple * \brief returns true if the <tt>i</tt>th root is known to be a multiple
* root of the curve. * root of the curve.
*/ */
bool is_certainly_multiple_root(int i) const { bool is_certainly_multiple_root(int i) const {
@ -1391,7 +1391,7 @@ public:
/*! /*!
* \brief Returns the multiplicity of the root if know, otherwise -1 * \brief returns the multiplicity of the root if know, otherwise -1
*/ */
int multiplicity_of_root(int i) const { int multiplicity_of_root(int i) const {
CGAL_assertion(is_isolated()); CGAL_assertion(is_isolated());
@ -1407,7 +1407,7 @@ public:
} }
/*! /*!
* \brief Returns the isolator of the polynomial f(1/x + q), if known * \brief returns the isolator of the polynomial f(1/x + q), if known
*/ */
Self inverse_transform_isolator() const { Self inverse_transform_isolator() const {
return this->ptr()->inverse_transform_isolator(); return this->ptr()->inverse_transform_isolator();

View File

@ -707,13 +707,13 @@ public:
this->ptr()->node_list_.erase(n); this->ptr()->node_list_.erase(n);
} }
/*! \brief Replace traits class /*! \brief replaces traits class
*/ */
void set_traits(TRAITS& traits) { void set_traits(TRAITS& traits) {
this->ptr()->b_from_p_.set_traits(traits); this->ptr()->b_from_p_.set_traits(traits);
} }
/*! \brief Returns a copy of this with its own representation /*! \brief returns a copy of this with its own representation
*/ */
Self make_unique() const { Self make_unique() const {
Self tmp = *this; Self tmp = *this;

View File

@ -1079,7 +1079,7 @@ public:
this->ptr()->node_list_.erase(n); this->ptr()->node_list_.erase(n);
} }
/*! \brief Replace traits class /*! \brief replaces traits class
*/ */
void set_traits(TRAITS& traits) { void set_traits(TRAITS& traits) {
@ -1090,7 +1090,7 @@ public:
} }
/*! \brief Returns a copy of this with its own representation /*! \brief returns a copy of this with its own representation
*/ */
Self make_unique() const { Self make_unique() const {
Self tmp = *this; Self tmp = *this;

View File

@ -512,7 +512,7 @@ public:
private: private:
/* /*
* \brief Sets all status lines at events and of intervals * \brief sets all status lines at events and of intervals
* *
* Writes the status lines of events and interval into the object. * Writes the status lines of events and interval into the object.
* The value type of both \c InputIterator1 and \c InputIterator2 * The value type of both \c InputIterator1 and \c InputIterator2
@ -571,7 +571,7 @@ private:
public: public:
/*! \brief Returns whether the curve has a valid defining polynomial /*! \brief returns whether the curve has a valid defining polynomial
*/ */
bool has_defining_polynomial() const { bool has_defining_polynomial() const {
return bool(this->ptr()->f); return bool(this->ptr()->f);
@ -579,7 +579,7 @@ public:
public: public:
/*! \brief Sets the defining polynomial. /*! \brief sets the defining polynomial.
* *
* \pre The object has no defining polynomial yet. * \pre The object has no defining polynomial yet.
*/ */
@ -595,7 +595,7 @@ public:
public: public:
/*! /*!
* \brief Returns whether the curve is y-regular * \brief returns whether the curve is y-regular
* *
* A curve is called y-regular if the leading coefficient of its defining * A curve is called y-regular if the leading coefficient of its defining
* polynomial wrt y is a constant, i.e., contains no x * polynomial wrt y is a constant, i.e., contains no x
@ -646,7 +646,7 @@ public:
public: public:
/*! /*!
* \brief Returns the number of event lines of the curve * \brief returns the number of event lines of the curve
* *
* Algebraically, the number of real roots of the discriminant of * Algebraically, the number of real roots of the discriminant of
* the curve's defining equation is returned. * the curve's defining equation is returned.
@ -664,7 +664,7 @@ public:
public: public:
/*! /*!
* \brief Returns whether the given x-coordinate is critical for the curve * \brief returns whether the given x-coordinate is critical for the curve
* and which event or interval index the x-coordinate belongs to. * and which event or interval index the x-coordinate belongs to.
* *
* \param is_event is set to \c true if the curve has an event * \param is_event is set to \c true if the curve has an event
@ -734,7 +734,7 @@ public:
private: private:
/* /*
* \brief Returns a status line for an exact value \c alpha that * \brief returns a status line for an exact value \c alpha that
* is not an event of the curve * is not an event of the curve
* *
* This function controls the internal cache that stores already created * This function controls the internal cache that stores already created
@ -1167,7 +1167,7 @@ private:
public: public:
/*! /*!
* \brief Returns the status line for the interval * \brief returns the status line for the interval
* preceeding the <tt>i</tt>th event * preceeding the <tt>i</tt>th event
* *
* Returns a status line for a reference x-coordinate of the <tt>i</tt>th * Returns a status line for a reference x-coordinate of the <tt>i</tt>th
@ -1235,7 +1235,7 @@ public:
private: private:
/* /*
* \brief Creates an intermediate line at position \c ar. * \brief creates an intermediate line at position \c ar.
* *
* It is required that none of the following situations occurs at position * It is required that none of the following situations occurs at position
* <tt>ar</tt>: singularity, vertical tangent line, vertical asymptote.\n * <tt>ar</tt>: singularity, vertical tangent line, vertical asymptote.\n
@ -1279,7 +1279,7 @@ private:
private: private:
/* /*
* \brief Returns an Event_line_builder instance * \brief returns an Event_line_builder instance
* *
* Note: So far, a new instance is created each time the function is called * Note: So far, a new instance is created each time the function is called
*/ */
@ -1444,7 +1444,7 @@ private:
public: public:
/*! /*!
* \brief Returns the <tt>i</tt>th Sturm-Habicht polynomial * \brief returns the <tt>i</tt>th Sturm-Habicht polynomial
* of the primitive part of the defining polynomial * of the primitive part of the defining polynomial
*/ */
Polynomial_2 sturm_habicht_of_primitive(size_type i) const Polynomial_2 sturm_habicht_of_primitive(size_type i) const
@ -1458,7 +1458,7 @@ public:
public: public:
/*! /*!
* \brief Returns the <tt>i</tt>th principal Sturm-Habicht coefficient * \brief returns the <tt>i</tt>th principal Sturm-Habicht coefficient
* of the primitive part of the defining polynomial * of the primitive part of the defining polynomial
*/ */
Polynomial_1 principal_sturm_habicht_of_primitive(size_type i) const Polynomial_1 principal_sturm_habicht_of_primitive(size_type i) const
@ -1477,7 +1477,7 @@ public:
public: public:
/*! /*!
* \brief Returns the <tt>i</tt>th coprincipal Sturm-Habicht coefficient * \brief returns the <tt>i</tt>th coprincipal Sturm-Habicht coefficient
* of the primitive part of the defining polynomial * of the primitive part of the defining polynomial
* *
* The coprincipal Sturm-Habicht coefficient is the coefficient * The coprincipal Sturm-Habicht coefficient is the coefficient
@ -1498,7 +1498,7 @@ public:
public: public:
/*! /*!
* \brief Returns an iterator to the principal Sturm-Habicht coefficients, * \brief returns an iterator to the principal Sturm-Habicht coefficients,
* starting with the <tt>0</tt>th one (the resultant) * starting with the <tt>0</tt>th one (the resultant)
*/ */
Principal_sturm_habicht_iterator principal_sturm_habicht_begin() const { Principal_sturm_habicht_iterator principal_sturm_habicht_begin() const {
@ -1930,7 +1930,7 @@ private:
public: public:
/*! /*!
* \brief Returns a \c Curve_analysis_2 object for a sheared curve. * \brief returns a \c Curve_analysis_2 object for a sheared curve.
* *
* The shear factor is given by the integer \c s. * The shear factor is given by the integer \c s.
* This functions only shears the primitive part of the defining equation. * This functions only shears the primitive part of the defining equation.
@ -2082,7 +2082,7 @@ public:
public: public:
/*! /*!
* \brief Returns the limit an infinite arc converges to * \brief returns the limit an infinite arc converges to
* *
* \pre <tt>loc==CGAL::LEFT_BOUNDARY || * \pre <tt>loc==CGAL::LEFT_BOUNDARY ||
* loc==CGAL::RIGHT_BOUNDARY</tt> * loc==CGAL::RIGHT_BOUNDARY</tt>
@ -2399,7 +2399,7 @@ private:
}; // class Algebraic_curve_2_2 }; // class Algebraic_curve_2_2
//! \brief Prints the objects. //! \brief prints the objects.
template<typename AlgebraicKernelWithAnalysis_2, template<typename AlgebraicKernelWithAnalysis_2,
typename Rep_> typename Rep_>
std::ostream& operator<< ( std::ostream& operator<< (
@ -2507,7 +2507,7 @@ std::ostream& operator<< (
return out; return out;
} }
//! \brief Reads the objects from stream //! \brief reads the objects from stream
template<typename AlgebraicKernelWithAnalysis_2, template<typename AlgebraicKernelWithAnalysis_2,
typename Rep_> typename Rep_>
std::istream& operator>> ( std::istream& operator>> (

View File

@ -611,7 +611,7 @@ public:
public: public:
/* /*
* \brief Returns the indices of the <tt>i</tt>th event value * \brief returns the indices of the <tt>i</tt>th event value
* *
* Returns a Event_indices <tt>(fg,ffy,ggy)</tt> such that * Returns a Event_indices <tt>(fg,ffy,ggy)</tt> such that
* the <tt>i</tt>th event root is the <tt>fg</tt>th root of the * the <tt>i</tt>th event root is the <tt>fg</tt>th root of the
@ -963,7 +963,7 @@ public:
} }
/*! /*!
* \brief Returns the number of event slices * \brief returns the number of event slices
* *
* Precisely, this is the number of points which are either root of * Precisely, this is the number of points which are either root of
* the resultant of the two curves, or root of discriminant of one * the resultant of the two curves, or root of discriminant of one
@ -1171,7 +1171,7 @@ private:
Integer s) const; Integer s) const;
/* /*
* \brief Reduces the number of possible intersections * \brief reduces the number of possible intersections
* *
* At the position given by the event lins \c e1 and \c e2 and the slice * At the position given by the event lins \c e1 and \c e2 and the slice
* info object \c slice, the points on the event lines are further refined * info object \c slice, the points on the event lines are further refined
@ -1197,7 +1197,7 @@ private:
}; // end of Curve_pair_analysis_2 }; // end of Curve_pair_analysis_2
//! \brief Prints the objects. //! \brief prints the objects.
template<typename AlgebraicKernelWithAnalysis_2> template<typename AlgebraicKernelWithAnalysis_2>
std::ostream& operator<< std::ostream& operator<<
(std::ostream& out, (std::ostream& out,

View File

@ -16,7 +16,7 @@
// they may be wrong now. // they may be wrong now.
/*! \file NiX/Descartes.h /*! \file NiX/Descartes.h
\brief Defines class NiX::Descartes. \brief defines class NiX::Descartes.
Isolate real roots of polynomials. Isolate real roots of polynomials.

View File

@ -114,7 +114,7 @@ public:
/*! /*!
* \brief Creates an event line at position \c alpha for the specified * \brief creates an event line at position \c alpha for the specified
* curve. * curve.
* *
* Additionally, the \c id of the event line to be created has to be * Additionally, the \c id of the event line to be created has to be

View File

@ -95,7 +95,7 @@ set_union_with_source(InputIterator1 first_begin,
} }
/* /*
* \brief Removes the leading term of the polynomial \c f as long as it * \brief removes the leading term of the polynomial \c f as long as it
* vanishes at \c alpha * vanishes at \c alpha
* *
*/ */
@ -169,7 +169,7 @@ template<typename AlgebraicKernel_1> typename AlgebraicKernel_1::Bound
/*! /*!
* \brief Produces intermediate rational values for a list of * \brief produces intermediate rational values for a list of
* algebraic reals. * algebraic reals.
* *
* For a list of Algebraic real values with \c n elements, a list with * For a list of Algebraic real values with \c n elements, a list with

View File

@ -36,7 +36,7 @@ namespace CGAL {
namespace internal { namespace internal {
/*! \brief Tries to find a SIMPLE rational q with a<q<b. /*! \brief tries to find a SIMPLE rational q with a<q<b.
* *
* In this context, simple means that the denominator of <tt>q</tt> * In this context, simple means that the denominator of <tt>q</tt>
* is a power of two, and is not too big. There is no guarantee to find * is a power of two, and is not too big. There is no guarantee to find

View File

@ -31,7 +31,7 @@ namespace internal {
} // namespace internal } // namespace internal
/*! /*!
* \brief Represents different strategies how to handle * \brief represents different strategies how to handle
* degenerate cases during the analysis * degenerate cases during the analysis
* *
* Currently, there are two possible strategies implemented. See the * Currently, there are two possible strategies implemented. See the

View File

@ -1,67 +1,65 @@
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( Algebraic_kernel_d_Tests ) project(Algebraic_kernel_d_Tests)
# CGAL and its components # CGAL and its components
find_package( CGAL QUIET COMPONENTS Core) find_package(CGAL REQUIRED COMPONENTS Core)
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
find_package(RS3 QUIET) find_package(RS3 QUIET)
if(MPFI_FOUND) if(MPFI_FOUND)
include( ${MPFI_USE_FILE} ) include(${MPFI_USE_FILE})
endif() endif()
if(RS3_FOUND) if(RS3_FOUND)
include( ${RS3_USE_FILE} ) include(${RS3_USE_FILE})
endif() endif()
# Boost and its components # 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() return()
endif() endif()
# include for local directory # 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 # Creating entries for all .cpp/.C files with "main" routine
# ########################################################## # ##########################################################
create_single_source_cgal_program( "cyclic.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.cpp")
create_single_source_cgal_program( "algebraic_curve_kernel_2_tools.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_LEDA.cpp")
create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_Integer_rational.cpp" ) create_single_source_cgal_program(
create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtII_rational.cpp" ) "Algebraic_kernel_d_1_CORE_Integer_rational.cpp")
create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtRI_rational.cpp" ) create_single_source_cgal_program(
create_single_source_cgal_program( "Algebraic_kernel_d_1_CORE_SqrtRR_rational.cpp" ) "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_1_GMP.cpp")
create_single_source_cgal_program( "Algebraic_kernel_d_2.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("Algebraic_real_d_1.cpp")
create_single_source_cgal_program( "Bitstream_descartes.cpp" ) create_single_source_cgal_program("Bitstream_descartes.cpp")
create_single_source_cgal_program( "Curve_analysis_2.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("Curve_pair_analysis_2.cpp")
create_single_source_cgal_program( "Descartes.cpp" ) create_single_source_cgal_program("Descartes.cpp")
create_single_source_cgal_program( "Real_embeddable_traits_extension.cpp" ) create_single_source_cgal_program("Real_embeddable_traits_extension.cpp")
if(RS_FOUND) if(RS_FOUND)
create_single_source_cgal_program( "Algebraic_kernel_rs_gmpq_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" ) create_single_source_cgal_program("Algebraic_kernel_rs_gmpz_d_1.cpp")
else() 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() endif()

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) include_directories(BEFORE "include")
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()
# 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()

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) include_directories(BEFORE "include")
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()
# 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()

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -2,7 +2,7 @@
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project (Alpha_shapes_3_Demo) project(Alpha_shapes_3_Demo)
# Find includes in corresponding build directories # Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -16,35 +16,38 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW) cmake_policy(SET CMP0071 NEW)
endif() endif()
find_package(CGAL COMPONENTS Qt5) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg) 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) add_definitions(-DQT_NO_KEYWORDS)
# include(${QT_USE_FILE}) # include(${QT_USE_FILE})
include_directories (BEFORE ./ ) include_directories(BEFORE ./)
# ui file, created wih Qt Designer # 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) # 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_executable(
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Alpha_shape_3 ) 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 target_link_libraries(Alpha_shape_3 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5
CGAL::CGAL CGAL::CGAL_Qt5 Qt5::OpenGL Qt5::Gui)
Qt5::OpenGL Qt5::Gui )
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(Alpha_shape_3) cgal_add_compilation_test(Alpha_shape_3)
else() 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() endif()

View File

@ -192,6 +192,10 @@ the vertices, edges, facets and cells of the different types
(`EXTERIOR`, `SINGULAR`, `REGULAR` or (`EXTERIOR`, `SINGULAR`, `REGULAR` or
`INTERIOR`). `INTERIOR`).
\subsection AlphaShape3DIO Input/Output
It is possible to export a 3D alpha shape to a `std::ostream` or to a `Geomview_stream`
using the `operator<<`, see the documentation of the class `Alpha_shape_3` for more information.
\section AlphaShape3D_ConceptAndModels Concepts and Models \section AlphaShape3D_ConceptAndModels Concepts and Models
We currently do not specify concepts for the underlying triangulation We currently do not specify concepts for the underlying triangulation

View File

@ -1,24 +1,16 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) # create a target per cppfile
file(
if ( CGAL_FOUND ) GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# create a target per cppfile ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles})
foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}")
create_single_source_cgal_program( "${cppfile}" ) endforeach()
endforeach()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -5,21 +5,23 @@
// Max-Planck-Institute Saarbruecken (Germany), // Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved. // and Tel-Aviv University (Israel). All rights reserved.
// //
// This file is part of CGAL (www.cgal.org) // This file is part of CGAL (www.cgal.org).
// //
// $URL$ // $URL$
// $Id$ // $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Andreas Fabri // Author(s) : Andreas Fabri
#ifndef CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H #ifndef CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
#define CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H #define CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
#include <CGAL/basic.h> #include <CGAL/license/Alpha_shapes_3.h>
#include <CGAL/IO/VRML_2_ostream.h>
#include <CGAL/Alpha_shape_3.h>
#include <CGAL/IO/VRML/VRML_2_ostream.h>
#include <CGAL/number_utils.h>
#ifdef CGAL_ALPHA_SHAPE_3_H
namespace CGAL { namespace CGAL {
template <class Dt > template <class Dt >
@ -90,6 +92,5 @@ operator<<(VRML_2_ostream& os,
} }
} //namespace CGAL } //namespace CGAL
#endif // CGAL_ALPHA_SHAPE_3_H
#endif CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H #endif // CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H

View File

@ -4,7 +4,6 @@ Arithmetic_kernel
Cartesian_kernel Cartesian_kernel
Circulator Circulator
Filtered_kernel Filtered_kernel
Geomview
Hash_map Hash_map
Homogeneous_kernel Homogeneous_kernel
Installation Installation

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) include_directories(BEFORE "include")
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()
# 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()

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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 ) include(${CGAL_USE_FILE})
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()
# 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()

View File

@ -1,26 +1,18 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) 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) include_directories(BEFORE "include")
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()
# 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()

View File

@ -1,56 +1,53 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( Arithmetic_kernel_Tests ) project(Arithmetic_kernel_Tests)
find_package(CGAL REQUIRED COMPONENTS Core)
find_package(CGAL QUIET COMPONENTS Core)
find_package(GMP QUIET) find_package(GMP QUIET)
if ( CGAL_FOUND AND GMP_FOUND ) if(GMP_FOUND)
include(${CGAL_USE_FILE}) 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) include_directories(include)
find_package( MPFI ) find_package(MPFI)
if( MPFI_FOUND ) if(MPFI_FOUND)
include( ${MPFI_USE_FILE} ) include(${MPFI_USE_FILE})
# for the testsuite, the version of MPFI shipped with RS is used; this # 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 # version needs GMP>=4.2, so we require this dependency only here and
# not in FindMPFI.cmake # not in FindMPFI.cmake
if( _IS_GMP_VERSION_TO_LOW ) if(_IS_GMP_VERSION_TO_LOW)
message( STATUS message(
"MPFI tests need GMP>=4.2, some of the tests will not be compiled" ) STATUS
else( _IS_GMP_VERSION_TO_LOW ) "MPFI tests need GMP>=4.2, some of the tests will not be compiled")
include( ${MPFI_USE_FILE} ) else(_IS_GMP_VERSION_TO_LOW)
create_single_source_cgal_program( "GMP_arithmetic_kernel.cpp" ) include(${MPFI_USE_FILE})
endif( _IS_GMP_VERSION_TO_LOW ) create_single_source_cgal_program("GMP_arithmetic_kernel.cpp")
else( MPFI_FOUND ) endif(_IS_GMP_VERSION_TO_LOW)
message( STATUS else(MPFI_FOUND)
"MPFI is not present, some of the tests will not be compiled." ) message(
endif( MPFI_FOUND ) 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("Arithmetic_kernel.cpp")
create_single_source_cgal_program( "LEDA_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("CORE_arithmetic_kernel.cpp")
create_single_source_cgal_program( "Get_arithmetic_kernel.cpp" ) create_single_source_cgal_program("Get_arithmetic_kernel.cpp")
else() 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() endif()

View File

@ -10,7 +10,7 @@
// Author(s) : Oren Salzman <orenzalz@post.tau.ac.il > // Author(s) : Oren Salzman <orenzalz@post.tau.ac.il >
// Michael Hemmer <Michael.Hemmer@sophia.inria.fr> // Michael Hemmer <Michael.Hemmer@sophia.inria.fr>
//TODO: somehow use the fact the the x-value is the same in all comparisons //TODO: somehow use the fact the x-value is the same in all comparisons
#ifndef CGAL_ARR_VERTICAL_SEGMENT_TRAITS #ifndef CGAL_ARR_VERTICAL_SEGMENT_TRAITS
#define CGAL_ARR_VERTICAL_SEGMENT_TRAITS #define CGAL_ARR_VERTICAL_SEGMENT_TRAITS
@ -660,23 +660,33 @@ public:
return Equal_2(_traits); return Equal_2(_traits);
} }
/*! A functor that divides a curve into continues (x-monotone) curves. */ //! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 class Make_x_monotone_2
{ {
private: private:
Traits& _traits; Traits& _traits;
public: public:
Make_x_monotone_2(Traits& traits) : _traits(traits) {} Make_x_monotone_2(Traits& traits) : _traits(traits) {}
template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) const /*! Subdivide a given curve into x-monotone subcurves and insert them into
* a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return The past-the-end iterator.
*/
template <class OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{ {
Object_vector res (boost::apply_visitor(Make_x_monotone_2_visitor(_traits),cv.variant())); Object_vector res (boost::apply_visitor(Make_x_monotone_2_visitor(_traits),cv.variant()));
re_cast_object_vector(res,oi); re_cast_object_vector(res,oi);
return (oi); return (oi);
} }
private: private:
class Make_x_monotone_2_visitor class Make_x_monotone_2_visitor :
: public boost::static_visitor < Object_vector > public boost::static_visitor < Object_vector >
{ {
private: private:
typedef boost::static_visitor <Object_vector> Base; typedef boost::static_visitor <Object_vector> Base;
@ -1787,4 +1797,3 @@ public:
#endif // CGAL_DONT_SUBMIT #endif // CGAL_DONT_SUBMIT
#endif //CGAL_ARR_RATIONAL_ARC_TRAITS_D_1_H #endif //CGAL_ARR_RATIONAL_ARC_TRAITS_D_1_H

View File

@ -80,7 +80,7 @@ public:
Arr_rational_arc_traits_2 () Arr_rational_arc_traits_2 ()
{} {}
/// \name Functor definitions. /// \name Basic functor definitions.
//@{ //@{
/*! A functor that compares the x-coordinates of two points */ /*! A functor that compares the x-coordinates of two points */
@ -381,19 +381,22 @@ public:
{ {
return Equal_2(); return Equal_2();
} }
//@}
//! \name Intersections, subdivisions, and mergings
//@{
/*! A functor that divides a curve into continues (x-monotone) curves. */ /*! A functor that divides a curve into continues (x-monotone) curves. */
class Make_x_monotone_2 class Make_x_monotone_2
{ {
public: public:
/*! /*! Subdivide a given rational arc into x-monotone subcurves and insert them
* Cut the given conic curve (or conic arc) into x-monotone subcurves * into a given output iterator.
* and insert them to the given output iterator. * \param cv the arc.
* \param cv The curve. * \param oi an output iterator for the result. Its value type is a variant
* \param oi The output iterator, whose value-type is Object. The returned * that wraps Point_2 or an X_monotone_curve_2 objects.
* objects is a wrapper for an X_monotone_curve_2 object. * \return the past-the-end iterator.
* \return The past-the-end iterator.
*/ */
template<class OutputIterator> template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) OutputIterator operator() (const Curve_2& cv, OutputIterator oi)

View File

@ -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();
}

View File

@ -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 <QDialog>
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

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AlgebraicCurveInputDialog</class>
<widget class="QDialog" name="AlgebraicCurveInputDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>448</width>
<height>173</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="0" rowspan="2" colspan="2">
<widget class="QLabel" name="label_3">
<property name="midLineWidth">
<number>1</number>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Enter the polynomial that represents the curve you would like to insert.&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;For example, to insert a circle of radius 10 centered at (10,10) enter:&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; color:#000000;&quot;&gt;(x-10)^2+(y-10)^2=10^2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AlgebraicCurveInputDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AlgebraicCurveInputDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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 <ssingh@cs.iitr.ac.in>
// Ahmed Essam <theartful.ae@gmail.com>
#include <CGAL/Polynomial_traits_d.h>
#include <CGAL/polynomial_utils.h>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
#include "AlgebraicCurveParser.h"
namespace phx = boost::phoenix;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template <typename Polynomial_d, typename Iterator, typename Skipper>
struct PolynomialParser : qi::grammar<Iterator, Polynomial_d(), Skipper>
{
using Self = PolynomialParser<Polynomial_d, Iterator, Skipper>;
using Traits = CGAL::Polynomial_traits_d<Polynomial_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<Polynomial_d>(qi::_1)] | var[_val = qi::_1];
coeff = qi::as_string[qi::lexeme[+qi::digit]]
[_val = phx::construct<Coefficient>(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<Iterator, Polynomial_d(), Skipper> start;
qi::rule<Iterator, Polynomial_d(), Skipper> expr;
qi::rule<Iterator, Polynomial_d(), Skipper> term;
qi::rule<Iterator, Polynomial_d(), Skipper> pow_expr;
qi::rule<Iterator, Polynomial_d(), Skipper> factor;
qi::rule<Iterator, Polynomial_d(), Skipper> factor2;
qi::rule<Iterator, Polynomial_d(), Skipper> factor3;
qi::rule<Iterator, Polynomial_d(), Skipper> var;
qi::rule<Iterator, Coefficient(), Skipper> 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 <typename Polynomial_d>
boost::optional<Polynomial_d>
AlgebraicCurveParser<Polynomial_d>::operator()(const std::string& expression)
{
using Traits = CGAL::Polynomial_traits_d<Polynomial_d>;
using iterator_type = std::string::const_iterator;
if (!hasValidChars(expression, Traits::d)) return {};
PolynomialParser<Polynomial_d, iterator_type, ascii::space_type> 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<demo_types::Alg_seg_traits::Polynomial_2>;
// AlgebraicCurveParser<demo_types::Rational_traits::Polynomial_1>;
#include <CGAL/Algebraic_kernel_d_1.h>
#include <CGAL/Arr_algebraic_segment_traits_2.h>
template struct AlgebraicCurveParser<
CGAL::Arr_algebraic_segment_traits_2<CORE::BigInt>::Polynomial_2>;
template struct AlgebraicCurveParser<
typename CGAL::Algebraic_kernel_d_1<CORE::BigInt>::Polynomial_1>;
#endif

View File

@ -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 <ssingh@cs.iitr.ac.in>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H
#define ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H
#include <vector>
#include <string>
#include <boost/optional.hpp>
template <typename Polynomial_d>
struct AlgebraicCurveParser
{
boost::optional<Polynomial_d> operator()(const std::string& expression);
};
#endif //ARRANGEMENT_ON_SURFACE_2_DEMO_ALGEBRAICCURVEPARSERNEW_H

View File

@ -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 <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#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 <typename ArrTraits>
class ArrTraitsAdaptor
{
};
template <typename Kernel_>
class ArrTraitsAdaptor<CGAL::Arr_segment_traits_2<Kernel_>>
{
public:
typedef Kernel_ Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template <typename Kernel_>
class ArrTraitsAdaptor<CGAL::Arr_linear_traits_2<Kernel_>>
{
public:
typedef Kernel_ Kernel;
typedef CGAL::Arr_linear_traits_2<Kernel> ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template <typename SegmentTraits>
class ArrTraitsAdaptor<CGAL::Arr_polyline_traits_2<SegmentTraits>>
{
public:
typedef CGAL::Arr_polyline_traits_2<SegmentTraits> ArrTraits;
typedef typename SegmentTraits::Kernel Kernel;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template <typename RatKernel, typename AlgKernel, typename NtTraits>
class ArrTraitsAdaptor<CGAL::Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>>
{
public:
typedef CGAL::Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits> 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<CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits, BoundingTraits>>
{
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 <typename Coefficient_>
class ArrTraitsAdaptor<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>
{
public:
typedef Coefficient_ Coefficient;
typedef typename CGAL::Arr_algebraic_segment_traits_2<Coefficient> ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename ArrTraits::Algebraic_real_1 CoordinateType;
typedef CGAL::Cartesian<typename ArrTraits::Bound> Kernel;
};
template <typename AlgebraicKernel_d_1>
class ArrTraitsAdaptor<
CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1>>
{
public:
typedef typename CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1>
ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename ArrTraits::Algebraic_real_1 CoordinateType;
typedef CGAL::Cartesian<typename ArrTraits::Bound> Kernel;
};
#endif

View File

@ -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 <alextsui05@gmail.com>
#ifndef ARRANGEMENT_CURVE_INPUT_CALLBACK_H
#define ARRANGEMENT_CURVE_INPUT_CALLBACK_H
#include <CGAL/Qt/GraphicsViewInput.h>
#include <CGAL/Qt/Converter.h>
#include <QEvent>
#include <QGraphicsLineItem>
#include <QGraphicsSceneMouseEvent>
#include <iostream>
#include "GraphicsViewCurveInput.h"
#include "Utils.h"
template <typename Arr_, typename ArrTraits = typename Arr_::Geometry_traits_2>
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

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,114 +7,49 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#include "ArrangementDemoGraphicsView.h" #include "ArrangementDemoGraphicsView.h"
#include <iostream> #include <iostream>
#include <cmath>
#include <QVarLengthArray> #include <QVarLengthArray>
#include <QPen> #include <QPen>
#include <QCoreApplication>
#include <QKeyEvent>
#include <QFontMetrics>
//! Member function to setup the viewport of the screen
/*!
\param parent a Qwidget pointer to the class
*/
ArrangementDemoGraphicsView::ArrangementDemoGraphicsView( QWidget* parent ) : ArrangementDemoGraphicsView::ArrangementDemoGraphicsView( QWidget* parent ) :
QGraphicsView( parent ), QGraphicsView( parent ),
showGrid( false ), maxScale( 500000 ),
gridSize( 50 ), minScale( 0.0002 )
gridColor( ::Qt::black ),
backgroundColor( ::Qt::white )
{ {
QTransform m( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0 ); this->resetTransform();
this->setTransform( m ); this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
this->setBackgroundBrush( QBrush( backgroundColor ) ); 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; this->setTransform({1.0, 0.0, 0.0, -1.0, 0.0, 0.0});
}
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;
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,7 +7,8 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_GRAPHICS_VIEW_H #ifndef ARRANGEMENT_DEMO_GRAPHICS_VIEW_H
#define ARRANGEMENT_DEMO_GRAPHICS_VIEW_H #define ARRANGEMENT_DEMO_GRAPHICS_VIEW_H
@ -15,29 +16,22 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QColor> #include <QColor>
class QPaintEvent;
class ArrangementDemoGraphicsView : public QGraphicsView class ArrangementDemoGraphicsView : public QGraphicsView
{ {
public: public:
ArrangementDemoGraphicsView( QWidget* parent = 0 ); 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 ); void setBackgroundColor( QColor color );
QColor getBackgroundColor( ) const; QColor getBackgroundColor( ) const;
void resetTransform();
protected: protected:
void drawForeground( QPainter* painter, const QRectF& rect ); void paintEvent(QPaintEvent* event) override;
QRectF getViewportRect( ) const;
bool showGrid; qreal maxScale;
int gridSize; qreal minScale;
QColor gridColor;
QColor backgroundColor;
}; };
#endif // ARRANGEMENT_DEMO_GRAPHICS_VIEW_H #endif // ARRANGEMENT_DEMO_GRAPHICS_VIEW_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,19 +7,24 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#include "ArrangementDemoPropertiesDialog.h" #include "ArrangementDemoPropertiesDialog.h"
#include "ui_ArrangementDemoPropertiesDialog.h" #include "ui_ArrangementDemoPropertiesDialog.h"
#include "ArrangementDemoWindow.h" #include "ArrangementDemoWindow.h"
#include "PropertyValueDelegate.h" #include "PropertyValueDelegate.h"
#include "DeleteCurveMode.h"
#include "ArrangementDemoGraphicsView.h" #include "ArrangementDemoGraphicsView.h"
#include "VerticalRayShootCallback.h"
#include "ArrangementGraphicsItem.h"
#include "ArrangementDemoTab.h"
#include "EnvelopeCallback.h"
#include "GridGraphicsItem.h"
ArrangementDemoPropertiesDialog:: ArrangementDemoPropertiesDialog::
ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_, ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ ) :
Qt::WindowFlags f ) : QDialog( parent_ ),
QDialog( parent_, f ),
parent( parent_ ), parent( parent_ ),
ui( new Ui::ArrangementDemoPropertiesDialog ) ui( new Ui::ArrangementDemoPropertiesDialog )
{ {
@ -43,30 +48,14 @@ QVariant ArrangementDemoPropertiesDialog::property( int index )
// return user data, if it is set // return user data, if it is set
QVariant myData = item->data( Qt::UserRole ); QVariant myData = item->data( Qt::UserRole );
/* res = item->data( Qt::DisplayRole );
if ( qVariantCanConvert< QColor >( myData ) ||
qVariantCanConvert< DeleteCurveMode >( myData ) )
{
return myData;
}
else
{
res = item->data( Qt::DisplayRole );
}
*/
if ( myData.canConvert<QColor>() ||
myData.canConvert<DeleteCurveMode>())
{
return myData;
}
else
{
res = item->data( Qt::DisplayRole );
}
return res; return res;
} }
//! function to setup the user interface that contains the buttons to draw and manipulate like segments and cones
/*!
*/
void ArrangementDemoPropertiesDialog::setupUi( ) void ArrangementDemoPropertiesDialog::setupUi( )
{ {
this->ui->setupUi( this ); this->ui->setupUi( this );
@ -84,8 +73,6 @@ void ArrangementDemoPropertiesDialog::setupUi( )
QTableWidgetItem* envelopeVertexRadiusItem = new QTableWidgetItem; QTableWidgetItem* envelopeVertexRadiusItem = new QTableWidgetItem;
QTableWidgetItem* verticalRayEdgeColorItem = new QTableWidgetItem; QTableWidgetItem* verticalRayEdgeColorItem = new QTableWidgetItem;
QTableWidgetItem* verticalRayEdgeWidthItem = new QTableWidgetItem; QTableWidgetItem* verticalRayEdgeWidthItem = new QTableWidgetItem;
QTableWidgetItem* deleteCurveModeItem = new QTableWidgetItem;
QTableWidgetItem* gridSizeItem = new QTableWidgetItem;
QTableWidgetItem* gridColorItem = new QTableWidgetItem; QTableWidgetItem* gridColorItem = new QTableWidgetItem;
this->ui->tableWidget->setItem( int(EDGE_COLOR_KEY), 0, edgeColorItem ); 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(EDGE_WIDTH_KEY), 0, edgeWidthItem );
this->ui->tableWidget->setItem( int(VERTEX_RADIUS_KEY), 0, vertexRadiusItem ); this->ui->tableWidget->setItem( int(VERTEX_RADIUS_KEY), 0, vertexRadiusItem );
this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_COLOR_KEY), 0, this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_COLOR_KEY), 0,
envelopeEdgeColorItem ); envelopeEdgeColorItem );
this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_COLOR_KEY), 0, this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_COLOR_KEY), 0,
envelopeVertexColorItem ); envelopeVertexColorItem );
this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_WIDTH_KEY), 0, this->ui->tableWidget->setItem( int(ENVELOPE_EDGE_WIDTH_KEY), 0,
envelopeEdgeWidthItem ); envelopeEdgeWidthItem );
this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_RADIUS_KEY), 0, this->ui->tableWidget->setItem( int(ENVELOPE_VERTEX_RADIUS_KEY), 0,
envelopeVertexRadiusItem ); envelopeVertexRadiusItem );
this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_COLOR_KEY), 0, this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_COLOR_KEY), 0,
verticalRayEdgeColorItem ); verticalRayEdgeColorItem );
this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_WIDTH_KEY), 0, this->ui->tableWidget->setItem( int(VERTICAL_RAY_EDGE_WIDTH_KEY), 0,
verticalRayEdgeWidthItem ); verticalRayEdgeWidthItem );
this->ui->tableWidget->setItem( int(DELETE_CURVE_MODE_KEY), 0,
deleteCurveModeItem );
this->ui->tableWidget->setItem( int(GRID_SIZE_KEY), 0, gridSizeItem );
this->ui->tableWidget->setItem( int(GRID_COLOR_KEY), 0, gridColorItem ); this->ui->tableWidget->setItem( int(GRID_COLOR_KEY), 0, gridColorItem );
// fill in the items with data // fill in the items with data
this->updateUi( ); this->updateUi( );
} }
//! Adding a new tab whenever the user creates a new file and updating the menu options accordingly
/*!
*/
void ArrangementDemoPropertiesDialog::updateUi( ) void ArrangementDemoPropertiesDialog::updateUi( )
{ {
if ( this->parent == NULL ) if ( this->parent == NULL )
{ {
return; return;
} }
ArrangementDemoTabBase* currentTab = this->parent->getCurrentTab( ); ArrangementDemoTab* currentTab = this->parent->getCurrentTab();
if ( currentTab == NULL ) if ( currentTab == NULL )
{ {
return; return;
@ -130,10 +117,10 @@ void ArrangementDemoPropertiesDialog::updateUi( )
return; return;
} }
ArrangementDemoGraphicsView* view = currentTab->getView( );
EnvelopeCallbackBase* envelopeCallback = currentTab->getEnvelopeCallback( ); EnvelopeCallbackBase* envelopeCallback = currentTab->getEnvelopeCallback( );
VerticalRayShootCallbackBase* verticalRayShootCallback = VerticalRayShootCallbackBase* verticalRayShootCallback =
currentTab->getVerticalRayShootCallback( ); currentTab->getVerticalRayShootCallback( );
GridGraphicsItem* gridGraphicsItem = currentTab->getGridGraphicsItem();
QPen vertexPen = agi->getVerticesPen( ); QPen vertexPen = agi->getVerticesPen( );
QPen edgePen = agi->getEdgesPen( ); QPen edgePen = agi->getEdgesPen( );
@ -143,42 +130,37 @@ void ArrangementDemoPropertiesDialog::updateUi( )
QColor edgeColor = edgePenBrush.color( ); QColor edgeColor = edgePenBrush.color( );
unsigned int edgeWidth = edgePen.width( ); unsigned int edgeWidth = edgePen.width( );
unsigned int vertexRadius = vertexPen.width( ); unsigned int vertexRadius = vertexPen.width( );
unsigned int gridSize = view->getGridSize( ); QColor gridColor = gridGraphicsItem->getAxesColor( );
QColor gridColor = view->getGridColor( );
unsigned int envelopeEdgeWidth = envelopeCallback->getEnvelopeEdgeWidth( ); unsigned int envelopeEdgeWidth = envelopeCallback->getEnvelopeEdgeWidth( );
unsigned int envelopeVertexRadius = unsigned int envelopeVertexRadius =
envelopeCallback->getEnvelopeVertexRadius( ); envelopeCallback->getEnvelopeVertexRadius( );
QColor envelopeEdgeColor = envelopeCallback->getEnvelopeEdgeColor( ); QColor envelopeEdgeColor = envelopeCallback->getEnvelopeEdgeColor( );
QColor envelopeVertexColor = envelopeCallback->getEnvelopeVertexColor( ); QColor envelopeVertexColor = envelopeCallback->getEnvelopeVertexColor( );
unsigned int verticalRayEdgeWidth = verticalRayShootCallback->edgeWidth( ); unsigned int verticalRayEdgeWidth = verticalRayShootCallback->edgeWidth( );
QColor verticalRayEdgeColor = verticalRayShootCallback->edgeColor( ); QColor verticalRayEdgeColor = verticalRayShootCallback->edgeColor( );
QTableWidgetItem* edgeColorItem = QTableWidgetItem* edgeColorItem =
this->ui->tableWidget->item( int(EDGE_COLOR_KEY), 0 ); this->ui->tableWidget->item( int(EDGE_COLOR_KEY), 0 );
QTableWidgetItem* edgeWidthItem = QTableWidgetItem* edgeWidthItem =
this->ui->tableWidget->item( int(EDGE_WIDTH_KEY), 0 ); this->ui->tableWidget->item( int(EDGE_WIDTH_KEY), 0 );
QTableWidgetItem* vertexColorItem = QTableWidgetItem* vertexColorItem =
this->ui->tableWidget->item( int(VERTEX_COLOR_KEY), 0 ); this->ui->tableWidget->item( int(VERTEX_COLOR_KEY), 0 );
QTableWidgetItem* vertexRadiusItem = QTableWidgetItem* vertexRadiusItem =
this->ui->tableWidget->item( int(VERTEX_RADIUS_KEY), 0 ); 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 );
QTableWidgetItem* gridColorItem = QTableWidgetItem* gridColorItem =
this->ui->tableWidget->item( int( GRID_COLOR_KEY ), 0 ); this->ui->tableWidget->item( int( GRID_COLOR_KEY ), 0 );
QTableWidgetItem* envelopeEdgeColorItem = QTableWidgetItem* envelopeEdgeColorItem =
this->ui->tableWidget->item( int(ENVELOPE_EDGE_COLOR_KEY), 0 ); this->ui->tableWidget->item( int(ENVELOPE_EDGE_COLOR_KEY), 0 );
QTableWidgetItem* envelopeEdgeWidthItem = QTableWidgetItem* envelopeEdgeWidthItem =
this->ui->tableWidget->item( int(ENVELOPE_EDGE_WIDTH_KEY), 0 ); this->ui->tableWidget->item( int(ENVELOPE_EDGE_WIDTH_KEY), 0 );
QTableWidgetItem* envelopeVertexColorItem = QTableWidgetItem* envelopeVertexColorItem =
this->ui->tableWidget->item( int(ENVELOPE_VERTEX_COLOR_KEY), 0 ); this->ui->tableWidget->item( int(ENVELOPE_VERTEX_COLOR_KEY), 0 );
QTableWidgetItem* envelopeVertexRadiusItem = QTableWidgetItem* envelopeVertexRadiusItem =
this->ui->tableWidget->item( int(ENVELOPE_VERTEX_RADIUS_KEY), 0 ); this->ui->tableWidget->item( int(ENVELOPE_VERTEX_RADIUS_KEY), 0 );
QTableWidgetItem* verticalRayEdgeColorItem = 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 = 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 // arrangement properties
edgeColorItem->setData( Qt::DisplayRole, edgeColor ); edgeColorItem->setData( Qt::DisplayRole, edgeColor );
@ -197,14 +179,14 @@ void ArrangementDemoPropertiesDialog::updateUi( )
envelopeEdgeColorItem->setData( Qt::DisplayRole, envelopeEdgeColor ); envelopeEdgeColorItem->setData( Qt::DisplayRole, envelopeEdgeColor );
envelopeEdgeColorItem->setData( Qt::DecorationRole, envelopeEdgeColor ); envelopeEdgeColorItem->setData( Qt::DecorationRole, envelopeEdgeColor );
envelopeEdgeColorItem->setData( Qt::UserRole, envelopeEdgeColorItem->setData( Qt::UserRole,
QVariant::fromValue( envelopeEdgeColor ) ); QVariant::fromValue( envelopeEdgeColor ) );
envelopeEdgeWidthItem->setData( Qt::DisplayRole, envelopeEdgeWidth ); envelopeEdgeWidthItem->setData( Qt::DisplayRole, envelopeEdgeWidth );
envelopeVertexColorItem->setData( Qt::DisplayRole, envelopeVertexColor ); envelopeVertexColorItem->setData( Qt::DisplayRole, envelopeVertexColor );
envelopeVertexColorItem->setData( Qt::DecorationRole, envelopeVertexColor ); envelopeVertexColorItem->setData( Qt::DecorationRole, envelopeVertexColor );
envelopeVertexColorItem->setData( Qt::UserRole, envelopeVertexColorItem->setData( Qt::UserRole,
QVariant::fromValue(envelopeVertexColor)); QVariant::fromValue(envelopeVertexColor));
envelopeVertexRadiusItem->setData( Qt::DisplayRole, envelopeVertexRadius ); envelopeVertexRadiusItem->setData( Qt::DisplayRole, envelopeVertexRadius );
@ -212,22 +194,12 @@ void ArrangementDemoPropertiesDialog::updateUi( )
verticalRayEdgeColorItem->setData( Qt::DisplayRole, verticalRayEdgeColor ); verticalRayEdgeColorItem->setData( Qt::DisplayRole, verticalRayEdgeColor );
verticalRayEdgeColorItem->setData( Qt::DecorationRole, verticalRayEdgeColor ); verticalRayEdgeColorItem->setData( Qt::DecorationRole, verticalRayEdgeColor );
verticalRayEdgeColorItem->setData( Qt::UserRole, verticalRayEdgeColorItem->setData( Qt::UserRole,
QVariant::fromValue(verticalRayEdgeColor)); QVariant::fromValue(verticalRayEdgeColor));
verticalRayEdgeWidthItem->setData( Qt::DisplayRole, verticalRayEdgeWidth ); 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 // grid properties
gridSizeItem->setData( Qt::DisplayRole, gridSize );
gridColorItem->setData( Qt::DisplayRole, gridColor ); gridColorItem->setData( Qt::DisplayRole, gridColor );
gridColorItem->setData( Qt::DecorationRole, gridColor ); gridColorItem->setData( Qt::DecorationRole, gridColor );
gridColorItem->setData( Qt::UserRole, QVariant::fromValue( gridColor ) ); gridColorItem->setData( Qt::UserRole, QVariant::fromValue( gridColor ) );
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,7 +7,8 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H #ifndef ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H
#define ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H #define ARRANGEMENT_DEMO_PROPERTIES_DIALOG_H
@ -27,23 +28,20 @@ class ArrangementDemoPropertiesDialog : public QDialog
public: public:
// keep this in order with the ui layout // keep this in order with the ui layout
enum PropertyKey { enum PropertyKey {
EDGE_COLOR_KEY, EDGE_COLOR_KEY, /*!< color key */
EDGE_WIDTH_KEY, EDGE_WIDTH_KEY, /*!< width key */
VERTEX_COLOR_KEY, VERTEX_COLOR_KEY, /*!< vertex color */
VERTEX_RADIUS_KEY, VERTEX_RADIUS_KEY, /*!< vertex radius */
ENVELOPE_EDGE_COLOR_KEY, ENVELOPE_EDGE_COLOR_KEY, /*!< envelope color */
ENVELOPE_EDGE_WIDTH_KEY, ENVELOPE_EDGE_WIDTH_KEY, /*!< envelope size */
ENVELOPE_VERTEX_COLOR_KEY, ENVELOPE_VERTEX_COLOR_KEY, /*!< envelope vertex color */
ENVELOPE_VERTEX_RADIUS_KEY, ENVELOPE_VERTEX_RADIUS_KEY, /*!< color key */
VERTICAL_RAY_EDGE_COLOR_KEY, VERTICAL_RAY_EDGE_COLOR_KEY, /*!< shooting ray color */
VERTICAL_RAY_EDGE_WIDTH_KEY, VERTICAL_RAY_EDGE_WIDTH_KEY, /*!< shooting ray size */
DELETE_CURVE_MODE_KEY, GRID_COLOR_KEY /*!< color of the grid */
GRID_SIZE_KEY,
GRID_COLOR_KEY
}; };
ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ = 0, ArrangementDemoPropertiesDialog( ArrangementDemoWindow* parent_ = 0 );
Qt::WindowFlags f = Qt::WindowType(0));
QVariant property( int index ); QVariant property( int index );
protected: protected:

View File

@ -78,16 +78,6 @@
<string>Vertical Ray Edge Width</string> <string>Vertical Ray Edge Width</string>
</property> </property>
</row> </row>
<row>
<property name="text">
<string>Delete Curve Mode</string>
</property>
</row>
<row>
<property name="text">
<string>Grid Size</string>
</property>
</row>
<row> <row>
<property name="text"> <property name="text">
<string>Grid Color</string> <string>Grid Color</string>

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,95 +7,400 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#include "ArrangementDemoTab.h" #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 <CGAL/Qt/GraphicsViewNavigation.h>
#include <QGridLayout> #include <QGridLayout>
#include <limits>
ArrangementDemoTabBase::ArrangementDemoTabBase( QWidget* parent ) :
QWidget( parent ), ArrangementDemoTab::ArrangementDemoTab(
graphicsView( new ArrangementDemoGraphicsView( this ) ), QWidget* parent, demo_types::TraitsType tt, CGAL::Object arrangement_) :
scene( new QGraphicsScene( -100, -100, 100, 100 ) ), QWidget(parent),
layout( new QGridLayout( this ) ), GraphicsSceneMixin(new QGraphicsScene()),
arrangementGraphicsItem( NULL ), graphicsView(new ArrangementDemoGraphicsView(this)),
curveInputCallback( NULL ), layout(new QGridLayout(this)),
deleteCurveCallback( NULL ), navigation(std::make_unique<CGAL::Qt::GraphicsViewNavigation>()),
pointLocationCallback( NULL ), activeCallback(nullptr), arrangementGraphicsItem(nullptr),
verticalRayShootCallback( NULL ), gridGraphicsItem(nullptr), ttype(tt), arrangement(arrangement_)
mergeEdgeCallback( NULL ),
splitEdgeCallback( NULL ),
envelopeCallback( NULL ),
fillFaceCallback( NULL )
{ {
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 ); auto scene = this->getScene();
this->graphicsView->setScene( this->scene );
this->graphicsView->setMouseTracking( true ); this->layout->addWidget(this->graphicsView, 0, 0);
this->graphicsView->setScene(scene);
double MAX_WIDTH = (std::numeric_limits<double>::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 QGraphicsView* ArrangementDemoTab::getView() const
{
return this->scene;
}
ArrangementDemoGraphicsView* ArrangementDemoTabBase::getView( ) const
{ {
return this->graphicsView; return this->graphicsView;
} }
CGAL::Qt::ArrangementGraphicsItemBase* CGAL::Qt::ArrangementGraphicsItemBase*
ArrangementDemoTabBase::getArrangementGraphicsItem( ) const ArrangementDemoTab::getArrangementGraphicsItem() const
{ {
return this->arrangementGraphicsItem; 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* 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* 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<CGAL::Qt::Callback*>(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>(PointSnapperBase::create(
this->traitsType(), scene, this->gridGraphicsItem, this->getArrangement()));
this->curveInputCallback =
std::unique_ptr<CGAL::Qt::GraphicsViewCurveInputBase>(
CGAL::Qt::GraphicsViewCurveInputBase::create(
this->traitsType(), this->getArrangement(), this, scene));
this->deleteCurveCallback =
std::unique_ptr<DeleteCurveCallbackBase>(DeleteCurveCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->pointLocationCallback = std::unique_ptr<PointLocationCallbackBase>(
PointLocationCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->verticalRayShootCallback =
std::unique_ptr<VerticalRayShootCallbackBase>(
VerticalRayShootCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->mergeEdgeCallback =
std::unique_ptr<MergeEdgeCallbackBase>(MergeEdgeCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->splitEdgeCallback =
std::unique_ptr<SplitEdgeCallbackBase>(SplitEdgeCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->envelopeCallback =
std::unique_ptr<EnvelopeCallbackBase>(EnvelopeCallbackBase::create(
this->traitsType(), this->getArrangement(), this));
this->fillFaceCallback =
std::unique_ptr<FillFaceCallbackBase>(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();
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,195 +7,148 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_TAB_H #ifndef ARRANGEMENT_DEMO_TAB_H
#define ARRANGEMENT_DEMO_TAB_H #define ARRANGEMENT_DEMO_TAB_H
#include "GraphicsSceneMixin.h"
#include <CGAL/Object.h>
#include <QWidget> #include <QWidget>
#include <QColor>
#include <memory>
#include "ArrangementGraphicsItem.h" class QGraphicsScene;
#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 QGridLayout; 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_OBJECT
Q_SIGNALS: Q_SIGNALS:
void modelChanged( ); void modelChanged( );
public: public:
ArrangementDemoTabBase( QWidget* parent ); ArrangementDemoTab(
virtual ~ArrangementDemoTabBase( ); QWidget* parent, demo_types::TraitsType tt, CGAL::Object arrangement_);
virtual QGraphicsScene* getScene( ) const; virtual ~ArrangementDemoTab();
virtual ArrangementDemoGraphicsView* getView( ) const;
virtual CGAL::Qt::ArrangementGraphicsItemBase* getArrangementGraphicsItem( ) CGAL::Object getArrangement() const;
const; demo_types::TraitsType traitsType() const;
virtual CGAL::Qt::GraphicsViewCurveInputBase* getCurveInputCallback( ) const;
virtual CGAL::Qt::Callback* getDeleteCurveCallback( ) const; QGraphicsView* getView() const;
virtual CGAL::Qt::Callback* getPointLocationCallback( ) const; void showGrid(bool);
virtual VerticalRayShootCallbackBase* getVerticalRayShootCallback( ) const; bool isGridVisible();
virtual CGAL::Qt::Callback* getMergeEdgeCallback( ) const; void setSnapToGrid(bool);
virtual SplitEdgeCallbackBase* getSplitEdgeCallback( ) const; void setSnapToArrangement(bool);
virtual EnvelopeCallbackBase* getEnvelopeCallback( ) const; bool isSnapToGridEnabled();
virtual FillFaceCallbackBase* getFillFaceCallback( ) const; 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: protected:
void initArrangement();
void initComponents();
void setupCallbacks();
virtual void setupUi( ); virtual void setupUi( );
void unhookAndInstallEventFilter(CGAL::Qt::Callback*);
ArrangementDemoGraphicsView* graphicsView; ArrangementDemoGraphicsView* graphicsView;
QGraphicsScene* scene;
QGridLayout* layout; QGridLayout* layout;
CGAL::Qt::ArrangementGraphicsItemBase* arrangementGraphicsItem; std::unique_ptr<CGAL::Qt::GraphicsViewCurveInputBase> curveInputCallback;
CGAL::Qt::GraphicsViewCurveInputBase* curveInputCallback; std::unique_ptr<DeleteCurveCallbackBase> deleteCurveCallback;
CGAL::Qt::Callback* deleteCurveCallback; std::unique_ptr<PointLocationCallbackBase> pointLocationCallback;
CGAL::Qt::Callback* pointLocationCallback; std::unique_ptr<VerticalRayShootCallbackBase> verticalRayShootCallback;
VerticalRayShootCallbackBase* verticalRayShootCallback; std::unique_ptr<MergeEdgeCallbackBase> mergeEdgeCallback;
CGAL::Qt::Callback* mergeEdgeCallback; std::unique_ptr<SplitEdgeCallbackBase> splitEdgeCallback;
SplitEdgeCallbackBase* splitEdgeCallback; std::unique_ptr<EnvelopeCallbackBase> envelopeCallback;
EnvelopeCallbackBase* envelopeCallback; std::unique_ptr<FillFaceCallbackBase> fillFaceCallback;
FillFaceCallbackBase* fillFaceCallback; std::unique_ptr<PointSnapperBase> snapper;
std::unique_ptr<CGAL::Qt::GraphicsViewNavigation> navigation;
CGAL::Qt::Callback* activeCallback;
CGAL::Qt::ArrangementGraphicsItemBase* arrangementGraphicsItem;
GridGraphicsItem* gridGraphicsItem;
demo_types::TraitsType ttype;
CGAL::Object arrangement;
}; // class ArrangementDemoTabBase }; // class ArrangementDemoTabBase
template < class Arr_ >
class ArrangementDemoTab : public ArrangementDemoTabBase
{
public:
typedef ArrangementDemoTabBase Superclass;
typedef Arr_ Arrangement;
ArrangementDemoTab( Arrangement* arrangement_, QWidget* parent = 0 ):
Superclass( parent ),
arrangement( arrangement_ )
{
// std::cout << this->scene->views( ).size( ) << std::endl;
// set up demo components
this->arrangementGraphicsItem =
new CGAL::Qt::ArrangementGraphicsItem<Arrangement>(this->arrangement);
this->curveInputCallback =
new ArrangementCurveInputCallback<Arrangement>(this->arrangement, this);
this->deleteCurveCallback =
new DeleteCurveCallback<Arrangement>( this->arrangement, this );
this->pointLocationCallback =
new PointLocationCallback<Arrangement>( this->arrangement, this );
this->verticalRayShootCallback =
new VerticalRayShootCallback<Arrangement>( this->arrangement, this );
this->mergeEdgeCallback =
new MergeEdgeCallback<Arrangement>( this->arrangement, this );
this->splitEdgeCallback =
new SplitEdgeCallback<Arrangement>( this->arrangement, this );
this->envelopeCallback =
new EnvelopeCallback<Arrangement>( this->arrangement, this );
this->fillFaceCallback =
new FillFaceCallback<Arrangement>( this->arrangement, this );
this->scene->addItem( this->arrangementGraphicsItem );
this->arrangementGraphicsItem->setScene( this->scene );
this->curveInputCallback->setScene( this->scene );
this->deleteCurveCallback->setScene( this->scene );
this->pointLocationCallback->setScene( this->scene );
this->verticalRayShootCallback->setScene( this->scene );
this->mergeEdgeCallback->setScene( this->scene );
this->splitEdgeCallback->setScene( this->scene );
this->envelopeCallback->setScene( this->scene );
this->fillFaceCallback->setScene( this->scene );
// set up callbacks
this->scene->installEventFilter( this->curveInputCallback );
QObject::connect(this->curveInputCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this->deleteCurveCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this->fillFaceCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this, SIGNAL(modelChanged()),
this->arrangementGraphicsItem, SLOT(modelChanged()));
QObject::connect(this, SIGNAL(modelChanged()), this->envelopeCallback,
SLOT(slotModelChanged()));
// TODO: Add a connection to update the demo window when the fill color
// changes
}
void setArrangement( Arrangement* newArr )
{
this->scene->removeItem( this->arrangementGraphicsItem );
delete this->arrangementGraphicsItem;
delete this->curveInputCallback;
delete this->deleteCurveCallback;
delete this->pointLocationCallback;
delete this->verticalRayShootCallback;
delete this->mergeEdgeCallback;
delete this->splitEdgeCallback;
delete this->envelopeCallback;
delete this->fillFaceCallback;
this->arrangement = newArr;
this->arrangementGraphicsItem =
new CGAL::Qt::ArrangementGraphicsItem<Arrangement>( this->arrangement );
this->curveInputCallback =
new ArrangementCurveInputCallback<Arrangement>(this->arrangement, this);
this->deleteCurveCallback =
new DeleteCurveCallback<Arrangement>( this->arrangement, this );
this->pointLocationCallback =
new PointLocationCallback<Arrangement>( this->arrangement, this );
this->verticalRayShootCallback =
new VerticalRayShootCallback<Arrangement>( this->arrangement, this );
this->mergeEdgeCallback =
new MergeEdgeCallback<Arrangement>( this->arrangement, this );
this->splitEdgeCallback =
new SplitEdgeCallback<Arrangement>( this->arrangement, this );
this->envelopeCallback =
new EnvelopeCallback<Arrangement>( this->arrangement, this );
this->fillFaceCallback =
new FillFaceCallback<Arrangement>( this->arrangement, this );
this->scene->addItem( this->arrangementGraphicsItem );
this->arrangementGraphicsItem->setScene( this->scene );
this->curveInputCallback->setScene( this->scene );
this->deleteCurveCallback->setScene( this->scene );
this->pointLocationCallback->setScene( this->scene );
this->verticalRayShootCallback->setScene( this->scene );
this->mergeEdgeCallback->setScene( this->scene );
this->splitEdgeCallback->setScene( this->scene );
this->envelopeCallback->setScene( this->scene );
this->fillFaceCallback->setScene( this->scene );
this->scene->installEventFilter(this->curveInputCallback);
QObject::connect(this->curveInputCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this->deleteCurveCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this->fillFaceCallback, SIGNAL(modelChanged()), this,
SIGNAL(modelChanged()));
QObject::connect(this, SIGNAL(modelChanged()),
this->arrangementGraphicsItem, SLOT(modelChanged()));
QObject::connect(this, SIGNAL(modelChanged()), this->envelopeCallback,
SLOT(slotModelChanged()));
// TODO: Add a connection to update the demo window when the fill color
// changes
Q_EMIT modelChanged( );
}
protected:
Arrangement* arrangement;
}; // class ArrangementDemoTab
#endif // ARRANGEMENT_DEMO_TAB_H #endif // ARRANGEMENT_DEMO_TAB_H

View File

@ -1,138 +1,109 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
// //
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_WINDOW_H #ifndef ARRANGEMENT_DEMO_WINDOW_H
#define ARRANGEMENT_DEMO_WINDOW_H #define ARRANGEMENT_DEMO_WINDOW_H
#include "ArrangementGraphicsItem.h" #include <CGAL/Object.h>
#include "ArrangementTypes.h"
#include "DeleteCurveCallback.h"
#include "PointLocationCallback.h"
#include "VerticalRayShootCallback.h"
#include "MergeEdgeCallback.h"
#include "SplitEdgeCallback.h"
#include "EnvelopeCallback.h"
#include "ArrangementDemoTab.h"
#include <CGAL/Arr_overlay_2.h>
#include <CGAL/Arr_default_overlay_traits.h>
#include <CGAL/Qt/DemosMainWindow.h> #include <CGAL/Qt/DemosMainWindow.h>
extern const char * hand_xpm[];
#include <Qt> #include <Qt>
#include <utility>
#include <vector>
#include "ui_ArrangementDemoWindow.h" namespace Ui
{
class ArrangementDemoWindow;
}
//#include <QFileDialog> namespace CGAL
//#include <QInputDialog> {
//#include <QMessageBox> class Object;
//#include <QtGui> namespace Qt
{
class GraphicsViewNavigation;
}
} // namespace CGAL
namespace Ui { class ArrangementDemoWindow; } namespace demo_types
{
enum class TraitsType;
}
class ArrangementDemoTab;
class QActionGroup; class QActionGroup;
class ArrangementDemoWindow : public CGAL::Qt::DemosMainWindow class ArrangementDemoWindow : public CGAL::Qt::DemosMainWindow
{ {
Q_OBJECT Q_OBJECT
public:
#if 0
typedef Seg_traits::Point_2 Point;
typedef Seg_traits::Segment_2 Segment;
#endif
typedef enum TraitsType {
SEGMENT_TRAITS,
POLYLINE_TRAITS,
CONIC_TRAITS,
LINEAR_TRAITS,
CIRCULAR_ARC_TRAITS
// ALGEBRAIC_TRAITS
} TraitsType;
ArrangementDemoWindow(QWidget* parent = 0); public:
ArrangementDemoWindow(QWidget* parent = nullptr);
~ArrangementDemoWindow(); ~ArrangementDemoWindow();
ArrangementDemoTabBase* makeTab( TraitsType tt ); ArrangementDemoTab* getCurrentTab();
ArrangementDemoTabBase* getTab( unsigned int tabIndex ) const;
ArrangementDemoTabBase* getCurrentTab( ) const;
std::vector< QString > getTabLabels( ) const;
std::vector< CGAL::Object > getArrangements( ) const;
template < class ArrType >
void makeOverlayTab( ArrType* arr1, ArrType* arr2 );
public Q_SLOTS: public Q_SLOTS:
void updateMode( QAction* a ); void updateEnvelope(QAction*);
void updateEnvelope( QAction* a ); void updateInputType(QAction*);
void updateSnapping( QAction* a ); void on_actionNewTab_triggered();
void updateConicType( QAction* a ); void on_actionSaveAs_triggered();
void on_actionNewTab_triggered( ); void on_actionOpen_triggered();
void on_actionSaveAs_triggered( ); void on_actionQuit_triggered();
void on_actionOpen_triggered( ); void on_tabWidget_currentChanged(int);
void on_actionQuit_triggered( ); void on_actionOverlay_triggered();
void on_tabWidget_currentChanged( ); void on_actionCloseTab_triggered();
void on_actionOverlay_triggered( ); void on_actionZoomIn_triggered();
void on_actionCloseTab_triggered( ); void on_actionZoomOut_triggered();
void on_actionPrintConicCurves_triggered( ); void on_actionZoomReset_triggered();
void on_actionZoomIn_triggered( ); void on_actionPreferences_triggered();
void on_actionZoomOut_triggered( ); void on_actionFillColor_triggered();
void on_actionPreferences_triggered( ); void on_actionInsert_toggled(bool);
void on_actionFillColor_triggered( ); void on_actionDrag_toggled(bool);
void on_actionDelete_toggled(bool);
void on_actionDelete_triggered();
void on_actionPointLocation_toggled(bool);
void on_actionRayShootingUp_toggled(bool);
void on_actionRayShootingDown_toggled(bool);
void on_actionShowGrid_toggled(bool);
void on_actionGridSnapMode_toggled(bool);
void on_actionArrangementSnapMode_toggled(bool);
void on_actionMerge_toggled(bool);
void on_actionSplit_toggled(bool);
void on_actionFill_toggled(bool);
void on_actionAddAlgebraicCurve_triggered();
void on_actionAddRationalCurve_triggered();
Q_SIGNALS: Q_SIGNALS:
void modelChanged( ); void modelChanged();
protected: protected:
void setupUi( ); void setupUi();
void resetCallbackState( unsigned int tabIndex ); ArrangementDemoTab* makeTab(
void removeCallback( unsigned int tabIndex ); demo_types::TraitsType, QString label = {}, CGAL::Object arr_obj = {});
void updateFillColorSwatch( ); void addTab(ArrangementDemoTab*, QString);
void resetCallbackState(ArrangementDemoTab*);
void openArrFile( QString filename ); void resetActionGroups(ArrangementDemoTab*, demo_types::TraitsType);
void openDatFile( QString filename ); void hideInsertMethods();
void showInsertMethods(demo_types::TraitsType);
std::vector< ArrangementDemoTabBase* > tabs; void updateFillColorSwatch(ArrangementDemoTab*);
std::vector< CGAL::Object > arrangements; QString makeTabLabel(demo_types::TraitsType);
std::vector< QAction* > activeModes; // for the current tab; always size 1 ArrangementDemoTab* openArrFile(QString filename);
unsigned int lastTabIndex;
private:
Ui::ArrangementDemoWindow* ui; Ui::ArrangementDemoWindow* ui;
std::vector<ArrangementDemoTab*> tabs;
QActionGroup* modeGroup; QActionGroup* modeGroup;
QActionGroup* envelopeGroup; QActionGroup* envelopeGroup;
QActionGroup* snapGroup; QActionGroup* inputTypeGroup;
QActionGroup* conicTypeGroup; int tabLabelCounter;
}; };
template < class ArrType >
void
ArrangementDemoWindow::
makeOverlayTab( ArrType* arr1, ArrType* arr2 )
{
QString tabLabel = QString( "Overlay Tab" );
ArrangementDemoTabBase* demoTab;
ArrType* overlayArr = new ArrType;
CGAL::Arr_default_overlay_traits< ArrType > defaultTraits;
CGAL::overlay( *arr1, *arr2, *overlayArr, defaultTraits );
demoTab = new ArrangementDemoTab< ArrType >( overlayArr, 0 );
this->arrangements.push_back( CGAL::make_object( overlayArr ) );
this->tabs.push_back( demoTab );
QGraphicsView* view = demoTab->getView( );
this->addNavigation( view );
this->ui->tabWidget->addTab( demoTab, tabLabel );
this->lastTabIndex = this->ui->tabWidget->currentIndex( );
}
#endif // ARRANGEMENT_DEMO_WINDOW_H #endif // ARRANGEMENT_DEMO_WINDOW_H

View File

@ -1,31 +0,0 @@
<RCC>
<qresource>
<file>icons/demo_fill.xpm</file>
<file>icons/demo_conic_line.xpm</file>
<file>icons/demo_zoomin.xpm</file>
<file>icons/demo_zoomout.xpm</file>
<file>icons/yellow_icon.xpm</file>
<file>icons/red_icon.xpm</file>
<file>icons/green_icon.xpm</file>
<file>icons/blue_icon.xpm</file>
<file>icons/demo_conic_circle.xpm</file>
<file>icons/demo_conic_ellipse.xpm</file>
<file>icons/demo_conic_5points.xpm</file>
<file>icons/demo_conic_segment.xpm</file>
<file>icons/demo_conic_3points.xpm</file>
<file>icons/demo_snapvertex.xpm</file>
<file>icons/demo_conic_ray.xpm</file>
<file>icons/lower_env_xpm.xpm</file>
<file>icons/upper_env_xpm.xpm</file>
<file>icons/demo_snapgrid.xpm</file>
<file>icons/demo_split.xpm</file>
<file>icons/demo_merge.xpm</file>
<file>icons/demo_rayshoot_down.xpm</file>
<file>icons/demo_rayshoot_up.xpm</file>
<file>icons/demo_insert.xpm</file>
<file>icons/hand.xpm</file>
<file>icons/demo_delete.xpm</file>
<file>icons/demo_pointlocation.xpm</file>
<file>help/about.html</file>
</qresource>
</RCC>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>2D Arrangements Demo</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -49,20 +49,27 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionZoomIn"/> <addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/> <addaction name="actionZoomOut"/>
<addaction name="actionZoomReset"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionSnapMode"/> <addaction name="actionShowGrid"/>
<addaction name="separator"/>
<addaction name="actionArrangementSnapMode"/>
<addaction name="actionGridSnapMode"/> <addaction name="actionGridSnapMode"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionLowerEnvelope"/> <addaction name="actionLowerEnvelope"/>
<addaction name="actionUpperEnvelope"/> <addaction name="actionUpperEnvelope"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionConicSegment"/> <addaction name="actionSegment"/>
<addaction name="actionCurveRay"/> <addaction name="actionPolyline"/>
<addaction name="actionCurveLine"/> <addaction name="actionRay"/>
<addaction name="actionConicCircle"/> <addaction name="actionLine"/>
<addaction name="actionConicEllipse"/> <addaction name="actionCircle"/>
<addaction name="actionEllipse"/>
<addaction name="actionBezier"/>
<addaction name="actionConicThreePoint"/> <addaction name="actionConicThreePoint"/>
<addaction name="actionConicFivePoint"/> <addaction name="actionConicFivePoint"/>
<addaction name="actionAddAlgebraicCurve"/>
<addaction name="actionAddRationalCurve"/>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">
@ -103,11 +110,11 @@
<property name="title"> <property name="title">
<string>&amp;Edit</string> <string>&amp;Edit</string>
</property> </property>
<addaction name="actionSnapMode"/>
<addaction name="actionGridSnapMode"/>
<addaction name="separator"/>
<addaction name="actionShowGrid"/> <addaction name="actionShowGrid"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionArrangementSnapMode"/>
<addaction name="actionGridSnapMode"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/> <addaction name="actionPreferences"/>
</widget> </widget>
<widget class="QMenu" name="menuT_ools"> <widget class="QMenu" name="menuT_ools">
@ -130,12 +137,9 @@
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_insert.xpm</normaloff>:/icons/demo_insert.xpm</iconset> <normaloff>:/cgal/icons/insert.xpm</normaloff>:/cgal/icons/insert.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Insert</string> <string>&amp;Insert</string>
@ -146,8 +150,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_delete.xpm</normaloff>:/icons/demo_delete.xpm</iconset> <normaloff>:/cgal/icons/delete.xpm</normaloff>:/cgal/icons/delete.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Delete</string> <string>&amp;Delete</string>
@ -158,8 +162,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/hand.xpm</normaloff>:/icons/hand.xpm</iconset> <normaloff>:/cgal/icons/hand.xpm</normaloff>:/cgal/icons/hand.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Drag</string> <string>Drag</string>
@ -170,8 +174,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_pointlocation.xpm</normaloff>:/icons/demo_pointlocation.xpm</iconset> <normaloff>:/cgal/icons/pointlocation.xpm</normaloff>:/cgal/icons/pointlocation.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Point Location</string> <string>Point Location</string>
@ -182,8 +186,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_rayshoot_up.xpm</normaloff>:/icons/demo_rayshoot_up.xpm</iconset> <normaloff>:/cgal/icons/rayshoot_up.xpm</normaloff>:/cgal/icons/rayshoot_up.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Ray Shooting Up</string> <string>Ray Shooting Up</string>
@ -194,8 +198,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_rayshoot_down.xpm</normaloff>:/icons/demo_rayshoot_down.xpm</iconset> <normaloff>:/cgal/icons/rayshoot_down.xpm</normaloff>:/cgal/icons/rayshoot_down.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Ray Shooting Down</string> <string>Ray Shooting Down</string>
@ -206,8 +210,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_merge.xpm</normaloff>:/icons/demo_merge.xpm</iconset> <normaloff>:/cgal/icons/merge.xpm</normaloff>:/cgal/icons/merge.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Merge</string> <string>Merge</string>
@ -218,8 +222,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_split.xpm</normaloff>:/icons/demo_split.xpm</iconset> <normaloff>:/cgal/icons/split.xpm</normaloff>:/cgal/icons/split.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Split</string> <string>Split</string>
@ -230,23 +234,35 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_fill.xpm</normaloff>:/icons/demo_fill.xpm</iconset> <normaloff>:/cgal/icons/fill.xpm</normaloff>:/cgal/icons/fill.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Fill</string> <string>Fill</string>
</property> </property>
</action> </action>
<action name="actionSnapMode"> <action name="actionShowGrid">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_snapvertex.xpm</normaloff>:/icons/demo_snapvertex.xpm</iconset> <normaloff>:/cgal/icons/grid.xpm</normaloff>:/cgal/icons/grid.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Enable snapping</string> <string>Show grid</string>
</property>
</action>
<action name="actionArrangementSnapMode">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/snapvertex.xpm</normaloff>:/cgal/icons/snapvertex.xpm</iconset>
</property>
<property name="text">
<string>Snap to arrangement</string>
</property> </property>
</action> </action>
<action name="actionGridSnapMode"> <action name="actionGridSnapMode">
@ -254,28 +270,13 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_snapgrid.xpm</normaloff>:/icons/demo_snapgrid.xpm</iconset> <normaloff>:/cgal/icons/snapgrid.xpm</normaloff>:/cgal/icons/snapgrid.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Snap to grid</string> <string>Snap to grid</string>
</property> </property>
</action> </action>
<action name="actionSegment">
<property name="text">
<string>Segment</string>
</property>
</action>
<action name="actionPolyline">
<property name="text">
<string>Polyline</string>
</property>
</action>
<action name="actionConic">
<property name="text">
<string>Conic</string>
</property>
</action>
<action name="actionNewTab"> <action name="actionNewTab">
<property name="text"> <property name="text">
<string>New tab</string> <string>New tab</string>
@ -294,21 +295,13 @@
<string>&amp;Preferences...</string> <string>&amp;Preferences...</string>
</property> </property>
</action> </action>
<action name="actionShowGrid">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show &amp;grid</string>
</property>
</action>
<action name="actionLowerEnvelope"> <action name="actionLowerEnvelope">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/lower_env_xpm.xpm</normaloff>:/icons/lower_env_xpm.xpm</iconset> <normaloff>:/cgal/icons/lower_env_xpm.xpm</normaloff>:/cgal/icons/lower_env_xpm.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Lower envelope</string> <string>Lower envelope</string>
@ -319,72 +312,141 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/upper_env_xpm.xpm</normaloff>:/icons/upper_env_xpm.xpm</iconset> <normaloff>:/cgal/icons/upper_env_xpm.xpm</normaloff>:/cgal/icons/upper_env_xpm.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Upper envelope</string> <string>Upper envelope</string>
</property> </property>
</action> </action>
<action name="actionConicSegment"> <action name="actionSegment">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_segment.xpm</normaloff>:/icons/demo_conic_segment.xpm</iconset> <normaloff>:/cgal/icons/conic_segment.xpm</normaloff>:/cgal/icons/conic_segment.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Segment</string> <string>Segment</string>
</property> </property>
<property name="toolTip">
<string>Segment</string>
</property>
</action> </action>
<action name="actionConicCircle"> <action name="actionPolyline">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_circle.xpm</normaloff>:/icons/demo_conic_circle.xpm</iconset> <normaloff>:/cgal/icons/conic_segment.xpm</normaloff>:/cgal/icons/conic_segment.xpm</iconset>
</property>
<property name="text">
<string>Polyline</string>
</property>
<property name="toolTip">
<string>Polyline</string>
</property>
</action>
<action name="actionCircle">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/conic_circle.xpm</normaloff>:/cgal/icons/conic_circle.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Circle</string> <string>Circle</string>
</property> </property>
<property name="toolTip">
<string>Circle</string>
</property>
</action> </action>
<action name="actionConicEllipse"> <action name="actionEllipse">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_ellipse.xpm</normaloff>:/icons/demo_conic_ellipse.xpm</iconset> <normaloff>:/cgal/icons/conic_ellipse.xpm</normaloff>:/cgal/icons/conic_ellipse.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Ellipse</string> <string>Ellipse</string>
</property> </property>
<property name="toolTip">
<string>Ellipse</string>
</property>
</action> </action>
<action name="actionConicThreePoint"> <action name="actionConicThreePoint">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_3points.xpm</normaloff>:/icons/demo_conic_3points.xpm</iconset> <normaloff>:/cgal/icons/conic_3points.xpm</normaloff>:/cgal/icons/conic_3points.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Three Point Conic</string> <string>Three Point Conic</string>
</property> </property>
<property name="toolTip">
<string>Three Point Conic</string>
</property>
</action> </action>
<action name="actionConicFivePoint"> <action name="actionConicFivePoint">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_5points.xpm</normaloff>:/icons/demo_conic_5points.xpm</iconset> <normaloff>:/cgal/icons/conic_5points.xpm</normaloff>:/cgal/icons/conic_5points.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Five Point Conic</string> <string>Five Point Conic</string>
</property> </property>
<property name="toolTip">
<string>Five Point Conic</string>
</property>
</action>
<action name="actionBezier">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/conic_segment.xpm</normaloff>:/cgal/icons/conic_segment.xpm</iconset>
</property>
<property name="text">
<string>Bezier</string>
</property>
<property name="toolTip">
<string>Bezier</string>
</property>
</action>
<action name="actionAddAlgebraicCurve">
<property name="text">
<string>Add Curve</string>
</property>
<property name="toolTip">
<string>Curve Equation</string>
</property>
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/equation.xpm</normaloff>:/cgal/icons/equation.xpm</iconset>
</property>
</action>
<action name="actionAddRationalCurve">
<property name="text">
<string>Add Curve</string>
</property>
<property name="toolTip">
<string>Curve Equation</string>
</property>
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/equation.xpm</normaloff>:/cgal/icons/equation.xpm</iconset>
</property>
</action> </action>
<action name="actionCloseTab"> <action name="actionCloseTab">
<property name="text"> <property name="text">
@ -417,45 +479,69 @@
</action> </action>
<action name="actionZoomIn"> <action name="actionZoomIn">
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_zoomin.xpm</normaloff>:/icons/demo_zoomin.xpm</iconset> <normaloff>:/cgal/icons/zoomin.xpm</normaloff>:/cgal/icons/zoomin.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Zoom In</string> <string>Zoom In</string>
</property> </property>
<property name="toolTip">
<string>Zoom In</string>
</property>
</action> </action>
<action name="actionZoomOut"> <action name="actionZoomOut">
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_zoomout.xpm</normaloff>:/icons/demo_zoomout.xpm</iconset> <normaloff>:/cgal/icons/zoomout.xpm</normaloff>:/cgal/icons/zoomout.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Zoom Out</string> <string>Zoom Out</string>
</property> </property>
<property name="toolTip">
<string>Zoom Out</string>
</property>
</action> </action>
<action name="actionCurveRay"> <action name="actionZoomReset">
<property name="icon">
<iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/cgal/icons/zoomreset.xpm</normaloff>:/cgal/icons/zoomreset.xpm</iconset>
</property>
<property name="text">
<string>Zoom Reset</string>
</property>
<property name="toolTip">
<string>Zoom Reset</string>
</property>
</action>
<action name="actionRay">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_ray.xpm</normaloff>:/icons/demo_conic_ray.xpm</iconset> <normaloff>:/cgal/icons/conic_ray.xpm</normaloff>:/cgal/icons/conic_ray.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Ray</string> <string>Ray</string>
</property> </property>
<property name="toolTip">
<string>Ray</string>
</property>
</action> </action>
<action name="actionCurveLine"> <action name="actionLine">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ArrangementDemoWindow.qrc"> <iconset resource="Arrangement_on_surface_2.qrc">
<normaloff>:/icons/demo_conic_line.xpm</normaloff>:/icons/demo_conic_line.xpm</iconset> <normaloff>:/cgal/icons/conic_line.xpm</normaloff>:/cgal/icons/conic_line.xpm</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Line</string> <string>Line</string>
</property> </property>
<property name="toolTip">
<string>Line</string>
</property>
</action> </action>
<action name="actionFillColor"> <action name="actionFillColor">
<property name="text"> <property name="text">
@ -467,7 +553,7 @@
</action> </action>
</widget> </widget>
<resources> <resources>
<include location="ArrangementDemoWindow.qrc"/> <include location="Arrangement_on_surface_2.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -0,0 +1,142 @@
// Copyright (c) 2008, 2012, 2020 GeometryFactory Sarl (France).
// 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 <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef CGAL_QT_ARRANGEMENT_GRAPHICS_ITEM_TYPED_H
#define CGAL_QT_ARRANGEMENT_GRAPHICS_ITEM_TYPED_H
#include <CGAL/Object.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Qt/GraphicsItem.h>
#include <QImage>
#include <QPen>
#include "ArrangementGraphicsItem.h"
#include "FloodFill.h"
#include "ForwardDeclarations.h"
#include "PointsGraphicsItem.h"
namespace CGAL
{
namespace Qt
{
template <typename Arr_>
class ArrangementGraphicsItem : public ArrangementGraphicsItemBase
{
typedef Arr_ Arrangement;
typedef typename Arrangement::Geometry_traits_2 Traits;
typedef typename Arrangement::Halfedge Halfedge;
typedef typename Arrangement::Halfedge_handle Halfedge_handle;
typedef typename Arrangement::Face_handle Face_handle;
typedef typename Arrangement::Hole_iterator Hole_iterator;
typedef typename Arrangement::Ccb_halfedge_circulator Ccb_halfedge_circulator;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename Traits::Point_2 Point_2;
public:
/*! Constructor */
ArrangementGraphicsItem(Arrangement* t_);
public:
void modelChanged() override;
QRectF boundingRect() const override;
QRectF getInterestingViewport() const override;
void paint(
QPainter* painter, const QStyleOptionGraphicsItem* option,
QWidget* widget) override;
protected:
void updatePointsItem();
template <typename TTraits>
void paint(QPainter*, const TTraits&);
template <typename Coefficient_>
void
paint(QPainter*, const CGAL::Arr_algebraic_segment_traits_2<Coefficient_>&);
template <typename AlgebraicKernel_d_1>
void paint(
QPainter*,
const CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1>&);
template <typename TTraits>
void paintWithFloodFill(QPainter*, const TTraits&);
void updateBoundingBox();
template <typename TTraits>
void paintEdges(QPainter*, const TTraits&);
template <typename Coefficient_>
void paintEdges(
QPainter*, const CGAL::Arr_algebraic_segment_traits_2<Coefficient_>&);
void paintFaces(QPainter* painter);
void paintFacesFloodFill(QPainter*, QImage&);
void paintFace(Face_handle f, QPainter* painter);
void visit_ccb_faces(Face_handle& fh, QPainter* painter);
/*! antenna - return true if the halfedge and its
* twin point to the same face.
*/
bool antenna(Halfedge_handle h);
template <typename ArrTraits>
void paintFace(Face_handle, QPainter*, ArrTraits);
template <typename Kernel_>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_segment_traits_2<Kernel_>&);
template <typename Kernel_>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_polyline_traits_2<Kernel_>&);
template <typename RatKernel, typename AlgKernel, typename NtTraits>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>&);
template <
typename RatKernel, typename AlgKernel, typename NtTraits,
typename BoundingTraits>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits, BoundingTraits>&);
template <typename Coefficient_>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_algebraic_segment_traits_2<Coefficient_>&);
template <typename Kernel_>
void paintFace(
Face_handle f, QPainter* painter,
const CGAL::Arr_linear_traits_2<Kernel_>&);
protected:
Arrangement* arr;
PointsGraphicsItem* pointsGraphicsItem;
CGAL::Bbox_2 bb;
FloodFill flood_fill;
QImage tempImage;
}; // class ArrangementGraphicsItem
} // namespace Qt
} // namespace CGAL
#endif

View File

@ -0,0 +1,169 @@
// Copyright (c) 2020 GeometryFactory Sarl (France).
// 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): Ahmed Essam <theartful.ae@gmail.com>
#include "ArrangementIO.h"
#include "ArrangementDemoTab.h"
#include "ArrangementTypes.h"
#include "ArrangementTypesUtils.h"
#include "Conic_reader.h"
#include <CGAL/IO/Arr_text_formatter.h>
#include <CGAL/IO/Arr_with_history_iostream.h>
#include <CGAL/IO/Arr_with_history_text_formatter.h>
template <
typename Arrangement,
typename Traits = typename Arrangement::Geometry_traits_2>
struct ArrReader
{
Arrangement* operator()(std::ifstream& ifs)
{
using Text_formatter = CGAL::Arr_text_formatter<Arrangement>;
using ArrFormatter = CGAL::Arr_with_history_text_formatter<Text_formatter>;
ArrFormatter arrFormatter;
auto arr = new Arrangement();
CGAL::read(*arr, ifs, arrFormatter);
return arr;
}
};
#ifdef CGAL_USE_CORE
template <
typename Arrangement, typename Rat_kernel_, typename Alg_kernel_,
typename Nt_traits_>
struct ArrReader<
Arrangement, CGAL::Arr_conic_traits_2<Rat_kernel_, Alg_kernel_, Nt_traits_>>
{
using Traits = typename Arrangement::Geometry_traits_2;
using Curve_2 = typename Arrangement::Curve_2;
Arrangement* operator()(std::ifstream& ifs)
{
Conic_reader<Traits> conicReader;
std::vector<Curve_2> curve_list;
CGAL::Bbox_2 bbox;
conicReader.read_data(ifs, std::back_inserter(curve_list), bbox);
auto arr = new Arrangement();
CGAL::insert(*arr, curve_list.begin(), curve_list.end());
return arr;
}
};
template <
typename Arrangement, typename Rat_kernel_, typename Alg_kernel_,
typename Nt_traits_, typename Bounding_traits_>
struct ArrReader<
Arrangement, CGAL::Arr_Bezier_curve_traits_2<
Rat_kernel_, Alg_kernel_, Nt_traits_, Bounding_traits_>>
{
Arrangement* operator()(std::ifstream&) { return nullptr; }
};
template <typename Arrangement, typename AlgebraicKernel_d_1_>
struct ArrReader<
Arrangement, CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>>
{
Arrangement* operator()(std::ifstream&) { return nullptr; }
};
#endif
std::pair<CGAL::Object, demo_types::TraitsType>
ArrangementIO::read(std::ifstream& ifs)
{
// read type info
while (ifs.peek() == '#' || std::isspace(ifs.peek())) ifs.get();
int tt_int;
ifs >> tt_int;
auto tt = static_cast<demo_types::TraitsType>(tt_int);
std::pair<CGAL::Object, demo_types::TraitsType> res;
demo_types::visitArrangementType(tt, [&](auto type_holder) {
using Arrangement = typename decltype(type_holder)::type;
auto arr = ArrReader<Arrangement>{}(ifs);
res = {CGAL::make_object(arr), demo_types::enumFromArrType<Arrangement>()};
});
return res;
}
template <
typename Arrangement,
typename Traits = typename Arrangement::Geometry_traits_2>
struct ArrWriter
{
void operator()(Arrangement* arr, std::ofstream& ofs)
{
using TextFormatter = CGAL::Arr_text_formatter<Arrangement>;
using ArrFormatter = CGAL::Arr_with_history_text_formatter<TextFormatter>;
ArrFormatter arrFormatter;
CGAL::write(*arr, ofs, arrFormatter);
}
};
#ifdef CGAL_USE_CORE
template <
typename Arrangement, typename Rat_kernel_, typename Alg_kernel_,
typename Nt_traits_>
struct ArrWriter<
Arrangement, CGAL::Arr_conic_traits_2<Rat_kernel_, Alg_kernel_, Nt_traits_>>
{
using Traits = typename Arrangement::Geometry_traits_2;
using Curve_2 = typename Arrangement::Curve_2;
void operator()(Arrangement* arr, std::ofstream& ofs)
{
Conic_reader<Traits> conicReader;
conicReader.write_data(ofs, arr->curves_begin(), arr->curves_end());
}
};
template <
typename Arrangement, typename Rat_kernel_, typename Alg_kernel_,
typename Nt_traits_, typename Bounding_traits_>
struct ArrWriter<
Arrangement, CGAL::Arr_Bezier_curve_traits_2<
Rat_kernel_, Alg_kernel_, Nt_traits_, Bounding_traits_>>
{
void operator()(Arrangement*, std::ofstream&) { }
};
template <typename Arrangement, typename AlgebraicKernel_d_1_>
struct ArrWriter<
Arrangement, CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>>
{
void operator()(Arrangement*, std::ofstream&) { }
};
#endif
bool ArrangementIO::write(
const std::pair<CGAL::Object, demo_types::TraitsType>& arr_pair,
std::ofstream& ofs)
{
auto tt = arr_pair.second;
auto arr_obj = arr_pair.first;
// write type info
ofs << "# " << static_cast<int>(tt) << std::endl;
bool result = false;
demo_types::visitArrangementType(tt, [&](auto type_holder) {
using Arrangement = typename decltype(type_holder)::type;
Arrangement* arr;
if (CGAL::assign(arr, arr_obj))
{
ArrWriter<Arrangement>{}(arr, ofs);
result = true;
}
});
return result;
}

View File

@ -0,0 +1,35 @@
// Copyright (c) 2020 GeometryFactory Sarl (France).
// 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): Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_IO_H
#define ARRANGEMENT_DEMO_IO_H
#include <fstream>
#include <vector>
namespace demo_types
{
enum class TraitsType : int;
}
namespace CGAL
{
class Object;
}
struct ArrangementIO
{
std::pair<CGAL::Object, demo_types::TraitsType> read(std::ifstream&);
bool
write(const std::pair<CGAL::Object, demo_types::TraitsType>&, std::ofstream&);
};
#endif // ARRANGEMENT_DEMO_IO_H

View File

@ -0,0 +1,670 @@
// 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 <alextsui05@gmail.com>
// Saurabh Singh <ssingh@cs.iitr.ac.in>
// Ahmed Essam <theartful.ae@gmail.com>
#include "ArrangementPainterOstream.h"
#include "ArrangementTypes.h"
#include <CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h>
#include <QGraphicsView>
namespace CGAL
{
namespace Qt
{
// Instantiation of Arr_segment_traits_2
template <typename Kernel_>
ArrangementPainterOstream<CGAL::Arr_segment_traits_2<Kernel_>>&
ArrangementPainterOstream<CGAL::Arr_segment_traits_2<Kernel_>>::operator<<(
const X_monotone_curve_2& curve)
{
const Point_2& p1 = curve.source();
const Point_2& p2 = curve.target();
Segment_2 seg(p1, p2);
// skip segments outside our view
QRectF seg_bb = this->convert(seg.bbox());
if (
this->clippingRect.isValid() && !this->clippingRect.intersects(seg_bb) &&
(!seg.is_horizontal() && !seg.is_vertical()))
{ return *this; }
this->painterOstream << seg;
return *this;
}
// Instantiation of Arr_polyline_traits_2
template <typename SegmentTraits>
ArrangementPainterOstream<CGAL::Arr_polyline_traits_2<SegmentTraits>>&
ArrangementPainterOstream<CGAL::Arr_polyline_traits_2<SegmentTraits>>::
operator<<(const X_monotone_curve_2& curve)
{
int cnt = 0;
for (typename X_monotone_curve_2::Subcurve_const_iterator it =
curve.subcurves_begin();
it != curve.subcurves_end(); ++it)
{
cnt++;
this->painterOstream << *it;
}
return *this;
}
// Instantiation of Arr_conic_traits_2
template <typename RatKernel, class AlgKernel, class NtTraits>
auto ArrangementPainterOstream<CGAL::Arr_conic_traits_2<
RatKernel, AlgKernel, NtTraits>>::visibleParts(X_monotone_curve_2 curve)
-> std::vector<X_monotone_curve_2>
{
// see if we intersect the bottom edge of the viewport
Point_2 bottomLeft = this->convert(this->clippingRect.bottomLeft());
Point_2 bottomRight = this->convert(this->clippingRect.bottomRight());
Point_2 topLeft = this->convert(this->clippingRect.topLeft());
Point_2 topRight = this->convert(this->clippingRect.topRight());
X_monotone_curve_2 bottom =
this->construct_x_monotone_curve_2(bottomLeft, bottomRight);
X_monotone_curve_2 left =
this->construct_x_monotone_curve_2(bottomLeft, topLeft);
X_monotone_curve_2 top =
this->construct_x_monotone_curve_2(topLeft, topRight);
X_monotone_curve_2 right =
this->construct_x_monotone_curve_2(topRight, bottomRight);
std::vector<CGAL::Object> bottomIntersections;
std::vector<CGAL::Object> leftIntersections;
std::vector<CGAL::Object> topIntersections;
std::vector<CGAL::Object> rightIntersections;
std::vector<CGAL::Object> intersections;
this->intersect_2(bottom, curve, bottomIntersections);
this->intersect_2(left, curve, leftIntersections);
this->intersect_2(top, curve, topIntersections);
this->intersect_2(right, curve, rightIntersections);
this->intersect_2(bottom, curve, intersections);
this->intersect_2(left, curve, intersections);
this->intersect_2(top, curve, intersections);
this->intersect_2(right, curve, intersections);
this->filterIntersectionPoints(intersections);
Point_2 leftEndpt = curve.source();
Point_2 rightEndpt = curve.target();
if (leftEndpt.x() > rightEndpt.x()) { std::swap(leftEndpt, rightEndpt); }
QPointF qendpt1 = this->convert(leftEndpt);
QPointF qendpt2 = this->convert(rightEndpt);
std::list<Point_2> pointList;
for (unsigned int i = 0; i < intersections.size(); ++i)
{
CGAL::Object o = intersections[i];
std::pair<Intersection_point_2, Multiplicity> pair;
if (CGAL::assign(pair, o))
{
Point_2 pt = pair.first;
pointList.push_back(pt);
}
}
bool includeLeftEndpoint = this->clippingRect.contains(qendpt1);
bool includeRightEndpoint = this->clippingRect.contains(qendpt2);
if (includeLeftEndpoint) { pointList.push_front(leftEndpt); }
if (includeRightEndpoint) { pointList.push_back(rightEndpt); }
// TODO: make ArrangementPainterOstream take traits object
Traits traits;
Construct_x_monotone_subcurve_2<Traits> construct_x_monotone_subcurve_2{
&traits};
std::vector<X_monotone_curve_2> clippings;
typename std::list<Point_2>::iterator pointListItr = pointList.begin();
for (unsigned int i = 0; i < pointList.size(); i += 2)
{
typename Traits::Point_2 p1 = *pointListItr++;
typename Traits::Point_2 p2 = *pointListItr++;
X_monotone_curve_2 subcurve =
construct_x_monotone_subcurve_2(curve, p1, p2);
clippings.push_back(subcurve);
}
return clippings;
}
template <typename RatKernel, class AlgKernel, class NtTraits>
void ArrangementPainterOstream<
CGAL::Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>>::
filterIntersectionPoints(std::vector<CGAL::Object>& res)
{
std::vector<std::pair<Intersection_point_2, Multiplicity>> tmp;
// filter out the non-intersection point results
for (unsigned int i = 0; i < res.size(); ++i)
{
CGAL::Object obj = res[i];
std::pair<Intersection_point_2, Multiplicity> pair;
if (CGAL::assign(pair, obj)) { tmp.push_back(pair); }
}
res.clear();
// sort the intersection points by x-coord
Compare_intersection_point_result compare_intersection_point_result;
std::sort(tmp.begin(), tmp.end(), compare_intersection_point_result);
// box up the sorted elements
for (unsigned int i = 0; i < tmp.size(); ++i)
{
std::pair<Intersection_point_2, Multiplicity> pair = tmp[i];
CGAL::Object o = CGAL::make_object(pair);
res.push_back(o);
}
}
template <typename RatKernel, class AlgKernel, class NtTraits>
ArrangementPainterOstream<
CGAL::Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>>&
ArrangementPainterOstream<CGAL::Arr_conic_traits_2<
RatKernel, AlgKernel, NtTraits>>::operator<<(const X_monotone_curve_2& curve)
{
CGAL::Bbox_2 bb = curve.bbox();
QRectF qbb = this->convert(bb);
// quick cull
if (this->clippingRect.isValid() && !this->clippingRect.intersects(qbb))
{ return *this; }
// get number of segments
QGraphicsView* view = this->scene->views().first();
int xmin = view->mapFromScene(bb.xmin(), bb.ymin()).x();
int xmax = view->mapFromScene(bb.xmax(), bb.ymin()).x();
// can be negitive due to rotation trasnformation
size_t n = static_cast<size_t>(std::abs(xmax - xmin));
if (n == 0) { return *this; }
auto paintCurve = [&](auto&& curve_) {
std::vector<std::pair<double, double>> app_pts;
app_pts.reserve(n + 1);
curve_.polyline_approximation(n, std::back_inserter(app_pts));
auto p_curr = app_pts.begin();
auto end_pts = app_pts.end();
auto p_next = p_curr + 1;
int count = 0;
do
{
QPointF p1(p_curr->first, p_curr->second);
QPointF p2(p_next->first, p_next->second);
this->qp->drawLine(p1, p2);
p_curr++;
p_next++;
++count;
} while (p_next != end_pts);
};
if (this->clippingRect.isValid())
{
std::vector<X_monotone_curve_2> visibleParts;
if (this->clippingRect.contains(qbb))
visibleParts.push_back(curve);
else
visibleParts = this->visibleParts(curve);
for (auto& visiblePart : visibleParts) paintCurve(visiblePart);
}
else
{ // draw the whole curve
paintCurve(curve);
}
return *this;
}
// Instantiation of Arr_Bezier_traits_2
template <
typename RatKernel, typename AlgKernel, typename NtTraits,
typename BoundingTraits>
std::vector<std::pair<double, double>>
ArrangementPainterOstream<CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits,
BoundingTraits>>::getPoints(const X_monotone_curve_2& curve)
{
std::pair<double, double> param_range = curve.parameter_range();
auto&& supporting_curve = curve.supporting_curve();
std::vector<std::pair<double, double>> sampled_points;
// TODO: get adaptive number of samples
unsigned int number_of_samples =
100 * (param_range.second - param_range.first);
sampled_points.reserve(number_of_samples);
supporting_curve.sample(
param_range.first, param_range.second, number_of_samples,
std::back_inserter(sampled_points));
return sampled_points;
}
template <
typename RatKernel, typename AlgKernel, typename NtTraits,
typename BoundingTraits>
auto ArrangementPainterOstream<CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits,
BoundingTraits>>::operator<<(const X_monotone_curve_2& curve)
-> ArrangementPainterOstream<Traits>&
{
auto sampled_points = this->getPoints(curve);
if (sampled_points.empty()) return *this;
QPainterPath painterPath;
painterPath.moveTo(sampled_points[0].first, sampled_points[0].second);
for (auto& p : sampled_points) painterPath.lineTo(p.first, p.second);
this->qp->drawPath(painterPath);
return *this;
}
// Instantiation of Arr_linear_traits_2
template <typename Kernel_>
ArrangementPainterOstream<CGAL::Arr_linear_traits_2<Kernel_>>&
ArrangementPainterOstream<CGAL::Arr_linear_traits_2<Kernel_>>::operator<<(
const X_monotone_curve_2& curve)
{
if (curve.is_segment())
{
Segment_2 seg = curve.segment();
// skip segments outside our view
QRectF seg_bb = this->convert(seg.bbox());
if (
this->clippingRect.isValid() &&
!this->clippingRect.intersects(seg_bb) &
(!seg.is_horizontal() && !seg.is_vertical()))
{ return *this; }
this->painterOstream << seg;
}
else if (curve.is_ray())
{
Ray_2 ray = curve.ray();
QLineF qseg = this->convert(ray);
if (qseg.isNull())
{ // it's out of view
return *this;
}
Segment_2 seg = this->convert(qseg);
this->painterOstream << seg;
}
else // curve.is_line( )
{
Line_2 line = curve.line();
QLineF qseg = this->convert(line);
if (qseg.isNull())
{ // it's out of view
return *this;
}
Segment_2 seg = this->convert(qseg);
this->painterOstream << seg;
}
return *this;
}
// Instantiation of Arr_algebraic_segment_traits_2
template <typename Traits>
static bool lies_on_border(
const ArrangementPainterOstream<Traits>* apo, const QPointF& point)
{
QGraphicsView* view = apo->getScene()->views().first();
qreal width = view->width();
qreal height = view->height();
const float tol = 2;
return std::abs(point.x() - width) < tol || point.x() < tol ||
std::abs(point.y() - height) < tol || point.y() < tol;
}
template <typename Coefficient_>
void ArrangementPainterOstream<
CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::remapFacadePainter()
{
this->qp->setTransform(this->getPointsListMapping());
}
template <typename Coefficient_>
QTransform ArrangementPainterOstream<
CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::getPointsListMapping()
{
auto worldTransform = this->qp->transform();
return this->getPointsListMapping(worldTransform);
}
template <typename Coefficient_>
QTransform
ArrangementPainterOstream<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::
getPointsListMapping(const QTransform& worldTransform)
{
auto view = this->getView();
QRectF viewport = this->viewportRect();
// (0, 0) ==> map(topLeft)
QPointF dxdy = worldTransform.map(viewport.topLeft());
// (view.width(), 0) ==> map(bottomRight)
QPointF p1 = worldTransform.map(viewport.topRight());
// (0, view.height()) ==> map(0, 0)
QPointF p2 = worldTransform.map(viewport.bottomLeft());
// x' = m11*x + m21*y + dx
// y' = m22*y + m12*x + dy
float dx = dxdy.x();
float dy = dxdy.y();
float m11 = (p1.x() - dx) / view->width();
float m21 = (p2.x() - dx) / view->height();
float m22 = (p2.y() - dy) / view->height();
float m12 = (p1.y() - dy) / view->width();
return QTransform{m11, m12, m21, m22, dx, dy};
}
template <typename Coefficient_>
auto ArrangementPainterOstream<CGAL::Arr_algebraic_segment_traits_2<
Coefficient_>>::getPointsList(const X_monotone_curve_2& curve)
-> std::vector<Coord_vec_2>
{
typedef Curve_renderer_facade<CKvA_2> Facade;
typedef std::pair<double, double> Coord_2;
typedef std::vector<Coord_2> Coord_vec_2;
std::vector<Coord_vec_2> points;
Facade::instance().draw(curve, points);
return points;
}
template <typename Coefficient_>
ArrangementPainterOstream<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>&
ArrangementPainterOstream<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::
operator<<(const X_monotone_curve_2& curve)
{
this->qp->save();
this->remapFacadePainter();
this->paintCurve(curve);
this->qp->restore();
return *this;
}
template <typename Coefficient_>
void ArrangementPainterOstream<CGAL::Arr_algebraic_segment_traits_2<
Coefficient_>>::paintCurve(const X_monotone_curve_2& curve)
{
std::vector<Coord_vec_2> points = this->getPointsList(curve);
for (auto& vec : points)
{
auto vit = vec.begin();
QPainterPath path;
QPointF qpt(vit->first, vit->second);
path.moveTo(qpt);
for (auto& vit : vec)
{
QPointF qpt_new = QPointF(vit.first, vit.second);
if (lies_on_border(this, qpt) && lies_on_border(this, qpt_new))
path.moveTo(qpt_new);
else
path.lineTo(qpt_new);
qpt = qpt_new;
}
this->qp->drawPath(path);
}
}
template <typename Coefficient_>
void ArrangementPainterOstream<
CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::setupFacade()
{
typedef Curve_renderer_facade<CKvA_2> Facade;
QGraphicsView* view = this->getView();
QRectF viewport = this->viewportRect();
CGAL::Bbox_2 bbox = this->convert(viewport).bbox();
Facade::setup(bbox, view->width(), view->height());
}
// Instantiation of Arr_rational_function_traits_2
template <class T>
constexpr const T& clamp(const T& v, const T& lo, const T& hi)
{
return (v < lo) ? lo : (hi < v) ? hi : v;
}
template <typename AlgebraicKernel_d_1_>
auto ArrangementPainterOstream<CGAL::Arr_rational_function_traits_2<
AlgebraicKernel_d_1_>>::operator<<(const X_monotone_curve_2& curve) -> Self&
{
QPainterPath painterPath;
const QRectF viewport = this->viewportRect();
// overshoot so that the slope would be more accurate
double min_y = viewport.top();
double max_y = viewport.bottom();
bool disconnected = true;
bool first_point = true;
double last_x = 0, last_y = 0;
// TODO: this is ugly! clean up these conditions
auto path_filler = [&](double x, double y) {
if (y > max_y || y < min_y)
{
double x_ = x;
double y_ = clamp(y, min_y, max_y);
// make line to the first out of range point
if (!disconnected) { painterPath.lineTo(x_, y_); }
// connect between two out of range points when they cross different
// boundaries
else if (
(last_y == min_y && y_ == max_y) || (last_y == max_y && y_ == min_y))
{
painterPath.moveTo(last_x, last_y);
painterPath.lineTo(x_, y_);
}
last_x = x_;
last_y = y_;
disconnected = true;
}
else if (first_point)
{
painterPath.moveTo(x, y);
disconnected = false;
}
else
{
if (disconnected)
{
painterPath.moveTo(last_x, last_y);
disconnected = false;
}
painterPath.lineTo(x, y);
}
first_point = false;
};
this->sample_points(curve, path_filler);
this->qp->drawPath(painterPath);
return *this;
}
template <typename AlgebraicKernel_d_1_>
auto ArrangementPainterOstream<CGAL::Arr_rational_function_traits_2<
AlgebraicKernel_d_1_>>::getPointsList(const X_monotone_curve_2& curve)
-> std::vector<Coord_vec_2>
{
std::vector<Coord_vec_2> points_list;
Coord_vec_2* cur_list = nullptr;
const QRectF viewport = this->viewportRect();
// overshoot so that the slope would be more accurate
double min_y = viewport.top();
double max_y = viewport.bottom();
bool disconnected = true;
double last_x = 0, last_y = 0;
bool first_point = false;
// TODO: this is ugly! clean up these conditions
auto path_filler = [&](double x, double y) {
if (y > max_y || y < min_y)
{
double x_ = x;
double y_ = clamp(y, min_y, max_y);
if (!disconnected)
cur_list->push_back({x_, y_});
else if (
(last_y == min_y && y_ == max_y) || (last_y == max_y && y_ == min_y))
{
cur_list->push_back({last_x, last_y});
cur_list->push_back({x_, y_});
}
last_x = x_;
last_y = y_;
disconnected = true;
}
else
{
if (disconnected)
{
points_list.emplace_back();
cur_list = &points_list.back();
if (!first_point) cur_list->push_back({last_x, last_y});
disconnected = false;
}
cur_list->push_back({x, y});
}
first_point = false;
};
this->sample_points(curve, path_filler);
return points_list;
}
template <typename AlgebraicKernel_d_1_>
template <typename Lambda>
void ArrangementPainterOstream<
CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>>::
sample_points(const X_monotone_curve_2& curve, Lambda&& lambda)
{
// TODO: cache maximum and minimal points for each curve, and include them
// in the sampled points
const QRectF viewport = this->viewportRect();
qreal min_x = viewport.left();
qreal max_x = viewport.right();
auto&& numer = curve._f.numer();
auto&& denom = curve._f.denom();
auto eval_at = [&](auto&& x) {
return numer.evaluate(x) / denom.evaluate(x);
};
if ( // be conservative and prefer this branch to avoid zero division
curve.left_parameter_space_in_x() == ARR_INTERIOR &&
curve.left_x().to_interval().second >= min_x)
{
min_x = curve.left_x().to_interval().second;
switch (curve.left_parameter_space_in_y())
{
case ARR_INTERIOR: {
auto left_pt = curve.left().to_double();
lambda(min_x, left_pt.second);
break;
}
case ARR_TOP_BOUNDARY: {
lambda(min_x, std::numeric_limits<double>::infinity());
break;
}
case ARR_BOTTOM_BOUNDARY: {
lambda(min_x, -std::numeric_limits<double>::infinity());
break;
}
default: {
CGAL_error();
}
}
}
else if (
curve.right_parameter_space_in_x() != ARR_INTERIOR ||
min_x < curve.right_x().to_interval().first)
{
lambda(min_x, CGAL::to_double(eval_at(Rational{min_x})));
}
else // outside of viewport
{
return;
}
std::pair<double, double> last_pt;
if ( // be conservative and prefer this branch to avoid zero division
curve.right_parameter_space_in_x() == ARR_INTERIOR &&
curve.right_x().to_interval().first <= max_x)
{
max_x = curve.right_x().to_interval().first;
switch (curve.right_parameter_space_in_y())
{
case ARR_INTERIOR: {
last_pt = {max_x, curve.right().to_double().second};
break;
}
case ARR_TOP_BOUNDARY: {
last_pt = {max_x, std::numeric_limits<double>::infinity()};
break;
}
case ARR_BOTTOM_BOUNDARY: {
last_pt = {max_x, -std::numeric_limits<double>::infinity()};
break;
}
default: {
CGAL_error();
}
}
}
else if (max_x > min_x)
{
last_pt = {max_x, CGAL::to_double(eval_at(Rational{max_x}))};
}
else // outside of viewport
{
return;
}
static constexpr int dx_pixel = 1;
static constexpr int min_num_points = 20;
QLineF ux_line = this->getView()->transform().map(QLineF{0, 0, 1, 0});
Rational dx = (CGAL::min)(
dx_pixel * Rational{1} / ux_line.length(),
Rational{max_x - min_x} / min_num_points);
for (Rational cur_x = min_x + dx; cur_x < max_x - dx; cur_x += dx)
lambda(CGAL::to_double(cur_x), CGAL::to_double(eval_at(cur_x)));
lambda(last_pt.first, last_pt.second);
}
ARRANGEMENT_DEMO_SPECIALIZE_TRAITS(ArrangementPainterOstream)
} // namespace Qt
} // namespace CGAL

View File

@ -1,11 +1,13 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
// //
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Saurabh Singh <ssingh@cs.iitr.ac.in>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef CGAL_QT_ARRANGEMENT_PAINTER_OSTREAM_H #ifndef CGAL_QT_ARRANGEMENT_PAINTER_OSTREAM_H
#define CGAL_QT_ARRANGEMENT_PAINTER_OSTREAM_H #define CGAL_QT_ARRANGEMENT_PAINTER_OSTREAM_H
@ -13,19 +15,11 @@
#include <QRectF> #include <QRectF>
#include <vector> #include <vector>
// TODO: should be included in PainterOstream.h
#include <CGAL/Kernel/global_functions.h>
#include <CGAL/Qt/PainterOstream.h> #include <CGAL/Qt/PainterOstream.h>
#include <CGAL/Qt/Converter.h> #include "ForwardDeclarations.h"
#include <CGAL/Arr_segment_traits_2.h> #include "GraphicsSceneMixin.h"
#include <CGAL/Arr_polyline_traits_2.h> #include "Utils/Utils.h"
#include <CGAL/Arr_conic_traits_2.h> #include "Utils/IntersectCurves.h"
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arr_algebraic_segment_traits_2.h>
#include "Utils.h"
// #include <CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h>
class QPainter; class QPainter;
@ -33,19 +27,16 @@ namespace CGAL {
namespace Qt { namespace Qt {
template < typename ArrTraits > template < typename ArrTraits >
class ArrangementPainterOstreamBase : public QGraphicsSceneMixin class ArrangementPainterOstreamBase : public GraphicsSceneMixin
{ {
public: public:
// typedefs // typedefs
typedef ArrTraits Traits; typedef ArrTraits Traits;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel; typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point_2; typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2; typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::Ray_2 Ray_2; typedef typename Kernel::Ray_2 Ray_2;
typedef typename Kernel::Line_2 Line_2; typedef typename Kernel::Line_2 Line_2;
typedef typename Kernel::Triangle_2 Triangle_2;
typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Kernel::Circle_2 Circle_2;
public: public:
/*! Constructor */ /*! Constructor */
@ -54,14 +45,8 @@ public:
painterOstream( p, clippingRectangle ), painterOstream( p, clippingRectangle ),
qp( p ), qp( p ),
convert( clippingRectangle ), convert( clippingRectangle ),
// scene( NULL ), clippingRect( QRectF( ) ) // null rectangle
clippingRect( QRectF( ) ), // null rectangle
scale( 1.0 )
{ {
if ( p != 0 )
{
this->scale = p->worldTransform( ).m11( );
}
} }
/*! Destructor (virtual) */ /*! Destructor (virtual) */
@ -75,56 +60,24 @@ public:
return *this; return *this;
} }
void setScene( QGraphicsScene* scene_ ) void setScene( QGraphicsScene* scene_ ) override
{ {
this->scene = scene_; GraphicsSceneMixin::setScene(scene_);
// set the clipping rectangle // set the clipping rectangle
if ( scene_ == NULL ) if ( scene_ )
{ {
return; this->clippingRect = this->viewportRect( );
this->convert = Converter< Kernel >( this->clippingRect );
} }
this->clippingRect = this->viewportRect( );
this->convert = Converter< Kernel >( this->clippingRect );
} }
#if 0
void setScene( QGraphicsScene* scene_ )
{
this->scene = scene_;
// set the clipping rectangle
if ( scene_ == NULL )
{
return;
}
this->clippingRect = this->getViewportRect( );
}
#endif
protected: // methods
#if 0
QRectF getViewportRect( ) const
{
// assumes scene is not null and attached to exactly one view
QGraphicsView* view = this->scene->views( ).first( );
QPointF p1 = view->mapToScene( 0, 0 );
QPointF p2 = view->mapToScene( view->width( ), view->height( ) );
QRectF clipRect = QRectF( p1, p2 );
return clipRect;
}
#endif
protected: protected:
// fields // fields
PainterOstream< Kernel > painterOstream; PainterOstream< Kernel > painterOstream;
QPainter* qp; QPainter* qp;
Converter< Kernel > convert; Converter< Kernel > convert;
// QGraphicsScene* scene;
QRectF clippingRect; QRectF clippingRect;
double scale;
}; // class ArrangementPainterOstreamBase }; // class ArrangementPainterOstreamBase
template < typename ArrTraits > template < typename ArrTraits >
@ -153,9 +106,6 @@ public: // typedefs
typedef typename Superclass::Segment_2 Segment_2; typedef typename Superclass::Segment_2 Segment_2;
typedef typename Superclass::Ray_2 Ray_2; typedef typename Superclass::Ray_2 Ray_2;
typedef typename Superclass::Line_2 Line_2; typedef typename Superclass::Line_2 Line_2;
typedef typename Superclass::Triangle_2 Triangle_2;
typedef typename Superclass::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Superclass::Circle_2 Circle_2;
typedef typename Traits::Curve_2 Curve_2; typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
@ -169,45 +119,7 @@ public:
virtual ~ArrangementPainterOstream() {} virtual ~ArrangementPainterOstream() {}
public: // methods public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve ) ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
{
const Point_2& p1 = curve.source( );
const Point_2& p2 = curve.target( );
Segment_2 seg( p1, p2 );
// skip segments outside our view
QRectF seg_bb = this->convert( seg.bbox( ) );
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.intersects( seg_bb ) )
{
return *this;
}
this->painterOstream << seg;
return *this;
}
ArrangementPainterOstream& operator<<( const Point_2& p )
{
QPointF qpt = this->convert( p );
// clip the point if possible
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.contains( qpt ) )
{
return *this;
}
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
return *this;
}
template < typename T > template < typename T >
ArrangementPainterOstream& operator<<( const T& p ) ArrangementPainterOstream& operator<<( const T& p )
@ -231,9 +143,6 @@ public: // typedefs
typedef typename Superclass::Segment_2 Segment_2; typedef typename Superclass::Segment_2 Segment_2;
typedef typename Superclass::Ray_2 Ray_2; typedef typename Superclass::Ray_2 Ray_2;
typedef typename Superclass::Line_2 Line_2; typedef typename Superclass::Line_2 Line_2;
typedef typename Superclass::Triangle_2 Triangle_2;
typedef typename Superclass::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Superclass::Circle_2 Circle_2;
typedef typename Traits::Curve_2 Curve_2; typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
@ -247,39 +156,7 @@ public:
virtual ~ArrangementPainterOstream() {} virtual ~ArrangementPainterOstream() {}
public: // methods public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve ) ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
{
for (typename X_monotone_curve_2::Subcurve_const_iterator it =
curve.subcurves_begin();
it != curve.subcurves_end(); ++it)
{
this->painterOstream << *it;
}
// TODO: implement polyline painting
#if 0
const Point_2& p1 = curve.source( );
const Point_2& p2 = curve.target( );
Segment_2 seg( p1, p2 );
this->painterOstream << seg;
#endif
return *this;
}
// cloned from segtraits painter
ArrangementPainterOstream& operator<<( const Point_2& p )
{
QPointF qpt = this->convert( p );
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
return *this;
}
template < typename T > template < typename T >
ArrangementPainterOstream& operator<<( const T& p ) ArrangementPainterOstream& operator<<( const T& p )
@ -303,9 +180,6 @@ public: // typedefs
typedef typename Superclass::Segment_2 Segment_2; typedef typename Superclass::Segment_2 Segment_2;
typedef typename Superclass::Ray_2 Ray_2; typedef typename Superclass::Ray_2 Ray_2;
typedef typename Superclass::Line_2 Line_2; typedef typename Superclass::Line_2 Line_2;
typedef typename Superclass::Triangle_2 Triangle_2;
typedef typename Superclass::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Superclass::Circle_2 Circle_2;
typedef typename Traits::Curve_2 Curve_2; typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename Traits::Construct_x_monotone_curve_2 typedef typename Traits::Construct_x_monotone_curve_2
@ -335,8 +209,7 @@ public:
/*! Constructor */ /*! Constructor */
ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()) : ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()) :
Superclass( p, clippingRectangle ), Superclass( p, clippingRectangle ),
//intersect_2( this->traits.intersect_2_object( ) ), intersect_2( &this->traits ),
// Why doesn't this work?
construct_x_monotone_curve_2(this-> construct_x_monotone_curve_2(this->
traits.construct_x_monotone_curve_2_object()) traits.construct_x_monotone_curve_2_object())
{ } { }
@ -345,143 +218,7 @@ public:
virtual ~ArrangementPainterOstream() {} virtual ~ArrangementPainterOstream() {}
public: // methods public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve ) ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
{
CGAL::Bbox_2 bb = curve.bbox( );
QRectF qbb = this->convert( bb );
// quick cull
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.intersects( qbb ) )
{
//std::cout << "quick culled curve" << std::endl;
return *this;
}
#if 0
std::cout << "bottom: ("
<< this->clippingRect.bottomLeft( ).x( )
<< " "
<< this->clippingRect.bottomLeft( ).y( )
<< " "
<< this->clippingRect.bottomRight( ).x( )
<< " "
<< this->clippingRect.bottomRight( ).y( )
<< ")"
<< std::endl;
#endif
if ( this->clippingRect.isValid( ) )
{
std::vector< X_monotone_curve_2 > visibleParts;
if ( this->clippingRect.contains( qbb ) )
{
visibleParts.push_back( curve );
}
else
{
visibleParts = this->visibleParts( curve );
}
for ( unsigned int i = 0; i < visibleParts.size( ); ++i )
{
X_monotone_curve_2 subcurve = visibleParts[ i ];
int n;
if ( this->scene == NULL )
n = 100; // TODO: get an adaptive approximation
else
{
QGraphicsView* view = this->scene->views( ).first( );
int xmin, xmax;
xmin = view->mapFromScene( bb.xmin( ), bb.ymin( ) ).x( );
xmax = view->mapFromScene( bb.xmax( ), bb.ymin( ) ).x( );
n = xmax - xmin;
}
if ( n == 0 )
{
return *this;
}
std::pair<double, double>* app_pts =
new std::pair<double, double>[n + 1];
std::pair<double, double>* end_pts =
subcurve.polyline_approximation(n, app_pts);
std::pair<double, double>* p_curr = app_pts;
std::pair<double, double>* p_next = p_curr + 1;
int count = 0;
do
{
QPointF p1( p_curr->first, p_curr->second );
QPointF p2( p_next->first, p_next->second );
#if 0
Segment_2 seg( p1, p2 );
this->painterOstream << seg;
#endif
this->qp->drawLine( p1, p2 );
p_curr++;
p_next++;
++count;
}
while ( p_next != end_pts );
}
}
else
{ // draw the whole curve
int n;
if ( this->scene == NULL )
n = 100; // TODO: get an adaptive approximation
else
{
QGraphicsView* view = this->scene->views( ).first( );
int xmin, xmax;
xmin = view->mapFromScene( bb.xmin( ), bb.ymin( ) ).x( );
xmax = view->mapFromScene( bb.xmax( ), bb.ymin( ) ).x( );
n = xmax - xmin;
}
if ( n == 0 )
{
return *this;
}
std::pair<double, double>* app_pts = new std::pair<double, double>[n + 1];
std::pair<double, double>* end_pts =
curve.polyline_approximation(n, app_pts);
std::pair<double, double>* p_curr = app_pts;
std::pair<double, double>* p_next = p_curr + 1;
int count = 0;
do
{
QPointF p1( p_curr->first, p_curr->second );
QPointF p2( p_next->first, p_next->second );
#if 0
Segment_2 seg( p1, p2 );
this->painterOstream << seg;
#endif
this->qp->drawLine( p1, p2 );
p_curr++;
p_next++;
++count;
}
while ( p_next != end_pts );
//std::cout << count << " approximation points" << std::endl;
}
return *this;
}
// cloned from segtraits painter
ArrangementPainterOstream& operator<<( const Point_2& p )
{
QPointF qpt = this->convert( p );
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
return *this;
}
template < typename T > template < typename T >
ArrangementPainterOstream& operator<<( const T& p ) ArrangementPainterOstream& operator<<( const T& p )
@ -493,174 +230,52 @@ public: // methods
protected: // methods protected: // methods
// Returns subcurves of curve that are actually visible in the view. // Returns subcurves of curve that are actually visible in the view.
// Assumes that clippingRect is valid. // Assumes that clippingRect is valid.
std::vector< X_monotone_curve_2 > visibleParts( X_monotone_curve_2 curve ) std::vector< X_monotone_curve_2 > visibleParts( X_monotone_curve_2 curve );
{
// see if we intersect the bottom edge of the viewport
Intersect_2 intersect_2 = this->traits.intersect_2_object( );
Point_2 bottomLeft = this->convert( this->clippingRect.bottomLeft( ) );
Point_2 bottomRight = this->convert( this->clippingRect.bottomRight( ) );
Point_2 topLeft = this->convert( this->clippingRect.topLeft( ) );
Point_2 topRight = this->convert( this->clippingRect.topRight( ) );
X_monotone_curve_2 bottom =
this->construct_x_monotone_curve_2( bottomLeft, bottomRight );
X_monotone_curve_2 left =
this->construct_x_monotone_curve_2( bottomLeft, topLeft );
X_monotone_curve_2 top =
this->construct_x_monotone_curve_2( topLeft, topRight );
X_monotone_curve_2 right =
this->construct_x_monotone_curve_2( topRight, bottomRight );
std::vector< CGAL::Object > bottomIntersections;
std::vector< CGAL::Object > leftIntersections;
std::vector< CGAL::Object > topIntersections;
std::vector< CGAL::Object > rightIntersections;
std::vector< CGAL::Object > intersections;
intersect_2( bottom, curve, std::back_inserter( bottomIntersections ) );
intersect_2( left, curve, std::back_inserter( leftIntersections ) );
intersect_2( top, curve, std::back_inserter( topIntersections ) );
intersect_2( right, curve, std::back_inserter( rightIntersections ) );
// int total = bottomIntersections.size( )
// + leftIntersections.size( )
// + topIntersections.size( )
// + rightIntersections.size( );
intersect_2( bottom, curve, std::back_inserter( intersections ) );
intersect_2( left, curve, std::back_inserter( intersections ) );
intersect_2( top, curve, std::back_inserter( intersections ) );
intersect_2( right, curve, std::back_inserter( intersections ) );
this->filterIntersectionPoints( intersections );
//std::cout << "total intersections: " << intersections.size( )
// << std::endl;
//this->printIntersectResult( intersections );
Point_2 leftEndpt = curve.source( );
Point_2 rightEndpt = curve.target( );
if ( leftEndpt.x( ) > rightEndpt.x( ) )
{
std::swap( leftEndpt, rightEndpt );
}
QPointF qendpt1 = this->convert( leftEndpt );
QPointF qendpt2 = this->convert( rightEndpt );
std::list< Point_2 > pointList;
for ( unsigned int i = 0; i < intersections.size( ); ++i )
{
CGAL::Object o = intersections[ i ];
std::pair< Intersection_point_2, Multiplicity > pair;
if ( CGAL::assign( pair, o ) )
{
Point_2 pt = pair.first;
pointList.push_back( pt );
}
}
bool includeLeftEndpoint = this->clippingRect.contains( qendpt1 );
bool includeRightEndpoint = this->clippingRect.contains( qendpt2 );
if ( includeLeftEndpoint )
pointList.push_front( leftEndpt );
if ( includeRightEndpoint )
pointList.push_back( rightEndpt );
Construct_x_monotone_subcurve_2< Traits > construct_x_monotone_subcurve_2;
std::vector< X_monotone_curve_2 > clippings;
typename std::list< Point_2 >::iterator pointListItr = pointList.begin( );
for ( unsigned int i = 0; i < pointList.size( ); i += 2 )
{
Point_2 p1 = *pointListItr++;
Point_2 p2 = *pointListItr++;
X_monotone_curve_2 subcurve =
construct_x_monotone_subcurve_2( curve, p1, p2 );
clippings.push_back( subcurve );
}
#if 0
// std::cout << "pointList size: " << pointList.size( ) << std::endl;
// if ( intersections.size( ) % 2 == 0 )
// {
// // either both curve endpoints are in view or both are out
// if ( this->clippingRect.contains( qendpt1 ) )
// {
// if ( this->clippingRect.contains( qendpt2 ) )
// {
// std::cout << "both endpoints are in view" << std::endl;
// }
// }
// else if ( !this->clippingRect.contains( qendpt2 ) )
// {
// std::cout << "both endpoints are out of view" << std::endl;
// }
// }
// else
// { // one curve endpoint is in view
// if ( this->clippingRect.contains( qendpt1 ) )
// {
// std::cout << "left endpoint is in view" << std::endl;
// }
// else if ( this->clippingRect.contains( qendpt2 ) )
// {
// std::cout << "right endpoint is in view" << std::endl;
// }
// }
std::vector< X_monotone_curve_2 > res;
res.push_back( curve );
return res;
#endif
return clippings;
}
// keep only the intersection points ie. throw out overlapping curve segments // keep only the intersection points ie. throw out overlapping curve segments
void filterIntersectionPoints( std::vector< CGAL::Object >& res ) void filterIntersectionPoints( std::vector< CGAL::Object >& res );
{
std::vector< std::pair< Intersection_point_2, Multiplicity > > tmp;
// filter out the non-intersection point results
for ( unsigned int i = 0; i < res.size( ); ++i )
{
CGAL::Object obj = res[ i ];
std::pair< Intersection_point_2, Multiplicity > pair;
if ( CGAL::assign( pair, obj ) )
{
tmp.push_back( pair );
}
}
res.clear( );
// sort the intersection points by x-coord
Compare_intersection_point_result compare_intersection_point_result;
std::sort( tmp.begin( ), tmp.end( ), compare_intersection_point_result );
// box up the sorted elements
for ( unsigned int i = 0; i < tmp.size( ); ++i )
{
std::pair< Intersection_point_2, Multiplicity > pair = tmp[ i ];
CGAL::Object o = CGAL::make_object( pair );
res.push_back( o );
}
}
void printIntersectResult( const std::vector< CGAL::Object >& res )
{
for ( std::vector< CGAL::Object >::const_iterator it = res.begin( );
it != res.end( ); ++it )
{
CGAL::Object obj = *it;
std::pair< Intersection_point_2, Multiplicity > pair;
if ( CGAL::assign( pair, obj ) )
{
Point_2 pt = pair.first;
/* QPointF qpt = */ this->convert( pt );
// std::cout << "(" << pt.x( ) << " " << pt.y( ) < ")" << std::endl;
}
}
}
protected: // members protected: // members
Traits traits; Traits traits;
//Intersect_2 intersect_2; Intersect_curves<Traits> intersect_2;
Construct_x_monotone_curve_2 construct_x_monotone_curve_2; Construct_x_monotone_curve_2 construct_x_monotone_curve_2;
}; };
template <
typename RatKernel, typename AlgKernel, typename NtTraits,
typename BoundingTraits>
class ArrangementPainterOstream<CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits, BoundingTraits>> :
public ArrangementPainterOstreamBase<CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits, BoundingTraits>>
{
public: // typedefs
typedef CGAL::Arr_Bezier_curve_traits_2<
RatKernel, AlgKernel, NtTraits, BoundingTraits>
Traits;
typedef ArrangementPainterOstreamBase< Traits > Superclass;
typedef typename Superclass::Point_2 Point_2;
typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
public:
/*! Constructor */
ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()) :
Superclass( p, clippingRectangle )
{ }
/*! Destructor (virtual) */
virtual ~ArrangementPainterOstream() {}
public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
std::vector<std::pair<double, double>>
getPoints(const X_monotone_curve_2& curve);
};
template < typename Kernel_ > template < typename Kernel_ >
class ArrangementPainterOstream< CGAL::Arr_linear_traits_2< Kernel_ > >: class ArrangementPainterOstream< CGAL::Arr_linear_traits_2< Kernel_ > >:
public ArrangementPainterOstreamBase< CGAL::Arr_linear_traits_2< Kernel_ > > public ArrangementPainterOstreamBase< CGAL::Arr_linear_traits_2< Kernel_ > >
@ -673,9 +288,6 @@ public: // typedefs
typedef typename Superclass::Segment_2 Segment_2; typedef typename Superclass::Segment_2 Segment_2;
typedef typename Superclass::Ray_2 Ray_2; typedef typename Superclass::Ray_2 Ray_2;
typedef typename Superclass::Line_2 Line_2; typedef typename Superclass::Line_2 Line_2;
typedef typename Superclass::Triangle_2 Triangle_2;
typedef typename Superclass::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Superclass::Circle_2 Circle_2;
typedef typename Traits::Curve_2 Curve_2; typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
@ -689,68 +301,7 @@ public:
virtual ~ArrangementPainterOstream() {} virtual ~ArrangementPainterOstream() {}
public: // methods public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve ) ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
{
if ( curve.is_segment( ) )
{
Segment_2 seg = curve.segment( );
// skip segments outside our view
QRectF seg_bb = this->convert( seg.bbox( ) );
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.intersects( seg_bb ) )
{
return *this;
}
this->painterOstream << seg;
}
else if ( curve.is_ray( ) )
{
Ray_2 ray = curve.ray( );
QLineF qseg = this->convert( ray );
if ( qseg.isNull( ) )
{ // it's out of view
return *this;
}
Segment_2 seg = this->convert( qseg );
this-> painterOstream << seg;
}
else // curve.is_line( )
{
Line_2 line = curve.line( );
QLineF qseg = this->convert( line );
if ( qseg.isNull( ) )
{ // it's out of view
return *this;
}
Segment_2 seg = this->convert( qseg );
this-> painterOstream << seg;
}
return *this;
}
ArrangementPainterOstream& operator<<( const Point_2& p )
{
QPointF qpt = this->convert( p );
// clip the point if possible
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.contains( qpt ) )
{
return *this;
}
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
return *this;
}
template < typename T > template < typename T >
ArrangementPainterOstream& operator<<( const T& p ) ArrangementPainterOstream& operator<<( const T& p )
@ -760,72 +311,7 @@ public: // methods
} }
}; };
template < typename CircularKernel >
class ArrangementPainterOstream< CGAL::Arr_circular_arc_traits_2<
CircularKernel > >:
public ArrangementPainterOstreamBase< CGAL::Arr_circular_arc_traits_2<
CircularKernel > >
{
public:
typedef CircularKernel Kernel;
typedef CGAL::Arr_circular_arc_traits_2< Kernel > Traits;
typedef ArrangementPainterOstreamBase< Traits > Superclass;
typedef typename Superclass::Point_2 Point_2;
typedef typename Superclass::Segment_2 Segment_2;
typedef typename Superclass::Ray_2 Ray_2;
typedef typename Superclass::Line_2 Line_2;
typedef typename Superclass::Triangle_2 Triangle_2;
typedef typename Superclass::Iso_rectangle_2 Iso_rectangle_2;
typedef typename Superclass::Circle_2 Circle_2;
typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
public:
/*! Constructor */
ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()):
Superclass( p, clippingRectangle )
{ }
/*! Destructor (virtual) */
virtual ~ArrangementPainterOstream() {}
public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve )
{
this->painterOstream << curve;
return *this;
}
ArrangementPainterOstream& operator<<( const Point_2& p )
{
QPointF qpt = this->convert( p );
// clip the point if possible
if ( this->clippingRect.isValid( ) &&
! this->clippingRect.contains( qpt ) )
{
return *this;
}
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
return *this;
}
template < typename T >
ArrangementPainterOstream& operator<<( const T& p )
{
(*(static_cast< Superclass* >(this)) << p);
return *this;
}
};
#if 0
template < typename Coefficient_ > template < typename Coefficient_ >
class ArrangementPainterOstream< CGAL::Arr_algebraic_segment_traits_2< class ArrangementPainterOstream< CGAL::Arr_algebraic_segment_traits_2<
Coefficient_ > >: Coefficient_ > >:
@ -840,140 +326,50 @@ public:
typedef typename Traits::CKvA_2 CKvA_2; typedef typename Traits::CKvA_2 CKvA_2;
typedef typename Traits::Point_2 Point_2; typedef typename Traits::Point_2 Point_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef std::pair<double, double> Coord_2;
typedef std::vector<Coord_2> Coord_vec_2;
public: public:
/*! Constructor */ /*! Constructor */
ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()): ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = QRectF()) :
Superclass( p, clippingRectangle ) Superclass(p, clippingRectangle)
{ } {
}
void setScene(QGraphicsScene* scene_) override
{
Superclass::setScene(scene_);
this->setupFacade();
}
/*! Destructor (virtual) */ /*! Destructor (virtual) */
virtual ~ArrangementPainterOstream() {} virtual ~ArrangementPainterOstream() {}
public: // methods public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve )
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve );
// more efficient than repeatedly calling operator<< since we will only call
// remapFacadePainter once
template <typename EdgesIterator>
void paintEdges(EdgesIterator first, EdgesIterator last)
{ {
//std::cout << "paint curve stub (alg traits)" << std::endl; this->qp->save();
typedef Curve_renderer_facade<CKvA_2> Facade; this->remapFacadePainter();
typedef std::pair< int, int > Coord_2; for (auto it = first; it != last; ++it)
typedef std::vector< Coord_2 > Coord_vec_2;
this->setupFacade( );
boost::optional < Coord_2 > p1, p2;
std::list<Coord_vec_2> points;
Facade::instance().draw( curve, points, &p1, &p2 );
if(points.empty())
return *this;
// QPainter *ppnt = this->qp;
QGraphicsView* view = this->scene->views( ).first( );
// int height = view->height();
// std::cerr << ws.width() << " and " << ws.height() << "\n";
typename std::list<Coord_vec_2>::const_iterator lit = points.begin();
//ppnt->moveTo((*p1).first, height - (*p1).second);
while(lit != points.end()) {
const Coord_vec_2& vec = *lit;
typename Coord_vec_2::const_iterator vit = vec.begin();
//std::cerr << "(" << vit->first << "; " << vit->second << ")\n";
// if(lit == points.begin() &&*/ vit != vec.end()) {
// ppnt->lineTo(vit->first, height - vit->second);
// vit++;
// }
#if 0
if(vit != vec.end())
ppnt->moveTo(vit->first, height - vit->second);
while(vit != vec.end()) {
ppnt->lineTo(vit->first, height - vit->second);
vit++;
//std::cerr << "(" << vit->e0 << "; " << vit->e1 << "\n";
}
lit++;
#endif
QPainterPath path;
QPoint coord( vit->first, vit->second );
QPointF qpt = view->mapToScene( coord );
if ( vit != vec.end() )
{
path.moveTo( qpt );
}
while ( vit != vec.end() )
{
path.lineTo( qpt );
vit++;
coord = QPoint( vit->first, vit->second );
qpt = view->mapToScene( coord );
//std::cout << vit->first << " " << vit->second << std::endl;
}
this->qp->drawPath( path );
lit++;
}
//ppnt->lineTo((*p2).first, height - (*p2).second);
#if 0
QPen old_pen = ppnt->pen();
ppnt->setPen(QPen(Qt::NoPen)); // avoid drawing outlines
// draw with the current brush attributes
//std::cerr << "endpts1: (" << (*p1).first << "; " << (*p1).second << "\n";
//std::cerr << "endpts2: (" << (*p2).first << "; " << (*p2).second << "\n";
unsigned sz = CGAL_REND_PT_RADIUS;
ppnt->drawEllipse((*p1).first - sz, height-(*p1).second - sz, sz*2, sz*2);
ppnt->drawEllipse((*p2).first - sz, height-(*p2).second - sz, sz*2, sz*2);
ppnt->setPen(old_pen);
#endif
return *this;
}
ArrangementPainterOstream& operator<<( const Point_2& p )
{
typedef Curve_renderer_facade<CKvA_2> Facade;
std::pair< int, int > coord;
//std::cout << "draw point stub" << std::endl;
this->setupFacade( );
if(!Facade::instance().draw(p, coord)) {
return *this;
}
else
{ {
//std::cout << coord.first << " " << coord.second << std::endl; X_monotone_curve_2 curve = it->curve();
QPoint coords( coord.first, coord.second ); this->paintCurve(curve);
QGraphicsView* view = this->scene->views( ).first( );
QPointF qpt = view->mapToScene( coords );
QPen savePen = this->qp->pen( );
this->qp->setBrush( QBrush( savePen.color( ) ) );
double radius = savePen.width( ) / 2.0;
radius /= this->scale;
this->qp->drawEllipse( qpt, radius, radius );
this->qp->setBrush( QBrush( ) );
this->qp->setPen( savePen );
} }
#if 0 this->qp->restore();
QPainter *ppnt = &ws.get_painter();
QPen old_pen = ppnt->pen();
ppnt->setPen(QPen(Qt::NoPen));
unsigned sz = CGAL_REND_PT_RADIUS;
ppnt->drawEllipse(coord.first - sz, ws.height() - coord.second - sz,
sz*2, sz*2);
ppnt->setPen(old_pen);
#endif
return *this;
} }
// Maybe move these functions to someplace else?
std::vector<Coord_vec_2> getPointsList(const X_monotone_curve_2& curve);
QTransform getPointsListMapping();
QTransform getPointsListMapping(const QTransform& worldTransform);
void setupFacade();
template < typename T > template < typename T >
ArrangementPainterOstream& operator<<( const T& p ) ArrangementPainterOstream& operator<<( const T& p )
{ {
@ -982,16 +378,40 @@ public: // methods
} }
protected: protected:
void setupFacade( ) void paintCurve(const X_monotone_curve_2& curve);
{ void remapFacadePainter();
typedef Curve_renderer_facade<CKvA_2> Facade; };
QGraphicsView* view = this->scene->views( ).first( );
QRectF viewport = this->viewportRect( ); template <typename AlgebraicKernel_d_1_>
CGAL::Bbox_2 bbox = this->convert( viewport ).bbox( ); class ArrangementPainterOstream<
Facade::setup(bbox, view->width(), view->height()); CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>> :
} public ArrangementPainterOstreamBase<
CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>>
{
public:
typedef AlgebraicKernel_d_1_ AlgebraicKernel_d_1;
typedef Arr_rational_function_traits_2<AlgebraicKernel_d_1>
Traits;
typedef typename Traits::Rational Rational;
typedef ArrangementPainterOstreamBase<Traits> Superclass;
typedef ArrangementPainterOstream<Traits> Self;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef std::pair<double, double> Coord_2;
typedef std::vector<Coord_2> Coord_vec_2;
public:
ArrangementPainterOstream(QPainter* p, QRectF clippingRectangle = {}) :
Superclass(p, clippingRectangle)
{
}
Self& operator<<(const X_monotone_curve_2& curve);
std::vector<Coord_vec_2> getPointsList(const X_monotone_curve_2& curve);
protected:
template <typename Lambda>
void sample_points(const X_monotone_curve_2& curve, Lambda&& lambda);
}; };
#endif
} // namespace Qt } // namespace Qt
} // namespace CGAL } // namespace CGAL

View File

@ -1,115 +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 <alextsui05@gmail.com>
#ifndef ARRANGEMENT_SEGMENT_INPUT_CALLBACK_H
#define ARRANGEMENT_SEGMENT_INPUT_CALLBACK_H
#include <CGAL/Qt/GraphicsViewInput.h>
//#include <CGAL/Qt/Converter.h>
//#include <QEvent>
//#include <QGraphicsLineItem>
#include <QGraphicsSceneMouseEvent>
#include <iostream>
#include "GraphicsViewSegmentInput.h"
#include "Utils.h"
template < typename Arr_ >
class ArrangementSegmentInputCallback:
public CGAL::Qt::GraphicsViewSegmentInput<
typename ArrTraitsAdaptor< typename Arr_::Geometry_traits_2 >::Kernel >
{
public:
typedef Arr_ Arrangement;
typedef typename Arrangement::Geometry_traits_2 Traits;
typedef typename Arrangement::Vertex_iterator Vertex_iterator;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef CGAL::Qt::GraphicsViewSegmentInput< Kernel > Superclass;
typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename Traits::Construct_x_monotone_curve_2
Construct_x_monotone_curve_2;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::FT FT;
ArrangementSegmentInputCallback( Arrangement* arrangement_, QObject* parent);
void processInput( CGAL::Object );
void setScene( QGraphicsScene* scene_ );
protected:
Point_2 snapPoint( QGraphicsSceneMouseEvent* event );
Arrangement* arrangement;
Construct_x_monotone_curve_2 construct_x_monotone_curve_2;
SnapToArrangementVertexStrategy< Arrangement > snapToVertexStrategy;
SnapToGridStrategy< Kernel > snapToGridStrategy;
}; // class ArrangementSegmentInputCallback
template < typename Arr_ >
ArrangementSegmentInputCallback< Arr_ >::
ArrangementSegmentInputCallback( Arrangement* arrangement_, QObject* parent ):
Superclass( parent ),
arrangement( arrangement_ )
{
this->snapToVertexStrategy.setArrangement( arrangement_ );
QObject::connect( this, SIGNAL( generate( CGAL::Object ) ),
this, SLOT( processInput( CGAL::Object ) ) );
}
template < typename Arr_ >
void
ArrangementSegmentInputCallback< Arr_ >::
processInput( CGAL::Object o )
{
Segment_2 segment;
if ( CGAL::assign( segment, o ) )
{
// insert a segment
Point_2 p1 = segment.source( );
Point_2 p2 = segment.target( );
Curve_2 curve = this->construct_x_monotone_curve_2( p1, p2 );
CGAL::insert( *( this->arrangement ), curve );
}
Q_EMIT CGAL::Qt::GraphicsViewInput::modelChanged( );
}
template < typename Arr_ >
void
ArrangementSegmentInputCallback< Arr_ >::setScene( QGraphicsScene* scene_ )
{
this->Superclass::setScene( scene_ );
this->snapToVertexStrategy.setScene( scene_ );
this->snapToGridStrategy.setScene( scene_ );
}
template < typename Arr_ >
typename ArrangementSegmentInputCallback< Arr_ >::Point_2
ArrangementSegmentInputCallback< Arr_ >::
snapPoint( QGraphicsSceneMouseEvent* event )
{
if ( this->snapToGridEnabled )
{
return this->snapToGridStrategy.snapPoint( event );
}
else if ( this->snappingEnabled )
{
return this->snapToVertexStrategy.snapPoint( event );
}
else
{
return this->convert( event->scenePos( ) );
}
}
#endif // ARRANGEMENT_SEGMENT_INPUT_CALLBACK_H

View File

@ -1,75 +1,55 @@
// Copyright (c) 2005,2012 Tel-Aviv University (Israel). // Copyright (c) 2005, 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
// //
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
// Alex Tsui <alextsui05@gmail.com> // Alex Tsui <alextsui05@gmail.com>
// Saurabh Singh <ssingh@cs.iitr.ac.in>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_TYPES_H #ifndef ARRANGEMENT_DEMO_TYPES_H
#define ARRANGEMENT_DEMO_TYPES_H #define ARRANGEMENT_DEMO_TYPES_H
#include <CGAL/basic.h> #include <CGAL/Arrangement_with_history_2.h>
/*
#include <CGAL/IO/Qt_widget.h>
#include <CGAL/IO/Qt_widget_Polygon_2.h>
#include <CGAL/IO/Qt_help_window.h>
*/
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
#include <CGAL/Arr_default_dcel.h> #include <CGAL/Arr_default_dcel.h>
#include <CGAL/Arr_segment_traits_2.h> #include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arr_linear_traits_2.h> #include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arr_consolidated_curve_data_traits_2.h>
#include <CGAL/Arr_polyline_traits_2.h> #include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arr_algebraic_segment_traits_2.h>
#include <CGAL/Arrangement_with_history_2.h>
#include <CGAL/Arr_conic_traits_2.h>
#include <CGAL/Arr_trapezoid_ric_point_location.h>
#include <CGAL/Arr_simple_point_location.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arr_landmarks_point_location.h>
#include <CGAL/squared_distance_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Arr_observer.h> #ifdef CGAL_USE_CORE
#include <CGAL/Polygon_2.h> #include <CGAL/CORE_algebraic_number_traits.h>
#include <CGAL/Arr_conic_traits_2.h>
// Coordinate related typedef - using inexact number type #include <CGAL/Arr_algebraic_segment_traits_2.h>
typedef float Coord_type; #include <CGAL/Arr_Bezier_curve_traits_2.h>
typedef CGAL::Cartesian<Coord_type> Coord_kernel; #include <CGAL/Arr_rational_function_traits_2.h>
typedef Coord_kernel::Point_2 Coord_point; #include <CGAL/Algebraic_kernel_d_1.h>
typedef Coord_kernel::Segment_2 Coord_segment; #include <CGAL/CORE_BigRat.h>
typedef Coord_kernel::Circle_2 Coord_circle;
typedef CGAL::Polygon_2<Coord_kernel> My_polygon;
// polygon is usefull for filling faces
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpq.h>
typedef CGAL::Gmpq NT;
#else
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
typedef CGAL::Quotient<CGAL::MP_Float> NT;
#endif #endif
// instead of
//typedef CGAL::Cartesian<NT> Kernel;
// workaround for VC++
struct Kernel : public CGAL::Cartesian<NT> {};
#include "RationalTypes.h"
#include <QColor>
// avoid polluting global namespace
// caused multiple bugs before!
namespace demo_types
{
struct DemoTypes
{
class Face_with_color : public CGAL::Arr_face_base class Face_with_color : public CGAL::Arr_face_base
{ {
QColor m_color; QColor m_color;
bool m_visited; bool m_visited;
public: public:
Face_with_color() : CGAL::Arr_face_base(), m_color(), m_visited(false) { } Face_with_color() :
CGAL::Arr_face_base(), m_color(::Qt::white), m_visited(false)
{
}
QColor color() const { return m_color; } QColor color() const { return m_color; }
void set_color(const QColor& c) { m_color = c; } void set_color(const QColor& c) { m_color = c; }
@ -79,10 +59,10 @@ public:
template <class Traits> template <class Traits>
class Dcel : class Dcel :
public CGAL::Arr_dcel_base<CGAL::Arr_vertex_base<typename Traits::Point_2>, public CGAL::Arr_dcel_base<
CGAL::Arr_halfedge_base< CGAL::Arr_vertex_base<typename Traits::Point_2>,
typename Traits::X_monotone_curve_2>, CGAL::Arr_halfedge_base<typename Traits::X_monotone_curve_2>,
Face_with_color> Face_with_color>
{ {
public: public:
/*! \struct /*! \struct
@ -93,225 +73,98 @@ public:
{ {
typedef Dcel<T> other; typedef Dcel<T> other;
}; };
// CREATION
Dcel() {}
}; };
// use same rational type across arrangements
// less specializations, and makes PointSnapper untemplated
typedef typename RationalTypes::Rational Rational;
typedef typename RationalTypes::Rat_kernel Rat_kernel;
typedef typename RationalTypes::Rat_point_2 Rat_point_2;
// Segments: // Segments:
typedef CGAL::Arr_segment_traits_2<Kernel> Seg_traits; typedef CGAL::Arr_segment_traits_2<Rat_kernel> Seg_traits;
typedef Seg_traits::Curve_2 Arr_seg_2;
typedef Seg_traits::X_monotone_curve_2 Arr_xseg_2;
typedef Seg_traits::Point_2 Arr_seg_point_2;
typedef Dcel<Seg_traits> Seg_dcel; typedef Dcel<Seg_traits> Seg_dcel;
typedef CGAL::Arrangement_with_history_2<Seg_traits, Seg_dcel> typedef CGAL::Arrangement_with_history_2<Seg_traits, Seg_dcel>
Seg_arr; Seg_arr;
typedef Seg_arr::Halfedge Seg_halfedge;
typedef Seg_arr::Halfedge_handle Seg_halfedge_handle;
typedef Seg_arr::Face_handle Seg_face_handle;
typedef Seg_arr::Ccb_halfedge_circulator
Seg_ccb_halfedge_circulator;
typedef Seg_arr::Hole_iterator Seg_holes_iterator;
typedef Seg_arr::Face_iterator Seg_face_iterator;
typedef std::list<Arr_seg_2*> Arr_seg_list;
typedef Arr_seg_list::const_iterator Arr_seg_const_iter;
typedef Arr_seg_list::iterator Arr_seg_iter;
// point location
typedef CGAL::Arr_trapezoid_ric_point_location<Seg_arr>
Seg_trap_point_location;
typedef CGAL::Arr_simple_point_location<Seg_arr>
Seg_simple_point_location;
typedef CGAL::Arr_walk_along_line_point_location<Seg_arr>
Seg_walk_point_location;
typedef CGAL::Arr_landmarks_point_location<Seg_arr>
Seg_lanmarks_point_location;
// Polyline // Polyline
typedef CGAL::Arr_polyline_traits_2<Seg_traits> Pol_traits; typedef CGAL::Arr_polyline_traits_2<Seg_traits> Pol_traits;
typedef Pol_traits::Curve_2 Arr_pol_2;
typedef Pol_traits::X_monotone_curve_2 Arr_xpol_2;
typedef Pol_traits::Point_2 Arr_pol_point_2;
typedef Dcel<Pol_traits> Pol_dcel; typedef Dcel<Pol_traits> Pol_dcel;
typedef CGAL::Arrangement_with_history_2<Pol_traits, typedef CGAL::Arrangement_with_history_2<Pol_traits,
Pol_dcel> Pol_arr; Pol_dcel> Pol_arr;
typedef Pol_arr::Halfedge_handle Pol_halfedge_handle;
typedef Pol_arr::Face_handle Pol_face_handle;
typedef Pol_arr::Ccb_halfedge_circulator
Pol_ccb_halfedge_circulator;
typedef Pol_arr::Hole_iterator Pol_holes_iterator;
typedef Pol_arr::Halfedge Pol_halfedge;
typedef Pol_arr::Face_iterator Pol_face_iterator;
typedef std::list<Arr_pol_2*> Arr_pol_list;
typedef Arr_pol_list::const_iterator Arr_pol_const_iter;
typedef Arr_pol_list::iterator Arr_pol_iter;
// point location
typedef CGAL::Arr_trapezoid_ric_point_location<Pol_arr>
Pol_trap_point_location;
typedef CGAL::Arr_simple_point_location<Pol_arr>
Pol_simple_point_location;
typedef CGAL::Arr_walk_along_line_point_location<Pol_arr>
Pol_walk_point_location;
typedef CGAL::Arr_landmarks_point_location<Pol_arr>
Pol_lanmarks_point_location;
// Conics
#ifdef CGAL_USE_CORE
#include <CGAL/CORE_algebraic_number_traits.h>
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
// instead of
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Conic_traits;
// workaround for VC++
/*
struct Conic_traits: public CGAL::Arr_conic_traits_2<Rat_kernel,
Alg_kernel,
Nt_traits> {};
*/
typedef Conic_traits::Curve_2 Arr_conic_2;
typedef Conic_traits::Rat_point_2 Rat_point_2;
typedef Conic_traits::Rat_segment_2 Rat_segment_2;
typedef Conic_traits::Rat_circle_2 Rat_circle_2;
typedef Conic_traits::Rat_line_2 Rat_line_2;
typedef Conic_traits::X_monotone_curve_2 Arr_xconic_2;
typedef Conic_traits::Point_2 Arr_conic_point_2;
typedef Dcel<Conic_traits> Conic_dcel;
typedef CGAL::Arrangement_with_history_2<Conic_traits, Conic_dcel>
Conic_arr;
typedef Conic_arr::Halfedge_handle Conic_halfedge_handle;
typedef Conic_arr::Face_handle Conic_face_handle;
typedef Conic_arr::Ccb_halfedge_circulator
Conic_ccb_halfedge_circulator;
typedef Conic_arr::Hole_iterator Conic_holes_iterator;
//typedef CGAL::Arr_file_scanner<Conic_arr> Arr_scanner;
typedef Conic_arr::Halfedge Conic_halfedge;
typedef Conic_arr::Face_iterator Conic_face_iterator;
typedef std::list<Arr_xconic_2*> Arr_xconic_list;
typedef Arr_xconic_list::const_iterator Arr_xconic_const_iter;
typedef Arr_xconic_list::iterator Arr_xconic_iter;
// point location
typedef CGAL::Arr_trapezoid_ric_point_location<Conic_arr>
Conic_trap_point_location;
typedef CGAL::Arr_simple_point_location<Conic_arr>
Conic_simple_point_location;
typedef CGAL::Arr_walk_along_line_point_location<Conic_arr>
Conic_walk_point_location;
typedef CGAL::Arr_landmarks_point_location<Conic_arr>
Conic_lanmarks_point_location;
typedef Nt_traits::Integer Coefficient;
typedef CGAL::Arr_algebraic_segment_traits_2<Coefficient> Alg_seg_traits;
typedef Dcel< Alg_seg_traits > Alg_seg_dcel;
typedef CGAL::Arrangement_with_history_2< Alg_seg_traits, Alg_seg_dcel >
Alg_seg_arr;
#endif
// Linear: // Linear:
typedef CGAL::Arr_linear_traits_2<Kernel> Lin_traits; typedef CGAL::Arr_linear_traits_2<Rat_kernel> Lin_traits;
typedef Lin_traits::Curve_2 Arr_lin_2;
typedef Lin_traits::X_monotone_curve_2 Arr_xlin_2;
typedef Lin_traits::Point_2 Arr_lin_point_2;
typedef Dcel<Lin_traits> Lin_dcel; typedef Dcel<Lin_traits> Lin_dcel;
typedef CGAL::Arrangement_with_history_2<Lin_traits, Lin_dcel> typedef CGAL::Arrangement_with_history_2<Lin_traits, Lin_dcel>
Lin_arr; Lin_arr;
typedef Lin_arr::Halfedge Lin_halfedge;
typedef Lin_arr::Halfedge_handle Lin_halfedge_handle;
typedef Lin_arr::Face_handle Lin_face_handle;
typedef Lin_arr::Ccb_halfedge_circulator
Lin_ccb_halfedge_circulator;
typedef Lin_arr::Hole_iterator Lin_holes_iterator;
typedef Lin_arr::Face_iterator Lin_face_iterator;
typedef std::list<Arr_lin_2*> Arr_lin_list;
typedef Arr_lin_list::const_iterator Arr_lin_const_iter;
typedef Arr_lin_list::iterator Arr_lin_iter;
//point location #ifdef CGAL_USE_CORE
typedef CGAL::Arr_trapezoid_ric_point_location<Lin_arr> typedef CGAL::CORE_algebraic_number_traits Core_nt_traits;
Lin_trap_point_location; typedef Core_nt_traits::Integer Core_integer;
typedef CGAL::Arr_simple_point_location<Lin_arr> typedef Core_nt_traits::Rational Core_rational;
Lin_simple_point_location; typedef Core_nt_traits::Algebraic Core_algebraic;
typedef CGAL::Arr_walk_along_line_point_location<Lin_arr> typedef CGAL::Cartesian<Core_rational> Core_rat_kernel;
Lin_walk_point_location; typedef CGAL::Cartesian<Core_algebraic> Core_alg_kernel;
typedef CGAL::Arr_landmarks_point_location<Lin_arr>
Lin_landmarks_point_location;
// Conics
typedef CGAL::Arr_conic_traits_2<
Core_rat_kernel, Core_alg_kernel, Core_nt_traits>
Conic_traits;
#include <CGAL/Exact_circular_kernel_2.h> typedef Dcel<Conic_traits> Conic_dcel;
#include <CGAL/Arr_circular_arc_traits_2.h> typedef CGAL::Arrangement_with_history_2<Conic_traits, Conic_dcel>
Conic_arr;
// Algebraic
typedef CGAL::Arr_algebraic_segment_traits_2<Core_integer>
Alg_seg_traits;
typedef Dcel<Alg_seg_traits> Alg_seg_dcel;
typedef CGAL::Arrangement_with_history_2<Alg_seg_traits, Alg_seg_dcel>
Alg_seg_arr;
// Bezier
typedef CGAL::Arr_Bezier_curve_traits_2<
Core_rat_kernel, Core_alg_kernel, Core_nt_traits>
Bezier_traits;
typedef Dcel<Bezier_traits> Bezier_dcel;
typedef CGAL::Arrangement_with_history_2<Bezier_traits, Bezier_dcel>
Bezier_arr;
// Circular arcs: // Rational functions
typedef CGAL::Exact_circular_kernel_2 CircularKernel; typedef CGAL::Algebraic_kernel_d_1<Core_integer> AK1;
typedef CGAL::Arr_circular_arc_traits_2< CircularKernel > Arc_traits; typedef CGAL::Arr_rational_function_traits_2<AK1> Rational_traits;
typedef Arc_traits::Curve_2 Arr_arc_2; typedef Dcel<Rational_traits> Rational_dcel;
typedef Arc_traits::X_monotone_curve_2 Arr_xarc_2; typedef CGAL::Arrangement_with_history_2<Rational_traits, Rational_dcel>
typedef Arc_traits::Point_2 Arr_arc_point_2; Rational_arr;
typedef Dcel<Arc_traits> Arc_dcel; #endif
typedef CGAL::Arrangement_with_history_2<Arc_traits, Arc_dcel> };
Arc_arr; }
typedef Arc_arr::Halfedge Arc_halfedge;
typedef Arc_arr::Halfedge_handle Arc_halfedge_handle;
typedef Arc_arr::Face_handle Arc_face_handle;
typedef Arc_arr::Ccb_halfedge_circulator
Arc_ccb_halfedge_circulator;
typedef Arc_arr::Hole_iterator Arc_holes_iterator;
typedef Arc_arr::Face_iterator Arc_face_iterator;
typedef std::list<Arr_arc_2*> Arr_arc_list;
typedef Arr_arc_list::const_iterator Arr_arc_const_iter;
typedef Arr_arc_list::iterator Arr_arc_iter;
//point location #ifdef CGAL_USE_CORE
typedef CGAL::Arr_trapezoid_ric_point_location<Arc_arr> #define ARRANGEMENT_DEMO_SPECIALIZE_ARR_CORE(class_name) \
Arc_trap_point_location; template class class_name<demo_types::DemoTypes::Conic_arr>; \
typedef CGAL::Arr_simple_point_location<Arc_arr> template class class_name<demo_types::DemoTypes::Alg_seg_arr>; \
Arc_simple_point_location; template class class_name<demo_types::DemoTypes::Bezier_arr>; \
typedef CGAL::Arr_walk_along_line_point_location<Arc_arr> template class class_name<demo_types::DemoTypes::Rational_arr>;
Arc_walk_point_location; #define ARRANGEMENT_DEMO_SPECIALIZE_TRAITS_CORE(class_name) \
#if 0 // not supported template class class_name<demo_types::DemoTypes::Conic_traits>; \
typedef CGAL::Arr_landmarks_point_location<Arc_arr> template class class_name<demo_types::DemoTypes::Alg_seg_traits>; \
Arc_landmarks_point_location; template class class_name<demo_types::DemoTypes::Bezier_traits>; \
template class class_name<demo_types::DemoTypes::Rational_traits>;
#else
#define ARRANGEMENT_DEMO_SPECIALIZE_ARR_CORE(class_name)
#define ARRANGEMENT_DEMO_SPECIALIZE_TRAITS_CORE(class_name)
#endif #endif
template <class Arrangement_> #define ARRANGEMENT_DEMO_SPECIALIZE_ARR(class_name) \
class My_observer : public CGAL::Arr_observer<Arrangement_> template class class_name<demo_types::DemoTypes::Seg_arr>; \
{ template class class_name<demo_types::DemoTypes::Pol_arr>; \
public: template class class_name<demo_types::DemoTypes::Lin_arr>; \
ARRANGEMENT_DEMO_SPECIALIZE_ARR_CORE(class_name)
typedef Arrangement_ Arrangement; #define ARRANGEMENT_DEMO_SPECIALIZE_TRAITS(class_name) \
typedef CGAL::Arr_observer<Arrangement> Arr_observer; template class class_name<demo_types::DemoTypes::Seg_traits>; \
typedef typename Arrangement::Face_handle Face_handle; template class class_name<demo_types::DemoTypes::Pol_traits>; \
template class class_name<demo_types::DemoTypes::Lin_traits>; \
My_observer (Arrangement& arr) : Arr_observer (arr) {} ARRANGEMENT_DEMO_SPECIALIZE_TRAITS_CORE(class_name)
virtual void after_split_face (Face_handle f ,
Face_handle new_f ,
bool /* is_hole */)
{
new_f ->set_color(f->color());
}
};
//Q_DECLARE_METATYPE( Seg_arr )
//Q_DECLARE_METATYPE( Pol_arr )
//Q_DECLARE_METATYPE( Conic_arr )
Q_DECLARE_METATYPE( CGAL::Object )
#endif // ARRANGEMENT_DEMO_TYPES_H #endif // ARRANGEMENT_DEMO_TYPES_H

View File

@ -0,0 +1,151 @@
// Copyright (c) 2020 GeometryFactory Sarl (France).
// 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): Ahmed Essam <theartful.ae@gmail.com>
#ifndef ARRANGEMENT_DEMO_TYPE_UTILS
#define ARRANGEMENT_DEMO_TYPE_UTILS
#include "ForwardDeclarations.h"
#include <CGAL/assertions.h>
namespace demo_types
{
// avoid including "ArrangementTypes.h" at all costs for better compilation
// speed
struct DemoTypes;
enum class TraitsType : int
{
SEGMENT_TRAITS,
POLYLINE_TRAITS,
LINEAR_TRAITS,
#ifdef CGAL_USE_CORE
CONIC_TRAITS,
ALGEBRAIC_TRAITS,
BEZIER_TRAITS,
RATIONAL_FUNCTION_TRAITS,
#endif
NONE,
};
template <class T>
struct TypeHolder
{
using type = T;
};
namespace details
{
template <typename T>
struct EnumFromTraits
{
static constexpr TraitsType value = TraitsType::NONE;
};
template <typename Kernel_>
struct EnumFromTraits<CGAL::Arr_segment_traits_2<Kernel_>>
{
static constexpr TraitsType value = TraitsType::SEGMENT_TRAITS;
};
template <typename SegmentTraits_2_>
struct EnumFromTraits<CGAL::Arr_polyline_traits_2<SegmentTraits_2_>>
{
static constexpr TraitsType value = TraitsType::POLYLINE_TRAITS;
};
template <typename Kernel_>
struct EnumFromTraits<CGAL::Arr_linear_traits_2<Kernel_>>
{
static constexpr TraitsType value = TraitsType::LINEAR_TRAITS;
};
#ifdef CGAL_USE_CORE
template <class Rat_kernel_, class Alg_kernel_, class Nt_traits_>
struct EnumFromTraits<
CGAL::Arr_conic_traits_2<Rat_kernel_, Alg_kernel_, Nt_traits_>>
{
static constexpr TraitsType value = TraitsType::CONIC_TRAITS;
};
template <
typename RatKernel_, typename AlgKernel_, typename NtTraits_,
typename BoundingTraits_>
struct EnumFromTraits<CGAL::Arr_Bezier_curve_traits_2<
RatKernel_, AlgKernel_, NtTraits_, BoundingTraits_>>
{
static constexpr TraitsType value = TraitsType::BEZIER_TRAITS;
};
template <typename Coefficient_>
struct EnumFromTraits<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>
{
static constexpr TraitsType value = TraitsType::ALGEBRAIC_TRAITS;
};
template <typename AlgebraicKernel_d_1_>
struct EnumFromTraits<
CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1_>>
{
static constexpr TraitsType value = TraitsType::RATIONAL_FUNCTION_TRAITS;
};
#endif // CGAL_USE_CORE
}
template <typename T>
static constexpr TraitsType enumFromArrType()
{
return details::EnumFromTraits<typename T::Geometry_traits_2>::value;
}
template <class Lambda, class Types=DemoTypes>
static void visitArrangementType(TraitsType tt, Lambda&& lambda)
{
switch (tt)
{
case TraitsType::SEGMENT_TRAITS:
lambda(TypeHolder<typename Types::Seg_arr>{});
break;
case TraitsType::POLYLINE_TRAITS:
lambda(TypeHolder<typename Types::Pol_arr>{});
break;
case TraitsType::LINEAR_TRAITS:
lambda(TypeHolder<typename Types::Lin_arr>{});
break;
#ifdef CGAL_USE_CORE
case TraitsType::CONIC_TRAITS:
lambda(TypeHolder<typename Types::Conic_arr>{});
break;
case TraitsType::ALGEBRAIC_TRAITS:
lambda(TypeHolder<typename Types::Alg_seg_arr>{});
break;
case TraitsType::BEZIER_TRAITS:
lambda(TypeHolder<typename Types::Bezier_arr>{});
break;
case TraitsType::RATIONAL_FUNCTION_TRAITS:
lambda(TypeHolder<typename Types::Rational_arr>{});
break;
#endif
default:
CGAL_error();
}
}
template <class Lambda, class Types=DemoTypes>
static void forEachArrangementType(Lambda&& lambda)
{
lambda(TypeHolder<typename Types::Seg_arr>{});
lambda(TypeHolder<typename Types::Pol_arr>{});
lambda(TypeHolder<typename Types::Lin_arr>{});
#ifdef CGAL_USE_CORE
lambda(TypeHolder<typename Types::Conic_arr>{});
lambda(TypeHolder<typename Types::Alg_seg_arr>{});
lambda(TypeHolder<typename Types::Bezier_arr>{});
lambda(TypeHolder<typename Types::Rational_arr>{});
#endif
}
}
#endif

View File

@ -0,0 +1,37 @@
<RCC>
<qresource prefix="/cgal/icons">
<file alias="fill.xpm">resources/icons/fill.xpm</file>
<file alias="conic_line.xpm">resources/icons/conic_line.xpm</file>
<file alias="zoomin.xpm">resources/icons/zoomin.xpm</file>
<file alias="zoomout.xpm">resources/icons/zoomout.xpm</file>
<file alias="zoomreset.xpm">resources/icons/zoomreset.xpm</file>
<file alias="yellow_icon.xpm">resources/icons/yellow_icon.xpm</file>
<file alias="red_icon.xpm">resources/icons/red_icon.xpm</file>
<file alias="green_icon.xpm">resources/icons/green_icon.xpm</file>
<file alias="blue_icon.xpm">resources/icons/blue_icon.xpm</file>
<file alias="pink_icon.xpm">resources/icons/pink_icon.xpm</file>
<file alias="conic_circle.xpm">resources/icons/conic_circle.xpm</file>
<file alias="conic_ellipse.xpm">resources/icons/conic_ellipse.xpm</file>
<file alias="conic_5points.xpm">resources/icons/conic_5points.xpm</file>
<file alias="conic_segment.xpm">resources/icons/conic_segment.xpm</file>
<file alias="conic_3points.xpm">resources/icons/conic_3points.xpm</file>
<file alias="snapvertex.xpm">resources/icons/snapvertex.xpm</file>
<file alias="conic_ray.xpm">resources/icons/conic_ray.xpm</file>
<file alias="lower_env_xpm.xpm">resources/icons/lower_env_xpm.xpm</file>
<file alias="upper_env_xpm.xpm">resources/icons/upper_env_xpm.xpm</file>
<file alias="grid.xpm">resources/icons/grid.xpm</file>
<file alias="snapgrid.xpm">resources/icons/snapgrid.xpm</file>
<file alias="split.xpm">resources/icons/split.xpm</file>
<file alias="merge.xpm">resources/icons/merge.xpm</file>
<file alias="rayshoot_down.xpm">resources/icons/rayshoot_down.xpm</file>
<file alias="rayshoot_up.xpm">resources/icons/rayshoot_up.xpm</file>
<file alias="insert.xpm">resources/icons/insert.xpm</file>
<file alias="hand.xpm">resources/icons/hand.xpm</file>
<file alias="delete.xpm">resources/icons/delete.xpm</file>
<file alias="pointlocation.xpm">resources/icons/pointlocation.xpm</file>
<file alias="equation.xpm">resources/icons/equation.xpm</file>
</qresource>
<qresource prefix="/cgal/Arrangement_on_surface_2">
<file alias="about.html">resources/about.html</file>
</qresource>
</RCC>

View File

@ -1,7 +1,10 @@
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( Arrangement_on_surface_2_Demo ) project(Arrangement_on_surface_2_Demo)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(NOT POLICY CMP0070 AND POLICY CMP0053) if(NOT POLICY CMP0070 AND POLICY CMP0053)
# Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
@ -12,78 +15,125 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW) cmake_policy(SET CMP0071 NEW)
endif() endif()
find_package(CGAL COMPONENTS Core Qt5 ) find_package(CGAL QUIET COMPONENTS Qt5 OPTIONAL_COMPONENTS Core)
find_package(Qt5 QUIET COMPONENTS Gui Widgets)
find_package( Qt5 QUIET COMPONENTS Gui Widgets) if (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND)
if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND CGAL_Core_FOUND)
include(${CGAL_USE_FILE}) include(${CGAL_USE_FILE})
add_compile_definitions(QT_NO_KEYWORDS)
include_directories( BEFORE ./ )
include_directories( ./ ) option(COMPILE_UTILS_INCREMENTALLY
# Arrangement package includes "Compile files in Utils directory incrementally, or compile them all as a unit. \
add_definitions(-DQT_NO_KEYWORDS) Incremental compilation will be better for development and consume less \
memory while compiling but will take longer to compile."
OFF)
qt5_wrap_ui( arrangement_2_uis set(UTILS_SOURCE_FILES
ArrangementDemoWindow.ui "Utils/Utils.cpp"
NewTabDialog.ui "Utils/PointLocationFunctions.cpp"
OverlayDialog.ui "Utils/ConstructBoundingBox.cpp"
ArrangementDemoPropertiesDialog.ui "Utils/EnvelopeFunctions.cpp"
) "Utils/ConstructSegment.cpp"
qt5_wrap_cpp( CGAL_Qt5_MOC_FILES "Utils/IntersectCurves.cpp"
ArrangementDemoWindow.h "Utils/SplitAndMerge.cpp"
ArrangementDemoTab.h
Callback.h
# NewTabDialog.h
OverlayDialog.h
ArrangementDemoPropertiesDialog.h
ColorItemEditor.h
DeleteCurveModeItemEditor.h
PropertyValueDelegate.h
#PropertyValueDelegate.cpp
)
qt5_add_resources( CGAL_Qt5_RESOURCE_FILES
ArrangementDemoWindow.qrc
)
add_executable( arrangement_2
arrangement_2.cpp
ArrangementGraphicsItem.cpp
ArrangementDemoWindow.cpp
ArrangementDemoTab.cpp
ArrangementDemoGraphicsView.cpp
Callback.cpp
VerticalRayShootCallback.cpp
EnvelopeCallback.cpp
SplitEdgeCallback.cpp
FillFaceCallback.cpp
GraphicsViewSegmentInput.cpp
GraphicsViewCurveInput.cpp
Utils.cpp
NewTabDialog.cpp
OverlayDialog.cpp
ArrangementDemoPropertiesDialog.cpp
ColorItemEditor.cpp
PropertyValueDelegate.cpp
DeleteCurveMode.cpp
DeleteCurveModeItemEditor.cpp
PointsGraphicsItem.cpp
VerticalRayGraphicsItem.cpp
${CGAL_Qt5_MOC_FILES}
${arrangement_2_uis}
${CGAL_Qt5_RESOURCE_FILES}
)
target_link_libraries( arrangement_2 PRIVATE
CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_Core
Qt5::Gui
) )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS arrangement_2 ) if (COMPILE_UTILS_INCREMENTALLY)
set(UTILS_COMPILE_FILES ${UTILS_SOURCE_FILES})
else()
set(UTILS_CPP_FILES_INCLUDES "")
foreach(utils_src IN LISTS UTILS_SOURCE_FILES)
string(APPEND UTILS_CPP_FILES_INCLUDES "#include \"${utils_src}\"\n")
endforeach()
file(WRITE "${CMAKE_BINARY_DIR}/CombinedUtils.cpp" ${UTILS_CPP_FILES_INCLUDES})
set(UTILS_COMPILE_FILES "${CMAKE_BINARY_DIR}/CombinedUtils.cpp")
endif()
qt5_wrap_ui(arrangement_2_uis
ArrangementDemoWindow.ui
NewTabDialog.ui
OverlayDialog.ui
ArrangementDemoPropertiesDialog.ui
AlgebraicCurveInputDialog.ui
RationalCurveInputDialog.ui)
qt5_wrap_cpp(CGAL_Qt5_MOC_FILES
ArrangementDemoWindow.h
ArrangementDemoTab.h
GraphicsViewCurveInput.h
Callback.h
OverlayDialog.h
ArrangementDemoPropertiesDialog.h
AlgebraicCurveInputDialog.h
RationalCurveInputDialog.h
ColorItemEditor.h
PropertyValueDelegate.h)
qt5_add_resources(CGAL_Qt5_RESOURCE_FILES Arrangement_on_surface_2.qrc)
add_executable(arrangement_2
arrangement_2.cpp
ArrangementDemoWindow.cpp
ArrangementDemoTab.cpp
ArrangementDemoGraphicsView.cpp
ArrangementGraphicsItem.cpp
Callback.cpp
VerticalRayShootCallback.cpp
EnvelopeCallback.cpp
SplitEdgeCallback.cpp
FillFaceCallback.cpp
MergeEdgeCallback.cpp
PointLocationCallback.cpp
NewTabDialog.cpp
OverlayDialog.cpp
ArrangementDemoPropertiesDialog.cpp
AlgebraicCurveInputDialog.cpp
RationalCurveInputDialog.cpp
ColorItemEditor.cpp
PropertyValueDelegate.cpp
PointsGraphicsItem.cpp
VerticalRayGraphicsItem.cpp
DeleteCurveCallback.cpp
CurveGraphicsItem.cpp
ArrangementPainterOstream.cpp
GraphicsViewCurveInput.cpp
AlgebraicCurveParser.cpp
GraphicsSceneMixin.cpp
GridGraphicsItem.cpp
PointSnapper.cpp
CurveInputMethods.cpp
FloodFill.cpp
ArrangementIO.cpp
${UTILS_COMPILE_FILES}
${arrangement_2_uis}
${CGAL_Qt5_RESOURCE_FILES}
${CGAL_Qt5_MOC_FILES})
target_link_libraries(arrangement_2 Qt5::Core Qt5::Gui Qt5::Widgets)
target_link_libraries(arrangement_2 CGAL::CGAL CGAL::CGAL_Qt5)
if(CGAL_Core_FOUND)
target_link_libraries(arrangement_2 CGAL::CGAL_Core)
endif()
add_to_cached_list(CGAL_EXECUTABLE_TARGETS arrangement_2)
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(arrangement_2) cgal_add_compilation_test(arrangement_2)
else() else()
set(MISSING_DEPS "")
message(STATUS "NOTICE: This demo requires CGAL, CGAL-Core and Qt5, and will not be compiled.") if(NOT CGAL_FOUND)
set(MISSING_DEPS "CGAL, ${MISSING_DEPS}")
endif()
if(NOT CGAL_Qt5_FOUND)
set(MISSING_DEPS "the CGAL Qt5 library, ${MISSING_DEPS}")
endif()
if(NOT Qt5_FOUND)
set(MISSING_DEPS "Qt5, ${MISSING_DEPS}")
endif()
message(STATUS
"NOTICE: This demo requires ${MISSING_DEPS} and will not be compiled.")
endif() endif()
# add_subdirectory( tests )

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,7 +7,8 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#include "Callback.h" #include "Callback.h"
@ -20,7 +21,8 @@
namespace CGAL { namespace CGAL {
namespace Qt { namespace Qt {
Callback::Callback( QObject* parent ) : QObject( parent ) { } Callback::Callback(QObject* parent, QGraphicsScene* scene_) :
QObject(parent), GraphicsSceneMixin(scene_) { }
void Callback::reset( ) { } void Callback::reset( ) { }
@ -31,23 +33,27 @@ bool Callback::eventFilter( QObject* object, QEvent* event )
QGraphicsSceneMouseEvent* mouseEvent = QGraphicsSceneMouseEvent* mouseEvent =
static_cast< QGraphicsSceneMouseEvent* >( event ); static_cast< QGraphicsSceneMouseEvent* >( event );
this->mouseMoveEvent( mouseEvent ); this->mouseMoveEvent( mouseEvent );
return true;
} }
else if ( event->type( ) == QEvent::GraphicsSceneMousePress ) else if ( event->type( ) == QEvent::GraphicsSceneMousePress )
{ {
QGraphicsSceneMouseEvent* mouseEvent = QGraphicsSceneMouseEvent* mouseEvent =
static_cast< QGraphicsSceneMouseEvent* >( event ); static_cast< QGraphicsSceneMouseEvent* >( event );
this->mousePressEvent( mouseEvent ); this->mousePressEvent( mouseEvent );
return true;
} }
else if ( event->type( ) == QEvent::GraphicsSceneMouseRelease ) else if ( event->type( ) == QEvent::GraphicsSceneMouseRelease )
{ {
QGraphicsSceneMouseEvent* mouseEvent = QGraphicsSceneMouseEvent* mouseEvent =
static_cast< QGraphicsSceneMouseEvent* >( event ); static_cast< QGraphicsSceneMouseEvent* >( event );
this->mouseReleaseEvent( mouseEvent ); this->mouseReleaseEvent( mouseEvent );
return true;
} }
else if ( event->type( ) == QEvent::KeyPress ) else if ( event->type( ) == QEvent::KeyPress )
{ {
QKeyEvent* keyEvent = static_cast< QKeyEvent* >( event ); QKeyEvent* keyEvent = static_cast< QKeyEvent* >( event );
this->keyPressEvent( keyEvent ); this->keyPressEvent( keyEvent );
return true;
} }
return QObject::eventFilter( object, event ); return QObject::eventFilter( object, event );
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,16 +7,15 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef CGAL_QT_CALLBACK_H #ifndef CGAL_QT_CALLBACK_H
#define CGAL_QT_CALLBACK_H #define CGAL_QT_CALLBACK_H
#include <QObject> #include <QObject>
#include "GraphicsSceneMixin.h"
#include "Utils.h"
class QRectF;
class QEvent; class QEvent;
class QKeyEvent; class QKeyEvent;
class QGraphicsScene; class QGraphicsScene;
@ -25,13 +24,14 @@ class QGraphicsSceneMouseEvent;
namespace CGAL { namespace CGAL {
namespace Qt { namespace Qt {
class Callback : public QObject, public QGraphicsSceneMixin class Callback : public QObject, public GraphicsSceneMixin
{ {
Q_OBJECT Q_OBJECT
public: public:
Callback( QObject* parent ); Callback( QObject* parent, QGraphicsScene* scene_ = nullptr );
virtual void reset( ); virtual void reset( );
virtual bool eventFilter( QObject* object, QEvent* event );
public Q_SLOTS: public Q_SLOTS:
virtual void slotModelChanged( ); virtual void slotModelChanged( );
@ -40,7 +40,6 @@ Q_SIGNALS:
void modelChanged( ); void modelChanged( );
protected: protected:
virtual bool eventFilter( QObject* object, QEvent* event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent* event ); virtual void mousePressEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseMoveEvent( QGraphicsSceneMouseEvent* event ); virtual void mouseMoveEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
@ -49,4 +48,5 @@ protected:
} // namespace Qt } // namespace Qt
} // namespace CGAL } // namespace CGAL
#endif // CGAL_QT_CALLBACK_H #endif // CGAL_QT_CALLBACK_H

View File

@ -48,21 +48,37 @@
#include "ColorItemEditor.h" #include "ColorItemEditor.h"
//! a pick color option
/*!
\param widget A QWidget pointer
\return a starting point to ask the user for color
*/
ColorItemEditor::ColorItemEditor( QWidget* widget ) : QPushButton( widget ) ColorItemEditor::ColorItemEditor( QWidget* widget ) : QPushButton( widget )
{ {
this->setText( tr("Select a color") ); this->setText( tr("Select a color") );
} }
//! get the color reference
/*!
\return the Qcolor object of the selected color
*/
QColor ColorItemEditor::color( ) const QColor ColorItemEditor::color( ) const
{ {
return this->m_color; return this->m_color;
} }
//! a pick color option
/*!
\param color A QColor that the user selected to be changed
*/
void ColorItemEditor::setColor( QColor color ) void ColorItemEditor::setColor( QColor color )
{ {
this->m_color = color; this->m_color = color;
} }
//! checking if the color reference that user wanted is valid or not
/*!
*/
void ColorItemEditor::mousePressEvent(QMouseEvent* /* e */) void ColorItemEditor::mousePressEvent(QMouseEvent* /* e */)
{ {
QColor selectedColor = QColorDialog::getColor(this->m_color); QColor selectedColor = QColorDialog::getColor(this->m_color);

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 Tel-Aviv University (Israel). // Copyright (c) 2012, 2020 Tel-Aviv University (Israel).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -7,15 +7,14 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Alex Tsui <alextsui05@gmail.com> // Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#ifndef CGAL_CONIC_READER_H #ifndef CGAL_CONIC_READER_H
#define CGAL_CONIC_READER_H #define CGAL_CONIC_READER_H
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream>
#include <list>
#include <string> #include <string>
template <typename Traits> template <typename Traits>
@ -33,16 +32,15 @@ public:
typedef typename Traits::Rat_circle_2 Rat_circle_2; typedef typename Traits::Rat_circle_2 Rat_circle_2;
template<class OutputIterator> template<class OutputIterator>
int read_data(const char * filename, OutputIterator curves_out, int read_data(std::ifstream & inp, OutputIterator curves_out,
CGAL::Bbox_2 & bbox) CGAL::Bbox_2 & bbox)
{ {
Curve_2 cv; Curve_2 cv;
char dummy[256]; char dummy[256];
std::ifstream inp(filename);
if (!inp.is_open()) { if (!inp.is_open()) {
std::cerr << "Cannot open file " << filename << "!" << std::endl; std::cerr << "Input stream is not open!" << std::endl;
return -1; return -1;
} }
int count; int count;
@ -56,7 +54,6 @@ public:
else bbox = bbox + curve_bbox; else bbox = bbox + curve_bbox;
} }
} }
inp.close();
return 0; return 0;
} }
@ -234,6 +231,54 @@ public:
if (one_line[0] != '#') break; if (one_line[0] != '#') break;
} }
} }
// should probably change class name since it reads and writes
template <typename InputIterator>
int write_data(std::ofstream & ofs, InputIterator begin_, InputIterator end_)
{
ofs << std::distance(begin_, end_) << std::endl;
for (auto it = begin_; it != end_; ++it)
{
if (it->is_full_conic())
{
ofs << "F ";
ofs << it->r() << " ";
ofs << it->s() << " ";
ofs << it->t() << " ";
ofs << it->u() << " ";
ofs << it->v() << " ";
ofs << it->w() << " ";
ofs << std::endl;
}
else if (it->orientation() == CGAL::COLLINEAR)
{
ofs << "S ";
ofs << it->source() << " ";
ofs << it->target() << " ";
ofs << std::endl;
}
else
{
ofs << "A ";
ofs << it->r() << " ";
ofs << it->s() << " ";
ofs << it->t() << " ";
ofs << it->u() << " ";
ofs << it->v() << " ";
ofs << it->w() << " ";
if (it->orientation() == CGAL::COUNTERCLOCKWISE)
ofs << "1 ";
else if (it->orientation() == CGAL::CLOCKWISE)
ofs << "-1 ";
else
ofs << "0 ";
ofs << it->source() << " ";
ofs << it->target() << " ";
ofs << std::endl;
}
}
return 0;
}
}; };
#endif #endif

View File

@ -0,0 +1,165 @@
// Copyright (c) 2012, 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
//
// Author(s): Alex Tsui <alextsui05@gmail.com>
// Ahmed Essam <theartful.ae@gmail.com>
#include "CurveGraphicsItem.h"
#include "ArrangementPainterOstream.h"
#include "ArrangementTypes.h"
#include "Utils/ConstructBoundingBox.h"
#include "Utils/Utils.h"
#include <limits>
namespace CGAL
{
namespace Qt
{
template <class ArrTraits>
CurveGraphicsItem<ArrTraits>::CurveGraphicsItem() :
bb(), m_edgeColor(::Qt::red), m_edgeWidth(2),
m_vertexColor(::Qt::red), m_vertexRadius(1)
{
this->setZValue(4);
this->pointsGraphicsItem.setParentItem(this);
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::paint(
QPainter* painter, const QStyleOptionGraphicsItem* /* option */,
QWidget* /* widget */)
{
// draw the curves
QPen edgesPen(this->m_edgeColor, this->m_edgeWidth);
edgesPen.setCosmetic(true);
painter->setPen(edgesPen);
auto painterOstream = ArrangementPainterOstream<Traits>(painter);
painterOstream.setScene(this->getScene());
for (auto& curve : this->curves) { painterOstream << curve; }
}
template <class ArrTraits>
QRectF CurveGraphicsItem<ArrTraits>::boundingRect() const
{
auto viewport = this->viewportRect();
qreal xmin = viewport.left();
qreal ymin = viewport.top();
qreal xmax = viewport.right();
qreal ymax = viewport.bottom();
if (this->bb.xmin() > xmin) xmin = this->bb.xmin();
if (this->bb.ymin() > ymin) ymin = this->bb.ymin();
if (this->bb.xmax() < xmax) xmax = this->bb.xmax();
if (this->bb.ymax() < ymax) ymax = this->bb.ymax();
if (xmin > xmax || ymin > ymax)
{
xmin = 0;
xmax = 0;
ymin = 0;
ymax = 0;
}
return {QPointF{xmin, ymin}, QPointF{xmax, ymax}};
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::insert(const X_monotone_curve_2& curve)
{
this->curves.push_back(curve);
this->updateBoundingBox();
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::insert(const Point_2& point)
{
this->pointsGraphicsItem.insert(point);
this->updateBoundingBox();
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::clear()
{
this->curves.clear();
this->pointsGraphicsItem.clear();
this->updateBoundingBox();
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::modelChanged()
{
this->updateBoundingBox();
this->update();
}
template <class ArrTraits>
const QColor& CurveGraphicsItem<ArrTraits>::edgeColor() const
{
return this->m_edgeColor;
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::setEdgeColor(const QColor& color)
{
this->m_edgeColor = color;
}
template <class ArrTraits>
int CurveGraphicsItem<ArrTraits>::edgeWidth() const
{
return this->m_edgeWidth;
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::setEdgeWidth(int width)
{
this->m_edgeWidth = width;
}
template <class ArrTraits>
const QColor& CurveGraphicsItem<ArrTraits>::vertexColor() const
{
return this->m_vertexColor;
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::setVertexColor(const QColor& color)
{
this->m_vertexColor = color;
}
template <class ArrTraits>
int CurveGraphicsItem<ArrTraits>::vertexRadius() const
{
return this->m_vertexRadius;
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::setVertexRadius(int radius)
{
this->m_vertexRadius = radius;
}
template <class ArrTraits>
void CurveGraphicsItem<ArrTraits>::updateBoundingBox()
{
this->prepareGeometryChange();
this->bb = {};
ConstructBoundingBox<Traits> construct_bounding_box;
for (auto& curve : curves)
this->bb += construct_bounding_box(curve);
}
ARRANGEMENT_DEMO_SPECIALIZE_TRAITS(CurveGraphicsItem)
} // namespace Qt
} // namespace CGAL

Some files were not shown because too many files have changed in this diff Show More