Browse Source

Add unit test for X3D IndexedLineSet

Unit test for issue #3101

Thanks to @mvidiassov for the X3D test file!
Andre Schulz 1 year ago
parent
commit
74af43f655
2 changed files with 33 additions and 0 deletions
  1. 19 0
      test/models/X3D/IndexedLineSet.x3d
  2. 14 0
      test/unit/utX3DImportExport.cpp

+ 19 - 0
test/models/X3D/IndexedLineSet.x3d

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
+<X3D profile='Interchange' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
+  <head>
+  </head>
+  <Scene>
+    <WorldInfo title='vertices.x3d'/>
+    <NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
+    <Viewpoint description='vertices' position='0 0 10'/>
+    <Shape>
+      <Appearance>
+        <Material emissiveColor='1 0 0'/>
+      </Appearance>
+      <IndexedLineSet coordIndex='0 1 2 3 0 -1'>
+        <Coordinate point='1 0 0 1 1 0 0 1 0 0 0 0'/>
+      </IndexedLineSet>
+    </Shape>
+  </Scene>
+</X3D>

+ 14 - 0
test/unit/utX3DImportExport.cpp

@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assimp/postprocess.h>
 #include <assimp/Importer.hpp>
+#include <assimp/scene.h>
 
 using namespace Assimp;
 
@@ -59,3 +60,16 @@ public:
 TEST_F(utX3DImportExport, importX3DFromFileTest) {
     EXPECT_TRUE(importerTest());
 }
+
+TEST_F(utX3DImportExport, importX3DIndexedLineSet) {
+    Assimp::Importer importer;
+    const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/IndexedLineSet.x3d", aiProcess_ValidateDataStructure);
+    ASSERT_NE(nullptr, scene);
+    ASSERT_EQ(scene->mNumMeshes, 1u);
+    ASSERT_EQ(scene->mMeshes[0]->mNumFaces, 4u);
+    ASSERT_EQ(scene->mMeshes[0]->mPrimitiveTypes, aiPrimitiveType_LINE);
+    ASSERT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
+    for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; i++) {
+        ASSERT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
+    }
+}