From e9c652d63f4483e92b8e9370485550b67c522638 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 8 Feb 2018 15:03:39 +0000 Subject: [PATCH 1/4] Add several fallthrough --- .../Triangle_3_Segment_3_intersection.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h index e26e108a5de..18f4da33ae2 100644 --- a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h +++ b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h @@ -263,7 +263,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, else return intersection_return(); } - + CGAL_FALLTHROUGH; case NEGATIVE: if ( POSITIVE == pqc ) // b is isolated on the negative side @@ -271,7 +271,6 @@ intersection_coplanar(const typename K::Triangle_3 &t, else // a is isolated on the positive side return t3s3_intersection_coplanar_aux(b,c,a,q,p,false,k); - case COLLINEAR: switch ( pqc ) { case POSITIVE: @@ -286,7 +285,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, // b,c,p,q are aligned, [p,q]&[b,c] have the same direction return t3s3_intersection_collinear_aux(b,c,p,q,k); } - + CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); return intersection_return(); @@ -320,6 +319,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, else return intersection_return(); } + CGAL_FALLTHROUGH; case COLLINEAR: switch ( pqc ) { @@ -335,6 +335,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, // b,c,p,q are aligned, [p,q]&[c,b] have the same direction return t3s3_intersection_collinear_aux(c,b,p,q,k); } + CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); @@ -360,6 +361,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, // a,c,p,q are aligned, [p,q]&[c,a] have the same direction return t3s3_intersection_collinear_aux(c,a,p,q,k); } + CGAL_FALLTHROUGH; case NEGATIVE: switch ( pqc ) { @@ -375,6 +377,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, // a,c,p,q are aligned, [p,q]&[a,c] have the same direction return t3s3_intersection_collinear_aux(a,c,p,q,k); } + CGAL_FALLTHROUGH; case COLLINEAR: switch ( pqc ) { @@ -390,6 +393,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, CGAL_error(); return intersection_return(); } + CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); From fbc1a9b1d3797084e65a2ab6397b3978e8b73b56 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 8 Feb 2018 15:11:48 +0000 Subject: [PATCH 2/4] Replace last case with default and remove fallthrough --- .../Triangle_3_Segment_3_intersection.h | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h index 18f4da33ae2..a2755831f12 100644 --- a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h +++ b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h @@ -257,13 +257,12 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // c is isolated on the negative side return t3s3_intersection_coplanar_aux(a,b,c,p,q,true,k); - case COLLINEAR: + dafault: if ( collinear_ordered(p,c,q) ) // c is inside [p,q] return intersection_return(c); else return intersection_return(); } - CGAL_FALLTHROUGH; case NEGATIVE: if ( POSITIVE == pqc ) // b is isolated on the negative side @@ -281,11 +280,10 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // a is isolated on the positive side return t3s3_intersection_coplanar_aux(b,c,a,q,p,false,k); - case COLLINEAR: + default: // b,c,p,q are aligned, [p,q]&[b,c] have the same direction return t3s3_intersection_collinear_aux(b,c,p,q,k); } - CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); return intersection_return(); @@ -313,13 +311,12 @@ intersection_coplanar(const typename K::Triangle_3 &t, // the triangle lies in the negative halfspace // defined by the segment's supporting line. return intersection_return(); - case COLLINEAR: + default: if ( collinear_ordered(p,c,q) ) // c is inside [p,q] return intersection_return(c); else return intersection_return(); } - CGAL_FALLTHROUGH; case COLLINEAR: switch ( pqc ) { @@ -331,11 +328,10 @@ intersection_coplanar(const typename K::Triangle_3 &t, return intersection_return(b); else return intersection_return(); - case COLLINEAR: + default: // b,c,p,q are aligned, [p,q]&[c,b] have the same direction return t3s3_intersection_collinear_aux(c,b,p,q,k); } - CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); @@ -357,11 +353,10 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // b is isolated on the positive side return t3s3_intersection_coplanar_aux(c,a,b,q,p,false,k); - case COLLINEAR: + default: // a,c,p,q are aligned, [p,q]&[c,a] have the same direction return t3s3_intersection_collinear_aux(c,a,p,q,k); } - CGAL_FALLTHROUGH; case NEGATIVE: switch ( pqc ) { @@ -373,11 +368,10 @@ intersection_coplanar(const typename K::Triangle_3 &t, return intersection_return(a); else return intersection_return(); - case COLLINEAR: + default: // a,c,p,q are aligned, [p,q]&[a,c] have the same direction return t3s3_intersection_collinear_aux(a,c,p,q,k); } - CGAL_FALLTHROUGH; case COLLINEAR: switch ( pqc ) { @@ -387,13 +381,12 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // a,b,p,q are aligned, [p,q]&[b,a] have the same direction return t3s3_intersection_collinear_aux(b,a,p,q,k); - case COLLINEAR: + default: // case pqc == COLLINEAR is impossible since the triangle is // assumed to be non flat CGAL_error(); return intersection_return(); } - CGAL_FALLTHROUGH; default: // should not happen. CGAL_error(); From 6f79d2c6f0495912dfcb62cb755ead107cf2c8fc Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 8 Feb 2018 15:30:25 +0000 Subject: [PATCH 3/4] fix typo --- .../Intersections_3/Triangle_3_Segment_3_intersection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h index a2755831f12..9b4051fb186 100644 --- a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h +++ b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h @@ -257,7 +257,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // c is isolated on the negative side return t3s3_intersection_coplanar_aux(a,b,c,p,q,true,k); - dafault: + default: if ( collinear_ordered(p,c,q) ) // c is inside [p,q] return intersection_return(c); else From 11704338853f0d9ccd684657c036c21d7b24d6ba Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 9 Feb 2018 14:23:40 +0000 Subject: [PATCH 4/4] Comment what default means --- .../Triangle_3_Segment_3_intersection.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h index 9b4051fb186..320919e4593 100644 --- a/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h +++ b/Intersections_3/include/CGAL/internal/Intersections_3/Triangle_3_Segment_3_intersection.h @@ -280,7 +280,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // a is isolated on the positive side return t3s3_intersection_coplanar_aux(b,c,a,q,p,false,k); - default: + default: // COLLINEAR // b,c,p,q are aligned, [p,q]&[b,c] have the same direction return t3s3_intersection_collinear_aux(b,c,p,q,k); } @@ -311,7 +311,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, // the triangle lies in the negative halfspace // defined by the segment's supporting line. return intersection_return(); - default: + default: // COLLINEAR if ( collinear_ordered(p,c,q) ) // c is inside [p,q] return intersection_return(c); else @@ -328,7 +328,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, return intersection_return(b); else return intersection_return(); - default: + default: // COLLINEAR // b,c,p,q are aligned, [p,q]&[c,b] have the same direction return t3s3_intersection_collinear_aux(c,b,p,q,k); } @@ -353,7 +353,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // b is isolated on the positive side return t3s3_intersection_coplanar_aux(c,a,b,q,p,false,k); - default: + default: // COLLINEAR // a,c,p,q are aligned, [p,q]&[c,a] have the same direction return t3s3_intersection_collinear_aux(c,a,p,q,k); } @@ -368,7 +368,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, return intersection_return(a); else return intersection_return(); - default: + default: // COLLINEAR // a,c,p,q are aligned, [p,q]&[a,c] have the same direction return t3s3_intersection_collinear_aux(a,c,p,q,k); } @@ -381,7 +381,7 @@ intersection_coplanar(const typename K::Triangle_3 &t, case NEGATIVE: // a,b,p,q are aligned, [p,q]&[b,a] have the same direction return t3s3_intersection_collinear_aux(b,a,p,q,k); - default: + default: // COLLINEAR // case pqc == COLLINEAR is impossible since the triangle is // assumed to be non flat CGAL_error();