diff --git a/Stream_support/include/CGAL/IO/GOCAD.h b/Stream_support/include/CGAL/IO/GOCAD.h index f0bab7148bb..5fe66515fe0 100644 --- a/Stream_support/include/CGAL/IO/GOCAD.h +++ b/Stream_support/include/CGAL/IO/GOCAD.h @@ -332,9 +332,9 @@ bool write_GOCAD(std::ostream& os, * * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} - * \cgalParamDescription{a property map associating points with floating point coordinates to the elements of the point set `points`} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type - * of the iterator of `PointRange` and value type is a point type with floating point coordinates} + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} * \cgalParamDefault{`CGAL::Identity_property_map::value_type>`} * \cgalParamNEnd * \cgalParamNBegin{stream_precision} @@ -379,6 +379,12 @@ bool write_GOCAD(std::ostream& os, * \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin + * \cgalParamNBegin{point_map} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} + * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} + * \cgalParamDefault{`CGAL::Identity_property_map::value_type>`} + * \cgalParamNEnd * \cgalParamNBegin{stream_precision} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamType{int} diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 924e2353172..74b46a457ae 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -315,9 +315,9 @@ bool read_OBJ(const std::string& fname, * * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} - * \cgalParamDescription{a property map associating points with floating point coordinates to the elements of the point set `points`} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type - * of the iterator of `PointRange` and value type is a point type with floating point coordinates} + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} * \cgalParamDefault{`CGAL::Identity_property_map::value_type>`} * \cgalParamNEnd * \cgalParamNBegin{stream_precision} @@ -364,6 +364,12 @@ bool write_OBJ(std::ostream& os, * \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin + * \cgalParamNBegin{point_map} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} + * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} + * \cgalParamDefault{`CGAL::Identity_property_map::value_type>`} + * \cgalParamNEnd * \cgalParamNBegin{stream_precision} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamType{int} diff --git a/Stream_support/include/CGAL/IO/OFF.h b/Stream_support/include/CGAL/IO/OFF.h index e12e2494720..a7fc601ea49 100644 --- a/Stream_support/include/CGAL/IO/OFF.h +++ b/Stream_support/include/CGAL/IO/OFF.h @@ -268,9 +268,9 @@ bool read_OFF(const std::string& fname, * * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} - * \cgalParamDescription{a property map associating points with floating point coordinates to the elements of the point set `points`} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type - * of the iterator of `PointRange` and value type is a point type with floating point coordinates} + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} * \cgalParamDefault{`CGAL::Identity_property_map::value_type>`} * \cgalParamNEnd * \cgalParamNBegin{stream_precision} @@ -315,9 +315,9 @@ bool write_OFF(std::ostream& os, * * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} - * \cgalParamDescription{a property map associating points with floating point coordinates to the elements of the point set `points`} + * \cgalParamDescription{a property map associating points with %Cartesian coordinates to the elements of the point set `points`} * \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type - * of the iterator of `PointRange` and value type is a point type with floating point coordinates} + * of the iterator of `PointRange` and value type is a point type with %Cartesian coordinates} * \cgalParamDefault{`CGAL::Identity_property_map`} * \cgalParamNEnd * \cgalParamNBegin{stream_precision} diff --git a/Stream_support/include/CGAL/IO/STL.h b/Stream_support/include/CGAL/IO/STL.h index dfa3ecded7e..06929db9ccf 100644 --- a/Stream_support/include/CGAL/IO/STL.h +++ b/Stream_support/include/CGAL/IO/STL.h @@ -17,6 +17,9 @@ #include #include +#include +#include + #include #include @@ -296,7 +299,6 @@ bool write_STL(std::ostream& os, typedef typename boost::property_traits::value_type Point; typedef typename CGAL::Kernel_traits::Kernel K; - typedef typename K::Vector_3 Vector_3; K k = choose_parameter(get_parameter(np, internal_np::geom_traits)); @@ -305,6 +307,11 @@ bool write_STL(std::ostream& os, set_stream_precision_from_NP(os, np); + typedef Simple_cartesian SC; + typedef typename SC::Point_3 Point_3; + typedef typename SC::Vector_3 Vector_3; + Cartesian_converter conv; + if(get_mode(os) == BINARY) { os << "FileType: Binary "; @@ -317,12 +324,16 @@ bool write_STL(std::ostream& os, const Point& q = get(point_map, points[face[1]]); const Point& r = get(point_map, points[face[2]]); - const Vector_3 n = collinear(p,q,r) ? Vector_3(1,0,0) : unit_normal(p,q,r); + Point_3 pp = conv(p); + Point_3 qq = conv(q); + Point_3 rr = conv(r); - const float coords[12] = { static_cast(n.x()), static_cast(n.y()), static_cast(n.z()), - static_cast(p.x()), static_cast(p.y()), static_cast(p.z()), - static_cast(q.x()), static_cast(q.y()), static_cast(q.z()), - static_cast(r.x()), static_cast(r.y()), static_cast(r.z()) }; + const Vector_3 nn = collinear(pp,qq,rr) ? Vector_3(1,0,0) : unit_normal(pp,qq,rr); + + const float coords[12] = { static_cast(nn.x()), static_cast(nn.y()), static_cast(nn.z()), + static_cast(pp.x()), static_cast(pp.y()), static_cast(pp.z()), + static_cast(qq.x()), static_cast(qq.y()), static_cast(qq.z()), + static_cast(rr.x()), static_cast(rr.y()), static_cast(rr.z()) }; for(int i=0; i<12; ++i) os.write(reinterpret_cast(&coords[i]), sizeof(coords[i])); @@ -338,11 +349,15 @@ bool write_STL(std::ostream& os, const Point& q = get(point_map, points[face[1]]); const Point& r = get(point_map, points[face[2]]); - const Vector_3 n = internal::construct_normal_of_STL_face(p, q, r, k); - os << "facet normal " << n << "\nouter loop\n"; - os << "vertex " << p << "\n"; - os << "vertex " << q << "\n"; - os << "vertex " << r << "\n"; + Point_3 pp = conv(p); + Point_3 qq = conv(q); + Point_3 rr = conv(r); + + const Vector_3 nn = conv(internal::construct_normal_of_STL_face(p, q, r, k)); + os << "facet normal " << nn << "\nouter loop\n"; + os << "vertex " << pp << "\n"; + os << "vertex " << qq << "\n"; + os << "vertex " << rr << "\n"; os << "endloop\nendfacet\n"; } os << "endsolid"< points; std::vector> polygons; - auto pm = CGAL::make_cartesian_converter_property_map(CGAL::make_identity_property_map(Kernel::Point_3())); - CGAL::IO::write_polygon_soup("xxx.off", points, polygons, CGAL::parameters::stream_precision(17).point_map(pm)); + CGAL::IO::write_polygon_soup("xxx.off", points, polygons, CGAL::parameters::stream_precision(17)); return 0; }