1 // Copyright (c) 1997
2 // Utrecht University (The Netherlands),
3 // ETH Zurich (Switzerland),
4 // INRIA Sophia-Antipolis (France),
5 // Max-Planck-Institute Saarbruecken (Germany),
6 // and Tel-Aviv University (Israel).  All rights reserved.
7 //
8 // This file is part of CGAL (www.cgal.org)
9 //
10 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Stream_support/include/CGAL/IO/OI/File_writer_inventor.h $
11 // $Id: File_writer_inventor.h 4e519a3 2021-05-05T13:15:37+02:00 Sébastien Loriot
12 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
13 //
14 //
15 // Author(s)     : Lutz Kettner  <kettner@mpi-sb.mpg.de>
16 
17 #ifndef CGAL_IO_FILE_WRITER_INVENTOR_H
18 #define CGAL_IO_FILE_WRITER_INVENTOR_H
19 
20 #include <CGAL/IO/OI/Inventor_ostream.h>
21 
22 #include <iostream>
23 
24 namespace CGAL {
25 
26 class File_writer_inventor
27 {
28   Inventor_ostream_base m_os;
29   std::size_t m_facets;
30 
31 public:
File_writer_inventor()32   File_writer_inventor() {}
out()33   std::ostream& out() const { return m_os.os(); }
34 
35   void write_header(Inventor_ostream_base& o,
36                     std::size_t vertices,
37                     std::size_t halfedges,
38                     std::size_t facets,
39                     const bool /*colors*/ = false,
40                     const bool /*normals*/ = false,
41                     const bool /*textures*/ = false)
42   {
43     m_os = o;
44     m_facets = facets;
45 
46     out() << "# " << vertices << " vertices\n";
47     out() << "# " << halfedges << " halfedges\n";
48     out() << "# " << facets << " facets\n\n";
49     out() << "Separator {\n"
50              "    Coordinate3 {\n"
51              "        point   [" << std::endl;
52   }
53 
write_footer()54   void write_footer() const
55   {
56     out() << "        ] #coordIndex\n"
57              "    } #IndexedFaceSet\n"
58              "} #Separator" << std::endl;
59   }
60 
write_vertex(const double x,const double y,const double z)61   void write_vertex( const double x, const double y, const double z)
62   {
63     out() << "            " << IO::oformat(x) << ' ' << IO::oformat(y) << ' ' << IO::oformat(z) << ',' <<'\n';
64   }
65 
write_vertex_normal(const double,const double,const double)66   void write_vertex_normal(const double, const double, const double) { }
write_vertex_color(const double,const double,const double)67   void write_vertex_color(const double, const double, const double) { }
write_vertex_texture(const double,const double)68   void write_vertex_texture(const double, const double) { }
69 
write_facet_header()70   void write_facet_header() const
71   {
72     out() << "        ] #point\n"
73              "    } #Coordinate3\n"
74              "    # " << m_facets << " facets\n"
75              "    IndexedFaceSet {\n"
76              "        coordIndex [\n";
77   }
78 
write_facet_begin(std::size_t)79   void write_facet_begin( std::size_t) { out() << "            "; }
write_facet_vertex_index(std::size_t idx)80   void write_facet_vertex_index( std::size_t idx) { out() << idx << ','; }
write_face_color(const double,const double,const double)81   void write_face_color(const double, const double, const double) { }
write_facet_end()82   void write_facet_end() { out() << "-1,\n"; }
83 };
84 
85 } // namespace CGAL
86 
87 #endif // CGAL_IO_FILE_WRITER_INVENTOR_H
88