OpenMesh
STLReader.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 an reader module for STL files
53 //
54 //=============================================================================
55 
56 
57 #ifndef __STLREADER_HH__
58 #define __STLREADER_HH__
59 
60 
61 //=== INCLUDES ================================================================
62 
63 
64 #include <stdio.h>
65 #include <string>
66 
67 #include <OpenMesh/Core/System/config.h>
68 #include <OpenMesh/Core/Utils/SingletonT.hh>
69 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
70 
71 
72 //== NAMESPACES ===============================================================
73 
74 
75 namespace OpenMesh {
76 namespace IO {
77 
78 //== FORWARDS =================================================================
79 
80 class BaseImporter;
81 
82 //== IMPLEMENTATION ===========================================================
83 
84 
89 class OPENMESHDLLEXPORT _STLReader_ : public BaseReader
90 {
91 public:
92 
93  // constructor
94  _STLReader_();
95 
97  virtual ~_STLReader_() {};
98 
99 
100  std::string get_description() const
101  { return "Stereolithography Interface Format"; }
102  std::string get_extensions() const { return "stl stla stlb"; }
103 
104  bool read(const std::string& _filename,
105  BaseImporter& _bi,
106  Options& _opt);
107 
108  bool read(std::istream& _in,
109  BaseImporter& _bi,
110  Options& _opt);
111 
114  void set_epsilon(float _eps) { eps_=_eps; }
115 
117  float epsilon() const { return eps_; }
118 
119 
120 
121 private:
122 
123  enum STL_Type { STLA, STLB, NONE };
124  STL_Type check_stl_type(const std::string& _filename) const;
125 
126  bool read_stla(const std::string& _filename, BaseImporter& _bi, Options& _opt) const;
127  bool read_stla(std::istream& _in, BaseImporter& _bi, Options& _opt) const;
128  bool read_stlb(const std::string& _filename, BaseImporter& _bi, Options& _opt) const;
129  bool read_stlb(std::istream& _in, BaseImporter& _bi, Options& _opt) const;
130 
131 
132 private:
133 
134  float eps_;
135 };
136 
137 
138 //== TYPE DEFINITION ==========================================================
139 
140 
143 OPENMESHDLLEXPORT _STLReader_& STLReader();
144 
145 
146 //=============================================================================
147 } // namespace IO
148 } // namespace OpenMesh
149 //=============================================================================
150 #endif
151 //=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
std::string get_description() const
Returns a brief description of the file type that can be parsed.
Definition: STLReader.hh:100
Base class for reader modules.
Definition: BaseReader.hh:94
std::string get_extensions() const
Returns a string with the accepted file extensions separated by a whitespace and in small caps...
Definition: STLReader.hh:102
_STLReader_ __STLReaderInstance
Declare the single entity of the STL reader.
Definition: STLReader.cc:84
void set_epsilon(float _eps)
Set the threshold to be used for considering two point to be equal.
Definition: STLReader.hh:114
Implementation of the STL format reader.
Definition: STLReader.hh:89
Set options for reader/writer modules.
Definition: Options.hh:95
Base class for importer modules.
Definition: BaseImporter.hh:88
float epsilon() const
Returns the threshold to be used for considering two point to be equal.
Definition: STLReader.hh:117
virtual ~_STLReader_()
Destructor.
Definition: STLReader.hh:97

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .