Merge remote-tracking branch 'cgal/master' into Kernel_23-Fix_dangling_ref_in_CC3-GF

This commit is contained in:
Mael Rouxel-Labbé 2025-01-16 11:43:53 +01:00
commit 3b7a4ed21e
5082 changed files with 782862 additions and 252699 deletions

View File

@ -0,0 +1,55 @@
# Use an official Fedora as a parent image for the build stage
FROM fedora:latest AS sources_deps
# Set environment variables to non-interactive
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN dnf update -y && dnf install -y \
wget \
make \
gcc \
gcc-c++ \
patch \
cmake \
bison \
flex \
unzip \
python3 \
&& dnf clean all
# Copy the patch file to the build context
COPY cgal-NO_ADDITIONAL_DETAILS.patch .
FROM sources_deps AS build
# Build and install Doxygen from sources
ARG DOXYGEN_VERSION=1.9.6
ARG MAKEFLAGS=-j$(nproc)
RUN if [ -n "$DEBUG"];then set -x && make --version && ls -lZ /tmp && id; fi \
&& DOXYGEN_VERSION_UNDERSCORE=$(echo ${DOXYGEN_VERSION} | sed 's/\./_/g') \
&& wget https://github.com/doxygen/doxygen/archive/refs/tags/Release_${DOXYGEN_VERSION_UNDERSCORE}.zip \
&& unzip Release_${DOXYGEN_VERSION_UNDERSCORE}.zip \
&& cd doxygen-Release_${DOXYGEN_VERSION_UNDERSCORE} \
&& patch -p1 < ../cgal-NO_ADDITIONAL_DETAILS.patch \
&& mkdir build \
&& cd build \
&& cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . \
&& cmake --install . \
&& mkdir -p /usr/local/share/doc/doxygen && cp ../LICENSE /usr/local/share/doc/doxygen/LICENSE.TXT \
&& cd ../.. \
&& rm -rf doxygen-Release_${DOXYGEN_VERSION_UNDERSCORE} Release_${DOXYGEN_VERSION_UNDERSCORE}.zip
# Use a smaller base image for the final stage
FROM fedora:latest
# Install necessary runtime dependencies
RUN set -x \
&& dnf update -y && dnf install -y graphviz 'perl(Getopt::Std)' tex-bibtex cmake python3-lxml python3-pyquery \
&& dnf clean all
# Copy Doxygen from the build stage
COPY --from=build /usr/local/bin/doxygen /usr/local/bin
COPY --from=build /usr/local/share/doc/doxygen/LICENSE.TXT /usr/local/share/doc/doxygen/LICENSE.TXT
RUN doxygen --version

View File

@ -0,0 +1,23 @@
SHELL := /bin/bash
DOXYGEN_VERSIONS := 1.12.0 1.11.0 1.10.0 1.9.8 1.9.7 1.9.6
.PHONY: all build-% push-% build push
all: build
@echo "Use `$(MAKE) push` to push the images to the registry."
build-%:
@echo "MAKEFLAGS: $(MAKEFLAGS)"
@echo "Building Doxygen version $*..."
if [ "$$(getenforce || true)" == "Enforcing" ]; then Z=:z; else Z=; fi; \
F="$(MAKEFLAGS)"; F=$${F##*fifo:}; F=$${F%% *}; \
if [ -p "$$F" ]; then echo "The GNU make FIFO file exists:"; ls -l $$F; VOLUME_ARGS="-v $$F:$$F$$Z"; echo -- $$VOLUME_ARGS; fi; \
podman build --build-arg DOXYGEN_VERSION=$* --build-arg "MAKEFLAGS=$(MAKEFLAGS)" $$VOLUME_ARGS -t cgal/doxygen:$* .
push-%: build-%
@echo "Pushing cgal/doxygen:$*..."
podman push cgal/doxygen:$*
build: $(foreach version,$(DOXYGEN_VERSIONS),build-$(version))
push: $(foreach version,$(DOXYGEN_VERSIONS),push-$(version))

View File

@ -0,0 +1,44 @@
diff --git a/src/config.xml b/src/config.xml
index 13910958a6..31f1354e44 100644
--- a/src/config.xml
+++ b/src/config.xml
@@ -893,6 +893,18 @@ Go to the <a href="commands.html">next</a> section or return to the
\note This will also disable the warnings about undocumented members
that are normally produced when \ref cfg_warnings "WARNINGS" is
set to \c YES.
+]]>
+ </docs>
+ </option>
+ </group>
+ <group name='Build' docs='Build related configuration options'>
+ <option type='bool' id='NO_ADDITIONAL_DETAILS' defval='0'>
+ <docs>
+<![CDATA[
+ When the \c EXTRACT_ALL tag is set to \c YES and a member or class
+ as no documentation, no detailed section will be produced if
+ the \c NO_ADDITIONAL_DETAILS tag is set to \c YES.
+ This tag has no effect if the \c EXTRACT_ALL tag is set to \c NO.
]]>
</docs>
</option>
diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index 08d9bf24c5..ab04e994c5 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -2501,6 +2501,7 @@ bool MemberDefImpl::hasDetailedDescription() const
if (!m_hasDetailedDescriptionCached)
{
bool extractAll = Config_getBool(EXTRACT_ALL);
+ bool xAllNoDetailedSec = Config_getBool(NO_ADDITIONAL_DETAILS);
bool alwaysDetailedSec = Config_getBool(ALWAYS_DETAILED_SEC);
bool repeatBrief = Config_getBool(REPEAT_BRIEF);
bool briefMemberDesc = Config_getBool(BRIEF_MEMBER_DESC);
@@ -2512,7 +2513,7 @@ bool MemberDefImpl::hasDetailedDescription() const
// the member has detailed documentation because the user added some comments
bool docFilter =
// extract all is enabled
- extractAll ||
+ (extractAll && !xAllNoDetailedSec) ||
// has detailed docs
!documentation().isEmpty() ||
// has inbody docs

View File

@ -0,0 +1,16 @@
{
"name": "CGAL Doxygen Dev Container, version 1.12.0, with CGAL patch",
"image": "docker.io/cgal/doxygen:1.12.0",
"features": {
"ghcr.io/devcontainers/features/git:1.3.2": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"bbenoist.Doxygen",
"ms-vscode.cpptools"
]
}
},
}

View File

@ -0,0 +1,29 @@
[distrobox-doxygen-1.12.0]
image=cgal/doxygen:1.12.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.12.0
[distrobox-doxygen-1.11.0]
image=cgal/doxygen:1.11.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.11.0
[distrobox-doxygen-1.10.0]
image=cgal/doxygen:1.10.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.10.0
[distrobox-doxygen-1.9.8]
image=cgal/doxygen:1.9.8
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.8
[distrobox-doxygen-1.9.7]
image=cgal/doxygen:1.9.7
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.7
[distrobox-doxygen-1.9.6]
image=cgal/doxygen:1.9.6
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.6

1
.gitattributes vendored
View File

@ -58,7 +58,6 @@ Scripts/developer_scripts/check_svn_keywords text eol=lf
Scripts/developer_scripts/create_cgal_test text eol=lf
Scripts/developer_scripts/create_cgal_test_with_cmake text eol=lf
Scripts/developer_scripts/create_internal_release text eol=lf
Scripts/developer_scripts/create_macosx_installer text eol=lf
Scripts/developer_scripts/create_new_release text eol=lf
Scripts/developer_scripts/detect_files_with_mixed_eol_styles text eol=lf
Scripts/developer_scripts/detect_packages_licenses text eol=lf

View File

@ -1,3 +1,11 @@
---
name: Issue
about: Use this template for reporting issues with CGAL
title: ''
labels: ''
assignees: ''
---
_Please use the following template to help us solving your issue._
## Issue Details

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1 @@
blank_issues_enabled: false

32
.github/install.sh vendored
View File

@ -1,11 +1,29 @@
#!/bin/bash
set -ex
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 libboost-dev libinsighttoolkit4-dev zsh
#update cmake to 3.18.4
sudo apt-get install -y \
libmpfr-dev \
libtbb-dev \
libmetis-dev \
libssh-dev \
libeigen3-dev \
qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev libqt5websockets5-dev \
libqt5svg5-dev qttools5-dev qttools5-dev-tools \
libboost-dev libboost-serialization-dev libboost-iostreams-dev libboost-filesystem-dev libboost-filesystem-dev \
libvtk9-dev libgdcm-tools libvtkgdcm-dev libunwind-dev \
libinsighttoolkit5-dev \
libceres-dev \
libglpk-dev \
libopencv-dev \
zsh \
qt6-base-dev qt6-declarative-dev libqt6svg6-dev libqt6websockets6-dev
#update CMake
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
CMAKE_VER=$(curl --silent https://cmake.org/files/LatestRelease/cmake-latest-files-v1.json | jq -r .version.string)
wget https://cmake.org/files/LatestRelease/cmake-$CMAKE_VER-linux-x86_64.sh
sudo sh cmake-*.sh --skip-license --prefix=/usr/local
rm cmake-*.sh

10
.github/test.sh vendored
View File

@ -2,12 +2,12 @@
/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)
cd Lab/demo
/usr/local/bin/cmake -S Lab -B build -DCGAL_DIR=$2
LIST_OF_PLUGINS=$(/usr/local/bin/cmake --build 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))}
NUM_PROCS=$(nproc)
make -j${NUM_PROCS} ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))}

View File

@ -10,7 +10,7 @@ jobs:
name: remove label
steps:
- name: removelabel
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -21,7 +21,7 @@ jobs:
name: "Tested",
});
- name: Post address
uses: actions/github-script@v6
uses: actions/github-script@v7
if: ${{ success() }}
with:
script: |

View File

@ -1,56 +1,115 @@
name: Documentation
name: Build Documentation
on:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull request number for which the documentation should be built'
type: number
required: true
doc_version:
description: 'Version number of the documentation build'
type: string
required: true
force_build:
description: 'Force the build of the documentation'
type: boolean
required: false
default: false
issue_comment:
types: [created]
types: [created]
env:
author_association: ${{ github.event.comment.author_association }}
comment_body: ${{ github.event.comment.body }}
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
pre_build_checks:
runs-on: ubuntu-latest
name: Trigger the build?
outputs:
trigger_build: ${{ steps.get_doc_version.outputs.result && steps.get_doc_version.outputs.result != '' }}
force_build: ${{ steps.check_comment_body.outputs.force_build }}
pr_number: ${{ steps.get_pr_number.outputs.pr_number }}
doc_version: ${{ steps.get_doc_version.outputs.result }}
steps:
- name: Display inputs
run: |
echo "pr_number=${{ inputs.pr_number || github.event.issue.number }}"
echo "doc_version=${{ inputs.doc_version }}"
echo "force_build=${{ inputs.force_build || startsWith(env.comment_body, '/force-build:') }}"
- name: Check comment body
id: check_comment_body
env:
trigger_build: ${{ inputs && inputs.pr_number || startsWith(env.comment_body, '/build:') || startsWith(env.comment_body, '/force-build:') }}
force_build: ${{ inputs && inputs.force_build || startsWith(env.comment_body, '/force-build:') }}
if: inputs.pr_number || startsWith(env.comment_body, '/build:') || startsWith(env.comment_body, '/force-build:')
run: |
if [ "${trigger_build}" = "false" ]; then
echo "No build requested"
exit 1
fi
echo "force_build=${force_build}" >> $GITHUB_OUTPUT
echo "trigger_build=${trigger_build}" >> $GITHUB_OUTPUT
- name: Check permissions
if: ( steps.check_comment_body.outputs.trigger_build || false ) && (inputs.pr_number || env.author_association == 'OWNER' || env.author_association == 'MEMBER')
run: echo "Authorized"
- name: No permissions
if: ( steps.check_comment_body.outputs.trigger_build || false ) && (! inputs.pr_number && env.author_association != 'OWNER' && env.author_association != 'MEMBER' )
run: |
echo 'ERROR: User ${{ github.actor }} is not allowed to trigger the build of the documentation with /build:* or /force-build:*'
exit 1
- name: Get PR number
if: ( steps.check_comment_body.outputs.trigger_build || false )
id: get_pr_number
env:
pr_number: ${{ inputs.pr_number || github.event.issue.number }}
run: echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
- name: Get doc version
if: ( steps.check_comment_body.outputs.trigger_build || false )
uses: actions/github-script@v7
id: get_doc_version
with:
result-encoding: string
script: |
if ( context.payload.input && context.payload.inputs.doc_version ) {
return context.payload.inputs.doc_version
}
const body = context.payload.comment.body
const re = /\/(force-)?build:(\w+)\s*/;
if(re.test(body)) {
const res = re.exec(body)
return res[2]
}
throw new Error('No version found')
build_doc:
name: |
${{ format('{0}: Build Documentation version "{1}"', github.actor, needs.pre_build_checks.outputs.doc_version) }}
needs: pre_build_checks
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create comment
runs-on: ubuntu-latest
env:
force_build: ${{ needs.pre_build_checks.outputs.force_build }}
pr_number: ${{ needs.pre_build_checks.outputs.pr_number }}
doc_version: ${{ needs.pre_build_checks.outputs.doc_version }}
if: ${{ fromJSON(needs.pre_build_checks.outputs.trigger_build || false) }}
steps:
- uses: actions/github-script@v6
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 = /\/(force-)?build:(\w+)\s*/;
if(re.test(body)){
const res = re.exec(body)
if(body.includes("force-")) {
return res[2]+":yes"
}
else{
return res[2]+":no"
}
}
}
}
return 'stop'
- uses: actions/github-script@v6
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
- name: Emoji-comment
uses: actions/github-script@v6
if: steps.get_round.outputs.result != 'stop'
if: github.event_name == 'issue_comment'
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
github.rest.reactions.createForIssueComment({
@ -60,19 +119,25 @@ jobs:
content: 'rocket'
})
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: "checkout branch"
if: steps.get_round.outputs.result != 'stop'
with:
repository: ${{ github.repository }}
ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge
fetch-depth: 2
repository: ${{ github.repository }}
ref: refs/pull/${{ env.pr_number }}/head
fetch-depth: 0
- name: install dependencies
if: steps.get_round.outputs.result != 'stop'
- name: Install dependencies
run: |
set -x
sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
# Install Github CLI `gh`
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update && sudo apt-get install -y gh cmake graphviz ssh bibtex2html
sudo pip install lxml
sudo pip install pyquery
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~cgaltest/doxygen_1_9_6_patched/doxygen
@ -81,36 +146,40 @@ jobs:
git config --global user.email "cgal@geometryfactory.com"
git config --global user.name "cgaltest"
- name: configure all
if: steps.get_round.outputs.result != 'stop'
- name: CMake configuration of Documentation/doc
run: |
set -ex
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
- name: Build and Upload Doc
- name: Build and upload Doc
id: build_and_run
if: steps.get_round.outputs.result != 'stop'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -ex
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
TMP_ROUND=${{ steps.get_round.outputs.result }}
ROUND=$(echo $TMP_ROUND | cut -d ":" -f 1)
force=$(echo $TMP_ROUND | cut -d ":" -f 2)
wget --no-verbose cgal.github.io -O tmp.html
if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html || [ "$force" = "yes" ]; then
PR_NUMBER=$pr_number
ROUND=$doc_version
force=$force_build
wget --no-verbose cgal.github.io -O index.html
if ! egrep -qF "/$PR_NUMBER/$ROUND" index.html || [ "$force" = "yes" ]; then
#list impacted packages
LIST_OF_PKGS=$(git diff --name-only HEAD^1 HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true)
LIST_OF_PKGS=$(git diff --name-only origin/master...HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true)
if [ "$LIST_OF_PKGS" = "" ]; then
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
exit 1
fi
cd build_doc && make -j2 doc
make -j2 doc_with_postprocessing 2>tmp.log
if [ -s tmp.log ]; then
content=`cat ./tmp.log`
for p in $LIST_OF_PKGS; do
if [ -f $p/doc/$p/dependencies ]; then
LIST_OF_PKGS="$LIST_OF_PKGS $(cat $p/doc/$p/dependencies)"
fi
done
LIST_OF_PKGS=$(echo $LIST_OF_PKGS | tr ' ' '\n' | sort -u)
cd build_doc && make -j$(nproc) doc
make -j$(nproc) doc_with_postprocessing 2>build.log
if [ -s build.log ]; then
delimiter="$(openssl rand -hex 8)"
echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}"
cat tmp.log >> "${GITHUB_OUTPUT}"
cat build.log >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
exit 1
fi
@ -118,32 +187,28 @@ jobs:
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
rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf
for f in $LIST_OF_PKGS
for f in $LIST_OF_PKGS Manual
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 index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./index.html
./cleanup.bash
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "sole commit" && git push -q -f -u origin master
else
echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT
exit 1
fi
- name: Post address
uses: actions/github-script@v6
if: ${{ success() && steps.get_round.outputs.result != 'stop' }}
uses: actions/github-script@v7
if: ${{ success() }}
with:
script: |
const tmp_round = "${{ steps.get_round.outputs.result }}";
const id = tmp_round.indexOf(":");
const round = tmp_round.substring(0,id);
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 }}/"+round+"/Manual/index.html"
const round = "${{ env.doc_version }}"
const address = "The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/${{ env.pr_number }}/"+round+"/Manual/index.html"
github.rest.issues.createComment({
owner: "CGAL",
repo: "cgal",
@ -154,8 +219,8 @@ jobs:
- name: Post error
env:
ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}}
uses: actions/github-script@v6
if: ${{ failure() && steps.get_round.outputs.result != 'stop' }}
uses: actions/github-script@v7
if: ${{ failure() }}
with:
script: |
const error = process.env.ERRORMSG

View File

@ -7,17 +7,16 @@ permissions:
jobs:
build:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- 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 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/~cgaltest/doxygen_1_8_13_patched/doxygen
sudo mv doxygen_exe /usr/bin/doxygen

View File

@ -7,29 +7,27 @@ permissions:
jobs:
cmake-testsuite:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: sudo apt-get install -y libboost-dev libboost-program-options-dev libmpfr-dev libeigen3-dev
- name: configure all
run: |
set -e
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DBUILD_TESTING=ON ..
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DCGAL_ENABLE_TESTING=ON ..
ctest -L Installation -j $(getconf _NPROCESSORS_ONLN)
cmake-testsuite-with-qt5:
cmake-testsuite-with-qt:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: sudo bash -e .github/install.sh
- name: configure all
run: |
set -e
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DBUILD_TESTING=ON ..
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DCGAL_ENABLE_TESTING=ON ..
ctest -L Installation -j $(getconf _NPROCESSORS_ONLN)

View File

@ -1,27 +1,33 @@
name: Documentation Removal
on:
workflow_dispatch:
inputs:
PR_NUMBER:
description: 'Pull request number for which the documentation should be removed'
type: number
required: true
pull_request_target:
types: [closed, removed, workflow_dispatch]
types: [closed]
permissions:
contents: read
jobs:
build:
delete_doc:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: delete directory
- uses: actions/checkout@v4
- name: delete directory ${{ github.event.inputs.PR_NUMBER || github.event.pull_request.number }}/ in cgal.github.io
env:
PR_NUMBER: ${{ github.event.inputs.PR_NUMBER || github.event.pull_request.number }}
run: |
set -x
git config --global user.email "cgal@geometryfactory.com"
git config --global user.name "cgaltest"
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
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

View File

@ -1,4 +1,4 @@
name: Test Polyhedron Demo
name: Compile CGAL Lab
on: [push, pull_request,workflow_dispatch]
@ -9,7 +9,7 @@ jobs:
batch_1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: .github/install.sh
- name: run1
@ -17,7 +17,7 @@ jobs:
batch_2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: .github/install.sh
- name: run2
@ -25,7 +25,7 @@ jobs:
batch_3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: .github/install.sh
- name: run3
@ -33,7 +33,7 @@ jobs:
batch_4:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install dependencies
run: .github/install.sh
- name: run4

View File

@ -1,75 +0,0 @@
name: Filter Testsuite
on:
issue_comment:
types: [created]
workflow_dispatch:
permissions: {}
jobs:
build:
permissions:
pull-requests: write # to create comment
if: (github.event.comment.user.login == 'sloriot' || github.event.comment.user.login == 'lrineau') && contains(github.event.comment.body, '/testme')
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: get_label
with:
result-encoding: string
script: |
//get branch name and username
const pr_url = context.payload.issue.pull_request.url
const pr_content = await github.request(pr_url)
const label = pr_content.data.head.label
const base = pr_content.data.base.ref
console.log(label)
return label+":"+base
- name: Run Testsuite
run: |
mkdir -p ~/.ssh
#ssh key
(
cat <<EOF
${{ secrets.ssh_key }}
EOF
)>> ~/.ssh/id_rsa
chmod 600 /home/runner/.ssh/id_rsa
#ssh public key
(
cat <<EOF
${{ secrets.ssh_key_pub }}
EOF
)>> ~/.ssh/id_rsa.pub
chmod 644 /home/runner/.ssh/id_rsa.pub
#known hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_known_hosts -O ~/.ssh/known_hosts
#config file
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_config -O ~/.ssh/config
#list of hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_host_list -O ~/ssh_host_list
#ssh command
LABEL="${{ steps.get_label.outputs.result }}"
USER_NAME=$(echo $LABEL | cut -d':' -f 1)
BRANCH_NAME=$(echo $LABEL | cut -d':' -f 2)
BASE=$(echo $LABEL | cut -d':' -f 3)
PR_NUMBER=${{ github.event.issue.number }}
mapfile -t HOSTS < ~/ssh_host_list;
for i in ${!HOSTS[@]}; do
HOST=$(echo ${HOSTS[$i]}|cut -d' ' -f 1 )
PATH_TO_SCRIPT=$(echo ${HOSTS[$i]}|cut -d' ' -f 2 )
echo "ssh ${HOST} ${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER"
ssh ${HOST} "${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER"
done
- name: Post address
uses: actions/github-script@v6
with:
script: |
const address = "Testsuite launched. Results will appear on the following page: https://cgal.geometryfactory.com/~cgaltest/test_suite/TESTRESULTS/index.shtml "
github.issues.createComment({
owner: "CGAL",
repo: "cgal",
issue_number: ${{ github.event.issue.number }},
body: address
});

View File

@ -12,7 +12,7 @@
messages: ${{ steps.cat_output.outputs.message }}
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: run script
run: |
chmod +x ./Scripts/developer_scripts/list_cgal_workflows_last_run.sh

36
.github/workflows/reuse.yml vendored Normal file
View File

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2020 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later
name: REUSE Compliance Check
on: [push, pull_request]
jobs:
reuse:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Display reuse-tool version
uses: fsfe/reuse-action@v5
with:
args: --version
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v5
with:
args: --include-submodules lint
- name: REUSE SPDX SBOM
uses: fsfe/reuse-action@v5
with:
args: spdx
- name: install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake
- name: Create CGAL internal release
run: |
mkdir -p ./release
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
- name: REUSE Compliance Check of release tarball
uses: fsfe/reuse-action@v5
with:
args: --root ./release/CGAL-9.9 --include-submodules lint

View File

@ -9,7 +9,7 @@ jobs:
messages: ${{ steps.set-result.outputs.result }}
steps:
- name: get informations and prepare email
uses: actions/github-script@v6
uses: actions/github-script@v7
id: set-result
with:
result-encoding: string

10
.gitignore vendored
View File

@ -178,12 +178,6 @@ GraphicsView/demo/Triangulation_2/Makefile
GraphicsView/demo/Triangulation_2/Regular_triangulation_2
GraphicsView/demo/Triangulation_2/qrc_*.cxx
GraphicsView/demo/Triangulation_2/ui_*.h
GraphicsView/src/CGAL_Qt5/*.dll
GraphicsView/src/CGAL_Qt5/*.lib
GraphicsView/src/CGAL_Qt5/*.so
GraphicsView/src/CGAL_Qt5/Makefile
GraphicsView/src/CGAL_Qt5/moc_*.cxx
GraphicsView/src/CGAL_Qt5/qrc_*.cxx
HalfedgeDS/test/HalfedgeDS/cgal_test_with_cmake
HalfedgeDS/test/HalfedgeDS/test_hds
HalfedgeDS/test/HalfedgeDS/test_hds_decorator
@ -879,7 +873,6 @@ Surface_mesher/demo/Surface_mesher/.*.deps
Surface_mesher/demo/Surface_mesher/.qglviewer.xml
Surface_mesher/demo/Surface_mesher/Makefile
Surface_mesher/demo/Surface_mesher/Surface_mesher
Surface_mesher/demo/Surface_mesher/Surface_mesher_Qt5_Demo
Surface_mesher/demo/Surface_mesher/VTK/Makefile
Surface_mesher/demo/Surface_mesher/VTK/mesh_a_3D_image
Surface_mesher/demo/Surface_mesher/VTK/mesh_a_VTK_3D_image
@ -894,7 +887,6 @@ Surface_mesher/demo/Surface_mesher/out*.off
Surface_mesher/demo/Surface_mesher/polyhedron_remesher
Surface_mesher/demo/Surface_mesher/polyhedron_remesher_with_edges
Surface_mesher/demo/Surface_mesher/qrc_*.c*
Surface_mesher/demo/Surface_mesher/qt5-demo
Surface_mesher/demo/Surface_mesher/ui_*.h
Surface_mesher/doxygen
Surface_mesher/examples/Surface_mesher/.*.deps
@ -1066,7 +1058,7 @@ cmake_install.cmake
*~
.#*
# MacOS file https://en.wikipedia.org/wiki/.DS_Store
# macOS file https://en.wikipedia.org/wiki/.DS_Store
.DS_Store
# Binaries:

7
.markdownlint.json Normal file
View File

@ -0,0 +1,7 @@
{
"default": true,
"line-length": false,
"no-duplicate-heading": {
"siblings_only": true
}
}

View File

@ -1,7 +1,7 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.23)
cmake_minimum_required(VERSION 3.12...3.29)
project(AABB_traits_benchmark)
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core)

View File

@ -1,4 +1,4 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/intersection.h>
@ -6,8 +6,8 @@
#include <CGAL/boost/graph/copy_face_graph.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polygon_mesh_processing/internal/AABB_do_intersect_transform_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Rigid_triangle_mesh_collision_detection.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Side_of_triangle_mesh.h>
@ -18,12 +18,12 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Surface_mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Surface_mesh> Primitive;
typedef CGAL::AABB_do_intersect_transform_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
namespace PMP = CGAL::Polygon_mesh_processing;
void naive_test(int k, const char* fname,
void naive_test(int k, const std::string& fname,
int& nb_inter, int& nb_no_inter, int& nb_include)
{
std::ifstream input(fname);
@ -33,7 +33,7 @@ void naive_test(int k, const char* fname,
CGAL::Aff_transformation_3<K> init1(CGAL::SCALING, 6.0);
PMP::transform(init1, tm);
CGAL::Bbox_3 box = PMP::bbox(tm);
typedef CGAL::AABB_tree<CGAL::AABB_traits<K, Primitive> > Tree;
Tree tmTree(tm.faces_begin(), tm.faces_end(), tm);
Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2);
CGAL::Aff_transformation_3<K> init2(CGAL::TRANSLATION, - K::Vector_3(
@ -86,7 +86,8 @@ void naive_test(int k, const char* fname,
T0 = CGAL::Aff_transformation_3<K>(CGAL::TRANSLATION, -i*unit_vec);
}
}
void test_no_collision(int k, const char* fname,
void test_no_collision(int k, const std::string &fname,
int& nb_inter, int& nb_no_inter, int& nb_include)
{
std::ifstream input(fname);
@ -97,9 +98,11 @@ void test_no_collision(int k, const char* fname,
PMP::transform(init1, tm);
CGAL::Bbox_3 box = PMP::bbox(tm);
Tree tmTree(tm.faces_begin(), tm.faces_end(), tm);
Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2);
CGAL::Aff_transformation_3<K> init2(CGAL::TRANSLATION, - K::Vector_3(
(box.xmax()-box.xmin()),0,0));
PMP::transform(init2, tm2);
tmTree.build();
@ -113,6 +116,12 @@ void test_no_collision(int k, const char* fname,
CGAL::Side_of_triangle_mesh<Surface_mesh, K,
VPM, Tree> sotm1(tmTree);
CGAL::Rigid_triangle_mesh_collision_detection<Surface_mesh> collision_detection;
collision_detection.add_mesh(tm);
collision_detection.add_mesh(tm2);
for(int i=1; i<k+1; ++i)
{
K::FT rot[9];
@ -130,34 +139,24 @@ void test_no_collision(int k, const char* fname,
rot[6], rot[7], rot[8]);
CGAL::Aff_transformation_3<K> T1 = CGAL::Aff_transformation_3<K>(CGAL::TRANSLATION, i*unit_vec);
CGAL::Aff_transformation_3<K> transfo = R*T1;
tmTree2.traits().set_transformation(transfo);
CGAL::Interval_nt_advanced::Protector protector;
if(tmTree2.do_intersect(tmTree))
collision_detection.set_transformation(1, transfo);
std::vector< std::pair<std::size_t, bool> > res = collision_detection.get_all_intersections_and_inclusions(0);
if (res.empty())
nb_no_inter++;
else if(!res[0].second)
++nb_inter;
else
{
if(sotm1(transfo.transform(vpm2[*tm2.vertices().begin()])) != CGAL::ON_UNBOUNDED_SIDE)
{
++nb_include;
}
else
{
CGAL::Side_of_triangle_mesh<Surface_mesh, K,
VPM, Tree> sotm2(tmTree2);
if(sotm2(tm.point(*tm.vertices().begin())) != CGAL::ON_UNBOUNDED_SIDE)
++nb_include;
else
++nb_no_inter;
}
}
++nb_include;
}
}
int main(int argc, const char** argv)
{
int k = (argc>1) ? atoi(argv[1]) : 10;
const char* path = (argc>2)?argv[2]:"data/handle"
".off";
int k = (argc>1) ? atoi(argv[1]) : 20;
std::string path = (argc>2)?argv[2]: CGAL::data_file_path("meshes/handle.off");
std::cout<< k<<" steps in "<<path<<std::endl;
int nb_inter(0), nb_no_inter(0), nb_include(0),
@ -165,12 +164,12 @@ int main(int argc, const char** argv)
auto start = std::chrono::steady_clock::now();
naive_test(k, path, naive_inter, naive_no_inter, naive_include);
auto end = std::chrono::steady_clock::now();
std::cout<<"Naive test :"<<naive_inter<<" collisions, "<<naive_include<<" inclusions, "<<naive_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << "μs." << std::endl;
std::cout<<"Naive test : "<<naive_inter<<" collisions, "<<naive_include<<" inclusions, "<<naive_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms." << std::endl;
start = std::chrono::steady_clock::now();
test_no_collision(k, path,nb_inter, nb_no_inter, nb_include);
end = std::chrono::steady_clock::now();
std::cout<<"With transform_traits: "<<nb_inter<<" collisions, "<<nb_include<<" inclusions, "<<nb_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << "μs." << std::endl;
<<std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms." << std::endl;
return 0;
}

View File

@ -30,7 +30,7 @@ int main(int argc, char **argv)
app.setOrganizationName("INRIA");
app.setApplicationName("AABB tree demo");
// Import resources from libCGALQt (Qt5).
// Import resources from libCGALQt (Qt6).
CGAL_QT_INIT_RESOURCES;
MainWindow mainWindow;
@ -49,12 +49,3 @@ int main(int argc, char **argv)
return app.exec();
}
# include "Scene.cpp"
# include "Scene_moc.cpp"
# include "benchmarks.cpp"
# include "Viewer.cpp"
# include "Viewer_moc.cpp"
# include "MainWindow.cpp"
# include "MainWindow_moc.cpp"

View File

@ -1,78 +1,51 @@
# This is the CMake script for compiling the AABB tree demo.
cmake_minimum_required(VERSION 3.1...3.23)
cmake_minimum_required(VERSION 3.12...3.29)
project(AABB_tree_Demo)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
if(NOT POLICY CMP0070 AND POLICY CMP0053)
# Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
cmake_policy(SET CMP0053 OLD)
endif()
# Find CGAL and CGAL Qt6
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt6)
if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()
# Find Qt6 itself
find_package(Qt6 QUIET COMPONENTS Gui OpenGL)
# Include this package's headers first
include_directories(BEFORE ./ ./include)
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
# Find CGAL and CGAL Qt5
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
add_compile_definitions(QT_NO_KEYWORDS)
# Find Qt5 itself
find_package(Qt5 QUIET COMPONENTS Widgets OpenGL)
# Instruct CMake to run moc/ui/rcc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
qt5_wrap_ui(UI_FILES MainWindow.ui)
include(AddFileDependencies)
qt5_generate_moc("MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp")
add_file_dependencies(MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h")
qt5_generate_moc("Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp")
add_file_dependencies(Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h")
qt5_generate_moc("Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp")
add_file_dependencies(Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h")
qt5_add_resources(CGAL_Qt5_RESOURCE_FILES AABB_demo.qrc)
add_file_dependencies(
AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp")
add_executable(
AABB_demo AABB_demo.cpp ${UI_FILES} ${CGAL_Qt5_RESOURCE_FILES}
#${CGAL_Qt5_MOC_FILES}
qt_add_executable(
AABB_demo AABB_demo.cpp Scene.cpp benchmarks.cpp Viewer.cpp MainWindow.cpp
MainWindow.ui AABB_demo.qrc
)
# Link with Qt libraries
target_link_libraries(AABB_demo PRIVATE Qt5::Widgets Qt5::OpenGL
CGAL::CGAL CGAL::CGAL_Qt5)
target_link_libraries(AABB_demo PRIVATE Qt6::Gui Qt6::OpenGL
CGAL::CGAL CGAL::CGAL_Qt6)
add_to_cached_list(CGAL_EXECUTABLE_TARGETS AABB_demo)
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(AABB_demo)
else(CGAL_Qt5_FOUND AND Qt5_FOUND)
else(CGAL_Qt6_FOUND AND Qt6_FOUND)
set(AABB_MISSING_DEPS "")
if(NOT CGAL_Qt5_FOUND)
set(AABB_MISSING_DEPS "CGAL_Qt5, ${AABB_MISSING_DEPS}")
if(NOT CGAL_Qt6_FOUND)
set(AABB_MISSING_DEPS "CGAL_Qt6, ${AABB_MISSING_DEPS}")
endif()
if(NOT Qt5_FOUND)
set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}")
if(NOT Qt6_FOUND)
set(AABB_MISSING_DEPS "Qt6, ${AABB_MISSING_DEPS}")
endif()
message("NOTICE: This demo requires ${AABB_MISSING_DEPS}, and will not be compiled.")
endif(CGAL_Qt5_FOUND AND Qt5_FOUND)
endif(CGAL_Qt6_FOUND AND Qt6_FOUND)

View File

@ -10,15 +10,19 @@
#include <QSettings>
#include <QHeaderView>
#include <QClipboard>
#include <QInputDialog>
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget* parent)
: CGAL::Qt::DemosMainWindow(parent)
: CGAL::Qt::DemosMainWindow(parent)
{
ui = new Ui::MainWindow;
ui->setupUi(this);
this->addAboutDemo(":/cgal/AABB_demo/about.html");
this->addAboutCGAL();
// saves some pointers from ui, for latter use.
m_pViewer = ui->viewer;
@ -418,7 +422,3 @@ void MainWindow::on_actionCopy_snapshot_triggered()
qb->setImage(snapshot);
QApplication::restoreOverrideCursor();
}

View File

@ -1,7 +1,6 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtOpenGL/qgl.h>
#include <CGAL/Qt/DemosMainWindow.h>
class QDragEnterEvent;
@ -12,7 +11,6 @@ namespace Ui {
class MainWindow;
}
class MainWindow :
public CGAL::Qt::DemosMainWindow
{
@ -21,12 +19,12 @@ public:
MainWindow(QWidget* parent = nullptr);
~MainWindow();
public slots:
public Q_SLOTS:
void updateViewerBBox();
void open(QString filename);
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);
protected slots:
protected Q_SLOTS:
// settings
void quit();

View File

@ -618,7 +618,7 @@ void Scene::draw(CGAL::QGLViewer* viewer)
vao[0].bind();
attrib_buffers(viewer);
rendering_program.bind();
color.setRgbF(0.7,0.0,0.0);
color.setRgbF(0.7f,0.0f,0.0f);
rendering_program.setUniformValue(colorLocation, color);
rendering_program.setUniformValue(fLocation, fMatrix);
gl->glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
@ -631,7 +631,7 @@ void Scene::draw(CGAL::QGLViewer* viewer)
vao[1].bind();
attrib_buffers(viewer);
rendering_program.bind();
color.setRgbF(0.0,0.7,0.0);
color.setRgbF(0.0f,0.7f,0.0f);
rendering_program.setUniformValue(colorLocation, color);
rendering_program.setUniformValue(fLocation, fMatrix);
gl->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
@ -669,7 +669,7 @@ void Scene::draw(CGAL::QGLViewer* viewer)
vao[3].bind();
attrib_buffers(viewer);
rendering_program.bind();
color.setRgbF(1.0,0.0,0.0);
color.setRgbF(1.0f,0.0f,0.0f);
rendering_program.setUniformValue(colorLocation, color);
rendering_program.setUniformValue(fLocation, fMatrix);
gl->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_cut_segments.size()/3));
@ -867,7 +867,7 @@ void Scene::generate_points_in(const unsigned int nb_points,
}
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
std::cout << "Construct AABB tree...";
@ -920,7 +920,7 @@ void Scene::generate_inside_points(const unsigned int nb_points)
}
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
std::cout << "Construct AABB tree...";
@ -962,7 +962,7 @@ void Scene::generate_boundary_segments(const unsigned int nb_slices)
}
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
@ -1012,7 +1012,7 @@ void Scene::generate_boundary_points(const unsigned int nb_points)
}
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
@ -1062,7 +1062,7 @@ void Scene::generate_edge_points(const unsigned int nb_points)
}
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;

View File

@ -1,7 +1,6 @@
#ifndef SCENE_H
#define SCENE_H
#include <QtOpenGL/qgl.h>
#include <iostream>
#include <cmath>
@ -10,7 +9,7 @@
#include "Color_ramp.h"
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -63,11 +62,11 @@ public:
private:
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Facet_Primitive;
typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits;
typedef CGAL::AABB_traits_3<Kernel, Facet_Primitive> Facet_Traits;
typedef CGAL::AABB_tree<Facet_Traits> Facet_tree;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Edge_Primitive;
typedef CGAL::AABB_traits<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_traits_3<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_tree<Edge_Traits> Edge_tree;
typedef CGAL::qglviewer::ManipulatedFrame ManipulatedFrame;
@ -77,7 +76,6 @@ private:
};
public:
QGLContext* context;
void draw(CGAL::QGLViewer*);
void update_bbox();
Bbox bbox() { return m_bbox; }
@ -173,7 +171,7 @@ private:
void attrib_buffers(CGAL::QGLViewer*);
void compile_shaders();
void compute_texture(int, int, Color_ramp, Color_ramp);
private slots:
private Q_SLOTS:
void updateCutPlane();
public:
@ -255,7 +253,7 @@ public:
public slots:
public Q_SLOTS:
// cutting plane
void cutting_plane(bool override = false);
void changed();

View File

@ -1,9 +1,6 @@
#include "Viewer.h"
#include "Scene.h"
#include <QMouseEvent>
#include <QGLFunctions>
#include <CGAL/Qt/CreateOpenGLContext.h>
Viewer::Viewer(QWidget* parent)
: CGAL::QGLViewer(parent),
m_pScene(nullptr),

View File

@ -1,4 +1,5 @@
#include "Scene.h"
#include "Refiner.h"
#include <QInputDialog>
#include <CGAL/Memory_sizer.h>

View File

@ -0,0 +1,177 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBGeomTraits_2` defines the requirements for the first template parameter of the class
`CGAL::AABB_traits_2<AABBGeomTraits_2, AABBPrimitive>`. It provides predicates and constructors to detect
and compute intersections between query objects and the primitives stored in the AABB tree.
In addition, it contains predicates and constructors to compute distances between a point query
and the primitives stored in the AABB tree.
\cgalRefines{SearchGeomTraits_2}
\cgalHasModelsBegin
\cgalHasModelsBare{All models of the concept `Kernel`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBGeomTraits_2 {
public:
/// \name Types
/// @{
/*!
A functor object to detect intersections between two geometric objects.
Provides the following operators:
`bool operator()(const Query& q, const Bbox_2& b)`,
`bool operator()(const Query& q, const Primitive::Datum& d)`,
`bool operator()(const Circle_2& c, const Bbox_2& b)`.
The operator returns `true` iff there is an intersection.
*/
typedef unspecified_type Do_intersect_2;
/*!
A functor object to construct the intersection between two geometric objects.
Provides the operator:
`return_type operator()(const Query& q, const Primitive::Datum& d)`,
which computes the intersection between `q` and `d`. The type of the returned object
must be a `std::optional` of a `std::variant` of the possible intersection types.
*/
typedef unspecified_type Intersect_2;
/*!
A functor object to construct the circle specified by its center and squared radius.
Provides the operator:
`Circle_2 operator()(const Point_2& p, const FT & sr)`,
which returns the circle centered at `p` with `sr` as squared radius.
*/
typedef unspecified_type Construct_circle_2;
/*!
A functor object to compute the point on a geometric primitive which is closest from a query point.
Provides the operator:
`Point_2 operator()(const Primitive::Datum& d, const Point_2& p)`,
which returns the point on `d` that is closest to `p`.
*/
typedef unspecified_type Construct_projected_point_2;
/*!
A functor object to compare the distance of two points wrt a third one. Provides the operator:
`CGAL::Comparison_result operator()(const Point_2& p1, const Point_2& p2, const Point_2& p3)`,
which compares the distance between `p1` and `p2`, to the distance between `p1` and `p3`.
*/
typedef unspecified_type Compare_distance_2;
/*!
A functor object to compute the squared distance between two points. Provides the operator:
`FT operator()(const Point_2& p, const Point_2& q),`
which returns the squared distance between `p` and `q`.
*/
typedef unspecified_type Compute_squared_distance_2;
/*!
A functor object to compare the x-coordinates of two points. Provides the operator:
`bool operator()(const Point_2& p, const Point_2& q)`,
which returns `true` iff the x-coordinate of `p` is smaller than the x-coordinate of `q`.
*/
typedef unspecified_type Less_x_2;
/*!
A functor object to compare the y-coordinates of two points. Provides the operator:
`bool operator()(const Point_2& p, const Point_2& q)`,
which returns `true` iff the y-coordinate of `p` is smaller than the y-coordinate of `q`.
*/
typedef unspecified_type Less_y_2;
/*!
A functor object to compare two points. Provides the operator:
`bool operator()(const Point_2& p, const Point_2& q)`,
which returns `true` iff `p` is equal to `q`.
*/
typedef unspecified_type Equal_2;
/// @}
/// \name Operations
/// @{
/*!
returns the intersection detection predicate.
*/
Do_intersect_2 do_intersect_2_object();
/*!
returns the intersection constructor.
*/
Intersect_2 intersect_2_object();
/*!
returns the circle constructor.
*/
Construct_circle_2 construct_circle_2_object();
/*!
returns the closest point constructor.
*/
Construct_projected_point_2 construct_projected_point_2_object();
/*!
returns the compare distance predicate.
*/
Compare_distance_2 compare_distance_2_object();
/*!
returns the squared distance functor.
*/
Compute_squared_distance_2 compute_squared_distance_2_object();
/*!
returns the `Less_x_2` predicate.
*/
Less_x_2 less_x_2_object();
/*!
returns the `Less_y_2` predicate.
*/
Less_y_2 less_y_2_object();
/*!
returns the equal predicate.
*/
Equal_2 equal_2_object();
/// @}
}; /* end AABBGeomTraits_2 */

View File

@ -3,23 +3,25 @@
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBGeomTraits` defines the requirements for the first template parameter of the class
`CGAL::AABB_traits<AABBGeomTraits, AABBPrimitive>`. It provides predicates and constructors to detect
The concept `AABBGeomTraits_3` defines the requirements for the first template parameter of the class
`CGAL::AABB_traits_3<AABBGeomTraits_3, AABBPrimitive>`. It provides predicates and constructors to detect
and compute intersections between query objects and the primitives stored in the AABB tree.
In addition, it contains predicates and constructors to compute distances between a point query
and the primitives stored in the AABB tree.
\cgalRefines{SearchGeomTraits_3}
\cgalHasModel All models of the concept `Kernel`
\cgalHasModelsBegin
\cgalHasModelsBare{All models of the concept `Kernel`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBGeomTraits {
class AABBGeomTraits_3 {
public:
/// \name Types
@ -29,13 +31,13 @@ public:
A functor object to detect intersections between two geometric objects.
Provides the following operators:
`bool operator()(Query, Bbox_3)`,
`bool operator()(const Query& q, const Bbox_3& b)`,
`bool operator()(Query, Primitive::Datum)`,
`bool operator()(const Query& q, const Primitive::Datum& d)`,
`bool operator()(Sphere_3, Bbox_3)`.
`bool operator()(const Sphere_3& s, const Bbox_3& b)`.
The operator returns `true` iff there exists a non-empty intersection.
The operator returns `true` iff there is an intersection.
*/
typedef unspecified_type Do_intersect_3;
@ -47,12 +49,12 @@ Provides the operator:
`return_type operator()(const Query& q, const Primitive::Datum& d)`,
which computes the intersection between `q` and `d`. The type of the returned object
must be a `boost::optional` of a `boost::variant` of the possible intersection types.
must be a `std::optional` of a `std::variant` of the possible intersection types.
*/
typedef unspecified_type Intersect_3;
/*!
A functor object to construct the sphere centered at one point and passing through another one.
A functor object to construct the sphere specified by its center and squared radius.
Provides the operator:
`Sphere_3 operator()(const Point_3& p, const FT & sr)`,
@ -62,7 +64,7 @@ which returns the sphere centered at `p` with `sr` as squared radius.
typedef unspecified_type Construct_sphere_3;
/*!
A functor object to compute the point on a geometric primitive which is closest from a query.
A functor object to compute the point on a geometric primitive which is closest from a query point.
Provides the operator:
`Point_3 operator()(const Primitive::Datum& d, const Point_3& p)`,
@ -76,19 +78,10 @@ A functor object to compare the distance of two points wrt a third one. Provides
`CGAL::Comparison_result operator()(const Point_3& p1, const Point_3& p2, const Point_3& p3)`,
which compares the distance between `p1` and `p2`, and between `p2` and `p3`.
which compares the distance between `p1` and `p2`, to the distance between `p1` and `p3`.
*/
typedef unspecified_type Compare_distance_3;
/*!
A functor object to compute the squared radius of a sphere.
Provides the operator:
`FT operator()(const Sphere_3& s),`
which returns the squared radius of `s`.
*/
typedef unspecified_type Compute_squared_radius_3;
/*!
A functor object to compute the squared distance between two points. Provides the operator:
@ -165,10 +158,6 @@ returns the compare distance predicate.
*/
Compare_distance_3 compare_distance_3_object();
/*!
returns the squared radius functor.
*/
Compute_squared_radius_3 compute_squared_radius_3_object();
/*!
returns the squared distance functor.
@ -197,5 +186,4 @@ Equal_3 equal_3_object();
/// @}
}; /* end AABBGeomTraits */
}; /* end AABBGeomTraits_3 */

View File

@ -12,11 +12,15 @@ The concept `AABBPrimitive` describes the requirements for the primitives stored
The `Primitive` type can be, e.g., a wrapper around a `Handle`. Assume for instance that the input objects are the triangle faces of a mesh stored as a `CGAL::Polyhedron_3`. The `Datum` would be a `Triangle_3` and the `Id` would be a polyhedron `Face_handle`. Method `datum()` can return either a `Triangle_3` constructed on the fly from the face handle or a `Triangle_3` stored internally. This provides a way for the user to trade memory for efficiency.
\cgalHasModel `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,Tag_false,CacheDatum>`
\cgalHasModel `CGAL::AABB_segment_primitive<Iterator,CacheDatum>`
\cgalHasModel `CGAL::AABB_triangle_primitive<Iterator,CacheDatum>`
\cgalHasModel `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,Tag_false,CacheDatum>`
\cgalHasModel `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,Tag_false,CacheDatum>`
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,Tag_false,CacheDatum>}
\cgalHasModels{CGAL::AABB_segment_primitive_2<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_segment_primitive_3<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_triangle_primitive_2<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_triangle_primitive_3<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,Tag_false,CacheDatum>}
\cgalHasModels{CGAL::AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,Tag_false,CacheDatum>}
\cgalHasModelsEnd
*/
class AABBPrimitive {
@ -26,7 +30,7 @@ public:
/// @{
/*!
3D point type.
Point type.
*/
typedef unspecified_type Point;
@ -66,7 +70,7 @@ returns the corresponding identifier. This identifier is only used as a referenc
Id id();
/*!
returns a 3D point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries.
returns a point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries.
*/
Point_reference reference_point();

View File

@ -21,9 +21,11 @@ The `Datum` would be a `Triangle_3` and the `Id` a `std::size_t`. The shared dat
`std::vector<Triangle_3>`.
The method `datum(const Shared_data&)` then returns a triangle from the vector.
\cgalHasModel `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,Tag_true,CacheDatum>`
\cgalHasModel `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,Tag_true,CacheDatum>`
\cgalHasModel `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,Tag_true,CacheDatum>`
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,Tag_true,CacheDatum>}
\cgalHasModels{CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,Tag_true,CacheDatum>}
\cgalHasModels{CGAL::AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,Tag_true,CacheDatum>}
\cgalHasModelsEnd
*/
class AABBPrimitiveWithSharedData {
@ -32,7 +34,7 @@ public:
/// \name Types
/// @{
/*!
3D point type.
Point type.
*/
typedef unspecified_type Point;
@ -76,7 +78,7 @@ returns the corresponding identifier. This identifier is only used as a referenc
Id id();
/*!
returns a 3D point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries.
returns a point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries.
*/
Point_reference reference_point(const Shared_data& data);

View File

@ -1,64 +0,0 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBRayIntersectionGeomTraits` is a refinement of the
concept `AABBGeomTraits`. In addition to the types required by
`AABBGeomTraits` it also requires types and functors necessary to
define the Intersection_distance functor.
\cgalRefines{AABBGeomTraits}
\cgalHasModel All models of the concept `Kernel`
\sa `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBRayIntersectionGeomTraits {
public:
/*!
Type of a 3D ray.
*/
typedef unspecified_type Ray_3;
/*!
Type of a 3D vector.
*/
typedef unspecified_type Vector_3;
/*!
A functor object to construct the source point of a ray. Provides the operator:
`Point_3 operator()(const Ray_3&);`
*/
typedef unspecified_type Construct_source_3;
/*!
*/
Construct_source_3 construct_source_3_object();
/*!
A model of `CartesianConstIterator3`.
*/
typedef unspecified_type Cartesian_const_iterator_3;
/*!
A model of `ConstructCartesianConstIterator3`.
*/
typedef unspecified_type Construct_cartesian_const_iterator_3;
/*!
*/
Construct_source_3 construct_cartesian_const_iterator_3_object();
/*!
A functor object to construct a vector giving the direction of a ray. Provides the operator:
`Vector_3 operator()(const Ray_3&);`
*/
typedef unspecified_type Construct_vector_3;
/*!
*/
Construct_source_3 construct_vector_3_object();
};

View File

@ -0,0 +1,69 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBRayIntersectionGeomTraits_2` is a refinement of the
concept `AABBGeomTraits_2`. In addition to the types and functors required by
`AABBGeomTraits_2` it also requires types and functors necessary to
define the Intersection_distance functor (see `AABBRayIntersectionTraits`).
\cgalRefines{AABBGeomTraits_2}
\cgalHasModelsBegin
\cgalHasModelsBare{All models of the concept `Kernel`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBRayIntersectionGeomTraits_2 {
public:
/*!
Type of a 2D ray.
*/
typedef unspecified_type Ray_2;
/*!
Type of a 2D vector.
*/
typedef unspecified_type Vector_2;
/*!
A functor object to construct the source point of a ray. Provides the operator:
`Point_2 operator()(const Ray_2&);`
*/
typedef unspecified_type Construct_source_2;
/*!
returns the `Construct_source_2` functor.
*/
Construct_source_2 construct_source_2_object();
/*!
A model of `CartesianConstIterator_2`.
*/
typedef unspecified_type Cartesian_const_iterator_2;
/*!
A model of `ConstructCartesianConstIterator_2`.
*/
typedef unspecified_type Construct_cartesian_const_iterator_2;
/*!
returns the `Construct_cartesian_const_iterator_2` functor.
*/
Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2_object();
/*!
A functor object to construct a vector having the same direction as a ray. Provides the operator:
`Vector_2 operator()(const Ray_2&);`
*/
typedef unspecified_type Construct_vector_2;
/*!
returns the `Construct_vector_2` functor.
*/
Construct_vector_2 construct_vector_2_object();
};

View File

@ -0,0 +1,69 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the
concept `AABBGeomTraits_3`. In addition to the types required by
`AABBGeomTraits_3` it also requires types and functors necessary to
define the Intersection_distance functor.
\cgalRefines{AABBGeomTraits_3}
\cgalHasModelsBegin
\cgalHasModelsBare{All models of the concept `Kernel`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBRayIntersectionGeomTraits_3 {
public:
/*!
Type of a 3D ray.
*/
typedef unspecified_type Ray_3;
/*!
Type of a 3D vector.
*/
typedef unspecified_type Vector_3;
/*!
A functor object to construct the source point of a ray. Provides the operator:
`Point_3 operator()(const Ray_3&);`
*/
typedef unspecified_type Construct_source_3;
/*!
returns the `Construct_source_3` functor.
*/
Construct_source_3 construct_source_3_object();
/*!
A model of `CartesianConstIterator_3`.
*/
typedef unspecified_type Cartesian_const_iterator_3;
/*!
A model of `ConstructCartesianConstIterator_3`.
*/
typedef unspecified_type Construct_cartesian_const_iterator_3;
/*!
returns the `Construct_cartesian_const_iterator_3` functor.
*/
Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3_object();
/*!
A functor object to construct a vector having the same direction as a ray. Provides the operator:
`Vector_3 operator()(const Ray_3&);`
*/
typedef unspecified_type Construct_vector_3;
/*!
returns the `Construct_vector_3` functor.
*/
Construct_vector_3 construct_vector_3_object();
};

View File

@ -7,7 +7,12 @@ The concept `AABBRayIntersectionTraits` is a refinement of the concept
`AABBTraits` it also requires function objects to calculate the
distance of an intersection along a ray.
\cgalHasModel `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\cgalRefines{AABBTraits}
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>}
\cgalHasModelsEnd
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
@ -15,26 +20,72 @@ distance of an intersection along a ray.
*/
class AABBRayIntersectionTraits {
public:
/*!
Type of a ray.
*/
typedef unspecified_type Ray;
/*!
Type of a 3D ray.
Type of a vector.
*/
typedef unspecified_type Ray_3;
typedef unspecified_type Vector;
/*!
Type of bounding box.
*/
typedef AABBTraits::Bounding_box Bounding_box;
/*!
A functor object to construct the source point of a ray. Provides the operator:
`Point operator()(const Ray&);`
*/
typedef unspecified_type Construct_source;
/*!
returns the `Construct_source` functor.
*/
Construct_source construct_source_object();
/*!
A model of `CartesianConstIterator_2` or `CartesianConstIterator_3`, depending on the dimension of `Vector`.
*/
typedef unspecified_type Cartesian_const_iterator;
/*!
A model of `ConstructCartesianConstIterator_2` or `ConstructCartesianConstIterator_3`, depending on the dimension of `Vector`.
*/
typedef unspecified_type Construct_cartesian_const_iterator;
/*!
returns the `Construct_cartesian_const_iterator` functor.
*/
Construct_cartesian_const_iterator construct_cartesian_const_iterator_object();
/*!
A functor object to construct a vector having the same direction as a ray. Provides the operator:
`Vector operator()(const Ray&);`
*/
typedef unspecified_type Construct_vector;
/*!
returns the `Construct_vector` functor.
*/
Construct_vector construct_vector_object();
/*!
A functor object to compute the distance between the source of a ray and its
closest intersection point between the ray and a primitive or a bounding box.
An empty `boost::optional` is returned, if there is no intersection.
An empty `std::optional` is returned, if there is no intersection.
When there is an intersection, an object of type `FT` is returned such that
if `i1` and `i2` are two intersection points, then `i1` is closer to the source
of the ray than `i2` iff `n1 < n2`, `n1` and `n2` being the numbers returned for `i1` and `i2`
respectively.
Provides the operators:
`boost::optional<FT> operator()(const Ray_3& r, const Bounding_box& bbox)`.
`boost::optional<std::pair<FT, Intersection_and_primitive_id<Ray_3>::%Type > >
operator()(const Ray_3& r, const Primitive& primitive)`.
`std::optional<FT> operator()(const Ray& r, const Bounding_box& bbox)`.
`std::optional<std::pair<FT, Intersection_and_primitive_id<Ray>::%Type > >
operator()(const Ray& r, const Primitive& primitive)`.
A common algorithm to compute the intersection between a bounding box and a ray is <A
HREF="https://education.siggraph.org/static/HyperGraph/raytrace/rtinter3.htm">the

View File

@ -5,11 +5,13 @@
The concept `AABBTraits` provides the geometric primitive types and methods for the class `CGAL::AABB_tree<AABBTraits>`.
\cgalHasModel `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>}
\cgalHasModelsEnd
\cgalRefines{SearchGeomTraits_3}
\cgalRefines{SearchTraits}
\sa `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
@ -26,9 +28,9 @@ Value type of the `Squared_distance` functor.
typedef unspecified_type FT;
/*!
Type of a 3D point.
Type of a point.
*/
typedef unspecified_type Point_3;
typedef unspecified_type Point;
/*!
Type of primitive.
@ -41,19 +43,10 @@ Bounding box type.
*/
typedef unspecified_type Bounding_box;
/*!
enum required for axis selection
*/
enum Axis {
CGAL_X_AXIS,
CGAL_Y_AXIS,
CGAL_Z_AXIS
};
/*!
3D Point and Primitive Id type
Point and Primitive Id type
*/
typedef std::pair<Point_3, Primitive::Id> Point_and_primitive_id;
typedef std::pair<Point, Primitive::Id> Point_and_primitive_id;
/*!
\deprecated
@ -119,10 +112,10 @@ typedef unspecified_type Do_intersect;
/*!
A functor object to compute the intersection of a query and a primitive. Provides the operator:
`boost::optional<Intersection_and_primitive_id<Query>::%Type > operator()(const Query & q, const Primitive& primitive);` which returns the intersection as a pair composed of an object and a primitive id, iff the query intersects the primitive.
`std::optional<Intersection_and_primitive_id<Query>::%Type > operator()(const Query & q, const Primitive& primitive);` which returns the intersection as a pair composed of an object and a primitive id, iff the query intersects the primitive.
\cgalHeading{Note on Backward Compatibility}
Before the release 4.3 of \cgal, the return type of this function used to be `boost::optional<Object_and_primitive_id>`.
Before the release 4.3 of \cgal, the return type of this function used to be `std::optional<Object_and_primitive_id>`.
*/
typedef unspecified_type Intersection;
@ -142,22 +135,22 @@ A functor object to compute distance comparisons between the query and the nodes
typedef unspecified_type Compare_distance;
/*!
A functor object to compute closest point from the query on a primitive. Provides the operator:
`Point_3 operator()(const Query& query, const Primitive& primitive, const Point_3 & closest);` which returns the closest point to `query`, among `closest` and all points of the primitive.
A functor object to compute the closest point from the query on a primitive. Provides the operator:
`Point operator()(const Query& query, const Primitive& primitive, const Point & closest);` which returns the closest point to `query`, among `closest` and all points of the primitive.
*/
typedef unspecified_type Closest_point;
/*!
A functor object to compute the squared distance between two points. Provides the operator:
`FT operator()(const Point& query, const Point_3 & p);` which returns the squared distance between `p` and `q`.
`FT operator()(const Point& query, const Point & p);` which returns the squared distance between `p` and `q`.
*/
typedef unspecified_type Squared_distance;
/*!
A functor object to compare two points. Provides the operator:
`bool operator()(const Point_3& p, const Point_3& q);}` which returns `true` if `p` is equal to `q`.
`bool operator()(const Point& p, const Point& q);}` which returns `true` if `p` is equal to `q`.
*/
typedef unspecified_type Equal_3;
typedef unspecified_type Equal;
/// @}
/// \name Operations
@ -201,7 +194,7 @@ Squared_distance squared_distance_object();
/*!
returns the equal functor.
*/
Equal_3 equal_3_object();
Equal equal_object();
/// @}
@ -229,4 +222,3 @@ const Primitive::Shared_data& shared_data() const;
}; /* end AABBTraits */

View File

@ -1,10 +1,7 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Fast Intersection and Distance Computation (AABB Tree)"
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Fast Intersection and Distance Computation (AABB Tree)"
EXTRACT_ALL = false
HIDE_UNDOC_MEMBERS = true
HIDE_UNDOC_CLASSES = true

View File

@ -5,12 +5,12 @@
/*!
\addtogroup PkgAABBTreeRef
\cgalPkgDescriptionBegin{3D Fast Intersection and Distance Computation,PkgAABBTree}
\cgalPkgDescriptionBegin{2D and 3D Fast Intersection and Distance Computation,PkgAABBTree}
\cgalPkgPicture{aabb-teaser-thumb.png}
\cgalPkgSummaryBegin
\cgalPkgAuthors{Pierre Alliez, Stéphane Tayeb, and Camille Wormser}
\cgalPkgDesc{The AABB (axis-aligned bounding box) tree component offers a static data structure and algorithms to perform efficient intersection and distance queries on sets of finite 3D geometric objects.}
\cgalPkgManuals{Chapter_3D_Fast_Intersection_and_Distance_Computation,PkgAABBTreeRef}
\cgalPkgDesc{The AABB (axis-aligned bounding box) tree component offers a static data structure and algorithms to perform efficient intersection and distance queries on sets of finite 2D and 3D geometric objects.}
\cgalPkgManuals{Chapter_Fast_Intersection_and_Distance_Computation,PkgAABBTreeRef}
\cgalPkgSummaryEnd
\cgalPkgShortInfoBegin
\cgalPkgSince{3.5}
@ -25,18 +25,28 @@
\cgalCRPSection{Concepts}
- `AABBPrimitive`
- `AABBPrimitiveWithSharedData`
- `AABBGeomTraits`
- `AABBGeomTraits_2`
- `AABBGeomTraits_3`
- `AABBTraits`
- `AABBRayIntersectionGeomTraits`
- `AABBRayIntersectionGeomTraits_2`
- `AABBRayIntersectionGeomTraits_3`
- `AABBRayIntersectionTraits`
\cgalCRPSection{Classes}
- `CGAL::AABB_traits<GeomTraits,Primitive>`
- `CGAL::AABB_traits<GeomTraits,Primitive>` (deprecated, use `CGAL::AABB_traits_3<GeomTraits,Primitive>`)
- `CGAL::AABB_traits_2<GeomTraits,Primitive>`
- `CGAL::AABB_traits_3<GeomTraits,Primitive>`
- `CGAL::AABB_tree<AT>`
\cgalCRPSection{Primitives}
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_triangle_primitive_2<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_indexed_triangle_primitive_2<GeomTraits, IndexIterator, PointRange, CacheDatum, PointMap>`
- `CGAL::AABB_segment_primitive_2<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_polyline_segment_primitive_2<GeomTraits, Iterator, PointRange, CacheDatum, PointMap>`
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>` (deprecated, use `CGAL::AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>`)
- `CGAL::AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>` (deprecated, use `CGAL::AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>`)
- `CGAL::AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,ExternalPropertyMaps,CacheDatum>`
- `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,Vpm,OneHalfedgeGraphPerTree,CacheDatum>`
- `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,Vpm,OneFaceGraphPerTree,CacheDatum>`

View File

@ -3,7 +3,7 @@ namespace CGAL {
/*!
\mainpage User Manual
\anchor Chapter_3D_Fast_Intersection_and_Distance_Computation
\anchor Chapter_Fast_Intersection_and_Distance_Computation
\cgalAutoToc
\authors Pierre Alliez, Stephane Tayeb, and Camille Wormser
@ -12,7 +12,7 @@ namespace CGAL {
The AABB tree component offers a static data structure and algorithms
to perform efficient intersection and distance queries against sets of
finite 3D geometric objects. The set of geometric objects stored in
finite 2D or 3D geometric objects. The set of geometric objects stored in
the data structure can be queried for intersection detection,
intersection computation and distance. The intersection queries can be
of any type, provided that the corresponding intersection predicates
@ -123,7 +123,7 @@ the squared distance from a point query.
\subsection aabb_tree_examples_2 Tree of Polyhedron Triangle Facets for Intersection Queries
In the following example the AABB primitive wraps a facet handle of a
In the following example the AABB primitive wraps a facet handle of a
triangle polyhedral surface as `id` and the corresponding 3D
triangle as geometric object. From a segment query we test the
intersections, then compute the number of intersections, compute the
@ -163,12 +163,17 @@ handle.
\subsection aabb_tree_examples_4 Tree of Segments for Intersection and Distance Queries
In the following example the segments are stored into a list, and the
In the following example the segments are stored into a list, and the
AABB primitive wraps a segment as `datum` and an iterator in the
list as `id`. We compute the number of intersections with plane
and triangles queries, and the closest point from a point query.
\cgalExample{AABB_tree/AABB_segment_3_example.cpp}
\subsection aabb_tree_examples_8 Tree of Polyline and Polygon Segments for Intersection and Distance Queries
The following example uses segments given by a polyline and a polygon. The difference is that the polygon is closed. The `id` in this case is the iterator pointing to a `Point_2` in the polyline or the polygon. The datum, a `Segment_2`, is created on the fly from the points using the `id` as the source and the following `Point_2` as the target. We count the intersections with a `Segment_2` and the closest point and id from a point query.
\cgalExample{AABB_tree/AABB_polyline_segment_2_example.cpp}
\subsection aabb_tree_examples_5 Tree of Polyhedron Edge Segments for Intersection and Distance Queries
In the following example the AABB primitive wraps a halfedge handle as
@ -233,7 +238,7 @@ subdivision scheme which multiplies the number of triangles by four.
\subsection aabb_tree_perf_mem Memory
When using the polyhedron triangle facet primitive (defined in
`AABB_polyhedron_triangle_primitive.h`) the AABB tree occupies
`AABB_face_graph_triangle_primitive.h`) the AABB tree occupies
approximately 61 bytes per primitive (without constructing the
internal KD-tree). It increases to approximately 150 bytes per
primitive when constructing the internal KD-tree with one reference
@ -426,7 +431,7 @@ initial ball radius to a small value still guaranteed to intersect the
input primitives. This is achieved by constructing an internal secondary data
structure which provides a good hint to the algorithm at the beginning
of the traversal (done by default).
Calling `do_not_accelerate_distance_queries()` will disable
Calling `AABB_tree::do_not_accelerate_distance_queries()` will disable
the construction and the usage of this internal secondary data structure.
\section aabb_tree_history Design and Implementation History
@ -437,9 +442,14 @@ implementing both intersection and distance queries, and for generic
queries and primitives was developed by Camille Wormser. In 2009,
Pierre Alliez, Stéphane Tayeb and Camille Wormser made the
implementation CGAL-compliant, with the help of Laurent Rineau for
optimizing the tree construction. The authors wish to thank Andreas
Fabri, Jane Tournois, Mariette Yvinec and Sylvain Lefèbvre for
helpful comments and discussions.
optimizing the tree construction. Additionally, Andreas
Fabri, Jane Tournois, Mariette Yvinec and Sylvain Lefèbvre are
given thanks for helpful comments and discussions during that period.
Later, Sébastien Loriot contributed several improvements:
thread-safe queries, introduction of shared data stored in the traits
for lighter primitive types, ...
In 2024, the package was made compatible with 2D and 3D primitives by
Andreas Fabri, Sébastien Loriot, and Sven Oesau.
*/

View File

@ -8,3 +8,4 @@ Box_intersection_d
Polyhedron
BGL
Spatial_searching
Property_map

View File

@ -7,8 +7,12 @@
\example AABB_tree/AABB_polyhedron_edge_example.cpp
\example AABB_tree/AABB_polyhedron_facet_distance_example.cpp
\example AABB_tree/AABB_polyhedron_facet_intersection_example.cpp
\example AABB_tree/AABB_polyline_segment_2_example.cpp
\example AABB_tree/AABB_segment_3_example.cpp
\example AABB_tree/AABB_segment_2_example.cpp
\example AABB_tree/AABB_ray_shooting_example.cpp
\example AABB_tree/AABB_indexed_triangle_2_example.cpp
\example AABB_tree/AABB_triangle_2_example.cpp
\example AABB_tree/AABB_triangle_3_example.cpp
\example AABB_tree/AABB_halfedge_graph_edge_example.cpp
\example AABB_tree/AABB_face_graph_triangle_example.cpp

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -23,7 +23,7 @@ template <typename TriangleMesh>
void triangle_mesh(std::string fname)
{
typedef CGAL::AABB_face_graph_triangle_primitive<TriangleMesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
TriangleMesh tmesh;
@ -56,7 +56,7 @@ void surface_mesh_cache_bbox(std::string fname)
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
typedef Surface_mesh::Property_map<face_descriptor,Bbox_3> Bbox_pmap;
typedef CGAL::AABB_face_graph_triangle_primitive<Surface_mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive,Bbox_pmap> Traits;
typedef CGAL::AABB_traits_3<K, Primitive,Bbox_pmap> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
Surface_mesh tmesh;

View File

@ -5,7 +5,7 @@
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -91,7 +91,7 @@ public:
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
int main()

View File

@ -3,7 +3,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -97,7 +97,7 @@ public:
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
const double* My_triangle_primitive::point_container = nullptr;

View File

@ -7,7 +7,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -104,7 +104,7 @@ public:
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
const std::vector<My_point>* My_triangle_primitive::point_container = nullptr;

View File

@ -9,7 +9,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -95,7 +95,7 @@ public:
};
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
int main()

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
template <class Kernel, class FaceGraph>

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
template <class Kernel, class HalfedgeGraph>

View File

@ -0,0 +1,91 @@
#include <iostream>
#include <vector>
#include <array>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_indexed_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef K::Point_2 Point_2;
typedef K::Ray_2 Ray;
template <class GeomTraits>
struct Projection_xy_point_map {
typedef typename GeomTraits::Point_3 key_type;
typedef typename GeomTraits::Point_2 value_type;
typedef value_type reference;
typedef boost::readable_property_map_tag category;
typedef Projection_xy_point_map<GeomTraits> Self;
Projection_xy_point_map() {}
inline friend value_type get(Self, key_type p)
{
return value_type(p.x(), p.y());
}
};
typedef std::vector<std::array<uint8_t, 3> >::const_iterator IndexIterator;
typedef std::vector<Point_3> PointRange;
typedef CGAL::AABB_indexed_triangle_primitive_2<K, IndexIterator, PointRange, CGAL::Tag_false, Projection_xy_point_map<K>> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
int main()
{
Point_3 a(0.0, 0.0, 0.0);
Point_3 b(0.0, 1.0, 0.0);
Point_3 c(1.0, 0.0, 0.0);
Point_3 d(1.0, 1.0, 0.0);
Point_3 e(2.0, 0.0, 0.0);
Point_3 f(2.0, 1.0, 0.0);
std::vector<Point_3> points = { a, b, c, d, e, f };
std::vector<std::array<uint8_t, 3> > triangles;
triangles.push_back({ 0, 2, 1 });
triangles.push_back({ 1, 2, 3 });
triangles.push_back({ 3, 2, 4 });
triangles.push_back({ 3, 4, 5 });
// constructs AABB tree
Tree tree(triangles.begin(), triangles.end(), points);
// point sampling
Point_and_primitive_id id;
id = tree.closest_point_and_primitive(Point_2(0.5, 0.4));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(0.5, 0.6));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(1.5, 0.5));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(1.5, 0.6));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(1.0, 0.0));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(3.0, 0.5));
std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl;
Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.5));
Ray_intersection intersection = tree.first_intersection(ray);
if (!intersection) {
std::cout << "Ray does not intersect with triangles although it should!" << std::endl;
return EXIT_FAILURE;
}
else {
std::cout << std::distance(triangles.cbegin(), intersection->second) << ". triangle" << std::endl;
}
std::list<Ray_intersection> intersections;
tree.all_intersections(ray, std::back_inserter(intersections));
return EXIT_SUCCESS;
}

View File

@ -2,7 +2,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -13,7 +13,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron, CGAL::Default, CGAL::Tag_false> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -5,7 +5,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -15,7 +15,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;

View File

@ -5,7 +5,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -17,10 +17,10 @@ typedef K::Segment_3 Segment;
typedef K::Ray_3 Ray;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional< Tree::Intersection_and_primitive_id<Segment>::Type > Segment_intersection;
typedef boost::optional< Tree::Intersection_and_primitive_id<Plane>::Type > Plane_intersection;
typedef std::optional< Tree::Intersection_and_primitive_id<Segment>::Type > Segment_intersection;
typedef std::optional< Tree::Intersection_and_primitive_id<Plane>::Type > Plane_intersection;
typedef Tree::Primitive_id Primitive_id;
int main()
@ -57,7 +57,7 @@ int main()
if(intersection)
{
// gets intersection object
const Point* p = boost::get<Point>(&(intersection->first));
const Point* p = std::get_if<Point>(&(intersection->first));
if(p)
std::cout << "intersection object is a point " << *p << std::endl;
@ -81,7 +81,7 @@ int main()
if(plane_intersection)
{
if(boost::get<Segment>(&(plane_intersection->first)))
if(std::get_if<Segment>(&(plane_intersection->first)))
std::cout << "intersection object is a segment" << std::endl;
}

View File

@ -0,0 +1,71 @@
#include <iostream>
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_polyline_segment_primitive_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::vector<Point> PointRange;
typedef PointRange::const_iterator Iterator_pr;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_pr, PointRange> Primitive_pr;
typedef CGAL::AABB_traits_2<K, Primitive_pr> Traits_pr;
typedef CGAL::AABB_tree<Traits_pr> Tree_pr;
typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef Polygon_2::const_iterator Iterator_poly;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_poly, Polygon_2> Primitive_poly;
typedef CGAL::AABB_traits_2<K, Primitive_poly> Traits_poly;
typedef CGAL::AABB_tree<Traits_poly> Tree_poly;
typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly;
template<class AABBTree, class PPId>
void test(AABBTree tree) {
tree.build();
tree.accelerate_distance_queries();
// counts #intersections with a segment query
Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0));
std::cout << tree.number_of_intersected_primitives(segment_query)
<< " intersections(s) with segment" << std::endl;
// computes the closest point from a point query
Point point_query(1.5, 3.0);
Point closest = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest << std::endl;
PPId id = tree.closest_point_and_primitive(point_query);
std::cout << id.first << "\n";
}
int main()
{
Point a(0.0, 0.0);
Point b(2.0, 1.0);
Point c(3.0, 4.0);
Point d(1.0, 6.0);
Point e(-1.0, 3.0);
std::vector<Point> polyline = { a, b, c, d, e };
Polygon_2 poly(polyline.begin(), polyline.end());
test<Tree_poly, Point_and_primitive_id_poly>(Tree_poly(poly.begin(), poly.end(), poly));
// For a point range, the second iterator must be of the second-last point in the range.
// If it points to the end of the range, to polyline is considered to be closed.
test<Tree_pr, Point_and_primitive_id_pr>(Tree_pr(polyline.begin(), std::prev(polyline.end()), polyline));
return EXIT_SUCCESS;
}

View File

@ -2,7 +2,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
@ -21,9 +21,9 @@ typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
struct Skip
{
@ -70,8 +70,8 @@ int main(int argc, char* argv[])
Ray_intersection intersection = tree.first_intersection(ray, skip);
if(intersection)
{
if(boost::get<Point>(&(intersection->first))){
const Point* p = boost::get<Point>(&(intersection->first) );
if(std::get_if<Point>(&(intersection->first))){
const Point* p = std::get_if<Point>(&(intersection->first) );
std::cout << *p << std::endl;
}
}

View File

@ -0,0 +1,59 @@
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::list<Segment> SegmentRange;
typedef SegmentRange::const_iterator Iterator;
typedef CGAL::AABB_segment_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
int main()
{
Point a(0.0, 0.0);
Point b(2.0, 1.0);
Point c(3.0, 4.0);
Point d(1.0, 6.0);
Point e(-1.0, 3.0);
std::list<Segment> seg;
seg.push_back(Segment(a, b));
seg.push_back(Segment(b, c));
seg.push_back(Segment(c, d));
seg.push_back(Segment(d, e));
seg.push_back(Segment(e, a));
// constructs the AABB tree and the internal search tree for
// efficient distance computations.
Tree tree(seg.begin(), seg.end());
tree.build();
tree.accelerate_distance_queries();
// counts #intersections with a segment query
Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0));
std::cout << tree.number_of_intersected_primitives(segment_query)
<< " intersections(s) with segment" << std::endl;
// computes the closest point from a point query
Point point_query(1.5, 3.0);
Point closest = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest << std::endl;
Point_and_primitive_id id = tree.closest_point_and_primitive(point_query);
std::cout << id.second->source() << " " << id.second->target() << std::endl;
return EXIT_SUCCESS;
}

View File

@ -5,8 +5,8 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_segment_primitive_3.h>
typedef CGAL::Simple_cartesian<double> K;
@ -17,8 +17,8 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::list<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_segment_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -0,0 +1,52 @@
// Author(s) : Camille Wormser, Pierre Alliez
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_2 Ray;
typedef K::Point_2 Point;
typedef K::Triangle_2 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
int main()
{
Point a(1.0, 0.0);
Point b(0.0, 1.0);
Point c(1.0, 1.0);
Point d(0.0, 0.0);
std::list<Triangle> triangles;
triangles.push_back(Triangle(a,b,c));
triangles.push_back(Triangle(a,b,d));
triangles.push_back(Triangle(a,d,c));
// constructs AABB tree
Tree tree(triangles.begin(),triangles.end());
// counts #intersections
Ray ray_query(a,b);
std::cout << tree.number_of_intersected_primitives(ray_query)
<< " intersections(s) with ray query" << std::endl;
// compute closest point and squared distance
Point point_query(2.0, 2.0);
Point closest_point = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest_point << std::endl;
FT sqd = tree.squared_distance(point_query);
std::cout << "squared distance: " << sqd << std::endl;
return EXIT_SUCCESS;
}

View File

@ -5,20 +5,19 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_triangle_primitive_3.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Line_3 Line;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef std::list<Triangle>::const_iterator Iterator;
typedef CGAL::AABB_triangle_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
int main()

View File

@ -1,7 +1,7 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.23)
cmake_minimum_required(VERSION 3.12...3.29)
project(AABB_tree_Examples)
find_package(CGAL REQUIRED)

View File

@ -21,7 +21,6 @@
#include <CGAL/AABB_primitive.h>
#include <CGAL/boost/graph/property_maps.h>
#include <CGAL/Default.h>
#include <boost/mpl/if.hpp>
namespace CGAL {
@ -33,7 +32,7 @@ namespace CGAL {
* while the AABB tree holding the primitive is in use.
* The triangle type of the primitive (`Datum`) is `CGAL::Kernel_traits< boost::property_traits< VertexPointPMap >::%value_type >::%Kernel::Triangle_3`.
*
* \cgalModels `AABBPrimitiveWithSharedData`
* \cgalModels{AABBPrimitiveWithSharedData}
*
*\tparam FaceGraph is a model of the face graph concept.
*\tparam VertexPointPMap is a property map with `boost::graph_traits<FaceGraph>::%vertex_descriptor`
@ -49,7 +48,7 @@ namespace CGAL {
* The default is `CGAL::Tag_false` (datum is not stored).
*\sa `AABBPrimitive`
*\sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
*\sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
*\sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class FaceGraph,
class VertexPointPMap = Default,
@ -57,9 +56,9 @@ template < class FaceGraph,
class CacheDatum=Tag_false >
class AABB_face_graph_triangle_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive<typename boost::mpl::if_<OneFaceGraphPerTree,
typename boost::graph_traits<FaceGraph>::face_descriptor,
std::pair<typename boost::graph_traits<FaceGraph>::face_descriptor, const FaceGraph*> >::type,
: public AABB_primitive<std::conditional_t<OneFaceGraphPerTree::value,
typename boost::graph_traits<FaceGraph>::face_descriptor,
std::pair<typename boost::graph_traits<FaceGraph>::face_descriptor, const FaceGraph*> >,
Triangle_from_face_descriptor_map<
FaceGraph,
typename Default::Get<VertexPointPMap,
@ -76,7 +75,7 @@ class AABB_face_graph_triangle_primitive
{
typedef typename Default::Get<VertexPointPMap, typename boost::property_map< FaceGraph, vertex_point_t>::const_type >::type VertexPointPMap_;
typedef typename boost::graph_traits<FaceGraph>::face_descriptor FD;
typedef typename boost::mpl::if_<OneFaceGraphPerTree, FD, std::pair<FD, const FaceGraph*> >::type Id_;
typedef std::conditional_t<OneFaceGraphPerTree::value, FD, std::pair<FD, const FaceGraph*> > Id_;
typedef Triangle_from_face_descriptor_map<FaceGraph,VertexPointPMap_> Triangle_property_map;
typedef One_point_from_face_descriptor_map<FaceGraph,VertexPointPMap_> Point_property_map;

View File

@ -24,8 +24,6 @@
#include <iterator>
#include <boost/mpl/and.hpp>
#include <CGAL/type_traits/is_iterator.h>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/mpl/if.hpp>
#include <CGAL/Default.h>
@ -34,7 +32,7 @@ namespace CGAL {
/*!
* \ingroup PkgAABBTreeRef
* Primitive type for a edge of a polyhedral surface.
* Primitive type for an edge of a polyhedral surface.
* It wraps an `edge_descriptor` into a 3D segment.
* The class model of `HalfedgeGraph` from which the primitive is built should not be deleted
* while the AABB tree holding the primitive is in use.
@ -42,8 +40,10 @@ namespace CGAL {
* of `VertexPointPMap` (using the `Kernel_traits` mechanism).
* The segment type of the primitive (`Datum`) is `CGAL::Kernel_traits< boost::property_traits< VertexPointPMap >::%value_type >::%Kernel::Segment_3`.
*
* \cgalModels `AABBPrimitive` if `OneHalfedgeGraphPerTree` is `CGAL::Tag_false`,
* and `AABBPrimitiveWithSharedData` if `OneHalfedgeGraphPerTree` is `CGAL::Tag_true`.
* \cgalModelsBareBegin
* \cgalModelsBare{`AABBPrimitive` if `OneHalfedgeGraphPerTree` is `CGAL::Tag_false`}
* \cgalModelsBare{`AABBPrimitiveWithSharedData` if `OneHalfedgeGraphPerTree` is `CGAL::Tag_true`}
* \cgalModelsBareEnd
*
* \tparam HalfedgeGraph is a model of the halfedge graph concept.
* as key type and a \cgal Kernel `Point_3` as value type.
@ -60,7 +60,8 @@ namespace CGAL {
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_segment_primitive_3<Iterator,CacheDatum>`
* \sa \link BGLPolyGT `boost::graph_traits<Polyhedron>` \endlink
*/
template < class HalfedgeGraph,
@ -69,9 +70,9 @@ template < class HalfedgeGraph,
class CacheDatum = Tag_false >
class AABB_halfedge_graph_segment_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< typename boost::mpl::if_<OneHalfedgeGraphPerTree,
typename boost::graph_traits<HalfedgeGraph>::edge_descriptor,
std::pair<typename boost::graph_traits<HalfedgeGraph>::edge_descriptor, const HalfedgeGraph*> >::type,
: public AABB_primitive< std::conditional_t<OneHalfedgeGraphPerTree::value,
typename boost::graph_traits<HalfedgeGraph>::edge_descriptor,
std::pair<typename boost::graph_traits<HalfedgeGraph>::edge_descriptor, const HalfedgeGraph*> >,
Segment_from_edge_descriptor_map<
HalfedgeGraph,
typename Default::Get<VertexPointPMap,
@ -88,7 +89,7 @@ class AABB_halfedge_graph_segment_primitive
{
typedef typename Default::Get<VertexPointPMap,typename boost::property_map< HalfedgeGraph,vertex_point_t>::const_type >::type VertexPointPMap_;
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor ED;
typedef typename boost::mpl::if_<OneHalfedgeGraphPerTree, ED, std::pair<ED, const HalfedgeGraph*> >::type Id_;
typedef std::conditional_t<OneHalfedgeGraphPerTree::value, ED, std::pair<ED, const HalfedgeGraph*> > Id_;
typedef Segment_from_edge_descriptor_map<HalfedgeGraph,VertexPointPMap_> Segment_property_map;
typedef Source_point_from_edge_descriptor_map<HalfedgeGraph,VertexPointPMap_> Point_property_map;

View File

@ -0,0 +1,134 @@
// Copyright (c) 2024 GeometryFactory (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) : Sven Oesau
//
#ifndef CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_
#define CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator, class PointIterator, class PointMap>
struct Triangle_2_from_index_range_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Triangle_2 value_type;
typedef typename GeomTraits::Triangle_2 reference;
typedef boost::readable_property_map_tag category;
typedef Triangle_2_from_index_range_iterator_property_map<GeomTraits, Iterator, PointIterator, PointMap> Self;
Triangle_2_from_index_range_iterator_property_map() {}
Triangle_2_from_index_range_iterator_property_map(PointIterator b, PointMap& pmap) : begin(b), pmap(pmap) {}
inline friend value_type
get(Self s, key_type it)
{
return typename GeomTraits::Construct_triangle_2()(get(s.pmap, s.begin[(*it)[0]]), get(s.pmap, s.begin[(*it)[1]]), get(s.pmap, s.begin[(*it)[2]]));
}
PointIterator begin;
PointMap pmap;
};
template <class GeomTraits, class Iterator, class PointIterator, class PointMap>
struct Point_from_indexed_triangle_2_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename PointMap::value_type value_type;
typedef const value_type reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, Iterator, PointIterator, PointMap> Self;
Point_from_indexed_triangle_2_iterator_property_map() {}
Point_from_indexed_triangle_2_iterator_property_map(PointIterator b, PointMap &pmap) : begin(b), pmap(pmap) {}
inline friend reference
get(Self s, key_type it)
{
return get(s.pmap, s.begin[((*it)[0])]);
}
PointIterator begin;
PointMap pmap;
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a range of three indices as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Triangle_2`.
* It also provides the functor `Construct_triangle_2` that has an operator taking three `Point_2` as
* parameters and returns a `Triangle_2`
* \tparam IndexIterator is a model of `ForwardIterator` with its value type being a `RandomAccessRange` of size 3 with an index type as `value_type`, e.g., `uint8_t`, `uint16_t` or int.
* \tparam PointRange is a model of `RandomAccessRange`. Its value type needs to be compatible to `PointMap` or `Point_2` in the default case.
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
* \tparam PointMap is a model of `ReadablePropertyMap` with its key type being the value type of `PointRange` and the value type being a `Point_2`.
* The default is \link Identity_property_map `CGAL::Identity_property_map`\endlink<PointRange::value_type>.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
*/
template < class GeomTraits,
class IndexIterator,
class PointRange,
class CacheDatum = Tag_false,
class PointMap = Identity_property_map<typename PointRange::value_type>>
class AABB_indexed_triangle_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< IndexIterator,
internal::Triangle_2_from_index_range_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
Tag_true,
CacheDatum >
#endif
{
typedef AABB_primitive< IndexIterator,
internal::Triangle_2_from_index_range_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
Tag_true,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange&) : Base(it) {}
/// \internal
static typename Base::Shared_data construct_shared_data(PointRange &range, PointMap pmap = PointMap()) {
return std::make_pair(
internal::Triangle_2_from_index_range_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>(range.begin(), pmap),
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>(range.begin(), pmap));
}
};
} // end namespace CGAL
#endif // CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_

View File

@ -1,158 +0,0 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (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) : Pierre Alliez, Stephane Tayeb
//
//******************************************************************************
// File Description :
//
//******************************************************************************
#ifndef CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_
#define CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_polyhedron_segment_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_halfedge_graph_segment_primitive.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <type_traits>
namespace CGAL {
/// \addtogroup PkgAABBTreeRef
/// @{
/// \deprecated This class is deprecated since \cgal 4.3, the class
/// `AABB_halfedge_graph_segment_primitive` should be used instead.
///
/// Primitive type that wraps a halfedge handle of a
/// polyhedron, which is used as id, and allows the construction
/// of the datum on the fly. Since only the halfedge handle is
/// stored in this primitive, the polyhedron from which the
/// AABB tree is built should not be deleted while the AABB tree
/// is in use.
///
/// \cgalModels `AABBPrimitive`
/// \tparam GeomTraits must provide a \c %Point_3
/// type, used as \c Point, and a \c %Segment_3 type, used as \c
/// Datum and constructible from two arguments of type \c
/// Point.
/// \tparam Polyhedron must be a
/// \c CGAL::Polyhedron_3 whose points have type \c Point.
///
/// \sa `AABBPrimitive`
/// \sa `AABB_polyhedron_triangle_primitive`
template<typename GeomTraits, typename Polyhedron>
class AABB_polyhedron_segment_primitive
{
public:
// AABBTrianglePrimitive types
typedef typename GeomTraits::Point_3 Point;
/// \name Types
/// @{
/// Geometric data type.
typedef typename GeomTraits::Segment_3 Datum;
/// Id type.
typedef typename Polyhedron::Halfedge_handle Id;
/// @}
// Self
typedef AABB_polyhedron_segment_primitive<GeomTraits,Polyhedron> Self;
// Constructor
AABB_polyhedron_segment_primitive() {}
AABB_polyhedron_segment_primitive(const Id& handle)
: m_halfedge_handle(handle) { };
AABB_polyhedron_segment_primitive(const Id* ptr)
: m_halfedge_handle(*ptr) { };
template <class Iterator>
AABB_polyhedron_segment_primitive( Iterator it,
std::enable_if_t<
std::is_same<Id,typename Iterator::value_type>::value
>* =0
) : m_halfedge_handle(*it) { }
AABB_polyhedron_segment_primitive(const Self& primitive)
: m_halfedge_handle(primitive.m_halfedge_handle) {}
// Default destructor, copy constructor and assignment operator are ok
// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_halfedge_handle->vertex()->point();
const Point& b = m_halfedge_handle->opposite()->vertex()->point();
return Datum(a,b); // returns a 3D segment
}
// Returns the identifier
Id& id() { return m_halfedge_handle; }
const Id& id() const { return m_halfedge_handle; }
// Returns a point on the primitive
Point reference_point() const
{
return m_halfedge_handle->vertex()->point();
}
private:
// Id, here a polyhedron halfedge handle
Id m_halfedge_handle;
}; // end class AABB_polyhedron_segment_primitive
///@}
template<typename GeomTraits, typename Polyhedron>
class AABB_const_polyhedron_edge_primitive
{
public:
/// AABBTrianglePrimitive types
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Segment_3 Datum;
typedef typename Polyhedron::Halfedge_const_handle Id;
/// Constructor
AABB_const_polyhedron_edge_primitive(const Id& handle)
: m_halfedge_handle(handle) { };
// Default destructor, copy constructor and assignment operator are ok
/// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_halfedge_handle->vertex()->point();
const Point& b = m_halfedge_handle->opposite()->vertex()->point();
return Datum(a,b); // returns a 3D segment
}
/// Returns the identifier
const Id id() const { return m_halfedge_handle; }
/// Returns a point on the primitive
Point reference_point() const
{
return m_halfedge_handle->vertex()->point();
}
private:
/// Id, here a polyhedron halfedge handle
Id m_halfedge_handle;
}; // end class AABB_const_polyhedron_edge_primitive
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_

View File

@ -1,154 +0,0 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (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) : Stéphane Tayeb, Pierre Alliez
//
#ifndef CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_
#define CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_polyhedron_triangle_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_face_graph_triangle_primitive.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <type_traits>
namespace CGAL {
/// \ingroup PkgAABBTreeRef
/// \deprecated This class is deprecated since \cgal 4.3, the class
/// `AABB_face_graph_triangle_primitive` should be used instead.
///
/// Primitive type that wraps a facet handle of a polyhedron,
/// which is used as id, and allows the construction of the datum on
/// the fly. Since only the facet handle is stored in this primitive,
/// the polyhedron from which the AABB tree is built should not be
/// deleted while the AABB tree is in use.
///
/// \cgalModels `AABBPrimitive`
/// \tparam GeomTraits must provides a \c %Point_3
/// type, used as \c Point, and a \c %Triangle_3 type, used as \c
/// Datum and constructible from three arguments of type \c
/// Point.
/// \tparam Polyhedron must be a
/// \c CGAL::Polyhedron_3 whose points have type \c Point.
///
/// \sa `AABBPrimitive`
/// \sa `AABB_polyhedron_segment_primitive`
template<typename GeomTraits, typename Polyhedron>
class AABB_polyhedron_triangle_primitive
{
public:
typedef typename GeomTraits::Point_3 Point;
/// \name Types
/// @{
/// Id type.
typedef typename Polyhedron::Facet_handle Id;
/// Geometric data type.
typedef typename GeomTraits::Triangle_3 Datum;
/// @}
// Self
typedef AABB_polyhedron_triangle_primitive<GeomTraits, Polyhedron> Self;
// Constructors
AABB_polyhedron_triangle_primitive() {}
AABB_polyhedron_triangle_primitive(const AABB_polyhedron_triangle_primitive& primitive)
{
m_facet_handle = primitive.id();
}
AABB_polyhedron_triangle_primitive(const Id& handle)
: m_facet_handle(handle) { };
AABB_polyhedron_triangle_primitive(const Id* ptr)
: m_facet_handle(*ptr) { };
template <class Iterator>
AABB_polyhedron_triangle_primitive( Iterator it,
std::enable_if_t<
std::is_same<Id,typename Iterator::value_type>::value
>* =0
) : m_facet_handle(*it) { }
// Default destructor, copy constructor and assignment operator are ok
// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_facet_handle->halfedge()->vertex()->point();
const Point& b = m_facet_handle->halfedge()->next()->vertex()->point();
const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point();
return Datum(a,b,c);
}
// Returns a point on the primitive
Point reference_point() const
{
return m_facet_handle->halfedge()->vertex()->point();
}
// Returns the identifier
const Id& id() const { return m_facet_handle; }
Id& id() { return m_facet_handle; }
private:
/// The id, here a polyhedron facet handle
Id m_facet_handle;
}; // end class AABB_polyhedron_triangle_primitive
template<typename GeomTraits, typename Polyhedron>
class AABB_const_polyhedron_triangle_primitive
{
public:
/// AABBPrimitive types
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Triangle_3 Datum;
typedef typename Polyhedron::Facet_const_handle Id;
/// Constructors
AABB_const_polyhedron_triangle_primitive(const Id& handle)
: m_facet_handle(handle) { };
// Default destructor, copy constructor and assignment operator are ok
/// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_facet_handle->halfedge()->vertex()->point();
const Point& b = m_facet_handle->halfedge()->next()->vertex()->point();
const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point();
return Datum(a,b,c);
}
/// Returns a point on the primitive
Point reference_point() const
{
return m_facet_handle->halfedge()->vertex()->point();
}
/// Returns the identifier
Id id() const { return m_facet_handle; }
private:
/// The id, here a polyhedron facet handle
Id m_facet_handle;
}; // end class AABB_polyhedron_triangle_primitive
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_

View File

@ -0,0 +1,140 @@
// Copyright (c) 2024 GeometryFactory.
// 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) : Sven Oesau
//
#ifndef CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_
#define CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator, class PointMap>
struct Segment_2_from_point_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Segment_2 value_type;
typedef typename GeomTraits::Segment_2 reference; // The segments are created on the fly, so working with references is not possible.
typedef boost::readable_property_map_tag category;
typedef Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap> Self;
Segment_2_from_point_iterator_property_map(Iterator b, Iterator e, PointMap& pmap) : begin(b), end(e), pmap(pmap) {}
Segment_2_from_point_iterator_property_map() {}
inline friend reference // Cannot return reference as the Segment does not exist, only the points exist.
get(Self s, key_type it)
{
Iterator it2 = std::next(it);
if (it2 == s.end)
return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *s.begin));
else
return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *it2));
}
Iterator begin, end;
PointMap pmap;
};
template <class GeomTraits, class Iterator, class PointMap>
struct Point_from_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename PointMap::value_type value_type;
typedef const value_type reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_iterator_property_map<GeomTraits, Iterator, PointMap> Self;
Point_from_iterator_property_map() {}
Point_from_iterator_property_map(PointMap& pmap) : pmap(pmap) {}
inline friend reference
get(Self s, key_type it)
{
return get(s.pmap, *it);
}
PointMap pmap;
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 2D point as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use. The `Segment_2` is constructed on the fly using the `Point_2`
* the identifier is pointing to as source and the `Point_2` the next identifier is pointing to as target.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Segment_2`.
* It also provides the functor `Construct_segment_2` that has an operator taking two `Point_2`
* and returning a `Segment_2`.
* \tparam Iterator is a model of `ForwardIterator` whose value type is convertible to `GeomTraits::Point_2`
* \tparam PointRange is a model of `ConstRange` whose iterator is a model of `ForwardIterator`. Its value type needs to be the key type of `PointMap`.
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
* \tparam PointMap is a model of `ReadablePropertyMap` whose key type is the value type of `PointRange` and whose value type is `Point_2`.
* The default is \link Identity_property_map `CGAL::Identity_property_map`\endlink<PointRange::value_type>.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class PointRange,
class CacheDatum = Tag_false,
class PointMap = Identity_property_map<typename PointRange::value_type>>
class AABB_polyline_segment_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>,
internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>,
Tag_true,
CacheDatum >
#endif
{
typedef internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap> Segment_map;
typedef internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap> Point_primitive_map;
typedef AABB_primitive< Iterator,
Segment_map,
Point_primitive_map,
Tag_true,
CacheDatum > Base;
public:
AABB_polyline_segment_primitive_2(Iterator it, PointRange& poly, PointMap pmap = PointMap())
: Base(it,Segment_map(poly.begin(), poly.end(), pmap), Point_primitive_map(pmap))
{}
/// \internal
static typename Base::Shared_data construct_shared_data(PointRange& range, PointMap pmap = PointMap()) {
return std::make_pair(internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>(range.begin(), range.end(), pmap), internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>(pmap));
}
};
} // end namespace CGAL
#endif // CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_

View File

@ -53,8 +53,10 @@ public:
* The two property maps which are template parameters of the class enable to get the datum and the reference point of
* the primitive from the identifier. The last template parameter controls whether the primitive class holds a copy of the datum.
*
* \cgalModels `AABBPrimitive` if `ExternalPropertyMaps` is `CGAL::Tag_false`.
* \cgalModels `AABBPrimitiveWithSharedData` if `ExternalPropertyMaps` is `CGAL::Tag_true`.
* \cgalModelsBareBegin
* \cgalModelsBare{`AABBPrimitive` if `ExternalPropertyMaps` is `CGAL::Tag_false`}
* \cgalModelsBare{`AABBPrimitiveWithSharedData` if `ExternalPropertyMaps` is `CGAL::Tag_true`}
* \cgalModelsBareEnd
*
* \tparam ObjectPropertyMap is a model of `ReadablePropertyMap` with `Id` as
* `key_type`. It must be a model of `CopyConstructible`, `DefaultConstructible`, and `CopyAssignable`.
@ -69,10 +71,12 @@ public:
* it is constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABB_segment_primitive<Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
*/
template < class Id,
class ObjectPropertyMap,
@ -249,4 +253,3 @@ public:
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_PRIMITIVE_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (France).
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -11,91 +11,38 @@
// Author(s) : Sebastien Loriot
//
#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_H_
#define CGAL_AABB_SEGMENT_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_segment_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_segment_primitive_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/AABB_segment_primitive_3.h>
/// \file AABB_segment_primitive.h
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Source_of_segment_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_3>()(
// std::declval<typename GeomTraits::Segment_3>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_3()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_3()( *it );
}
};
}//namespace internal
/// \addtogroup PkgAABBTreeRef
/// @{
/// template alias for backward compatibility
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 3D segment as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels `AABBPrimitive`
*
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_triangle_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_segment_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive(Iterator it) : Base(it){}
};
using AABB_segment_primitive = AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>;
} // end namespace CGAL
///@}
#include <CGAL/enable_warnings.h>
} // CGAL namespace
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_H_
#endif // CGAL_NO_DEPRECATED_CODE
#endif //CGAL_AABB_SEGMENT_PRIMITIVE_H_

View File

@ -0,0 +1,99 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (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) : Sebastien Loriot
//
#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_2_H_
#define CGAL_AABB_SEGMENT_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Source_of_segment_2_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_2 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_2>()(
// std::declval<typename GeomTraits::Segment_2>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_2()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_2_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_2()( *it );
}
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 2D segment as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Segment_2`.
* It also provides the functor `Construct_source_2` that has an operator taking a `Segment_2`
* and returning its source as a type convertible to `Point_2`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_2`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_segment_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive_2(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_2_H_

View File

@ -0,0 +1,100 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (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) : Sebastien Loriot
//
#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_3_H_
#define CGAL_AABB_SEGMENT_PRIMITIVE_3_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Source_of_segment_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_3>()(
// std::declval<typename GeomTraits::Segment_3>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_3()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_3()( *it );
}
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 3D segment as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_segment_primitive_3
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive_3(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_3_H_

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -14,525 +14,35 @@
#ifndef CGAL_AABB_TRAITS_H_
#define CGAL_AABB_TRAITS_H_
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_traits.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_traits_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <boost/optional.hpp>
#include <CGAL/AABB_traits_3.h>
/// \file AABB_traits.h
namespace CGAL {
namespace internal{ namespace AABB_tree {
namespace CGAL
{
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::boost::optional<T> > { typedef T type; };
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data=Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive,false>{};
template <class Primitive>
struct AABB_traits_base<Primitive,true>{
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t){
m_primitive_data=Primitive::construct_shared_data(std::forward<T>(t)...);
}
const typename Primitive::Shared_data& shared_data() const {return m_primitive_data;}
};
// AABB_traits_base_2 brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits<GeomTraits>::value>
struct AABB_traits_base_2;
template <typename GeomTraits>
struct AABB_traits_base_2<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_base_2<GeomTraits,true>{
typedef typename GeomTraits::Ray_3 Ray_3;
typedef typename GeomTraits::Point_3 Point_3;
typedef typename GeomTraits::Vector_3 Vector_3;
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_source_3 Construct_source_3;
typedef typename GeomTraits::Construct_vector_3 Construct_vector_3;
// Defining Bounding_box and other types from the full AABB_traits
// here is might seem strange, but otherwise we would need to use
// CRTP to get access to the derived class, which would bloat the
// code more.
typedef typename CGAL::Bbox_3 Bounding_box;
struct Intersection_distance {
boost::optional<FT> operator()(const Ray_3& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;
const Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3
= GeomTraits().construct_cartesian_const_iterator_3_object();
const Construct_source_3 construct_source_3 = GeomTraits().construct_source_3_object();
const Construct_vector_3 construct_vector_3 = GeomTraits().construct_vector_3_object();
const Point_3 source = construct_source_3(ray);
const Vector_3 direction = construct_vector_3(ray);
Cartesian_const_iterator_3 source_iter = construct_cartesian_const_iterator_3(source);
Cartesian_const_iterator_3 direction_iter = construct_cartesian_const_iterator_3(direction);
for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) {
if(*direction_iter == 0) {
if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) {
return boost::none;
}
} else {
FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter;
FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter;
t_near = (std::max)(t_near, (std::min)(t1, t2));
t_far = (std::min)(t_far, (std::max)(t1, t2));
// if(t1 > t2)
// std::swap(t1, t2);
// if(t1 > t_near)
// t_near = t1;
// if(t2 < t_far)
// t_far = t2;
if(t_near > t_far || t_far < FT(0.))
return boost::none;
}
}
if(t_near < FT(0.))
return FT(0.);
else
return t_near;
}
};
Intersection_distance intersection_distance_object() const { return Intersection_distance(); }
};
} } //end of namespace internal::AABB_tree
/// \addtogroup PkgAABBTreeRef
/// @{
// forward declaration
template< typename AABBTraits>
class AABB_tree;
/// template alias for backward compatibility
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
using AABB_traits = AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap>;
///@}
/// This traits class handles any type of 3D geometric
/// primitives provided that the proper intersection tests and
/// constructions are implemented. It handles points, rays, lines and
/// segments as query types for intersection detection and
/// computations, and it handles points as query type for distance
/// queries.
///
/// \cgalModels AABBTraits
/// \cgalModels AABBRayIntersectionTraits
} // namespace CGAL
/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits,
/// and provide the geometric types as well as the intersection tests and computations.
/// \tparam Primitive provide the type of primitives stored in the AABB_tree.
/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`.
///
/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id,
/// and as value type a `Bounding_box`.
/// If the type is `Default` the `Datum` must have the
/// member function `bbox()` that returns the bounding box of the primitive.
///
/// If the argument `GeomTraits` is a model of the concept \ref
/// AABBRayIntersectionGeomTraits, this class is also a model of \ref
/// AABBRayIntersectionTraits.
///
/// \sa `AABBTraits`
/// \sa `AABB_tree`
/// \sa `AABBPrimitive`
/// \sa `AABBPrimitiveWithSharedData`
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_base_2<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
public:
typedef GeomTraits Geom_traits;
typedef AABB_traits<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `boost::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_3>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};
// types for search tree
/// \name Types
/// @{
/// Point query type.
typedef typename GeomTraits::Point_3 Point_3;
/// additional types for the search tree, required by the RangeSearchTraits concept
/// \bug This is not documented for now in the AABBTraits concept.
typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3;
/// Bounding box type.
typedef typename CGAL::Bbox_3 Bounding_box;
/// @}
typedef typename GeomTraits::Sphere_3 Sphere_3;
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_center_3 Construct_center_3;
typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3;
typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3;
typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3;
typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3;
BboxMap bbm;
/// Default constructor.
AABB_traits() { }
AABB_traits(BboxMap bbm)
: bbm(bbm)
{}
typedef typename GeomTraits::Compute_squared_distance_3 Squared_distance;
Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_3_object(); }
typedef typename GeomTraits::Equal_3 Equal_3;
Equal_3 equal_3_object() const { return GeomTraits().equal_3_object(); }
/**
* @internal
* @brief Sorts [first,beyond[
* @param first iterator on first element
* @param beyond iterator on beyond element
* @param bbox the bounding box of [first,beyond[
*
* Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest
* axis, using the comparison function `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
void operator()(PrimitiveIterator first,
PrimitiveIterator beyond,
const typename AT::Bounding_box& bbox) const
{
PrimitiveIterator middle = first + (beyond - first)/2;
switch(Traits::longest_axis(bbox))
{
case AT::CGAL_AXIS_X: // sort along x
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Y: // sort along y
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Z: // sort along z
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); });
break;
default:
CGAL_error();
}
}
};
Split_primitives split_primitives_object() const {return Split_primitives(*this);}
/*
* Computes the bounding box of a set of primitives
* @param first an iterator on the first primitive
* @param beyond an iterator on the past-the-end primitive
* @return the bounding box of the primitives of the iterator range
*/
class Compute_bbox {
const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
typename AT::Bounding_box operator()(ConstPrimitiveIterator first,
ConstPrimitiveIterator beyond) const
{
typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm);
for(++first; first != beyond; ++first)
{
bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm);
}
return bbox;
}
};
Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);}
/// \brief Function object using `GeomTraits::Do_intersect`.
/// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()`
/// function of this tree is used.
class Do_intersect {
const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_3_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Bounding_box& bbox) const
{
return other_tree.do_intersect(bbox);
}
};
Do_intersect do_intersect_object() const {return Do_intersect(*this);}
class Intersection {
const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper<AT>::get_datum(primitive,m_traits));
if (!inter_res)
return boost::none;
return boost::make_optional( std::make_pair(*inter_res, primitive.id()) );
}
};
Intersection intersection_object() const {return Intersection(*this);}
// This should go down to the GeomTraits, i.e. the kernel
class Closest_point {
typedef typename AT::Point_3 Point;
typedef typename AT::Primitive Primitive;
const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
: m_traits(traits) {}
Point operator()(const Point& p, const Primitive& pr, const Point& bound) const
{
GeomTraits geom_traits;
Point closest_point = geom_traits.construct_projected_point_3_object()(
internal::Primitive_helper<AT>::get_datum(pr,m_traits), p);
return (geom_traits.compare_distance_3_object()(p, closest_point, bound) == LARGER) ?
bound : closest_point;
}
};
// This should go down to the GeomTraits, i.e. the kernel
// and the internal implementation should change its name from
// do_intersect to something like does_contain (this is what we compute,
// this is not the same do_intersect as the spherical kernel)
class Compare_distance {
typedef typename AT::Point_3 Point;
typedef typename AT::FT FT;
typedef typename AT::Primitive Primitive;
public:
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const
{
return (*this)(p, bb, bound, Boolean_tag<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr)?
CGAL::SMALLER : CGAL::LARGER;
}
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()(p, sq_distance),
pr) ?
CGAL::SMALLER :
CGAL::LARGER;
}
};
Closest_point closest_point_object() const {return Closest_point(*this);}
Compare_distance compare_distance_object() const {return Compare_distance();}
typedef enum { CGAL_AXIS_X = 0,
CGAL_AXIS_Y = 1,
CGAL_AXIS_Z = 2} Axis;
static Axis longest_axis(const Bounding_box& bbox);
private:
/**
* @brief Computes bounding box of one primitive
* @param pr the primitive
* @return the bounding box of the primitive \c pr
*/
template <typename PM>
Bounding_box compute_bbox(const Primitive& pr, const PM&)const
{
return get(bbm, pr.id());
}
Bounding_box compute_bbox(const Primitive& pr, const Default&)const
{
return internal::Primitive_helper<AT>::get_datum(pr,*this).bbox();
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_z_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits<GT,P,B>::Axis
AABB_traits<GT,P,B>::longest_axis(const Bounding_box& bbox)
{
const double dx = bbox.xmax() - bbox.xmin();
const double dy = bbox.ymax() - bbox.ymin();
const double dz = bbox.zmax() - bbox.zmin();
if(dx>=dy)
{
if(dx>=dz)
{
return CGAL_AXIS_X;
}
else // dz>dx and dx>=dy
{
return CGAL_AXIS_Z;
}
}
else // dy>dx
{
if(dy>=dz)
{
return CGAL_AXIS_Y;
}
else // dz>dy and dy>dx
{
return CGAL_AXIS_Z;
}
}
}
/// @}
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_NO_DEPRECATED_CODE
#endif // CGAL_AABB_TRAITS_H_

View File

@ -0,0 +1,504 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#ifndef CGAL_AABB_TRAITS_2_H_
#define CGAL_AABB_TRAITS_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/Search_traits_2.h>
#include <optional>
/// \file AABB_traits_2.h
namespace CGAL {
namespace internal{ namespace AABB_tree {
// AABB_traits_intersection_base_2 brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits_2<GeomTraits>::value>
struct AABB_traits_intersection_base_2;
template <typename GeomTraits>
struct AABB_traits_intersection_base_2<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_intersection_base_2<GeomTraits,true>{
template<typename AABBTree, typename SkipFunctor>
friend class AABB_ray_intersection;
private:
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Point_2 Point;
typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator;
typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator;
static Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() {
return GeomTraits().construct_cartesian_const_iterator_2_object();
}
public:
typedef typename GeomTraits::Ray_2 Ray;
typedef typename GeomTraits::Vector_2 Vector;
typedef typename GeomTraits::Construct_source_2 Construct_source;
typedef typename GeomTraits::Construct_vector_2 Construct_vector;
static Construct_source construct_source_object() {
return GeomTraits().construct_source_2_object();
}
static Construct_vector construct_vector_object() {
return GeomTraits().construct_vector_2_object();
}
// Defining Bounding_box and other types from the full AABB_traits_2
// here might seem strange, but otherwise we would need to use
// CRTP to get access to the derived class, which would bloat the
// code more.
typedef typename CGAL::Bbox_2 Bounding_box;
struct Intersection_distance {
std::optional<FT> operator()(const Ray& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;
const Construct_cartesian_const_iterator construct_cartesian_const_iterator_2
= GeomTraits().construct_cartesian_const_iterator_2_object();
const Construct_source construct_source_2 = GeomTraits().construct_source_2_object();
const Construct_vector construct_vector_2 = GeomTraits().construct_vector_2_object();
const Point source = construct_source_2(ray);
const Vector direction = construct_vector_2(ray);
Cartesian_const_iterator source_iter = construct_cartesian_const_iterator_2(source);
Cartesian_const_iterator direction_iter = construct_cartesian_const_iterator_2(direction);
for(int i = 0; i < 2; ++i, ++source_iter, ++direction_iter) {
if(*direction_iter == 0) {
if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) {
return std::nullopt;
}
} else {
FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter;
FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter;
t_near = (std::max)(t_near, (std::min)(t1, t2));
t_far = (std::min)(t_far, (std::max)(t1, t2));
if(t_near > t_far || t_far < FT(0.))
return std::nullopt;
}
}
if(t_near < FT(0.))
return FT(0.);
else
return t_near;
}
};
Intersection_distance intersection_distance_object() const { return Intersection_distance(); }
};
} } //end of namespace internal::AABB_tree
/// \addtogroup PkgAABBTreeRef
/// @{
// forward declaration
template< typename AABBTraits>
class AABB_tree;
/// This traits class handles any type of 2D geometric
/// primitives provided that the proper intersection tests and
/// constructions are implemented. It handles points, rays, lines and
/// segments as query types for intersection detection and
/// computations, and it handles points as query type for distance
/// queries.
///
/// \cgalModels{AABBTraits,AABBRayIntersectionTraits}
///
/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits_2,
/// and provide the geometric types as well as the intersection tests and computations.
/// \tparam Primitive provide the type of primitives stored in the AABB_tree.
/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`.
///
/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id,
/// and as value type a `Bounding_box`.
/// If the type is `Default` the `Datum` must have the
/// member function `bbox()` that returns the bounding box of the primitive.
///
/// If the argument `GeomTraits` is a model of the concept \ref
/// AABBRayIntersectionGeomTraits_2, this class is also a model of \ref
/// AABBRayIntersectionTraits.
///
/// \sa `AABBTraits`
/// \sa `AABB_tree`
/// \sa `AABBPrimitive`
/// \sa `AABBPrimitiveWithSharedData`
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits_2
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_intersection_base_2<GeomTraits>,
public Search_traits_2<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
typedef GeomTraits Geom_traits;
public:
typedef AABB_traits_2<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_2, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_2::operator()`. If it is
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_2>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};
// types for search tree
/// \name Types
/// @{
/// <summary>
/// point type
/// </summary>
typedef typename GeomTraits::Point_2 Point;
/// additional types for the search tree, required by the RangeSearchTraits concept
/// \bug This is not documented for now in the AABBTraits concept.
typedef typename GeomTraits::Iso_rectangle_2 Iso_rectangle_2;
/// Bounding box type.
typedef typename CGAL::Bbox_2 Bounding_box;
/// @}
typedef typename GeomTraits::Circle_2 Circle_2;
typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2;
typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_2;
typedef typename GeomTraits::Construct_center_2 Construct_center_2;
typedef typename GeomTraits::Compute_squared_radius_2 Compute_squared_radius_2;
typedef typename GeomTraits::Construct_min_vertex_2 Construct_min_vertex_2;
typedef typename GeomTraits::Construct_max_vertex_2 Construct_max_vertex_2;
typedef typename GeomTraits::Construct_iso_rectangle_2 Construct_iso_rectangle_2;
BboxMap bbm;
/// Default constructor.
AABB_traits_2() { }
AABB_traits_2(BboxMap bbm)
: bbm(bbm)
{}
typedef typename GeomTraits::Compute_squared_distance_2 Squared_distance;
Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_2_object(); }
typedef typename GeomTraits::Equal_2 Equal;
Equal equal_object() const { return GeomTraits().equal_2_object(); }
/**
* @internal
* @brief Sorts [first,beyond[
* @param first iterator on first element
* @param beyond iterator on beyond element
* @param bbox the bounding box of [first,beyond[
*
* Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest
* axis, using the comparison function `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
void operator()(PrimitiveIterator first,
PrimitiveIterator beyond,
const typename AT::Bounding_box& bbox) const
{
PrimitiveIterator middle = first + (beyond - first)/2;
switch(Traits::longest_axis(bbox))
{
case AT::CGAL_AXIS_X: // sort along x
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Y: // sort along y
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); });
break;
default:
CGAL_error();
}
}
};
Split_primitives split_primitives_object() const {return Split_primitives(*this);}
/*
* Computes the bounding box of a set of primitives
* @param first an iterator on the first primitive
* @param beyond an iterator on the past-the-end primitive
* @return the bounding box of the primitives of the iterator range
*/
class Compute_bbox {
const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
typename AT::Bounding_box operator()(ConstPrimitiveIterator first,
ConstPrimitiveIterator beyond) const
{
typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm);
for(++first; first != beyond; ++first)
{
bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm);
}
return bbox;
}
};
Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);}
/// \brief Function object using `GeomTraits::Do_intersect`.
/// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()`
/// function of this tree is used.
class Do_intersect {
const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_2_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_2_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Bounding_box& bbox) const
{
return other_tree.do_intersect(bbox);
}
};
Do_intersect do_intersect_object() const {return Do_intersect(*this);}
class Intersection {
const AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_2_object()(query, internal::Primitive_helper<AT>::get_datum(primitive,m_traits));
if (!inter_res)
return std::nullopt;
return std::make_optional( std::make_pair(*inter_res, primitive.id()) );
}
};
Intersection intersection_object() const {return Intersection(*this);}
// This should go down to the GeomTraits, i.e. the kernel
class Closest_point {
typedef typename AT::Point Point;
typedef typename AT::Primitive Primitive;
const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
: m_traits(traits) {}
Point operator()(const Point& p, const Primitive& pr, const Point& bound) const
{
GeomTraits geom_traits;
Point closest_point = geom_traits.construct_projected_point_2_object()(
internal::Primitive_helper<AT>::get_datum(pr,m_traits), p);
return (geom_traits.compare_distance_2_object()(p, closest_point, bound) == LARGER) ?
bound : closest_point;
}
};
// This should go down to the GeomTraits, i.e. the kernel
// and the internal implementation should change its name from
// do_intersect to something like does_contain (this is what we compute,
// this is not the same do_intersect as the spherical kernel)
class Compare_distance {
typedef typename AT::Point Point;
typedef typename AT::FT FT;
typedef typename AT::Primitive Primitive;
public:
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const
{
return GeomTraits().do_intersect_2_object()
(GeomTraits().construct_circle_2_object()
(p, GeomTraits().compute_squared_distance_2_object()(p, bound)), bb,true)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const
{
return GeomTraits().do_intersect_2_object()
(GeomTraits().construct_circle_2_object()
(p, GeomTraits().compute_squared_distance_2_object()(p, bound)), bb)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const
{
return (*this)(p, bb, bound, Boolean_tag<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
{
return GeomTraits().do_intersect_2_object()
(GeomTraits().construct_circle_2_object()
(p, GeomTraits().compute_squared_distance_2_object()(p, bound)), pr)?
CGAL::SMALLER : CGAL::LARGER;
}
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
{
return GeomTraits().do_intersect_2_object()
(GeomTraits().construct_circle_2_object()(p, sq_distance),
pr) ?
CGAL::SMALLER :
CGAL::LARGER;
}
};
Closest_point closest_point_object() const {return Closest_point(*this);}
Compare_distance compare_distance_object() const {return Compare_distance();}
typedef enum { CGAL_AXIS_X = 0,
CGAL_AXIS_Y = 1} Axis;
static Axis longest_axis(const Bounding_box& bbox);
private:
/**
* @brief Computes bounding box of one primitive
* @param pr the primitive
* @return the bounding box of the primitive \c pr
*/
template <typename PM>
Bounding_box compute_bbox(const Primitive& pr, const PM&)const
{
return get(bbm, pr.id());
}
Bounding_box compute_bbox(const Primitive& pr, const Default&)const
{
return GeomTraits().construct_bbox_2_object()(internal::Primitive_helper<AT>::get_datum(pr, *this));
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_2_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_2_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits_2
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits_2<GT,P,B>::Axis
AABB_traits_2<GT,P,B>::longest_axis(const Bounding_box& bbox)
{
const double dx = bbox.xmax() - bbox.xmin();
const double dy = bbox.ymax() - bbox.ymin();
if(dx>=dy)
{
return CGAL_AXIS_X;
}
else
{
return CGAL_AXIS_Y;
}
}
/// @}
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRAITS_2_H_

View File

@ -0,0 +1,532 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#ifndef CGAL_AABB_TRAITS_3_H_
#define CGAL_AABB_TRAITS_3_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/Search_traits_3.h>
#include <optional>
/// \file AABB_traits_3.h
namespace CGAL {
namespace internal {
namespace AABB_tree {
// AABB_traits_intersection_base_3 brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits<GeomTraits>::value>
struct AABB_traits_intersection_base_3;
template <typename GeomTraits>
struct AABB_traits_intersection_base_3<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_intersection_base_3<GeomTraits, true> {
template<class, class>
friend class AABB_ray_intersection;
private:
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::FT FT;
// Defining Bounding_box and other types from the full AABB_traits_3
// here might seem strange, but otherwise we would need to use
// CRTP to get access to the derived class, which would bloat the
// code more.
typedef typename CGAL::Bbox_3 Bounding_box;
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator;
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator;
Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() {
return GeomTraits().construct_cartesian_const_iterator_3_object();
}
public:
typedef typename GeomTraits::Ray_3 Ray;
typedef typename GeomTraits::Vector_3 Vector;
typedef typename GeomTraits::Construct_source_3 Construct_source;
typedef typename GeomTraits::Construct_vector_3 Construct_vector;
Construct_source construct_source_object() {
return GeomTraits().construct_source_3_object();
}
Construct_vector construct_vector_object() {
return GeomTraits().construct_vector_3_object();
}
struct Intersection_distance {
std::optional<FT> operator()(const Ray& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;
const Construct_cartesian_const_iterator construct_cartesian_const_iterator
= GeomTraits().construct_cartesian_const_iterator_3_object();
const Construct_source construct_source = GeomTraits().construct_source_3_object();
const Construct_vector construct_vector = GeomTraits().construct_vector_3_object();
const Point source = construct_source(ray);
const Vector direction = construct_vector(ray);
Cartesian_const_iterator source_iter = construct_cartesian_const_iterator(source);
Cartesian_const_iterator direction_iter = construct_cartesian_const_iterator(direction);
for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) {
if(*direction_iter == 0) {
if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) {
return std::nullopt;
}
} else {
FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter;
FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter;
t_near = (std::max)(t_near, (std::min)(t1, t2));
t_far = (std::min)(t_far, (std::max)(t1, t2));
if(t_near > t_far || t_far < FT(0.))
return std::nullopt;
}
}
if(t_near < FT(0.))
return FT(0.);
else
return t_near;
}
};
Intersection_distance intersection_distance_object() const { return Intersection_distance(); }
};
} } //end of namespace internal::AABB_tree
/// \addtogroup PkgAABBTreeRef
/// @{
// forward declaration
template< typename AABBTraits>
class AABB_tree;
/// This traits class handles any type of 3D geometric
/// primitives provided that the proper intersection tests and
/// constructions are implemented. It handles points, rays, lines and
/// segments as query types for intersection detection and
/// computations, and it handles points as query type for distance
/// queries.
///
/// \cgalModels{AABBTraits,AABBRayIntersectionTraits}
///
/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits_3,
/// and provide the geometric types as well as the intersection tests and computations.
/// \tparam Primitive provide the type of primitives stored in the AABB_tree.
/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`.
///
/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id,
/// and as value type a `Bounding_box`.
/// If the type is `Default` the `Datum` must have the
/// member function `bbox()` that returns the bounding box of the primitive.
///
/// If the argument `GeomTraits` is a model of the concept \ref
/// AABBRayIntersectionGeomTraits_3, this class is also a model of \ref
/// AABBRayIntersectionTraits.
///
/// \sa `AABBTraits`
/// \sa `AABB_tree`
/// \sa `AABBPrimitive`
/// \sa `AABBPrimitiveWithSharedData`
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits_3
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_intersection_base_3<GeomTraits>,
public Search_traits_3<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
public:
typedef GeomTraits Geom_traits;
typedef AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_3>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};
// types for search tree
/// \name Types
/// @{
/// Point type
typedef typename GeomTraits::Point_3 Point; // because the AABB_tree is dimension agnostic
/// Deprecated point type
typedef typename GeomTraits::Point_3 Point_3; // kept for backward compatibility
/// additional types for the search tree, required by the RangeSearchTraits concept
/// \bug This is not documented for now in the AABBTraits concept.
typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3;
/// Bounding box type.
typedef typename CGAL::Bbox_3 Bounding_box;
/// @}
typedef typename GeomTraits::Sphere_3 Sphere_3;
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3;
typedef typename GeomTraits::Construct_center_3 Construct_center_3;
typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3;
typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3;
typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3;
typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3;
BboxMap bbm;
/// Default constructor.
AABB_traits_3() { }
AABB_traits_3(BboxMap bbm)
: bbm(bbm)
{}
typedef typename GeomTraits::Compute_squared_distance_3 Squared_distance;
Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_3_object(); }
typedef typename GeomTraits::Equal_3 Equal;
Equal equal_object() const { return GeomTraits().equal_3_object(); }
/**
* @internal
* @brief Sorts [first,beyond[
* @param first iterator on first element
* @param beyond iterator on beyond element
* @param bbox the bounding box of [first,beyond[
*
* Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest
* axis, using the comparison function `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
void operator()(PrimitiveIterator first,
PrimitiveIterator beyond,
const typename AT::Bounding_box& bbox) const
{
PrimitiveIterator middle = first + (beyond - first)/2;
switch(Traits::longest_axis(bbox))
{
case AT::CGAL_AXIS_X: // sort along x
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Y: // sort along y
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Z: // sort along z
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); });
break;
default:
CGAL_error();
}
}
};
Split_primitives split_primitives_object() const {return Split_primitives(*this);}
/*
* Computes the bounding box of a set of primitives
* @param first an iterator on the first primitive
* @param beyond an iterator on the past-the-end primitive
* @return the bounding box of the primitives of the iterator range
*/
class Compute_bbox {
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
typename AT::Bounding_box operator()(ConstPrimitiveIterator first,
ConstPrimitiveIterator beyond) const
{
typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm);
for(++first; first != beyond; ++first)
{
bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm);
}
return bbox;
}
};
Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);}
/// \brief Function object using `GeomTraits::Do_intersect`.
/// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()`
/// function of this tree is used.
class Do_intersect {
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_3_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Bounding_box& bbox) const
{
return other_tree.do_intersect(bbox);
}
};
Do_intersect do_intersect_object() const {return Do_intersect(*this);}
class Intersection {
const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper<AT>::get_datum(primitive,m_traits));
if (!inter_res)
return std::nullopt;
return std::make_optional( std::make_pair(*inter_res, primitive.id()) );
}
};
Intersection intersection_object() const {return Intersection(*this);}
// This should go down to the GeomTraits, i.e. the kernel
class Closest_point {
typedef typename AT::Point Point;
typedef typename AT::Primitive Primitive;
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
: m_traits(traits) {}
Point operator()(const Point& p, const Primitive& pr, const Point& bound) const
{
GeomTraits geom_traits;
Point closest_point = geom_traits.construct_projected_point_3_object()(
internal::Primitive_helper<AT>::get_datum(pr,m_traits), p);
return (geom_traits.compare_distance_3_object()(p, closest_point, bound) == LARGER) ?
bound : closest_point;
}
};
// This should go down to the GeomTraits, i.e. the kernel
// and the internal implementation should change its name from
// do_intersect to something like does_contain (this is what we compute,
// this is not the same do_intersect as the spherical kernel)
class Compare_distance {
typedef typename AT::Point Point;
typedef typename AT::FT FT;
typedef typename AT::Primitive Primitive;
public:
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb)?
CGAL::SMALLER : CGAL::LARGER;
}
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const
{
return (*this)(p, bb, bound, Boolean_tag<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr)?
CGAL::SMALLER : CGAL::LARGER;
}
template <class Solid>
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
{
return GeomTraits().do_intersect_3_object()
(GeomTraits().construct_sphere_3_object()(p, sq_distance),
pr) ?
CGAL::SMALLER :
CGAL::LARGER;
}
};
Closest_point closest_point_object() const {return Closest_point(*this);}
Compare_distance compare_distance_object() const {return Compare_distance();}
typedef enum { CGAL_AXIS_X = 0,
CGAL_AXIS_Y = 1,
CGAL_AXIS_Z = 2} Axis;
static Axis longest_axis(const Bounding_box& bbox);
private:
/**
* @brief Computes bounding box of one primitive
* @param pr the primitive
* @return the bounding box of the primitive \c pr
*/
template <typename PM>
Bounding_box compute_bbox(const Primitive& pr, const PM&)const
{
return get(bbm, pr.id());
}
Bounding_box compute_bbox(const Primitive& pr, const Default&)const
{
return internal::Primitive_helper<AT>::get_datum(pr,*this).bbox();
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_z_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits_3
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits_3<GT,P,B>::Axis
AABB_traits_3<GT,P,B>::longest_axis(const Bounding_box& bbox)
{
const double dx = bbox.xmax() - bbox.xmin();
const double dy = bbox.ymax() - bbox.ymin();
const double dz = bbox.zmax() - bbox.zmin();
if(dx>=dy)
{
if(dx>=dz)
{
return CGAL_AXIS_X;
}
else // dz>dx and dx>=dy
{
return CGAL_AXIS_Z;
}
}
else // dy>dx
{
if(dy>=dz)
{
return CGAL_AXIS_Y;
}
else // dz>dy and dy>dx
{
return CGAL_AXIS_Z;
}
}
}
/// @}
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRAITS_3_H_

View File

@ -26,8 +26,7 @@
#include <CGAL/AABB_tree/internal/AABB_search_tree.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <boost/optional.hpp>
#include <boost/lambda/lambda.hpp>
#include <optional>
#ifdef CGAL_HAS_THREADS
#include <CGAL/mutex.h>
@ -42,9 +41,9 @@ namespace CGAL {
/**
* Static data structure for efficient
* intersection and distance computations in 3D. It builds a
* intersection and distance computations in 2D and 3D. It builds a
* hierarchy of axis-aligned bounding boxes (an AABB tree) from a set
* of 3D geometric objects, and can receive intersection and distance
* of geometric objects, and can receive intersection and distance
* queries, provided that the corresponding predicates are
* implemented in the traits class AABBTraits.
* An instance of the class `AABBTraits` is internally stored.
@ -75,9 +74,8 @@ namespace CGAL {
/// Number type returned by the distance queries.
typedef typename AABBTraits::FT FT;
/// Type of 3D point.
typedef typename AABBTraits::Point_3 Point;
/// Type of point.
typedef typename AABBTraits::Point Point;
/// Type of input primitive.
typedef typename AABBTraits::Primitive Primitive;
@ -87,7 +85,7 @@ namespace CGAL {
typedef typename Primitives::size_type size_type;
/// Type of bounding box.
typedef typename AABBTraits::Bounding_box Bounding_box;
/// 3D Point and Primitive Id type
/// Point and Primitive Id type
typedef typename AABBTraits::Point_and_primitive_id Point_and_primitive_id;
/// \deprecated
typedef typename AABBTraits::Object_and_primitive_id Object_and_primitive_id;
@ -126,7 +124,7 @@ namespace CGAL {
Self& operator=(const Self&) = delete;
/**
* @brief Builds the data structure from a sequence of primitives.
* @brief builds the data structure from a sequence of primitives.
* @param first iterator over first primitive to insert
* @param beyond past-the-end iterator
*
@ -143,7 +141,7 @@ namespace CGAL {
/// An explicit call to `build()` must be made to ensure that the next call to
/// a query function will not trigger the construction of the data structure.
/// A call to `AABBTraits::set_shared_data(t...)` is made using the internally stored traits.
/// This procedure has a complexity of \f$O(n log(n))\f$, where \f$n\f$ is the number of
/// This procedure has a complexity of \cgalBigO{n log(n)}, where \f$n\f$ is the number of
/// primitives of the tree.
template<typename ... T>
void build(T&& ...);
@ -271,7 +269,7 @@ public:
/// \tparam Query must be a type for which `Do_intersect` operators are
/// defined in the traits class `AABBTraits`.
template <typename Query>
boost::optional<Primitive_id> any_intersected_primitive(const Query& query) const;
std::optional<Primitive_id> any_intersected_primitive(const Query& query) const;
///@}
/// \name Intersections
@ -294,14 +292,14 @@ public:
/// \tparam Query must be a type for which `Do_intersect` and `Intersection` operators are
/// defined in the traits class `AABBTraits`.
template <typename Query>
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
std::optional< typename Intersection_and_primitive_id<Query>::Type >
any_intersection(const Query& query) const;
/// returns the intersection and primitive id closest to the source point of the ray
/// query.
/// \tparam Ray must be the same as `AABBTraits::Ray_3` and
/// \tparam Ray must be the same as `AABBTraits::Ray` and
/// `do_intersect` predicates and intersections for it must be
/// defined.
/// \tparam Skip a functor with an operator
@ -318,21 +316,21 @@ public:
/// `AABBTraits` must be a model of `AABBRayIntersectionTraits` to
/// call this member function.
template<typename Ray, typename SkipFunctor>
boost::optional< typename Intersection_and_primitive_id<Ray>::Type >
std::optional< typename Intersection_and_primitive_id<Ray>::Type >
first_intersection(const Ray& query, const SkipFunctor& skip) const;
/// \cond
template<typename Ray>
boost::optional< typename Intersection_and_primitive_id<Ray>::Type >
std::optional< typename Intersection_and_primitive_id<Ray>::Type >
first_intersection(const Ray& query) const
{
return first_intersection(query, boost::lambda::constant(false));
return first_intersection(query, [](Primitive_id){ return false; });
}
/// \endcond
/// returns the primitive id closest to the source point of the ray
/// query.
/// \tparam Ray must be the same as `AABBTraits::Ray_3` and
/// \tparam Ray must be the same as `AABBTraits::Ray` and
/// `do_intersect` predicates and intersections for it must be
/// defined.
/// \tparam Skip a functor with an operator
@ -343,15 +341,15 @@ public:
/// `AABBTraits` must be a model of `AABBRayIntersectionTraits` to
/// call this member function.
template<typename Ray, typename SkipFunctor>
boost::optional<Primitive_id>
std::optional<Primitive_id>
first_intersected_primitive(const Ray& query, const SkipFunctor& skip) const;
/// \cond
template<typename Ray>
boost::optional<Primitive_id>
std::optional<Primitive_id>
first_intersected_primitive(const Ray& query) const
{
return first_intersected_primitive(query, boost::lambda::constant(false));
return first_intersected_primitive(query, [](Primitive_id){ return false; });
}
/// \endcond
///@}
@ -553,7 +551,7 @@ public:
traits.intersection(query, singleton_data());
break;
default: // if(size() >= 2)
root_node()->template traversal_with_priority_and_group_traversal(m_primitives, query, traits, m_primitives.size(), 0, group_traversal_bound);
root_node()->traversal_with_priority_and_group_traversal(m_primitives, query, traits, m_primitives.size(), 0, group_traversal_bound);
}
}
@ -964,7 +962,7 @@ public:
template <typename Tr>
template <typename Query>
boost::optional< typename AABB_tree<Tr>::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABB_tree<Tr>::template Intersection_and_primitive_id<Query>::Type >
AABB_tree<Tr>::any_intersection(const Query& query) const
{
using namespace CGAL::internal::AABB_tree;
@ -976,7 +974,7 @@ public:
template <typename Tr>
template <typename Query>
boost::optional<typename AABB_tree<Tr>::Primitive_id>
std::optional<typename AABB_tree<Tr>::Primitive_id>
AABB_tree<Tr>::any_intersected_primitive(const Query& query) const
{
using namespace CGAL::internal::AABB_tree;

View File

@ -56,7 +56,7 @@ public:
/**
* @brief General traversal query
* @param query the query
* @param traits the traversal traits that define the traversal behaviour
* @param traits the traversal traits that define the traversal behavior
* @param nb_primitives the number of primitive
*
* General traversal query. The traits class allows using it for the various

View File

@ -19,8 +19,7 @@
#include <functional>
#include <type_traits>
#include <boost/optional.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <optional>
# if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4996)
@ -37,20 +36,23 @@ namespace CGAL {
template<typename AABBTree, typename SkipFunctor>
class AABB_ray_intersection {
typedef typename AABBTree::AABB_traits AABB_traits;
typedef typename AABB_traits::Ray_3 Ray;
static const int dimension = AABB_traits::Point::Ambient_dimension::value;
typedef typename AABB_traits::Ray Ray;
typedef typename AABB_traits::Vector Vector;
typedef typename AABBTree::template Intersection_and_primitive_id<Ray>::Type Ray_intersection_and_primitive_id;
typedef typename Ray_intersection_and_primitive_id::first_type Ray_intersection;
public:
AABB_ray_intersection(const AABBTree& tree) : tree_(tree) {}
boost::optional< Ray_intersection_and_primitive_id >
std::optional< Ray_intersection_and_primitive_id >
ray_intersection(const Ray& query, SkipFunctor skip) const {
// We hit the root, now continue on the children. Keep track of
// nb_primitives through a variable in each Node on the stack. In
// BVH_node::traversal this is done through the function parameter
// nb_primitives in the recursion.
typedef
boost::heap::priority_queue< Node_ptr_with_ft, boost::heap::compare< std::greater<Node_ptr_with_ft> > >
typedef boost::heap::priority_queue< Node_ptr_with_ft, boost::heap::compare< std::greater<Node_ptr_with_ft> > >
Heap_type;
typename AABB_traits::Intersection
@ -63,7 +65,7 @@ public:
Heap_type pq;
// pq.reserve(tree_.size() / 2);
boost::optional< Ray_intersection_and_primitive_id >
std::optional< Ray_intersection_and_primitive_id >
intersection, /* the temporary for calculating the result */
p; /* the current best intersection */
@ -84,7 +86,7 @@ public:
if(!skip(current.node->left_data().id()) /* && do_intersect_obj(query, current.node->left_data()) */) {
intersection = intersection_obj(query, current.node->left_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
@ -96,7 +98,7 @@ public:
if(!skip(current.node->right_data().id()) /* && do_intersect_obj(query, current.node->right_data()) */) {
intersection = intersection_obj(query, current.node->right_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
@ -111,7 +113,7 @@ public:
if(!skip(current.node->left_data().id()) /* && do_intersect_obj(query, current.node->left_data()) */) {
intersection = intersection_obj(query, current.node->left_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
@ -121,7 +123,7 @@ public:
// right child
const Node* child = &(current.node->right_child());
boost::optional< FT > dist = intersection_distance_obj(query, child->bbox());
std::optional< FT > dist = intersection_distance_obj(query, child->bbox());
if(dist)
pq.push(Node_ptr_with_ft(child, *dist, 2));
@ -130,7 +132,7 @@ public:
default: // Children both inner nodes
{
const Node* child = &(current.node->left_child());
boost::optional<FT> dist = intersection_distance_obj(query, child->bbox());
std::optional<FT> dist = intersection_distance_obj(query, child->bbox());
if(dist)
pq.push(Node_ptr_with_ft(child, *dist, current.nb_primitives/2));
@ -168,8 +170,8 @@ private:
as_ray_param_visitor(const Ray* ray)
: ray(ray), max_i(0)
{
typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector();
for (int i=1; i<3; ++i)
Vector v = AABB_traits().construct_vector_object()(*ray);
for (int i=1; i<dimension; ++i)
if( CGAL::abs(v[i]) > CGAL::abs(v[max_i]) )
max_i = i;
}
@ -185,8 +187,8 @@ private:
}
FT operator()(const Point& point) {
typename AABB_traits::Geom_traits::Vector_3 x(ray->source(), point);
typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector();
Vector x = Vector(AABB_traits().construct_source_object()(*ray), point);
Vector v = AABB_traits().construct_vector_object()(*ray);
return x[max_i] / v[max_i];
}
@ -198,11 +200,11 @@ private:
template<typename AABBTraits>
template<typename Ray, typename SkipFunctor>
boost::optional< typename AABB_tree<AABBTraits>::template Intersection_and_primitive_id<Ray>::Type >
std::optional< typename AABB_tree<AABBTraits>::template Intersection_and_primitive_id<Ray>::Type >
AABB_tree<AABBTraits>::first_intersection(const Ray& query,
const SkipFunctor& skip) const {
CGAL_static_assertion_msg((std::is_same<Ray, typename AABBTraits::Ray_3>::value),
"Ray and Ray_3 must be the same type");
static_assert(std::is_same<Ray, typename AABBTraits::Ray>::value,
"Ray and AABBTraits::Ray must be the same type");
switch(size()) // copy-paste from AABB_tree::traversal
{
@ -219,22 +221,22 @@ AABB_tree<AABBTraits>::first_intersection(const Ray& query,
break;
}
}
return boost::none;
return std::nullopt;
}
template<typename AABBTraits>
template<typename Ray, typename SkipFunctor>
boost::optional<typename AABB_tree<AABBTraits>::Primitive_id>
std::optional<typename AABB_tree<AABBTraits>::Primitive_id>
AABB_tree<AABBTraits>::first_intersected_primitive(const Ray& query,
const SkipFunctor& skip) const
{
boost::optional<
std::optional<
typename AABB_tree<AABBTraits>::
template Intersection_and_primitive_id<Ray>::Type > res =
first_intersection(query, skip);
if ( (bool) res )
return boost::make_optional( res->second );
return boost::none;
return std::make_optional( res->second );
return std::nullopt;
}
}

View File

@ -15,110 +15,60 @@
#include <CGAL/license/AABB_tree.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_3.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/property_map.h>
namespace CGAL
{
template <class Underlying, class Id>
class Add_decorated_point: public Underlying
{
class Decorated_point: public Underlying::Point_3
{
public:
const Id& id() const { return m_id; }
Decorated_point()
: Underlying::Point_3()
, m_id()
, m_is_id_initialized(false) {}
template <class Traits>
struct AABB_search_tree
{
// Allows the user not to provide the id
// so that we don't break existing code
Decorated_point(const typename Underlying::Point_3& p)
: Underlying::Point_3(p)
, m_id()
, m_is_id_initialized(false) {}
typedef typename Traits::Point_and_primitive_id Point_and_primitive_id;
typedef typename Point_and_primitive_id::first_type Point;
typedef typename Point_and_primitive_id::second_type Id;
typedef First_of_pair_property_map<Point_and_primitive_id> Pmap;
typedef Search_traits_adapter<Point_and_primitive_id, Pmap, Traits> TreeTraits;
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
typedef typename Neighbor_search::Tree Tree;
private:
Tree m_tree;
Decorated_point(const typename Underlying::Point_3& p,
const Id& id)
: Underlying::Point_3(p)
, m_id(id)
, m_is_id_initialized(true) {}
Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p)
{
return p;
}
Decorated_point(const Decorated_point& rhs)
: Underlying::Point_3(rhs)
, m_id()
, m_is_id_initialized(rhs.m_is_id_initialized)
{
if ( m_is_id_initialized )
m_id = rhs.m_id;
}
Point_and_primitive_id get_p_and_p(const Point& p)
{
return Point_and_primitive_id(p, Id());
}
Decorated_point& operator=(const Decorated_point&)=default;
private:
Id m_id;
public:
template <class ConstPointIterator>
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
: m_tree{}
{
std::vector<Point_and_primitive_id> points;
while (begin != beyond) {
Point_and_primitive_id pp = get_p_and_p(*begin);
points.emplace_back(pp);
++begin;
}
m_tree.insert(points.begin(), points.end());
m_tree.build();
}
// Needed to avoid exception (depending on Id type)
// "error: attempt to copy-construct an iterator from a singular iterator."
// This exception may appear if we copy-construct an Id
// which has Id() as value (It is done when constructing
// Neighbor_search since we pass the Point only as query)
bool m_is_id_initialized;
};
public:
typedef Decorated_point Point_3;
};
template <class Traits>
class AABB_search_tree
{
public:
typedef typename Traits::FT FT;
typedef typename Traits::Point_3 Point;
typedef typename Traits::Primitive Primitive;
typedef typename Traits::Point_and_primitive_id Point_and_primitive_id;
typedef typename CGAL::Search_traits_3<Add_decorated_point<Traits, typename Traits::Primitive::Id> > TreeTraits;
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
typedef typename Neighbor_search::Tree Tree;
private:
Tree m_tree;
Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p)
{
return p;
}
Point_and_primitive_id get_p_and_p(const Point& p)
{
return Point_and_primitive_id(p, typename Primitive::Id());
}
public:
template <class ConstPointIterator>
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
: m_tree{}
{
typedef typename Add_decorated_point<Traits,typename Traits::Primitive::Id>::Point_3 Decorated_point;
std::vector<Decorated_point> points;
while(begin != beyond) {
Point_and_primitive_id pp = get_p_and_p(*begin);
points.emplace_back(pp.first, pp.second);
++begin;
}
m_tree.insert(points.begin(), points.end());
m_tree.build();
}
Point_and_primitive_id closest_point(const Point& query) const
{
Neighbor_search search(m_tree, query, 1);
return Point_and_primitive_id(static_cast<Point>(search.begin()->first), search.begin()->first.id());
}
};
template <typename Point>
Point_and_primitive_id closest_point(const Point& query) const
{
Neighbor_search search(m_tree, query, 1);
return search.begin()->first;
}
};
}
#endif // CGAL_AABB_SEARCH_TREE_H

View File

@ -0,0 +1,47 @@
// Copyright (c) 2024 INRIA Sophia-Antipolis (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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#ifndef CGAL_AABB_TRAITS_BASE_H
#define CGAL_AABB_TRAITS_BASE_H
#include <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
namespace CGAL {
namespace internal {
namespace AABB_tree {
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data = Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive, false> {};
template <class Primitive>
struct AABB_traits_base<Primitive, true> {
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t) {
m_primitive_data = Primitive::construct_shared_data(std::forward<T>(t)...);
}
const typename Primitive::Shared_data& shared_data() const { return m_primitive_data; }
};
}
}
}
#endif

View File

@ -17,7 +17,7 @@
#include <CGAL/AABB_tree/internal/AABB_node.h>
#include <boost/optional.hpp>
#include <optional>
namespace CGAL {
@ -59,7 +59,7 @@ template<typename AABBTraits, typename Query>
class First_intersection_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -69,11 +69,11 @@ class First_intersection_traits
public:
typedef
boost::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
Result;
public:
First_intersection_traits(const AABBTraits& traits)
: m_result(), m_traits(traits)
: m_result(std::nullopt), m_traits(traits)
{}
bool go_further() const {
@ -108,7 +108,7 @@ template<typename AABBTraits, typename Query, typename Output_iterator>
class Listing_intersection_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -124,7 +124,7 @@ public:
void intersection(const Query& query, const Primitive& primitive)
{
boost::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
intersection = m_traits.intersection_object()(query, primitive);
if(intersection)
@ -151,7 +151,7 @@ template<typename AABBTraits, typename Query, typename Output_iterator>
class Listing_primitive_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -191,7 +191,7 @@ template<typename AABBTraits, typename Query>
class First_primitive_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -202,7 +202,7 @@ class First_primitive_traits
public:
First_primitive_traits(const AABBTraits& traits)
: m_is_found(false)
, m_result()
, m_result(std::nullopt)
, m_traits(traits) {}
bool go_further() const { return !m_is_found; }
@ -211,7 +211,7 @@ public:
{
if( m_traits.do_intersect_object()(query, primitive) )
{
m_result = boost::optional<typename Primitive::Id>(primitive.id());
m_result = std::optional<typename Primitive::Id>(primitive.id());
m_is_found = true;
}
}
@ -221,12 +221,12 @@ public:
return m_traits.do_intersect_object()(query, node.bbox());
}
boost::optional<typename Primitive::Id> result() const { return m_result; }
std::optional<typename Primitive::Id> result() const { return m_result; }
bool is_intersection_found() const { return m_is_found; }
private:
bool m_is_found;
boost::optional<typename Primitive::Id> m_result;
std::optional<typename Primitive::Id> m_result;
const AABBTraits& m_traits;
};
@ -237,7 +237,7 @@ template<typename AABBTraits, typename Query>
class Do_intersect_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -278,7 +278,7 @@ template <typename AABBTraits>
class Projection_traits
{
typedef typename AABBTraits::FT FT;
typedef typename AABBTraits::Point_3 Point;
typedef typename AABBTraits::Point Point;
typedef typename AABBTraits::Primitive Primitive;
typedef typename AABBTraits::Bounding_box Bounding_box;
typedef typename AABBTraits::Primitive::Id Primitive_id;
@ -301,7 +301,7 @@ public:
{
Point new_closest_point = m_traits.closest_point_object()
(query, primitive, m_closest_point);
if( !m_traits.equal_3_object()(new_closest_point, m_closest_point) )
if( !m_traits.equal_object()(new_closest_point, m_closest_point) )
{
m_closest_primitive = primitive.id();
m_closest_point = new_closest_point; // this effectively shrinks the sphere

View File

@ -24,19 +24,34 @@ namespace CGAL {
namespace internal {
namespace AABB_tree {
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_3,Ray_3,false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_3,Construct_source_3,false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_3,Construct_vector_3,false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_3,Construct_cartesian_const_iterator_3,false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_3,Cartesian_const_iterator_3,false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_3, Ray_3, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_3, Construct_source_3, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_3, Construct_vector_3, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_3, Construct_cartesian_const_iterator_3, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_3, Cartesian_const_iterator_3, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_2, Ray_2, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_2, Construct_source_2, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_2, Construct_vector_2, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_2, Construct_cartesian_const_iterator_2, false)
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_2, Cartesian_const_iterator_2, false)
template<typename GeomTraits>
struct Is_ray_intersection_geomtraits_2
: std::bool_constant< Has_ray_2<GeomTraits>::value &&
Has_construct_source_2<GeomTraits>::value &&
Has_vector_2<GeomTraits>::value &&
Has_construct_cartesian_const_iterator_2<GeomTraits>::value &&
Has_cartesian_const_iterator_2<GeomTraits>::value >
{};
template<typename GeomTraits>
struct Is_ray_intersection_geomtraits
: boost::mpl::and_< Has_ray_3<GeomTraits>,
Has_construct_source_3<GeomTraits>,
Has_vector_3<GeomTraits>,
Has_construct_cartesian_const_iterator_3<GeomTraits>,
Has_cartesian_const_iterator_3<GeomTraits> >::type
: std::bool_constant< Has_ray_3<GeomTraits>::value&&
Has_construct_source_3<GeomTraits>::value&&
Has_vector_3<GeomTraits>::value&&
Has_construct_cartesian_const_iterator_3<GeomTraits>::value&&
Has_cartesian_const_iterator_3<GeomTraits>::value >
{};

View File

@ -0,0 +1,33 @@
// Copyright (c) 2024 INRIA Sophia-Antipolis (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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#ifndef CGAL_REMOVE_OPTIONAL_H_
#define CGAL_REMOVE_OPTIONAL_H_
#include <CGAL/license/AABB_tree.h>
#include <optional>
namespace CGAL {
namespace internal {
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::std::optional<T> > { typedef T type; };
} // end namespace internal
} // end namespace CGAL
#endif

View File

@ -19,7 +19,7 @@
#include <CGAL/AABB_tree/internal/AABB_traversal_traits.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/array.h>
#include <CGAL/Bbox_3.h>
@ -161,7 +161,7 @@ struct AABB_covered_triangle_tree_traits
CGAL::Tag_false /*no caching*/>;
using AABB_geom_traits = Kernel;
using AABB_traits = CGAL::AABB_traits<AABB_geom_traits, Primitive, BPM>;
using AABB_traits = CGAL::AABB_traits_3<AABB_geom_traits, Primitive, BPM>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
};

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (France).
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -11,92 +11,38 @@
// Author(s) : Sebastien Loriot
//
#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_triangle_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_triangle_primitive_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/AABB_triangle_primitive_3.h>
/// \file AABB_triangle_primitive.h
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Point_from_triangle_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_3>()(
// std::declval<typename GeomTraits::Triangle_3>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_3()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_3()( *it, 0 );
}
};
}//namespace internal
/// \addtogroup PkgAABBTreeRef
/// @{
/// template alias for backward compatibility
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 3D triangle as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels `AABBPrimitive`
*
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_triangle_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive(Iterator it) : Base(it){}
};
using AABB_triangle_primitive = AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>;
} // end namespace CGAL
///@}
#include <CGAL/enable_warnings.h>
} //CGAL namespace
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#endif // CGAL_NO_DEPRECATED_CODE
#endif //CGAL_AABB_TRIANGLE_PRIMITIVE_H_

View File

@ -0,0 +1,100 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (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) : Sebastien Loriot
//
#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Point_from_triangle_2_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_2 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_2>()(
// std::declval<typename GeomTraits::Triangle_2>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_2()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_2()( *it, 0 );
}
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 2D triangle as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Triangle_2`.
* It also provides the functor `Construct_vertex_2` that has an operator taking a `Triangle_2`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_2`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_2`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_triangle_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive_2(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_

View File

@ -0,0 +1,101 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (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) : Sebastien Loriot
//
#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Point_from_triangle_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_3>()(
// std::declval<typename GeomTraits::Triangle_3>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_3()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_3()( *it, 0 );
}
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* Primitive type that uses as identifier an iterator with a 3D triangle as `value_type`.
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels{AABBPrimitive}
*
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
* The default is `CGAL::Tag_false` (datum is not stored).
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_triangle_primitive_3
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive_3(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_

View File

@ -36,7 +36,7 @@ namespace CGAL
std::declval<int>())) reference;
// typedef decltype(
// typename GeomTraits::Construct_vertex_3()(
// *std::declval<key_type&>(), 0)) reference; // fails polyhedron demo!
// *std::declval<key_type&>(), 0)) reference; // fails CGAL Lab!
typedef boost::readable_property_map_tag category;
typedef Point_from_cell_iterator_proprety_map<GeomTraits, Iterator> Self;

View File

@ -28,7 +28,7 @@ namespace CGAL {
// the TriangleMesh from which the AABB tree is built should not be
// deleted while the AABB tree is in use.
//
// \cgalModels `AABBPrimitive`
// \cgalModels{AABBPrimitive}
// \tparam GeomTraits must provides a \c %Point_3
// type, used as \c Point, and a \c %Triangle_3 type, used as \c
// Datum and constructible from three arguments of type \c

View File

@ -1 +1 @@
Data structure for efficient intersection and distance queries over sets of 3D geometric primitives.
Data structure for efficient intersection and distance queries over sets of 2D and 3D geometric primitives.

View File

@ -1 +1 @@
This component implements a hierarchy of axis-aligned bounding boxes (a AABB tree) for efficient intersection and distance computations between 3D queries and sets of input 3D geometric objects.
This component implements a hierarchy of axis-aligned bounding boxes (a AABB tree) for efficient intersection and distance computations between 2D/3D queries and sets of input 2D/3D geometric objects.

View File

@ -95,20 +95,23 @@ void test_all_intersection_query_types(Tree& tree)
tree.all_intersected_primitives(segment,std::back_inserter(primitives));
// any_intersection
boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Ray>::Type > r = tree.any_intersection(ray);
boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Line>::Type > l = tree.any_intersection(line);
boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Segment>::Type > s = tree.any_intersection(segment);
std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Ray>::Type > r = tree.any_intersection(ray);
std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Line>::Type > l = tree.any_intersection(line);
std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Segment>::Type > s = tree.any_intersection(segment);
CGAL_USE(r);
CGAL_USE(l);
CGAL_USE(s);
// any_intersected_primitive
boost::optional<typename Primitive::Id> optional_primitive;
std::optional<typename Primitive::Id> optional_primitive;
optional_primitive = tree.any_intersected_primitive(ray);
optional_primitive = tree.any_intersected_primitive(line);
optional_primitive = tree.any_intersected_primitive(segment);
// all_intersections
std::list< boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Ray>::Type > > intersections_r;
std::list< boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Line>::Type > > intersections_l;
std::list< boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Segment>::Type > > intersections_s;
std::list< std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Ray>::Type > > intersections_r;
std::list< std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Line>::Type > > intersections_l;
std::list< std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Segment>::Type > > intersections_s;
tree.all_intersections(ray,std::back_inserter(intersections_r));
tree.all_intersections(line,std::back_inserter(intersections_l));
tree.all_intersections(segment,std::back_inserter(intersections_s));
@ -243,7 +246,7 @@ void test(const std::string filename,
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef Primitive_generator<Primitive,K,Polyhedron> Pr_generator;
typedef typename Pr_generator::Primitive Pr;
typedef CGAL::AABB_traits<K, Pr> Traits;
typedef CGAL::AABB_traits_3<K, Pr> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
Polyhedron polyhedron;
@ -313,16 +316,16 @@ class Naive_implementations
{
typedef Primitive_generator<Primitive,K,Polyhedron> Pr_generator;
typedef typename Pr_generator::Primitive Pr;
typedef CGAL::AABB_traits<K, Pr> Traits;
typedef CGAL::AABB_traits_3<K, Pr> Traits;
typedef typename Pr_generator::iterator Polyhedron_primitive_iterator;
typedef unsigned int size_type;
typedef typename Traits::Object_and_primitive_id Object_and_primitive_id;
typedef typename Pr::Id Primitive_id;
typedef typename Traits::FT FT;
typedef typename Traits::Point_3 Point;
typedef typename Traits::Point Point;
typedef typename Traits::Point_and_primitive_id Point_and_primitive_id;
typedef boost::optional<Object_and_primitive_id> Intersection_result;
typedef std::optional<Object_and_primitive_id> Intersection_result;
const Traits& m_traits;
public:
@ -380,7 +383,7 @@ public:
Polyhedron_primitive_iterator it = Pr_generator().begin(p);
for ( ; it != Pr_generator().end(p) ; ++it )
{
boost::optional< typename Traits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename Traits::template Intersection_and_primitive_id<Query>::Type >
intersection = m_traits.intersection_object()(query, Pr(it,p));
if ( intersection )
*out++ = *intersection;
@ -653,7 +656,7 @@ private:
}
// any_intersected_primitive test (do not count time here)
typedef boost::optional<typename Primitive::Id> Any_primitive;
typedef std::optional<typename Primitive::Id> Any_primitive;
Any_primitive primitive = tree.any_intersected_primitive(query);
// Check: verify we do get the result by naive method
@ -723,7 +726,7 @@ private:
}
// Any intersection test (do not count time here)
boost::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename Tree::AABB_traits::template Intersection_and_primitive_id<Query>::Type >
intersection = tree.any_intersection(query);
// Check: verify we do get the result by naive method

View File

@ -1,7 +1,7 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.23)
cmake_minimum_required(VERSION 3.12...3.29)
project(AABB_tree_Tests)
find_package(CGAL REQUIRED)

View File

@ -10,7 +10,7 @@
#include <CGAL/function_objects.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polyhedron_3.h>
@ -46,7 +46,7 @@ std::size_t intersect(ForwardIterator b, ForwardIterator e, const Tree& tree, lo
v.reserve(elements);
for(; b != e; ++b) {
tree.all_intersections(*b, std::back_inserter(v));
boost::optional<Obj_type> o = tree.any_intersection(*b);
std::optional<Obj_type> o = tree.any_intersection(*b);
if(o)
++counter;
}
@ -64,7 +64,7 @@ std::tuple<std::size_t, std::size_t, std::size_t, long> test(const char* name) {
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
std::ifstream ifs(name);

View File

@ -23,7 +23,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
template <class K>
@ -43,7 +43,7 @@ int test()
// construct tree from facets
typedef typename CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef typename CGAL::AABB_traits<K,Primitive> Traits;
typedef typename CGAL::AABB_traits_3<K,Primitive> Traits;
typedef typename CGAL::AABB_tree<Traits> Tree;
typedef typename Tree::Object_and_primitive_id Object_and_primitive_id;
Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron);
@ -65,7 +65,7 @@ int test()
return EXIT_FAILURE;
}
boost::optional<Object_and_primitive_id> any;
std::optional<Object_and_primitive_id> any;
any = tree.any_intersection(pq);
if(!any)
{

View File

@ -0,0 +1,56 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
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::list<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()
{
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::list<Segment> segments;
segments.push_back(Segment(a,b));
segments.push_back(Segment(a,c));
segments.push_back(Segment(c,d));
// constructs the AABB tree and the internal search tree for
// efficient distance computations.
Tree tree(segments.begin(),segments.end());
// counts #intersections with a plane query
Plane plane_query(a,b,d);
std::cout << tree.number_of_intersected_primitives(plane_query)
<< " intersections(s) with plane" << std::endl;
// counts #intersections with a triangle query
Triangle triangle_query(a,b,c);
std::cout << tree.number_of_intersected_primitives(triangle_query)
<< " intersections(s) with triangle" << std::endl;
// computes the closest point from a point query
Point point_query(2.0, 2.0, 2.0);
Point closest = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest << std::endl;
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,51 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
int main()
{
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::list<Triangle> triangles;
triangles.push_back(Triangle(a,b,c));
triangles.push_back(Triangle(a,b,d));
triangles.push_back(Triangle(a,d,c));
// constructs AABB tree
Tree tree(triangles.begin(),triangles.end());
// counts #intersections
Ray ray_query(a,b);
assert(tree.number_of_intersected_primitives(ray_query) != 0);
// compute closest point and squared distance
Point point_query(2.0, 2.0, 2.0);
Point closest_point = tree.closest_point(point_query);
std::cout << closest_point << std::endl;
FT sqd = tree.squared_distance(point_query);
std::cout << sqd << std::endl;
return EXIT_SUCCESS;
}

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