diff --git a/src/csg/tests/parser/boolean.t.cpp b/src/csg/tests/parser/boolean.t.cpp index 6cb885bea85cff116d3ce0e3e6a2c7d02d0b8d5d..8a563511a876d204aaa477c578d00cf0fea4201b 100644 --- a/src/csg/tests/parser/boolean.t.cpp +++ b/src/csg/tests/parser/boolean.t.cpp @@ -93,11 +93,29 @@ circle(size = [1,2], center=true); CHECK(st == nullptr); } -TEST_CASE("sphere and cylinder union", "[csg]") { - auto st = csg::parse_csg(R"( +TEST_CASE("sphere and mulmat cylinder", "[csg]") { + auto st = *csg::parse_csg(R"( sphere(r = 0.1); multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0.1], [0, 0, 1, 0], [0, 0, 0, 1]]) { - cylinder(h = 0.1, r1 = 0.1, r2 = 0.1, center = false); + cylinder(h = 0.2, r1 = 0.3, r2 = 0.4, center = false); } )"); + + CHECK(st.top.objs.size() == 2); + + auto sph = std::get(st.top.objs.at(0)); + auto mm = std::get(st.top.objs.at(1)); + + CHECK(sph.radius == 0.1); + CHECK(mm.group.objs.size() == 1); + CHECK(mm.translation == std::array({0.5, 0.1, 0})); + CHECK(mm.rotation()[0] == std::array({1, 0, 0})); + CHECK(mm.rotation()[1] == std::array({0, 1, 0})); + CHECK(mm.rotation()[2] == std::array({0, 0, 1})); + + auto cone = std::get(mm.group.objs.at(0)); + CHECK(cone.height == 0.2); + CHECK(cone.radius1 == 0.3); + CHECK(cone.radius2 == 0.4); + CHECK(cone.center == false); } diff --git a/src/csg/tests/parser/transform.t.cpp b/src/csg/tests/parser/transform.t.cpp index 3f042ffacdb1102663f253f24a7a4b43654c1949..e7fa6bca7d43b9070d4255f38b23323f57c1c378 100644 --- a/src/csg/tests/parser/transform.t.cpp +++ b/src/csg/tests/parser/transform.t.cpp @@ -27,6 +27,10 @@ multmatrix( )"); auto mat = std::get(st.top.objs.back()); CHECK(mat.group.objs.size() == 1); + CHECK(mat.translation == std::array({0.0020, 0.0005, 0.0005})); + CHECK(mat.rotation()[0] == std::array({1, 0, 0})); + CHECK(mat.rotation()[1] == std::array({0, 1, 0})); + CHECK(mat.rotation()[2] == std::array({0, 0, 1})); auto cyl = std::get(mat.group.objs.at(0)); CHECK(cyl.height == 2); CHECK(cyl.radius == 10); @@ -47,6 +51,10 @@ multmatrix( } )"); auto mat = std::get(st.top.objs.back()); + CHECK(mat.translation == std::array({0.0020, 0.0005, 0.0005})); + CHECK(mat.rotation()[0] == std::array({1, 0, 0})); + CHECK(mat.rotation()[1] == std::array({0, 1, 0})); + CHECK(mat.rotation()[2] == std::array({0, 0, 1})); auto cyl = std::get(mat.group.objs.at(0)); auto sph = std::get(mat.group.objs.at(1)); CHECK(cyl.height == 2); @@ -80,6 +88,10 @@ multmatrix( } )"); auto mat = std::get(st.top.objs.at(0)); + CHECK(mat.translation == std::array({0.0020, 0.0005, 0.0005})); + CHECK(mat.rotation()[0] == std::array({1, 0, 0})); + CHECK(mat.rotation()[1] == std::array({0, 1, 0})); + CHECK(mat.rotation()[2] == std::array({0, 0, 1})); auto cyl = std::get(mat.group.objs.at(0)); auto sph = std::get(mat.group.objs.at(1)); CHECK(cyl.height == 2); @@ -87,6 +99,10 @@ multmatrix( CHECK(sph.radius == 11); auto mat2 = std::get(st.top.objs.at(1)); + CHECK(mat2.translation == std::array({0.0020, 0.0005, 0.0005})); + CHECK(mat2.rotation()[0] == std::array({1, 0, 0})); + CHECK(mat2.rotation()[1] == std::array({0, 1, 0})); + CHECK(mat2.rotation()[2] == std::array({0, 0, 1})); auto cube = std::get(mat2.group.objs.at(0)); auto cone = std::get(mat2.group.objs.at(1)); auto [XX, YY, ZZ] = cube.size; @@ -117,6 +133,10 @@ multmatrix( auto cyl = std::get(st.top.objs.at(0)); auto sph = std::get(st.top.objs.at(1)); auto mat = std::get(st.top.objs.at(2)); + CHECK(mat.translation == std::array({0.0020, 0.0005, 0.0005})); + CHECK(mat.rotation()[0] == std::array({1, 0, 0})); + CHECK(mat.rotation()[1] == std::array({0, 1, 0})); + CHECK(mat.rotation()[2] == std::array({0, 0, 1})); CHECK(cyl.height == 2); CHECK(cyl.radius == 10); CHECK(sph.radius == 11);