Skip to content

Commit

Permalink
Merge pull request #7908 from soesau/Kinetic_surface_reconstruction-n…
Browse files Browse the repository at this point in the history
…ew_package-soesau

Kinetic Surface Reconstruction
  • Loading branch information
sloriot committed May 26, 2024
2 parents 596fa09 + 28ef0b6 commit 61decad
Show file tree
Hide file tree
Showing 39 changed files with 3,846 additions and 185 deletions.
1 change: 1 addition & 0 deletions Documentation/doc/Documentation/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
\package_listing{Advancing_front_surface_reconstruction}
\package_listing{Polygonal_surface_reconstruction}
\package_listing{Kinetic_space_partition}
\package_listing{Kinetic_surface_reconstruction}
\package_listing{Optimal_transportation_reconstruction_2}

\cgalPackageSection{PartGeometryProcessing,Geometry Processing}
Expand Down
54 changes: 54 additions & 0 deletions Installation/include/CGAL/license/Kinetic_surface_reconstruction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2016 GeometryFactory SARL (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Andreas Fabri
//
// Warning: this file is generated, see include/CGAL/license/README.md

#ifndef CGAL_LICENSE_KINETIC_SURFACE_RECONSTRUCTION_H
#define CGAL_LICENSE_KINETIC_SURFACE_RECONSTRUCTION_H

#include <CGAL/config.h>
#include <CGAL/license.h>

#ifdef CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE

# if CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE

# if defined(CGAL_LICENSE_WARNING)

CGAL_pragma_warning("Your commercial license for CGAL does not cover "
"this release of the Kinetic Surface Reconstruction package.")
# endif

# ifdef CGAL_LICENSE_ERROR
# error "Your commercial license for CGAL does not cover this release \
of the Kinetic Surface Reconstruction package. \
You get this error, as you defined CGAL_LICENSE_ERROR."
# endif // CGAL_LICENSE_ERROR
# endif // CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE
#else // no CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE
# if defined(CGAL_LICENSE_WARNING)
CGAL_pragma_warning("\nThe macro CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE is not defined."
"\nYou use the CGAL Kinetic Surface Reconstruction package under "
"the terms of the GPLv3+.")
# endif // CGAL_LICENSE_WARNING
# ifdef CGAL_LICENSE_ERROR
# error "The macro CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE is not defined.\
You use the CGAL Kinetic Surface Reconstruction package under the terms of \
the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR."
# endif // CGAL_LICENSE_ERROR
#endif // no CGAL_KINETIC_SURFACE_RECONSTRUCTION_COMMERCIAL_LICENSE
#endif // CGAL_LICENSE_KINETIC_SURFACE_RECONSTRUCTION_H
2 changes: 1 addition & 1 deletion Installation/include/CGAL/license/gpl_package_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Inscribed_areas Inscribed Areas
Interpolation 2D and Surface Function Interpolation
Interval_skip_list Interval Skip List
Jet_fitting_3 Estimation of Local Differential Properties of Point-Sampled Surfaces
Kinetic_space_partition Kinetic Space Partition
Kinetic_surface_reconstruction Kinetic Surface Reconstruction
Matrix_search Monotone and Sorted Matrix Search
Mesh_2 2D Conforming Triangulations and Meshes
Mesh_3 3D Mesh Generation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,6 @@ namespace KSR {
void set_parameters(
Input_parameters& input_parameters,
const std::vector<std::string>& required) {

if (!are_required_parameters_set(input_parameters, required)) {
std::cerr << std::endl <<
"ERROR: SEVERAL REQUIRED PARAMETERS ARE MISSING!"
<< std::endl << std::endl;
exit(EXIT_FAILURE);
}

if (parameters_should_be_loaded(input_parameters))
load_parameters_from_file(input_parameters);
m_parameters = input_parameters;
Expand Down
36 changes: 1 addition & 35 deletions Kinetic_space_partition/include/CGAL/KSP/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,42 +914,7 @@ void dump_volumes(const DS& data, const std::string tag = std::string()) {
saver.export_polygon_soup_3(polygons, colors, file_name);
}
}
/*
template<typename KSP>
void dump_volumes_ksp(const KSP& ksp, const std::string tag = std::string()) {
using Point_3 = typename KSP::Point_3;
using Index = typename KSP::Index;
std::vector< std::vector<Point_3> > polygons;
std::vector<Color> colors;
std::vector<Index> faces_of_volume;
std::vector<Point_3> pts_of_face;
Saver<typename KSP::Kernel> saver;
for (std::size_t i = 0; i < ksp.number_of_volumes(); ++i) {
faces_of_volume.clear();
polygons.clear();
colors.clear();

const auto color = saver.get_idx_color(i);
ksp.faces(i, std::back_inserter(faces_of_volume));
colors.clear();
polygons.clear();
for (const Index& f : faces_of_volume) {
pts_of_face.clear();
ksp.vertices(f, std::back_inserter(pts_of_face));
polygons.push_back(pts_of_face);
colors.push_back(color);
}
const std::string file_name = tag + std::to_string(i);
saver.export_polygon_soup_3(polygons, colors, file_name);
}
}
*/
template<typename K>
void dump_polygon(const std::vector<typename K::Point_3>& pts, const std::string& filename) {
Saver<K> saver;
Expand All @@ -966,6 +931,7 @@ void dump_polygon(const std::vector<CGAL::Epick::Point_3>& pts, const std::strin

saver.export_polygon_soup_3(pts2, filename);
}

void dump_polygona(const std::vector<CGAL::Epick::Point_3>& pts, const std::string& filename) {
Saver<CGAL::Epick> saver;
std::vector<std::vector<CGAL::Epick::Point_3> > pts2;
Expand Down
9 changes: 0 additions & 9 deletions Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ class Data_structure {
continue;
}
IkPoint_2 p;
FT diff = sp.data().original_vectors[idx].squared_length() - from_exact(sp.data().original_rays[idx].to_vector().squared_length());

if (CGAL::assign(p, result)) {
IkFT l = CGAL::approximate_sqrt(sp.data().original_vectors[idx].squared_length());
Expand Down Expand Up @@ -556,14 +555,6 @@ class Data_structure {
event.intersection_bary = 1;
}


if (kinetic_interval.size() > 4) {
if (kinetic_interval[2].first > kinetic_interval[1].first) {
int a;
a = 2;
}
}

CGAL_assertion(0 <= event.intersection_bary && event.intersection_bary <= 1);

return event.time;
Expand Down
4 changes: 2 additions & 2 deletions Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Finalizer {
for (const auto& v : m_data.volumes())
dump_volume(m_data, v.pfaces, "volumes/" + m_data.prefix() + std::to_string(v.index), true, v.index);
}

CGAL_assertion(m_data.check_faces());
}

Expand Down Expand Up @@ -446,7 +447,7 @@ class Finalizer {
// for each face, find vertex that is not collinear with the edge
// sort around a reference face

const Segment_3 segment = m_data.segment_3(pedge);
// const Segment_3 segment = m_data.segment_3(pedge);
IEdge ie = m_data.iedge(pedge);
non_collinear_vertex(pface, ie);

Expand Down Expand Up @@ -529,7 +530,6 @@ class Finalizer {
}

Oriented_side oriented_side(const PFace& a, const PFace& b) const {
FT max_dist = 0;
if (a.first == b.first)
return CGAL::ON_ORIENTED_BOUNDARY;
Oriented_side side = CGAL::ON_ORIENTED_BOUNDARY;
Expand Down
74 changes: 37 additions & 37 deletions Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class Kinetic_space_partition_3 {
}*/

for (const Index& v : vtx_of_face) {
ib.add_vertex_to_facet(static_cast<std::size_t>(mapped_vertices[v]));
ib.add_vertex_to_facet(static_cast<typename LCC::size_type>(mapped_vertices[v]));
//std::cout << " " << mapped_vertices[v];
if (!used_vertices[mapped_vertices[v]]) {
used_vertices[mapped_vertices[v]] = true;
Expand Down Expand Up @@ -1037,42 +1037,6 @@ class Kinetic_space_partition_3 {
}


template<class OutputIterator>
void faces_of_input_polygon(const std::size_t polygon_index, OutputIterator it) const {
if (polygon_index >= m_input_planes.size()) {
assert(false);
}

for (std::size_t idx : m_partitions) {
const Sub_partition& p = m_partition_nodes[idx];
// Check if it contains this input polygon and get support plane index
int sp_idx = -1;
for (std::size_t i = 0; i < p.input_polygons.size(); i++) {
if (p.input_polygons[i] == polygon_index) {
sp_idx = p.m_data->support_plane_index(i);
break;
}
}

// Continue if the partition does not contain this input polygon.
if (sp_idx == -1)
continue;

auto pfaces = p.m_data->pfaces(sp_idx);
auto f2i = p.m_data->face_to_index();
const auto& f2sp = p.m_data->face_to_support_plane();

for (std::size_t i = 0; i < f2sp.size(); i++) {
if (f2sp[i] == sp_idx)
*it++ = std::make_pair(idx, i);
}
}
}

const std::vector<std::vector<std::size_t> >& input_mapping() const {
return m_regularized2input;
}

/*!
\brief Face indices of the volume.
Expand Down Expand Up @@ -1168,6 +1132,42 @@ class Kinetic_space_partition_3 {
}


template<class OutputIterator>
void faces_of_input_polygon(const std::size_t polygon_index, OutputIterator it) const {
if (polygon_index >= m_input_planes.size()) {
assert(false);
}

for (std::size_t idx : m_partitions) {
const Sub_partition& p = m_partition_nodes[idx];
// Check if it contains this input polygon and get support plane index
int sp_idx = -1;
for (std::size_t i = 0; i < p.input_polygons.size(); i++) {
if (p.input_polygons[i] == polygon_index) {
sp_idx = p.m_data->support_plane_index(i);
break;
}
}

// Continue if the partition does not contain this input polygon.
if (sp_idx == -1)
continue;

auto pfaces = p.m_data->pfaces(sp_idx);
auto f2i = p.m_data->face_to_index();
const auto& f2sp = p.m_data->face_to_support_plane();

for (std::size_t i = 0; i < f2sp.size(); i++) {
if (f2sp[i] == sp_idx)
*it++ = std::make_pair(idx, i);
}
}
}

const std::vector<std::vector<std::size_t> >& input_mapping() const {
return m_regularized2input;
}

/*!
\brief Indices of adjacent volumes. Negative indices correspond to the empty spaces behind the sides of the bounding box.
Expand Down
35 changes: 25 additions & 10 deletions Kinetic_space_partition/test/Kinetic_space_partition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,35 @@ cmake_minimum_required(VERSION 3.1...3.23)

project(Kinetic_space_partition_Tests)

find_package(CGAL REQUIRED)
set(CMAKE_CXX_STANDARD 17)

find_package(CGAL QUIET COMPONENTS Core)
include(CGAL_CreateSingleSourceCGALProgram)

find_package(Eigen3 3.1.0 REQUIRED)
if(Eigen3_FOUND)
message(STATUS "Found Eigen")
include(CGAL_Eigen_support)
find_package(Boost REQUIRED)
if(Boost_FOUND)
message(STATUS "Found Boost")

find_package(Eigen3 3.1.0 REQUIRED)
if(Eigen3_FOUND)
message(STATUS "Found Eigen")
include(CGAL_Eigen_support)

set(targets kinetic_3d_test_all)

foreach(target ${targets})
create_single_source_cgal_program("${target}.cpp")
target_link_libraries(${target} PUBLIC CGAL::Eigen_support)
endforeach()
set(project_linked_libraries)
set(project_compilation_definitions)

foreach(target ${targets})
create_single_source_cgal_program("${target}.cpp")
if(TARGET ${target})
target_link_libraries(${target} PUBLIC ${project_linked_libraries} CGAL::Eigen_support)
target_compile_definitions(${target} PUBLIC ${project_compilation_definitions})
endif()
endforeach()
else()
message(ERROR "This program requires the Eigen library, and will not be compiled.")
endif()
else()
message(ERROR "This program requires the Eigen library, and will not be compiled.")
message(ERROR "This program requires the Boost library, and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}

PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Kinetic Surface Reconstruction"
EXTRACT_ALL = YES
WARN_IF_UNDOCUMENTED = NO
PREDEFINED += DOXYGEN_RUNNING

INPUT += \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Kinetic_surface_reconstruction_3.h \
Loading

0 comments on commit 61decad

Please sign in to comment.