| OpenMesh

BaseWriter.hh
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42
43
44
45 //=============================================================================
46 //
47 // Implements the baseclass for IOManager writer modules
48 //
49 //=============================================================================
50
51
52 #ifndef __BASEWRITER_HH__
53 #define __BASEWRITER_HH__
54
55
56 //=== INCLUDES ================================================================
57
58
59 // STD C++
60 #include <iosfwd>
61 #include <string>
62
63 // OpenMesh
64 #include <OpenMesh/Core/System/config.h>
65 #include <OpenMesh/Core/IO/Options.hh>
66 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
67
68
69 //== NAMESPACES ===============================================================
70
71
72 namespace OpenMesh {
73 namespace IO {
74
75
76 //=== IMPLEMENTATION ==========================================================
77
78
83 class OPENMESHDLLEXPORT BaseWriter
84 {
85 public:
86
87 typedef unsigned int Option;
88
90 virtual ~BaseWriter() {};
91
93 virtual std::string get_description() const = 0;
94
96 virtual std::string get_extensions() const = 0;
97
103 virtual bool can_u_write(const std::string& _filename) const;
104
111 virtual bool write(const std::string& _filename,
112 BaseExporter& _be,
113 Options _opt,
114 std::streamsize _precision = 6) const = 0;
115
122 virtual bool write(std::ostream& _os,
123 BaseExporter& _be,
124 Options _opt,
125 std::streamsize _precision = 6) const = 0;
126
128 virtual size_t binary_size(BaseExporter&, Options) const { return 0; }
129
130
131
132 protected:
133
134 bool check(BaseExporter& _be, Options _opt) const
135 {
136 return (_opt.check(Options::VertexNormal ) <= _be.has_vertex_normals())
137 && (_opt.check(Options::VertexTexCoord)<= _be.has_vertex_texcoords())
138 && (_opt.check(Options::VertexColor) <= _be.has_vertex_colors())
139 && (_opt.check(Options::FaceNormal) <= _be.has_face_normals())
140 && (_opt.check(Options::FaceColor) <= _be.has_face_colors());
141 }
142 };
143
144
145 //=============================================================================
146 } // namespace IO
147 } // namespace OpenMesh
148 //=============================================================================
149 #endif
150 //=============================================================================
OpenMesh::IO::Options::FaceColor
Has (r) / store (w) face colors.
Definition: Options.hh:109
OpenMesh::IO::Options::VertexColor
Has (r) / store (w) vertex colors.
Definition: Options.hh:105
OpenMesh::IO::Options::VertexNormal
Has (r) / store (w) vertex normals.
Definition: Options.hh:104
OpenMesh::IO::BaseWriter::binary_size
virtual size_t binary_size(BaseExporter &, Options) const
Returns expected size of file if binary format is supported else 0.
Definition: BaseWriter.hh:128
OpenMesh::IO::Options::VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition: Options.hh:106
OpenMesh::IO::BaseExporter
Base class for exporter modules.
Definition: BaseExporter.hh:84
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition: Options.hh:90
OpenMesh::IO::BaseWriter::~BaseWriter
virtual ~BaseWriter()
Destructor.
Definition: BaseWriter.hh:90
OpenMesh::IO::Options::FaceNormal
Has (r) / store (w) face normals.
Definition: Options.hh:108
OpenMesh::IO::BaseWriter
Base class for all writer modules.
Definition: BaseWriter.hh:83
Option
Definition: mconvert.cc:102