File size: 1,497 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: LGPL-2.1-or-later

#include <gtest/gtest.h>
#include <Base/FileInfo.h>
#include <Mod/Mesh/App/Core/IO/Reader3MF.h>
#include <Mod/Mesh/App/Core/IO/ReaderOBJ.h>
#include <xercesc/util/PlatformUtils.hpp>
#include <zipios++/fcoll.h>

class ImporterTest: public ::testing::Test
{
protected:
    static void SetUpTestSuite()
    {
        XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
    }
};

// NOLINTBEGIN(cppcoreguidelines-*,readability-*)
TEST_F(ImporterTest, Test3MF)
{
    std::string file(DATADIR);
    file.append("/tests/mesh.3mf");

    MeshCore::Reader3MF reader(file);
    EXPECT_EQ(reader.Load(), true);

    std::vector<int> ids = reader.GetMeshIds();
    std::sort(ids.begin(), ids.end());

    EXPECT_EQ(ids.size(), 2);

    const MeshCore::MeshKernel& mesh1 = reader.GetMesh(ids[0]);
    EXPECT_EQ(mesh1.CountPoints(), 8);
    EXPECT_EQ(mesh1.CountEdges(), 18);
    EXPECT_EQ(mesh1.CountFacets(), 12);

    const MeshCore::MeshKernel& mesh2 = reader.GetMesh(ids[1]);
    EXPECT_EQ(mesh2.CountPoints(), 652);
    EXPECT_EQ(mesh2.CountEdges(), 1950);
    EXPECT_EQ(mesh2.CountFacets(), 1300);
}

TEST_F(ImporterTest, TestOBJ)
{
    std::string file(DATADIR);
    file.append("/tests/mesh.obj");

    MeshCore::MeshKernel kernel;
    MeshCore::ReaderOBJ reader(kernel, nullptr);
    EXPECT_EQ(reader.Load(file), true);

    EXPECT_EQ(kernel.CountPoints(), 8);
    EXPECT_EQ(kernel.CountFacets(), 12);
}
// NOLINTEND(cppcoreguidelines-*,readability-*)