1 #include <deal.II/opencascade/boundary_lib.h> 3 #ifdef DEAL_II_WITH_OPENCASCADE 5 #include <GCPnts_AbscissaPoint.hxx> 6 #include <BRepAdaptor_Curve.hxx> 7 #include <BRepAdaptor_CompCurve.hxx> 8 #include <BRepAdaptor_HCurve.hxx> 9 #include <BRepAdaptor_HCompCurve.hxx> 10 #include <GCPnts_AbscissaPoint.hxx> 11 #include <ShapeAnalysis_Curve.hxx> 12 #include <BRep_Tool.hxx> 14 #include <Adaptor3d_HCurve.hxx> 15 #include <Handle_Adaptor3d_HCurve.hxx> 17 DEAL_II_NAMESPACE_OPEN
31 Handle_Adaptor3d_HCurve curve_adaptor(
const TopoDS_Shape &shape)
33 Assert( (shape.ShapeType() == TopAbs_WIRE) ||
34 (shape.ShapeType() == TopAbs_EDGE),
35 ExcUnsupportedShape());
36 if (shape.ShapeType() == TopAbs_WIRE)
37 return (Handle(BRepAdaptor_HCompCurve(
new BRepAdaptor_HCompCurve(TopoDS::Wire(shape)))));
38 else if (shape.ShapeType() == TopAbs_EDGE)
39 return (Handle(BRepAdaptor_HCurve(
new BRepAdaptor_HCurve(TopoDS::Edge(shape)))));
41 Assert(
false, ExcInternalError());
42 return Handle(BRepAdaptor_HCurve(
new BRepAdaptor_HCurve()));
48 double shape_length(
const TopoDS_Shape &sh)
50 Handle_Adaptor3d_HCurve adapt = curve_adaptor(sh);
51 return GCPnts_AbscissaPoint::Length(adapt->GetCurve());
56 template <
int dim,
int spacedim>
58 const double tolerance) :
62 Assert(spacedim == 3, ExcNotImplemented());
66 template <
int dim,
int spacedim>
71 (void)surrounding_points;
73 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
77 ExcPointNotOnManifold(surrounding_points[i]));
84 template <
int dim,
int spacedim>
92 Assert(spacedim == 3, ExcNotImplemented());
96 template <
int dim,
int spacedim>
101 (void)surrounding_points;
103 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
107 ExcPointNotOnManifold(surrounding_points[i]));
115 template <
int dim,
int spacedim>
121 Assert(spacedim == 3, ExcNotImplemented());
123 ExcMessage(
"NormalToMeshProjectionBoundary needs a shape containing faces to operate."));
127 template <
int dim,
int spacedim>
132 TopoDS_Shape out_shape;
135 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
138 .distance(surrounding_points[i]) <
140 ExcPointNotOnManifold(surrounding_points[i]));
144 switch (surrounding_points.size())
148 for (
unsigned int i=0; i<surrounding_points.size(); ++i)
150 std_cxx11::tuple<Point<3>,
Point<3>,
double>
153 surrounding_points[i],
155 average_normal += std_cxx11::get<1>(p_and_diff_forms);
161 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."));
163 Tensor<1,3> T = surrounding_points[0]-surrounding_points[1];
165 average_normal = average_normal-(average_normal*T)*T;
166 average_normal /= average_normal.
norm();
171 Tensor<1,3> u = surrounding_points[1]-surrounding_points[0];
172 Tensor<1,3> v = surrounding_points[2]-surrounding_points[0];
173 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]};
176 u = surrounding_points[2]-surrounding_points[3];
177 v = surrounding_points[1]-surrounding_points[3];
178 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]};
181 u = surrounding_points[4]-surrounding_points[7];
182 v = surrounding_points[6]-surrounding_points[7];
183 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]};
186 u = surrounding_points[6]-surrounding_points[7];
187 v = surrounding_points[5]-surrounding_points[7];
188 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]};
196 average_normal = (n1+n2+n3+n4)/4.0;
199 ExcMessage(
"Failed to refine cell: the normal estimated via the surrounding points turns out to be a null vector, making the projection direction undetermined."));
201 average_normal /= average_normal.
norm();
216 template <
int dim,
int spacedim>
221 Point<1>(shape_length(sh)) :
223 curve(curve_adaptor(sh)),
224 tolerance(tolerance),
225 length(shape_length(sh))
227 Assert(spacedim == 3, ExcNotImplemented());
231 template <
int dim,
int spacedim>
236 ShapeAnalysis_Curve curve_analysis;
238 const double dist = curve_analysis.Project(
curve->GetCurve(),
point(space_point),
tolerance, proj, t,
true);
241 return Point<1>(GCPnts_AbscissaPoint::Length(
curve->GetCurve(),
curve->GetCurve().FirstParameter(),t));
246 template <
int dim,
int spacedim>
250 GCPnts_AbscissaPoint AP(
curve->GetCurve(), chart_point[0],
curve->GetCurve().FirstParameter());
251 gp_Pnt P =
curve->GetCurve().Value(AP.Parameter());
257 #include "boundary_lib.inst" 261 DEAL_II_NAMESPACE_CLOSE
std_cxx11::tuple< Point< 3 >, Point< 3 >, 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)
::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
numbers::NumberTraits< Number >::real_type norm() const
std_cxx11::tuple< unsigned int, unsigned int, unsigned int > count_elements(const TopoDS_Shape &shape)
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)
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &surrounding_points, const Point< spacedim > &candidate) const
Handle_Adaptor3d_HCurve curve
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
ArclengthProjectionLineManifold(const TopoDS_Shape &sh, const double tolerance=1e-7)
const Point< 3 > direction
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
DirectionalProjectionBoundary(const TopoDS_Shape &sh, const Tensor< 1, spacedim > &direction, const double tolerance=1e-7)