diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h index a709bddd4b1..baf8908269c 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h @@ -622,7 +622,7 @@ bool are_holes_and_boundary_pairwise_disjoint Topology_traits; typedef CGAL::Gps_on_surface_base_2 Polygon_set_2; - typedef typename Polygon_set_2::Size Size; + // typedef typename Polygon_set_2::Size Size; typedef typename Traits_2::Polygon_2 Polygon_2; typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; typedef typename Polygon_with_holes_2::Hole_const_iterator @@ -676,7 +676,7 @@ bool are_holes_and_boundary_pairwise_disjoint Polygon_set_2 gps(traits); // check for 2D intersections of holes (holes must be disjoint except for // vertices) - Size num_of_holes = 0; + // Size num_of_holes = 0; // functors for creating a pwh needed for inserting pgns into the arrangement // quickly Construct_polygon_with_holes_2 construct_pwh_functor = @@ -700,7 +700,7 @@ bool are_holes_and_boundary_pairwise_disjoint // traits.Construct_polygon_with_holes_2 (hole); // Polygon_with_holes_2 empty_pwh(hole); gps.insert(empty_pwh); - num_of_holes++; + // num_of_holes++; } } /* not good - doesn't work if intersection at vertices is legal. diff --git a/GraphicsView/include/CGAL/Qt/qglviewer.h b/GraphicsView/include/CGAL/Qt/qglviewer.h index e24a5fcd6d7..673e9450980 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer.h @@ -34,6 +34,13 @@ #include #include +#ifndef APIENTRY +#define APIENTRY QT_APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + class QTabWidget; class QImage; class QOpenGLFramebufferObject; diff --git a/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt b/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt index 3c344555147..dda7d3fac53 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt +++ b/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt @@ -49,7 +49,7 @@ else() endif() find_package(Boost QUIET OPTIONAL_COMPONENTS filesystem system) -if(Boost_FILESYSTEM_FOUND) +if(Boost_FILESYSTEM_FOUND AND Boost_SYSTEM_FOUND) qt6_wrap_ui( imgUI_FILES Image_res_dialog.ui raw_image.ui) cgal_lab_plugin(io_image_plugin Io_image_plugin Volume_plane_intersection.cpp diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h index 25096d0c26f..35c3104dd7e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h @@ -646,6 +646,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range, { using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; + using parameters::is_default_parameter; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -702,21 +703,25 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range, CGAL_precondition(is_triangle_mesh(tmesh)); // constrain extremities of constrained edges - for(face_descriptor f : face_range) + if constexpr (!is_default_parameter::value || + !is_default_parameter::value) { - if(f == boost::graph_traits::null_face()) - continue; - - for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, tmesh), tmesh)) + for(face_descriptor f : face_range) { - if(get(ecm, edge(h, tmesh))) + if(f == boost::graph_traits::null_face()) + continue; + + for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, tmesh), tmesh)) { - put(vcm, source(h, tmesh), true); - put(vcm, target(h, tmesh), true); - } - else if(get(vcm_np, target(h, tmesh))) - { - put(vcm, target(h, tmesh), true); + if(get(ecm, edge(h, tmesh))) + { + put(vcm, source(h, tmesh), true); + put(vcm, target(h, tmesh), true); + } + else if(get(vcm_np, target(h, tmesh))) + { + put(vcm, target(h, tmesh), true); + } } } } @@ -813,7 +818,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range, const edge_descriptor e = edge(h, tmesh); CGAL_assertion(!get(ecm, edge(h, tmesh))); - CGAL_assertion(!get(vcm, source(h, tmesh)) && !get(vcm, target(h, tmesh))); + CGAL_assertion(!get(vcm, source(h, tmesh)) || !get(vcm, target(h, tmesh))); #ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA std::cout << " treat needle: " << e diff --git a/Property_map/include/CGAL/Property_container.h b/Property_map/include/CGAL/Property_container.h index 4aa3fe15577..0f9c35ed8b8 100644 --- a/Property_map/include/CGAL/Property_container.h +++ b/Property_map/include/CGAL/Property_container.h @@ -50,7 +50,7 @@ public: virtual void append(const Property_array_base& other) = 0; - virtual void reserve(std::size_t n) = 0; + virtual void resize(std::size_t n) = 0; virtual void shrink_to_fit() = 0; @@ -89,7 +89,6 @@ public: Property_array(const std::vector& active_indices, const T& default_value) : m_data(), m_active_indices(active_indices), m_default_value(default_value) { - m_data.reserve(active_indices.capacity()); m_data.resize(active_indices.size(), m_default_value); } @@ -124,7 +123,7 @@ public: m_data.insert(m_data.end(), other.m_data.begin(), other.m_data.end()); } - virtual void reserve(std::size_t n) override { + virtual void resize(std::size_t n) override { CGAL_precondition(m_active_indices.size() == n); m_data.resize(n, m_default_value); }; @@ -248,6 +247,7 @@ class Property_container { std::multimap>> m_properties; std::vector m_active_indices{}; + bool m_has_deleted_elements = false; public: @@ -258,6 +258,7 @@ public: Property_container(const Property_container& other) { m_active_indices = other.m_active_indices; + m_has_deleted_elements = other.m_has_deleted_elements; for (auto [name, array] : other.m_properties) { // todo: this could probably be made faster using emplace_hint @@ -273,6 +274,7 @@ public: // This is not exactly an assignment as existing unique properties are kept. Property_container& operator=(const Property_container& other) { m_active_indices = other.m_active_indices; + m_has_deleted_elements = other.m_has_deleted_elements; for (auto [name, array] : other.m_properties) { // search if property already exists @@ -295,6 +297,7 @@ public: // This is not exactly an assignment as existing unique properties are kept. Property_container& operator=(Property_container&& other) { m_active_indices = std::move(other.m_active_indices); + m_has_deleted_elements = other.m_has_deleted_elements; for (auto [name, array] : other.m_properties) { // search if property already exists @@ -312,7 +315,7 @@ public: } // The moved-from property map should retain all of its properties, but contain 0 elements - other.reserve(0); + other.resize(0); return *this; } @@ -441,16 +444,15 @@ public: }*/ public: - - void reserve(std::size_t n) { - m_active_indices.resize(n); - for (auto [name, array]: m_properties) - array->reserve(n); - } - void resize(std::size_t n) { - reserve(n); + + m_active_indices.resize(n); + for (auto [name, array] : m_properties) + array->resize(n); + std::fill(m_active_indices.begin(), m_active_indices.end(), true); + + m_has_deleted_elements = false; } [[nodiscard]] std::size_t size() const { return std::count(m_active_indices.begin(), m_active_indices.end(), true); } @@ -460,8 +462,11 @@ public: Index emplace_back() { // Expand the storage and return the last element - reserve(capacity() + 1); - m_active_indices.back() = true; + m_active_indices.push_back(true); + + for (auto [name, array] : m_properties) + array->resize(capacity()); + auto first_new_index = Index(capacity() - 1); reset(first_new_index); return first_new_index; @@ -469,6 +474,9 @@ public: Index emplace() { + if (!m_has_deleted_elements) + return emplace_back(); + // If there are empty slots, return the index of one of them and mark it as full auto first_unused = std::find_if(m_active_indices.begin(), m_active_indices.end(), [](bool used) { return !used; }); if (first_unused != m_active_indices.end()) { @@ -478,20 +486,27 @@ public: return index; } + m_has_deleted_elements = false; + return emplace_back(); } Index emplace_group_back(std::size_t n) { // Expand the storage and return the start of the new region - reserve(capacity() + n); - for (auto it = m_active_indices.end() - n; it < m_active_indices.end(); ++it) - *it = true; + m_active_indices.resize(capacity() + n, true); + + for (auto [name, array] : m_properties) + array->resize(capacity()); + return Index(capacity() - n); } Index emplace_group(std::size_t n) { + if (!m_has_deleted_elements) + return emplace_group_back(n); + auto search_start = m_active_indices.begin(); while (search_start != m_active_indices.end()) { @@ -544,6 +559,7 @@ public: void erase(Index i) { m_active_indices[i] = false; + m_has_deleted_elements = true; for (auto [name, array]: m_properties) array->reset(i); } @@ -606,7 +622,7 @@ public: if (it != range.second) array->append(*it->second.get()); else - array->reserve(m_active_indices.size()); + array->resize(m_active_indices.size()); } } diff --git a/Property_map/test/Property_map/test_Property_container.cpp b/Property_map/test/Property_map/test_Property_container.cpp index eb0099ed8c1..364ae65fdd6 100644 --- a/Property_map/test/Property_map/test_Property_container.cpp +++ b/Property_map/test/Property_map/test_Property_container.cpp @@ -41,11 +41,6 @@ void test_element_access() { auto& integers = properties.add_property("integers", 5); - // Reserve space for 100 elements - properties.reserve(100); - assert(properties.capacity() == 100); - assert(properties.size() == 0); - // Newly emplaced elements should go at the front assert(properties.emplace() == 0); assert(properties.emplace() == 1); @@ -61,7 +56,6 @@ void test_element_access() { auto& floats = properties.add_property("floats", 6.0f); // The new property array should already be of the right size - assert(floats.capacity() == 100); assert(properties.size() == 3); // Pre-existing elements should contain the default value @@ -87,9 +81,8 @@ void test_element_access() { // Erase an element, and the size should be reduced properties.erase(1); assert(properties.size() == 2); - assert(properties.capacity() == 100); assert(properties.active_list().size() == 2); - assert(properties.inactive_list().size() == 98); + assert(properties.inactive_list().size() == 1); // A newly emplaced element should take the empty slot assert(properties.emplace() == 1); diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/ARAP_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/ARAP_parameterization.cpp index 6919bd32dc8..192502af616 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/ARAP_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/ARAP_parameterization.cpp @@ -26,6 +26,11 @@ namespace SMP = CGAL::Surface_mesh_parameterization; int main(int argc, char** argv) { +#ifdef CGAL_SMP_USE_SUITESPARSE_SOLVERS + std::cout << "Using SuiteSparse" << std::endl; +#else + std::cout << "Using Eigen3" << std::endl; +#endif const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/head.off"); SurfaceMesh sm; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt index c0c9b03e652..c8f3149f3a0 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt @@ -34,13 +34,11 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(square_border_parameterizer PRIVATE CGAL::Eigen3_support) create_single_source_cgal_program( "iterative_authalic_parameterizer.cpp" ) target_link_libraries(iterative_authalic_parameterizer PRIVATE CGAL::Eigen3_support) - if(SuiteSparse_FOUND) - target_link_libraries(ARAP_parameterization PRIVATE ${SuiteSparse_LIBRARIES}) - target_link_libraries(orbifold PRIVATE ${SuiteSparse_LIBRARIES}) - if(SuiteSparse_UMFPACK_FOUND OR TARGET SuiteSparse::umfpack) - target_compile_definitions(ARAP_parameterization PRIVATE EIGEN_DONT_ALIGN_STATICALLY CGAL_SMP_USE_SUITESPARSE_SOLVERS ) - target_compile_definitions(orbifold PRIVATE EIGEN_DONT_ALIGN_STATICALLY CGAL_SMP_USE_SUITESPARSE_SOLVERS ) - endif() + if(TARGET SuiteSparse::UMFPACK) + target_link_libraries(ARAP_parameterization PRIVATE SuiteSparse::UMFPACK) + target_link_libraries(orbifold PRIVATE PRIVATE SuiteSparse::UMFPACK) + target_compile_definitions(ARAP_parameterization PRIVATE EIGEN_DONT_ALIGN_STATICALLY CGAL_SMP_USE_SUITESPARSE_SOLVERS) + target_compile_definitions(orbifold PRIVATE EIGEN_DONT_ALIGN_STATICALLY CGAL_SMP_USE_SUITESPARSE_SOLVERS) endif() else() diff --git a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt index 0a0e459223a..62639571dca 100644 --- a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt +++ b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt @@ -6,11 +6,24 @@ project(Surface_mesh_parameterization_Tests) # Find CGAL find_package(CGAL REQUIRED) +find_package(UMFPACK QUIET NO_MODULE) + +if(TARGET SuiteSparse::UMFPACK) + message(STATUS "Orbifold Tutte Embeddings will use UmfPackLU") +else() + message(STATUS "NOTICE: Examples will be compiled without the SuiteSparse library and UmfPack. Try setting CMAKE_PREFIX_PATH to your SuiteSparse installation.") +endif() + find_package(Eigen3 3.1.0 QUIET) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("extensive_parameterization_test.cpp") target_link_libraries(extensive_parameterization_test PRIVATE CGAL::Eigen3_support) + + if(TARGET SuiteSparse::UMFPACK) + target_link_libraries(extensive_parameterization_test PRIVATE SuiteSparse::UMFPACK) + target_compile_definitions(extensive_parameterization_test PRIVATE EIGEN_DONT_ALIGN_STATICALLY CGAL_SMP_USE_SUITESPARSE_SOLVERS) + endif() else() message("NOTICE: The tests require Eigen 3.1 (or greater), and will not be compiled.") endif() diff --git a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp index ff97d007295..dbfc458d93d 100644 --- a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp +++ b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/extensive_parameterization_test.cpp @@ -78,6 +78,11 @@ typedef boost::graph_traits::halfedge_descriptor SM_SE_halfedge int main(int, char**) { +#ifdef CGAL_SMP_USE_SUITESPARSE_SOLVERS + std::cout << "Using SuiteSparse" << std::endl; +#else + std::cout << "Using Eigen3" << std::endl; +#endif std::cout.precision(17); CGAL::IO::set_pretty_mode(std::cout); diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_cell_base_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_cell_base_3.h index af8ad177b2b..388f92d600c 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_cell_base_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_cell_base_3.h @@ -75,7 +75,7 @@ circumcenter is not supposed to be computed by the constructor `Construct_weighted_circumcenter_3` of the traits class, hence the returned point has no weight. */ -const Point_3& weighted_circumcenter(const Traits& gt = Traits()) const; +Point_3 weighted_circumcenter(const Traits& gt = Traits()) const; /// @} diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 6b5246c0d21..a65d61fe621 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -665,6 +665,9 @@ public: { CGAL_precondition(dimension() >= 2); + if(the_facet_is_in_its_cz) + *the_facet_is_in_its_cz = false; + std::vector cells; cells.reserve(32); std::vector facets;