1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42/** @file PLYLoader.h
43 * @brief Declaration of the .ply importer class.
44 */
45#ifndef AI_PLYLOADER_H_INCLUDED
46#define AI_PLYLOADER_H_INCLUDED
47
48#include "BaseImporter.h"
49#include <assimp/types.h>
50#include "PlyParser.h"
51#include <vector>
52
53struct aiNode;
54struct aiMaterial;
55struct aiMesh;
56
57namespace Assimp {
58
59
60using namespace PLY;
61
62// ---------------------------------------------------------------------------
63/** Importer class to load the stanford PLY file format
64*/
65class PLYImporter : public BaseImporter
66{
67public:
68 PLYImporter();
69 ~PLYImporter();
70
71public:
72
73 // -------------------------------------------------------------------
74 /** Returns whether the class can handle the format of the given file.
75 * See BaseImporter::CanRead() for details.
76 */
77 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
78 bool checkSig) const;
79
80 // -------------------------------------------------------------------
81 /** Extract a vertex from the DOM
82 */
83 void LoadVertex(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
84
85 // -------------------------------------------------------------------
86 /** Extract a face from the DOM
87 */
88 void LoadFace(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
89
90protected:
91
92 // -------------------------------------------------------------------
93 /** Return importer meta information.
94 * See #BaseImporter::GetInfo for the details
95 */
96 const aiImporterDesc* GetInfo () const;
97
98 // -------------------------------------------------------------------
99 /** Imports the given file into the given scene structure.
100 * See BaseImporter::InternReadFile() for details
101 */
102 void InternReadFile( const std::string& pFile, aiScene* pScene,
103 IOSystem* pIOHandler);
104
105protected:
106 // -------------------------------------------------------------------
107 /** Extract a material list from the DOM
108 */
109 void LoadMaterial(std::vector<aiMaterial*>* pvOut, std::string &defaultTexture, const bool pointsOnly);
110
111 // -------------------------------------------------------------------
112 /** Static helper to parse a color from four single channels in
113 */
114 static void GetMaterialColor(
115 const std::vector<PLY::PropertyInstance>& avList,
116 unsigned int aiPositions[4],
117 PLY::EDataType aiTypes[4],
118 aiColor4D* clrOut);
119
120 // -------------------------------------------------------------------
121 /** Static helper to parse a color channel value. The input value
122 * is normalized to 0-1.
123 */
124 static ai_real NormalizeColorValue (
125 PLY::PropertyInstance::ValueUnion val,
126 PLY::EDataType eType);
127
128 /** Buffer to hold the loaded file */
129 unsigned char* mBuffer;
130
131 /** Document object model representation extracted from the file */
132 PLY::DOM* pcDOM;
133
134 /** Mesh generated by loader */
135 aiMesh* mGeneratedMesh;
136};
137
138} // end of namespace Assimp
139
140#endif // AI_3DSIMPORTER_H_INC
141