diff --git a/Installation/changes.html b/Installation/changes.html
index 0e2496ccc2e..e0554bdb8dd 100755
--- a/Installation/changes.html
+++ b/Installation/changes.html
@@ -143,6 +143,11 @@ David A. Wheeler's 'SLOCCount', restricted to the include/CGAL/
faster version.
+
3D Boolean Operations on Nef Polyhedra
+
+ - Bug-fix in IO when using
Lazy_exact_nt as number type or Exact_predicates_exact_constructions_kernel as kernel.
+
+
Release 4.2
diff --git a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h
index d1a0659e55a..b15d1d8e985 100644
--- a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h
+++ b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h
@@ -34,6 +34,9 @@
#include
#include
#include
+#include
+#include
+
#undef CGAL_NEF_DEBUG
#define CGAL_NEF_DEBUG 293
@@ -43,8 +46,81 @@
#include
#endif
+#include
+
namespace CGAL {
+template class Lazy_exact_nt;
+class Homogeneous_tag;
+class Cartesian_tag;
+template struct Simple_cartesian;
+template struct Simple_homogeneous;
+template class Quotient;
+
+namespace Nef_3_internal{
+
+BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_nested_Exact_kernel,Exact_kernel,false)
+
+template ::value, class FT = typename R::RT, class Kernel_tag=typename R::Kernel_tag>
+struct Type_converter{
+ typedef const CGAL::Point_3& Point_3;
+ typedef const CGAL::Vector_3& Vector_3;
+ typedef const CGAL::Plane_3& Plane_3;
+
+ static Point_3 convert(Point_3 p){return p;}
+ static Plane_3 convert(Plane_3 p){return p;}
+ static Vector_3 convert(Vector_3 v){return v;}
+};
+
+template
+struct Type_converter{
+ typedef CGAL::Point_3 Point_3;
+ typedef CGAL::Plane_3 Plane_3;
+ typedef CGAL::Vector_3 Vector_3;
+
+ static Point_3 convert(const CGAL::Point_3& p){return p.exact();}
+ static Plane_3 convert(const CGAL::Plane_3& p){return p.exact();}
+ static Vector_3 convert(const CGAL::Vector_3& v){return v.exact();}
+};
+
+template
+struct Type_converter, ::CGAL::Cartesian_tag >{
+ typedef CGAL::Simple_cartesian< NT > EK;
+ typedef CGAL::Cartesian_converter Converter;
+ typedef CGAL::Point_3 Point_3;
+ typedef CGAL::Plane_3 Plane_3;
+ typedef CGAL::Vector_3 Vector_3;
+
+ static Point_3 convert(const CGAL::Point_3& p){return Converter()(p);}
+ static Plane_3 convert(const CGAL::Plane_3& p){return Converter()(p);}
+ static Vector_3 convert(const CGAL::Vector_3& v){return Converter()(v);}
+};
+
+template
+struct Type_converter, ::CGAL::Homogeneous_tag>{
+ typedef CGAL::Simple_homogeneous< NT, CGAL::Quotient > EK;
+ typedef CGAL::Homogeneous_converter Converter;
+ typedef CGAL::Point_3 Point_3;
+ typedef CGAL::Plane_3 Plane_3;
+ typedef CGAL::Vector_3 Vector_3;
+
+ static Point_3 convert(const CGAL::Point_3& p){return Converter()(p);}
+ static Plane_3 convert(const CGAL::Plane_3& p){return Converter()(p);}
+ static Vector_3 convert(const CGAL::Vector_3& v){return Converter()(v);}
+};
+
+
+template
+typename Type_converter::Point_3 get_point(const CGAL::Point_3& p){ return Type_converter::convert(p); }
+
+template
+typename Type_converter::Plane_3 get_plane(const CGAL::Plane_3& p){ return Type_converter::convert(p); }
+
+template
+typename Type_converter::Vector_3 get_vector(const CGAL::Vector_3& v){ return Type_converter::convert(v); }
+
+} //end of Nef_3_internal
+
template
class moreLeft : public T {
@@ -593,82 +669,9 @@ struct find_minimal_sface_of_shell : public SNC_decorator {
SFace_handle& minimal_sface() { return sf_min; }
};
-class Homogeneous_tag;
-class Cartesian_tag;
+
template class Geometry_io;
-template
-class Geometry_io > > {
- public:
- template static
- typename EK::Point_3
- read_point(std::istream& in) {
- typedef Fraction_traits FracTraits;
- typename FracTraits::Type hx, hy, hz, hw;
- typename FracTraits::Numerator_type num;
- typename FracTraits::Denominator_type denom(1);
- typename FracTraits::Compose composer;
- in >> num;
- hx = composer(num, denom);
- in >> num;
- hy = composer(num, denom);
- in >> num;
- hz = composer(num, denom);
- in >> num;
- hw = composer(num, denom);
- return typename EK::Point_3(hx,hy,hz,hw);
- }
-
- template static
- typename EK::Plane_3 read_plane(std::istream& in) {
- typedef Fraction_traits FracTraits;
- typename FracTraits::Type a, b, c, d;
- typename FracTraits::Numerator_type num;
- typename FracTraits::Denominator_type denom(1);
- typename FracTraits::Compose composer;
- in >> num;
- a = composer(num, denom);
- in >> num;
- b = composer(num, denom);
- in >> num;
- c = composer(num, denom);
- in >> num;
- d = composer(num, denom);
- return typename EK::Plane_3(a,b,c,d);
- }
-
- template static
- void print_point(std::ostream& out, const CGAL::Point_3 p) {
- typedef typename CGAL::Simple_cartesian SC;
- typedef typename SC::Point_3 Exact_point;
- typedef Geometry_io Gio;
-
- Exact_point ep(p.x().exact(), p.y().exact(), p.z().exact());
- Gio::print_point(out, ep);
- }
-
- template static
- void print_vector(std::ostream& out, const CGAL::Vector_3 vec) {
- typedef typename CGAL::Simple_cartesian SC;
- typedef typename SC::Vector_3 Exact_vector;
- typedef Geometry_io Gio;
-
- Exact_vector ev(vec.x().exact(), vec.y().exact(), vec.z().exact());
- Gio::print_vector(out, ev);
- }
-
- template static
- void print_plane(std::ostream& out, const CGAL::Plane_3 p) {
- typedef typename CGAL::Simple_cartesian SC;
- typedef typename SC::Plane_3 Exact_plane;
- typedef Geometry_io Gio;
-
- Exact_plane ep(p.a().exact(), p.b().exact(),
- p.c().exact(), p.d().exact());
- Gio::print_plane(out, ep);
- }
-};
-
template
class Geometry_io {
public:
@@ -709,7 +712,7 @@ class Geometry_io {
}
template static
- void print_point(std::ostream& out, const CGAL::Point_3 p) {
+ void print_point_impl(std::ostream& out, const CGAL::Point_3 p) {
typedef Fraction_traits FracTraits;
typedef std::vector NV;
@@ -740,7 +743,7 @@ class Geometry_io {
}
template static
- void print_vector(std::ostream& out, const CGAL::Vector_3 p) {
+ void print_vector_impl(std::ostream& out, const CGAL::Vector_3 p) {
typedef Fraction_traits FracTraits;
typedef typename FracTraits::Numerator_type NumType;
typedef std::vector NV;
@@ -769,7 +772,7 @@ class Geometry_io {
}
template static
- void print_plane(std::ostream& out, const CGAL::Plane_3 p) {
+ void print_plane_impl(std::ostream& out, const CGAL::Plane_3 p) {
typedef Fraction_traits FracTraits;
typedef std::vector NV;
@@ -804,6 +807,22 @@ class Geometry_io {
out << vec[0] << " " << vec[1] << " "
<< vec[2] << " " << vec[3];
}
+
+ template static
+ void print_point(std::ostream& out, const CGAL::Point_3& p) {
+ print_point_impl(out, Nef_3_internal::get_point(p) );
+ }
+
+ template static
+ void print_vector(std::ostream& out, const CGAL::Vector_3& v) {
+ print_vector_impl(out, Nef_3_internal::get_vector(v) );
+ }
+
+ template static
+ void print_plane(std::ostream& out, const CGAL::Plane_3& p) {
+ print_plane_impl(out, Nef_3_internal::get_plane(p) );
+ }
+
};
template
@@ -824,19 +843,34 @@ class Geometry_io {
}
template static
- void print_point(std::ostream& out, const CGAL::Point_3& p) {
+ void print_point_impl(std::ostream& out, const CGAL::Point_3& p) {
out << p;
}
template static
- void print_vector(std::ostream& out, const CGAL::Vector_3& vec) {
+ void print_vector_impl(std::ostream& out, const CGAL::Vector_3& vec) {
out << vec;
}
template static
- void print_plane(std::ostream& out, const CGAL::Plane_3& p) {
+ void print_plane_impl(std::ostream& out, const CGAL::Plane_3& p) {
out << p;
- }
+ }
+
+ template static
+ void print_point(std::ostream& out, const CGAL::Point_3& p) {
+ print_point_impl(out, Nef_3_internal::get_point(p) );
+ }
+
+ template static
+ void print_vector(std::ostream& out, const CGAL::Vector_3& v) {
+ print_vector_impl(out, Nef_3_internal::get_vector(v) );
+ }
+
+ template static
+ void print_plane(std::ostream& out, const CGAL::Plane_3& p) {
+ print_plane_impl(out, Nef_3_internal::get_plane(p) );
+ }
};
template
diff --git a/Nef_3/test/Nef_3/test_nef_3_io.cpp b/Nef_3/test/Nef_3/test_nef_3_io.cpp
new file mode 100644
index 00000000000..542e15296cd
--- /dev/null
+++ b/Nef_3/test/Nef_3/test_nef_3_io.cpp
@@ -0,0 +1,86 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+
+typedef CGAL::Exact_predicates_exact_constructions_kernel EPEC;
+typedef CGAL::internal::Exact_type_selector::Type FT;
+typedef CGAL::Fraction_traits::Numerator_type RT;
+typedef CGAL::Lazy_exact_nt < FT > Lazy_FT;
+typedef CGAL::Lazy_exact_nt < RT > Lazy_RT;
+typedef CGAL::Cartesian< FT > C_FT;
+typedef CGAL::Simple_cartesian< FT > SC_FT;
+typedef CGAL::Homogeneous< RT > H_RT;
+typedef CGAL::Simple_homogeneous< RT > SH_RT;
+typedef CGAL::Cartesian< Lazy_FT > C_Lazy_FT;
+typedef CGAL::Simple_cartesian< Lazy_FT > SC_Lazy_FT;
+typedef CGAL::Homogeneous< Lazy_RT > H_Lazy_RT;
+typedef CGAL::Simple_homogeneous< Lazy_RT > SH_Lazy_RT;
+
+
+template
+void test_write_read()
+{
+ typedef CGAL::Nef_polyhedron_3< Kernel > Nef_polyhedron;
+ typedef CGAL::Polyhedron_3< Kernel > Polyhedron;
+ typedef typename Kernel::Point_3 Point;
+
+ typename Kernel::RT n( std::string("6369051672525773"));
+ typename Kernel::RT d( std::string("4503599627370496"));
+
+ Point p(n, 0, 0, d);
+ Point q(0, n, 0, d);
+ Point r(0, 0, n, d);
+ Point s(0, 0, 0, 1);
+
+ std::cout << " build...\n";
+ Polyhedron P;
+ P.make_tetrahedron( p, q, r, s);
+ Nef_polyhedron nef_1( P );
+
+ std::cout << " write...\n";
+ std::ofstream out ("temp.nef");
+ out << nef_1;
+ out.close();
+
+ std::cout << " read...\n";
+ std::ifstream in ("temp.nef");
+ Nef_polyhedron nef_2;
+ in >> nef_2;
+ in.close();
+
+ std::cout << " check...\n";
+ assert( nef_1 == nef_2);
+}
+
+int main()
+{
+ std::cout << "Testing Exact_predicates_exact_constructions_kernel\n";
+ test_write_read();
+ std::cout << "Testing Cartesian< FT >\n";
+ test_write_read();
+ std::cout << "Testing Simple_cartesian< FT >\n";
+ test_write_read();
+ std::cout << "Testing Homogeneous< RT >\n";
+ test_write_read();
+ std::cout << "Testing Simple_homogeneous< RT >\n";
+ test_write_read();
+ std::cout << "Testing Cartesian< Lazy_exact_nt >\n";
+ test_write_read();
+ std::cout << "Testing Simple_cartesian< Lazy_exact_nt >\n";
+ test_write_read();
+ std::cout << "Testing Homogeneous< Lazy_exact_nt