utValidateDataStructure.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2020, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #include "UnitTestPCH.h"
  35. #include <assimp/mesh.h>
  36. #include <assimp/scene.h>
  37. #include <ValidateDataStructure.h>
  38. using namespace std;
  39. using namespace Assimp;
  40. class ValidateDataStructureTest : public ::testing::Test
  41. {
  42. public:
  43. virtual void SetUp();
  44. virtual void TearDown();
  45. protected:
  46. ValidateDSProcess* vds;
  47. aiScene* scene;
  48. };
  49. // ------------------------------------------------------------------------------------------------
  50. void ValidateDataStructureTest::SetUp()
  51. {
  52. // setup a dummy scene with a single node
  53. scene = new aiScene();
  54. scene->mRootNode = new aiNode();
  55. scene->mRootNode->mName.Set("<test>");
  56. // add some translation
  57. scene->mRootNode->mTransformation.a4 = 1.f;
  58. scene->mRootNode->mTransformation.b4 = 2.f;
  59. scene->mRootNode->mTransformation.c4 = 3.f;
  60. // and allocate a ScenePreprocessor to operate on the scene
  61. vds = new ValidateDSProcess();
  62. }
  63. // ------------------------------------------------------------------------------------------------
  64. void ValidateDataStructureTest::TearDown()
  65. {
  66. delete vds;
  67. delete scene;
  68. }
  69. // ------------------------------------------------------------------------------------------------
  70. //Template
  71. //TEST_F(ScenePreprocessorTest, test)
  72. //{
  73. //}
  74. // TODO Conditions not yet checked:
  75. //132: ReportError("aiScene::%s is NULL (aiScene::%s is %i)",
  76. //139: ReportError("aiScene::%s[%i] is NULL (aiScene::%s is %i)",
  77. //156: ReportError("aiScene::%s is NULL (aiScene::%s is %i)",
  78. //163: ReportError("aiScene::%s[%i] is NULL (aiScene::%s is %i)",
  79. //173: ReportError("aiScene::%s[%i] has the same name as "
  80. //192: ReportError("aiScene::%s[%i] has no corresponding node in the scene graph (%s)",
  81. //196: ReportError("aiScene::%s[%i]: there are more than one nodes with %s as name",
  82. //217: ReportError("aiScene::mNumMeshes is 0. At least one mesh must be there");
  83. //220: ReportError("aiScene::mMeshes is non-null although there are no meshes");
  84. //229: ReportError("aiScene::mAnimations is non-null although there are no animations");
  85. //238: ReportError("aiScene::mCameras is non-null although there are no cameras");
  86. //247: ReportError("aiScene::mLights is non-null although there are no lights");
  87. //256: ReportError("aiScene::mTextures is non-null although there are no textures");
  88. //266: ReportError("aiScene::mNumMaterials is 0. At least one material must be there");
  89. //270: ReportError("aiScene::mMaterials is non-null although there are no materials");
  90. //281: ReportWarning("aiLight::mType is aiLightSource_UNDEFINED");
  91. //286: ReportWarning("aiLight::mAttenuationXXX - all are zero");
  92. //290: ReportError("aiLight::mAngleInnerCone is larger than aiLight::mAngleOuterCone");
  93. //295: ReportWarning("aiLight::mColorXXX - all are black and won't have any influence");
  94. //303: ReportError("aiCamera::mClipPlaneFar must be >= aiCamera::mClipPlaneNear");
  95. //308: ReportWarning("%f is not a valid value for aiCamera::mHorizontalFOV",pCamera->mHorizontalFOV);
  96. //317: ReportError("aiMesh::mMaterialIndex is invalid (value: %i maximum: %i)",
  97. //332: ReportError("aiMesh::mFaces[%i].mNumIndices is 0",i);
  98. //336: ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes "
  99. //337: "does not report the POINT flag",i);
  100. //343: ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimitiveTypes "
  101. //344: "does not report the LINE flag",i);
  102. //350: ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimitiveTypes "
  103. //351: "does not report the TRIANGLE flag",i);
  104. //357: this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimitiveTypes "
  105. //358: "does not report the POLYGON flag",i);
  106. //365: ReportError("aiMesh::mFaces[%i].mIndices is NULL",i);
  107. //370: ReportError("The mesh %s contains no vertices", pMesh->mName.C_Str());
  108. //374: ReportError("Mesh has too many vertices: %u, but the limit is %u",pMesh->mNumVertices,AI_MAX_VERTICES);
  109. //377: ReportError("Mesh has too many faces: %u, but the limit is %u",pMesh->mNumFaces,AI_MAX_FACES);
  110. //382: ReportError("If there are tangents, bitangent vectors must be present as well");
  111. //387: ReportError("Mesh %s contains no faces", pMesh->mName.C_Str());
  112. //398: ReportError("Face %u has too many faces: %u, but the limit is %u",i,face.mNumIndices,AI_MAX_FACE_INDICES);
  113. //404: ReportError("aiMesh::mFaces[%i]::mIndices[%i] is out of range",i,a);
  114. //412: ReportError("aiMesh::mVertices[%i] is referenced twice - second "
  115. //426: ReportWarning("There are unreferenced vertices");
  116. //439: ReportError("Texture coordinate channel %i exists "
  117. //453: ReportError("Vertex color channel %i is exists "
  118. //464: ReportError("aiMesh::mBones is NULL (aiMesh::mNumBones is %i)",
  119. //480: ReportError("Bone %u has too many weights: %u, but the limit is %u",i,bone->mNumWeights,AI_MAX_BONE_WEIGHTS);
  120. //485: ReportError("aiMesh::mBones[%i] is NULL (aiMesh::mNumBones is %i)",
  121. //498: ReportError("aiMesh::mBones[%i], name = \"%s\" has the same name as "
  122. //507: ReportWarning("aiMesh::mVertices[%i]: bone weight sum != 1.0 (sum is %f)",i,afSum[i]);
  123. //513: ReportError("aiMesh::mBones is non-null although there are no bones");
  124. //524: ReportError("aiBone::mNumWeights is zero");
  125. //531: ReportError("aiBone::mWeights[%i].mVertexId is out of range",i);
  126. //534: ReportWarning("aiBone::mWeights[%i].mWeight has an invalid value",i);
  127. //549: ReportError("aiAnimation::mChannels is NULL (aiAnimation::mNumChannels is %i)",
  128. //556: ReportError("aiAnimation::mChannels[%i] is NULL (aiAnimation::mNumChannels is %i)",
  129. //563: ReportError("aiAnimation::mNumChannels is 0. At least one node animation channel must be there.");
  130. //567: // if (!pAnimation->mDuration)this->ReportError("aiAnimation::mDuration is zero");
  131. //592: ReportError("Material property %s is expected to be a string",prop->mKey.data);
  132. //596: ReportError("%s #%i is set, but there are only %i %s textures",
  133. //611: ReportError("Found texture property with index %i, although there "
  134. //619: ReportError("Material property %s%i is expected to be an integer (size is %i)",
  135. //627: ReportError("Material property %s%i is expected to be 5 floats large (size is %i)",
  136. //635: ReportError("Material property %s%i is expected to be an integer (size is %i)",
  137. //656: ReportWarning("Invalid UV index: %i (key %s). Mesh %i has only %i UV channels",
  138. //676: ReportWarning("UV-mapped texture, but there are no UV coords");
  139. //690: ReportError("aiMaterial::mProperties[%i] is NULL (aiMaterial::mNumProperties is %i)",
  140. //694: ReportError("aiMaterial::mProperties[%i].mDataLength or "
  141. //702: ReportError("aiMaterial::mProperties[%i].mDataLength is "
  142. //707: ReportError("Missing null-terminator in string material property");
  143. //713: ReportError("aiMaterial::mProperties[%i].mDataLength is "
  144. //720: ReportError("aiMaterial::mProperties[%i].mDataLength is "
  145. //739: ReportWarning("A specular shading model is specified but there is no "
  146. //743: ReportWarning("A specular shading model is specified but the value of the "
  147. //752: ReportWarning("Invalid opacity value (must be 0 < opacity < 1.0)");
  148. //776: ReportError("aiTexture::pcData is NULL");
  149. //781: ReportError("aiTexture::mWidth is zero (aiTexture::mHeight is %i, uncompressed texture)",
  150. //788: ReportError("aiTexture::mWidth is zero (compressed texture)");
  151. //791: ReportWarning("aiTexture::achFormatHint must be zero-terminated");
  152. //794: ReportWarning("aiTexture::achFormatHint should contain a file extension "
  153. //804: ReportError("aiTexture::achFormatHint contains non-lowercase letters");
  154. //815: ReportError("Empty node animation channel");
  155. //822: ReportError("aiNodeAnim::mPositionKeys is NULL (aiNodeAnim::mNumPositionKeys is %i)",
  156. //833: ReportError("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is larger "
  157. //840: ReportWarning("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is smaller "
  158. //853: ReportError("aiNodeAnim::mRotationKeys is NULL (aiNodeAnim::mNumRotationKeys is %i)",
  159. //861: ReportError("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is larger "
  160. //868: ReportWarning("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is smaller "
  161. //880: ReportError("aiNodeAnim::mScalingKeys is NULL (aiNodeAnim::mNumScalingKeys is %i)",
  162. //888: ReportError("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is larger "
  163. //895: ReportWarning("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is smaller "
  164. //907: ReportError("A node animation channel must have at least one subtrack");
  165. //915: ReportError("A node of the scenegraph is NULL");
  166. //920: ReportError("Non-root node %s lacks a valid parent (aiNode::mParent is NULL) ",pNode->mName);
  167. //928: ReportError("aiNode::mMeshes is NULL for node %s (aiNode::mNumMeshes is %i)",
  168. //937: ReportError("aiNode::mMeshes[%i] is out of range for node %s (maximum is %i)",
  169. //942: ReportError("aiNode::mMeshes[%i] is already referenced by this node %s (value: %i)",
  170. //951: ReportError("aiNode::mChildren is NULL for node %s (aiNode::mNumChildren is %i)",
  171. //965: ReportError("aiString::length is too large (%i, maximum is %lu)",
  172. //974: ReportError("aiString::data is invalid: the terminal zero is at a wrong offset");
  173. //979: ReportError("aiString::data is invalid. There is no terminal character");
  174. }