hyporo-cpp/source/hpr/csg/tests/csg-test.cpp
2023-04-10 22:01:56 +05:00

25 lines
715 B
C++

#include <gtest/gtest.h>
#include <hpr/csg.hpp>
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);
EXPECT_TRUE(equal(box.volume(), 1.));
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");
}