From 219e5be621fe575459bea3560a697b49acb06b7a Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 21 Aug 2019 15:23:53 +0200 Subject: [PATCH] Fixed small bug in OCC::interpolation_curve. --- doc/news/changes/minor/20190821LucaHeltai | 4 + source/opencascade/utilities.cc | 1 + .../interpolation_curve_boundary_02.cc | 80 +++++++++++++++++++ .../interpolation_curve_boundary_02.output | 48 +++++++++++ 4 files changed, 133 insertions(+) create mode 100644 doc/news/changes/minor/20190821LucaHeltai create mode 100644 tests/opencascade/interpolation_curve_boundary_02.cc create mode 100644 tests/opencascade/interpolation_curve_boundary_02.output diff --git a/doc/news/changes/minor/20190821LucaHeltai b/doc/news/changes/minor/20190821LucaHeltai new file mode 100644 index 0000000000..a6a164ceb0 --- /dev/null +++ b/doc/news/changes/minor/20190821LucaHeltai @@ -0,0 +1,4 @@ +Fixed: OpenCASCADE::interpolation_curve() returned a TopoDS_Shape that was not properly closed. This is +now fixed. +
+(Luca Heltai, 2019/08/21) diff --git a/source/opencascade/utilities.cc b/source/opencascade/utilities.cc index a679086eec..4ce89c1ae3 100644 --- a/source/opencascade/utilities.cc +++ b/source/opencascade/utilities.cc @@ -500,6 +500,7 @@ namespace OpenCASCADE Handle(Geom_BSplineCurve) bspline = bspline_generator.Curve(); TopoDS_Edge out_shape = BRepBuilderAPI_MakeEdge(bspline); + out_shape.Closed(closed); return out_shape; } diff --git a/tests/opencascade/interpolation_curve_boundary_02.cc b/tests/opencascade/interpolation_curve_boundary_02.cc new file mode 100644 index 0000000000..c32c3a6106 --- /dev/null +++ b/tests/opencascade/interpolation_curve_boundary_02.cc @@ -0,0 +1,80 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2014 - 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a Triangulation, interpolate its boundary points to a close +// smooth BSpline, and use that as a Boundary Descriptor with +// ArclengthProjectionLineManifold. + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../tests.h" + +using namespace OpenCASCADE; + +int +main() +{ + initlog(); + + // The curve passing through the vertices of the unit square. + std::vector> vertices; + vertices.emplace_back(Point<3>(0, 0, 0)); + vertices.emplace_back(Point<3>(1, 0, 0)); + vertices.emplace_back(Point<3>(1, 1, 0)); + vertices.emplace_back(Point<3>(0, 1, 0)); + auto shape = interpolation_curve(vertices, Point<3>(), true); + + // Create a boundary projector. + ArclengthProjectionLineManifold<2, 3> boundary_line(shape); + + // The unit square. + Triangulation<2, 3> tria; + GridGenerator::hyper_cube(tria); + + // Set the exterior boundary + tria.set_all_manifold_ids(0); + tria.set_manifold(0, boundary_line); + + // This is here to ignore the points created in the interior of the + // face. + tria.begin()->set_manifold_id(1); + + // We refine twice, and expect the outer points to end up on a + // smooth curve interpolating the square vertices. + tria.refine_global(2); + + // You can open the generated file with gmsh. + GridOut gridout; + gridout.write_msh(tria, deallog.get_file_stream()); +} diff --git a/tests/opencascade/interpolation_curve_boundary_02.output b/tests/opencascade/interpolation_curve_boundary_02.output new file mode 100644 index 0000000000..1ad7dd6d66 --- /dev/null +++ b/tests/opencascade/interpolation_curve_boundary_02.output @@ -0,0 +1,48 @@ + +$NOD +25 +1 0.00000 0.00000 0.00000 +2 1.00000 0.00000 0.00000 +3 0.00000 1.00000 0.00000 +4 1.00000 1.00000 0.00000 +5 0.515857 -0.251337 0.00000 +6 -0.311523 0.503182 0.00000 +7 1.14672 0.504074 0.00000 +8 0.505545 1.16406 0.00000 +9 0.482075 0.489998 0.00000 +10 0.242372 -0.158882 0.00000 +11 0.796991 -0.202770 0.00000 +12 -0.212866 0.218165 0.00000 +13 -0.219915 0.790006 0.00000 +14 1.10455 0.242844 0.00000 +15 1.12113 0.767092 0.00000 +16 0.242077 1.11495 0.00000 +17 0.771500 1.13535 0.00000 +18 0.498966 0.119330 0.00000 +19 0.493810 0.827030 0.00000 +20 0.0852760 0.496590 0.00000 +21 0.814399 0.497036 0.00000 +22 0.162520 0.177131 0.00000 +23 0.794945 0.174897 0.00000 +24 0.159668 0.798227 0.00000 +25 0.791898 0.798080 0.00000 +$ENDNOD +$ELM +16 +1 3 0 0 4 1 10 22 12 +2 3 0 0 4 10 5 18 22 +3 3 0 0 4 12 22 20 6 +4 3 0 0 4 22 18 9 20 +5 3 0 0 4 5 11 23 18 +6 3 0 0 4 11 2 14 23 +7 3 0 0 4 18 23 21 9 +8 3 0 0 4 23 14 7 21 +9 3 0 0 4 6 20 24 13 +10 3 0 0 4 20 9 19 24 +11 3 0 0 4 13 24 16 3 +12 3 0 0 4 24 19 8 16 +13 3 0 0 4 9 21 25 19 +14 3 0 0 4 21 7 15 25 +15 3 0 0 4 19 25 17 8 +16 3 0 0 4 25 15 4 17 +$ENDELM -- 2.39.5