17 #include <deal.II/opencascade/boundary_lib.h> 19 #ifdef DEAL_II_WITH_OPENCASCADE 21 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
23 #include <GCPnts_AbscissaPoint.hxx> 24 #include <BRepAdaptor_Curve.hxx> 25 #include <BRepAdaptor_CompCurve.hxx> 26 #include <BRepAdaptor_HCurve.hxx> 27 #include <BRepAdaptor_HCompCurve.hxx> 28 #include <GCPnts_AbscissaPoint.hxx> 29 #include <ShapeAnalysis_Curve.hxx> 30 #include <BRep_Tool.hxx> 31 #include <BRepTools.hxx> 32 #include <ShapeAnalysis_Surface.hxx> 35 #include <Standard_Version.hxx> 36 #if (OCC_VERSION_MAJOR < 7) 37 # include <Handle_Adaptor3d_HCurve.hxx> 40 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
42 DEAL_II_NAMESPACE_OPEN
56 Handle_Adaptor3d_HCurve curve_adaptor(
const TopoDS_Shape &shape)
58 Assert( (shape.ShapeType() == TopAbs_WIRE) ||
59 (shape.ShapeType() == TopAbs_EDGE),
61 if (shape.ShapeType() == TopAbs_WIRE)
62 return Handle(BRepAdaptor_HCompCurve)(
new BRepAdaptor_HCompCurve(TopoDS::Wire(shape)));
63 else if (shape.ShapeType() == TopAbs_EDGE)
64 return Handle(BRepAdaptor_HCurve)(
new BRepAdaptor_HCurve(TopoDS::Edge(shape)));
67 return Handle(BRepAdaptor_HCurve)(
new BRepAdaptor_HCurve());
73 double shape_length(
const TopoDS_Shape &sh)
75 Handle_Adaptor3d_HCurve adapt = curve_adaptor(sh);
76 return GCPnts_AbscissaPoint::Length(adapt->GetCurve());
81 template <
int dim,
int spacedim>
83 const double tolerance) :
91 template <
int dim,
int spacedim>
96 (void)surrounding_points;
98 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
101 std::max(tolerance*surrounding_points[i].norm(), tolerance),
109 template <
int dim,
int spacedim>
112 const double tolerance) :
114 direction(direction),
121 template <
int dim,
int spacedim>
126 (void)surrounding_points;
128 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
131 std::max(tolerance*surrounding_points[i].norm(), tolerance),
140 template <
int dim,
int spacedim>
142 const double tolerance) :
148 ExcMessage(
"NormalToMeshProjectionBoundary needs a shape containing faces to operate."));
152 template <
int dim,
int spacedim>
157 TopoDS_Shape out_shape;
160 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
163 .distance(surrounding_points[i]) <
164 std::max(tolerance*surrounding_points[i].norm(), tolerance),
169 switch (surrounding_points.size())
173 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
175 std_cxx11::tuple<Point<3>,
Tensor<1,3>, double,
double>
178 surrounding_points[i],
180 average_normal += std_cxx11::get<1>(p_and_diff_forms);
186 ExcMessage(
"Failed to refine cell: the average of the surface normals at the surrounding edge turns out to be a null vector, making the projection direction undetermined."));
188 Tensor<1,3> T = surrounding_points[0]-surrounding_points[1];
190 average_normal = average_normal-(average_normal*T)*T;
191 average_normal /= average_normal.
norm();
196 Tensor<1,3> u = surrounding_points[1]-surrounding_points[0];
197 Tensor<1,3> v = surrounding_points[2]-surrounding_points[0];
198 const double n1_coords[3] = {u[1] *v[2]-u[2] *v[1],u[2] *v[0]-u[0] *v[2],u[0] *v[1]-u[1] *v[0]};
201 u = surrounding_points[2]-surrounding_points[3];
202 v = surrounding_points[1]-surrounding_points[3];
203 const double n2_coords[3] = {u[1] *v[2]-u[2] *v[1],u[2] *v[0]-u[0] *v[2],u[0] *v[1]-u[1] *v[0]};
206 u = surrounding_points[4]-surrounding_points[7];
207 v = surrounding_points[6]-surrounding_points[7];
208 const double n3_coords[3] = {u[1] *v[2]-u[2] *v[1],u[2] *v[0]-u[0] *v[2],u[0] *v[1]-u[1] *v[0]};
211 u = surrounding_points[6]-surrounding_points[7];
212 v = surrounding_points[5]-surrounding_points[7];
213 const double n4_coords[3] = {u[1] *v[2]-u[2] *v[1],u[2] *v[0]-u[0] *v[2],u[0] *v[1]-u[1] *v[0]};
221 average_normal = (n1+n2+n3+n4)/4.0;
224 ExcMessage(
"Failed to refine cell: the normal estimated via the surrounding points turns out to be a null vector, making the projection direction undetermined."));
226 average_normal /= average_normal.
norm();
241 template <
int dim,
int spacedim>
243 const double tolerance):
246 Point<1>(shape_length(sh)) :
248 curve(curve_adaptor(sh)),
249 tolerance(tolerance),
250 length(shape_length(sh))
256 template <
int dim,
int spacedim>
261 ShapeAnalysis_Curve curve_analysis;
263 const double dist = curve_analysis.Project(curve->GetCurve(),
point(space_point), tolerance, proj, t,
true);
266 return Point<1>(GCPnts_AbscissaPoint::Length(curve->GetCurve(),curve->GetCurve().FirstParameter(),t));
271 template <
int dim,
int spacedim>
275 GCPnts_AbscissaPoint AP(curve->GetCurve(), chart_point[0], curve->GetCurve().FirstParameter());
276 gp_Pnt P = curve->GetCurve().Value(AP.Parameter());
280 template <
int dim,
int spacedim>
283 const double tolerance)
294 Handle(Geom_Surface) SurfToProj = BRep_Tool::Surface(face);
296 ShapeAnalysis_Surface projector(SurfToProj);
297 gp_Pnt2d proj_params = projector.ValueOfUV(
point(space_point), tolerance);
299 double u = proj_params.X();
300 double v = proj_params.Y();
310 return ::OpenCASCADE::push_forward(face, chart_point[0], chart_point[1]);
319 Handle(Geom_Surface) surf = BRep_Tool::Surface(face);
323 surf->D1(chart_point[0],chart_point[1], q, Du, Dv);
336 std_cxx11::tuple<double, double, double, double>
340 Standard_Real umin, umax, vmin, vmax;
341 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
342 return std_cxx11::make_tuple(umin, umax, vmin, vmax);
346 template class NURBSPatchManifold<2, 3 >;
347 #include "boundary_lib.inst" 351 DEAL_II_NAMESPACE_CLOSE
std_cxx11::tuple< Point< 3 >, Tensor< 1, 3 >, double, double > closest_point_and_differential_forms(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
Point< 3 > line_intersection(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const Tensor< 1, 3 > &direction, const double tolerance=1e-7)
virtual Point< 2 > pull_back(const Point< spacedim > &space_point) const
virtual Point< spacedim > push_forward(const Point< 2 > &chart_point) const
#define AssertThrow(cond, exc)
numbers::NumberTraits< Number >::real_type norm() const
virtual DerivativeForm< 1, 2, spacedim > push_forward_gradient(const Point< 2 > &chart_point) const
std_cxx11::tuple< unsigned int, unsigned int, unsigned int > count_elements(const TopoDS_Shape &shape)
static ::ExceptionBase & ExcMessage(std::string arg1)
NormalToMeshProjectionBoundary(const TopoDS_Shape &sh, const double tolerance=1e-7)
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &surrounding_points, const Point< spacedim > &candidate) const
#define Assert(cond, exc)
static ::ExceptionBase & ExcPointNotOnManifold(Point< 3 > arg1)
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &surrounding_points, const Point< spacedim > &candidate) const
std_cxx11::tuple< double, double, double, double > get_uv_bounds() const
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
Point< 3 > closest_point(const TopoDS_Shape &in_shape, const Point< 3 > &origin, const double tolerance=1e-7)
virtual Point< spacedim > push_forward(const Point< 1 > &chart_point) const
static ::ExceptionBase & ExcNotImplemented()
ArclengthProjectionLineManifold(const TopoDS_Shape &sh, const double tolerance=1e-7)
static ::ExceptionBase & ExcUnsupportedShape()
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &surrounding_points, const Point< spacedim > &candidate) const
NormalProjectionBoundary(const TopoDS_Shape &sh, const double tolerance=1e-7)
Point< 3 > point(const gp_Pnt &p)
virtual Point< 1 > pull_back(const Point< spacedim > &space_point) const
static ::ExceptionBase & ExcInternalError()
DirectionalProjectionBoundary(const TopoDS_Shape &sh, const Tensor< 1, spacedim > &direction, const double tolerance=1e-7)