diff --git a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_d.h b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_d.h
index aecf017cdbc..20f27bb125f 100644
--- a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_d.h
+++ b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_d.h
@@ -12,15 +12,14 @@ need to provide a unique `id`-number. The policy parameter
`IdPolicy` offers several choices. The template parameters have to
comply with the following requirements:
-
-- `NT`: number type for the box boundaries, needs to be a model
-of the `Assignable` and the `LessThanComparable` concept.
-
- `int D`: the dimension of the box.
-
- `IdPolicy`: specifies how the `id`-number will be
-provided. Can be one of the following types, where
+\tparam NT is the number type for the box boundaries. It must meet the requierements
+of the concepts `Assignable` and `LessThanComparable`.
+\tparam D is an integer and the dimension of the box.
+\tparam IdPolicy specifies how the `id`-number will be
+provided and can be one of the following types, where
`ID_EXPLICIT` is the default for this parameter:
-- `ID_NONE`: no `id`-number is provided. Can be useful
+
- `ID_NONE`: no `id`-number is provided. This can be useful
if `Box_d` is used as a base class for a different
implementation of `id`-numbers than the ones provided
here.
@@ -32,15 +31,14 @@ the old one, which is the behavior needed by the
`box_self_intersection_d()` algorithm. This is therefore
the safe default implementation.
- `ID_FROM_BOX_ADDRESS`: casts the address of the box into a
-`std::ptrdiff_t` to create the `id`-number. Works fine
+`std::ptrdiff_t` to create the `id`-number. This works fine
if the intersection algorithms work effectively with pointers
to boxes, but not in the case where the algorithms work with
box values, because the algorithms modify the order of the
boxes, and the `box_self_intersection_d()` algorithm
creates copies of the boxes that would not have identical
`id`-numbers.
-
-
+
\cgalModels `BoxIntersectionBox_d`
diff --git a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_traits_d.h b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_traits_d.h
index 54f79ee07fe..706b82ee620 100644
--- a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_traits_d.h
+++ b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_traits_d.h
@@ -16,11 +16,9 @@ the `Box_parameter` type required in the
`Box_parameter` to be of type `const B&`, while for the other
cases it just uses the pointer type.
-
-- `BoxHandle`: either a class type `B`, a pointer `B*`, or a
-const-pointer `const B*`, where `B` is a model of the
-`BoxIntersectionBox_d` concept.
-
+\tparam BoxHandle is either a class type `B`, a pointer `B*`, or a
+ const-pointer `const B*`, where `B` is a model of the
+ `BoxIntersectionBox_d` concept.
\cgalModels `BoxIntersectionTraits_d`
diff --git a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_with_handle_d.h b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_with_handle_d.h
index 45a3a33e83d..5a851bbe395 100644
--- a/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_with_handle_d.h
+++ b/Box_intersection_d/doc/Box_intersection_d/CGAL/Box_intersection_d/Box_with_handle_d.h
@@ -19,9 +19,9 @@ of the `Assignable` and the `LessThanComparable` concept.
\tparam D the dimension of the box.
\tparam Handle Handle concept, e.g., a pointer, an iterator, or a circulator.
\tparam IdPolicy specifies how the `id`-number will be
-provided. Can be one of the following types, where
+provided and can be one of the following types, where
`ID_FROM_HANDLE` is the default for this parameter:
- - `ID_NONE`: no `id`-number is provided. Can be useful
+ - `ID_NONE`: no `id`-number is provided. This can be useful
to have this class as a base class for different
implementations of `id`-numbers than the ones provided
here.
@@ -33,7 +33,7 @@ provided. Can be one of the following types, where
`CGAL::box_self_intersection_d()` algorithm. This is therefore
the safe default implementation.
- `ID_FROM_BOX_ADDRESS`: casts the address of the box into a
- `std::ptrdiff_t` to create the `id`-number. Works fine
+ `std::ptrdiff_t` to create the `id`-number. This works fine
if the intersection algorithms work effectively with pointers
to boxes, but not in the case where the algorithms work with
box values, because the algorithms modify the order of the
diff --git a/Box_intersection_d/doc/Box_intersection_d/CGAL/box_intersection_d.h b/Box_intersection_d/doc/Box_intersection_d/CGAL/box_intersection_d.h
index 86441b44f23..89b6facc3cc 100644
--- a/Box_intersection_d/doc/Box_intersection_d/CGAL/box_intersection_d.h
+++ b/Box_intersection_d/doc/Box_intersection_d/CGAL/box_intersection_d.h
@@ -46,8 +46,26 @@ namespace CGAL {
An important special application of this algorithm is the test for
self-intersections where the second box sequence is an identical copy
of the first sequence including the preserved `id`-number. We
- offer a specialized implementation
- `box_self_intersection_all_pairs` for this application.
+ offer a specialized implementation `box_self_intersection_all_pairs_d()`
+ for this application.
+
+\cgalHeading{Requirements}
+
+
+ - `ForwardIterator1`, and \f$ \ldots\f$ `2`, must meet
+ the requirements of `ForwardIterator` and both value types must be the same.
+ We call this value type `Box_handle` in the following.
+
- `Callback` must be of the `BinaryFunction` concept.
+ The `Box_handle` must be convertible to both argument types. The
+ return type is not used and can be `void`.
+
- The `Box_handle` must be a model of the `Assignable` concept.
+
- In addition, if the default box traits is used the `Box_handle` must
+ be a class type `T` or a pointer to a class type `T`, where
+ `T` must be a model of the `BoxIntersectionBox_d` concept.
+ In both cases, the default box traits specializes to a suitable
+ implementation.
+
- `BoxTraits` must be of the `BoxIntersectionTraits_d` concept.
+
\sa \link PkgBoxIntersectionD_box_intersection_d `CGAL::box_intersection_d()` \endlink
\sa \link PkgBoxIntersectionD_box_self_intersection_d `CGAL::box_self_intersection_d()` \endlink
@@ -63,6 +81,40 @@ namespace CGAL {
size of the second sequence.
*/
+/*!
+ \ingroup PkgBoxIntersectionD_box_intersection_all_pairs_d
+
+ Invocation of box intersection with default box traits
+ `Box_intersection_d::Box_traits_d`, where
+ `Box_handle` corresponds to the iterator value type of
+ `ForwardIterator1`.
+
+*/
+template< class ForwardIterator1,
+ class ForwardIterator2,
+ class Callback >
+void box_intersection_all_pairs_d(
+ ForwardIterator1 begin1, ForwardIterator1 end1,
+ ForwardIterator2 begin2, ForwardIterator2 end2,
+ Callback callback,
+ CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
+
+/*!
+ \ingroup PkgBoxIntersectionD_box_intersection_all_pairs_d
+
+ Invocation with custom box traits.
+
+*/
+template< class ForwardIterator1,
+ class ForwardIterator2,
+ class Callback, class BoxTraits >
+void box_intersection_all_pairs_d(
+ ForwardIterator1 begin1, ForwardIterator1 end1,
+ ForwardIterator2 begin2, ForwardIterator2 end2,
+ Callback callback,
+ BoxTraits box_traits,
+ CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
+
/*!
\addtogroup PkgBoxIntersectionD_box_intersection_d
@@ -112,7 +164,7 @@ namespace CGAL {
concept and that the box handle, i.e., the iterators value type, is
identical to the box type or a pointer to the box type.
- An important special application of this algorithm is the test for
+ An important special application of this algorithm is the test for
self-intersections where the second box sequence is an identical copy
of the first sequence including the preserved `id`-number. Note
that this implies that the address of the box is not sufficient for
@@ -130,12 +182,16 @@ namespace CGAL {
values `Box_intersection_d::COMPLETE` and
`Box_intersection_d::BIPARTITE`.
+ \warning The two sequences of boxes passed to `box_intersection_d()` can be
+ ranges created from the same container, but these ranges must not contain
+ any common element.
+
\cgalHeading{Requirements}
- - `RandomAccessIterator1`, and \f$ \ldots\f$ `2`, must be
- mutable random-access iterators and both value types must be
- the same. We call this value type `Box_handle` in the following.
+
- `RandomAccessIterator1`, and \f$ \ldots\f$ `2`, must meet
+ the requirements of `RandomAccessIterator` and both value types must be the same.
+ We call this value type `Box_handle` in the following.
- `Callback` must be of the `BinaryFunction` concept.
The `Box_handle` must be convertible to both argument types. The
return type is not used and can be `void`.
@@ -208,44 +264,6 @@ namespace CGAL {
*/
-/*!
- \ingroup PkgBoxIntersectionD_box_intersection_all_pairs_d
-
- Invocation of box intersection with default box traits
- `Box_intersection_d::Box_traits_d`, where
- `Box_handle` corresponds to the iterator value type of
- `ForwardIterator1`.
-
-*/
-template< class ForwardIterator1,
- class ForwardIterator2,
- class Callback >
-void box_intersection_all_pairs_d(
- ForwardIterator1 begin1, ForwardIterator1 end1,
- ForwardIterator2 begin2, ForwardIterator2 end2,
- Callback callback,
- CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
-
-/*!
- \ingroup PkgBoxIntersectionD_box_intersection_all_pairs_d
-
- Invocation with custom box traits.
-
-*/
-template< class ForwardIterator1,
- class ForwardIterator2,
- class Callback, class BoxTraits >
-void box_intersection_all_pairs_d(
- ForwardIterator1 begin1, ForwardIterator1 end1,
- ForwardIterator2 begin2, ForwardIterator2 end2,
- Callback callback,
- BoxTraits box_traits,
- CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
-
-} /* namespace CGAL */
-
-namespace CGAL {
-
/*!
\ingroup PkgBoxIntersectionD_box_intersection_d
@@ -297,7 +315,7 @@ namespace CGAL {
inferior to the fast `box_self_intersection_d()` algorithm.
The sequence of boxes is given with a forward iterator range. The
- sequences are not modified. For each intersecting pair of boxes a
+ sequence is not modified. For each intersecting pair of boxes a
`callback` function object is called with the two intersecting
boxes as argument.
@@ -330,7 +348,7 @@ namespace CGAL {
\cgalHeading{Requirements}
- - `ForwardIterator` must be a forward iterator. We call its
+
- `ForwardIter` must meet the requirements of `ForwardIterator`. We call its
value type `Box_handle` in the following.
- `Callback` must be of the `BinaryFunction` concept.
The `Box_handle` must be convertible to both argument types. The
@@ -365,13 +383,11 @@ namespace CGAL {
Invocation of box intersection with default box traits
`Box_intersection_d::Box_traits_d`, where
`Box_handle` corresponds to the iterator value type of
- `ForwardIterator`.
-
-
+ `ForwardIter`.
*/
-template< class ForwardIterator, class Callback >
+template< class ForwardIter, class Callback >
void box_self_intersection_all_pairs_d(
- ForwardIterator begin, ForwardIterator end,
+ ForwardIter begin, ForwardIter end,
Callback callback,
CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
@@ -381,10 +397,10 @@ void box_self_intersection_all_pairs_d(
*/
-template< class ForwardIterator,
+template< class ForwardIter,
class Callback, class BoxTraits >
void box_self_intersection_all_pairs_d(
- ForwardIterator begin, ForwardIterator end,
+ ForwardIter begin, ForwardIter end,
Callback callback,
BoxTraits box_traits,
CGAL::Box_intersection_d::Topology topology = CGAL::Box_intersection_d::CLOSED);
@@ -430,16 +446,17 @@ namespace CGAL {
`Box_intersection_d::HALF_OPEN` and
`Box_intersection_d::CLOSED`.
- In addition, a box has a unique `id`-number. It is used to order
- boxes consistently in each dimension even if boxes have identical
- coordinates. In consequence, the algorithm guarantees that a pair of
- intersecting boxes is reported only once. This self-intersection
- function creates internally a second copy of the box sequence. The
- copying has to preserve the `id`-number of boxes. Note that this
- implies that the address of the box is not sufficient for the
- `id`-number if boxes are copied by value. Boxes of equal
- `id`-number are not reported as intersecting pairs since they are
- always intersecting trivially.
+ In addition, a box has a unique `id`-number. It is used to order
+ boxes consistently in each dimension even if boxes have identical
+ coordinates. In consequence, the algorithm guarantees that a pair of
+ intersecting boxes is reported only once. Boxes of equal
+ `id`-number are not reported as intersecting pairs since they are
+ always intersecting trivially.
+
+ \warning This self-intersection function creates internally a second copy
+ of the box sequence. Note that this implies that an `id`-number based on the address
+ of the box is not acceptable if boxes are copied by value and one must either
+ pass boxes by pointer or use another type of box `id`-number such as `ID_EXPLICIT`.
The algorithm uses a traits class of the `BoxIntersectionTraits_d`
concept to access the boxes. A default traits class is provided that
diff --git a/Box_intersection_d/doc/Box_intersection_d/Concepts/BoxIntersectionTraits_d.h b/Box_intersection_d/doc/Box_intersection_d/Concepts/BoxIntersectionTraits_d.h
index 0b0614bd52a..f4203aca441 100644
--- a/Box_intersection_d/doc/Box_intersection_d/Concepts/BoxIntersectionTraits_d.h
+++ b/Box_intersection_d/doc/Box_intersection_d/Concepts/BoxIntersectionTraits_d.h
@@ -8,6 +8,7 @@ functions to the dimension, the `id`-number, and the boundaries of
the boxes manipulated in these algorithms.
\cgalRefines `Assignable`
+\cgalRefines `DefaultConstructible`
\cgalHasModel CGAL::Box_intersection_d::Box_traits_d
diff --git a/Box_intersection_d/include/CGAL/box_intersection_d.h b/Box_intersection_d/include/CGAL/box_intersection_d.h
index 4058085cd96..f20b7d9474e 100644
--- a/Box_intersection_d/include/CGAL/box_intersection_d.h
+++ b/Box_intersection_d/include/CGAL/box_intersection_d.h
@@ -181,13 +181,17 @@ template< class RandomAccessIter, class Callback, class BoxTraits >
void box_self_intersection_d(
RandomAccessIter begin, RandomAccessIter end,
Callback callback,
- BoxTraits box_traits)
+ BoxTraits box_traits,
+ std::ptrdiff_t cutoff,
+ Box_intersection_d::Topology topology)
{
+ // Copying rather than calling 'box_intersection_d(begin, end, begin, end, ...'
+ // is necessary because the 'std::partition' and range splits on the first range
+ // would be messed up by sorts on the second range otherwise.
typedef typename std::iterator_traits::value_type val_t;
std::vector< val_t> i( begin, end);
box_intersection_d( begin, end, i.begin(), i.end(),
- callback, box_traits, 10,
- Box_intersection_d::CLOSED,
+ callback, box_traits, cutoff, topology,
Box_intersection_d::COMPLETE);
}
@@ -198,26 +202,17 @@ void box_self_intersection_d(
BoxTraits box_traits,
std::ptrdiff_t cutoff)
{
- typedef typename std::iterator_traits::value_type val_t;
- std::vector< val_t> i( begin, end);
- box_intersection_d( begin, end, i.begin(), i.end(),
- callback, box_traits, cutoff,
- Box_intersection_d::CLOSED,
- Box_intersection_d::COMPLETE);
+ return box_self_intersection_d(begin, end, callback, box_traits, cutoff,
+ Box_intersection_d::CLOSED);
}
template< class RandomAccessIter, class Callback, class BoxTraits >
void box_self_intersection_d(
RandomAccessIter begin, RandomAccessIter end,
Callback callback,
- BoxTraits box_traits,
- std::ptrdiff_t cutoff,
- Box_intersection_d::Topology topology)
+ BoxTraits box_traits)
{
- typedef typename std::iterator_traits::value_type val_t;
- std::vector< val_t> i( begin, end);
- box_intersection_d( begin, end, i.begin(), i.end(),
- callback, box_traits, cutoff, topology, Box_intersection_d::COMPLETE);
+ return box_self_intersection_d(begin, end, callback, box_traits, 10);
}
// Specialized call with default box traits, specialized for self-intersection.
@@ -229,20 +224,18 @@ void box_self_intersection_d(
{
typedef typename std::iterator_traits::value_type val_t;
typedef Box_intersection_d::Box_traits_d< val_t> Box_traits;
- box_self_intersection_d(begin, end, callback,
- Box_traits(), 10, Box_intersection_d::CLOSED);
+ box_self_intersection_d(begin, end, callback, Box_traits());
}
template< class RandomAccessIter, class Callback >
void box_self_intersection_d(
RandomAccessIter begin, RandomAccessIter end,
Callback callback,
- std::ptrdiff_t)
+ std::ptrdiff_t cutoff)
{
typedef typename std::iterator_traits::value_type val_t;
typedef Box_intersection_d::Box_traits_d< val_t> Box_traits;
- box_self_intersection_d(begin, end, callback,
- Box_traits(), 10, Box_intersection_d::CLOSED);
+ box_self_intersection_d(begin, end, callback, Box_traits(), cutoff);
}
template< class RandomAccessIter, class Callback >
diff --git a/Box_intersection_d/test/Box_intersection_d/test_box_grid.cpp b/Box_intersection_d/test/Box_intersection_d/test_box_grid.cpp
index 1c87cf90cb0..4d51695b9bd 100644
--- a/Box_intersection_d/test/Box_intersection_d/test_box_grid.cpp
+++ b/Box_intersection_d/test/Box_intersection_d/test_box_grid.cpp
@@ -116,7 +116,7 @@ void test_box_intersection() {
std::ptrdiff_t(1),
CGAL::Box_intersection_d::HALF_OPEN,
CGAL::Box_intersection_d::COMPLETE);
- check_result( "Box self inters. 3x3+2, half-open", result, check5, 2);
+ check_result( "Box inters. 3x3+2, half-open", result, check5, 2);
// compare this with the bipartite case
// self intersect 3x3+2 query boxes, half-open boxes
diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
index 81e8ab558ea..600fe1af0d5 100644
--- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
+++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
@@ -1763,10 +1763,10 @@ namespace CartesianKernelFunctors {
// to avoid badly defined vectors with coordinates all close
// to 0 when the plane is almost horizontal, we ignore the
// smallest coordinate instead of always ignoring Z
- if (CGAL::possibly(CGAL_AND (a <= b, a <= c)))
+ if (a <= b && a <= c)
return Vector_3(FT(0), -h.c(), h.b());
- if (CGAL::possibly(CGAL_AND (b <= a, b <= c)))
+ if (b <= a && b <= c)
return Vector_3(-h.c(), FT(0), h.a());
return Vector_3(-h.b(), h.a(), FT(0));
diff --git a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h
index 50ec84d29c9..2ce7d74ba9a 100644
--- a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h
+++ b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h
@@ -273,9 +273,9 @@ point_on_planeC3(const FT &pa, const FT &pb, const FT &pc, const FT &pd,
// to avoid badly defined point with an overly large coordinate when
// the plane is almost orthogonal to one axis, we use the largest
// scalar coordinate instead of always using the first non-null
- if (CGAL::possibly(CGAL_AND (abs_pa >= abs_pb, abs_pa >= abs_pc)))
+ if (abs_pa >= abs_pb && abs_pa >= abs_pc)
x = -pd/pa;
- else if (CGAL::possibly(CGAL_AND (abs_pb >= abs_pa, abs_pb >= abs_pc)))
+ else if (abs_pb >= abs_pa && abs_pb >= abs_pc)
y = -pd/pb;
else
z = -pd/pc;
diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h
index 716f6acda16..fe5698a2232 100644
--- a/Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h
+++ b/Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h
@@ -155,12 +155,6 @@ Returns the number of vertices which are corners of the complex.
*/
size_type number_of_corners() const;
-/*!
-
-Returns the number of vertices which are corners of the complex with index `index`.
-*/
-size_type number_of_corners(Corner_index index) const;
-
/*!
Returns `true`
iff edge `e` belongs to some curve.
diff --git a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h
index 1d6dc7fb6fd..cdaba203276 100644
--- a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h
+++ b/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h
@@ -292,6 +292,10 @@ public:
{
return corners_.size();
}
+ size_type number_of_corners() const
+ {
+ return corners_.size();
+ }
void rescan_after_load_of_triangulation();
diff --git a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h
index 511f0fb1b14..9079520b94d 100644
--- a/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h
+++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h
@@ -137,6 +137,8 @@ bool is_simple_2(ForwardIterator first,
ForwardIterator last,
const PolygonTraits& traits)
{
+ if (first == last) return true;
+
return is_simple_polygon(first, last, traits);
}
diff --git a/Polygon/test/Polygon/AlgorithmTest.cpp b/Polygon/test/Polygon/AlgorithmTest.cpp
index 2f0fe8a3d02..c86d53a8236 100644
--- a/Polygon/test/Polygon/AlgorithmTest.cpp
+++ b/Polygon/test/Polygon/AlgorithmTest.cpp
@@ -161,6 +161,9 @@ void test_polygon(const R&, const Point&, const char* FileName)
cout << "the orientation is collinear" << endl;
break;
}
+
+ polygon.clear();
+ assert(CGAL::is_convex_2(polygon.begin(), polygon.end()));
}
//-----------------------------------------------------------------------//
diff --git a/Polygon/test/Polygon/SimplicityTest.cpp b/Polygon/test/Polygon/SimplicityTest.cpp
index e33a7741ef6..acbb61f69f4 100644
--- a/Polygon/test/Polygon/SimplicityTest.cpp
+++ b/Polygon/test/Polygon/SimplicityTest.cpp
@@ -63,6 +63,9 @@ void TestDegenerateCases()
polygon.push_back(Point(1,2));
assert(CGAL::is_simple_2(polygon.begin(), polygon.end()));
+
+ polygon.clear();
+ assert(CGAL::is_simple_2(polygon.begin(), polygon.end()));
}
int main()
diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h
index 48e756b3d76..f3c345a896d 100644
--- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h
+++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h
@@ -80,7 +80,7 @@ struct Intersect_coplanar_faces_3{
//constructor for intersection of edges. prev and curr are two points on an edge of the first facet (preserving the
//orientation of the facet). This edge is intersected by h2 from the second facet.
//
- //The rational is the following: we first check whether curr and prev are on the same edge. I so we create
+ //The rational is the following: we first check whether curr and prev are on the same edge. If so we create
//an intersection point between two edges. Otherwise, the point is a vertex of the second facet included into
//the first facet.
//
@@ -103,9 +103,25 @@ struct Intersect_coplanar_faces_3{
res.info_2=h2;
if (ipt_prev.type_1==ON_VERTEX && next(ipt_prev.info_1, tm1) == ipt_curr.info_1){
- CGAL_assertion(ipt_curr.type_1!=ON_FACE);
- res.type_1=ON_EDGE;
- res.info_1=ipt_curr.info_1;
+ if(ipt_curr.type_1!=ON_FACE)
+ {
+ res.type_1=ON_EDGE;
+ res.info_1=ipt_curr.info_1;
+ }
+ else
+ {
+ CGAL_assertion( ipt_curr.type_2==ON_VERTEX);
+ res.type_1=ON_FACE;
+ res.info_1=h1;
+ res.type_2=ON_VERTEX;
+ typename Exact_kernel::Collinear_3 is_collinear = Exact_kernel().collinear_3_object();
+ if ( !is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2)) ) ) ){
+ res.info_2=prev(res.info_2,tm2);
+ CGAL_assertion( is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2))) ) );
+ }
+ res.point = to_exact( get(vpm2, target(res.info_2,tm2)) );
+ return res;
+ }
}
else{
if(ipt_curr.type_1==ON_VERTEX && ipt_prev.info_1 == ipt_curr.info_1){
diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off
new file mode 100644
index 00000000000..692c64e5c3d
--- /dev/null
+++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off
@@ -0,0 +1,6 @@
+OFF
+3 1 0
+0 5310 100
+0 5400 100
+0 5310 150
+3 0 2 1
diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off
new file mode 100644
index 00000000000..21bb089ace4
--- /dev/null
+++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off
@@ -0,0 +1,6 @@
+OFF
+3 1 0
+0 5375 105
+0 5350 110
+0 5375 110
+3 1 2 0
diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd
index a173eef4b20..e7e5fb3547b 100644
--- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd
+++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd
@@ -64,6 +64,7 @@ data-coref/coplanar_triangles/all_cases/deg/tr15-1.off data-coref/coplanar_trian
data-coref/coplanar_triangles/all_cases/deg/tr16-1.off data-coref/coplanar_triangles/all_cases/deg/tr16-2.off
data-coref/coplanar_triangles/all_cases/deg/tr17-1.off data-coref/coplanar_triangles/all_cases/deg/tr17-2.off
data-coref/coplanar_triangles/all_cases/bugreport/tr1-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr1-2.off
+data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off
data-coref/coplanar_triangles/all_cases/tr1-1.off data-coref/coplanar_triangles/all_cases/tr1-2.off
data-coref/coplanar_triangles/all_cases/tr2-1.off data-coref/coplanar_triangles/all_cases/tr2-2.off
data-coref/coplanar_triangles/all_cases/tr3-1.off data-coref/coplanar_triangles/all_cases/tr3-2.off
diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp
index 6f51922d838..4aee863f3a6 100644
--- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp
+++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp
@@ -10,42 +10,48 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh Surface_mesh;
typedef CGAL::Polyhedron_3 Polyhedron_3;
+
+void test(const char* f1, const char* f2)
+{
+ std::cout << "Corefining " << f1
+ << " and " << f2 << "\n";
+
+ std::cout << " with Surface_mesh\n";
+ Surface_mesh sm1, sm2;
+ std::ifstream input(f1);
+ assert(input);
+ input >> sm1;
+ input.close();
+ input.open(f2);
+ assert(input);
+ input >> sm2;
+ input.close();
+
+ CGAL::Polygon_mesh_processing::corefine(sm1, sm2);
+
+ assert(sm1.is_valid());
+ assert(sm2.is_valid());
+
+ std::cout << " with Polyhedron_3\n";
+ Polyhedron_3 P, Q;
+ input.open(f1);
+ assert(input);
+ input >> P;
+ input.close();
+ input.open(f2);
+ assert(input);
+ input >> Q;
+
+ CGAL::Polygon_mesh_processing::corefine(P, Q);
+
+ assert(P.is_valid());
+ assert(Q.is_valid());
+}
int main(int argc, char** argv)
{
for(int i=0; i< (argc-1)/2;++i)
{
- std::cout << "Corefining " << argv[2*i+1]
- << " and " << argv[2*(i+1)] << "\n";
-
- std::cout << " with Surface_mesh\n";
- Surface_mesh sm1, sm2;
- std::ifstream input(argv[2*i+1]);
- assert(input);
- input >> sm1;
- input.close();
- input.open(argv[2*(i+1)]);
- assert(input);
- input >> sm2;
- input.close();
-
- CGAL::Polygon_mesh_processing::corefine(sm1, sm2);
-
- assert(sm1.is_valid());
- assert(sm2.is_valid());
-
- std::cout << " with Polyhedron_3\n";
- Polyhedron_3 P, Q;
- input.open(argv[2*i+1]);
- assert(input);
- input >> P;
- input.close();
- input.open(argv[2*(i+1)]);
- assert(input);
- input >> Q;
-
- CGAL::Polygon_mesh_processing::corefine(P, Q);
-
- assert(P.is_valid());
- assert(Q.is_valid());
+ test(argv[2*i+1], argv[2*(i+1)]);
+ test(argv[2*(i+1)], argv[2*i+1]);
}
}
diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h
index d2f9b9791fa..215acb5ea58 100644
--- a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h
+++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h
@@ -389,7 +389,7 @@ public:
// Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100);
- while (dimension() < 3 || i < num_points_seq)
+ while (i < num_points_seq || (dimension() < 3 && i < num_points))
{
hint = insert(points[i], hint);
++i;
@@ -472,7 +472,7 @@ private:
// Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100);
- while (dimension() < 3 || i < num_points_seq)
+ while (i < num_points_seq || (dimension() < 3 && i < num_points))
{
hint = insert(points[indices[i]], hint);
if (hint != Vertex_handle()) hint->info() = infos[indices[i]];
diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h
index 7d153d62259..8e8e5900045 100644
--- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h
+++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h
@@ -361,7 +361,7 @@ namespace CGAL {
// Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100);
- while (dimension() < 3 || i < num_points_seq)
+ while (i < num_points_seq || (dimension() < 3 && i < num_points))
{
Locate_type lt;
Cell_handle c;
@@ -484,7 +484,7 @@ namespace CGAL {
// Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100);
- while (dimension() < 3 || i < num_points_seq)
+ while (i < num_points_seq || (dimension() < 3 && i < num_points))
{
Locate_type lt;
Cell_handle c;