00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * * 00009 * License * 00010 * * 00011 * This library is free software; you can redistribute it and/or modify it * 00012 * under the terms of the GNU Library General Public License as published * 00013 * by the Free Software Foundation, version 2. * 00014 * * 00015 * This library is distributed in the hope that it will be useful, but * 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00018 * Library General Public License for more details. * 00019 * * 00020 * You should have received a copy of the GNU Library General Public * 00021 * License along with this library; if not, write to the Free Software * 00022 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00023 * * 00024 \*===========================================================================*/ 00025 00026 00027 //============================================================================= 00028 // 00029 // Implements an reader module for STL files 00030 // 00031 //============================================================================= 00032 00033 00034 #ifndef __STLREADER_HH__ 00035 #define __STLREADER_HH__ 00036 00037 00038 //=== INCLUDES ================================================================ 00039 00040 00041 #include <stdio.h> 00042 #include <string> 00043 00044 #include <OpenMesh/Core/System/config.h> 00045 #include <OpenMesh/Core/Utils/SingletonT.hh> 00046 #include <OpenMesh/Core/IO/reader/BaseReader.hh> 00047 00048 00049 //== NAMESPACES =============================================================== 00050 00051 00052 namespace OpenMesh { 00053 namespace IO { 00054 00055 //== FORWARDS ================================================================= 00056 00057 class BaseImporter; 00058 00059 //== IMPLEMENTATION =========================================================== 00060 00061 00066 class _STLReader_ : public BaseReader 00067 { 00068 public: 00069 00070 // constructor 00071 _STLReader_(); 00072 00073 std::string get_description() const 00074 { return "Stereolithography Interface Format"; } 00075 std::string get_extensions() const { return "stla stlb"; } 00076 00077 bool read(const std::string& _filename, 00078 BaseImporter& _bi, 00079 Options& _opt); 00080 00081 private: 00082 00083 enum STL_Type { STLA, STLB, NONE }; 00084 STL_Type check_stl_type(const std::string& _filename) const; 00085 00086 bool read_stla(const std::string& _filename, BaseImporter& _bi) const; 00087 bool read_stlb(const std::string& _filename, BaseImporter& _bi) const; 00088 }; 00089 00090 00091 //== TYPE DEFINITION ========================================================== 00092 00093 00095 typedef SingletonT<_STLReader_> STLReader; 00096 00097 00098 //============================================================================= 00099 } // namespace IO 00100 } // namespace OpenMesh 00101 //============================================================================= 00102 #endif 00103 //=============================================================================