Stream support: Fix for Epeck (#9072)

## Summary of Changes

For file formats that expect floating point coordinates we convert on
the fly so that `CGAL::io::write_polygon_soup()` also works for polygon
soups with ` FT` which are non-float/double, e.g.
`Exact_predicates_exact_constructions_kernel`.
Additionally, we document the named parameter `point_map` as it was
missing.

## Release Management

* Affected package(s): Stream_support
* Issue(s) solved (if any): fix #9071
* License and copyright ownership: unchanged 
* upon integration update and test #9109
This commit is contained in:
Sebastien Loriot 2025-11-20 10:27:33 +01:00 committed by GitHub
commit bf25dd27b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 240 additions and 74 deletions

View File

@ -83,12 +83,12 @@ a newline character and each coordinate separated by a white
space. Other formats available are 'OFF', 'PLY' and 'LAS'. \cgal
provides functions to read such formats:
- `read_XYZ()`
- `read_OFF()`
- `read_PLY()`
- `read_PLY_with_properties()` to read additional PLY properties
- `read_LAS()`
- `read_LAS_with_properties()` to read additional LAS properties
- `CGAL::IO::read_XYZ()`
- `CGAL::IO::read_OFF()`
- `CGAL::IO::read_PLY()`
- `CGAL::IO::read_PLY_with_properties()` to read additional PLY properties
- `CGAL::IO::read_LAS()`
- `CGAL::IO::read_LAS_with_properties()` to read additional LAS properties
\cgal also provides a dedicated container `CGAL::Point_set_3` to
handle point sets with additional properties such as normal

View File

@ -48,7 +48,7 @@ Cartesian_converter<>();
/// @{
/*!
returns a `K2::Point_2` which coordinates are those of `p`,
returns a `K2::Point_2` whose coordinates are those of `p`,
converted by `NTConverter`.
*/
K2::Point_2 operator()(const K1::Point_2&p);

View File

@ -105,7 +105,6 @@ make_OR_property_map(const PM1& pm1, const PM2& pm2)
/// \cgalModels{ReadablePropertyMap}
///
/// \tparam InputIterator an input iterator
/// \endcond
template<class InputIterator>
struct Input_iterator_property_map{
typedef InputIterator key_type;
@ -119,6 +118,8 @@ struct Input_iterator_property_map{
get(Input_iterator_property_map<InputIterator>, const InputIterator& it){ return *it; }
};
/// \endcond
#ifdef DOXYGEN_RUNNING
/// \ingroup PkgPropertyMapRef
/// Property map that composes two property maps,
@ -274,8 +275,8 @@ struct Compose_property_map<KeyMap, ValueMap, boost::lvalue_property_map_tag>
};
#endif
/// \ingroup PkgPropertyMapRef
/// \relates Compose_property_map
/// returns `Compose_property_maps<KeyMap, ValueMap>(km,vm)`
/// \relates Compose_property_map
template <class KeyMap, class ValueMap>
Compose_property_map<KeyMap, ValueMap>
make_compose_property_map(const KeyMap& km, const ValueMap& vm)
@ -304,8 +305,8 @@ struct Dereference_property_map
reference operator[](const Iter_& it) const { return *it; }
};
/// \ingroup PkgPropertyMapRef
/// Free function to create a `Dereference_property_map` property map.
///
/// \relates Dereference_property_map
template <class Iter> // Type convertible to `key_type`
Dereference_property_map<typename CGAL::value_type_traits<Iter>::type>
@ -371,8 +372,8 @@ struct Identity_property_map_no_lvalue
};
/// \endcond
/// \ingroup PkgPropertyMapRef
/// Free function to create a `Identity_property_map` property map.
///
/// \relates Identity_property_map
template <class T> // Key and value type
Identity_property_map<T>
@ -409,8 +410,8 @@ struct First_of_pair_property_map
/// @}
};
/// \ingroup PkgPropertyMapRef
/// Free function to create a `First_of_pair_property_map` property map.
///
/// \relates First_of_pair_property_map
template <class Pair> // Pair type
First_of_pair_property_map<Pair>
@ -449,8 +450,8 @@ struct Second_of_pair_property_map
/// @}
};
/// \ingroup PkgPropertyMapRef
/// Free function to create a Second_of_pair_property_map property map.
///
/// \relates Second_of_pair_property_map
template <class Pair> // Pair type
Second_of_pair_property_map<Pair>
@ -509,8 +510,8 @@ struct Nth_of_tuple_property_map<N,std::tuple<T...> >
friend void put(const Self&, key_type& k, const value_type& v) { std::get<N>(k) = v; }
};
/// \ingroup PkgPropertyMapRef
/// Free function to create a Nth_of_tuple_property_map property map.
///
/// \relates Nth_of_tuple_property_map
template <int N, class Tuple> // Tuple type
Nth_of_tuple_property_map<N, Tuple>
@ -563,6 +564,7 @@ struct Pointer_property_map{
/// This function is a shortcut to the recommended replacement:
/// `boost::make_iterator_property_map(<pointer>, boost::typed_identity_property_map<std::size_t>())`
/// Note that the property map is a mutable `LvaluePropertyMap` with `std::size_t` as key.
/// \relates Pointer_property_map
template <class T>
inline
typename Pointer_property_map<T>::type
@ -574,6 +576,7 @@ make_property_map(T* pointer)
/// \ingroup PkgPropertyMapRef
/// equivalent to `make_property_map(&v[0])`
/// Note that `v` must not be modified while using the property map created
/// \relates Pointer_property_map
template <class T>
inline
typename Pointer_property_map<T>::type
@ -587,6 +590,7 @@ make_property_map(std::vector<T>& v)
/// \ingroup PkgPropertyMapRef
/// Non-mutable version
/// \relates Pointer_property_map
template <class T>
inline
typename Pointer_property_map<T>::const_type
@ -598,6 +602,7 @@ make_property_map(const T* pointer)
/// \ingroup PkgPropertyMapRef
/// equivalent to `make_property_map(&v[0])`
/// Note that `v` must not be modified while using the property map created
/// \relates Pointer_property_map
template <class T>
inline
typename Pointer_property_map<T>::const_type
@ -674,6 +679,7 @@ struct Boolean_property_map
/// \ingroup PkgPropertyMapRef
/// returns `Boolean_property_map<Set>(set_)`
/// \relates Boolean_property_map
template <class Set>
Boolean_property_map<Set>
make_boolean_property_map(Set& set_)
@ -716,6 +722,7 @@ struct Cartesian_converter_property_map
/// \ingroup PkgPropertyMapRef
/// returns `Cartesian_converter_property_map<GeomObject, Vpm>(vpm)`
/// \relates Cartesian_converter_property_map
template<class GeomObject, class Vpm>
Cartesian_converter_property_map<GeomObject, Vpm>
make_cartesian_converter_property_map(Vpm vpm)
@ -765,8 +772,8 @@ public:
};
/// \ingroup PkgPropertyMapRef
/// \relates Random_access_property_map
/// returns `Random_access_property_map<Container>(container)`
/// \relates Random_access_property_map
template <class Container>
Random_access_property_map<Container>
make_random_access_property_map(Container& container)
@ -775,6 +782,7 @@ make_random_access_property_map(Container& container)
}
/// \cond SKIP_IN_MANUAL
// Syntaxic sugar for transform_iterator+pmap_to_unary_function
template <typename Iterator, typename Pmap>
typename boost::transform_iterator<CGAL::Property_map_to_unary_function<Pmap>, Iterator>

View File

@ -5,3 +5,4 @@ Manual
Miscellany
Number_types
Surface_mesh
Triangulation_3

View File

@ -1,16 +1,3 @@
// Copyright 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// author(s) : Waqar Khan <wkhan@mpi-inf.mpg.de>
/* Usage
*
* This example converts arbitrary-precision arrangement into fixed-precision using Snap Rounding and by using INPUT DATA FROM A USER SPECIFIED FILE.

View File

@ -12,6 +12,7 @@ Point_set_processing_3
Polygon
Polygon_mesh_processing
Polyhedron
Property_map
SMDS_3
STL_Extension
Surface_mesh

View File

@ -21,6 +21,8 @@
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/iterator.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/use.h>
#include <boost/range/value_type.hpp>
@ -295,8 +297,11 @@ bool write_GOCAD(std::ostream& os,
"END_ORIGINAL_COORDINATE_SYSTEM\n"
"TFACE\n";
typedef typename Kernel_traits<typename boost::property_traits<PointMap>::value_type>::type K;
typedef Simple_cartesian<double> SC;
Cartesian_converter<K,SC> conv;
for(std::size_t i=0, end=points.size(); i<end; ++i)
os << "VRTX " << i << " " << get(point_map, points[i]) << "\n";
os << "VRTX " << i << " " << conv(get(point_map, points[i])) << "\n";
for(const Poly& poly : polygons)
{
@ -331,8 +336,14 @@ bool write_GOCAD(std::ostream& os,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamDescription{a parameter used to set the precision (i.e., how many digits are generated) of the output stream}
* \cgalParamType{int}
* \cgalParamDefault{the precision of the stream `os`}
* \cgalParamNEnd
@ -373,6 +384,12 @@ bool write_GOCAD(std::ostream& os,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}

View File

@ -19,6 +19,8 @@
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Simple_cartesian.h>
#include <iostream>
#include <iterator>
@ -51,11 +53,14 @@ public:
set_stream_precision_from_NP(m_os, np);
typedef typename Kernel_traits<typename boost::property_traits<PointMap>::value_type>::type K;
typedef Simple_cartesian<double> SC;
Cartesian_converter<K,SC> conv;
m_writer.write_header(m_os, points.size(), 0, polygons.size());
for(std::size_t i=0, end=points.size(); i<end; ++i)
{
const typename boost::property_traits<PointMap>::value_type& p = get(point_map, points[i]);
m_writer.write_vertex(to_double(p.x()), to_double(p.y()), to_double(p.z()));
decltype(auto) p = conv(get(point_map, points[i]));
m_writer.write_vertex(p.x(), p.y(), p.z());
}
m_writer.write_facet_header();

View File

@ -320,6 +320,12 @@ bool read_OBJ(const std::string& fname,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}
@ -364,6 +370,12 @@ bool write_OBJ(std::ostream& os,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}

View File

@ -267,6 +267,12 @@ bool read_OFF(const std::string& fname,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range`points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}
@ -308,6 +314,12 @@ bool write_OFF(std::ostream& os,
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}

View File

@ -17,6 +17,9 @@
#include <CGAL/IO/STL/STL_reader.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -233,14 +236,12 @@ typename K::Vector_3 construct_normal_of_STL_face(const typename K::Point_3& p,
typedef typename K::FT FT;
typedef typename K::Vector_3 Vector;
if(k.collinear_3_object()(p, q, r))
Vector res = k.construct_orthogonal_vector_3_object()(p, q, r);
const FT len = CGAL::approximate_sqrt(k.compute_squared_length_3_object()(res));
if (is_zero(len))
return k.construct_vector_3_object()(1, 0, 0);
Vector res = k.construct_orthogonal_vector_3_object()(p, q, r);
const FT sql = k.compute_squared_length_3_object()(res);
res = k.construct_divided_vector_3_object()(res, CGAL::approximate_sqrt(sql));
return res;
return k.construct_divided_vector_3_object()(res, len);
}
} // namespace internal
@ -296,7 +297,7 @@ bool write_STL(std::ostream& os,
typedef typename boost::property_traits<PointMap>::value_type Point;
typedef typename CGAL::Kernel_traits<Point>::Kernel K;
typedef typename K::Vector_3 Vector_3;
typedef typename K::Vector_3 Vector;
K k = choose_parameter<K>(get_parameter(np, internal_np::geom_traits));
@ -305,6 +306,9 @@ bool write_STL(std::ostream& os,
set_stream_precision_from_NP(os, np);
typedef Simple_cartesian<float> SC;
Cartesian_converter<K,SC> conv;
if(get_mode(os) == BINARY)
{
os << "FileType: Binary ";
@ -316,13 +320,17 @@ bool write_STL(std::ostream& os,
const Point& p = get(point_map, points[face[0]]);
const Point& q = get(point_map, points[face[1]]);
const Point& r = get(point_map, points[face[2]]);
const Vector n = internal::construct_normal_of_STL_face(p, q, r, k);
const Vector_3 n = internal::construct_normal_of_STL_face(p, q, r, k);
decltype(auto) pp = conv(p);
decltype(auto) qq = conv(q);
decltype(auto) rr = conv(r);
decltype(auto) nn = conv(n);
const float coords[12] = { static_cast<float>(n.x()), static_cast<float>(n.y()), static_cast<float>(n.z()),
static_cast<float>(p.x()), static_cast<float>(p.y()), static_cast<float>(p.z()),
static_cast<float>(q.x()), static_cast<float>(q.y()), static_cast<float>(q.z()),
static_cast<float>(r.x()), static_cast<float>(r.y()), static_cast<float>(r.z()) };
const float coords[12] = { nn.x(), nn.y(), nn.z(),
pp.x(), pp.y(), pp.z(),
qq.x(), qq.y(), qq.z(),
rr.x(), rr.y(), rr.z() };
for(int i=0; i<12; ++i)
os.write(reinterpret_cast<const char *>(&coords[i]), sizeof(coords[i]));
@ -337,12 +345,17 @@ bool write_STL(std::ostream& os,
const Point& p = get(point_map, points[face[0]]);
const Point& q = get(point_map, points[face[1]]);
const Point& r = get(point_map, points[face[2]]);
const Vector n = internal::construct_normal_of_STL_face(p, q, r, k);
const Vector_3 n = internal::construct_normal_of_STL_face(p, q, r, k);
os << "facet normal " << n << "\nouter loop\n";
os << "vertex " << p << "\n";
os << "vertex " << q << "\n";
os << "vertex " << r << "\n";
decltype(auto) pp = conv(p);
decltype(auto) qq = conv(q);
decltype(auto) rr = conv(r);
decltype(auto) nn = conv(n);
os << "facet normal " << nn << "\nouter loop\n";
os << "vertex " << pp << "\n";
os << "vertex " << qq << "\n";
os << "vertex " << rr << "\n";
os << "endloop\nendfacet\n";
}
os << "endsolid"<<std::endl;

View File

@ -20,6 +20,10 @@
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Simple_cartesian.h>
#include <boost/range.hpp>
#ifdef CGAL_USE_VTK
#include <vtkSmartPointer.h>
@ -241,8 +245,8 @@ void write_soup_points_tag(std::ostream& os,
typedef typename Gt::FT FT;
std::string format = binary ? "appended" : "ascii";
std::string type = (sizeof(FT) == 8) ? "Float64" : "Float32";
std::string type = (std::is_same_v<CGAL::cpp20::remove_cvref_t<FT>, float>) ? "Float32" : "Float64";
std::size_t sizeof_FT = (std::is_same_v<CGAL::cpp20::remove_cvref_t<FT>, float>) ? 4 : 8;
os << " <Points>\n"
<< " <DataArray type =\"" << type << "\" NumberOfComponents=\"3\" format=\""
<< format;
@ -250,14 +254,16 @@ void write_soup_points_tag(std::ostream& os,
if(binary)
{
os << "\" offset=\"" << offset << "\"/>\n";
offset += 3 * points.size() * sizeof(FT) + sizeof(std::size_t);
offset += 3 * points.size() * sizeof_FT + sizeof(std::size_t);
// 3 coords per points + length of the encoded data (size_t)
}
else
{
typedef Simple_cartesian<double> SC;
Cartesian_converter<Gt,SC> conv;
os << "\">\n";
for(const Point& p : points)
os << IO::oformat(p.x()) << " " << IO::oformat(p.y()) << " " << IO::oformat(p.z()) << " ";
os << conv(p) << " ";
os << " </DataArray>\n";
}
os << " </Points>\n";
@ -383,16 +389,31 @@ void write_soup_polys_points(std::ostream& os,
typedef typename CGAL::Kernel_traits<Point>::Kernel Gt;
typedef typename Gt::FT FT;
std::vector<FT> coordinates;
if(std::is_same_v<CGAL::cpp20::remove_cvref_t<FT>, float> ||
std::is_same_v<CGAL::cpp20::remove_cvref_t<FT>, double>){
std::vector<FT> coordinates;
for(const Point& p : points)
{
coordinates.push_back(p.x());
coordinates.push_back(p.y());
coordinates.push_back(p.z());
for(const Point& p : points)
{
coordinates.push_back(p.x());
coordinates.push_back(p.y());
coordinates.push_back(p.z());
}
write_vector<FT>(os, coordinates);
}else{
std::vector<double> coordinates;
for(const Point& p : points)
{
coordinates.push_back(CGAL::to_double(p.x()));
coordinates.push_back(CGAL::to_double(p.y()));
coordinates.push_back(CGAL::to_double(p.z()));
}
write_vector<double>(os, coordinates);
}
write_vector<FT>(os, coordinates);
}
} // namespace internal
@ -483,6 +504,7 @@ bool write_VTP(std::ostream& os,
internal::write_soup_polys(os, polygons,size_map, cell_type);
}
os << "</VTKFile>" << std::endl;
return true;
}
/*!

View File

@ -92,7 +92,7 @@ bool get_a_new_line(std::istream& in, std::string& line)
//!
//! \tparam Point can be a `CGAL::Point_2` or `CGAL::Point_3`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::Point_2`
//! \see `CGAL::Point_3`
@ -124,7 +124,7 @@ bool read_point_WKT(std::istream& in,
//! - a function `resize()` that takes a `size_type`
//! - an `operator[]()` that takes a `size_type`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::Point_2`
//! \see `CGAL::Point_3`
@ -162,7 +162,7 @@ bool read_multi_point_WKT(std::istream& in,
//! - a function `resize()` that takes a `size_type`
//! - an `operator[]()` that takes a `size_type`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::Point_2`
//! \see `CGAL::Point_3`
@ -199,7 +199,7 @@ bool read_linestring_WKT(std::istream& in,
//! - a function `resize()` that takes a `size_type`
//! - an `operator[]()` that takes a `size_type`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
template<typename MultiLineString>
bool read_multi_linestring_WKT(std::istream& in,
@ -239,7 +239,7 @@ bool read_multi_linestring_WKT(std::istream& in,
//!
//! \tparam Polygon is a `CGAL::General_polygon_with_holes_2`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::General_polygon_with_holes_2`
template<typename Polygon>
@ -274,7 +274,7 @@ bool read_polygon_WKT(std::istream& in,
//! - a function `resize()` that takes a `size_type`
//! - an `operator[]()` that takes a `size_type`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::General_polygon_with_holes_2`
template<typename MultiPolygon>
@ -317,7 +317,7 @@ bool read_multi_polygon_WKT(std::istream& in,
//!
//! \tparam Point is a `CGAL::Point_2` or `CGAL::Point_3`
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::Point_2`
//! \see `CGAL::Point_3`
@ -338,7 +338,7 @@ std::ostream& write_point_WKT(std::ostream& out,
//!
//! \tparam Polygon must be a `CGAL::General_polygon_with_holes_2`
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::General_polygon_with_holes_2`
template<typename Polygon>
@ -358,7 +358,7 @@ std::ostream& write_polygon_WKT(std::ostream& out,
//!
//! \tparam LineString must be a `RandomAccessRange` of `CGAL::Point_2` or `CGAL::Point_3`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//!\see `CGAL::Point_2`
//!\see `CGAL::Point_3`
@ -380,7 +380,7 @@ std::ostream& write_linestring_WKT(std::ostream& out,
//!
//! \tparam MultiPoint must be a `RandomAccessRange` of `CGAL::Point_2` or `CGAL::Point_3`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//!\see `CGAL::Point_2`
//!\see `CGAL::Point_2`
@ -402,7 +402,7 @@ std::ostream& write_multi_point_WKT(std::ostream& out,
//!
//! \tparam MultiPolygon must be a `RandomAccessRange` of `CGAL::General_polygon_with_holes_2`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//!\see `CGAL::General_polygon_with_holes_2`
template<typename MultiPolygon>
@ -430,7 +430,7 @@ std::ostream& write_multi_polygon_WKT(std::ostream& out,
//!
//! \tparam MultiLineString must be a `RandomAccessRange` of `LineString`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::IO::write_linestring_WKT()`
template<typename MultiLineString>
@ -465,7 +465,7 @@ std::ostream& write_multi_linestring_WKT(std::ostream& out,
//! \tparam MultiLineString must be a `RandomAccessRange` of `Linestring`.
//! \tparam MultiPolygon must be a model of `RandomAccessRange` of `CGAL::General_polygon_with_holes_2`.
//!
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
//! \attention Only %Cartesian Kernels with `double`or `float` as `FT` are supported.
//!
//! \see `CGAL::IO::read_linestring_WKT()`
template<typename MultiPoint,

View File

@ -142,6 +142,12 @@ bool read_polygon_soup(const std::string& fname,
* \param np optional \ref bgl_namedparameters "Named Parameters" described below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{point_map}
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
* of the iterator of `PointRange` and value type is a model of concept `Point_3`}
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
* \cgalParamNEnd
* \cgalParamNBegin{verbose}
* \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.}
* \cgalParamType{Boolean}

View File

@ -1,7 +1,12 @@
Algebraic_foundations
BGL
Cartesian_kernel
Circulator
Distance_2
Distance_3
Installation
Intersections_2
Intersections_3
Interval_support
Kernel_23
Modular_arithmetic

View File

@ -20,6 +20,15 @@ else()
message(STATUS "NOTICE : the LAS reader does not work with your version of Visual Studio 2017.")
endif()
set(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
find_package(VTK 9.0 QUIET COMPONENTS CommonCore IOCore IOLegacy IOXML FiltersCore FiltersSources)
if (VTK_FOUND AND VTK_LIBRARIES)
message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}")
else()
message(STATUS "Tests that use VTK will not be compiled.")
endif() #VTK_FOUND
# create a target per cppfile
file(
GLOB cppfiles
@ -45,7 +54,15 @@ foreach(cppfile ${cppfiles})
message(STATUS "NOTICE: Some tests require the LASlib library, and will not be compiled.")
endif()
else()
create_single_source_cgal_program("${cppfile}")
if("${cppfile}" STREQUAL "test_VTK.cpp")
if (VTK_FOUND AND VTK_LIBRARIES)
create_single_source_cgal_program("test_VTK.cpp")
target_link_libraries(test_VTK PRIVATE ${VTK_LIBRARIES})
target_compile_definitions(test_VTK PRIVATE -DCGAL_USE_VTK -DNOMINMAX)
endif()
else()
create_single_source_cgal_program("${cppfile}")
endif()
endif()
endif()
endforeach()

View File

@ -0,0 +1,16 @@
#include <array>
#include <vector>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/polygon_soup_io.h>
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
using Epick = CGAL::Exact_predicates_inexact_constructions_kernel;
int main() {
std::vector<Kernel::Point_3> points;
std::vector<std::array<std::size_t, 3>> polygons;
CGAL::IO::write_polygon_soup("xxx.off", points, polygons, CGAL::parameters::stream_precision(17));
return 0;
}

View File

@ -0,0 +1,44 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/IO/VTK.h>
#include <vector>
template <typename Kernel>
void test_VTK()
{
typedef typename Kernel::Point_3 Point;
typedef std::vector<std::size_t> Face;
const std::vector<Point> points = { Point(0,0,0), Point(1,0,0), Point(0,1,0), Point(0,0,1) };
const std::vector<Face> polygons = { Face{0,1,2}, Face{0,1,3}, Face{0,2,3}, Face{1,2,3} };
bool ok = CGAL::IO::write_VTP("tmp.vtp", points, polygons, CGAL::parameters::use_binary_mode(true));
assert(ok);
std::vector<Point> rpoints;
std::vector<Face> rpolygons;
ok = CGAL::IO::read_VTP("tmp.vtp", rpoints, rpolygons, CGAL::parameters::use_binary_mode(true));
assert(points == rpoints);
assert(polygons == rpolygons);
ok = CGAL::IO::write_VTP("tmp2.vtp", points, polygons, CGAL::parameters::use_binary_mode(false));
assert(ok);
rpoints.clear();
rpolygons.clear();
ok = CGAL::IO::read_VTP("tmp2.vtp", rpoints, rpolygons, CGAL::parameters::use_binary_mode(false));
assert(points == rpoints);
assert(polygons == rpolygons);
}
int main()
{
test_VTK<CGAL::Simple_cartesian<double>>();
test_VTK<CGAL::Simple_cartesian<CGAL::Exact_rational>>();
test_VTK<CGAL::Exact_predicates_exact_constructions_kernel>();
return 0;
}