1 | /* |
2 | Open Asset Import Library (assimp) |
3 | ---------------------------------------------------------------------- |
4 | |
5 | Copyright (c) 2006-2017, assimp team |
6 | |
7 | All rights reserved. |
8 | |
9 | Redistribution and use of this software in source and binary forms, |
10 | with or without modification, are permitted provided that the |
11 | following 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 | |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | |
39 | ---------------------------------------------------------------------- |
40 | */ |
41 | |
42 | /** @file Defines a (dummy) post processing step to validate the loader's |
43 | * output data structure (for debugging) |
44 | */ |
45 | #ifndef AI_VALIDATEPROCESS_H_INC |
46 | #define AI_VALIDATEPROCESS_H_INC |
47 | |
48 | #include <assimp/types.h> |
49 | #include <assimp/material.h> |
50 | #include "BaseProcess.h" |
51 | |
52 | struct aiBone; |
53 | struct aiMesh; |
54 | struct aiAnimation; |
55 | struct aiNodeAnim; |
56 | struct aiTexture; |
57 | struct aiMaterial; |
58 | struct aiNode; |
59 | struct aiString; |
60 | struct aiCamera; |
61 | struct aiLight; |
62 | |
63 | namespace Assimp { |
64 | |
65 | // -------------------------------------------------------------------------------------- |
66 | /** Validates the whole ASSIMP scene data structure for correctness. |
67 | * ImportErrorException is thrown of the scene is corrupt.*/ |
68 | // -------------------------------------------------------------------------------------- |
69 | class ValidateDSProcess : public BaseProcess |
70 | { |
71 | public: |
72 | |
73 | ValidateDSProcess(); |
74 | ~ValidateDSProcess(); |
75 | |
76 | public: |
77 | // ------------------------------------------------------------------- |
78 | bool IsActive( unsigned int pFlags) const; |
79 | |
80 | // ------------------------------------------------------------------- |
81 | void Execute( aiScene* pScene); |
82 | |
83 | protected: |
84 | |
85 | // ------------------------------------------------------------------- |
86 | /** Report a validation error. This will throw an exception, |
87 | * control won't return. |
88 | * @param msg Format string for sprintf().*/ |
89 | AI_WONT_RETURN void ReportError(const char* msg,...) AI_WONT_RETURN_SUFFIX; |
90 | |
91 | |
92 | // ------------------------------------------------------------------- |
93 | /** Report a validation warning. This won't throw an exception, |
94 | * control will return to the caller. |
95 | * @param msg Format string for sprintf().*/ |
96 | void ReportWarning(const char* msg,...); |
97 | |
98 | |
99 | // ------------------------------------------------------------------- |
100 | /** Validates a mesh |
101 | * @param pMesh Input mesh*/ |
102 | void Validate( const aiMesh* pMesh); |
103 | |
104 | // ------------------------------------------------------------------- |
105 | /** Validates a bone |
106 | * @param pMesh Input mesh |
107 | * @param pBone Input bone*/ |
108 | void Validate( const aiMesh* pMesh,const aiBone* pBone,float* afSum); |
109 | |
110 | // ------------------------------------------------------------------- |
111 | /** Validates an animation |
112 | * @param pAnimation Input animation*/ |
113 | void Validate( const aiAnimation* pAnimation); |
114 | |
115 | // ------------------------------------------------------------------- |
116 | /** Validates a material |
117 | * @param pMaterial Input material*/ |
118 | void Validate( const aiMaterial* pMaterial); |
119 | |
120 | // ------------------------------------------------------------------- |
121 | /** Search the material data structure for invalid or corrupt |
122 | * texture keys. |
123 | * @param pMaterial Input material |
124 | * @param type Type of the texture*/ |
125 | void SearchForInvalidTextures(const aiMaterial* pMaterial, |
126 | aiTextureType type); |
127 | |
128 | // ------------------------------------------------------------------- |
129 | /** Validates a texture |
130 | * @param pTexture Input texture*/ |
131 | void Validate( const aiTexture* pTexture); |
132 | |
133 | // ------------------------------------------------------------------- |
134 | /** Validates a light source |
135 | * @param pLight Input light |
136 | */ |
137 | void Validate( const aiLight* pLight); |
138 | |
139 | // ------------------------------------------------------------------- |
140 | /** Validates a camera |
141 | * @param pCamera Input camera*/ |
142 | void Validate( const aiCamera* pCamera); |
143 | |
144 | // ------------------------------------------------------------------- |
145 | /** Validates a bone animation channel |
146 | * @param pAnimation Animation channel. |
147 | * @param pBoneAnim Input bone animation */ |
148 | void Validate( const aiAnimation* pAnimation, |
149 | const aiNodeAnim* pBoneAnim); |
150 | |
151 | // ------------------------------------------------------------------- |
152 | /** Validates a node and all of its subnodes |
153 | * @param Node Input node*/ |
154 | void Validate( const aiNode* pNode); |
155 | |
156 | // ------------------------------------------------------------------- |
157 | /** Validates a string |
158 | * @param pString Input string*/ |
159 | void Validate( const aiString* pString); |
160 | |
161 | private: |
162 | |
163 | // template to validate one of the aiScene::mXXX arrays |
164 | template <typename T> |
165 | inline void DoValidation(T** array, unsigned int size, |
166 | const char* firstName, const char* secondName); |
167 | |
168 | // extended version: checks whether T::mName occurs twice |
169 | template <typename T> |
170 | inline void DoValidationEx(T** array, unsigned int size, |
171 | const char* firstName, const char* secondName); |
172 | |
173 | // extension to the first template which does also search |
174 | // the nodegraph for an item with the same name |
175 | template <typename T> |
176 | inline void DoValidationWithNameCheck(T** array, unsigned int size, |
177 | const char* firstName, const char* secondName); |
178 | |
179 | aiScene* mScene; |
180 | }; |
181 | |
182 | |
183 | |
184 | |
185 | } // end of namespace Assimp |
186 | |
187 | #endif // AI_VALIDATEPROCESS_H_INC |
188 | |