6 #include <TopoDS_Shape.hxx>
7 #include <TopoDS_Shell.hxx>
8 #include <TopoDS_Face.hxx>
9 #include <BRepTools.hxx>
10 #include <TopTools_SequenceOfShape.hxx>
11 #include <Handle_Standard_Transient.hxx>
12 #include <TColStd_SequenceOfTransient.hxx>
13 #include <TColStd_HSequenceOfTransient.hxx>
14 #include <TopExp_Explorer.hxx>
17 #include <GeomAPI_ProjectPointOnSurf.hxx>
18 #include <GeomAPI_ProjectPointOnCurve.hxx>
19 #include <Standard_Real.hxx>
20 #include <Standard_Integer.hxx>
21 #include <BRep_Tool.hxx>
22 #include <Geom_Surface.hxx>
23 #include <Geom_Plane.hxx>
24 #include <Prs3d_ShapeTool.hxx>
25 #include <Bnd_Box.hxx>
28 #include <BRepBuilderAPI_MakeFace.hxx>
29 #include <BRepBuilderAPI_MakeEdge.hxx>
30 #include <GeomAPI_IntSS.hxx>
31 #include <TopoDS_Wire.hxx>
32 #include <BRepBuilderAPI_MakePolygon.hxx>
33 #include <Geom_Curve.hxx>
34 #include <Geom_BoundedCurve.hxx>
35 #include <Geom_TrimmedCurve.hxx>
36 #include <TColGeom_Array1OfCurve.hxx>
37 #include <GeomAPI_IntCS.hxx>
38 #include <BRepBuilderAPI_MakeEdge.hxx>
39 #include <GeomLib_Tool.hxx>
40 #include <GCPnts_AbscissaPoint.hxx>
41 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
42 #include <ShapeAnalysis_Surface.hxx>
43 #include <GeomLProp_SLProps.hxx>
44 #include <TColgp_Array1OfPnt.hxx>
45 #include <TColgp_Array1OfPnt2d.hxx>
46 #include <BRepAdaptor_Curve.hxx>
47 #include <BRepAdaptor_Surface.hxx>
67 TopExp_Explorer edgeExplorer(sh , TopAbs_EDGE);
68 unsigned int n_edges = 0;
69 while (edgeExplorer.More())
80 TopExp_Explorer faceExplorer(sh , TopAbs_FACE);
81 unsigned int n_faces = 0;
82 while (faceExplorer.More())
98 TopLoc_Location L = sh.Location();
99 TopLoc_Location L_inv = L.Inverted();
102 gp_Pnt P0(origin(0),origin(1),origin(2));
105 gp_Pnt Pproj(0.0,0.0,0.0);
112 TopExp_Explorer edgeExplorer(sh , TopAbs_EDGE);
113 unsigned int tot_proj_points = 0;
114 double minDistance = 1e7;
116 while (edgeExplorer.More())
118 edge = TopoDS::Edge(edgeExplorer.Current());
120 BRepAdaptor_Curve AC(edge);
128 Handle(Geom_Curve) CurveToProj = BRep_Tool::Curve(edge,L,First,Last);
130 TopoDS_Shape shnew = BRepBuilderAPI_MakeEdge(CurveToProj);
132 GeomAPI_ProjectPointOnCurve Proj(P0,CurveToProj);
133 unsigned int num_proj_points = Proj.NbPoints();
134 tot_proj_points+=num_proj_points;
135 if ((num_proj_points > 0) && (Proj.LowerDistance() < minDistance))
137 Pproj = Proj.NearestPoint();
139 minDistance = Proj.LowerDistance();
144 Assert(tot_proj_points > 0,
145 ExcMessage(
"Point projection on curve in normal direction does not exist"));
148 projection(0) = Pproj.X();
149 projection(1) = Pproj.Y();
150 projection(2) = Pproj.Z();
158 TopLoc_Location L = sh.Location();
159 TopLoc_Location L_inv = L.Inverted();
162 gp_Pnt P0(origin(0),origin(1),origin(2));
165 gp_Pnt Pproj(0.0,0.0,0.0);
173 unsigned int face_count=0;
174 TopExp_Explorer faceExplorer(sh, TopAbs_FACE);
175 double minDistance = 1e7;
177 gp_Pnt face_proj(0.0,0.0,0.0);
179 while (faceExplorer.More())
181 face = TopoDS::Face(faceExplorer.Current());
187 Handle(Geom_Surface) SurfToProj = BRep_Tool::Surface(face);
190 ShapeAnalysis_Surface projector(SurfToProj);
191 gp_Pnt2d proj_params = projector.ValueOfUV(P0, 1e-7);
192 SurfToProj->D0(proj_params.X(),proj_params.Y(),face_proj);
193 if (
Pnt(face_proj).distance(origin) < minDistance)
195 minDistance =
Pnt(face_proj).distance(origin);
205 projection =
Pnt(Pproj);
219 ExcMessage(
"Method is not implemented for dim = 1"));
226 double &mean_curvature,
229 TopLoc_Location L = sh.Location();
230 TopLoc_Location L_inv = L.Inverted();
233 gp_Pnt P0 =
Pnt(origin);
236 gp_Pnt Pproj(0.0,0.0,0.0);
245 unsigned int face_count=0;
246 TopExp_Explorer faceExplorer(sh, TopAbs_FACE);
247 double minDistance = 1e7;
249 gp_Pnt face_proj(0.0,0.0,0.0);
251 Standard_Real Mean_Curvature = 0;
253 while (faceExplorer.More())
255 face = TopoDS::Face(faceExplorer.Current());
257 BRepAdaptor_Surface AF(face);
269 Handle(Geom_Surface) SurfToProj = BRep_Tool::Surface(face);
270 Standard_Real uufirst,uulast,vvfirst,vvlast;
271 SurfToProj->Bounds (uufirst, uulast, vvfirst, vvlast);
277 ShapeAnalysis_Surface projector(SurfToProj);
278 if (projector.IsDegenerated(P0,1e-7) )
281 Standard_Real ufirst,ulast,vfirst,vlast;
282 projector.Bounds (ufirst, ulast, vfirst, vlast);
285 gp_Pnt Pmid = SurfToProj->Value((ufirst+ulast)/2.0, (vfirst+vlast)/2.0);
287 gp_Pnt P0Mod(P0.X()+(Pmid.X()-P0.X())/1000.0,
288 P0.Y()+(Pmid.Y()-P0.Y())/1000.0,
289 P0.Z()+(Pmid.Z()-P0.Z())/1000.0);
293 gp_Pnt2d proj_params = projector.ValueOfUV(P0, 1e-7);
294 SurfToProj->D0(proj_params.X(),proj_params.Y(),face_proj);
295 if (
Pnt(face_proj).distance(origin) < minDistance)
297 minDistance =
Pnt(face_proj).distance(origin);
300 GeomLProp_SLProps props(SurfToProj, proj_params.X(), proj_params.Y(),1, 1e-7);
301 Normal = props.Normal();
302 Mean_Curvature = props.MeanCurvature();
305 if (face.Orientation()==TopAbs_REVERSED)
317 projection =
Pnt(Pproj);
321 normal(0) = Normal.X();
322 normal(1) = Normal.Y();
323 normal(2) = Normal.Z();
327 mean_curvature = double(Mean_Curvature);
337 normal_projection(projected_point, source_point);
338 return projected_point;
351 normal_projection(proj_point, init_point);
NormalProjection(const TopoDS_Shape &sh)
#define AssertThrow(cond, exc)
static::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
virtual Point< spacedim > get_new_point_on_line(const typename Triangulation< dim, spacedim >::line_iterator &line) const
dealii::Point< 3 > Pnt(const gp_Pnt &p)
Convert OpenCascade point into.
void normal_projection(Point< 3 > &projection, const Point< 3 > &origin) const
We collect in this namespace all utilities which operate on OpenCascade entities which don't need cla...
static::ExceptionBase & ExcNotImplemented()
void normal_projection_and_diff_forms(Point< 3 > &projection, Point< 3 > &normal, double &mean_curvature, const Point< 3 > &origin) const
Handle(Geom_Curve) NumericalTowingTank
virtual Point< spacedim > get_new_point_on_quad(const typename Triangulation< dim, spacedim >::quad_iterator &quad) const