6 #include <OpenMesh/Core/IO/BinaryHelper.hh> 7 #include <OpenMesh/Core/IO/writer/VTKWriter.hh> 8 #include <OpenMesh/Core/IO/IOManager.hh> 9 #include <OpenMesh/Core/Utils/color_cast.hh> 29 std::ofstream out(_filename.c_str());
32 omerr() <<
"[VTKWriter] : cannot open file " << _filename << std::endl;
36 return write(out, _be, _opt, _precision);
50 if (!check(_be, _opt)) {
56 omlog() <<
"[VTKWriter] : writer does not support any options\n";
60 omlog() <<
"[VTKWriter] : write file\n";
61 _out.precision(_precision);
63 std::vector<VertexHandle> vhandles;
64 size_t polygon_table_size = 0;
65 size_t nf = _be.n_faces();
66 for (
size_t i = 0; i < nf; ++i) {
67 polygon_table_size += _be.get_vhandles(
FaceHandle(
int(i)), vhandles);
69 polygon_table_size += nf;
72 _out <<
"# vtk DataFile Version 3.0\n";
73 _out <<
"Generated by OpenMesh\n";
75 _out <<
"DATASET POLYDATA\n";
78 _out <<
"POINTS " << _be.n_vertices() <<
" float\n";
79 size_t nv = _be.n_vertices();
80 for (
size_t i = 0; i < nv; ++i) {
82 _out << v[0] <<
' ' << v[1] <<
' ' << v[2] <<
'\n';
86 _out <<
"POLYGONS " << nf <<
' ' << polygon_table_size <<
'\n';
87 for (
size_t i = 0; i < nf; ++i) {
88 _be.get_vhandles(
FaceHandle(
int(i)), vhandles);
90 _out << vhandles.size() <<
' ';
91 for (
size_t j = 0; j < vhandles.size(); ++j) {
92 _out <<
" " << vhandles[j].idx();
Handle for a vertex entity.
_VTKWriter_ __VTKWriterinstance
Declare the single entity of the OBJ writer.
bool register_module(BaseReader *_bl)
_IOManager_ & IOManager()
bool is_empty(void) const
Returns true if all bits are zero.
Handle for a face entity.
Set options for reader/writer modules.
bool write(const std::string &, BaseExporter &, Options, std::streamsize _precision=6) const