diff --git a/Operations_on_polyhedra/include/CGAL/orient_polyhedron_3.h b/Operations_on_polyhedra/include/CGAL/orient_polyhedron_3.h index cab80dabc3e..541c06a2cd7 100644 --- a/Operations_on_polyhedra/include/CGAL/orient_polyhedron_3.h +++ b/Operations_on_polyhedra/include/CGAL/orient_polyhedron_3.h @@ -25,17 +25,22 @@ #include #include -namespace CGAL { -namespace internal { +namespace CGAL{ -template -struct Axis_compare { - template - bool operator()(const Vertex& v0, const Vertex& v1) const - { return v0.point()[axis] < v1.point()[axis]; } -}; +namespace internal{ + template + struct Compare_vertex_points_xyz_3{ + Less_xyz less; -} // namespace internal + typedef bool result_type; + template + bool operator()(const Vertex& v1, const Vertex& v2) const + { + return less(v1.point(), v2.point()); + } + + }; +} // end of namespace internal /** * Tests whether a closed polyhedron has a positive orientation. @@ -60,17 +65,23 @@ struct Axis_compare { * @endcode */ template -bool is_oriented(const Polyhedron& polyhedron) { - const unsigned int axis = 0; +bool is_oriented(const Polyhedron& polyhedron) +{ + typedef typename Polyhedron::Traits K; + internal::Compare_vertex_points_xyz_3< typename K::Less_xyz_3 > less_xyz; typename Polyhedron::Vertex_const_iterator v_min - = std::min_element(polyhedron.vertices_begin(), polyhedron.vertices_end(), internal::Axis_compare()); + = std::min_element(polyhedron.vertices_begin(), polyhedron.vertices_end(), less_xyz); - typedef typename Polyhedron::Traits K; const typename K::Vector_3& normal_v_min = compute_vertex_normal(*v_min); - CGAL_warning(normal_v_min[axis] != 0); - return normal_v_min[axis] < 0; + return normal_v_min[0] < 0 || ( + normal_v_min[0] == 0 && ( + normal_v_min[1] < 0 || + ( normal_v_min[1]==0 && normal_v_min[2] < 0 ) + ) + ); } + } // namespace CGAL #endif // CGAL_ORIENT_POLYHEDRON_3