mirror of https://github.com/CGAL/cgal
Reinstated back conversions
This commit is contained in:
parent
1683b8d39c
commit
8fa117bcc6
|
|
@ -102,7 +102,7 @@ convert_polygon_iterator(InputIterator it,
|
||||||
using Function_type = std::function<Return_type(Input_type)>;
|
using Function_type = std::function<Return_type(Input_type)>;
|
||||||
|
|
||||||
Function_type func =
|
Function_type func =
|
||||||
std::bind (convert_polygon<Kernel>, std::placeholders::_1, std::ref(tr));
|
std::bind(convert_polygon<Kernel>, std::placeholders::_1, std::ref(tr));
|
||||||
|
|
||||||
return boost::transform_iterator<Function_type, InputIterator>(it, func);
|
return boost::transform_iterator<Function_type, InputIterator>(it, func);
|
||||||
}
|
}
|
||||||
|
|
@ -118,34 +118,30 @@ struct Polygon_converter {
|
||||||
using Output_polygon = typename Output_type::Polygon_2;
|
using Output_polygon = typename Output_type::Polygon_2;
|
||||||
|
|
||||||
OutputIterator& output;
|
OutputIterator& output;
|
||||||
Polygon_converter(OutputIterator& output) : output (output) { }
|
Polygon_converter(OutputIterator& output) : output(output) {}
|
||||||
|
|
||||||
void operator() (const Input_type& pwh) const {
|
void operator()(const Input_type& pwh) const {
|
||||||
Output_polygon outer_boundary;
|
Output_polygon outer_boundary;
|
||||||
convert_polygon (pwh.outer_boundary(), outer_boundary);
|
convert_polygon(pwh.outer_boundary(), outer_boundary);
|
||||||
|
|
||||||
std::vector<Output_polygon> holes;
|
std::vector<Output_polygon> holes;
|
||||||
|
|
||||||
for (const Input_polygon& h : pwh.holes()) {
|
for (const Input_polygon& h : pwh.holes()) {
|
||||||
holes.emplace_back ();
|
holes.emplace_back();
|
||||||
convert_polygon (h, holes.back());
|
convert_polygon(h, holes.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
*(output ++) = Output_type(outer_boundary, holes.begin(), holes.end());
|
*(output++) = Output_type(outer_boundary, holes.begin(), holes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void convert_polygon(const Input_polygon& input, Output_polygon& out) const {
|
void convert_polygon(const Input_polygon& input, Output_polygon& out) const {
|
||||||
for (typename Input_polygon::Curve_const_iterator it = input.curves_begin();
|
for (auto cit = input.curves_begin(); cit != input.curves_end(); ++cit) {
|
||||||
it != input.curves_end(); ++ it)
|
auto end = cit->points_end();
|
||||||
{
|
// Skip last point, which is a duplication of the first point
|
||||||
// Skip last point which is the repetition of the first point
|
--end;
|
||||||
typename Input_polygon::X_monotone_curve_2::Point_const_iterator
|
for (auto pit = cit->points_begin(); pit != end; ++pit)
|
||||||
end = it->points_end();
|
out.push_back(*pit);
|
||||||
-- end;
|
|
||||||
for (typename Input_polygon::X_monotone_curve_2::Point_const_iterator
|
|
||||||
it2 = it->points_begin(); it2 != end; ++ it2)
|
|
||||||
out.push_back (*it2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -161,31 +157,38 @@ struct Polygon_converter_output_iterator :
|
||||||
|
|
||||||
OutputIterator& output;
|
OutputIterator& output;
|
||||||
Polygon_converter_output_iterator(OutputIterator& output) :
|
Polygon_converter_output_iterator(OutputIterator& output) :
|
||||||
Base(output), output(output)
|
Base(output),
|
||||||
|
output(output)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
operator OutputIterator() const { return output; }
|
operator OutputIterator() const { return output; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// THIS IS A TEMPORARY PLACE HOLDER AND SHOULD BE REMOVED
|
|
||||||
// Convert General_polygon_2<Polyline_traits> to Polygon_2
|
// Convert General_polygon_2<Polyline_traits> to Polygon_2
|
||||||
template <typename Kernel, typename Container, typename ArrTraits>
|
template <typename Kernel, typename Container, typename ArrTraits>
|
||||||
Polygon_2<Kernel, Container>
|
Polygon_2<Kernel, Container>
|
||||||
convert_polygon_back(const General_polygon_2<ArrTraits>& pgn)
|
convert_polygon_back(const General_polygon_2<ArrTraits>& gpgn) {
|
||||||
{
|
Polygon_2<Kernel, Container> pgn;
|
||||||
Polygon_2<Kernel, Container> tmp;
|
for (auto cit = gpgn.curves_begin(); cit != gpgn.curves_end(); ++cit) {
|
||||||
return tmp;
|
auto end = cit->points_end();
|
||||||
|
--end; // skip last point, which is a duplication of the first point
|
||||||
|
for (auto pit = cit->points_begin(); pit != end; ++pit) pgn.push_back(*pit);
|
||||||
|
}
|
||||||
|
return pgn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// THIS IS A TEMPORARY PLACE HOLDER AND SHOULD BE REMOVED
|
|
||||||
// Convert General_polygon_with_holes_2<Polyline_traits> to Polygon_with_holes_2
|
// Convert General_polygon_with_holes_2<Polyline_traits> to Polygon_with_holes_2
|
||||||
template <typename Kernel, typename Container, typename ArrTraits>
|
template <typename Kernel, typename Container, typename ArrTraits>
|
||||||
Polygon_with_holes_2<Kernel, Container>
|
Polygon_with_holes_2<Kernel, Container>
|
||||||
convert_polygon_back(const General_polygon_with_holes_2
|
convert_polygon_back(const General_polygon_with_holes_2
|
||||||
<General_polygon_2<ArrTraits> >& pwh)
|
<General_polygon_2<ArrTraits> >& gpwh)
|
||||||
{
|
{
|
||||||
Polygon_with_holes_2<Kernel, Container> tmp;
|
std::vector<Polygon_2<Kernel, Container>> holes;
|
||||||
return tmp;
|
for (const auto& gh : gpwh.holes())
|
||||||
|
holes.emplace_back(convert_polygon_back<Kernel, Container>(gh));
|
||||||
|
return Polygon_with_holes_2<Kernel, Container>
|
||||||
|
(convert_polygon_back<Kernel, Container>(gpwh.outer_boundary()),
|
||||||
|
holes.begin(), holes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts General_polygon_with_holes_2<Polyline_traits> to
|
// Converts General_polygon_with_holes_2<Polyline_traits> to
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue