Skip to content

Commit bf25dd2

Browse files
authored
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
2 parents 8ee288e + eb992b3 commit bf25dd2

File tree

18 files changed

+240
-74
lines changed

18 files changed

+240
-74
lines changed

Documentation/doc/Documentation/Tutorials/Tutorial_reconstruction.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ a newline character and each coordinate separated by a white
8383
space. Other formats available are 'OFF', 'PLY' and 'LAS'. \cgal
8484
provides functions to read such formats:
8585

86-
- `read_XYZ()`
87-
- `read_OFF()`
88-
- `read_PLY()`
89-
- `read_PLY_with_properties()` to read additional PLY properties
90-
- `read_LAS()`
91-
- `read_LAS_with_properties()` to read additional LAS properties
86+
- `CGAL::IO::read_XYZ()`
87+
- `CGAL::IO::read_OFF()`
88+
- `CGAL::IO::read_PLY()`
89+
- `CGAL::IO::read_PLY_with_properties()` to read additional PLY properties
90+
- `CGAL::IO::read_LAS()`
91+
- `CGAL::IO::read_LAS_with_properties()` to read additional LAS properties
9292

9393
\cgal also provides a dedicated container `CGAL::Point_set_3` to
9494
handle point sets with additional properties such as normal

Kernel_23/doc/Kernel_23/CGAL/Cartesian_converter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Cartesian_converter<>();
4848
/// @{
4949

5050
/*!
51-
returns a `K2::Point_2` which coordinates are those of `p`,
51+
returns a `K2::Point_2` whose coordinates are those of `p`,
5252
converted by `NTConverter`.
5353
*/
5454
K2::Point_2 operator()(const K1::Point_2&p);

Property_map/include/CGAL/property_map.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ make_OR_property_map(const PM1& pm1, const PM2& pm2)
105105
/// \cgalModels{ReadablePropertyMap}
106106
///
107107
/// \tparam InputIterator an input iterator
108-
/// \endcond
109108
template<class InputIterator>
110109
struct Input_iterator_property_map{
111110
typedef InputIterator key_type;
@@ -119,6 +118,8 @@ struct Input_iterator_property_map{
119118
get(Input_iterator_property_map<InputIterator>, const InputIterator& it){ return *it; }
120119
};
121120

121+
/// \endcond
122+
122123
#ifdef DOXYGEN_RUNNING
123124
/// \ingroup PkgPropertyMapRef
124125
/// Property map that composes two property maps,
@@ -274,8 +275,8 @@ struct Compose_property_map<KeyMap, ValueMap, boost::lvalue_property_map_tag>
274275
};
275276
#endif
276277
/// \ingroup PkgPropertyMapRef
277-
/// \relates Compose_property_map
278278
/// returns `Compose_property_maps<KeyMap, ValueMap>(km,vm)`
279+
/// \relates Compose_property_map
279280
template <class KeyMap, class ValueMap>
280281
Compose_property_map<KeyMap, ValueMap>
281282
make_compose_property_map(const KeyMap& km, const ValueMap& vm)
@@ -304,8 +305,8 @@ struct Dereference_property_map
304305
reference operator[](const Iter_& it) const { return *it; }
305306
};
306307

308+
/// \ingroup PkgPropertyMapRef
307309
/// Free function to create a `Dereference_property_map` property map.
308-
///
309310
/// \relates Dereference_property_map
310311
template <class Iter> // Type convertible to `key_type`
311312
Dereference_property_map<typename CGAL::value_type_traits<Iter>::type>
@@ -371,8 +372,8 @@ struct Identity_property_map_no_lvalue
371372
};
372373
/// \endcond
373374

375+
/// \ingroup PkgPropertyMapRef
374376
/// Free function to create a `Identity_property_map` property map.
375-
///
376377
/// \relates Identity_property_map
377378
template <class T> // Key and value type
378379
Identity_property_map<T>
@@ -409,8 +410,8 @@ struct First_of_pair_property_map
409410
/// @}
410411
};
411412

413+
/// \ingroup PkgPropertyMapRef
412414
/// Free function to create a `First_of_pair_property_map` property map.
413-
///
414415
/// \relates First_of_pair_property_map
415416
template <class Pair> // Pair type
416417
First_of_pair_property_map<Pair>
@@ -449,8 +450,8 @@ struct Second_of_pair_property_map
449450
/// @}
450451
};
451452

453+
/// \ingroup PkgPropertyMapRef
452454
/// Free function to create a Second_of_pair_property_map property map.
453-
///
454455
/// \relates Second_of_pair_property_map
455456
template <class Pair> // Pair type
456457
Second_of_pair_property_map<Pair>
@@ -509,8 +510,8 @@ struct Nth_of_tuple_property_map<N,std::tuple<T...> >
509510
friend void put(const Self&, key_type& k, const value_type& v) { std::get<N>(k) = v; }
510511
};
511512

513+
/// \ingroup PkgPropertyMapRef
512514
/// Free function to create a Nth_of_tuple_property_map property map.
513-
///
514515
/// \relates Nth_of_tuple_property_map
515516
template <int N, class Tuple> // Tuple type
516517
Nth_of_tuple_property_map<N, Tuple>
@@ -563,6 +564,7 @@ struct Pointer_property_map{
563564
/// This function is a shortcut to the recommended replacement:
564565
/// `boost::make_iterator_property_map(<pointer>, boost::typed_identity_property_map<std::size_t>())`
565566
/// Note that the property map is a mutable `LvaluePropertyMap` with `std::size_t` as key.
567+
/// \relates Pointer_property_map
566568
template <class T>
567569
inline
568570
typename Pointer_property_map<T>::type
@@ -574,6 +576,7 @@ make_property_map(T* pointer)
574576
/// \ingroup PkgPropertyMapRef
575577
/// equivalent to `make_property_map(&v[0])`
576578
/// Note that `v` must not be modified while using the property map created
579+
/// \relates Pointer_property_map
577580
template <class T>
578581
inline
579582
typename Pointer_property_map<T>::type
@@ -587,6 +590,7 @@ make_property_map(std::vector<T>& v)
587590

588591
/// \ingroup PkgPropertyMapRef
589592
/// Non-mutable version
593+
/// \relates Pointer_property_map
590594
template <class T>
591595
inline
592596
typename Pointer_property_map<T>::const_type
@@ -598,6 +602,7 @@ make_property_map(const T* pointer)
598602
/// \ingroup PkgPropertyMapRef
599603
/// equivalent to `make_property_map(&v[0])`
600604
/// Note that `v` must not be modified while using the property map created
605+
/// \relates Pointer_property_map
601606
template <class T>
602607
inline
603608
typename Pointer_property_map<T>::const_type
@@ -674,6 +679,7 @@ struct Boolean_property_map
674679

675680
/// \ingroup PkgPropertyMapRef
676681
/// returns `Boolean_property_map<Set>(set_)`
682+
/// \relates Boolean_property_map
677683
template <class Set>
678684
Boolean_property_map<Set>
679685
make_boolean_property_map(Set& set_)
@@ -716,6 +722,7 @@ struct Cartesian_converter_property_map
716722

717723
/// \ingroup PkgPropertyMapRef
718724
/// returns `Cartesian_converter_property_map<GeomObject, Vpm>(vpm)`
725+
/// \relates Cartesian_converter_property_map
719726
template<class GeomObject, class Vpm>
720727
Cartesian_converter_property_map<GeomObject, Vpm>
721728
make_cartesian_converter_property_map(Vpm vpm)
@@ -765,8 +772,8 @@ class Random_access_property_map
765772
};
766773

767774
/// \ingroup PkgPropertyMapRef
768-
/// \relates Random_access_property_map
769775
/// returns `Random_access_property_map<Container>(container)`
776+
/// \relates Random_access_property_map
770777
template <class Container>
771778
Random_access_property_map<Container>
772779
make_random_access_property_map(Container& container)
@@ -775,6 +782,7 @@ make_random_access_property_map(Container& container)
775782
}
776783

777784
/// \cond SKIP_IN_MANUAL
785+
778786
// Syntaxic sugar for transform_iterator+pmap_to_unary_function
779787
template <typename Iterator, typename Pmap>
780788
typename boost::transform_iterator<CGAL::Property_map_to_unary_function<Pmap>, Iterator>

STL_Extension/doc/STL_Extension/dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Manual
55
Miscellany
66
Number_types
77
Surface_mesh
8+
Triangulation_3

Snap_rounding_2/examples/Snap_rounding_2/snap_rounding_data.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
// Copyright 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
2-
// All rights reserved.
3-
//
4-
// This file is part of CGAL (www.cgal.org).
5-
//
6-
// $URL$
7-
// $Id$
8-
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9-
//
10-
//
11-
// author(s) : Waqar Khan <[email protected]>
12-
13-
141
/* Usage
152
*
163
* This example converts arbitrary-precision arrangement into fixed-precision using Snap Rounding and by using INPUT DATA FROM A USER SPECIFIED FILE.

Stream_support/doc/Stream_support/dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Point_set_processing_3
1212
Polygon
1313
Polygon_mesh_processing
1414
Polyhedron
15+
Property_map
1516
SMDS_3
1617
STL_Extension
1718
Surface_mesh

Stream_support/include/CGAL/IO/GOCAD.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <CGAL/boost/graph/named_params_helper.h>
2222
#include <CGAL/iterator.h>
2323
#include <CGAL/Kernel_traits.h>
24+
#include <CGAL/Cartesian_converter.h>
25+
#include <CGAL/Simple_cartesian.h>
2426
#include <CGAL/use.h>
2527

2628
#include <boost/range/value_type.hpp>
@@ -295,8 +297,11 @@ bool write_GOCAD(std::ostream& os,
295297
"END_ORIGINAL_COORDINATE_SYSTEM\n"
296298
"TFACE\n";
297299

300+
typedef typename Kernel_traits<typename boost::property_traits<PointMap>::value_type>::type K;
301+
typedef Simple_cartesian<double> SC;
302+
Cartesian_converter<K,SC> conv;
298303
for(std::size_t i=0, end=points.size(); i<end; ++i)
299-
os << "VRTX " << i << " " << get(point_map, points[i]) << "\n";
304+
os << "VRTX " << i << " " << conv(get(point_map, points[i])) << "\n";
300305

301306
for(const Poly& poly : polygons)
302307
{
@@ -331,8 +336,14 @@ bool write_GOCAD(std::ostream& os,
331336
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
332337
*
333338
* \cgalNamedParamsBegin
339+
* \cgalParamNBegin{point_map}
340+
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
341+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
342+
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
343+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
344+
* \cgalParamNEnd
334345
* \cgalParamNBegin{stream_precision}
335-
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
346+
* \cgalParamDescription{a parameter used to set the precision (i.e., how many digits are generated) of the output stream}
336347
* \cgalParamType{int}
337348
* \cgalParamDefault{the precision of the stream `os`}
338349
* \cgalParamNEnd
@@ -373,6 +384,12 @@ bool write_GOCAD(std::ostream& os,
373384
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
374385
*
375386
* \cgalNamedParamsBegin
387+
* \cgalParamNBegin{point_map}
388+
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
389+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
390+
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
391+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
392+
* \cgalParamNEnd
376393
* \cgalParamNBegin{stream_precision}
377394
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
378395
* \cgalParamType{int}

Stream_support/include/CGAL/IO/Generic_writer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <CGAL/Named_function_parameters.h>
2121
#include <CGAL/boost/graph/named_params_helper.h>
22+
#include <CGAL/Cartesian_converter.h>
23+
#include <CGAL/Simple_cartesian.h>
2224

2325
#include <iostream>
2426
#include <iterator>
@@ -51,11 +53,14 @@ class Generic_writer
5153

5254
set_stream_precision_from_NP(m_os, np);
5355

56+
typedef typename Kernel_traits<typename boost::property_traits<PointMap>::value_type>::type K;
57+
typedef Simple_cartesian<double> SC;
58+
Cartesian_converter<K,SC> conv;
5459
m_writer.write_header(m_os, points.size(), 0, polygons.size());
5560
for(std::size_t i=0, end=points.size(); i<end; ++i)
5661
{
57-
const typename boost::property_traits<PointMap>::value_type& p = get(point_map, points[i]);
58-
m_writer.write_vertex(to_double(p.x()), to_double(p.y()), to_double(p.z()));
62+
decltype(auto) p = conv(get(point_map, points[i]));
63+
m_writer.write_vertex(p.x(), p.y(), p.z());
5964
}
6065

6166
m_writer.write_facet_header();

Stream_support/include/CGAL/IO/OBJ.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ bool read_OBJ(const std::string& fname,
320320
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
321321
*
322322
* \cgalNamedParamsBegin
323+
* \cgalParamNBegin{point_map}
324+
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
325+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
326+
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
327+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
328+
* \cgalParamNEnd
323329
* \cgalParamNBegin{stream_precision}
324330
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
325331
* \cgalParamType{int}
@@ -364,6 +370,12 @@ bool write_OBJ(std::ostream& os,
364370
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
365371
*
366372
* \cgalNamedParamsBegin
373+
* \cgalParamNBegin{point_map}
374+
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
375+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
376+
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
377+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
378+
* \cgalParamNEnd
367379
* \cgalParamNBegin{stream_precision}
368380
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
369381
* \cgalParamType{int}

Stream_support/include/CGAL/IO/OFF.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ bool read_OFF(const std::string& fname,
267267
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
268268
*
269269
* \cgalNamedParamsBegin
270+
* \cgalParamNBegin{point_map}
271+
* \cgalParamDescription{a property map associating points to the elements of the range`points`}
272+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
273+
* of the iterator of `PointRange` and value type is a model of the concept `Point_3`}
274+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
275+
* \cgalParamNEnd
270276
* \cgalParamNBegin{stream_precision}
271277
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
272278
* \cgalParamType{int}
@@ -308,6 +314,12 @@ bool write_OFF(std::ostream& os,
308314
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
309315
*
310316
* \cgalNamedParamsBegin
317+
* \cgalParamNBegin{point_map}
318+
* \cgalParamDescription{a property map associating points to the elements of the range `points`}
319+
* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type
320+
* of the iterator of `PointRange` and value type is a model of the concept `Kernel::Point_3`}
321+
* \cgalParamDefault{`CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>`}
322+
* \cgalParamNEnd
311323
* \cgalParamNBegin{stream_precision}
312324
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
313325
* \cgalParamType{int}

0 commit comments

Comments
 (0)