Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 3D barycentric coordinates for convex polyhedra #8267

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ad026eb
adding basic file structure
antoniospg May 25, 2021
de57b75
Created tetrahedron_coordinates_3 that contains the functions to calc…
antoniospg May 30, 2021
1f2daeb
Fixing cmakelist and updating package_info
antoniospg Jun 4, 2021
d96185b
fixing cmakelists of test and benchmark
antoniospg Jun 7, 2021
bd7fd2d
Created structure for wachspress coordinates
antoniospg Jun 7, 2021
ff89fdd
enhancing the code structure, ran some tests with circulators, proper…
antoniospg Jun 8, 2021
5ccfcdf
better api, barycentric_enums and tests with tetrahedrons in the new api
antoniospg Jun 9, 2021
f4c74d4
making WP3 constructor work with default pmesh params
danston Jun 10, 2021
ed81295
first part of the calculation of wp coordinates
antoniospg Jun 11, 2021
a72d2d6
FIRST FUNCTIONAL VERSIONgit add .git add .git add . Just implemented …
antoniospg Jun 11, 2021
c60b01c
Testing better examples and make code look cleaner
antoniospg Jun 14, 2021
14f6bab
review 1 for wachspress coordinates 3
danston Jun 15, 2021
307cb85
fixing code issues after revision
antoniospg Jun 15, 2021
adf4392
testing different kernels
antoniospg Jun 15, 2021
907b48a
fixed minor issue
antoniospg Jun 15, 2021
6fa3c27
added tetrahedron vs wp test and the beggining of the general one
antoniospg Jun 16, 2021
8fd163f
changing the name triangle_coordiantes_3 to tetrahedron_coordinates a…
antoniospg Jun 17, 2021
418dadf
first test with cube, testing unit partition, barycenter, weights bet…
antoniospg Jun 17, 2021
6abb524
finishing test for cube, add generator of random points inside tetrah…
antoniospg Jun 21, 2021
d0a2b2f
removed vscode file
antoniospg Jun 21, 2021
5e863a6
fixing tests for wachspress coordinates after review
antoniospg Jun 22, 2021
f1fd97e
First implementation of DH coordinates (not working yet)
antoniospg Jun 23, 2021
db17cbe
fixing some bugs of the previous version
antoniospg Jun 25, 2021
700a1c9
functional version and first test of dh coordinates
antoniospg Jun 27, 2021
6689419
adding tests, fix for wp coordinates, dh now working for cube
antoniospg Jun 28, 2021
28cd2bc
dh coordinates final adjustements
antoniospg Jun 29, 2021
8e483e8
draft version of mv coordinates
antoniospg Jul 1, 2021
9d38440
fixing some bugs
antoniospg Jul 1, 2021
8e9540c
functional version of mv coordinates + tests
antoniospg Jul 1, 2021
9f55c00
First version voronoi coordinates (still debugging)
antoniospg Jul 6, 2021
f8928b2
Fixing after first review, need to finish tests
antoniospg Jul 7, 2021
fd6474f
more fixes and created first benchmark
antoniospg Jul 8, 2021
d35eb95
modifying api to handle edge cases
antoniospg Jul 8, 2021
25d9db8
make it work with arbitrary face graphs + fixed warnings
danston Jul 9, 2021
e1cd692
adding test to verify boundary
antoniospg Jul 13, 2021
53cd8eb
first functional version of edge cases(only wp now)
antoniospg Jul 15, 2021
b630fb6
final version edge cases
antoniospg Jul 19, 2021
436f6f7
minor fix
antoniospg Jul 19, 2021
83efe5a
fixes after review + adding doxygen files
antoniospg Jul 20, 2021
5e74195
final version edge_cases
antoniospg Jul 25, 2021
43aa951
added shape_deformation example
antoniospg Jul 27, 2021
da73958
one more example and update docs
antoniospg Jul 27, 2021
6e0214e
adding final example
antoniospg Jul 28, 2021
9acc3e2
fixed some examples + updated the docs
antoniospg Jul 28, 2021
2ea40bc
first version docs
antoniospg Jul 29, 2021
2d53594
fixing warnings in docs build
antoniospg Jul 29, 2021
46ad2ae
fixing issues after first revision
antoniospg Aug 2, 2021
99f88a3
more fixes
antoniospg Aug 3, 2021
4d0c310
minor fixes
antoniospg Aug 4, 2021
a1d2071
adding thumb
antoniospg Aug 5, 2021
b81ccb3
new line at the end of each file
antoniospg Aug 9, 2021
4107852
WP boundary coordinates can now be any polygon
antoniospg Aug 10, 2021
c7a25d8
updated doc after first revision
antoniospg Aug 16, 2021
da7905a
final tweaks
antoniospg Aug 17, 2021
f5f0f92
Final fixes in the docs after revision
antoniospg Aug 19, 2021
4ffd27d
adding benchmark scripts
antoniospg Aug 23, 2021
ef44ef2
use new macro
sloriot Jun 7, 2024
e1793d0
fix permission
sloriot Jun 7, 2024
a2a6319
update cmake scripts
sloriot Jun 7, 2024
fd7f8a1
add in package list
sloriot Jun 7, 2024
9ef332c
add license include header
sloriot Jun 7, 2024
ee08aeb
remove tabs
sloriot Jun 7, 2024
88e7c72
avoid duplicated targets
sloriot Jun 7, 2024
d7ab2dd
fix compilation errors and do not use Surface_mesher
sloriot Jun 7, 2024
58897b2
simplify
sloriot Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Created by the script cgal_create_cmake_script.
# This is the CMake script for compiling a CGAL application.

project(Barycentric_coordinates_3_Examples)
set(CMAKE_CXX_FLAGS "${CMAXE_CXX_FLAGS} -Wall -Wextra -Werror")

cmake_minimum_required(VERSION 3.1...3.15)
set(CMAKE_CXX_STANDARD 14)

find_package(CGAL QUIET COMPONENTS Core)
if(CGAL_FOUND)

include(${CGAL_USE_FILE})
include(CGAL_CreateSingleSourceCGALProgram)

create_single_source_cgal_program("benchmark_tetrahedon_coordinates.cpp")
create_single_source_cgal_program("benchmark_polyhedron_8_vertices.cpp")

else()
message(WARNING "This program requires the CGAL library, and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include <CGAL/Real_timer.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Barycentric_coordinates_3/Wachspress_coordinates_3.h>
#include <CGAL/Barycentric_coordinates_3/Mean_value_coordinates_3.h>
#include <CGAL/Barycentric_coordinates_3/Discrete_harmonic_coordinates_3.h>

#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>

#include <fstream>

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;
using Timer = CGAL::Real_timer;
using Vertices = std::vector<Point_3>;
using SM = CGAL::Surface_mesh<Point_3>;

using WPC3 = CGAL::Barycentric_coordinates::Wachspress_coordinates_3<SM, Kernel>;
using MVC3 = CGAL::Barycentric_coordinates::Mean_value_coordinates_3<SM, Kernel>;
using DHC3 = CGAL::Barycentric_coordinates::Discrete_harmonic_coordinates_3<SM, Kernel>;

template<typename COORD>
double benchmark_overload(const FT scale){

const std::size_t number_of_runs = 10;

// Cube
SM cube;
Vertices cube_coords;

cube_coords = {Point_3(1.0, 0.0, 0.0), Point_3(1.0, 1.0, 0.0),
Point_3(0.0, 1.0, 0.0), Point_3(0.0, 0.0, 0.0),
Point_3(0.0, 0.0, 1.0), Point_3(1.0, 0.0, 1.0),
Point_3(1.0, 1.0, 1.0), Point_3(0.0, 1.0, 1.0)};

CGAL::make_hexahedron(cube_coords[0], cube_coords[1], cube_coords[2], cube_coords[3],
cube_coords[4], cube_coords[5], cube_coords[6], cube_coords[7], cube);

CGAL::Polygon_mesh_processing::triangulate_faces(cube);

COORD bar_cube(cube);

const FT step = FT(1) / scale;
const FT limit = step*scale;

std::vector<FT> bar_coordinates_cube;
bar_coordinates_cube.resize(8);

Timer timer;
double time = 0.0;

// Sample interior points
for(std::size_t i = 0; i < number_of_runs; i++){

timer.start();
for(FT x = step; x < limit - step; x += step){
for(FT y = step; y < limit - step; y += step){
for(FT z = step; z < limit - step; z += step){

const Point_3 query(x, y, z);
bar_cube(query, bar_coordinates_cube.begin());
}
}
}
timer.stop();
time += timer.time();
timer.reset();
}

const double mean_time =
time / static_cast<double>(number_of_runs);

return mean_time;
}

int main(){

std::ofstream wp_file("wp_bench.txt");
std::ofstream dh_file("dh_bench.txt");
std::ofstream mv_file("mv_bench.txt");

std::ofstream num_file("num_bench.txt");

for(std::size_t i = 5; i <= 100; i += 5){

wp_file << benchmark_overload<WPC3>(i) << std::endl;
dh_file << benchmark_overload<DHC3>(i) << std::endl;
mv_file << benchmark_overload<MVC3>(i) << std::endl;

num_file << i << std::endl;

std::cout << i << "\% complete" << std::endl;
}

wp_file.close();
dh_file.close();
mv_file.close();
num_file.close();

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <CGAL/Real_timer.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Barycentric_coordinates_3/tetrahedron_coordinates.h>

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;
using Timer = CGAL::Real_timer;

int main() {

const std::size_t number_of_x_coordinates = 100;
const std::size_t number_of_y_coordinates = 100;
const std::size_t number_of_z_coordinates = 100;

const std::size_t number_of_runs = 10;

const FT zero = FT(0);
const FT one = FT(1);
const FT four = FT(4);

const FT x_step = one / static_cast<FT>(number_of_x_coordinates);
const FT y_step = one / static_cast<FT>(number_of_y_coordinates);
const FT z_step = one / static_cast<FT>(number_of_z_coordinates);

const Point_3 p0 = Point_3(zero - x_step, zero - y_step, zero - z_step);
const Point_3 p1 = Point_3(four + x_step, zero - y_step, zero - z_step);
const Point_3 p2 = Point_3(zero - x_step, four + y_step, zero - z_step);
const Point_3 p3 = Point_3(zero - x_step, zero - y_step, four + z_step);

Timer timer;
std::vector<FT> coordinates(4);
double time = 0.0;

for(std::size_t i = 0; i < number_of_runs; i++){

timer.start();
for (FT x = zero; x <= one; x += x_step){
for (FT y = zero; y <= one; y += y_step){
for (FT z = zero; z <= one; z += z_step){

const Point_3 query(x, y, z);
CGAL::Barycentric_coordinates::tetrahedron_coordinates(
p0, p1, p2, p3, query, coordinates.begin());
}
}
}

timer.stop();
time += timer.time();
timer.reset();
}

const double mean_time =
time / static_cast<double>(number_of_runs);

std::cout.precision(10);
std::cout << "benchmark_tretrahedron_coordinates (CPU time): " <<
mean_time << " seconds" << std::endl;
return EXIT_SUCCESS;
}
Loading
Loading