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

Improvement backports from CDT_3 branch (Follow-up to PR #8170) #8273

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c10dcf7
allow to call save_binary_file on non-C3t3 type (like a CDT_3)
lrineau Jun 10, 2024
93fd966
use boost::unordered_flat_map to optimize Polyline_constraint_hierarc…
lrineau Apr 15, 2024
82b5359
Mesh_2: sort the sequence tr.subconstraints_begin(), tr.subconstraint…
lrineau Jun 13, 2024
aaac2c2
Merge remote-tracking branch 'cgal/master' into pr/lrineau/8273
lrineau Jan 8, 2025
5526857
Add CGAL::unordered_flat_map implementation
lrineau Jan 8, 2025
b12625f
fix an error detected by UBSAN
lrineau Jan 8, 2025
ea151ff
fix CGAL_USE_BARE_STD_MAP with Polyline_constraint_hierarchy_2
lrineau Jan 8, 2025
bc8c1e6
new allocator type, that allocates randomly on purpose
lrineau Jan 8, 2025
364ba15
fix a missing #include
lrineau Jan 8, 2025
e5807ca
TWS
sloriot Jan 10, 2025
56bb419
cleanup existing code
lrineau Jan 10, 2025
e03ba91
Boost >= 1.74 is now required
lrineau Jan 10, 2025
93ac184
CDT_plus_2 hierarchy: add Edge_iterator, that is deterministic
lrineau Jan 10, 2025
d468962
hierarchy: remove `remove_Steiner(T v, T va, T vb)`
lrineau Jan 13, 2025
926bb0c
hierarchy: remove two undefined member functions
lrineau Jan 13, 2025
eafa97a
major cleanup of Polyline_constraint_hierarchy_2
lrineau Jan 13, 2025
1f70e59
doc bug-fix
lrineau Jan 14, 2025
d4e6ffd
fix protection against min/max macros
lrineau Jan 14, 2025
2869ad8
fix compilation errors with C++<20
lrineau Jan 15, 2025
cf50ad8
document the breakng change
lrineau Jan 16, 2025
cf815b8
doc fix: add that iterators are all bidirectional
lrineau Jan 16, 2025
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
35 changes: 35 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: true
BinPackParameters: false
BreakConstructorInitializers: BeforeComma
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
ColumnLimit: 120
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
# Control the spaces around conditionals
SpacesInConditionalStatement: false
SpaceBeforeParens: false
...
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ double mean_min_angle(const Mesh& mesh)
const Triangle_3 tr = surface_mesh_face_to_triangle(f, mesh);
std::array<FT, 3> angles = triangle_angles(tr);

FT min_angle = std::min({angles[0], angles[1], angles[2]});
FT min_angle = (std::min)({angles[0], angles[1], angles[2]});

min_angle = min_angle * (180.0 / CGAL_PI);
mean_min_angle += min_angle;
Expand All @@ -93,7 +93,7 @@ double mean_max_angle(const Mesh& mesh)
const Triangle_3 tr = surface_mesh_face_to_triangle(f, mesh);
std::array<FT, 3> angles = triangle_angles(tr);

FT max_angle = std::max({angles[0], angles[1], angles[2]});
FT max_angle = (std::max)({angles[0], angles[1], angles[2]});

max_angle = max_angle * (180.0 / CGAL_PI);
mean_max_angle += max_angle;
Expand Down Expand Up @@ -151,8 +151,8 @@ double mean_edge_ratio(const Mesh& mesh,
FT a = std::sqrt(CGAL::squared_distance(tr[0], tr[1]));
FT b = std::sqrt(CGAL::squared_distance(tr[1], tr[2]));
FT c = std::sqrt(CGAL::squared_distance(tr[2], tr[0]));
FT min_edge = std::min({a, b, c});
FT max_edge = std::max({a, b, c});
FT min_edge = (std::min)({a, b, c});
FT max_edge = (std::max)({a, b, c});
FT edge_ratio = max_edge / min_edge;

mean_edge_ratio += edge_ratio;
Expand Down Expand Up @@ -181,7 +181,7 @@ double mean_aspect_ratio(const Mesh& mesh,
FT c = std::sqrt(CGAL::squared_distance(tr[2], tr[0]));
FT s = 0.5 * (a + b + c);
FT inscribed_radius = std::sqrt((s * (s - a) * (s - b) * (s - c)) / s);
FT max_edge = std::max({a, b, c});
FT max_edge = (std::max)({a, b, c});
FT aspect_ratio = max_edge / inscribed_radius;
aspect_ratio /= (2. * std::sqrt(3.)); // normalized
mean_aspect_ratio += aspect_ratio;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void GUI_country_pick_handler::mouse_press_event(QMouseEvent* e) {
auto sd = sqrt(d);
auto t1 = (-b - sd) / (2 * a);
auto t2 = (-b + sd) / (2 * a);
if (t1 > 0 && t2 > 0) ti = std::min(t1, t2);
if (t1 > 0 && t2 > 0) ti = (std::min)(t1, t2);
else if (t1 > 0) ti = t1;
else ti = t2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void Main_widget::initializeGL() {
for (auto& [country_name, triangle_points] : country_triangles_map) {
auto country_triangles = std::make_unique<Triangles>(triangle_points);
auto color = QVector4D(rndm(), rndm(), rndm(), 1);
auto m = std::max(color.x(), std::max(color.y(), color.z()));
auto m = (std::max)(color.x(), (std::max)(color.y(), color.z()));
color /= m;
color *= m_dimming_factor;
color.setW(1);
Expand Down
2 changes: 1 addition & 1 deletion CGAL_Core/include/CGAL/CORE/poly/Curves.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ template <class NT>
int BiPoly<NT>::getXdegree(){
int deg=-1;
for(int i=0; i <=ydeg; i++)
deg = max(deg, coeffX[i].getTrueDegree());
deg = (max)(deg, coeffX[i].getTrueDegree());
return deg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ advanced_make_xy_monotone( const typename CK::Circular_arc_2 &a,
double ymax = (is_on_upper) ?
to_interval
( CircularFunctors::y_extremal_point<CK>(a.supporting_circle(),false).y() ).second :
CGAL::max(left_bb.ymax(),right_bb.ymax());
(CGAL::max)(left_bb.ymax(),right_bb.ymax());
*/
return Bbox_2(left_bb.xmin(),ymin,right_bb.xmax(),ymax);
}
Expand Down
2 changes: 1 addition & 1 deletion Distance_3/include/CGAL/Distance_3/Triangle_3_Triangle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ squared_distance(const typename K::Triangle_3& tr1,
FT sqd_q2 = CGAL::squared_distance(vertex(tr2, 1), tr1);
FT sqd_r2 = CGAL::squared_distance(vertex(tr2, 2), tr1);

const FT m = std::min({sqd_p1, sqd_q1, sqd_r1, sqd_p2, sqd_q2, sqd_r2});
const FT m = (std::min)({sqd_p1, sqd_q1, sqd_r1, sqd_p2, sqd_q2, sqd_r2});

return m;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Documentation/doc/Documentation/Third_party.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ or <A HREF="https://msdn.microsoft.com/en-us/library/1fe2x6kt(v=vs.140).aspx">`h
The \stl comes with the compiler, and as such no installation is required.

\subsection thirdpartyBoost Boost
<b>Version 1.72 or later</b>
<b>Version 1.74 or later</b>

The \boost libraries are a set of portable C++ source libraries.
Most of \boost libraries are header-only, but a few of them need to be compiled or
Expand Down Expand Up @@ -86,7 +86,6 @@ Version supported are <b>GMP Version 5.0.1 or later, MPFR Version 3.0.0 or later

The \boost library also provides a module for multi precision integers and rational numbers:
<A HREF="https://www.boost.org/doc/libs/release/libs/multiprecision/doc/html/index.html">\boost multiprecision</A>.
Versions supported are <b>\boost Version 1.72 or later</b>.

The components \cgal, and `CGAL_Qt6` require either \gmp and \mpfr, or \boost multiprecision
for multi precision numbers. `CGAL_Core` requires \boost multiprecision.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,11 @@ other but never both.

\subsection installation_boost Boost Libraries

\subsubsection inst_boost_1_72_plus Version 1.72 and Later
Starting from \boost 1.72, the cmake config mode can be used for configuring the \boost version
to use by setting the environment variable `Boost_DIR` to the path containing the file
`BoostConfig.cmake`. For example if you manually installed \boost 1.77 with `--prefix=<path>`,
then you should set `Boost_DIR=<path>/lib/cmake/Boost-1.77.0`.

\subsubsection inst_boost_up_2_1_69 Version 1.69 and Earlier

\warning If you have a version of Boost greater than 1.69 already installed on your system, and you want to configure and compile with an earlier version of Boost, then you will need to set the CMake variable `Boost_NO_BOOST_CMAKE` to `ON` (otherwise the `FindBoost.cmake` module of CMake will start searching for `BoostConfig.cmake`, and ignore the `BOOST_ROOT` variable).

In most cases, if \boost is not automatically found, setting the `BOOST_ROOT`
variable is enough. If it is not, you can specify the header and library
directories individually. You can also provide the full pathname to a specific compiled library
if it cannot be found in the library directory or its name is non-standard.

By default, when \boost binary libraries are needed, the shared versions
are used if present. You can set the variable
`CGAL_Boost_USE_STATIC_LIBS` to `ON` if you want to link
Expand All @@ -128,17 +118,6 @@ the `.dll` files are found by the dynamic linker, at run time.
For example, you can add the path to the \boost `.dll` to the
`PATH` environment variable.

| Variable | Description | Type |
| :- | :- | :- |
| `BOOST_ROOT`\cgalFootnote{The environment variable can be spelled either \cgalFootnoteCode{BOOST_ROOT} or \cgalFootnoteCode{BOOSTROOT}} | Root directory of your \boost installation | Either CMake or Environment |
| `Boost_INCLUDE_DIR` | Directory containing the `boost/version.hpp` file | CMake |
| `BOOST_INCLUDEDIR` | Idem | Environment |
| `Boost_LIBRARY_DIRS` | Directory containing the compiled \boost libraries | CMake |
| `BOOST_LIBRARYDIR` | Idem | Environment |
| `Boost_(xyz)_LIBRARY_RELEASE` | Full pathname to a release build of the compiled 'xyz' \boost library | CMake |
| `Boost_(xyz)_LIBRARY_DEBUG` | Full pathname to a debug build of the compiled 'xyz' \boost library | CMake |


\subsection installation_gmp GMP and MPFR Libraries

Under Windows, auto-linking is used, so only the <I>directory</I>
Expand Down
9 changes: 9 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

## [Release 6.1](https://github.com/CGAL/cgal/releases/tag/v6.1)

### General Changes
- The minimal supported version of Boost is now 1.74.0.

### [Algebraic Kernel](https://doc.cgal.org/6.1/Manual/packages.html#PkgAlgebraicKernelD)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must also announce the breaking changes in Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h.


- **Breaking change**: Classes based on the RS Library are no longer provided.
Expand All @@ -11,6 +14,12 @@

- Introduces two traits decorators, namely `Arr_tracing_traits_2` and `Arr_counting_traits_2`, which can be used to extract debugging and informative metadata about the traits in use while a program is being executed.

### [2D Triangulations](https://doc.cgal.org/6.1/Manual/packages.html#PkgTriangulation2)

- **Breaking change**: In the class template `Constrained_triangulation_plus_2`, the value type of the range returned
by `subconstraints()` has changed from `const std::pair<const Subconstraint, std::list<Context>*>` to `Subconstraint`.
The old range type is now returned by a new function named `subconstraints_and_contexts()`.

## [Release 6.0.1](https://github.com/CGAL/cgal/releases/tag/v6.0.1)

### [Poisson Surface Reconstruction](https://doc.cgal.org/6.0.1/Manual/packages.html#PkgPoissonSurfaceReconstruction3)
Expand Down
5 changes: 3 additions & 2 deletions Installation/cmake/modules/CGAL_SetupBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ set ( CGAL_Boost_Setup TRUE )

include(${CMAKE_CURRENT_LIST_DIR}/CGAL_TweakFindBoost.cmake)

find_package( Boost 1.72 REQUIRED )
cmake_policy(VERSION 3.12...3.30)
find_package( Boost 1.74 REQUIRED )

if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.72)
if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.74)
if(DEFINED Boost_DIR AND NOT Boost_DIR)
# Unset that cache variable that is set in the cache by FindBoost
# (while it was searching for boost-cmake).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE)
#

function(CGAL_setup_CGAL_Core_dependencies target)
find_package( Boost 1.72 REQUIRED )
find_package( Boost 1.74 REQUIRED )
if (NOT CGAL_DISABLE_GMP AND GMP_FOUND)
use_CGAL_GMP_support(CGAL_Core INTERFACE)
endif()
Expand Down
8 changes: 6 additions & 2 deletions Lab/demo/Lab/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2396,8 +2396,12 @@ void MainWindow::viewerShowObject()
}
if(item) {
const Scene::Bbox bbox = item->bbox();
CGAL::qglviewer::Vec min(static_cast<float>(bbox.xmin())+viewer->offset().x, static_cast<float>(bbox.ymin())+viewer->offset().y, static_cast<float>(bbox.zmin())+viewer->offset().z),
max(static_cast<float>(bbox.xmax())+viewer->offset().x, static_cast<float>(bbox.ymax())+viewer->offset().y, static_cast<float>(bbox.zmax())+viewer->offset().z);
CGAL::qglviewer::Vec min{static_cast<float>(bbox.xmin()) + viewer->offset().x,
static_cast<float>(bbox.ymin()) + viewer->offset().y,
static_cast<float>(bbox.zmin()) + viewer->offset().z};
CGAL::qglviewer::Vec max{static_cast<float>(bbox.xmax()) + viewer->offset().x,
static_cast<float>(bbox.ymax()) + viewer->offset().y,
static_cast<float>(bbox.zmax()) + viewer->offset().z};
viewer->setSceneBoundingBox(min, max);
viewerShow(static_cast<float>(min.x), static_cast<float>(min.y), static_cast<float>(min.z),
static_cast<float>(max.x), static_cast<float>(max.y), static_cast<float>(max.z));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void compute(SMesh* sMesh,
for (Vertex_descriptor v : vertices(*sMesh))
{
const PMP::Principal_curvatures_and_directions<Epic_kernel> pc = principal_curvatures_and_directions_map[v];
max_curvature_magnitude_on_mesh = std::max(max_curvature_magnitude_on_mesh, std::max(abs(pc.min_curvature), abs(pc.max_curvature)));
max_curvature_magnitude_on_mesh =
(std::max)(max_curvature_magnitude_on_mesh, (std::max)(abs(pc.min_curvature), abs(pc.max_curvature)));
}

for(Vertex_descriptor v : vertices(*sMesh))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ main( int argc, char* argv[])
*/

// evt. update max_entry:
max_entry = max( a[dim - 1] + b[dim - 1], max_entry);
max_entry = (max)( a[dim - 1] + b[dim - 1], max_entry);

// keep both vectors:
vectors.push_back( a);
Expand Down
17 changes: 5 additions & 12 deletions Mesh_2/include/CGAL/Delaunay_mesher_no_edge_refinement_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Delaunay_mesher_no_edge_refinement_2
Faces_level faces_level;

Seeds seeds;
bool seeds_mark;
bool seeds_mark = false;
bool initialized = false;
public:
/** \name CONSTRUCTORS */
Delaunay_mesher_no_edge_refinement_2(Tr& tr_, const Criteria& criteria_ = Criteria())
Expand All @@ -72,20 +73,18 @@ class Delaunay_mesher_no_edge_refinement_2
null_level(),
null_visitor(),
edges_level(tr, null_level),
faces_level(tr, criteria, edges_level),
initialized(false)
faces_level(tr, criteria, edges_level)
{
}

Delaunay_mesher_no_edge_refinement_2(Tr& tr_, Edges_level& edges_level_,
const Criteria& criteria_ = Criteria())
const Criteria& criteria_ = Criteria())
: tr(tr_),
criteria(criteria_),
null_level(),
null_visitor(),
edges_level(edges_level_),
faces_level(tr, criteria, edges_level),
initialized(false)
faces_level(tr, criteria, edges_level)
{
}

Expand All @@ -101,12 +100,6 @@ class Delaunay_mesher_no_edge_refinement_2
return seeds.end();
}

private:
/** \name INITIALIZED */

bool initialized;

public:
/** \name MARKING FUNCTIONS */

/** The value type of \a InputIterator should be `Point`, and represents
Expand Down
7 changes: 3 additions & 4 deletions Mesh_2/include/CGAL/Mesh_2/Clusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,14 @@ class Clusters
void create_clusters(Tag_true) {
cluster_map.clear();
Unique_hash_map<Vertex_handle,bool> created(false);
for(typename Tr::Subconstraint_iterator it = tr.subconstraints_begin();
it != tr.subconstraints_end(); ++it) {
Vertex_handle vh = it->first.first;
for(const auto& sc : tr.subconstraints()) {
Vertex_handle vh = sc.first;
if(!created[vh]){
created[vh] = true;
create_clusters_of_vertex(vh);
}

vh = it->first.second;
vh = sc.second;
if(!created[vh]){
created[vh] = true;
create_clusters_of_vertex(vh);
Expand Down
8 changes: 1 addition & 7 deletions Mesh_2/include/CGAL/Mesh_2/Refine_edges.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,8 @@ class Refine_edges_base :

void scan_triangulation_impl(Tag_true)
{
// with constraint hierarchy

for(typename Tr::Subconstraint_iterator it = tr.subconstraints_begin();
it != tr.subconstraints_end(); ++it)
for(const auto& [v1, v2] : tr.subconstraints())
{
const Vertex_handle& v1 = it->first.first;
const Vertex_handle& v2 = it->first.second;

if(!is_locally_conform(tr, v1, v2) ){
add_constrained_edge_to_be_conformed(v1, v2);
}
Expand Down
4 changes: 4 additions & 0 deletions Mesh_2/test/Mesh_2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ file(
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()

if(cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
target_compile_features(test_mesh_terrain PRIVATE cxx_std_20)
endif()
19 changes: 2 additions & 17 deletions Mesh_2/test/Mesh_2/conform_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ int main()

std::pair<Vertex_handle,Vertex_handle> p;

for(CDT::Subconstraint_iterator sit = cdt.subconstraints_begin();
sit != cdt.subconstraints_end();
++sit){

p = (*sit).first;

Vertex_handle vh1 = p.first;
Vertex_handle vh2 = p.second;

for(const auto& [vh1, vh2] : cdt.subconstraints()) {
std::cerr << "subconstraint: " << vh1->point() << " -- " << vh2->point() << std::endl;
}

Expand All @@ -36,15 +28,8 @@ int main()

int counter = 0;

for(CDT::Subconstraint_iterator sit = cdt.subconstraints_begin();
sit != cdt.subconstraints_end();
++sit){
for(const auto& [vh1, vh2] : cdt.subconstraints()) {
++counter;
p = (*sit).first;

Vertex_handle vh1 = p.first;
Vertex_handle vh2 = p.second;

std::cerr << "subconstraint: " << vh1->point() << " -- " << vh2->point() << std::endl;
}

Expand Down
Loading
Loading