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

Remove designator aggregate intialization so code compiles with C++17

parent b7563a5a
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ build-img:
            -DCMAKE_MODULE_PATH=$PWD/build
            -DCMAKE_BUILD_TYPE=Debug
            -DCSG_CGAL_ENABLED=${ENABLE_CGAL}
            -DCMAKE_CXX_FLAGS="-pedantic-errors"
    - cmake --build build --target unit_tests_csg
    - cd build
    - ctest
+18 −6
Original line number Diff line number Diff line
@@ -9,8 +9,12 @@ 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{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};
  csg::Cube my_cub;
  my_cub.size = {12, 12, 12};
  my_cub.center = true;

  csg::Sphere my_sph;
  my_sph.radius = 8;

  auto my_union = csg::Union3D();
  my_union.objs.push_back(my_cub);
@@ -35,8 +39,12 @@ 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{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};
  csg::Cube my_cub;
  my_cub.size = {12, 12, 12};
  my_cub.center = true;

  csg::Sphere my_sph;
  my_sph.radius = 8;

  auto my_in = csg::Intersection3D();
  my_in.objs.push_back(my_cub);
@@ -61,8 +69,12 @@ 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{.name = std::nullopt, .size = {12, 12, 12}, .center = true};
  csg::Sphere my_sph{.name = std::nullopt, .radius = 8};
  csg::Cube my_cub;
  my_cub.size = {12, 12, 12};
  my_cub.center = true;

  csg::Sphere my_sph;
  my_sph.radius = 8;

  csg::Union3D my_union;
  my_union.objs.push_back(my_sph);
+7 −3
Original line number Diff line number Diff line
@@ -24,8 +24,12 @@ TEST_CASE("Empty Difference3D", "[Levelset Boolean]") {

TEST_CASE("Empty Difference2D", "[Levelset Boolean]") {
  double height = 100, radius = 10;
  auto my_lin_ext = csg::LinearExtrude{
      .height = 100, .center = false, .scale = {1, 1}, .group = csg::Union2D()};
  csg::LinearExtrude my_lin_ext;
  my_lin_ext.height = 100;
  my_lin_ext.center = false;
  my_lin_ext.scale = {1, 1};
  my_lin_ext.group = csg::Union2D();

  auto my_diff = csg::Difference2D();

  my_lin_ext.center = false;
@@ -42,4 +46,4 @@ TEST_CASE("Empty Difference2D", "[Levelset Boolean]") {
  CHECK_FALSE(0 < my_levelset(9, 0, 0));
}

}
} // namespace
+46 −21
Original line number Diff line number Diff line
@@ -8,9 +8,14 @@ namespace {

TEST_CASE("linear", "[Levelset Extrude]") {
  double height = 100, radius = 10;
  auto my_lin_ext = csg::LinearExtrude{
      .height = 100, .center = false, .scale = {1, 1}, .group = csg::Union2D()};
  csg::Circle my_cir{.name = std::nullopt, .radius = radius};
  csg::LinearExtrude my_lin_ext;
  my_lin_ext.height = 100;
  my_lin_ext.center = false;
  my_lin_ext.scale = {1, 1};
  my_lin_ext.group = csg::Union2D();

  csg::Circle my_cir;
  my_cir.radius = radius;

  SECTION("Not centered") {
    my_lin_ext.center = false;
@@ -100,10 +105,15 @@ TEST_CASE("linear", "[Levelset Extrude]") {
}

TEST_CASE("two shape linear extrude", "[Levelset Extrude]") {
  auto my_lin_ext = csg::LinearExtrude{
      .height = 100, .center = true, .scale = {1, 1}, .group = csg::Union2D()};
  csg::LinearExtrude my_lin_ext;
  my_lin_ext.height = 100;
  my_lin_ext.center = true;
  my_lin_ext.scale = {1, 1};
  my_lin_ext.group = csg::Union2D();

  csg::Circle my_cir;
  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({{1, 0}}, {{0, 1}});
@@ -133,9 +143,13 @@ TEST_CASE("two shape linear extrude", "[Levelset Extrude]") {
}

TEST_CASE("simple torus", "[Levelset Extrude]") {
  auto my_rot_ext = csg::RotateExtrude{.angle = 360, .group = csg::Union2D()};
  csg::RotateExtrude my_rot_ext;
  my_rot_ext.angle = 360;
  my_rot_ext.group = csg::Union2D();

  csg::Circle my_cir;
  my_cir.radius = 1;

  csg::Circle my_cir{.name = std::nullopt, .radius = 1};
  auto my_mat = csg::Mulmatrix2D({{1, 0}}, {{0, 1}});
  my_mat.translation = {2, 0};
  my_mat.group.objs.push_back(my_cir);
@@ -166,8 +180,11 @@ TEST_CASE("Linear extrude of a triangle with hole", "[Levelset Primitives]") {
  double ht = 100.0, outer = 100.0, inner = 80.0;
  double thick = outer - inner;

  auto my_lin_ext = csg::LinearExtrude{
      .height = ht, .center = true, .scale = {1, 1}, .group = csg::Union2D()};
  csg::LinearExtrude my_lin_ext;
  my_lin_ext.height = ht;
  my_lin_ext.center = true;
  my_lin_ext.scale = {1, 1};
  my_lin_ext.group = csg::Union2D();

  // A 100 x 100 right triangle with a 80 x 80 hole formed by using a polygon
  // and extrude
@@ -190,9 +207,9 @@ TEST_CASE("Linear extrude of a triangle with hole", "[Levelset Primitives]") {
  csg::Union2D my_union;
  my_union.objs.push_back(my_inner_tri);

  auto my_diff = csg::Difference2D{
      .first_obj = std::make_shared<csg::Type2D>(my_outer_tri),
      .next_objs = csg::Union2D(my_union)};
  csg::Difference2D my_diff;
  my_diff.first_obj = std::make_shared<csg::Type2D>(my_outer_tri);
  my_diff.next_objs = csg::Union2D(my_union);

  my_lin_ext.group.objs.push_back(my_diff);

@@ -248,9 +265,13 @@ TEST_CASE("Linear extrude of a triangle with hole", "[Levelset Primitives]") {
#endif

TEST_CASE("sliced torus", "[Levelset Extrude]") {
  auto my_rot_ext = csg::RotateExtrude{.angle = 45, .group = csg::Union2D()};
  csg::RotateExtrude my_rot_ext;
  my_rot_ext.angle = 45;
  my_rot_ext.group = csg::Union2D();

  csg::Circle my_cir;
  my_cir.radius = 1;

  csg::Circle my_cir{.name = std::nullopt, .radius = 1};
  auto my_mat = csg::Mulmatrix2D({{1, 0}}, {{0, 1}});
  my_mat.translation = {2, 0};
  my_mat.group.objs.push_back(my_cir);
@@ -283,12 +304,16 @@ TEST_CASE("sliced torus", "[Levelset Extrude]") {

TEST_CASE("linear with twist", "[Levelset Extrude]") {
  double height = 10, radius = 1;
  auto my_lin_ext = csg::LinearExtrude{.height = height,
                                       .center = false,
                                       .scale = {1, 1},
                                       .twist = 320,
                                       .group = csg::Union2D()};
  csg::Circle my_cir{.name = std::nullopt, .radius = radius};
  csg::LinearExtrude my_lin_ext;
  my_lin_ext.height = height;
  my_lin_ext.center = false;
  my_lin_ext.scale = {1, 1};
  my_lin_ext.twist = 320;
  my_lin_ext.group = csg::Union2D();

  csg::Circle my_cir;
  my_cir.radius = radius;

  auto my_mat = csg::Mulmatrix2D({{1, 0}}, {{0, 1}});
  my_mat.translation = {2, 0};
  my_mat.group.objs.push_back(my_cir);
+8 −3
Original line number Diff line number Diff line
@@ -9,8 +9,12 @@ namespace {

TEST_CASE("union internal flow", "[Levelset Internal Flow]") {
  // Create a union of a cube of size 12 and a sphere of 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::Cube my_cub;
  my_cub.size = {12, 12, 12};
  my_cub.center = true;

  csg::Sphere my_sph;
  my_sph.radius = 8;

  auto my_union = csg::Union3D();
  my_union.objs.push_back(my_cub);
@@ -37,7 +41,8 @@ TEST_CASE("union internal flow", "[Levelset Internal Flow]") {

TEST_CASE("CsgIF copy constructor", "[Levelset Internal Flow]") {

  csg::Sphere my_sph{.name = std::nullopt, .radius = 10};
  csg::Sphere my_sph;
  my_sph.radius = 10;

  auto my_tree = std::make_shared<csg::Tree>();
  my_tree->top.objs.push_back(my_sph);
Loading