Merge remote-tracking branch 'cgal/5.6.x-branch'

This commit is contained in:
Sébastien Loriot 2024-09-06 16:07:49 +02:00
commit 9ff709885a
12 changed files with 237 additions and 48 deletions

View File

@ -1,8 +1,19 @@
if(LASLIB_FOUND AND NOT TARGET CGAL::LASLIB_support)
add_library(CGAL::LASLIB_support INTERFACE IMPORTED)
set_target_properties(CGAL::LASLIB_support PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_LINKED_WITH_LASLIB"
INTERFACE_INCLUDE_DIRECTORIES "${LASLIB_INCLUDE_DIR};${LASZIP_INCLUDE_DIR}"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${LASLIB_INCLUDE_DIR};${LASZIP_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${LASLIB_LIBRARIES}")
if(LASLIB_FOUND)
if (NOT TARGET CGAL::LASLIB_support)
if (NOT TARGET LASlib)
# message(STATUS "Found using MODULE mode")
add_library(CGAL::LASLIB_support INTERFACE IMPORTED)
set_target_properties(CGAL::LASLIB_support PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_LINKED_WITH_LASLIB"
INTERFACE_INCLUDE_DIRECTORIES "${LASLIB_INCLUDE_DIR}"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${LASLIB_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${LASLIB_LIBRARIES}")
else()
# message(STATUS "Found using CONFIG mode")
add_library(CGAL::LASLIB_support INTERFACE IMPORTED)
set_target_properties(CGAL::LASLIB_support PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_LINKED_WITH_LASLIB")
target_link_libraries(CGAL::LASLIB_support INTERFACE LASlib)
endif()
endif()
endif()

View File

@ -9,14 +9,16 @@
# first look in user defined locations
find_path(LASLIB_INCLUDE_DIR
NAMES lasreader.hpp
PATHS /usr/local/include/LASlib/
PATHS /usr/local/include/LASlib/
ENV LASLIB_INC_DIR
)
find_path(LASZIP_INCLUDE_DIR
NAMES mydefs.hpp
PATHS /usr/local/include/LASzip/
${LASLIB_INCLUDE_DIR}/../../LASzip/src
${LASLIB_INCLUDE_DIR}/../LASzip
${LASLIB_INCLUDE_DIR}
)
find_library(LASLIB_LIBRARIES
@ -27,9 +29,22 @@ find_library(LASLIB_LIBRARIES
${LASLIB_INCLUDE_DIR}/../../lib
ENV LASLIB_LIB_DIR
)
if (NOT LASLIB_LIBRARIES)
#library was renamed in recent versions of LAStools
find_library(LASLIB_LIBRARIES
NAMES LASlib
PATHS ENV LD_LIBRARY_PATH
ENV LIBRARY_PATH
/usr/local/lib
${LASLIB_INCLUDE_DIR}/../../lib
ENV LASLIB_LIB_DIR
)
endif()
if(LASLIB_LIBRARIES AND LASLIB_INCLUDE_DIR)
if(LASLIB_LIBRARIES AND LASLIB_INCLUDE_DIR AND LASZIP_INCLUDE_DIR)
if (NOT ${LASLIB_INCLUDE_DIR} STREQUAL ${LASZIP_INCLUDE_DIR})
list(APPEND LASLIB_INCLUDE_DIR ${LASZIP_INCLUDE_DIR})
endif()
set(LASLIB_FOUND TRUE)
set(LASLIB_USE_FILE "UseLASLIB")
endif()

View File

@ -3,4 +3,4 @@
add_definitions(-DCGAL_LINKED_WITH_LASLIB)
message(DEPRECATION "This file UseLASLIB.cmake is deprecated, and the imported target `CGAL::TBB_support` from CGAL_LASLIB_support.cmake should be used instead.")
message(DEPRECATION "This file UseLASLIB.cmake is deprecated, and the imported target `CGAL::LASLIB_support` from CGAL_LASLIB_support.cmake should be used instead.")

View File

@ -14,7 +14,7 @@ create_single_source_cgal_program("issue7996.cpp")
#Use LAS
#disable if MSVC 2017
if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1910))
if(NOT MSVC_VERSION OR MSVC_VERSION GREATER_EQUAL 1919 OR MSVC_VERSION LESS 1910)
find_package(LASLIB QUIET)
include(CGAL_LASLIB_support)
if (TARGET CGAL::LASLIB_support)
@ -23,5 +23,5 @@ if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1
message(STATUS "NOTICE: the LAS reader test requires LASlib, and will not be compiled.")
endif()
else()
message(STATUS "NOTICE: the LAS reader does not work with Visual Studio 2017.")
message(STATUS "NOTICE: the LAS reader does not work with your version of Visual Studio 2017.")
endif()

View File

@ -58,7 +58,9 @@ find_package(LASLIB QUIET)
include(CGAL_LASLIB_support)
if(TARGET CGAL::LASLIB_support)
create_single_source_cgal_program("read_las_example.cpp")
create_single_source_cgal_program("write_las_example.cpp")
target_link_libraries(read_las_example PRIVATE ${CGAL_libs} CGAL::LASLIB_support)
target_link_libraries(write_las_example PRIVATE ${CGAL_libs} CGAL::LASLIB_support)
else()
message(STATUS "NOTICE: the LAS reader example requires LASlib and will not be compiled.")
endif()

View File

@ -0,0 +1,45 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/write_las_points.h>
#include <utility>
#include <vector>
#include <fstream>
// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef std::array<unsigned short, 4> Color;
typedef std::pair<Point, Color> PointWithColor;
int main(int argc, char*argv[])
{
const char* fname = "colored_points.las";
std::ofstream os(fname, std::ios::binary);
std::vector<PointWithColor> points; // store points
points.push_back(std::make_pair(Point(0, 0, 0), Color{ 65535, 0, 0, 0 }));
points.push_back(std::make_pair(Point(1, 0, 0), Color{ 0, 65535, 0, 0 }));
points.push_back(std::make_pair(Point(0, 1, 0), Color{ 0, 0, 65535, 0 }));
points.push_back(std::make_pair(Point(1, 1, 0), Color{ 0, 65535, 65535, 0 }));
points.push_back(std::make_pair(Point(1, 1, 1), Color{ 65535, 65535, 0, 0 }));
// Writes a .las point set file with colors
if(!CGAL::IO::write_LAS_with_properties(os, points,
CGAL::IO::make_las_point_writer(CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),
CGAL::IO::LAS_property::R(),
CGAL::IO::LAS_property::G(),
CGAL::IO::LAS_property::B(),
CGAL::IO::LAS_property::I())))
{
std::cerr << "Error: cannot write file " << fname << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View File

@ -43,7 +43,7 @@
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
#define USE_AS_DLL
#define USE_AS_DLL 1
#include <lasreader_las.hpp>
#undef USE_AS_DLL
@ -384,7 +384,11 @@ bool read_LAS_with_properties(std::istream& is,
if(!is)
return false;
#if LAS_TOOLS_VERSION < 240319
LASreaderLAS lasreader;
#else
LASreaderLAS lasreader(nullptr);
#endif
lasreader.open(is);
while(lasreader.read_point())

View File

@ -37,7 +37,7 @@
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
#define USE_AS_DLL
#define USE_AS_DLL 1
#include <lasdefinitions.hpp>
#include <lasreader_las.hpp>
#include <laswriter_las.hpp>
@ -84,41 +84,41 @@ make_las_point_writer(PointMap point_map)
namespace internal {
namespace LAS {
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::Intensity&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::Intensity&)
{ r.set_intensity(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Return_number&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Return_number&)
{ r.set_return_number(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Number_of_returns&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Number_of_returns&)
{ r.set_number_of_returns(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Scan_direction_flag&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Scan_direction_flag&)
{ r.set_scan_direction_flag(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Edge_of_flight_line&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Edge_of_flight_line&)
{ r.set_edge_of_flight_line(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Classification&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Classification&)
{ r.set_classification(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Synthetic_flag&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Synthetic_flag&)
{ r.set_synthetic_flag(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Keypoint_flag&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Keypoint_flag&)
{ r.set_keypoint_flag(v); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::Withheld_flag&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::Withheld_flag&)
{ r.set_withheld_flag(v); }
inline void output_value(LASpoint& r, const float& v, LAS_property::Scan_angle&)
inline void output_value(LASpoint& r, const float& v, const LAS_property::Scan_angle&)
{ r.set_scan_angle_rank(char(v)); }
inline void output_value(LASpoint& r, const unsigned char& v, LAS_property::User_data&)
inline void output_value(LASpoint& r, const unsigned char& v, const LAS_property::User_data&)
{ r.set_user_data(v); }
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::Point_source_ID&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::Point_source_ID&)
{ r.set_point_source_ID(v); }
inline void output_value(LASpoint& r, const unsigned int& v, LAS_property::Deleted_flag&)
inline void output_value(LASpoint& r, const unsigned int& v, const LAS_property::Deleted_flag&)
{ r.set_deleted_flag(v); }
inline void output_value(LASpoint& r, const double& v, LAS_property::GPS_time&)
inline void output_value(LASpoint& r, const double& v, const LAS_property::GPS_time&)
{ r.set_gps_time(v); }
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::R&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::R&)
{ r.set_R(v); }
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::G&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::G&)
{ r.set_G(v); }
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::B&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::B&)
{ r.set_B(v); }
inline void output_value(LASpoint& r, const unsigned short& v, LAS_property::I&)
inline void output_value(LASpoint& r, const unsigned short& v, const LAS_property::I&)
{ r.set_I(v); }
template <typename ForwardIterator>
@ -134,20 +134,57 @@ namespace LAS {
output_value (point, get(current.first, *it), current.second);
}
template<typename Value, typename Tuple, std::size_t I>
void output_tuple(LASpoint& point, const Value& v, const Tuple& t, std::index_sequence<I>) {
output_value(point, std::get<I>(v), std::get<I>(t));
}
template<typename Value, typename Tuple, std::size_t I, std::size_t... Is>
void output_tuple(LASpoint& point, const Value& v, const Tuple& t, std::index_sequence<I, Is...>) {
output_value(point, std::get<I>(v), std::get<I>(t));
output_tuple(point, v, t, std::index_sequence<Is...>());
}
template <typename ForwardIterator,
typename PropertyMap,
typename T,
typename NextPropertyHandler,
typename ... PropertyHandler>
typename PropertyMap,
typename ... T>
void output_properties(LASpoint& point,
ForwardIterator it,
std::pair<PropertyMap, T>&& current,
NextPropertyHandler&& next,
PropertyHandler&& ... properties)
ForwardIterator it,
std::tuple<PropertyMap, T ...>&& current)
{
output_value (point, get(current.first, *it), current.second);
output_properties (point, it, std::forward<NextPropertyHandler>(next),
std::forward<PropertyHandler>(properties)...);
output_tuple(point, get(std::get<0>(current), *it), std::tuple<T ...>(), std::index_sequence_for<T ...>{});
}
template <typename ForwardIterator,
typename PropertyMap,
typename T,
typename NextPropertyHandler,
typename ... PropertyHandler>
void output_properties(LASpoint& point,
ForwardIterator it,
std::pair<PropertyMap, T>&& current,
NextPropertyHandler&& next,
PropertyHandler&& ... properties)
{
output_value(point, get(current.first, *it), current.second);
output_properties(point, it, std::forward<NextPropertyHandler>(next),
std::forward<PropertyHandler>(properties)...);
}
template <typename ForwardIterator,
typename PropertyMap,
typename ... T,
typename NextPropertyHandler,
typename ... PropertyHandler>
void output_properties(LASpoint& point,
ForwardIterator it,
std::tuple<PropertyMap, T ...>&& current,
NextPropertyHandler&& next,
PropertyHandler&& ... properties)
{
output_tuple(point, get(std::get<0>(current), *it), std::tuple<T ...>(), std::index_sequence_for<T ...>{});
output_properties(point, it, std::forward<NextPropertyHandler>(next),
std::forward<PropertyHandler>(properties)...);
}
} // namespace LAS

View File

@ -33,7 +33,7 @@ create_single_source_cgal_program( "structuring_test.cpp" )
#Use LAS
#disable if MSVC 2017
if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1910))
if(NOT MSVC_VERSION OR MSVC_VERSION GREATER_EQUAL 1919 OR MSVC_VERSION LESS 1910)
find_package(LASLIB QUIET)
include(CGAL_LASLIB_support)
if (TARGET CGAL::LASLIB_support)
@ -43,7 +43,7 @@ if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1
message(STATUS "NOTICE: the LAS reader test requires LASlib and will not be compiled.")
endif()
else()
message(STATUS "NOTICE: the LAS reader does not work with Visual Studio 2017.")
message(STATUS "NOTICE: the LAS reader does not work with your version of Visual Studio 2017.")
endif()
# Use Eigen

View File

@ -13,6 +13,9 @@ find_library(
NAMES 3MF
DOC "Path to the lib3MF library")
find_package(LASLIB QUIET)
include(CGAL_LASLIB_support)
# create a target per cppfile
file(
GLOB cppfiles
@ -30,6 +33,15 @@ foreach(cppfile ${cppfiles})
message(STATUS "NOTICE: Some tests require the lib3MF library, and will not be compiled.")
endif()
else()
create_single_source_cgal_program("${cppfile}")
if("${cppfile}" STREQUAL "test_LAS.cpp")
if(TARGET CGAL::LASLIB_support)
create_single_source_cgal_program("test_LAS.cpp")
target_link_libraries(test_LAS PRIVATE CGAL::LASLIB_support)
else()
message(STATUS "NOTICE: Some tests require the LASlib library, and will not be compiled.")
endif()
else()
create_single_source_cgal_program("${cppfile}")
endif()
endif()
endforeach()

View File

@ -0,0 +1,63 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_las_points.h>
#include <utility>
#include <vector>
#include <fstream>
// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef std::array<unsigned short, 4> Color;
typedef std::pair<Point, Color> PointWithColor;
int main(int argc, char* argv[])
{
std::ifstream is("data/colored_points.las");
// Reads a .las point set file with normal vectors and colors
std::vector<PointWithColor> points; // store points
if (!CGAL::IO::read_LAS_with_properties(is, std::back_inserter(points),
CGAL::IO::make_las_point_reader(CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),
CGAL::Construct_array(),
CGAL::IO::LAS_property::R(),
CGAL::IO::LAS_property::G(),
CGAL::IO::LAS_property::B(),
CGAL::IO::LAS_property::I())))
{
std::cerr << "Error: cannot read file data/colored_points.las" << std::endl;
return EXIT_FAILURE;
}
CGAL_assertion(points.size() == 5);
CGAL_assertion(points[0].second[0] == 65535);
CGAL_assertion(points[0].second[1] == 0);
CGAL_assertion(points[0].second[2] == 0);
CGAL_assertion(points[0].second[3] == 0);
CGAL_assertion(points[1].second[0] == 0);
CGAL_assertion(points[1].second[1] == 65535);
CGAL_assertion(points[1].second[2] == 0);
CGAL_assertion(points[1].second[3] == 0);
CGAL_assertion(points[2].second[0] == 0);
CGAL_assertion(points[2].second[1] == 0);
CGAL_assertion(points[2].second[2] == 65535);
CGAL_assertion(points[2].second[3] == 0);
CGAL_assertion(points[3].second[0] == 0);
CGAL_assertion(points[3].second[1] == 65535);
CGAL_assertion(points[3].second[2] == 65535);
CGAL_assertion(points[3].second[3] == 0);
CGAL_assertion(points[4].second[0] == 65535);
CGAL_assertion(points[4].second[1] == 65535);
CGAL_assertion(points[4].second[2] == 0);
CGAL_assertion(points[4].second[3] == 0);
return EXIT_SUCCESS;
}