OpenMesh: OpenMesh/Core/IO/writer/BaseWriter.hh Source File

| 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 * $Revision$ *
45 * $Date$ *
46 * *
47 \*===========================================================================*/
48
49
50 //=============================================================================
51 //
52 // Implements the baseclass for IOManager writer modules
53 //
54 //=============================================================================
55
56
57 #ifndef __BASEWRITER_HH__
58 #define __BASEWRITER_HH__
59
60
61 //=== INCLUDES ================================================================
62
63
64 // STD C++
65 #include <iosfwd>
66 #include <string>
67
68 // OpenMesh
69 #include <OpenMesh/Core/System/config.h>
70 #include <OpenMesh/Core/IO/Options.hh>
71 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
72
73
74 //== NAMESPACES ===============================================================
75
76
77 namespace OpenMesh {
78 namespace IO {
79
80
81 //=== IMPLEMENTATION ==========================================================
82
83
88 class OPENMESHDLLEXPORT BaseWriter
89 {
90 public:
91
92 typedef unsigned int Option;
93
95 virtual ~BaseWriter() {};
96
98 virtual std::string get_description() const = 0;
99
101 virtual std::string get_extensions() const = 0;
102
108 virtual bool can_u_write(const std::string& _filename) const;
109
116 virtual bool write(const std::string& _filename,
117 BaseExporter& _be,
118 Options _opt,
119 std::streamsize _precision = 6) const = 0;
120
127 virtual bool write(std::ostream& _os,
128 BaseExporter& _be,
129 Options _opt,
130 std::streamsize _precision = 6) const = 0;
131
133 virtual size_t binary_size(BaseExporter&, Options) const { return 0; }
134
135
136
137 protected:
138
139 bool check(BaseExporter& _be, Options _opt) const
140 {
141 return (_opt.check(Options::VertexNormal ) <= _be.has_vertex_normals())
142 && (_opt.check(Options::VertexTexCoord)<= _be.has_vertex_texcoords())
143 && (_opt.check(Options::VertexColor) <= _be.has_vertex_colors())
144 && (_opt.check(Options::FaceNormal) <= _be.has_face_normals())
145 && (_opt.check(Options::FaceColor) <= _be.has_face_colors());
146 }
147 };
148
149
150 //=============================================================================
151 } // namespace IO
152 } // namespace OpenMesh
153 //=============================================================================
154 #endif
155 //=============================================================================
OpenMesh::IO::Options::VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition: Options.hh:111
OpenMesh::IO::BaseWriter
Base class for all writer modules.
Definition: BaseWriter.hh:88
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::IO::Options::FaceNormal
Has (r) / store (w) face normals.
Definition: Options.hh:113
OpenMesh::IO::Options::FaceColor
Has (r) / store (w) face colors.
Definition: Options.hh:114
OpenMesh::IO::Options::VertexNormal
Has (r) / store (w) vertex normals.
Definition: Options.hh:109
OpenMesh::IO::Options::VertexColor
Has (r) / store (w) vertex colors.
Definition: Options.hh:110
OpenMesh::IO::BaseExporter
Base class for exporter modules.
Definition: BaseExporter.hh:89
OpenMesh::IO::BaseWriter::~BaseWriter
virtual ~BaseWriter()
Destructor.
Definition: BaseWriter.hh:95
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition: Options.hh:95
Option
Definition: mconvert.cc:107
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:133