OpenWalnut  1.5.0dev
WMeshReaderInterface.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMESHREADERINTERFACE_H
26 #define WMESHREADERINTERFACE_H
27 
28 #include <fstream>
29 #include <limits>
30 #include <memory>
31 #include <string>
32 #include <vector>
33 
34 #include <boost/filesystem/path.hpp>
35 
36 #include "core/common/WIOTools.h"
37 #include "core/common/WLogger.h"
38 #include "core/common/WProgressCombiner.h"
39 #include "core/common/WStringUtils.h"
40 #include "core/dataHandler/exceptions/WDHIOFailure.h"
41 #include "core/dataHandler/exceptions/WDHNoSuchFile.h"
42 #include "core/dataHandler/exceptions/WDHParseError.h"
43 #include "core/graphicsEngine/WTriangleMesh.h"
44 
45 /**
46  * Define the interface which is injected into an \ref WObjectNDIP. Remember that \ref WObjectNDIP is a template class deriving from its
47  * template type. This way we can inject methods into the base class. It avoids derivation from \ref WObjectNDIP.
48  *
49  * This defines the caller-interface common to each mesh loader
50  */
52 {
53 public:
54  /**
55  * Load the dataset. Throws exceptions if appropriate. Refer to the implementing class.
56  *
57  * \param progress the progress indicator
58  * \param file path to the file to load
59  *
60  * \return the loaded mesh
61  */
63  boost::filesystem::path file ) = 0;
64 
65  /**
66  * Destructor
67  */
68  virtual ~WMeshReaderInterface();
69 
70  /**
71  * Read a line from the given input stream and throw an exception on error.
72  *
73  * \param ifs the stream to read from
74  * \param desc the description for the exception. Provide some useful info here.
75  *
76  * \return the line
77  */
78  std::string getLine( std::shared_ptr< std::ifstream > ifs, const std::string& desc ) const;
79 
80  /**
81  * Read a line from the given input stream and throw an exception on error.
82  *
83  * \param ifs the stream to read from
84  * \param desc the description for the exception. Provide some useful info here.
85  *
86  * \return the line
87  */
88  std::string getLine( std::ifstream& ifs, const std::string& desc ) const;
89 };
90 
91 #endif // WMESHREADERINTERFACE_H
92 
Define the interface which is injected into an WObjectNDIP.
virtual ~WMeshReaderInterface()
Destructor.
std::string getLine(std::shared_ptr< std::ifstream > ifs, const std::string &desc) const
Read a line from the given input stream and throw an exception on error.
virtual WTriangleMesh::SPtr operator()(WProgressCombiner::SPtr progress, boost::filesystem::path file)=0
Load the dataset.
std::shared_ptr< WProgressCombiner > SPtr
Abbreviate shared_ptr for this class.
std::shared_ptr< WTriangleMesh > SPtr
Shared pointer.
Definition: WTriangleMesh.h:55