Loading...
Searching...
No Matches
OFFReader.hh
/* ========================================================================= *
* *
* OpenMesh *
* Copyright (c) 2001-2022, 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 a reader module for OFF files
//
//=============================================================================
#pragma once
//=== INCLUDES ================================================================
#include <iosfwd>
#include <string>
#include <cstdio>
#include <OpenMesh/Core/System/config.h>
#include <OpenMesh/Core/Utils/SingletonT.hh>
#include <OpenMesh/Core/IO/reader/BaseReader.hh>
//== NAMESPACES ===============================================================
namespace OpenMesh {
namespace IO {
//== FORWARDS =================================================================
class BaseImporter;
//== IMPLEMENTATION ===========================================================
class OPENMESHDLLEXPORT _OFFReader_ : public BaseReader
{
public:
_OFFReader_();
virtual ~_OFFReader_() {};
std::string get_description() const override { return "Object File Format"; }
std::string get_extensions() const override { return "off"; }
std::string get_magic() const override { return "OFF"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt) override;
bool can_u_read(const std::string& _filename) const override;
bool read(std::istream& _in, BaseImporter& _bi, Options& _opt ) override;
private:
bool can_u_read(std::istream& _is) const;
bool read_ascii(std::istream& _in, BaseImporter& _bi, Options& _opt) const;
bool read_binary(std::istream& _in, BaseImporter& _bi, Options& _opt, bool swap) const;
void readValue(std::istream& _in, float& _value) const;
void readValue(std::istream& _in, int& _value) const;
void readValue(std::istream& _in, unsigned int& _value) const;
int getColorType(std::string & _line, bool _texCoordsAvailable) const;
//available options for reading
mutable Options options_;
//options that the user wants to read
mutable Options userOptions_;
};
//== TYPE DEFINITION ==========================================================
extern _OFFReader_ __OFFReaderInstance;
OPENMESHDLLEXPORT _OFFReader_& OFFReader();
//=============================================================================
} // namespace IO
} // namespace OpenMesh
//=============================================================================
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
OpenMesh::IO::__OFFReaderInstance
_OFFReader_ __OFFReaderInstance
Declare the single entity of the OFF reader.
Definition OFFReader.cc:88
OpenMesh::IO::BaseImporter
Base class for importer modules.
Definition BaseImporter.hh:84
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition Options.hh:91
OpenMesh::IO::BaseReader
Base class for reader modules.
Definition BaseReader.hh:87
OpenMesh::IO::_OFFReader_
Implementation of the OFF format reader.
Definition OFFReader.hh:110
OpenMesh::IO::_OFFReader_::~_OFFReader_
virtual ~_OFFReader_()
Destructor.
Definition OFFReader.hh:116
OpenMesh::IO::_OFFReader_::get_description
std::string get_description() const override
Returns a brief description of the file type that can be parsed.
Definition OFFReader.hh:118
OpenMesh::IO::_OFFReader_::get_extensions
std::string get_extensions() const override
Returns a string with the accepted file extensions separated by a whitespace and in small caps.
Definition OFFReader.hh:119
OpenMesh::IO::_OFFReader_::get_magic
std::string get_magic() const override
Return magic bits used to determine file format.
Definition OFFReader.hh:120