cgal/Packages/Polyhedron_IO/include/CGAL/IO/File_writer_wavefront.h

71 lines
2.3 KiB
C++

// ============================================================================
//
// Copyright (c) 1997 The CGAL Consortium
//
// This software and related documentation is part of an INTERNAL release
// of the Computational Geometry Algorithms Library (CGAL). It is not
// intended for general use.
//
// ----------------------------------------------------------------------------
//
// release : $CGAL_Revision: $
// release_date : $CGAL_Date: $
//
// file : include/CGAL/IO/File_writer_wavefront.h
// package : Polyhedron_IO 2.11 (04 Feb 2000)
// chapter : Support Library
//
// revision : $Revision$
// revision_date : $Date$
//
// author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
// maintainer :
// coordinator : INRIA, Sophia Antipolis
//
// Writer for polyhedral surfaces in Wavefront file format (.obj)
// ============================================================================
#ifndef CGAL_IO_FILE_WRITER_WAVEFRONT_H
#define CGAL_IO_FILE_WRITER_WAVEFRONT_H 1
#ifndef CGAL_IO_BINARY_FILE_IO_H
#include <CGAL/IO/binary_file_io.h>
#endif // CGAL_IO_BINARY_FILE_IO_H
#ifndef CGAL_PROTECT_IOSTREAM
#include <iostream>
#define CGAL_PROTECT_IOSTREAM
#endif
#ifndef CGAL_PROTECT_CSTDDEF
#include <cstddef>
#define CGAL_PROTECT_CSTDDEF
#endif
CGAL_BEGIN_NAMESPACE
class File_writer_wavefront {
std::ostream* m_out;
std::size_t m_facets;
public:
std::ostream& out() const { return *m_out; }
void write_header( std::ostream& out,
std::size_t vertices,
std::size_t halfedges,
std::size_t facets);
void write_footer() const {
out() << "\n# End of Wavefront obj format #" << std::endl;
}
void write_vertex( const double& x, const double& y, const double& z) {
out() << "v " << x << ' ' << y << ' ' << z << '\n';
}
void write_facet_header() {
out() << "\n# " << m_facets << " facets\n";
out() << "# ------------------------------------------\n\n";
}
void write_facet_begin( std::size_t) { out() << "f "; }
void write_facet_vertex_index( std::size_t idx) { out() << ' ' << idx+1; }
void write_facet_end() { out() << '\n'; }
};
CGAL_END_NAMESPACE
#endif // CGAL_IO_FILE_WRITER_WAVEFRONT_H //
// EOF //