1 // Created on: 1993-08-24
2 // Created by: Bruno DUMORTIER
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 <gp_Circ.hxx>
19 #include <gp_Elips.hxx>
20 #include <gp_Hypr.hxx>
22 #include <gp_Parab.hxx>
25 #include <ProjLib_Plane.hxx>
26 #include <Standard_NoSuchObject.hxx>
28 //=======================================================================
29 //function : ProjLib_Plane
31 //=======================================================================
32 ProjLib_Plane::ProjLib_Plane()
37 //=======================================================================
38 //function : ProjLib_Plane
40 //=======================================================================
42 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl)
48 //=======================================================================
49 //function : ProjLib_Plane
51 //=======================================================================
53 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Lin& L)
60 //=======================================================================
61 //function : ProjLib_Plane
63 //=======================================================================
65 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Circ& C)
72 //=======================================================================
73 //function : ProjLib_Plane
75 //=======================================================================
77 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Elips& E)
84 //=======================================================================
85 //function : ProjLib_Plane
87 //=======================================================================
89 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Parab& P)
96 //=======================================================================
97 //function : ProjLib_Plane
99 //=======================================================================
101 ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Hypr& H)
108 //=======================================================================
111 //=======================================================================
113 void ProjLib_Plane::Init(const gp_Pln& Pl)
115 myType = GeomAbs_OtherCurve;
116 isDone = Standard_False;
117 myIsPeriodic = Standard_False;
121 //=======================================================================
122 //function : EvalPnt2d / EvalDir2d
123 //purpose : returns the Projected Pnt / Dir in the parametrization range
125 //=======================================================================
127 static gp_Pnt2d EvalPnt2d( const gp_Pnt P, const gp_Pln& Pl)
129 gp_Vec OP( Pl.Location(),P);
130 return gp_Pnt2d( OP.Dot(gp_Vec(Pl.Position().XDirection())),
131 OP.Dot(gp_Vec(Pl.Position().YDirection())));
134 static gp_Dir2d EvalDir2d( const gp_Dir& D, const gp_Pln& Pl)
136 return gp_Dir2d( D.Dot(Pl.Position().XDirection()),
137 D.Dot(Pl.Position().YDirection()));
141 //=======================================================================
144 //=======================================================================
146 void ProjLib_Plane::Project(const gp_Lin& L)
148 myType = GeomAbs_Line;
149 myLin = gp_Lin2d(EvalPnt2d(L.Location() ,myPlane),
150 EvalDir2d(L.Direction(),myPlane) );
151 isDone = Standard_True;
155 //=======================================================================
158 //=======================================================================
160 void ProjLib_Plane::Project(const gp_Circ& C)
163 myType = GeomAbs_Circle;
165 gp_Pnt2d P2d = EvalPnt2d(C.Location(),myPlane);
166 gp_Dir2d X2d = EvalDir2d(C.Position().XDirection(),myPlane);
167 gp_Dir2d Y2d = EvalDir2d(C.Position().YDirection(),myPlane);
168 gp_Ax22d Ax(P2d,X2d,Y2d);
170 myCirc = gp_Circ2d(Ax, C.Radius());
171 myIsPeriodic = Standard_True;
172 isDone = Standard_True;
176 //=======================================================================
179 //=======================================================================
181 void ProjLib_Plane::Project(const gp_Elips& E)
183 myType = GeomAbs_Ellipse;
185 gp_Pnt2d P2d = EvalPnt2d(E.Location(),myPlane);
186 gp_Dir2d X2d = EvalDir2d(E.Position().XDirection(),myPlane);
187 gp_Dir2d Y2d = EvalDir2d(E.Position().YDirection(),myPlane);
188 gp_Ax22d Ax(P2d,X2d,Y2d);
190 myElips = gp_Elips2d(Ax,E.MajorRadius(),E.MinorRadius());
191 myIsPeriodic = Standard_True;
192 isDone = Standard_True;
196 //=======================================================================
199 //=======================================================================
201 void ProjLib_Plane::Project(const gp_Parab& P)
203 myType = GeomAbs_Parabola;
205 gp_Pnt2d P2d = EvalPnt2d(P.Location(),myPlane);
206 gp_Dir2d X2d = EvalDir2d(P.Position().XDirection(),myPlane);
207 gp_Dir2d Y2d = EvalDir2d(P.Position().YDirection(),myPlane);
208 gp_Ax22d Ax(P2d,X2d,Y2d);
210 myParab = gp_Parab2d(Ax,P.Focal());
211 isDone = Standard_True;
215 //=======================================================================
218 //=======================================================================
220 void ProjLib_Plane::Project(const gp_Hypr& H)
222 myType = GeomAbs_Hyperbola;
224 gp_Pnt2d P2d = EvalPnt2d(H.Location(),myPlane);
225 gp_Dir2d X2d = EvalDir2d(H.Position().XDirection(),myPlane);
226 gp_Dir2d Y2d = EvalDir2d(H.Position().YDirection(),myPlane);
227 gp_Ax22d Ax(P2d,X2d,Y2d);
229 myHypr = gp_Hypr2d(Ax,H.MajorRadius(),H.MinorRadius());
230 isDone = Standard_True;