hyporo-cpp/source/hpr/csg/tests/csg-test.cpp

24 lines
690 B
C++
Raw Normal View History

2022-11-18 21:50:49 +05:00
#include <gtest/gtest.h>
2022-12-06 23:52:49 +05:00
#include "../../csg.hpp"
2022-11-18 21:50:49 +05:00
TEST(csgTest, Shape)
{
using namespace hpr;
double radius = 1.;
double volume = 4. / 3. * PI;
auto sphere = csg::sphere({0, 0, 0}, radius);
EXPECT_TRUE(equal(sphere.volume(), volume, 1e-6));
auto box = csg::box({0, 0, 0}, 1, 1, 1);
2022-12-13 23:09:36 +05:00
EXPECT_TRUE(equal(box.volume(), 1.));
2022-11-18 21:50:49 +05:00
auto edge = csg::Edge();
int n = 0;
for (auto& face : box.subShapes(csg::Shape::Type::Face))
{
std::stringstream name;
name << "face" << n;
csg::Face(face).label(name.str());
++n;
}
box.scale(box.center(), 5);
EXPECT_EQ(box.subShapes(csg::Shape::Type::Face)[2].label(), "face2");
}