ValidateDataStructure.h 6.3 KB

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