mirror of https://github.com/CGAL/cgal
Convert internally to double as required by file format. Document the point property map which is implemented
This commit is contained in:
parent
561ec37dc6
commit
0cf9d434b6
|
|
@ -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<std::iterator_traits<PointRange::iterator>::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<std::iterator_traits<PointRange::iterator>::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}
|
||||
|
|
|
|||
|
|
@ -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<std::iterator_traits<PointRange::iterator>::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<std::iterator_traits<PointRange::iterator>::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}
|
||||
|
|
|
|||
|
|
@ -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<std::iterator_traits<PointRange::iterator>::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<geom_traits::Point_3>`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalParamNBegin{stream_precision}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
#include <CGAL/IO/STL/STL_reader.h>
|
||||
#include <CGAL/IO/helpers.h>
|
||||
#include <CGAL/Cartesian_converter.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
|
||||
#include <CGAL/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
|
@ -296,7 +299,6 @@ bool write_STL(std::ostream& os,
|
|||
|
||||
typedef typename boost::property_traits<PointMap>::value_type Point;
|
||||
typedef typename CGAL::Kernel_traits<Point>::Kernel K;
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
|
||||
K k = choose_parameter<K>(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<double> SC;
|
||||
typedef typename SC::Point_3 Point_3;
|
||||
typedef typename SC::Vector_3 Vector_3;
|
||||
Cartesian_converter<Kernel,SC> 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<float>(n.x()), static_cast<float>(n.y()), static_cast<float>(n.z()),
|
||||
static_cast<float>(p.x()), static_cast<float>(p.y()), static_cast<float>(p.z()),
|
||||
static_cast<float>(q.x()), static_cast<float>(q.y()), static_cast<float>(q.z()),
|
||||
static_cast<float>(r.x()), static_cast<float>(r.y()), static_cast<float>(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<float>(nn.x()), static_cast<float>(nn.y()), static_cast<float>(nn.z()),
|
||||
static_cast<float>(pp.x()), static_cast<float>(pp.y()), static_cast<float>(pp.z()),
|
||||
static_cast<float>(qq.x()), static_cast<float>(qq.y()), static_cast<float>(qq.z()),
|
||||
static_cast<float>(rr.x()), static_cast<float>(rr.y()), static_cast<float>(rr.z()) };
|
||||
|
||||
for(int i=0; i<12; ++i)
|
||||
os.write(reinterpret_cast<const char *>(&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"<<std::endl;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using Epick = CGAL::Exact_predicates_inexact_constructions_kernel;
|
|||
int main() {
|
||||
std::vector<Kernel::Point_3> points;
|
||||
std::vector<std::array<std::size_t, 3>> polygons;
|
||||
auto pm = CGAL::make_cartesian_converter_property_map<Epick::Point_3>(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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue