Loading...
Searching...
No Matches
BaseWriter.hh
/* ========================================================================= *
* *
* OpenMesh *
* Copyright (c) 2001-2025, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= */
//=============================================================================
//
// Implements the baseclass for IOManager writer modules
//
//=============================================================================
#ifndef __BASEWRITER_HH__
#define __BASEWRITER_HH__
//=== INCLUDES ================================================================
// STD C++
#include <iosfwd>
#include <string>
// OpenMesh
#include <OpenMesh/Core/System/config.h>
#include <OpenMesh/Core/IO/Options.hh>
#include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
//== NAMESPACES ===============================================================
namespace OpenMesh {
namespace IO {
//=== IMPLEMENTATION ==========================================================
class OPENMESHDLLEXPORT BaseWriter
{
public:
typedef unsigned int Option;
virtual ~BaseWriter() {};
virtual std::string get_description() const = 0;
virtual std::string get_extensions() const = 0;
virtual bool can_u_write(const std::string& _filename) const;
virtual bool write(const std::string& _filename,
BaseExporter& _be,
const Options& _writeOptions,
std::streamsize _precision = 6) const = 0;
virtual bool write(std::ostream& _os,
BaseExporter& _be,
const Options& _writeOptions,
std::streamsize _precision = 6) const = 0;
virtual size_t binary_size(BaseExporter&, const Options&) const { return 0; }
protected:
bool check(BaseExporter& _be, const Options& _writeOptions) const
{
// Check for all Options. When we want to write them (_opt.check() ) , they have to be available ( has_ )
// Converts to not A (write them) or B (available)
return ( !_writeOptions.check(Options::VertexNormal ) || _be.has_vertex_normals())
&& ( !_writeOptions.check(Options::VertexTexCoord)|| _be.has_vertex_texcoords())
&& ( !_writeOptions.check(Options::VertexColor) || _be.has_vertex_colors())
&& ( !_writeOptions.check(Options::FaceNormal) || _be.has_face_normals())
&& ( !_writeOptions.check(Options::FaceColor) || _be.has_face_colors());
}
};
//=============================================================================
} // namespace IO
} // namespace OpenMesh
//=============================================================================
#endif
//=============================================================================
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
OpenMesh::IO
This namespace contains functions for reading and writing polygonal meshes and a list of supported fi...
OpenMesh::IO::BaseExporter
Base class for exporter modules.
Definition BaseExporter.hh:85
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition Options.hh:92
OpenMesh::IO::Options::FaceNormal
@ FaceNormal
Has (r) / store (w) face normals.
Definition Options.hh:109
OpenMesh::IO::Options::FaceColor
@ FaceColor
Has (r) / store (w) face colors.
Definition Options.hh:110
OpenMesh::IO::Options::VertexNormal
@ VertexNormal
Has (r) / store (w) vertex normals.
Definition Options.hh:105
OpenMesh::IO::Options::VertexTexCoord
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition Options.hh:107
OpenMesh::IO::Options::VertexColor
@ VertexColor
Has (r) / store (w) vertex colors.
Definition Options.hh:106
OpenMesh::IO::BaseWriter
Base class for all writer modules.
Definition BaseWriter.hh:84
OpenMesh::IO::BaseWriter::can_u_write
virtual bool can_u_write(const std::string &_filename) const
Returns true if writer can write _filename (checks extension).
Definition BaseWriter.cc:80
OpenMesh::IO::BaseWriter::write
virtual bool write(std::ostream &_os, BaseExporter &_be, const Options &_writeOptions, std::streamsize _precision=6) const =0
Write to a std::ostream.
OpenMesh::IO::BaseWriter::get_extensions
virtual std::string get_extensions() const =0
Return file format's extension.
OpenMesh::IO::BaseWriter::write
virtual bool write(const std::string &_filename, BaseExporter &_be, const Options &_writeOptions, std::streamsize _precision=6) const =0
Write to a file.
OpenMesh::IO::BaseWriter::~BaseWriter
virtual ~BaseWriter()
Destructor.
Definition BaseWriter.hh:90
OpenMesh::IO::BaseWriter::binary_size
virtual size_t binary_size(BaseExporter &, const Options &) const
Returns expected size of file if binary format is supported else 0.
Definition BaseWriter.hh:128
OpenMesh::IO::BaseWriter::get_description
virtual std::string get_description() const =0
Return short description of the supported file format.