File size: 3,105 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | // SPDX-License-Identifier: LGPL-2.1-or-later
#include <gtest/gtest.h>
#include <Mod/Mesh/App/Mesh.h>
#include <Mod/Mesh/App/Core/Grid.h>
#include <src/App/InitApplication.h>
class MeshTest: public ::testing::Test
{
protected:
static void SetUpTestSuite()
{
tests::initApplication();
}
};
// NOLINTBEGIN(cppcoreguidelines-*,readability-*)
TEST_F(MeshTest, TestDefault)
{
MeshCore::MeshKernel kernel;
Base::Vector3f p1 {0, 0, 0};
Base::Vector3f p2 {0, 0, 1};
Base::Vector3f p3 {0, 1, 0};
kernel.AddFacet(MeshCore::MeshGeomFacet(p1, p2, p3));
EXPECT_EQ(kernel.CountPoints(), 3);
EXPECT_EQ(kernel.CountEdges(), 3);
EXPECT_EQ(kernel.CountFacets(), 1);
}
TEST_F(MeshTest, TestGrid1OfPlanarMesh)
{
MeshCore::MeshKernel kernel;
Base::Vector3f p1 {0, 0, 0};
Base::Vector3f p2 {1, 0, 0};
Base::Vector3f p3 {0, 1, 0};
Base::Vector3f p4 {1, 1, 0};
kernel.AddFacet(MeshCore::MeshGeomFacet(p1, p2, p3));
kernel.AddFacet(MeshCore::MeshGeomFacet(p3, p2, p4));
MeshCore::MeshFacetGrid grid(kernel, 10);
unsigned long countX {};
unsigned long countY {};
unsigned long countZ {};
grid.GetCtGrids(countX, countY, countZ);
EXPECT_EQ(countX, 1);
EXPECT_EQ(countY, 1);
EXPECT_EQ(countZ, 1);
}
TEST_F(MeshTest, TestGrid2OfPlanarMesh)
{
MeshCore::MeshKernel kernel;
Base::Vector3f p1 {0, 0, 0};
Base::Vector3f p2 {1, 0, 0};
Base::Vector3f p3 {0, 1, 0};
Base::Vector3f p4 {1, 1, 0};
kernel.AddFacet(MeshCore::MeshGeomFacet(p1, p2, p3));
kernel.AddFacet(MeshCore::MeshGeomFacet(p3, p2, p4));
MeshCore::MeshFacetGrid grid(kernel);
unsigned long countX {};
unsigned long countY {};
unsigned long countZ {};
grid.GetCtGrids(countX, countY, countZ);
EXPECT_EQ(countX, 1);
EXPECT_EQ(countY, 1);
EXPECT_EQ(countZ, 1);
}
TEST_F(MeshTest, TestGrid1OfAlmostPlanarMesh)
{
MeshCore::MeshKernel kernel;
Base::Vector3f p1 {0, 0, 0};
Base::Vector3f p2 {1, 0, 0};
Base::Vector3f p3 {0, 1, 0};
Base::Vector3f p4 {1, 1, 1.0e-18F};
kernel.AddFacet(MeshCore::MeshGeomFacet(p1, p2, p3));
kernel.AddFacet(MeshCore::MeshGeomFacet(p3, p2, p4));
MeshCore::MeshFacetGrid grid(kernel, 10);
unsigned long countX {};
unsigned long countY {};
unsigned long countZ {};
grid.GetCtGrids(countX, countY, countZ);
EXPECT_EQ(countX, 1);
EXPECT_EQ(countY, 1);
EXPECT_EQ(countZ, 1);
}
TEST_F(MeshTest, TestGrid2OfAlmostPlanarMesh)
{
MeshCore::MeshKernel kernel;
Base::Vector3f p1 {0, 0, 0};
Base::Vector3f p2 {1, 0, 0};
Base::Vector3f p3 {0, 1, 0};
Base::Vector3f p4 {1, 1, 1.0e-18F};
kernel.AddFacet(MeshCore::MeshGeomFacet(p1, p2, p3));
kernel.AddFacet(MeshCore::MeshGeomFacet(p3, p2, p4));
MeshCore::MeshFacetGrid grid(kernel);
unsigned long countX {};
unsigned long countY {};
unsigned long countZ {};
grid.GetCtGrids(countX, countY, countZ);
EXPECT_EQ(countX, 1);
EXPECT_EQ(countY, 1);
EXPECT_EQ(countZ, 1);
}
// NOLINTEND(cppcoreguidelines-*,readability-*)
|