Commit a9aca05c authored by Deepak Rangarajan's avatar Deepak Rangarajan Committed by Mark Meredith
Browse files

Fix bug when empty group is followed by mulmat

parent 415c23ac
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ template <> struct action<mulmat<Dimension::D2>> {
    for (const auto &curr_obj : st.current_2d_group) {
      mulmat.group.objs.push_back(curr_obj);
    }
    st.current_2d_group.clear();
    st.current_2d_objs.back().push_back(mulmat);
    st.current_matrices.pop_back();
  }
@@ -435,6 +436,7 @@ template <> struct action<mulmat<Dimension::D3>> {
    for (const auto &curr_obj : st.current_3d_group) {
      mulmat.group.objs.push_back(curr_obj);
    }
    st.current_3d_group.clear();
    st.current_3d_objs.back().push_back(mulmat);
    st.current_matrices.pop_back();
  }
+12 −0
Original line number Diff line number Diff line
@@ -119,3 +119,15 @@ multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0.1], [0, 0, 1, 0], [0, 0, 0, 1]]) {
  CHECK(cone.radius2 == 0.4);
  CHECK(cone.center == false);
}

TEST_CASE("mulmat and empty group", "[csg]") {
  auto st = *csg::parse_csg(R"(
multmatrix([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) {
   cylinder($fn = 0, $fa = 12, $fs = 2, h = 200, r1 = 7, r2 = 7, center = false);
}
group();
)");
  auto un = std::get<csg::Union3D>(st.top.objs.at(1));

  CHECK(un.objs.size() == 0);
}