-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
make_ellipsoid_mesh_test.cc
65 lines (56 loc) · 2.24 KB
/
make_ellipsoid_mesh_test.cc
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
#include "drake/geometry/proximity/make_ellipsoid_mesh.h"
#include <gtest/gtest.h>
#include "drake/geometry/proximity/tessellation_strategy.h"
#include "drake/geometry/shape_specification.h"
namespace drake {
namespace geometry {
namespace internal {
namespace {
// Correctness of MakeEllipsoidVolumeMesh() depends on MakeSphereVolumeMesh().
// This is a smoke test only.
GTEST_TEST(MakeEllipsoidMeshTest, MakeEllipsoidVolumeMesh) {
// For an ellipsoid with bounding box 10cm x 16cm x 6cm, its semi-axes are
// 5cm, 8cm, and 3cm long.
const Ellipsoid ellipsoid(0.05, 0.08, 0.03);
// Coarsest mesh for resolution_hint equals the length of the major
// axis 16cm. The coarsest mesh is an octahedron with 7 vertices and 8
// tetrahedra.
{
const auto coarse_mesh = MakeEllipsoidVolumeMesh<double>(
ellipsoid, 0.16, TessellationStrategy::kDenseInteriorVertices);
EXPECT_EQ(7, coarse_mesh.num_vertices());
EXPECT_EQ(8, coarse_mesh.num_elements());
}
// Cutting the resolution_hint in half from 16cm down to 8cm increases
// the number of tetrahedra by 8X.
{
const auto medium_mesh = MakeEllipsoidVolumeMesh<double>(
ellipsoid, 0.08, TessellationStrategy::kDenseInteriorVertices);
EXPECT_EQ(64, medium_mesh.num_elements());
}
}
// Correctness of MakeEllipsoidSurfaceMesh() depends on
// MakeEllipsoidVolumeMesh(). This is a smoke test only.
GTEST_TEST(MakeEllipsoidMeshTest, MakeEllipsoidSurfaceMesh) {
// For an ellipsoid with bounding box 10cm x 16cm x 6cm, its semi-axes are
// 5cm, 8cm, and 3cm long.
const Ellipsoid ellipsoid(0.05, 0.08, 0.03);
// Coarsest mesh for resolution_hint equals the length of the major
// axis 16cm. The coarsest mesh is an octahedron with 6 vertices and 8
// triangles.
{
const auto coarse_mesh = MakeEllipsoidSurfaceMesh<double>(ellipsoid, 0.16);
EXPECT_EQ(6, coarse_mesh.num_vertices());
EXPECT_EQ(8, coarse_mesh.num_triangles());
}
// Cutting the resolution_hint in half from 16cm down to 8cm increases
// the number of triangles by 4X.
{
const auto medium_mesh = MakeEllipsoidSurfaceMesh<double>(ellipsoid, 0.08);
EXPECT_EQ(32, medium_mesh.num_triangles());
}
}
} // namespace
} // namespace internal
} // namespace geometry
} // namespace drake