From c787e40ca7a3069bbd9a3d2181f0effb51fc3626 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 18 Mar 2019 13:14:00 +0100 Subject: [PATCH 01/20] Use boost variant for attributes to be able to send `double`s, `uint_8`s and `std::size_t`s --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 46 +++++++++++++++---- .../Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 2 +- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index 5c9583ba272..333f6f275d4 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -258,12 +258,20 @@ write_attributes(std::ostream& os, write_vector(os,att); } +enum VTU_ATTRIBUTE_TYPE{ + DOUBLE=0, + UNIT_8, + SIZE_TYPE +}; + template void output_to_vtu_with_attributes(std::ostream& os, const C3T3& c3t3, - std::vector*> >& attributes, + std::vector, std::vector, std::vector >*> >& attributes, + // std::vector& attribute_types, IO::Mode mode = IO::BINARY) { + //CGAL_assertion(attributes.size() == attribute_types.size()); typedef typename C3T3::Triangulation Tr; typedef typename Tr::Vertex_handle Vertex_handle; const Tr& tr = c3t3.triangulation(); @@ -296,7 +304,17 @@ void output_to_vtu_with_attributes(std::ostream& os, os << " \n"; for(std::size_t i = 0; i< attributes.size(); ++i) { - write_attribute_tag(os,attributes[i].first, *attributes[i].second, binary,offset); + switch(attributes[i].second->which()){ + case 0: + write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + break; + case 1: + write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + break; + default: + write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + break; + } } os << " \n"; os << " \n" @@ -306,7 +324,17 @@ void output_to_vtu_with_attributes(std::ostream& os, write_c3t3_points(os,tr,V); // fills V if the mode is BINARY write_cells(os,c3t3,V); for(std::size_t i = 0; i< attributes.size(); ++i) - write_attributes(os, *attributes[i].second); + switch(attributes[i].second->which()){ + case 0: + write_attributes(os, *boost::get >(attributes[i].second)); + break; + case 1: + write_attributes(os, *boost::get >(attributes[i].second)); + break; + default: + write_attributes(os, *boost::get >(attributes[i].second)); + break; + } } os << "\n"; } @@ -324,11 +352,13 @@ void output_to_vtu(std::ostream& os, for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; ++cit ) - { - mids.push_back(cit->subdomain_index()); - } - std::vector* > > atts; - atts.push_back(std::make_pair("MeshDomain", &mids)); + { + double v = cit->subdomain_index(); + mids.push_back(v); + } + std::vector, std::vector, std::vector >* > > atts; + boost::variant, std::vector, std::vector > v = mids; + atts.push_back(std::make_pair("MeshDomain", &v)); output_to_vtu_with_attributes(os, c3t3, atts, mode); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 30855054d34..514834003fb 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -318,7 +318,7 @@ public: const Scene_facegraph_item* poly_item = qobject_cast(item); - + if (poly_item) { if (extension != "vtp") From b9762b9431848f27697960d4c0c0ad3934d41260 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 19 Mar 2019 10:47:01 +0100 Subject: [PATCH 02/20] Fix declared type in xml --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index 333f6f275d4..da0911a7e4a 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -231,7 +231,20 @@ write_attribute_tag(std::ostream& os, std::size_t& offset) { std::string format = binary ? "appended" : "ascii"; - std::string type = (sizeof(T) == 8) ? "Float64" : "Float32"; + std::string type = ""; + if(std::is_floating_point::value) + { + type = (sizeof(T) == 8) ? "Float64" : "Float32"; + } + else + { + if(sizeof(T) == 1) + type = "UInt8"; + else if(sizeof(T) == 4) + type = "UInt32"; + else + type = "UInt64"; + } os << " void output_to_vtu_with_attributes(std::ostream& os, const C3T3& c3t3, std::vector, std::vector, std::vector >*> >& attributes, - // std::vector& attribute_types, IO::Mode mode = IO::BINARY) { //CGAL_assertion(attributes.size() == attribute_types.size()); @@ -348,7 +360,8 @@ void output_to_vtu(std::ostream& os, IO::Mode mode = IO::BINARY) { typedef typename C3T3::Cells_in_complex_iterator Cell_iterator; - std::vector mids; + std::vector mids; + std::size_t id = 0; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; ++cit ) @@ -356,6 +369,7 @@ void output_to_vtu(std::ostream& os, double v = cit->subdomain_index(); mids.push_back(v); } + std::vector, std::vector, std::vector >* > > atts; boost::variant, std::vector, std::vector > v = mids; atts.push_back(std::make_pair("MeshDomain", &v)); From 15aca3ebf7a6012836d316a64b5786f2a7538e1a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 19 Mar 2019 16:08:28 +0100 Subject: [PATCH 03/20] Add a bool to decide if we want to export the complex or the cells not in complex. --- .../IO/Complex_3_in_triangulation_3_to_vtk.h | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h index 8370bab261f..cecf3aefea1 100644 --- a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h +++ b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h @@ -35,10 +35,12 @@ namespace CGAL { +//if export_complex is false, there must be no far point. template vtkUnstructuredGrid* output_c3t3_to_vtk_unstructured_grid(const C3T3& c3t3, - vtkUnstructuredGrid* grid = 0) + vtkUnstructuredGrid* grid = 0, + bool export_complex = true) { typedef typename C3T3::Triangulation Triangulation; typedef typename Triangulation::Vertex_handle Vertex_handle; @@ -52,7 +54,7 @@ output_c3t3_to_vtk_unstructured_grid(const C3T3& c3t3, vtk_points->Allocate(c3t3.triangulation().number_of_vertices()- c3t3.number_of_far_points()); vtk_facets->Allocate(c3t3.number_of_facets_in_complex()); - vtk_cells->Allocate(c3t3.number_of_cells_in_complex()); + vtk_cells->Allocate(export_complex ? c3t3.number_of_cells_in_complex() : tr.number_of_finite_cells()); boost::unordered_map V; vtkIdType inum = 0; @@ -86,18 +88,34 @@ output_c3t3_to_vtk_unstructured_grid(const C3T3& c3t3, CGAL_assertion(j==3); vtk_facets->InsertNextCell(3, cell); } - - for(typename C3T3::Cells_in_complex_iterator + if(export_complex) + { + for(typename C3T3::Cells_in_complex_iterator cit = c3t3.cells_in_complex_begin(), end = c3t3.cells_in_complex_end(); - cit != end; ++cit) - { - vtkIdType cell[4]; - for (int i = 0; i < 4; ++i) - cell[i] = V[cit->vertex(i)]; - vtk_cells->InsertNextCell(4, cell); + cit != end; ++cit) + { + vtkIdType cell[4]; + for (int i = 0; i < 4; ++i) + cell[i] = V[cit->vertex(i)]; + vtk_cells->InsertNextCell(4, cell); + } + } + else + { + for(auto cit = tr.finite_cells_begin(), + end = tr.finite_cells_end(); + cit != end; ++cit) + { + if(!c3t3.is_in_complex(cit)) + { + vtkIdType cell[4]; + for (int i = 0; i < 4; ++i) + cell[i] = V[cit->vertex(i)]; + vtk_cells->InsertNextCell(4, cell); + } + } } - if(!grid) { grid = vtkUnstructuredGrid::New(); } From adfeee84d9104f00b086df58590b631de51e07e4 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 20 Mar 2019 16:25:09 +0100 Subject: [PATCH 04/20] typedef the attribute type --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index da0911a7e4a..383442353a2 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -277,10 +277,12 @@ enum VTU_ATTRIBUTE_TYPE{ SIZE_TYPE }; +typedef boost::variant, std::vector, std::vector > Vtu_attributes; + template void output_to_vtu_with_attributes(std::ostream& os, const C3T3& c3t3, - std::vector, std::vector, std::vector >*> >& attributes, + std::vector >&attributes, IO::Mode mode = IO::BINARY) { //CGAL_assertion(attributes.size() == attribute_types.size()); From 27ceec33b5a5fe661bd250c20affeb402f99a194 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 21 Mar 2019 16:10:18 +0100 Subject: [PATCH 05/20] Replace Weighted point by Point --- Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h index cecf3aefea1..9d1a9a5d79f 100644 --- a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h +++ b/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h @@ -65,10 +65,10 @@ output_c3t3_to_vtk_unstructured_grid(const C3T3& c3t3, vit != end; ++vit) { - typedef typename Triangulation::Weighted_point Weighted_point; + typedef typename Triangulation::Point Point; if(vit->in_dimension() > -1) { - const Weighted_point& p = tr.point(vit); + const Point& p = tr.point(vit); vtk_points->InsertNextPoint(CGAL::to_double(p.x()), CGAL::to_double(p.y()), CGAL::to_double(p.z())); From 4326f39944395811d93217518a177eb9dc46ae05 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 25 Mar 2019 16:12:42 +0100 Subject: [PATCH 06/20] Add misisng header --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index 383442353a2..b5cf023f6a4 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -32,6 +32,7 @@ #include #include #include +#include //todo try to factorize with functors namespace CGAL{ From c54e7c974beb59153ad90234e1ea7a9bdc2b2dc8 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 2 Apr 2019 10:29:01 +0200 Subject: [PATCH 07/20] Fix AppleClang -Wnull-pointer-arithmetic warning --- STL_Extension/include/CGAL/Compact_container.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index b4960af00c4..c1927dd9c3f 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -815,7 +815,7 @@ private: static char * clean_pointer(char * p) { - return ((p - (char *) NULL) & ~ (std::ptrdiff_t) START_END) + (char *) NULL; + return reinterpret_cast((p - (char *) NULL) & ~ (std::ptrdiff_t) START_END); } // Returns the pointee, cleaned up from the squatted bits. From aed5a55354dcd7451d787c46a7a731dfd3ae7768 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:10:27 +0200 Subject: [PATCH 08/20] Fix the syntax of find_path --- Polyhedron/demo/Polyhedron/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 519f73f74fb..ee89a2b7adc 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -142,7 +142,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND ) qt5_add_resources ( CGAL_Qt5_RESOURCE_FILES Polyhedron_3.qrc ) find_path(CGAL_THREE_HEADERS_PATH - NAME CGAL/Three/Scene_item.h + NAMES CGAL/Three/Scene_item.h HINTS ${CGAL_INCLUDE_DIRS} NO_DEFAULT_PATH DOC "Path to CGAL/Three/Scene_item.h") From bba76c20f399524fd3faf9b994c77bed60d20c1a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:10:42 +0200 Subject: [PATCH 09/20] Fix that find_path in case of cross-compilation --- Polyhedron/demo/Polyhedron/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index ee89a2b7adc..b231e97b148 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -145,6 +145,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND ) NAMES CGAL/Three/Scene_item.h HINTS ${CGAL_INCLUDE_DIRS} NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH DOC "Path to CGAL/Three/Scene_item.h") if(CGAL_THREE_HEADERS_PATH) From eb769f13fd5d43c81454cb10dedc161ef15543ef Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:10:57 +0200 Subject: [PATCH 10/20] Fix the error message --- Polyhedron/demo/Polyhedron/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index b231e97b148..7d6f9ca4207 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -160,7 +160,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND ) qt5_generate_moc( "${CGAL_THREE_HEADERS_PATH}/CGAL/Three/TextRenderer.h" "${CMAKE_CURRENT_BINARY_DIR}/TextRenderer_moc.cpp" ) else() - message(FATAL_ERROR "Cannot find ") + message(FATAL_ERROR "Cannot find ") endif() unset(CGAL_THREE_HEADERS_PATH CACHE) From 85047bcb613794425d405beeb9e317a681fbe5ab Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:11:50 +0200 Subject: [PATCH 11/20] Sneak a new feature in this branch: detect unused .cpp files For the moment, the feature is far from being ready: - in case of header-only, the .cpp sources files of CGAL libraries are reported, - when a dependency for a test/examples is missing, the corresponding .cpp files is reported, - and I have no clue which CMake version is required. But I found real issues. By default, the feature is OFF. It will only be activated if the CMake variable or cache variable `CGAL_CHECK_UNUSED_CPP_FILES` is true. We might activate it on a per-directory basis... or have it by default, and deactivate it per-directory. We'll see. For the moment, let's keep it deactivated. --- ...GAL_enable_end_of_configuration_hook.cmake | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake index 2401063a25f..6f8e423af1d 100644 --- a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake +++ b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake @@ -14,11 +14,47 @@ if(PROPERTY_CGAL_run_at_the_end_of_configuration_INCLUDED) endif() function(CGAL_run_at_the_end_of_configuration variable access value current_list_file stack) - if(NOT access STREQUAL "MODIFIED_ACCESS" OR value) - # Only do something at the end of the CMake process, when the value of - # variable CMAKE_CURRENT_LIST_DIR is changed to the empty string. + if(NOT access STREQUAL "MODIFIED_ACCESS") return() endif() + if(CGAL_CHECK_UNUSED_CPP_FILES + AND NOT current_list_file STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + AND stack STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt") + file(GLOB _cppfiles ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) + get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) + if(_targets AND _cppfiles) + set(_sources) + foreach(_target ${_targets}) + get_property(_target_type TARGET ${_target} PROPERTY TYPE) + if(_target_type STREQUAL INTERFACE_LIBRARY) + continue() + endif() + get_property(_target_sources TARGET ${_target} PROPERTY SOURCES) + list(APPEND _sources ${_target_sources}) + endforeach() + if(_sources) + list(REMOVE_ITEM _cppfiles ${_sources}) + endif() + if(_cppfiles) + set(_warning "In ${CMAKE_CURRENT_SOURCE_DIR}, the following files are unused:") + foreach(_cppfile ${_cppfiles}) + set(_warning "${_warning} + ${_cppfile}") + endforeach() + set(_warning "${_warning} +") + message(AUTHOR_WARNING "${_warning}") + endif() + endif() + endif() + + if(value) + # Only do the following at the end of the CMake process, when the + # value of variable CMAKE_CURRENT_LIST_DIR is changed to the empty + # string. + return() + endif() + # Warn when CMAKE_BUILD_TYPE is empty or Debug if(DEFINED CMAKE_BUILD_TYPE AND ( NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "Debug") ) set(keyword WARNING) From 5a67ea92fcf75f3f25cea2b832590ab1af52b501 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:15:00 +0200 Subject: [PATCH 12/20] Fix the verinfo of CGAL DLLs, on Windows And fix the test files. --- Installation/src/CGAL_libs_verinfo.rc.in | 2 +- Installation/test/Installation/CMakeLists.txt | 9 ++++++--- .../test/Installation/display_dll_version_info.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Installation/src/CGAL_libs_verinfo.rc.in b/Installation/src/CGAL_libs_verinfo.rc.in index d1f838e8db6..56a65021857 100644 --- a/Installation/src/CGAL_libs_verinfo.rc.in +++ b/Installation/src/CGAL_libs_verinfo.rc.in @@ -25,7 +25,7 @@ #define CGAL_VER_str(s) CGAL_VER_xstr(s) #define CGAL_VER_VERSION CGAL_VERSION_MAJOR,CGAL_VERSION_MINOR,CGAL_VERSION_PATCH,CGAL_VERSION_BUILD -#define CGAL_VER_VERSION_STR CGAL_VER_str(CGAL_VERSION) +#define CGAL_VER_VERSION_STR CGAL_VER_str(CGAL_VERSION_MAJOR) "." CGAL_VER_str(CGAL_VERSION_MINOR) "." CGAL_VER_str(CGAL_VERSION_PATCH) "." CGAL_VER_str(CGAL_VERSION_BUILD) #define CGAL_VER_COMPANYNAME_STR "The CGAL Project, https://www.cgal.org/\0" #define CGAL_VER_FILEDESCRIPTION_STR "@LIBRARY_NAME@ Library\0" #define CGAL_VER_FILEVERSION_STR CGAL_VER_VERSION_STR diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index ce85c54f412..4727106e2e6 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -79,10 +79,13 @@ if ( CGAL_FOUND ) endif() endif() - if(WIN32) + if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Windows) + add_executable(display_dll_version_info display_dll_version_info.cpp) + target_link_libraries(display_dll_version_info version) add_executable(test_gmp_mpfr_dll test_gmp_mpfr_dll.cpp) - target_link_libraries(test_gmp_mpfr_dll Version) - endif(WIN32) + target_link_libraries(test_gmp_mpfr_dll version) + CGAL_add_test(test_gmp_mpfr_dll) + endif() find_package( LEDA QUIET) if(LEDA_FOUND) diff --git a/Installation/test/Installation/display_dll_version_info.cpp b/Installation/test/Installation/display_dll_version_info.cpp index 985e2ed15af..2ed4da4742c 100644 --- a/Installation/test/Installation/display_dll_version_info.cpp +++ b/Installation/test/Installation/display_dll_version_info.cpp @@ -49,7 +49,7 @@ int main(int argc, char** argv) { } else { std::cerr << "Usage:\n" << " display_dll_version_info /path/to/a.dll\n"; - return 0; } + return 0; } #endif From 68f6ebf42d74e99c0397803825d7909bbcd4ed42 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:52:12 +0200 Subject: [PATCH 13/20] More reinterpret_cast to avoid undefined behavior --- STL_Extension/include/CGAL/Compact_container.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index c1927dd9c3f..1b7ea962e78 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -815,7 +816,8 @@ private: static char * clean_pointer(char * p) { - return reinterpret_cast((p - (char *) NULL) & ~ (std::ptrdiff_t) START_END); + return reinterpret_cast(reinterpret_cast(p) & + ~ (std::uintptr_t) START_END); } // Returns the pointee, cleaned up from the squatted bits. @@ -828,7 +830,8 @@ private: static Type type(const_pointer ptr) { char * p = (char *) Traits::pointer(*ptr); - return (Type) (p - clean_pointer(p)); + return (Type) (reinterpret_cast(p) - + reinterpret_cast(clean_pointer(p))); } // Sets the pointer part and the type of the pointee. @@ -837,7 +840,8 @@ private: // This out of range compare is always true and causes lots of // unnecessary warnings. // CGAL_precondition(0 <= t && t < 4); - Traits::pointer(*ptr) = (void *) ((clean_pointer((char *) p)) + (int) t); + Traits::pointer(*ptr) = reinterpret_cast + (reinterpret_cast(clean_pointer((char *) p)) + (int) t); } public: From 34cf27b47e9d3218a2cdd240dea10338793049ba Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 14:56:21 +0200 Subject: [PATCH 14/20] Use std::ptrdiff_t, because the target branch is not C++11 `std::uintptr_t` was introduced by C++11, but the target branch if CGAL-4.13-branch, does not require C++11. --- STL_Extension/include/CGAL/Compact_container.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 1b7ea962e78..6064a81c6d9 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -816,8 +816,8 @@ private: static char * clean_pointer(char * p) { - return reinterpret_cast(reinterpret_cast(p) & - ~ (std::uintptr_t) START_END); + return reinterpret_cast(reinterpret_cast(p) & + ~ (std::ptrdiff_t) START_END); } // Returns the pointee, cleaned up from the squatted bits. @@ -830,8 +830,8 @@ private: static Type type(const_pointer ptr) { char * p = (char *) Traits::pointer(*ptr); - return (Type) (reinterpret_cast(p) - - reinterpret_cast(clean_pointer(p))); + return (Type) (reinterpret_cast(p) - + reinterpret_cast(clean_pointer(p))); } // Sets the pointer part and the type of the pointee. @@ -841,7 +841,7 @@ private: // unnecessary warnings. // CGAL_precondition(0 <= t && t < 4); Traits::pointer(*ptr) = reinterpret_cast - (reinterpret_cast(clean_pointer((char *) p)) + (int) t); + (reinterpret_cast(clean_pointer((char *) p)) + (int) t); } public: From dcc6d7a58a832930f474c9962ecc1b3391321f84 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 18:30:04 +0200 Subject: [PATCH 15/20] Fix CGAL::output_to_vtu(..., ASCII) and add tests --- .../mesh_polyhedral_domain_with_features.cpp | 7 +++++-- .../mesh_polyhedral_domain_with_features_sm.cpp | 7 +++++-- Mesh_3/include/CGAL/IO/output_to_vtu.h | 16 ++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp index 05ff6d73f6b..e5a9c5179fa 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp @@ -6,6 +6,7 @@ #include #include +#include // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -62,8 +63,10 @@ int main(int argc, char*argv[]) C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); // Output - std::ofstream medit_file("out.mesh"); - c3t3.output_to_medit(medit_file); + std::ofstream file("out.vtu"); + CGAL::output_to_vtu(file, c3t3); + // Could be replaced by: + // c3t3.output_to_medit(file); return EXIT_SUCCESS; } diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp index 5501fad4bfc..ab357f2ca0c 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp @@ -7,6 +7,7 @@ #include #include #include +#include // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -63,8 +64,10 @@ int main(int argc, char*argv[]) C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); // Output - std::ofstream medit_file("out.mesh"); - c3t3.output_to_medit(medit_file); + std::ofstream file("out-sm.vtu"); + CGAL::output_to_vtu(file, c3t3, CGAL::IO::ASCII); + // Could be replaced by: + // c3t3.output_to_medit(file); return EXIT_SUCCESS; } diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index 5c9583ba272..89c6c9e7d23 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -66,7 +66,7 @@ write_cells_tag(std::ostream& os, // 4 indices (size_t) per cell + length of the encoded data (size_t) } else { - os << "\">\n"; + os << ">\n"; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; ++cit ) @@ -74,7 +74,7 @@ write_cells_tag(std::ostream& os, for (int i=0; i<4; i++) os << V[cit->vertex(i)] << " "; } - os << " \n"; + os << "\n \n"; } // Write offsets @@ -87,7 +87,7 @@ write_cells_tag(std::ostream& os, // 1 offset (size_t) per cell + length of the encoded data (size_t) } else { - os << "\">\n"; + os << ">\n"; std::size_t cells_offset = 0; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; @@ -96,7 +96,7 @@ write_cells_tag(std::ostream& os, cells_offset += 4; os << cells_offset << " "; } - os << " \n"; + os << "\n \n"; } // Write cell type (tetrahedra == 10) @@ -109,12 +109,12 @@ write_cells_tag(std::ostream& os, // 1 unsigned char per cell + length of the encoded data (size_t) } else { - os << "\">\n"; + os << ">\n"; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; ++cit ) os << "10 "; - os << " \n"; + os << "\n \n"; } os << " \n"; } @@ -188,7 +188,7 @@ write_c3t3_points_tag(std::ostream& os, else os << 0.0 << " "; } - os << " \n"; + os << "\n \n"; } os << " \n"; } @@ -245,7 +245,7 @@ write_attribute_tag(std::ostream& os, it != attribute.end(); ++it ) os << *it << " "; - os << " \n"; + os << "\n \n"; } } From 2e43cc0f71be440e9355129df8e46daa6e51569e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 19:11:15 +0200 Subject: [PATCH 16/20] Remove a warning about an unused variable --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index b5cf023f6a4..029364c161b 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -364,7 +364,6 @@ void output_to_vtu(std::ostream& os, { typedef typename C3T3::Cells_in_complex_iterator Cell_iterator; std::vector mids; - std::size_t id = 0; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; ++cit ) From 043239d7384dcf2e9fdd2bc6752a98c4287ee6ab Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 3 Apr 2019 19:57:06 +0200 Subject: [PATCH 17/20] Avoid copies of vectors of attributes --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index 029364c161b..43d31463c83 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -278,12 +278,12 @@ enum VTU_ATTRIBUTE_TYPE{ SIZE_TYPE }; -typedef boost::variant, std::vector, std::vector > Vtu_attributes; +typedef boost::variant*, const std::vector*, const std::vector* > Vtu_attributes; template void output_to_vtu_with_attributes(std::ostream& os, const C3T3& c3t3, - std::vector >&attributes, + std::vector >&attributes, IO::Mode mode = IO::BINARY) { //CGAL_assertion(attributes.size() == attribute_types.size()); @@ -319,15 +319,15 @@ void output_to_vtu_with_attributes(std::ostream& os, os << " \n"; for(std::size_t i = 0; i< attributes.size(); ++i) { - switch(attributes[i].second->which()){ + switch(attributes[i].second.which()){ case 0: - write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + write_attribute_tag(os,attributes[i].first, *boost::get* >(attributes[i].second), binary,offset); break; case 1: - write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + write_attribute_tag(os,attributes[i].first, *boost::get* >(attributes[i].second), binary,offset); break; default: - write_attribute_tag(os,attributes[i].first, *boost::get >(attributes[i].second), binary,offset); + write_attribute_tag(os,attributes[i].first, *boost::get* >(attributes[i].second), binary,offset); break; } } @@ -339,15 +339,15 @@ void output_to_vtu_with_attributes(std::ostream& os, write_c3t3_points(os,tr,V); // fills V if the mode is BINARY write_cells(os,c3t3,V); for(std::size_t i = 0; i< attributes.size(); ++i) - switch(attributes[i].second->which()){ + switch(attributes[i].second.which()){ case 0: - write_attributes(os, *boost::get >(attributes[i].second)); + write_attributes(os, *boost::get* >(attributes[i].second)); break; case 1: - write_attributes(os, *boost::get >(attributes[i].second)); + write_attributes(os, *boost::get* >(attributes[i].second)); break; default: - write_attributes(os, *boost::get >(attributes[i].second)); + write_attributes(os, *boost::get* >(attributes[i].second)); break; } } @@ -372,9 +372,9 @@ void output_to_vtu(std::ostream& os, mids.push_back(v); } - std::vector, std::vector, std::vector >* > > atts; - boost::variant, std::vector, std::vector > v = mids; - atts.push_back(std::make_pair("MeshDomain", &v)); + std::vector > atts; + Vtu_attributes v = &mids; + atts.push_back(std::make_pair("MeshDomain", v)); output_to_vtu_with_attributes(os, c3t3, atts, mode); } From d07a2c918440cb2589f8d0df633b6215d729c588 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 4 Apr 2019 15:25:01 +0200 Subject: [PATCH 18/20] Remove (GMP|MPFR)_IN_CGAL_AUXILIARY There was a bug in `FindGMP.cmake` and `FindMPFR.cmake`: they were using the undefined macro `cache_set`. I have removed those variables definitions, and wrote the code differently where they were used. --- Installation/CMakeLists.txt | 2 +- Installation/cmake/modules/CGAL_SetupGMP.cmake | 4 ++-- Installation/cmake/modules/FindGMP.cmake | 6 ------ Installation/cmake/modules/FindMPFR.cmake | 5 ----- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 4a45bf89485..70d6cae5330 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -901,7 +901,7 @@ install(PROGRAMS ${scripts} DESTINATION ${CGAL_INSTALL_BIN_DIR}) install(DIRECTORY ${CGAL_MODULES_REL_DIR}/ DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) install(FILES ${CGAL_MODULES_REL_DIR}/UseCGAL.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) -if ( GMP_IN_CGAL_AUXILIARY OR MPFR_IN_CGAL_AUXILIARY ) +if ( IS_DIRECTORY auxiliary/gmp/include AND IS_DIRECTORY auxiliary/gmp/lib ) install(DIRECTORY auxiliary/gmp/include/ DESTINATION ${CGAL_INSTALL_INC_DIR} ) install(DIRECTORY auxiliary/gmp/lib/ DESTINATION ${CGAL_INSTALL_LIB_DIR} ) endif() diff --git a/Installation/cmake/modules/CGAL_SetupGMP.cmake b/Installation/cmake/modules/CGAL_SetupGMP.cmake index 0cfe429e48e..e43737c6abf 100644 --- a/Installation/cmake/modules/CGAL_SetupGMP.cmake +++ b/Installation/cmake/modules/CGAL_SetupGMP.cmake @@ -54,14 +54,14 @@ function(use_CGAL_GMP_support target) return() endif() - if(NOT GMP_IN_CGAL_AUXILIARY) + if(NOT GMP_INCLUDE_DIR STREQUAL "${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include") target_include_directories(${target} SYSTEM ${keyword} ${GMP_INCLUDE_DIR}) else() target_include_directories(${target} SYSTEM ${keyword} $ $) endif() - if(NOT MPFR_IN_CGAL_AUXILIARY) + if(NOT MPFR_INCLUDE_DIR STREQUAL "${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include") target_include_directories(${target} SYSTEM ${keyword} ${MPFR_INCLUDE_DIR}) else() target_include_directories(${target} SYSTEM ${keyword} diff --git a/Installation/cmake/modules/FindGMP.cmake b/Installation/cmake/modules/FindGMP.cmake index f3084cc72f7..663203d11c9 100644 --- a/Installation/cmake/modules/FindGMP.cmake +++ b/Installation/cmake/modules/FindGMP.cmake @@ -4,7 +4,6 @@ # GMP_INCLUDE_DIR - the GMP include directory # GMP_LIBRARIES_DIR - directory where the GMP libraries are located # GMP_LIBRARIES - Link these to use GMP -# GMP_IN_CGAL_AUXILIARY - TRUE if the GMP found is the one distributed with CGAL in the auxiliary folder # TODO: support MacOSX @@ -52,8 +51,3 @@ if( NOT GMP_in_cache ) endif() find_package_handle_standard_args(GMP "DEFAULT_MSG" GMP_LIBRARIES GMP_INCLUDE_DIR) - -if ( GMP_INCLUDE_DIR STREQUAL "${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include" ) - cache_set( GMP_IN_CGAL_AUXILIARY TRUE ) -endif() - diff --git a/Installation/cmake/modules/FindMPFR.cmake b/Installation/cmake/modules/FindMPFR.cmake index cb3c0fc1c73..b21fb1f678e 100644 --- a/Installation/cmake/modules/FindMPFR.cmake +++ b/Installation/cmake/modules/FindMPFR.cmake @@ -3,7 +3,6 @@ # MPFR_INCLUDE_DIR - the MPFR include directory # MPFR_LIBRARIES_DIR - Directory where the MPFR libraries are located # MPFR_LIBRARIES - the MPFR libraries -# MPFR_IN_CGAL_AUXILIARY - TRUE if the MPFR found is the one distributed with CGAL in the auxiliary folder # TODO: support MacOSX @@ -51,7 +50,3 @@ if (NOT MPFR_in_cache) endif() find_package_handle_standard_args(MPFR "DEFAULT_MSG" MPFR_LIBRARIES MPFR_INCLUDE_DIR) - -if ( MPFR_INCLUDE_DIR STREQUAL "${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include" ) - cache_set( MPFR_IN_CGAL_AUXILIARY TRUE ) -endif() From b1a747b514bf897d3808f4476a545f521cc253d6 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 2 Apr 2019 16:32:37 +0200 Subject: [PATCH 19/20] Add an conversion operator to tuple into Iterator_range to satisfy all versions of clang. --- STL_Extension/include/CGAL/Iterator_range.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/STL_Extension/include/CGAL/Iterator_range.h b/STL_Extension/include/CGAL/Iterator_range.h index 677aa9c44d2..20a2bc8458b 100644 --- a/STL_Extension/include/CGAL/Iterator_range.h +++ b/STL_Extension/include/CGAL/Iterator_range.h @@ -78,6 +78,15 @@ namespace CGAL { return begin()==end(); } + operator std::tuple() + { + return std::tuple{this->first, this->second}; + } + + operator std::tuple() const + { + return std::tuple{this->first, this->second}; + } }; template From 0cace864cdbbe387a33a2d6b9568b7e64b06378c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 4 Apr 2019 15:59:02 +0200 Subject: [PATCH 20/20] Protect new code --- STL_Extension/include/CGAL/Iterator_range.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/STL_Extension/include/CGAL/Iterator_range.h b/STL_Extension/include/CGAL/Iterator_range.h index 20a2bc8458b..708c5c142e3 100644 --- a/STL_Extension/include/CGAL/Iterator_range.h +++ b/STL_Extension/include/CGAL/Iterator_range.h @@ -77,6 +77,7 @@ namespace CGAL { { return begin()==end(); } +#ifndef CGAL_CFG_NO_CPP0X_TUPLE operator std::tuple() { @@ -87,6 +88,8 @@ namespace CGAL { { return std::tuple{this->first, this->second}; } +#endif + }; template