use specialized classes with parameterized with

kernel tags
This commit is contained in:
Peter Hachenberger 2006-03-12 22:20:20 +00:00
parent ef4adb44da
commit 312b04bebb
1 changed files with 42 additions and 37 deletions

View File

@ -37,48 +37,50 @@
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
template <class Kernel> class Homogeneous_tag;
typename Kernel::Point_3 class Cartesian_tag;
number_type_converter_nef_3 (const CGAL::Cartesian<double>::Point_3 &d) template<typename Tag, typename Kernel> class number_type_converter_nef_3;
{
typedef typename Kernel::Point_3 Point_3;
typedef typename Kernel::RT RT;
CGAL::Gmpq x(d.x()), y(d.y()), z(d.z()); template<class Kernel>
class number_type_converter_nef_3<Homogeneous_tag, Kernel> {
public:
static typename Kernel::Point_3
convert (const CGAL::Cartesian<double>::Point_3 &d)
{
typedef typename Kernel::Point_3 Point_3;
typedef typename Kernel::RT RT;
CGAL::Homogeneous<CGAL::Gmpz>::Point_3 b = CGAL::Gmpq x(d.x()), y(d.y()), z(d.z());
normalized ( CGAL::Homogeneous<CGAL::Gmpz>::Point_3 (
x.numerator() * y.denominator() * z.denominator(), CGAL::Homogeneous<CGAL::Gmpz>::Point_3 b =
normalized ( CGAL::Homogeneous<CGAL::Gmpz>::Point_3 (
x.numerator() * y.denominator() * z.denominator(),
x.denominator() * y.numerator() * z.denominator(), x.denominator() * y.numerator() * z.denominator(),
x.denominator() * y.denominator() * z.numerator(), x.denominator() * y.denominator() * z.numerator(),
x.denominator() * y.denominator() * z.denominator() ) ); x.denominator() * y.denominator() * z.denominator() ) );
std::ostringstream outx, outy, outz, outw; std::ostringstream outx, outy, outz, outw;
outx << b.hx(); outx << b.hx();
outy << b.hy(); outy << b.hy();
outz << b.hz(); outz << b.hz();
outw << b.hw(); outw << b.hw();
RT rx (outx.str().c_str()); RT rx (outx.str().c_str());
RT ry (outy.str().c_str()); RT ry (outy.str().c_str());
RT rz (outz.str().c_str()); RT rz (outz.str().c_str());
RT rw (outw.str().c_str()); RT rw (outw.str().c_str());
return Point_3 (rx, ry, rz, rw); return Point_3 (rx, ry, rz, rw);
} }
};
template <> template<class Kernel>
CGAL::Cartesian<CGAL::Gmpq>::Point_3 class number_type_converter_nef_3<Cartesian_tag, Kernel> {
number_type_converter_nef_3<CGAL::Cartesian<CGAL::Gmpq> > (const CGAL::Cartesian<double>::Point_3 &d) public:
{ return CGAL::Cartesian<CGAL::Gmpq>::Point_3 (d.x(), d.y(), d.z()); static typename Kernel::Point_3
} convert (const CGAL::Cartesian<double>::Point_3 &d)
{ return typename Kernel::Point_3(d.x(), d.y(), d.z());
#ifdef CGAL_USE_LEDA }
template <> };
CGAL::Cartesian<leda_rational>::Point_3
number_type_converter_nef_3<CGAL::Cartesian<leda_rational> > (const CGAL::Cartesian<double>::Point_3 &d)
{ return CGAL::Cartesian<leda_rational>::Point_3 (d.x(), d.y(), d.z());
}
#endif // CGAL_USE_LEDA
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // NUMBER_TYPE_CONVERTER_NEF_3_H #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::Facet_iterator Scan_facet_it;
typedef Scan_OFF::Index_iterator Scan_index_it; typedef Scan_OFF::Index_iterator Scan_index_it;
typedef typename Kernel::Kernel_tag Kernel_tag;
typedef typename CGAL::number_type_converter_nef_3<Kernel_tag,Kernel> ntc;
// declarations and defaults // declarations and defaults
std::size_t discarded_facets=0; std::size_t discarded_facets=0;
long idx; 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(); Scan_vertex_it v_it = scan.vertices_begin();
for (idx=0; v_it != scan.vertices_end(); ++v_it, ++idx) for (idx=0; v_it != scan.vertices_end(); ++v_it, ++idx)
{ V_scan.push_back (*v_it); { V_scan.push_back (*v_it);
V.push_back (CGAL::number_type_converter_nef_3<Kernel>(*v_it)); V.push_back (ntc::convert(*v_it));
} }
CGAL_warning ( idx==NOV ); CGAL_warning ( idx==NOV );
NOV = idx; NOV = idx;