From a8e5594e1e2c680867777cb15482f4a7cf727a94 Mon Sep 17 00:00:00 2001 From: iyaz Date: Tue, 18 Jun 2013 13:57:20 +0300 Subject: [PATCH] self_intersect: return output iterator, rename Kernel to GeomTraits, append concept for GeomTraits inside the code --- .../CGAL/Self_intersection_polyhedron_3.h | 61 ++++++++++++++++--- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/Point_inside_Polyhedron/include/CGAL/Self_intersection_polyhedron_3.h b/Point_inside_Polyhedron/include/CGAL/Self_intersection_polyhedron_3.h index 09c9fada847..560f01c6ab7 100644 --- a/Point_inside_Polyhedron/include/CGAL/Self_intersection_polyhedron_3.h +++ b/Point_inside_Polyhedron/include/CGAL/Self_intersection_polyhedron_3.h @@ -124,19 +124,57 @@ struct Throw_at_output { }// namespace internal +//////////////////////////////////////////////////////////////////////////////////// +/* +/// Geometric traits concept for the functions `self_intersect` +concept SelfIntersectionTraits{ + /// @name Geometric Types + /// @{ + /// 3D point type + typedef unspecified_type Point_3; + /// 3D triangle type + typedef unspecified_type Triangle_3; + /// 3D segment type + typedef unspecified_type Segment_3; + /// @} + + /// @name Functors + /// @{ + /// Functor constructing triangles. It provides `Triangle_3 operator() const(const Point_3&, const Point_3&, const Point_3&) + typedef unspecified_type Construct_triangle_3; + /// Functor constructing segments. It provides `Segment_3 operator() const(const Point_3&, const Point_3&) + typedef unspecified_type Construct_segment_3; + /// Functor testing intersections between triangles and segment. It provides `bool operator() const (const Triangle_3&, const Segment_3&)` and `bool operator() const (const Triangle_3&, const Triangle_3&)` + typedef unspecified_type Do_intersect_3; + /// @} + + /// @name Functions + /// @{ + Construct_triangle_3 construct_triangle_3_object() const; + Construct_segment_3 construct_segment_3_object() const; + Do_intersect_3 do_intersect_3_object() const; + /// @} +}; +*/ +//////////////////////////////////////////////////////////////////////////////////// + /** * Detects and reports self-intersections of a triangulated polyhedral surface * @pre @a p.is_pure_triangle() * - * @tparam Kernel a \cgal kernel + * @tparam GeomTraits a model of `SelfIntersectionTraits` * @tparam Polyhedron a \cgal polyhedron * @tparam OutputIterator Output iterator accepting objects of type `std::pair` * - * @param p polyhedron to be checked + * @param polyhedron polyhedron to be checked * @param out all pairs of non-adjacent facets intersecting are put in it + * + * @return out + * + * \TODO Doc: move SelfIntersectionTraits concept to appropriate location. */ -template -void self_intersect(const Polyhedron& polyhedron, OutputIterator out, const Kernel& kernel = Kernel()) +template +OutputIterator self_intersect(const Polyhedron& polyhedron, OutputIterator out, const GeomTraits& geom_traits = GeomTraits()) { CGAL_assertion(polyhedron.is_pure_triangle()); @@ -167,27 +205,30 @@ void self_intersect(const Polyhedron& polyhedron, OutputIterator out, const Kern box_ptr.push_back(&*b); // compute self-intersections filtered out by boxes - internal::Intersect_facets intersect_facets(out, kernel); + internal::Intersect_facets intersect_facets(out, geom_traits); std::ptrdiff_t cutoff = 2000; CGAL::box_self_intersection_d(box_ptr.begin(), box_ptr.end(),intersect_facets,cutoff); + return intersect_facets.m_iterator; } /** * Checks if a polyhedron is self-intersecting * @pre @a p.is_pure_triangle() * - * @tparam Kernel a %CGAL kernel + * @tparam GeomTraits a model of `SelfIntersectionTraits` * @tparam Polyhedron a %CGAL polyhedron * - * @param p polyhedron to be tested + * @param polyhedron polyhedron to be tested + * + * @return true if `polyhedron` is self-intersecting */ -template -bool self_intersect(const Polyhedron& polyhedron, const Kernel& kernel = Kernel()) +template +bool self_intersect(const Polyhedron& polyhedron, const GeomTraits& geom_traits = GeomTraits()) { try { typedef boost::function_output_iterator OutputIterator; - self_intersect(polyhedron, OutputIterator(), kernel); + self_intersect(polyhedron, OutputIterator(), geom_traits); } catch( internal::Throw_at_output::Throw_at_output_exception& ) { return true; }