1 // Created on: 1993-12-06
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor2d_HCurve2d.hxx>
19 #include <Adaptor3d_HSurface.hxx>
20 #include <Adaptor3d_HVertex.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepBlend_BlendTool.hxx>
23 #include <BRepBlend_HCurve2dTool.hxx>
24 #include <BRepClass_FaceClassifier.hxx>
25 #include <Extrema_EPCOfExtPC2d.hxx>
26 #include <Extrema_POnCurv2d.hxx>
27 #include <Geom2d_Line.hxx>
28 #include <Geom2dAdaptor_Curve.hxx>
29 #include <Geom2dInt_GInter.hxx>
30 #include <gp_Dir2d.hxx>
31 #include <gp_Pnt2d.hxx>
32 #include <gp_Vec2d.hxx>
33 #include <IntRes2d_IntersectionPoint.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Vertex.hxx>
37 //=======================================================================
39 //purpose : Projection orthogonal d'un point sur une courbe
40 // pmn 8/10/98 : On retourne toujours une distance. (BUC60360)
41 //=======================================================================
42 Standard_Boolean BRepBlend_BlendTool::Project(const gp_Pnt2d& P,
43 const Handle(Adaptor3d_HSurface)&,
44 const Handle(Adaptor2d_HCurve2d)& C,
45 Standard_Real& Paramproj,
48 Paramproj = BRepBlend_HCurve2dTool::FirstParameter(C);
50 BRepBlend_HCurve2dTool::D0(C, Paramproj, P2d);
51 Dist = P2d.Distance(P);
53 const Standard_Real t = BRepBlend_HCurve2dTool::LastParameter(C);
54 BRepBlend_HCurve2dTool::D0(C, t, P2d);
55 if (P2d.Distance(P) < Dist) {
57 Dist = P2d.Distance(P);
60 const Standard_Real epsX = 1.e-8;
61 const Standard_Integer Nbu = 20;
62 const Standard_Real Tol = 1.e-5;
63 Extrema_EPCOfExtPC2d extrema(P, C->Curve2d(), Nbu, epsX, Tol);
64 if (!extrema.IsDone())
67 const Standard_Integer Nbext = extrema.NbExt();
68 Standard_Real aDist2 = Dist * Dist;
69 for (Standard_Integer i=1; i<=Nbext; i++) {
70 if (extrema.SquareDistance(i) < aDist2) {
71 aDist2 = extrema.SquareDistance(i);
72 Paramproj = extrema.Point(i).Parameter();
80 //=======================================================================
82 //purpose : Intersection d'un segment avec une courbe
83 //=======================================================================
84 Standard_Boolean BRepBlend_BlendTool::Inters(const gp_Pnt2d& P1,
86 const Handle(Adaptor3d_HSurface)&,
87 const Handle(Adaptor2d_HCurve2d)& C,
91 const Standard_Real Tol = 1.e-8;
92 const gp_Vec2d v(P1,P2);
93 const Standard_Real mag = v.Magnitude();
94 if(mag < Tol) return Standard_False;
97 Handle(Geom2d_Line) bid = new Geom2d_Line(P1,d);
98 Geom2dAdaptor_Curve seg(bid,-0.01*mag,1.01*mag);
100 Geom2dInt_GInter inter(seg,C->Curve2d(),Tol,Tol);
102 return Standard_False;
104 const Standard_Integer Nbint = inter.NbPoints();
106 return Standard_False;
108 IntRes2d_IntersectionPoint ip = inter.Point(1);
109 Param = ip.ParamOnSecond();
110 Dist = P1.Distance(ip.Value());
111 return Standard_True;
114 Standard_Integer BRepBlend_BlendTool::NbSamplesV
115 (const Handle(Adaptor3d_HSurface)&,
122 Standard_Integer BRepBlend_BlendTool::NbSamplesU
123 (const Handle(Adaptor3d_HSurface)&,
130 void BRepBlend_BlendTool::Bounds(const Handle(Adaptor2d_HCurve2d)& A,
131 Standard_Real& Ufirst,
132 Standard_Real& Ulast)
134 Ufirst = BRepBlend_HCurve2dTool::FirstParameter(A);
135 Ulast = BRepBlend_HCurve2dTool::LastParameter(A);