]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed small bug in OCC::interpolation_curve. 8613/head
authorLuca Heltai <luca.heltai@sissa.it>
Wed, 21 Aug 2019 13:23:53 +0000 (15:23 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Wed, 21 Aug 2019 14:40:59 +0000 (16:40 +0200)
doc/news/changes/minor/20190821LucaHeltai [new file with mode: 0644]
source/opencascade/utilities.cc
tests/opencascade/interpolation_curve_boundary_02.cc [new file with mode: 0644]
tests/opencascade/interpolation_curve_boundary_02.output [new file with mode: 0644]

diff --git a/doc/news/changes/minor/20190821LucaHeltai b/doc/news/changes/minor/20190821LucaHeltai
new file mode 100644 (file)
index 0000000..a6a164c
--- /dev/null
@@ -0,0 +1,4 @@
+Fixed: OpenCASCADE::interpolation_curve() returned a TopoDS_Shape that was not properly closed. This is 
+now fixed.
+<br>
+(Luca Heltai, 2019/08/21)
index a679086eec9d9e10fa0046e570334f6fd31b3081..4ce89c1ae380967694ffc93a93808c76fb2533df 100644 (file)
@@ -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 (file)
index 0000000..c32c3a6
--- /dev/null
@@ -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 <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/manifold_lib.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <deal.II/opencascade/boundary_lib.h>
+
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <GC_MakeCircle.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+
+#include "../tests.h"
+
+using namespace OpenCASCADE;
+
+int
+main()
+{
+  initlog();
+
+  // The curve passing through the vertices of the unit square.
+  std::vector<Point<3>> 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 (file)
index 0000000..1ad7dd6
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.