Loading src/csg/parser.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ template <> struct action<attr_list> { std::stringstream ss(in.string()); st.curr_attrs.push_back(st.curr_attr); st.curr_attr.clear(); st.current_name.clear(); } }; Loading Loading @@ -510,6 +511,7 @@ template <> struct action<cylinder> { if (curr_attr.count("r1") || curr_attr.count("r2")) { std::cout << " ERROR: cannot specify both r and (r1 or r2); ambiguous " << std::endl; assert(false); } csg::Cylinder cyl; cyl.name = get_name(curr_attr); Loading Loading @@ -640,6 +642,7 @@ template <> struct action<string_literal> { std::stringstream ss(in.string()); std::string v; ss >> v; if (!st.current_name.empty()) st.curr_attr[st.current_name] = v; } }; Loading @@ -650,6 +653,7 @@ template <> struct action<double_> { std::stringstream ss(in.string()); double v; ss >> v; if (!st.current_name.empty()) st.curr_attr[st.current_name] = v; } }; Loading @@ -658,6 +662,7 @@ template <> struct action<true_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = true; } }; Loading @@ -666,6 +671,7 @@ template <> struct action<false_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = false; } }; Loading @@ -674,6 +680,7 @@ template <> struct action<undef_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = UNDEFINED_STR; } }; Loading @@ -682,6 +689,7 @@ template <> struct action<vector_attr> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = st.current_vec; st.current_vec.clear(); } Loading @@ -691,6 +699,7 @@ template <> struct action<matrix_attr> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = st.current_matrix; st.current_matrix.clear(); } Loading src/csg/tests/parser/boolean.t.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -92,3 +92,12 @@ circle(size = [1,2], center=true); )"); CHECK(st == nullptr); } TEST_CASE("sphere and cylinder union", "[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); } )"); } Loading
src/csg/parser.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ template <> struct action<attr_list> { std::stringstream ss(in.string()); st.curr_attrs.push_back(st.curr_attr); st.curr_attr.clear(); st.current_name.clear(); } }; Loading Loading @@ -510,6 +511,7 @@ template <> struct action<cylinder> { if (curr_attr.count("r1") || curr_attr.count("r2")) { std::cout << " ERROR: cannot specify both r and (r1 or r2); ambiguous " << std::endl; assert(false); } csg::Cylinder cyl; cyl.name = get_name(curr_attr); Loading Loading @@ -640,6 +642,7 @@ template <> struct action<string_literal> { std::stringstream ss(in.string()); std::string v; ss >> v; if (!st.current_name.empty()) st.curr_attr[st.current_name] = v; } }; Loading @@ -650,6 +653,7 @@ template <> struct action<double_> { std::stringstream ss(in.string()); double v; ss >> v; if (!st.current_name.empty()) st.curr_attr[st.current_name] = v; } }; Loading @@ -658,6 +662,7 @@ template <> struct action<true_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = true; } }; Loading @@ -666,6 +671,7 @@ template <> struct action<false_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = false; } }; Loading @@ -674,6 +680,7 @@ template <> struct action<undef_literal> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = UNDEFINED_STR; } }; Loading @@ -682,6 +689,7 @@ template <> struct action<vector_attr> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = st.current_vec; st.current_vec.clear(); } Loading @@ -691,6 +699,7 @@ template <> struct action<matrix_attr> { template <typename Input> static void apply(const Input &in, parser_state &st) { std::stringstream ss(in.string()); if (!st.current_name.empty()) st.curr_attr[st.current_name] = st.current_matrix; st.current_matrix.clear(); } Loading
src/csg/tests/parser/boolean.t.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -92,3 +92,12 @@ circle(size = [1,2], center=true); )"); CHECK(st == nullptr); } TEST_CASE("sphere and cylinder union", "[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); } )"); }