Skip to content

Commit

Permalink
merge master (WIP: need CGAL#8273)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrineau committed Jul 1, 2024
2 parents 6a45cc9 + ecbf98e commit 7f4928b
Show file tree
Hide file tree
Showing 1,181 changed files with 72,479 additions and 8,222 deletions.
2 changes: 1 addition & 1 deletion AABB_tree/benchmark/AABB_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
61 changes: 30 additions & 31 deletions AABB_tree/benchmark/AABB_tree/test.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#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>
#include <CGAL/Polygon_mesh_processing/transform.h>

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

Expand All @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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];
Expand All @@ -130,47 +139,37 @@ 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),
naive_inter(0), naive_no_inter(0), naive_include(0);
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;
}
2 changes: 1 addition & 1 deletion AABB_tree/demo/AABB_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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
Expand Down
10 changes: 5 additions & 5 deletions AABB_tree/demo/AABB_tree/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...";
Expand Down Expand Up @@ -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...";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions AABB_tree/demo/AABB_tree/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,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>
Expand Down Expand Up @@ -62,11 +62,11 @@ class Scene : public QObject

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;
Expand Down
Loading

0 comments on commit 7f4928b

Please sign in to comment.