Skip to content

Commit

Permalink
Add unit test for X3D IndexedLineSet
Browse files Browse the repository at this point in the history
Unit test for issue assimp#3101

Thanks to @mvidiassov for the X3D test file!
  • Loading branch information
andre-schulz authored and kimkulling committed Jan 9, 2024
1 parent 9d71a27 commit 74af43f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/models/X3D/IndexedLineSet.x3d
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions test/unit/utX3DImportExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -59,3 +60,16 @@ class utX3DImportExport : public AbstractImportExportBase {
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);
}
}

0 comments on commit 74af43f

Please sign in to comment.