From 312b04bebb37a2f7d828bf42572bb3de10d8f403 Mon Sep 17 00:00:00 2001 From: Peter Hachenberger Date: Sun, 12 Mar 2006 22:20:20 +0000 Subject: [PATCH] use specialized classes with parameterized with kernel tags --- Nef_3/include/CGAL/OFF_to_nef_3.h | 79 ++++++++++++++++--------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/Nef_3/include/CGAL/OFF_to_nef_3.h b/Nef_3/include/CGAL/OFF_to_nef_3.h index afa32b7eb3d..adfd46e9588 100644 --- a/Nef_3/include/CGAL/OFF_to_nef_3.h +++ b/Nef_3/include/CGAL/OFF_to_nef_3.h @@ -37,48 +37,50 @@ CGAL_BEGIN_NAMESPACE -template -typename Kernel::Point_3 -number_type_converter_nef_3 (const CGAL::Cartesian::Point_3 &d) -{ - typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::RT RT; +class Homogeneous_tag; +class Cartesian_tag; +template class number_type_converter_nef_3; - CGAL::Gmpq x(d.x()), y(d.y()), z(d.z()); - - CGAL::Homogeneous::Point_3 b = - normalized ( CGAL::Homogeneous::Point_3 ( - x.numerator() * y.denominator() * z.denominator(), +template +class number_type_converter_nef_3 { + public: + static typename Kernel::Point_3 + convert (const CGAL::Cartesian::Point_3 &d) + { + typedef typename Kernel::Point_3 Point_3; + typedef typename Kernel::RT RT; + + CGAL::Gmpq x(d.x()), y(d.y()), z(d.z()); + + CGAL::Homogeneous::Point_3 b = + normalized ( CGAL::Homogeneous::Point_3 ( + x.numerator() * y.denominator() * z.denominator(), x.denominator() * y.numerator() * z.denominator(), x.denominator() * y.denominator() * z.numerator(), x.denominator() * y.denominator() * z.denominator() ) ); - std::ostringstream outx, outy, outz, outw; - outx << b.hx(); - outy << b.hy(); - outz << b.hz(); - outw << b.hw(); - RT rx (outx.str().c_str()); - RT ry (outy.str().c_str()); - RT rz (outz.str().c_str()); - RT rw (outw.str().c_str()); + std::ostringstream outx, outy, outz, outw; + outx << b.hx(); + outy << b.hy(); + outz << b.hz(); + outw << b.hw(); + RT rx (outx.str().c_str()); + RT ry (outy.str().c_str()); + RT rz (outz.str().c_str()); + RT rw (outw.str().c_str()); + + return Point_3 (rx, ry, rz, rw); + } +}; - return Point_3 (rx, ry, rz, rw); -} - -template <> -CGAL::Cartesian::Point_3 -number_type_converter_nef_3 > (const CGAL::Cartesian::Point_3 &d) -{ return CGAL::Cartesian::Point_3 (d.x(), d.y(), d.z()); -} - -#ifdef CGAL_USE_LEDA -template <> -CGAL::Cartesian::Point_3 -number_type_converter_nef_3 > (const CGAL::Cartesian::Point_3 &d) -{ return CGAL::Cartesian::Point_3 (d.x(), d.y(), d.z()); -} -#endif // CGAL_USE_LEDA +template +class number_type_converter_nef_3 { + public: + static typename Kernel::Point_3 + convert (const CGAL::Cartesian::Point_3 &d) + { return typename Kernel::Point_3(d.x(), d.y(), d.z()); + } +}; CGAL_END_NAMESPACE #endif // NUMBER_TYPE_CONVERTER_NEF_3_H @@ -123,6 +125,9 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) typedef Scan_OFF::Facet_iterator Scan_facet_it; typedef Scan_OFF::Index_iterator Scan_index_it; + typedef typename Kernel::Kernel_tag Kernel_tag; + typedef typename CGAL::number_type_converter_nef_3 ntc; + // declarations and defaults std::size_t discarded_facets=0; long idx; @@ -150,7 +155,7 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) Scan_vertex_it v_it = scan.vertices_begin(); for (idx=0; v_it != scan.vertices_end(); ++v_it, ++idx) { V_scan.push_back (*v_it); - V.push_back (CGAL::number_type_converter_nef_3(*v_it)); + V.push_back (ntc::convert(*v_it)); } CGAL_warning ( idx==NOV ); NOV = idx;