diff --git a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h index af5e70f0558..ea8331eab48 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h @@ -48,8 +48,23 @@ Angle angle(const CGAL::Point_3& p, const CGAL::Point_3& q, const CGAL::Point_3& r); + +/*! +returns an approximation of the signed dihedral angle in the tetrahedron `pqrs` of edge `pq`. + The sign is negative if `orientation(p,q,r,s)` is `CGAL::NEGATIVE` and positive otherwise. + The angle is given in degree. + \pre `p,q,r` and `p,q,s` are not collinear. +*/ +template +Kernel::FT approximate_dihedral_angle(const CGAL::Point_3& p, + const CGAL::Point_3& q, + const CGAL::Point_3& r, + const CGAL::Point_3& s); + /// @} + + /// \defgroup area_grp CGAL::area() /// \ingroup kernel_global_function /// @{ @@ -1690,14 +1705,6 @@ const CGAL::Vector_3& v, const CGAL::Vector_3& w); /// @} -/*! -returns the dihedral angle of .... between `-180` and `180` degree. -*/ -template -Kernel::FT dihedral_angle(const CGAL::Point_3& p, - const CGAL::Point_3& q, - const CGAL::Point_3& r, - const CGAL::Point_3& s); // This is there to keep the global functions in alphabetical order diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h index 6db79272c1b..337f0e05778 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -1626,6 +1626,37 @@ public: }; /* end Kernel::ComputeApproximateArea_3 */ + +/*! + \ingroup PkgKernel23ConceptsFunctionObjects + \cgalConcept + + \cgalRefines `AdaptableFunctor` + +*/ +class ComputeApproximateDihedralAngle_3 { +public: + + /// \name Operations + /// A model of this concept must provide: + /// @{ + + /*! + returns an approximation of the signed dihedral angle in the tetrahedron `pqrs` of edge `pq`. + The sign is negative if `orientation(p,q,r,s)` is `CGAL::NEGATIVE` and positive otherwise. + The angle is given in degree. + \pre `p,q,r` and `p,q,s` are not collinear. + */ + Kernel::FT operator()(const Kernel::Point_3& p, + const Kernel::Point_3& q, + const Kernel::Point_3& r, + const Kernel::Point_3& s) const; + + /// @} + +}; /* end Kernel::ComputeApproximateDihedralAngle_3 */ + + /*! \ingroup PkgKernel23ConceptsFunctionObjects \cgalConcept @@ -1925,6 +1956,8 @@ public: }; /* end Kernel::ComputeDeterminant_3 */ + + /*! \ingroup PkgKernel23ConceptsFunctionObjects \cgalConcept diff --git a/Kernel_23/doc/Kernel_23/Concepts/Kernel.h b/Kernel_23/doc/Kernel_23/Concepts/Kernel.h index f587c2c36e4..79bff45f0a2 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/Kernel.h +++ b/Kernel_23/doc/Kernel_23/Concepts/Kernel.h @@ -1217,6 +1217,11 @@ public: */ typedef unspecified_type Compute_approximate_area_3; + /*! + a model of `Kernel::ComputeApproximateDihedralAngle_3` + */ + typedef unspecified_type Compute_approximate_dihedral_angle_3; + /*! a model of `Kernel::ComputeDeterminant_3` */ diff --git a/Kernel_23/doc/Kernel_23/PackageDescription.txt b/Kernel_23/doc/Kernel_23/PackageDescription.txt index 3cedc3e8db1..7debf77ec1c 100644 --- a/Kernel_23/doc/Kernel_23/PackageDescription.txt +++ b/Kernel_23/doc/Kernel_23/PackageDescription.txt @@ -288,6 +288,7 @@ - `Kernel::ComputeB_2` - `Kernel::ComputeC_2` - `Kernel::ComputeApproximateArea_3` +- `Kernel::ComputeApproximateDihedralAngle_3` - `Kernel::ComputeApproximateSquaredLength_3` - `Kernel::ComputeArea_2` - `Kernel::ComputeArea_3` diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 596b51b44f5..fee859a34fa 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -344,30 +344,8 @@ namespace CommonKernelFunctors { } }; - template - class Compute_area_3 - { - typedef typename K::FT FT; - typedef typename K::Point_3 Point_3; - typedef typename K::Triangle_3 Triangle_3; - public: - typedef FT result_type; - - FT - operator()( const Triangle_3& t ) const - { - return CGAL_NTS sqrt(K().compute_squared_area_3_object()(t)); - } - - FT - operator()( const Point_3& p, const Point_3& q, const Point_3& r ) const - { - return CGAL_NTS sqrt(K().compute_squared_area_3_object()(p, q, r)); - } - }; - template - class Compute_dihedral_angle_3 + class Compute_approximate_dihedral_angle_3 { typedef typename K::Point_3 Point_3; public: @@ -401,6 +379,28 @@ namespace CommonKernelFunctors { } }; + template + class Compute_area_3 + { + typedef typename K::FT FT; + typedef typename K::Point_3 Point_3; + typedef typename K::Triangle_3 Triangle_3; + public: + typedef FT result_type; + + FT + operator()( const Triangle_3& t ) const + { + return CGAL_NTS sqrt(K().compute_squared_area_3_object()(t)); + } + + FT + operator()( const Point_3& p, const Point_3& q, const Point_3& r ) const + { + return CGAL_NTS sqrt(K().compute_squared_area_3_object()(p, q, r)); + } + }; + template class Compute_squared_distance_2 { diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_3.h index 7fde519b63f..731257a3799 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_3.h @@ -59,6 +59,17 @@ angle(const Point_3 &p, const Point_3 &q, return internal::angle(p, q, r, s, K()); } +template < class K > +inline +typename K::FT +approximate_dihedral_angle(const Point_3 &p, + const Point_3 &q, + const Point_3 &r, + const Point_3 &s) +{ + return internal::approximate_dihedral_angle(p, q, r, s, K()); +} + template < typename K > inline typename K::Boolean @@ -516,17 +527,6 @@ determinant(const Vector_3 &v0, const Vector_3 &v1, return internal::determinant(v0, v1, v2, K()); } -template < class K > -inline -typename K::FT -dihedral_angle(const Point_3 &p, - const Point_3 &q, - const Point_3 &r, - const Point_3 &s) -{ - return internal::dihedral_angle(p, q, r, s, K()); -} - template < class K > inline typename K::Line_3 diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h index 0e5b013430a..bb5eafd0b2e 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h @@ -70,6 +70,17 @@ angle(const typename K::Point_3 &p, return k.angle_3_object()(p, q, r, s); } +template < class K > +inline +typename K::FT +approximate_dihedral_angle(const typename K::Point_3 &p, + const typename K::Point_3 &q, + const typename K::Point_3 &r, + const typename K::Point_3 &s, const K& k) +{ + return k.compute_approximate_dihedral_angle_3_object()(p, q, r, s); +} + template < class K > inline typename K::Boolean @@ -591,17 +602,6 @@ determinant(const typename K::Vector_3 &v0, return k.compute_determinant_3_object()(v0, v1, v2); } -template < class K > -inline -typename K::FT -dihedral_angle(const typename K::Point_3 &p, - const typename K::Point_3 &q, - const typename K::Point_3 &r, - const typename K::Point_3 &s, const K& k) -{ - return k.compute_dihedral_angle_3_object()(p, q, r, s); -} - template < class K > inline typename K::Line_3 diff --git a/Kernel_23/include/CGAL/Kernel/interface_macros.h b/Kernel_23/include/CGAL/Kernel/interface_macros.h index 164a4ee3e82..29e98635e06 100644 --- a/Kernel_23/include/CGAL/Kernel/interface_macros.h +++ b/Kernel_23/include/CGAL/Kernel/interface_macros.h @@ -162,6 +162,8 @@ CGAL_Kernel_cons(Compute_c_3, compute_c_3_object) CGAL_Kernel_cons(Compute_d_3, compute_d_3_object) +CGAL_Kernel_cons(Compute_approximate_dihedral_angle_3, + compute_approximate_dihedral_angle_3_object) CGAL_Kernel_cons(Compute_approximate_area_3, compute_approximate_area_3_object) CGAL_Kernel_cons(Compute_approximate_squared_length_3, @@ -176,8 +178,6 @@ CGAL_Kernel_cons(Compute_determinant_2, compute_determinant_2_object) CGAL_Kernel_cons(Compute_determinant_3, compute_determinant_3_object) -CGAL_Kernel_cons(Compute_dihedral_angle_3, - compute_dihedral_angle_3_object) CGAL_Kernel_cons(Compute_scalar_product_2, compute_scalar_product_2_object) CGAL_Kernel_cons(Compute_scalar_product_3, diff --git a/Mesh_3/include/CGAL/Mesh_3/dihedral_angle_3.h b/Mesh_3/include/CGAL/Mesh_3/dihedral_angle_3.h index 5ce2397f297..d5a85054a2f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/dihedral_angle_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/dihedral_angle_3.h @@ -41,7 +41,7 @@ dihedral_angle(const typename K::Point_3& a, K k = K()) { // Now in the CGAL kernels - return k.compute_dihedral_angle_3_object()(a, b, c, d); + return k.compute_approximate_dihedral_angle_3_object()(a, b, c, d); } diff --git a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h index e9f1df8ce16..214de1b899b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h +++ b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h @@ -979,10 +979,10 @@ private: const int k3, const Cell_handle& cell) const { - return CGAL::abs(dihedral_angle(p, - cell->vertex(k1)->point(), - cell->vertex(k2)->point(), - cell->vertex(k3)->point())); + return CGAL::abs(approximate_dihedral_angle(p, + cell->vertex(k1)->point(), + cell->vertex(k2)->point(), + cell->vertex(k3)->point())); } /** diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 6cd8dfb5ff9..4106f4591bf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -248,14 +248,14 @@ private: // check whether the edge is border if( (v0 + 1 == v1 || (v0 == n-1 && v1 == 0) ) && !Q.empty() ) { angle = 180 - CGAL::abs( - to_double(CGAL::dihedral_angle(P[v0],P[v1],P[v_other],Q[v0])) ); + to_double(CGAL::approximate_dihedral_angle(P[v0],P[v1],P[v_other],Q[v0])) ); } else { if(e == 2) { continue; } if(lambda.get(v0, v1) != -1){ const Point_3& p01 = P[lambda.get(v0, v1)]; angle = 180 - CGAL::abs( - to_double(CGAL::dihedral_angle(P[v0],P[v1],P[v_other],p01)) ); + to_double(CGAL::approximate_dihedral_angle(P[v0],P[v1],P[v_other],p01)) ); } } ang_max = (std::max)(ang_max, angle); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp index 9ec5715273e..e3c7b62d9b6 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp @@ -82,11 +82,11 @@ CGAL::internal::Weight_min_max_dihedral_and_area Halfedge_handle edge_it = halfedge(*begin, poly); double ang_max = 0; for(int i = 0; i < 3; ++i) { - double angle = 180 - CGAL::abs( - CGAL::dihedral_angle(ppmap[target(edge_it,poly)], - ppmap[source(edge_it,poly)], - ppmap[target(next(edge_it,poly),poly)], - ppmap[target(next(opposite(edge_it,poly),poly),poly)]) ); + double angle = 180 - + CGAL::abs(CGAL::approximate_dihedral_angle(ppmap[target(edge_it,poly)], + ppmap[source(edge_it,poly)], + ppmap[target(next(edge_it,poly),poly)], + ppmap[target(next(opposite(edge_it,poly),poly),poly)]) ); edge_it = next(edge_it,poly); ang_max = (std::max)(angle, ang_max); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp index 542ebd19931..4003415e2e4 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp @@ -85,10 +85,10 @@ CGAL::internal::Weight_min_max_dihedral_and_area double ang_max = 0; for(int i = 0; i < 3; ++i) { double angle = 180 - CGAL::abs( - CGAL::dihedral_angle(ppmap[target(edge_it,poly)], - ppmap[source(edge_it,poly)], - ppmap[target(next(edge_it,poly),poly)], - ppmap[target(next(opposite(edge_it,poly),poly),poly)]) ); + CGAL::approximate_dihedral_angle(ppmap[target(edge_it,poly)], + ppmap[source(edge_it,poly)], + ppmap[target(next(edge_it,poly),poly)], + ppmap[target(next(opposite(edge_it,poly),poly),poly)]) ); edge_it = next(edge_it,poly); ang_max = (std::max)(angle, ang_max); } diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 38ac8896279..fb0b7df0cec 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -562,32 +561,32 @@ create_histogram(const C3t3& c3t3, double& min_value, double& max_value) const Point_3& p2 = cit->vertex(2)->point(); const Point_3& p3 = cit->vertex(3)->point(); - double a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p0, p1, p2, p3))); + double a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p0, p1, p2, p3))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); - a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p0, p2, p1, p3))); + a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p0, p2, p1, p3))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); - a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p0, p3, p1, p2))); + a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p0, p3, p1, p2))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); - a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p1, p2, p0, p3))); + a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p1, p2, p0, p3))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); - a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p1, p3, p0, p2))); + a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p1, p3, p0, p2))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); - a = CGAL::to_double(CGAL::abs(CGAL::Mesh_3::dihedral_angle(p2, p3, p0, p1))); + a = CGAL::to_double(CGAL::abs(CGAL::approximate_dihedral_angle(p2, p3, p0, p1))); histo[static_cast(std::floor(a))] += 1; min_value = (std::min)(min_value, a); max_value = (std::max)(max_value, a); diff --git a/Scale_space_reconstruction_3/include/CGAL/Scale_space_reconstruction_3/Scale_space_surface_reconstruction_3_impl.h b/Scale_space_reconstruction_3/include/CGAL/Scale_space_reconstruction_3/Scale_space_surface_reconstruction_3_impl.h index c9294946c15..2ff0eb187ef 100644 --- a/Scale_space_reconstruction_3/include/CGAL/Scale_space_reconstruction_3/Scale_space_surface_reconstruction_3_impl.h +++ b/Scale_space_reconstruction_3/include/CGAL/Scale_space_reconstruction_3/Scale_space_surface_reconstruction_3_impl.h @@ -752,10 +752,10 @@ detect_bubbles(FT border_angle) { || _shape->classify (f1) != Shape::REGULAR) continue; - double angle = CGAL::dihedral_angle (vedge.first->point (), - vedge.second->point (), - c->vertex (i)->point (), - c->vertex ((i + (j+2)%3 + 1)%4)->point ()); + double angle = CGAL::approximate_dihedral_angle (vedge.first->point (), + vedge.second->point (), + c->vertex (i)->point (), + c->vertex ((i + (j+2)%3 + 1)%4)->point ()); if (-border_angle < angle && angle < border_angle) { diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Surface_mesh_segmentation.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Surface_mesh_segmentation.h index 82f5394c6f1..25365fe3d5d 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Surface_mesh_segmentation.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Surface_mesh_segmentation.h @@ -326,7 +326,7 @@ private: // As far as I check: if, say, dihedral angle is 5, this returns 175, // if dihedral angle is -5, this returns -175. // Another words this function returns angle between planes. - double n_angle = to_double( ::CGAL::dihedral_angle(a, b, c, d) ); + double n_angle = to_double( ::CGAL::approximate_dihedral_angle(a, b, c, d) ); n_angle /= 180.0; bool concave = n_angle > 0; double angle = 1 + ((concave ? -1 : +1) * n_angle); diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp index 042458af7c0..39d8a1214db 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp @@ -1,8 +1,6 @@ #include #include - - #include #include #include @@ -13,7 +11,6 @@ #include #include #include -#include #include #include @@ -106,10 +103,10 @@ int main( int argc, char** argv ) point(target(hd,surface_mesh),surface_mesh)); } else{ - double angle = CGAL::Mesh_3::dihedral_angle(point(target(opposite(hd,surface_mesh),surface_mesh),surface_mesh), - point(target(hd,surface_mesh),surface_mesh), - point(target(next(hd,surface_mesh),surface_mesh),surface_mesh), - point(target(next(opposite(hd,surface_mesh),surface_mesh),surface_mesh),surface_mesh)); + double angle = CGAL::approximate_dihedral_angle(point(target(opposite(hd,surface_mesh),surface_mesh),surface_mesh), + point(target(hd,surface_mesh),surface_mesh), + point(target(next(hd,surface_mesh),surface_mesh),surface_mesh), + point(target(next(opposite(hd,surface_mesh),surface_mesh),surface_mesh),surface_mesh)); if ( CGAL::abs(angle)<100 ){ ++nb_sharp_edges; constraint_hmap[*eb]=true; @@ -152,10 +149,10 @@ int main( int argc, char** argv ) point(target(hd,surface_mesh),surface_mesh))); } else{ - double angle = CGAL::Mesh_3::dihedral_angle(point(target(opposite(hd,surface_mesh),surface_mesh),surface_mesh), - point(target(hd,surface_mesh),surface_mesh), - point(target(next(hd,surface_mesh),surface_mesh),surface_mesh), - point(target(next(opposite(hd,surface_mesh),surface_mesh),surface_mesh),surface_mesh)); + double angle = approximate_dihedral_angle(point(target(opposite(hd,surface_mesh),surface_mesh),surface_mesh), + point(target(hd,surface_mesh),surface_mesh), + point(target(next(hd,surface_mesh),surface_mesh),surface_mesh), + point(target(next(opposite(hd,surface_mesh),surface_mesh),surface_mesh),surface_mesh)); if ( CGAL::abs(angle)<100 ){ --nb_sharp_edges; assert(