From: Luca Heltai <luca.heltai@sissa.it> Date: Fri, 6 Apr 2018 13:26:50 +0000 (+0200) Subject: Clone functions for OpenCASCADE objects. X-Git-Tag: v9.0.0-rc1~196^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31d08eaa4c2a22b865c700c11753361b267326ac;p=dealii.git Clone functions for OpenCASCADE objects. --- 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<Manifold<dim,spacedim> > 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<spacedim> project_to_manifold (const ArrayView<const Point<spacedim>> &surrounding_points, - const Point<spacedim> &candidate) const; + const Point<spacedim> &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<Manifold<dim,spacedim> > 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<spacedim> project_to_manifold (const ArrayView<const Point<spacedim>> &surrounding_points, - const Point<spacedim> &candidate) const; + const Point<spacedim> &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<Manifold<dim,spacedim> > 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<spacedim> project_to_manifold (const ArrayView<const Point<spacedim>> &surrounding_points, - const Point<spacedim> &candidate) const; + const Point<spacedim> &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<Manifold<dim,spacedim> > 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<spacedim> &space_point) const; + pull_back(const Point<spacedim> &space_point) const override; /** * Given an arclength parameter, find its image in real space. */ virtual Point<spacedim> - 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<Manifold<dim,spacedim> > 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<spacedim> &space_point) const; + pull_back(const Point<spacedim> &space_point) const override; /** * Given a @p chart_point in the uv coordinate system, this method returns the * Euclidean coordinates associated. */ virtual Point<spacedim> - 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<int dim, int spacedim> + std::unique_ptr<Manifold<dim, spacedim> > + NormalProjectionBoundary<dim,spacedim>::clone() const + { + return std::unique_ptr<Manifold<dim,spacedim> >(new NormalProjectionBoundary(sh, tolerance)); + } + + + template <int dim, int spacedim> Point<spacedim> NormalProjectionBoundary<dim,spacedim>:: project_to_manifold (const ArrayView<const Point<spacedim>> &surrounding_points, @@ -116,6 +126,17 @@ namespace OpenCASCADE } + + template<int dim, int spacedim> + std::unique_ptr<Manifold<dim, spacedim> > + DirectionalProjectionBoundary<dim,spacedim>::clone() const + { + return std::unique_ptr<Manifold<dim,spacedim> > + (new DirectionalProjectionBoundary(sh, direction, tolerance)); + } + + + template <int dim, int spacedim> Point<spacedim> DirectionalProjectionBoundary<dim,spacedim>:: project_to_manifold (const ArrayView<const Point<spacedim>> &surrounding_points, @@ -146,6 +167,14 @@ namespace OpenCASCADE ExcMessage("NormalToMeshProjectionBoundary needs a shape containing faces to operate.")); } + template<int dim, int spacedim> + std::unique_ptr<Manifold<dim, spacedim> > + NormalToMeshProjectionBoundary<dim,spacedim>::clone() const + { + return std::unique_ptr<Manifold<dim, spacedim> > + (new NormalToMeshProjectionBoundary<dim,spacedim>(sh,tolerance)); + } + template <int dim, int spacedim> Point<spacedim> NormalToMeshProjectionBoundary<dim,spacedim>:: @@ -260,6 +289,7 @@ namespace OpenCASCADE ChartManifold<dim,spacedim,1>(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<int dim, int spacedim> + std::unique_ptr<Manifold<dim, spacedim> > + ArclengthProjectionLineManifold<dim, spacedim>::clone() const + { + return std::unique_ptr<Manifold<dim, spacedim> > + (new ArclengthProjectionLineManifold(sh,tolerance)); + } + + + template <int dim, int spacedim> Point<1> ArclengthProjectionLineManifold<dim,spacedim>::pull_back(const Point<spacedim> &space_point) const @@ -301,6 +342,18 @@ namespace OpenCASCADE tolerance(tolerance) {} + + + template<int dim, int spacedim> + std::unique_ptr<Manifold<dim, spacedim> > + NURBSPatchManifold<dim,spacedim>::clone() const + { + return std::unique_ptr<Manifold<dim, spacedim> > + (new NURBSPatchManifold<dim,spacedim>(face,tolerance)); + } + + + template <int dim, int spacedim> Point<2> NURBSPatchManifold<dim, spacedim>:: pull_back(const Point<spacedim> &space_point) const