Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Documentation/doc/Documentation/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
54 changes: 54 additions & 0 deletions Installation/include/CGAL/license/Sphere_packing.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_SPHERE_PACKING_H
#define CGAL_LICENSE_SPHERE_PACKING_H

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

#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
1 change: 1 addition & 0 deletions Installation/include/CGAL/license/gpl_package_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Sphere_packing/doc/Sphere_packing/Doxyfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}

PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Sphere Packing"
33 changes: 33 additions & 0 deletions Sphere_packing/doc/Sphere_packing/PackageDescription.txt
Original file line number Diff line number Diff line change
@@ -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()`
*/
27 changes: 27 additions & 0 deletions Sphere_packing/doc/Sphere_packing/Sphere_packing.txt
Original file line number Diff line number Diff line change
@@ -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 */
7 changes: 7 additions & 0 deletions Sphere_packing/doc/Sphere_packing/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Manual
Kernel_23
STL_Extension
Algebraic_foundations
Circulator
Stream_support
BGL
3 changes: 3 additions & 0 deletions Sphere_packing/doc/Sphere_packing/examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*!
\example Sphere_packing/sphere_packing.cpp
*/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Sphere_packing/examples/Sphere_packing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})

23 changes: 23 additions & 0 deletions Sphere_packing/examples/Sphere_packing/sphere_packing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <CGAL/Sphere_packing.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>

using Kernel = CGAL::Simple_cartesian<double>;
using Point = Kernel::Point_3;
using Mesh = CGAL::Surface_mesh<Point>;

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;
}
120 changes: 120 additions & 0 deletions Sphere_packing/include/CGAL/Sphere_packing.h
Original file line number Diff line number Diff line change
@@ -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 <CGAL/license/Sphere_packing.h>

#include <CGAL/disable_warnings.h>
#include <CGAL/Named_function_parameters.h>


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<float>::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<bool(unsigned int iteration, unsigned int performed_splits, unsigned int number_of_spheres, float sphere_volume, float object_volume, const float4 *)>`.}
* \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<TriangleMesh>::%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<typename TriangleMesh, typename OutputIterator, typename NamedParameters = parameters::Default_named_parameters>
OutputIterator pack_spheres(const TriangleMesh& tm, OutputIterator out, const NamedParameters& np = parameters::default_values()) {

return out;
}

} // end namespace CGAL

#include <CGAL/enable_warnings.h>

#endif // CGAL_SPHERE_PACKINGH_H_
1 change: 1 addition & 0 deletions Sphere_packing/package_info/Sphere_packing/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
University of Bremen
1 change: 1 addition & 0 deletions Sphere_packing/package_info/Sphere_packing/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Computes the sphere packing for a triangle mesh or a point set delimiting a volume
1 change: 1 addition & 0 deletions Sphere_packing/package_info/Sphere_packing/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GPL (v3 or later)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Computes the sphere packing for a triangle mesh or a point set delimiting a volume
1 change: 1 addition & 0 deletions Sphere_packing/package_info/Sphere_packing/maintainer
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rene Welle, Sven Oesau
14 changes: 14 additions & 0 deletions Sphere_packing/test/Sphere_packing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions Sphere_packing/test/Sphere_packing/sphere_packing_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <CGAL/Sphere_packing.h>

int main()
{
return 0;
}
Loading