more clean-up

This commit is contained in:
Maxime Gimeno 2020-03-19 16:41:59 +01:00
parent ce4cbe6d06
commit fe0d4d0a6e
8 changed files with 135 additions and 133 deletions

View File

@ -350,20 +350,20 @@ intersection(const typename K::Triangle_2 &tr1,
const typename K::Triangle_2 &tr2,
const K&)
{
typedef Triangle_2_Triangle_2_pair<K> is_t;
is_t ispair(&tr1, &tr2);
typedef Triangle_2_Triangle_2_pair<K> Intersection_type;
Intersection_type ispair(&tr1, &tr2);
switch (ispair.intersection_type())
{
case is_t::NO_INTERSECTION:
case Intersection_type::NO_INTERSECTION:
default:
return intersection_return<typename K::Intersect_2, typename K::Triangle_2, typename K::Triangle_2>();
case is_t::POINT:
case Intersection_type::POINT:
return intersection_return<typename K::Intersect_2, typename K::Triangle_2, typename K::Triangle_2>(ispair.intersection_point());
case is_t::SEGMENT:
case Intersection_type::SEGMENT:
return intersection_return<typename K::Intersect_2, typename K::Triangle_2, typename K::Triangle_2>(ispair.intersection_segment());
case is_t::TRIANGLE:
case Intersection_type::TRIANGLE:
return intersection_return<typename K::Intersect_2, typename K::Triangle_2, typename K::Triangle_2>(ispair.intersection_triangle());
case is_t::POLYGON:
case Intersection_type::POLYGON:
{
typedef std::vector<typename K::Point_2> Container;
Container points(ispair.vertex_count());
@ -372,10 +372,7 @@ intersection(const typename K::Triangle_2 &tr1,
if(Is_cw<K, typename Algebraic_structure_traits<typename K::FT>::Is_exact>()(points))
{
std::size_t length = points.size();
for(std::size_t i = 0; i< length/2; ++i)
std::swap(points[i], points[length-i-1]);
std::reverse(points.begin(), points.end());
}
return intersection_return<typename K::Intersect_2, typename K::Triangle_2, typename K::Triangle_2>(points);

View File

@ -151,8 +151,8 @@ intersection(
case 2: //intersects diagonally
{
Poly res(4);
Segment_3 front(segments.front()),
back(segments.back());
Segment_3 &front(segments.front()),
&back(segments.back());
res[0] = front.target();
res[1] = back.target();
res[2] = back.source();
@ -311,13 +311,17 @@ intersection(
}
}
}
if(tmp_segs.size() < 3)
return result_type();
std::list<Point_3> tmp_pts;
fill_points_list(tmp_segs,tmp_pts);
Poly res;
for(const auto& p : tmp_pts)
res.push_back(p);
if(res.size() == 3){
typename K::Triangle_3 tr(res[0], res[1], res[2]);
return result_type(std::forward<typename K::Triangle_3>(tr));

View File

@ -32,7 +32,7 @@ struct Tetrahedron_segment_intersection_3
typedef typename K::Segment_3 O;
typedef Tetrahedron_lines_intersection_3_base<K,typename K::Segment_3,
Tetrahedron_segment_intersection_3<K> > Base;
typedef typename Base::Result_type Result_type;
typedef typename Base::Result_type result_type;
Tetrahedron_segment_intersection_3(const typename K::Tetrahedron_3& tet,
const O& o):Base(tet,o) {}
@ -43,7 +43,7 @@ struct Tetrahedron_segment_intersection_3
if(this->tet.has_on_bounded_side(this->o.source())
&& this->tet.has_on_bounded_side(this->o.target())){
typename K::Segment_3 result = this->o;
this->output = Result_type(std::forward<typename K::Segment_3>(result));
this->output = result_type(std::forward<typename K::Segment_3>(result));
return true;
}
return false;
@ -55,12 +55,12 @@ struct Tetrahedron_segment_intersection_3
if(this->tet.has_on_bounded_side(this->o.source()))
{
typename K::Segment_3 result(this->o.source(), this->res_points.front());
this->output = Result_type(std::forward<typename K::Segment_3>(result));
this->output = result_type(std::forward<typename K::Segment_3>(result));
return true;
}
else if(this->tet.has_on_bounded_side(this->o.target())){
typename K::Segment_3 result(this->res_points.front(), this->o.target());
this->output = Result_type(std::forward<typename K::Segment_3>(result));
this->output = result_type(std::forward<typename K::Segment_3>(result));
return true;
}
return false;

View File

@ -110,9 +110,8 @@ intersection(
fill_segments_infos(segments,tmp, tr);
Poly res;
res.reserve(4);
for( const auto& p : tmp){
for(const auto& p : tmp)
res.push_back(p);
}
return result_type(std::forward<Poly>(res));
}
//else it must be adjacent to an vertex, so we return the point
@ -238,7 +237,8 @@ intersection(
Poly res;
res.reserve(4);
res.push_back(inside_points.front());
for( const auto& p : tmp){res.push_back(p);}
for(const auto& p : tmp)
res.push_back(p);
return result_type(std::forward<Poly>(res));
}
else //size 2
@ -256,7 +256,8 @@ intersection(
res.push_back(inside_points.front());
}
res.push_back(inside_points.back());
for( const auto& p : tmp){res.push_back(p);}
for(const auto& p : tmp)
res.push_back(p);
return result_type(std::forward<Poly>(res));
}
}

View File

@ -66,7 +66,7 @@ void fill_segments_infos(std::vector<Segment>& segments,
std::vector<Wrapped_segment> wrapped_segments;
for(const auto& s:segments)
for(const Segment& s:segments)
wrapped_segments.push_back(Wrapped_segment(s));
std::vector<Segment> bis = segments;

View File

@ -720,7 +720,7 @@ struct Test {
const std::vector<P>* poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(tet.has_on_boundary(p) && tr.has_on(p));
}
@ -773,7 +773,7 @@ struct Test {
std::vector<P>* inter = boost::get<std::vector<P> >(&*res);
CGAL_assertion(inter != nullptr);
CGAL_assertion(inter->size() == 4);
for(auto p : *inter)
for(auto& p : *inter)
{
CGAL_assertion(tet.has_on_boundary(p) && tr.has_on(p));
}
@ -788,7 +788,7 @@ struct Test {
inter = boost::get<std::vector<P> >(&*res);
CGAL_assertion(inter != nullptr);
CGAL_assertion(inter->size() == 4);
for(auto p : *inter)
for(auto& p : *inter)
{
CGAL_assertion(tet.has_on_boundary(p) && tr.has_on(p));
}
@ -823,7 +823,7 @@ struct Test {
CGAL_assertion(inter != nullptr);
CGAL_assertion(inter->size() == 4);
for(auto p : *inter)
for(auto& p : *inter)
{
CGAL_assertion(
(tet.has_on_bounded_side(p) || tet.has_on_boundary(p))
@ -914,7 +914,7 @@ struct Test {
const std::vector<P>* poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(p.x() == 1);
}
@ -922,7 +922,7 @@ struct Test {
poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(cub.has_on_boundary(p));
}
@ -945,7 +945,7 @@ struct Test {
poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(pl.has_on(p) && cub.has_on_boundary(p));
}
@ -956,7 +956,7 @@ struct Test {
poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 5);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(pl.has_on(p) && cub.has_on_boundary(p));
}
@ -1105,7 +1105,7 @@ struct Test {
const std::vector<P>* poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(p.x() == 1);
}
@ -1131,7 +1131,7 @@ struct Test {
poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 5);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(pl.has_on(p));
}
@ -1184,7 +1184,7 @@ struct Test {
std::vector<P>* poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(tr.has_on(p) && cub.has_on_boundary(p));
}
@ -1212,7 +1212,7 @@ struct Test {
std::vector<P>* poly = boost::get<std::vector<P> >(&*res);
CGAL_assertion(poly != nullptr);
CGAL_assertion(poly->size() == 4);
for(auto p : *poly)
for(auto& p : *poly)
{
CGAL_assertion(tr.has_on(p) && cub.has_on_boundary(p));
}