Commit 32fd9998 authored by Deepak Rangarajan's avatar Deepak Rangarajan
Browse files

Merge branch 'mwm/fix_warnings' into 'master'

Fix warnings

See merge request exa/mfix-parser!19
parents 8ba483f0 88483f84
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -131,7 +131,8 @@ double signed_distance_3d(const Cylinder &cyl, double xx, double yy,
double signed_distance_3d(const LinearExtrude &lin_ext, double xx, double yy,
                          double zz) {
  // TODO: support height, center and twist
  return signed_distance_2d(lin_ext.group, xx, yy);
  double sign_z = (0 <= zz && zz <= lin_ext.height) ? 1.0 : 1.0; // unused zz warning workaround
  return sign_z*signed_distance_2d(lin_ext.group, xx, yy);
}

double signed_distance_3d(const RotateExtrude &rot_ext, double xx, double yy,
+29 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ template <typename Rule> struct action {};
template <> struct action<L_BLK<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    // std::cout << " { " << std::endl;
    std::vector<csg::Type3D> new_3d_group;
    st.current_3d_objs.push_back(new_3d_group);
@@ -188,6 +189,7 @@ template <> struct action<L_BLK<Dimension::D3>> {
template <> struct action<L_BLK<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    std::vector<csg::Type2D> new_2d_group;
    st.current_2d_objs.push_back(new_2d_group);
  }
@@ -196,6 +198,7 @@ template <> struct action<L_BLK<Dimension::D2>> {
template <> struct action<R_BLK<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    // std::cout << " } " << std::endl;
    st.current_3d_group.clear();
    for (auto obj : st.current_3d_objs.back()) {
@@ -208,6 +211,7 @@ template <> struct action<R_BLK<Dimension::D3>> {
template <> struct action<R_BLK<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.current_2d_group.clear();
    for (auto obj : st.current_2d_objs.back()) {
      st.current_2d_group.push_back(obj);
@@ -229,6 +233,7 @@ template <> struct action<vector_cell> {
template <> struct action<matrix> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.current_matrices.push_back(st.current_matrix);
    st.current_matrix.clear();
  }
@@ -237,6 +242,7 @@ template <> struct action<matrix> {
template <> struct action<attr_list> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.curr_attrs.push_back(st.curr_attr);
    st.curr_attr.clear();
  }
@@ -245,6 +251,7 @@ template <> struct action<attr_list> {
template <> struct action<row> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.current_matrix.push_back(st.current_vec);
    st.current_vec.clear();
  }
@@ -269,6 +276,7 @@ void add_group_3d(parser_state &st) {
template <> struct action<group<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_3d(st);
  }
};
@@ -276,6 +284,7 @@ template <> struct action<group<Dimension::D3>> {
template <> struct action<group<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_2d(st);
  }
};
@@ -283,6 +292,7 @@ template <> struct action<group<Dimension::D2>> {
template <> struct action<render> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_3d(st);
  }
};
@@ -290,6 +300,7 @@ template <> struct action<render> {
template <> struct action<colorgroup> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_3d(st);
  }
};
@@ -297,6 +308,7 @@ template <> struct action<colorgroup> {
template <> struct action<bool_union<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_3d(st);
  }
};
@@ -304,6 +316,7 @@ template <> struct action<bool_union<Dimension::D3>> {
template <> struct action<bool_union<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    add_group_2d(st);
  }
};
@@ -311,6 +324,7 @@ template <> struct action<bool_union<Dimension::D2>> {
template <> struct action<bool_intersection<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto csg_in = csg::Intersection3D();
    for (const auto &curr_obj : st.current_3d_group) {
      csg_in.objs.push_back(curr_obj);
@@ -322,6 +336,7 @@ template <> struct action<bool_intersection<Dimension::D3>> {
template <> struct action<bool_intersection<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto csg_in = csg::Intersection2D();
    for (const auto &curr_obj : st.current_2d_group) {
      csg_in.objs.push_back(curr_obj);
@@ -333,6 +348,7 @@ template <> struct action<bool_intersection<Dimension::D2>> {
template <> struct action<bool_diff<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto csg_diff = csg::Difference3D();
    for (auto it = st.current_3d_group.begin(); it != st.current_3d_group.end();
         ++it) {
@@ -349,6 +365,7 @@ template <> struct action<bool_diff<Dimension::D3>> {
template <> struct action<bool_diff<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto csg_diff = csg::Difference2D();
    for (auto it = st.current_2d_group.begin(); it != st.current_2d_group.end();
         ++it) {
@@ -365,6 +382,7 @@ template <> struct action<bool_diff<Dimension::D2>> {
template <> struct action<mulmat<Dimension::D2>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto mulmat = csg::Mulmatrix2D();
    auto mat = st.current_matrices.back();
    // clang-format off
@@ -388,6 +406,7 @@ template <> struct action<mulmat<Dimension::D2>> {
template <> struct action<mulmat<Dimension::D3>> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto mulmat = csg::Mulmatrix3D();
    auto mat = st.current_matrices.back();
    // clang-format off
@@ -413,6 +432,7 @@ template <> struct action<mulmat<Dimension::D3>> {
template <> struct action<extrude_lin> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto lin_ext = csg::LinearExtrude();
    auto &curr_attr = st.curr_attrs.back();
    lin_ext.height = std::get<double>(curr_attr["height"]);
@@ -431,6 +451,7 @@ template <> struct action<extrude_lin> {
template <> struct action<extrude_rot> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto rot_ext = csg::RotateExtrude();
    auto &curr_attr = st.curr_attrs.back();
    rot_ext.angle = std::get<double>(curr_attr["angle"]);
@@ -456,6 +477,7 @@ std::optional<std::string> get_name(AttrMap curr_attr) {
template <> struct action<cube> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    csg::Cube cub;
    auto &curr_attr = st.curr_attrs.back();
    auto size = std::get<std::vector<double>>(curr_attr["size"]);
@@ -471,6 +493,7 @@ template <> struct action<cube> {
template <> struct action<cylinder> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    auto &curr_attr = st.curr_attrs.back();
    if (curr_attr.count("r")) {
      // proper cylinder
@@ -503,6 +526,7 @@ template <> struct action<cylinder> {
template <> struct action<sphere> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    csg::Sphere sph;
    auto &curr_attr = st.curr_attrs.back();
    sph.name = get_name(curr_attr);
@@ -516,6 +540,7 @@ template <> struct action<sphere> {
template <> struct action<circle> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    csg::Circle cir;
    auto &curr_attr = st.curr_attrs.back();
    cir.name = get_name(curr_attr);
@@ -529,6 +554,7 @@ template <> struct action<circle> {
template <> struct action<square> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    csg::Square sq;
    auto &curr_attr = st.curr_attrs.back();
    auto size = std::get<std::vector<double>>(curr_attr["size"]);
@@ -572,6 +598,7 @@ template <> struct action<double_> {
template <> struct action<true_literal> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.curr_attr[st.current_name] = true;
  }
};
@@ -579,6 +606,7 @@ template <> struct action<true_literal> {
template <> struct action<false_literal> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.curr_attr[st.current_name] = false;
  }
};
@@ -586,6 +614,7 @@ template <> struct action<false_literal> {
template <> struct action<vector_attr> {
  template <typename Input>
  static void apply(const Input &in, parser_state &st) {
    std::stringstream ss(in.string());
    st.curr_attr[st.current_name] = st.current_vec;
    st.current_vec.clear();
  }
+4 −2
Original line number Diff line number Diff line
lib_csg_parser = static_library(
lib_csg_parser = library(
  'csg-parser',
  'impl/csg.cpp',
  'impl/levelset_3d.cpp',
@@ -7,4 +7,6 @@ lib_csg_parser = static_library(
  include_directories: tao_inc,
  install : true)

if get_option('cpp_std')=='c++2a'
  subdir('tests')
endif
+6 −6
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@ namespace {

TEST_CASE("Union3D", "[Levelset Boolean]") {
  // Create a union of a cube of size 12 and a sphere of radius 8
  csg::Cube my_cub{.size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.radius = 8};
  csg::Cube my_cub{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};

  auto my_union = csg::Union3D();
  my_union.objs.push_back(my_cub);
@@ -35,8 +35,8 @@ TEST_CASE("Union3D", "[Levelset Boolean]") {

TEST_CASE("Intersection3D", "[Levelset Boolean]") {
  // Create an of a cube of size 12 and a sphere of radius 8
  csg::Cube my_cub{.size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.radius = 8};
  csg::Cube my_cub{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};

  auto my_in = csg::Intersection3D();
  my_in.objs.push_back(my_cub);
@@ -61,8 +61,8 @@ TEST_CASE("Intersection3D", "[Levelset Boolean]") {

TEST_CASE("Difference3D", "[Levelset Boolean]") {
  // Create an of a cube of size 12 and remove a sphere of radius 8
  csg::Cube my_cub{.size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.radius = 8};
  csg::Cube my_cub{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};

  csg::Union3D my_union;
  my_union.objs.push_back(my_sph);
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ namespace {
TEST_CASE("two shape linear", "[Levelset Extrude]") {
  auto my_lin_ext = csg::LinearExtrude();

  csg::Circle my_cir{.radius = 1};
  csg::Circle my_cir{.name = std::nullopt, .radius = 1};
  my_lin_ext.group.objs.push_back(my_cir);

  auto my_mat = csg::Mulmatrix2D();
@@ -40,7 +40,7 @@ TEST_CASE("two shape linear", "[Levelset Extrude]") {
TEST_CASE("simple torus", "[Levelset Extrude]") {
  auto my_rot_ext = csg::RotateExtrude();

  csg::Circle my_cir{.radius = 1};
  csg::Circle my_cir{.name = std::nullopt, .radius = 1};
  auto my_mat = csg::Mulmatrix2D();
  my_mat.rotation[0] = std::array<double, 2>{{1, 0}};
  my_mat.rotation[1] = std::array<double, 2>{{0, 1}};
Loading