ValidateDataStructure.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, 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 "../include/assimp/types.h"
  39. #include "BaseProcess.h"
  40. struct aiBone;
  41. struct aiMesh;
  42. struct aiAnimation;
  43. struct aiNodeAnim;
  44. struct aiTexture;
  45. struct aiMaterial;
  46. struct aiNode;
  47. struct aiString;
  48. namespace Assimp {
  49. // --------------------------------------------------------------------------------------
  50. /** Validates the whole ASSIMP scene data structure for correctness.
  51. * ImportErrorException is thrown of the scene is corrupt.*/
  52. // --------------------------------------------------------------------------------------
  53. class ValidateDSProcess : public BaseProcess
  54. {
  55. public:
  56. ValidateDSProcess();
  57. ~ValidateDSProcess();
  58. public:
  59. // -------------------------------------------------------------------
  60. bool IsActive( unsigned int pFlags) const;
  61. // -------------------------------------------------------------------
  62. void Execute( aiScene* pScene);
  63. protected:
  64. // -------------------------------------------------------------------
  65. /** Report a validation error. This will throw an exception,
  66. * control won't return.
  67. * @param msg Format string for sprintf().*/
  68. AI_WONT_RETURN void ReportError(const char* msg,...);
  69. // -------------------------------------------------------------------
  70. /** Report a validation warning. This won't throw an exception,
  71. * control will return to the callera.
  72. * @param msg Format string for sprintf().*/
  73. void ReportWarning(const char* msg,...);
  74. // -------------------------------------------------------------------
  75. /** Validates a mesh
  76. * @param pMesh Input mesh*/
  77. void Validate( const aiMesh* pMesh);
  78. // -------------------------------------------------------------------
  79. /** Validates a bone
  80. * @param pMesh Input mesh
  81. * @param pBone Input bone*/
  82. void Validate( const aiMesh* pMesh,const aiBone* pBone,float* afSum);
  83. // -------------------------------------------------------------------
  84. /** Validates an animation
  85. * @param pAnimation Input animation*/
  86. void Validate( const aiAnimation* pAnimation);
  87. // -------------------------------------------------------------------
  88. /** Validates a material
  89. * @param pMaterial Input material*/
  90. void Validate( const aiMaterial* pMaterial);
  91. // -------------------------------------------------------------------
  92. /** Search the material data structure for invalid or corrupt
  93. * texture keys.
  94. * @param pMaterial Input material
  95. * @param type Type of the texture*/
  96. void SearchForInvalidTextures(const aiMaterial* pMaterial,
  97. aiTextureType type);
  98. // -------------------------------------------------------------------
  99. /** Validates a texture
  100. * @param pTexture Input texture*/
  101. void Validate( const aiTexture* pTexture);
  102. // -------------------------------------------------------------------
  103. /** Validates a light source
  104. * @param pLight Input light
  105. */
  106. void Validate( const aiLight* pLight);
  107. // -------------------------------------------------------------------
  108. /** Validates a camera
  109. * @param pCamera Input camera*/
  110. void Validate( const aiCamera* pCamera);
  111. // -------------------------------------------------------------------
  112. /** Validates a bone animation channel
  113. * @param pAnimation Animation channel.
  114. * @param pBoneAnim Input bone animation */
  115. void Validate( const aiAnimation* pAnimation,
  116. const aiNodeAnim* pBoneAnim);
  117. // -------------------------------------------------------------------
  118. /** Validates a node and all of its subnodes
  119. * @param Node Input node*/
  120. void Validate( const aiNode* pNode);
  121. // -------------------------------------------------------------------
  122. /** Validates a string
  123. * @param pString Input string*/
  124. void Validate( const aiString* pString);
  125. private:
  126. // template to validate one of the aiScene::mXXX arrays
  127. template <typename T>
  128. inline void DoValidation(T** array, unsigned int size,
  129. const char* firstName, const char* secondName);
  130. // extended version: checks whethr T::mName occurs twice
  131. template <typename T>
  132. inline void DoValidationEx(T** array, unsigned int size,
  133. const char* firstName, const char* secondName);
  134. // extension to the first template which does also search
  135. // the nodegraph for an item with the same name
  136. template <typename T>
  137. inline void DoValidationWithNameCheck(T** array, unsigned int size,
  138. const char* firstName, const char* secondName);
  139. aiScene* mScene;
  140. };
  141. } // end of namespace Assimp
  142. #endif // AI_VALIDATEPROCESS_H_INC