ValidateDataStructure.h 6.8 KB

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