Skip to content

Commit

Permalink
Merge branch 'master' into Aos_2-fixes-efif
Browse files Browse the repository at this point in the history
  • Loading branch information
efifogel committed Jan 8, 2024
2 parents cc35868 + 6df7424 commit 8a886ea
Show file tree
Hide file tree
Showing 491 changed files with 10,852 additions and 5,171 deletions.
9 changes: 4 additions & 5 deletions AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <iterator>
#include <boost/mpl/and.hpp>
#include <CGAL/type_traits/is_iterator.h>
#include <boost/mpl/if.hpp>

#include <CGAL/Default.h>

Expand Down Expand Up @@ -70,9 +69,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,
Expand All @@ -89,7 +88,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_3,Cartesian_const

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 >
{};


Expand Down
16 changes: 8 additions & 8 deletions Algebraic_foundations/include/CGAL/number_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,21 @@ root_of( int k, Input_iterator begin, Input_iterator end ) {
template< class Number_type >
inline
// select a Is_zero functor
typename boost::mpl::if_c<
::std::is_same< typename Algebraic_structure_traits< Number_type >::Is_zero,
Null_functor >::value ,
typename std::conditional_t<
std::is_same_v< typename Algebraic_structure_traits< Number_type >::Is_zero,
Null_functor >,
typename Real_embeddable_traits< Number_type >::Is_zero,
typename Algebraic_structure_traits< Number_type >::Is_zero
>::type::result_type
>::result_type
is_zero( const Number_type& x ) {
// We take the Algebraic_structure_traits<>::Is_zero functor by default. If it
// is not available, we take the Real_embeddable_traits functor
typename ::boost::mpl::if_c<
::std::is_same<
std::conditional_t<
std::is_same_v<
typename Algebraic_structure_traits< Number_type >::Is_zero,
Null_functor >::value ,
Null_functor > ,
typename Real_embeddable_traits< Number_type >::Is_zero,
typename Algebraic_structure_traits< Number_type >::Is_zero >::type
typename Algebraic_structure_traits< Number_type >::Is_zero >
is_zero;
return is_zero( x );
}
Expand Down
15 changes: 15 additions & 0 deletions Alpha_wrap_3/benchmark/Alpha_wrap_3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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.20)
project(Alpha_wrap_3_Benchmark)

find_package(CGAL REQUIRED)

include_directories (BEFORE ../../include ./Quality ./Robustness) # AW3 includes
include_directories (BEFORE ../../../CGAL-Patches/include)

# create a target per cppfile
create_single_source_cgal_program("Performance/performance_benchmark.cpp")
create_single_source_cgal_program("Quality/quality_benchmark.cpp")
create_single_source_cgal_program("Robustness/robustness_benchmark.cpp")
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2019-2023 Google LLC (USA).
# All rights reserved.
#
# This file is part of CGAL (www.cgal.org).
#
# $URL$
# $Id$
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
# Author(s) : Pierre Alliez
# Michael Hemmer
# Cedric Portaneri
#
#!/usr/bin/python

import os, sys, subprocess, datetime, time, getopt

def compute_performance_benchmark_data(execname, filename, alpha):

output = ""
cmd = ("/usr/bin/time", "-v",
execname, "-i",
filename, "-a", alpha)
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
start_new_session=True)

outs, errs = proc.communicate()
output = outs.decode("utf-8") + errs.decode("utf-8")

for output_line in output.split("\n"):
if "User time (seconds): " in output_line:
print(output_line[len("User time (seconds): "):])
continue
if "Maximum resident set size (kbytes): " in output_line:
print(output_line[len("Maximum resident set size (kbytes): "):])
continue

def main(argv):
execname=""
filename=""
alpha=""
try:
opts, args = getopt.getopt(sys.argv[1:], 'e:i:a:')
except getopt.GetoptError:
sys.exit(2)
for opt, arg in opts:
if opt == "-e":
execname = arg
elif opt == "-i":
filename = arg
elif opt == "-a":
alpha = arg

compute_performance_benchmark_data(execname, filename, alpha)

if __name__ == "__main__":
main(sys.argv[1:])
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Copyright (c) 2019-2023 Google LLC (USA).
# All rights reserved.
#
# This file is part of CGAL (www.cgal.org).
#
# $URL$
# $Id$
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
# Author(s) : Pierre Alliez
# Michael Hemmer
# Cedric Portaneri
#
#!/usr/bin/python

import os, sys, subprocess, datetime, time, signal, getopt
import numpy as np
import matplotlib.pyplot as plt

def main(argv):

inputdir=""
outputdir=""
commit_hash=""
alpha=""
do_diff=False
diffdir=""
diff_hash=""
try:
opts, args = getopt.getopt(sys.argv[1:], 'i:a:o:c:d:p:')
except getopt.GetoptError:
sys.exit(2)
for opt, arg in opts:
if opt == "-i":
inputdir = arg
elif opt == "-a":
alpha = arg
elif opt == "-o":
outputdir = arg
elif opt == "-c":
commit_hash = arg
elif opt == "-d":
diff_hash = arg
do_diff = True
elif opt == "-p":
diffdir = arg

all_metric = {
"Time_(second)" : {},
"Memory_Peak_(kbytes)" : {}}
num_input = 0
for filename in os.listdir(inputdir) :
new_path = os.path.join(inputdir,filename)
new_file = open(new_path)
is_empty_new = os.path.getsize(new_path) <= 1
if do_diff :
old_path = os.path.join(diffdir,filename)
old_file = open(old_path)
is_empty_old = os.path.getsize(old_path) <= 1
for key in all_metric:
if is_empty_new or is_empty_old :
new_val = 0.
old_val = 0.
else :
new_val = float(new_file.readline().rstrip('\n'))
old_val = float(old_file.readline().rstrip('\n'))
mesh_id = str(filename.split('.')[0])
all_metric[key][mesh_id] = [new_val, old_val]
else :
for key in all_metric:
if is_empty_new :
new_val = 0.
else :
new_val = float(new_file.readline().rstrip('\n'))
mesh_id = str(filename.split('.')[0])
all_metric[key][mesh_id] = [new_val, new_val]
num_input = num_input+1

# update .pdf chart
date_now = datetime.datetime.now()
date_for_filename = str(date_now.year) +"_"+ str(date_now.month) +"_"+ str(date_now.day) +"_"+ str(date_now.hour) +"h"+ str(date_now.minute) +"mn"
for key in all_metric:
goal = 0
num_el = range(len(all_metric[key]))
avg_diff_to_goal = 0.
avg = 0.
x1 = []
x2 = []
for value in all_metric[key].values() :
avg += value[0]
diff_to_goal = abs(value[1]-goal) - abs(value[0]-goal)
avg_diff_to_goal += diff_to_goal
x1.append(value[0])
x2.append(value[1])
avg_diff_to_goal /= float(len(all_metric[key]))
avg /= float(len(all_metric[key]))

plt.figure(figsize=(8,8))
if do_diff :
plt.hist(x2, bins=100, color='tab:green', alpha=0.5)
plt.hist(x1, bins=100, color='tab:blue', alpha=0.5)
plt.vlines(x = goal, ymin=plt.ylim()[0], ymax=plt.ylim()[1], linestyles='dashed')

title = ""
if do_diff :
title += "Diff between " + commit_hash + " and " + diff_hash + " on " + str(num_input) + " meshes from Thingi10K\nAlpha = Bbox diag length / " + alpha
else :
title += "Benchmarking on " + str(num_input) + " meshes from Thingi10K\nAlpha = Bbox diag length / " + alpha

avg_str = str(format(abs(avg), '.2f'))
if key == "Time_(second)" :
title += "\nIn average we spend " + avg_str + " seconds"
else :
title += "\nIn average we use up to " + avg_str + " kbytes"

if do_diff and avg_diff_to_goal == 0. :
title += "\nNo change between the two commits"
elif do_diff :
avg_diff_str = str(format(abs(avg_diff_to_goal), '.2f'))
if key == "Time_(second)" :
if avg_diff_to_goal < 0 :
title += "\nIn average we get slower by "
else :
title += "\nIn average we get faster "
title += avg_diff_str + " seconds"
else :
if avg_diff_to_goal < 0 :
title += "\nIn average we use " + avg_diff_str + " more"
else :
title += "\nIn average we use " + avg_diff_str + " less"
title += " kbytes"

plt.title(title, fontsize=15)
plt.xlabel(key.replace("_"," "), fontsize=14)
plt.ylabel("# of meshes", fontsize=14)
plt.tick_params(axis="x", labelsize=9)
plt.tick_params(axis="y", labelsize=9)

chart_filename = ""
if do_diff :
chart_filename += "diff_"+commit_hash+"_"+diff_hash+"_"+key+"_"+date_for_filename+".pdf"
else :
chart_filename += "results_"+commit_hash+"_"+key+"_"+date_for_filename+".pdf"
chart_path = os.path.join(outputdir+"/charts",chart_filename)
if os.path.isfile(chart_path) :
os.remove(chart_path)
plt.savefig(chart_path, bbox_inches="tight")
plt.close()

print("pdf updated")

sys.exit()

if __name__ == "__main__":
main(sys.argv[1:])
Loading

0 comments on commit 8a886ea

Please sign in to comment.