Loading include/csg_types.hpp +6 −12 Original line number Diff line number Diff line Loading @@ -58,12 +58,9 @@ private: public: std::optional<std::string> name; Polyhedron(const std::vector<std::vector<double>> &points, const std::vector<std::vector<double>> &faces) { for (const auto &pt : points) { assert(pt.size() == 3); m_points.push_back({pt[0], pt[1], pt[2]}); } Polyhedron(const std::vector<std::tuple<double, double, double>> &points, const std::vector<std::vector<double>> &faces) : m_points(points) { for (const auto &f : faces) { m_faces.push_back(std::vector<unsigned int>(f.begin(), f.end())); } Loading @@ -83,12 +80,9 @@ private: public: std::optional<std::string> name; Polygon(const std::vector<std::vector<double>> &points, const std::vector<double> &path) { for (const auto &pt : points) { assert(pt.size() == 2); m_points.push_back({pt[0], pt[1]}); } Polygon(const std::vector<std::tuple<double, double>> &points, const std::vector<double> &path) : m_points(points) { for (const auto &p : path) { m_path.push_back((unsigned int)(p)); } Loading src/csg/parser.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -586,9 +586,16 @@ template <> struct action<polygon> { std::stringstream ss(in.string()); auto &curr_attr = st.curr_attrs.back(); auto points = auto points_raw = std::get<std::vector<std::vector<double>>>(curr_attr["points"]); std::vector<std::tuple<double, double>> points; for (const auto &pt : points_raw) { if (pt.size() != 2) throw csg::Exception("action<polygon>", "pt.size() != 2"); points.push_back({pt[0], pt[1]}); } std::vector<std::vector<double>> paths = {{}}; if (std::holds_alternative<std::string>(curr_attr["paths"])) { auto paths_str = std::get<std::string>(curr_attr["paths"]); Loading Loading @@ -620,10 +627,17 @@ template <> struct action<polyhedron> { std::stringstream ss(in.string()); auto &curr_attr = st.curr_attrs.back(); auto points = auto points_raw = std::get<std::vector<std::vector<double>>>(curr_attr["points"]); auto faces = std::get<std::vector<std::vector<double>>>(curr_attr["faces"]); std::vector<std::tuple<double, double, double>> points; for (const auto &pt : points_raw) { if (pt.size() != 3) throw csg::Exception("action<polyhedron>", "pt.size() != 3"); points.push_back({pt[0], pt[1], pt[2]}); } csg::Polyhedron polyh(points, faces); polyh.name = get_name(curr_attr); Loading Loading
include/csg_types.hpp +6 −12 Original line number Diff line number Diff line Loading @@ -58,12 +58,9 @@ private: public: std::optional<std::string> name; Polyhedron(const std::vector<std::vector<double>> &points, const std::vector<std::vector<double>> &faces) { for (const auto &pt : points) { assert(pt.size() == 3); m_points.push_back({pt[0], pt[1], pt[2]}); } Polyhedron(const std::vector<std::tuple<double, double, double>> &points, const std::vector<std::vector<double>> &faces) : m_points(points) { for (const auto &f : faces) { m_faces.push_back(std::vector<unsigned int>(f.begin(), f.end())); } Loading @@ -83,12 +80,9 @@ private: public: std::optional<std::string> name; Polygon(const std::vector<std::vector<double>> &points, const std::vector<double> &path) { for (const auto &pt : points) { assert(pt.size() == 2); m_points.push_back({pt[0], pt[1]}); } Polygon(const std::vector<std::tuple<double, double>> &points, const std::vector<double> &path) : m_points(points) { for (const auto &p : path) { m_path.push_back((unsigned int)(p)); } Loading
src/csg/parser.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -586,9 +586,16 @@ template <> struct action<polygon> { std::stringstream ss(in.string()); auto &curr_attr = st.curr_attrs.back(); auto points = auto points_raw = std::get<std::vector<std::vector<double>>>(curr_attr["points"]); std::vector<std::tuple<double, double>> points; for (const auto &pt : points_raw) { if (pt.size() != 2) throw csg::Exception("action<polygon>", "pt.size() != 2"); points.push_back({pt[0], pt[1]}); } std::vector<std::vector<double>> paths = {{}}; if (std::holds_alternative<std::string>(curr_attr["paths"])) { auto paths_str = std::get<std::string>(curr_attr["paths"]); Loading Loading @@ -620,10 +627,17 @@ template <> struct action<polyhedron> { std::stringstream ss(in.string()); auto &curr_attr = st.curr_attrs.back(); auto points = auto points_raw = std::get<std::vector<std::vector<double>>>(curr_attr["points"]); auto faces = std::get<std::vector<std::vector<double>>>(curr_attr["faces"]); std::vector<std::tuple<double, double, double>> points; for (const auto &pt : points_raw) { if (pt.size() != 3) throw csg::Exception("action<polyhedron>", "pt.size() != 3"); points.push_back({pt[0], pt[1], pt[2]}); } csg::Polyhedron polyh(points, faces); polyh.name = get_name(curr_attr); Loading