From 31d08eaa4c2a22b865c700c11753361b267326ac Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Fri, 6 Apr 2018 15:26:50 +0200 Subject: [PATCH] Clone functions for OpenCASCADE objects. --- include/deal.II/opencascade/boundary_lib.h | 46 +++++++++++++++---- source/opencascade/boundary_lib.cc | 53 ++++++++++++++++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/include/deal.II/opencascade/boundary_lib.h b/include/deal.II/opencascade/boundary_lib.h index 5e4b0df7ae..60b09fcf8d 100644 --- a/include/deal.II/opencascade/boundary_lib.h +++ b/include/deal.II/opencascade/boundary_lib.h @@ -77,6 +77,11 @@ namespace OpenCASCADE NormalProjectionBoundary(const TopoDS_Shape &sh, const double tolerance=1e-7); + /** + * Clone the current Manifold. + */ + virtual std::unique_ptr > clone() const override; + /** * Perform the actual projection onto the manifold. This function, in * debug mode, checks that each of the @p surrounding_points is within @@ -88,7 +93,7 @@ namespace OpenCASCADE */ virtual Point project_to_manifold (const ArrayView> &surrounding_points, - const Point &candidate) const; + const Point &candidate) const override; private: @@ -139,6 +144,11 @@ namespace OpenCASCADE const Tensor<1,spacedim> &direction, const double tolerance=1e-7); + /** + * Clone the current Manifold. + */ + virtual std::unique_ptr > clone() const override; + /** * Perform the actual projection onto the manifold. This function, in * debug mode, checks that each of the @p surrounding_points is within @@ -150,7 +160,7 @@ namespace OpenCASCADE */ virtual Point project_to_manifold (const ArrayView> &surrounding_points, - const Point &candidate) const; + const Point &candidate) const override; private: /** @@ -229,6 +239,11 @@ namespace OpenCASCADE NormalToMeshProjectionBoundary(const TopoDS_Shape &sh, const double tolerance=1e-7); + /** + * Clone the current Manifold. + */ + virtual std::unique_ptr > clone() const override; + /** * Perform the actual projection onto the manifold. This function, in * debug mode, checks that each of the @p surrounding_points is within @@ -237,7 +252,7 @@ namespace OpenCASCADE */ virtual Point project_to_manifold (const ArrayView> &surrounding_points, - const Point &candidate) const; + const Point &candidate) const override; private: /** @@ -283,21 +298,31 @@ namespace OpenCASCADE ArclengthProjectionLineManifold(const TopoDS_Shape &sh, const double tolerance=1e-7); + /** + * Clone the current Manifold. + */ + virtual std::unique_ptr > clone() const override; + /** * Given a point on real space, find its arclength parameter. Throws an * error in debug mode, if the point is not on the TopoDS_Edge given at * construction time. */ virtual Point<1> - pull_back(const Point &space_point) const; + pull_back(const Point &space_point) const override; /** * Given an arclength parameter, find its image in real space. */ virtual Point - push_forward(const Point<1> &chart_point) const; + push_forward(const Point<1> &chart_point) const override; private: + /** + * The actual shape used to build this object. + */ + const TopoDS_Shape sh; + /** * A Curve adaptor. This is the one which is used in the computations, and * it points to the right one above. @@ -334,19 +359,24 @@ namespace OpenCASCADE */ NURBSPatchManifold(const TopoDS_Face &face, const double tolerance = 1e-7); + /** + * Clone the current Manifold. + */ + virtual std::unique_ptr > clone() const override; + /** * Pull back the given point from the Euclidean space. Will return the uv * coordinates associated with the point @p space_point. */ virtual Point<2> - pull_back(const Point &space_point) const; + pull_back(const Point &space_point) const override; /** * Given a @p chart_point in the uv coordinate system, this method returns the * Euclidean coordinates associated. */ virtual Point - push_forward(const Point<2> &chart_point) const; + push_forward(const Point<2> &chart_point) const override; /** * Given a point in the spacedim dimensional Euclidean space, this @@ -362,7 +392,7 @@ namespace OpenCASCADE */ virtual DerivativeForm<1,2,spacedim> - push_forward_gradient(const Point<2> &chart_point) const; + push_forward_gradient(const Point<2> &chart_point) const override; private: /** diff --git a/source/opencascade/boundary_lib.cc b/source/opencascade/boundary_lib.cc index 773a30b7c0..fc8cd5741e 100644 --- a/source/opencascade/boundary_lib.cc +++ b/source/opencascade/boundary_lib.cc @@ -86,6 +86,16 @@ namespace OpenCASCADE } + + template + std::unique_ptr > + NormalProjectionBoundary::clone() const + { + return std::unique_ptr >(new NormalProjectionBoundary(sh, tolerance)); + } + + + template Point NormalProjectionBoundary:: project_to_manifold (const ArrayView> &surrounding_points, @@ -116,6 +126,17 @@ namespace OpenCASCADE } + + template + std::unique_ptr > + DirectionalProjectionBoundary::clone() const + { + return std::unique_ptr > + (new DirectionalProjectionBoundary(sh, direction, tolerance)); + } + + + template Point DirectionalProjectionBoundary:: project_to_manifold (const ArrayView> &surrounding_points, @@ -146,6 +167,14 @@ namespace OpenCASCADE ExcMessage("NormalToMeshProjectionBoundary needs a shape containing faces to operate.")); } + template + std::unique_ptr > + NormalToMeshProjectionBoundary::clone() const + { + return std::unique_ptr > + (new NormalToMeshProjectionBoundary(sh,tolerance)); + } + template Point NormalToMeshProjectionBoundary:: @@ -260,6 +289,7 @@ namespace OpenCASCADE ChartManifold(sh.Closed() ? Point<1>(shape_length(sh)) : Point<1>()), + sh(sh), curve(curve_adaptor(sh)), tolerance(tolerance), length(shape_length(sh)) @@ -268,6 +298,17 @@ namespace OpenCASCADE } + + template + std::unique_ptr > + ArclengthProjectionLineManifold::clone() const + { + return std::unique_ptr > + (new ArclengthProjectionLineManifold(sh,tolerance)); + } + + + template Point<1> ArclengthProjectionLineManifold::pull_back(const Point &space_point) const @@ -301,6 +342,18 @@ namespace OpenCASCADE tolerance(tolerance) {} + + + template + std::unique_ptr > + NURBSPatchManifold::clone() const + { + return std::unique_ptr > + (new NURBSPatchManifold(face,tolerance)); + } + + + template Point<2> NURBSPatchManifold:: pull_back(const Point &space_point) const -- 2.39.5