diff --git a/Documentation/doc/Documentation/packages.txt b/Documentation/doc/Documentation/packages.txt index da8d09c1f0d9..1f70af8f379e 100644 --- a/Documentation/doc/Documentation/packages.txt +++ b/Documentation/doc/Documentation/packages.txt @@ -151,6 +151,7 @@ \package_listing{Polytope_distance_d} \package_listing{Principal_component_analysis} \package_listing{Optimal_bounding_box} +\package_listing{Sphere_packing} \cgalPackageSection{PartInterpolation,Interpolation} diff --git a/Installation/include/CGAL/license/Sphere_packing.h b/Installation/include/CGAL/license/Sphere_packing.h new file mode 100644 index 000000000000..871379973df5 --- /dev/null +++ b/Installation/include/CGAL/license/Sphere_packing.h @@ -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_SPHERE_PACKING_H +#define CGAL_LICENSE_SPHERE_PACKING_H + +#include +#include + +#ifdef CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE + +# if CGAL_SPHERE_PACKING_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 Sphere Packing package.") +# endif + +# ifdef CGAL_LICENSE_ERROR +# error "Your commercial license for CGAL does not cover this release \ + of the Sphere Packings package. \ + You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +# endif // CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +#else // no CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE + +# if defined(CGAL_LICENSE_WARNING) + CGAL_pragma_warning("\nThe macro CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE is not defined." + "\nYou use the CGAL Sphere Packings package under " + "the terms of the GPLv3+.") +# endif // CGAL_LICENSE_WARNING + +# ifdef CGAL_LICENSE_ERROR +# error "The macro CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE is not defined.\ + You use the CGAL Sphere Packings package under the terms of \ + the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +#endif // no CGAL_SPHERE_PACKING_COMMERCIAL_LICENSE + +#endif // CGAL_LICENSE_SPHERE_PACKING_H diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index 6fd1d5b9b42e..040e9842d248 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -88,6 +88,7 @@ Skin_surface_3 3D Skin Surface Meshing SMDS_3 3D Simplicial Mesh Data Structure Snap_rounding_2 2D Snap Rounding Spatial_searching dD Spatial Searching +Sphere_packing Sphere Packing Straight_skeleton_2 2D Straight Skeleton and Polygon Offsetting Straight_skeleton_extrusion_2 2D Straight Skeleton Extrusion Stream_lines_2 2D Placement of Streamlines diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index ffe386d086cb..988a58618b6c 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -180,6 +180,13 @@ CGAL_add_named_parameter(dimension_t, dimension, dimension) CGAL_add_named_parameter(apply_iterative_snap_rounding_t, apply_iterative_snap_rounding, apply_iterative_snap_rounding) CGAL_add_named_parameter(snap_grid_size_t, snap_grid_size, snap_grid_size) +// List of named parameters that we use in the package 'Sphere packing' +CGAL_add_named_parameter(number_of_target_spheres_t, number_of_target_spheres, number_of_target_spheres) +CGAL_add_named_parameter(iteration_functor_t, iteration_functor, iteration_functor) +CGAL_add_named_parameter(iterations_between_splits_t, iterations_between_splits, iterations_between_splits) +CGAL_add_named_parameter(maximum_splits_t, maximum_splits, maximum_splits) +CGAL_add_named_parameter(initial_grid_resolution_t, initial_grid_resolution, initial_grid_resolution) + // List of named parameters that we use in the package 'Surface Mesh Simplification' CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) CGAL_add_named_parameter(get_placement_policy_t, get_placement_policy, get_placement) diff --git a/Sphere_packing/doc/Sphere_packing/Doxyfile.in b/Sphere_packing/doc/Sphere_packing/Doxyfile.in new file mode 100644 index 000000000000..63c00010065f --- /dev/null +++ b/Sphere_packing/doc/Sphere_packing/Doxyfile.in @@ -0,0 +1,3 @@ +@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} + +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Sphere Packing" diff --git a/Sphere_packing/doc/Sphere_packing/PackageDescription.txt b/Sphere_packing/doc/Sphere_packing/PackageDescription.txt new file mode 100644 index 000000000000..901d90c43d98 --- /dev/null +++ b/Sphere_packing/doc/Sphere_packing/PackageDescription.txt @@ -0,0 +1,33 @@ + +/// \defgroup PkgSpherePackingRef Sphere Packing Reference + +/// \defgroup PkgSpherePackingAlgorithms Algorithms +/// \ingroup PkgSpherePackingRef +/*! + +\addtogroup PkgSpherePackingRef +\cgalPkgDescriptionBegin{SpherePacking, PkgSpherePacking} +\cgalPkgPicture{sphere_packing_logo_small.png} + +\cgalPkgSummaryBegin +\cgalPkgAuthors{Rene Weller, Sven Oesau} +\cgalPkgDesc{ +The SpherePacking provides ... } +\cgalPkgManuals{Chapter_SpherePacking,PkgSpherePackingRef} +\cgalPkgSummaryEnd + +\cgalPkgShortInfoBegin +\cgalPkgSince{6.2} +\cgalPkgBib{cgal:w-sp} +\cgalPkgLicense{\ref licensesGPL "GPL"} + +\cgalPkgShortInfoEnd + +\cgalPkgDescriptionEnd + + +\cgalClassifedRefPages + +\cgalCRPSection{Algorithms} +- `CGAL::pack_spheres()` +*/ diff --git a/Sphere_packing/doc/Sphere_packing/Sphere_packing.txt b/Sphere_packing/doc/Sphere_packing/Sphere_packing.txt new file mode 100644 index 000000000000..56f12a6dce97 --- /dev/null +++ b/Sphere_packing/doc/Sphere_packing/Sphere_packing.txt @@ -0,0 +1,27 @@ +namespace CGAL { +/*! + +\mainpage User Manual +\anchor Chapter_SpherePacking + +\cgalAutoToc +\author Rene Weller + +This chapter describes the ... + +\section secSpherePackingDefinitions Definitions + +Section on definitions here ... + +\section secSpherePackingExamples Examples + +\subsection secSpherePackingFirstExample First Example + +The following example shows ... + +\cgalExample{Sphere_packing/sphere_packing.cpp} + + + +*/ +} /* namespace CGAL */ diff --git a/Sphere_packing/doc/Sphere_packing/dependencies b/Sphere_packing/doc/Sphere_packing/dependencies new file mode 100644 index 000000000000..80d55008aa4e --- /dev/null +++ b/Sphere_packing/doc/Sphere_packing/dependencies @@ -0,0 +1,7 @@ +Manual +Kernel_23 +STL_Extension +Algebraic_foundations +Circulator +Stream_support +BGL diff --git a/Sphere_packing/doc/Sphere_packing/examples.txt b/Sphere_packing/doc/Sphere_packing/examples.txt new file mode 100644 index 000000000000..d5bd6f7ef60d --- /dev/null +++ b/Sphere_packing/doc/Sphere_packing/examples.txt @@ -0,0 +1,3 @@ +/*! +\example Sphere_packing/sphere_packing.cpp +*/ diff --git a/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo.png b/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo.png new file mode 100644 index 000000000000..f8fa75c3a230 Binary files /dev/null and b/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo.png differ diff --git a/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo_small.png b/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo_small.png new file mode 100644 index 000000000000..a2c9917443d8 Binary files /dev/null and b/Sphere_packing/doc/Sphere_packing/fig/sphere_packing_logo_small.png differ diff --git a/Sphere_packing/examples/Sphere_packing/CMakeLists.txt b/Sphere_packing/examples/Sphere_packing/CMakeLists.txt new file mode 100644 index 000000000000..880a0a00f4c1 --- /dev/null +++ b/Sphere_packing/examples/Sphere_packing/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.12...3.31) +project(Sphere_packing_Examples) + +find_package(CGAL REQUIRED) +find_package(CUDAToolkit) +#find_package(ProtoSphere) + +if (CUDAToolkit_FOUND) + message(STATUS ${CMAKE_CUDA_COMPILER_VERSION}) + enable_language(CUDA) +endif() + +# Allow the user to specify the path to MyLib's include directory +set(ProtoSphere_INCLUDE_DIR "" CACHE PATH "Path to ProtoSphere include directory") + +# Allow the user to specify the path to MyLib's library directory +set(ProtoSphere_LIBRARY "" CACHE FILEPATH "Path to ProtoSphere library file (e.g. libmylib.a or mylib.lib)") + +create_single_source_cgal_program("sphere_packing.cpp") +target_link_libraries(sphere_packing PRIVATE ${ProtoSphere_LIBRARY}) +target_include_directories(sphere_packing PRIVATE ${ProtoSphere_INCLUDE_DIR}) + diff --git a/Sphere_packing/examples/Sphere_packing/sphere_packing.cpp b/Sphere_packing/examples/Sphere_packing/sphere_packing.cpp new file mode 100644 index 000000000000..df625fd4c7d6 --- /dev/null +++ b/Sphere_packing/examples/Sphere_packing/sphere_packing.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +using Kernel = CGAL::Simple_cartesian; +using Point = Kernel::Point_3; +using Mesh = CGAL::Surface_mesh; + +namespace PMP = CGAL::Polygon_mesh_processing; + +int main(int argc, const char **argv) +{ + const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/bear.off"); + + Mesh mesh; + if (!PMP::IO::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + return 0; +} diff --git a/Sphere_packing/include/CGAL/Sphere_packing.h b/Sphere_packing/include/CGAL/Sphere_packing.h new file mode 100644 index 000000000000..e53995b9d093 --- /dev/null +++ b/Sphere_packing/include/CGAL/Sphere_packing.h @@ -0,0 +1,120 @@ +// Copyright (c) 2025 Universitaet Bremen +// 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) : Rene Weller, Sven Oesau +// + +#ifndef CGAL_SPHERE_PACKINGH_H_ +#define CGAL_SPHERE_PACKINGH_H_ + +#include + +#include +#include + + +namespace CGAL { + +/** + * \ingroup PkgSpherePackingAlgorithms + * \brief Packs spheres into a closed mesh. + * Computes a packing of spheres into a closed and self-intersection free triangle mesh. The possible range of radii of spheres can be chosen; large spheres are preferred during the packing. + * The optimal solution is not guaranteed as it has NP-hard complexity. + * + * Note that the precision of the method is limited by the precision of the GPU, i.e., non-exact arithmetic with 32-bit floating point numbers is used. + * + * \tparam TriangleMesh a model of `HalfedgeListGraph`, `FaceListGraph`, and `MutableFaceGraph` + * + * \tparam OutputIterator must be an output iterator accepting variables of type `geom_traits::Sphere_3`. + * + * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * \param tm the input tm to pack spheres into. It has to be a closed triangle mesh and may not have self-intersections. + * \param out output iterator into which the packed spheres are written. + * \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * + * \cgalParamNBegin{number_of_target_spheres} + * \cgalParamDescription{target number of spheres to be packed into `tm`.} + * \cgalParamType{unsigned int} + * \cgalParamDefault{10,000} + * \cgalParamNEnd + * + * \cgalParamNBegin{minimum_radius} + * \cgalParamDescription{minimum radius of packed spheres} + * \cgalParamType{float} + * \cgalParamDefault{0} + * \cgalParamNEnd + * + * \cgalParamNBegin{maximum_radius} + * \cgalParamDescription{maximum radius of packed spheres} + * \cgalParamType{float} + * \cgalParamDefault{std::numeric_limits::max()} + * \cgalParamNEnd + * + * \cgalParamNBegin{iteration_functor} + * \cgalParamDescription{a functor that is called before each split to decide whether the packing should continue.} + * \cgalParamType{an instance of `std::function`.} + * \cgalParamDefault{No functor is used. Packing continues until `number_of_target_spheres` or `maximum_splits` are met.} + * \cgalParamExtra{`float4` is a CUDA data type and has 4 members: `float x, y, z, w`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{initial_grid_resolution} + * \cgalParamDescription{number of grid cells for the longest side of the bounding box. Grid cells are cubes.} + * \cgalParamType{unsigned int} + * \cgalParamDefault{4} + * \cgalParamNEnd + * + * \cgalParamNBegin{maximum_splits} + * \cgalParamDescription{how often the grid is subdivided at most.} + * \cgalParamType{unsigned int} + * \cgalParamDefault{6} + * \cgalParamNEnd + * + * \cgalParamNBegin{iterations_between_splits} + * \cgalParamDescription{iterations of placing spheres between splitting the grid into a higher resolution.} + * \cgalParamType{unsigned int} + * \cgalParamDefault{30} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `tm`} + * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` + * as key type and `%Point_3` as value type} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, tm)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` + * must be available in `TriangleMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{geom_traits} + * \cgalParamDescription{an instance of a geometric traits class} + * \cgalParamType{a class model of `Kernel`} + * \cgalParamDefault{a \cgal Kernel deduced from the point type of `TriangleMesh`, using `CGAL::Kernel_traits`} + * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * \return `out`, the output iterator + */ + + +template +OutputIterator pack_spheres(const TriangleMesh& tm, OutputIterator out, const NamedParameters& np = parameters::default_values()) { + + return out; +} + +} // end namespace CGAL + +#include + +#endif // CGAL_SPHERE_PACKINGH_H_ diff --git a/Sphere_packing/package_info/Sphere_packing/copyright b/Sphere_packing/package_info/Sphere_packing/copyright new file mode 100644 index 000000000000..7999f03ca2b8 --- /dev/null +++ b/Sphere_packing/package_info/Sphere_packing/copyright @@ -0,0 +1 @@ +University of Bremen diff --git a/Sphere_packing/package_info/Sphere_packing/description.txt b/Sphere_packing/package_info/Sphere_packing/description.txt new file mode 100644 index 000000000000..dbb0a70f2c9e --- /dev/null +++ b/Sphere_packing/package_info/Sphere_packing/description.txt @@ -0,0 +1 @@ +Computes the sphere packing for a triangle mesh or a point set delimiting a volume diff --git a/Sphere_packing/package_info/Sphere_packing/license.txt b/Sphere_packing/package_info/Sphere_packing/license.txt new file mode 100644 index 000000000000..8bb8efcb72b0 --- /dev/null +++ b/Sphere_packing/package_info/Sphere_packing/license.txt @@ -0,0 +1 @@ +GPL (v3 or later) diff --git a/Sphere_packing/package_info/Sphere_packing/long_description.txt b/Sphere_packing/package_info/Sphere_packing/long_description.txt new file mode 100644 index 000000000000..dbb0a70f2c9e --- /dev/null +++ b/Sphere_packing/package_info/Sphere_packing/long_description.txt @@ -0,0 +1 @@ +Computes the sphere packing for a triangle mesh or a point set delimiting a volume diff --git a/Sphere_packing/package_info/Sphere_packing/maintainer b/Sphere_packing/package_info/Sphere_packing/maintainer new file mode 100644 index 000000000000..53456210416f --- /dev/null +++ b/Sphere_packing/package_info/Sphere_packing/maintainer @@ -0,0 +1 @@ +Rene Welle, Sven Oesau diff --git a/Sphere_packing/test/Sphere_packing/CMakeLists.txt b/Sphere_packing/test/Sphere_packing/CMakeLists.txt new file mode 100644 index 000000000000..1cd0f06159eb --- /dev/null +++ b/Sphere_packing/test/Sphere_packing/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 3.12...3.31) +project(Sphere_packing_Tests) + +find_package(CGAL REQUIRED) + +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Sphere_packing/test/Sphere_packing/sphere_packing_test.cpp b/Sphere_packing/test/Sphere_packing/sphere_packing_test.cpp new file mode 100644 index 000000000000..acdc4910620a --- /dev/null +++ b/Sphere_packing/test/Sphere_packing/sphere_packing_test.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + return 0; +}