ValidateDataStructure.h 6.7 KB

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