[Small Feature] Use CGAL_DEPRECATED and protect deprecated functions

This commit is contained in:
Yliess Bellargui 2025-07-16 13:56:17 +02:00
parent 289716dbab
commit 66de6cba3d
7 changed files with 67 additions and 16 deletions

View File

@ -23,6 +23,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <list> #include <list>
#include <CGAL/config.h>
namespace CGAL { namespace CGAL {
@ -130,8 +131,12 @@ namespace CGAL {
return first; return first;
} }
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\deprecated This function is deprecated since CGAL 5.6. Use `read_plane_graph_in_lcc()` instead.
*/
template< class LCC > template< class LCC >
[[deprecated("Use read_plane_graph_in_lcc instead")]] CGAL_DEPRECATED
typename LCC::Dart_descriptor typename LCC::Dart_descriptor
import_from_plane_graph(LCC& alcc, import_from_plane_graph(LCC& alcc,
const std::vector<typename LCC::Point>& vertices, const std::vector<typename LCC::Point>& vertices,
@ -139,6 +144,7 @@ import_from_plane_graph(LCC& alcc,
{ {
return read_plane_graph_in_lcc(alcc, vertices, edge_indices); return read_plane_graph_in_lcc(alcc, vertices, edge_indices);
} }
#endif
/** /**
* Imports a plane-embedded graph from a file into a LinearCellComplex. * Imports a plane-embedded graph from a file into a LinearCellComplex.
@ -198,13 +204,18 @@ import_from_plane_graph(LCC& alcc,
return read_plane_graph_in_lcc(alcc, vertices, edge_indices); return read_plane_graph_in_lcc(alcc, vertices, edge_indices);
} }
template <class LCC> #ifndef CGAL_NO_DEPRECATED_CODE
[[deprecated("Use read_plane_graph_in_lcc instead")]] /*!
\deprecated This function is deprecated since CGAL 5.6. Use `read_plane_graph_in_lcc()` instead.
*/
template< class LCC >
CGAL_DEPRECATED
typename LCC::Dart_descriptor typename LCC::Dart_descriptor
import_from_plane_graph(LCC& alcc, std::istream& ais) import_from_plane_graph(LCC& alcc, std::istream& ais)
{ {
return read_plane_graph_in_lcc(alcc, ais); return read_plane_graph_in_lcc(alcc, ais);
} }
#endif
template < class LCC > template < class LCC >
typename LCC::Dart_descriptor typename LCC::Dart_descriptor
@ -215,13 +226,18 @@ import_from_plane_graph(LCC& alcc, std::istream& ais)
return read_plane_graph_in_lcc(alcc, input); return read_plane_graph_in_lcc(alcc, input);
} }
template <class LCC> #ifndef CGAL_NO_DEPRECATED_CODE
[[deprecated("Use read_plane_graph_in_lcc instead")]] /*!
\deprecated This function is deprecated since CGAL 5.6. Use `read_plane_graph_in_lcc()` instead.
*/
template< class LCC >
CGAL_DEPRECATED
typename LCC::Dart_descriptor typename LCC::Dart_descriptor
import_from_plane_graph(LCC& alcc, const char* filename) import_from_plane_graph(LCC& alcc, const char* filename)
{ {
return read_plane_graph_in_lcc(alcc, filename); return read_plane_graph_in_lcc(alcc, filename);
} }
#endif
template < class LCC > template < class LCC >
bool load_off(LCC& alcc, std::istream& in) bool load_off(LCC& alcc, std::istream& in)

View File

@ -39,3 +39,21 @@ add_executable(Linear_cell_complex_copy_test_index Linear_cell_complex_copy_test
target_compile_definitions(Linear_cell_complex_copy_test_index PRIVATE USE_COMPACT_CONTAINER_WITH_INDEX) target_compile_definitions(Linear_cell_complex_copy_test_index PRIVATE USE_COMPACT_CONTAINER_WITH_INDEX)
target_link_libraries(Linear_cell_complex_copy_test_index PRIVATE CGAL CGAL::Data) target_link_libraries(Linear_cell_complex_copy_test_index PRIVATE CGAL CGAL::Data)
cgal_add_compilation_test(Linear_cell_complex_copy_test_index) cgal_add_compilation_test(Linear_cell_complex_copy_test_index)
# Test sans warning de dépréciation pour test_plane_graph_alias
add_executable(test_plane_graph_alias_nowarn test_plane_graph_alias.cpp ${hfiles})
target_compile_definitions(test_plane_graph_alias_nowarn PRIVATE CGAL_NO_DEPRECATION_WARNINGS)
target_link_libraries(test_plane_graph_alias_nowarn PRIVATE CGAL CGAL::Data)
cgal_add_compilation_test(test_plane_graph_alias_nowarn)
# Test sans warning de dépréciation pour test_polyhedron_3_alias
add_executable(test_polyhedron_3_alias_nowarn test_polyhedron_3_alias.cpp ${hfiles})
target_compile_definitions(test_polyhedron_3_alias_nowarn PRIVATE CGAL_NO_DEPRECATION_WARNINGS)
target_link_libraries(test_polyhedron_3_alias_nowarn PRIVATE CGAL CGAL::Data)
cgal_add_compilation_test(test_polyhedron_3_alias_nowarn)
# Test sans warning de dépréciation pour test_triangulation_alias
add_executable(test_triangulation_alias_nowarn test_triangulation_alias.cpp ${hfiles})
target_compile_definitions(test_triangulation_alias_nowarn PRIVATE CGAL_NO_DEPRECATION_WARNINGS)
target_link_libraries(test_triangulation_alias_nowarn PRIVATE CGAL CGAL::Data)
cgal_add_compilation_test(test_triangulation_alias_nowarn)

View File

@ -1,3 +1,4 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h> #include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_constructors.h> #include <CGAL/Linear_cell_complex_constructors.h>
#include <cassert> #include <cassert>
@ -22,7 +23,7 @@ int main()
input.clear(); input.clear();
input.seekg(0, std::ios::beg); input.seekg(0, std::ios::beg);
#if !defined(CGAL_NO_DEPRECATED_CODE) && !defined(CGAL_NO_DEPRECATION_WARNINGS) #ifndef CGAL_NO_DEPRECATED_CODE
// Test deprecated function // Test deprecated function
auto d2 = CGAL::import_from_plane_graph(lcc2, input); auto d2 = CGAL::import_from_plane_graph(lcc2, input);
assert(d2 != LCC::null_descriptor); assert(d2 != LCC::null_descriptor);

View File

@ -1,4 +1,5 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h> #include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <CGAL/Polyhedron_3.h> #include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_3_to_lcc.h> #include <CGAL/Polyhedron_3_to_lcc.h>
#include <sstream> #include <sstream>
@ -20,7 +21,7 @@ int main()
auto d1 = CGAL::polyhedron_3_to_lcc(lcc1, P); auto d1 = CGAL::polyhedron_3_to_lcc(lcc1, P);
assert(d1 == LCC::null_descriptor); assert(d1 == LCC::null_descriptor);
#if !defined(CGAL_NO_DEPRECATED_CODE) && !defined(CGAL_NO_DEPRECATION_WARNINGS) #ifndef CGAL_NO_DEPRECATED_CODE
auto d2 = CGAL::import_from_polyhedron_3<LCC>(lcc2, P); auto d2 = CGAL::import_from_polyhedron_3<LCC>(lcc2, P);
assert(d2 == LCC::null_descriptor); assert(d2 == LCC::null_descriptor);
#endif #endif

View File

@ -1,4 +1,5 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h> #include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <CGAL/Delaunay_triangulation_3.h> #include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_3_to_lcc.h> #include <CGAL/Triangulation_3_to_lcc.h>
#include <cassert> #include <cassert>
@ -17,7 +18,7 @@ int main()
auto d1 = CGAL::triangulation_3_to_lcc(lcc1, T); auto d1 = CGAL::triangulation_3_to_lcc(lcc1, T);
assert(d1 == LCC_3::null_descriptor); assert(d1 == LCC_3::null_descriptor);
#if !defined(CGAL_NO_DEPRECATED_CODE) && !defined(CGAL_NO_DEPRECATION_WARNINGS) #ifndef CGAL_NO_DEPRECATED_CODE
auto d2 = CGAL::import_from_triangulation_3(lcc2, T); auto d2 = CGAL::import_from_triangulation_3(lcc2, T);
assert(d2 == LCC_3::null_descriptor); assert(d2 == LCC_3::null_descriptor);
#endif #endif

View File

@ -21,6 +21,7 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <CGAL/Polyhedron_3.h> #include <CGAL/Polyhedron_3.h>
#include <CGAL/config.h>
namespace CGAL { namespace CGAL {
@ -94,14 +95,21 @@ namespace CGAL {
return firstAll; return firstAll;
} }
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\deprecated This function is deprecated since CGAL 5.6. Use `polyhedron_3_to_lcc()` instead.
*/
template< class LCC, class Polyhedron > template< class LCC, class Polyhedron >
[[deprecated("Use polyhedron_3_to_lcc instead")]] CGAL_DEPRECATED
typename LCC::Dart_descriptor typename LCC::Dart_descriptor
import_from_polyhedron_3(LCC& alcc, const Polyhedron &apoly) import_from_polyhedron_3(LCC& alcc, const Polyhedron &apoly)
{ {
return polyhedron_3_to_lcc<LCC, Polyhedron>(alcc, apoly); return polyhedron_3_to_lcc<LCC, Polyhedron>(alcc, apoly);
} }
#endif // CGAL_NO_DEPRECATED_CODE
/** Convert a Polyhedron_3 read into a flux into 3D linear cell complex. /** Convert a Polyhedron_3 read into a flux into 3D linear cell complex.
* @param alcc the linear cell complex where Polyhedron_3 will be converted. * @param alcc the linear cell complex where Polyhedron_3 will be converted.
* @param ais the istream where read the Polyhedron_3. * @param ais the istream where read the Polyhedron_3.

View File

@ -19,6 +19,7 @@
#include <CGAL/assertions.h> #include <CGAL/assertions.h>
#include <map> #include <map>
#include <CGAL/Weighted_point_3.h> #include <CGAL/Weighted_point_3.h>
#include <CGAL/config.h>
namespace CGAL { namespace CGAL {
@ -149,15 +150,20 @@ namespace CGAL {
return dart; return dart;
} }
template < class LCC, class Triangulation > #ifndef CGAL_NO_DEPRECATED_CODE
[[deprecated("Use triangulation_3_to_lcc instead")]] /*!
typename LCC::Dart_descriptor import_from_triangulation_3 \deprecated This function is deprecated since CGAL 5.6. Use `triangulation_3_to_lcc()` instead.
(LCC& alcc, const Triangulation &atr, */
std::map<typename Triangulation::Cell_handle, template <class LCC, class Triangulation>
typename LCC::Dart_descriptor >* avol_to_dart=nullptr) CGAL_DEPRECATED
typename LCC::Dart_descriptor
import_from_triangulation_3(LCC& alcc, const Triangulation& atr,
std::map<typename Triangulation::Cell_handle,
typename LCC::Dart_descriptor>* avol_to_dart = nullptr)
{ {
return triangulation_3_to_lcc(alcc, atr, avol_to_dart); return triangulation_3_to_lcc(alcc, atr, avol_to_dart);
} }
#endif
} // namespace CGAL } // namespace CGAL