0026196: Wrong result obtained by projection algorithm.
[occt.git] / src / ProjLib / ProjLib.cxx
CommitLineData
b311480e 1// Created on: 1993-08-24
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <ElSLib.hxx>
19#include <gp_Circ.hxx>
20#include <gp_Circ2d.hxx>
21#include <gp_Cone.hxx>
22#include <gp_Cylinder.hxx>
23#include <gp_Elips.hxx>
24#include <gp_Elips2d.hxx>
25#include <gp_Hypr.hxx>
26#include <gp_Hypr2d.hxx>
27#include <gp_Lin.hxx>
28#include <gp_Lin2d.hxx>
29#include <gp_Parab.hxx>
30#include <gp_Parab2d.hxx>
31#include <gp_Pln.hxx>
32#include <gp_Pnt.hxx>
33#include <gp_Pnt2d.hxx>
34#include <gp_Sphere.hxx>
35#include <gp_Torus.hxx>
36#include <ProjLib.hxx>
7fd59977 37#include <ProjLib_Cone.hxx>
42cf5bc1 38#include <ProjLib_Cylinder.hxx>
39#include <ProjLib_Plane.hxx>
7fd59977 40#include <ProjLib_Sphere.hxx>
41#include <ProjLib_Torus.hxx>
42
7fd59977 43//=======================================================================
44//function : Project
45//purpose :
46//=======================================================================
7fd59977 47gp_Pnt2d ProjLib::Project(const gp_Pln& Pl, const gp_Pnt& P)
48{
49 Standard_Real U, V;
50 ElSLib::Parameters(Pl, P, U, V);
51 return gp_Pnt2d(U,V);
52}
53
54
55//=======================================================================
56//function : Project
57//purpose :
58//=======================================================================
59
60gp_Lin2d ProjLib::Project(const gp_Pln& Pl, const gp_Lin& L)
61{
62 ProjLib_Plane Proj( Pl, L);
63 return Proj.Line();
64}
65
66
67//=======================================================================
68//function : Project
69//purpose :
70//=======================================================================
71
72gp_Circ2d ProjLib::Project(const gp_Pln& Pl, const gp_Circ& C)
73{
74 ProjLib_Plane Proj( Pl, C);
75 return Proj.Circle();
76}
77
78
79//=======================================================================
80//function : Project
81//purpose :
82//=======================================================================
83
84gp_Elips2d ProjLib::Project(const gp_Pln& Pl, const gp_Elips& E)
85{
86 ProjLib_Plane Proj( Pl, E);
87 return Proj.Ellipse();
88}
89
90
91//=======================================================================
92//function : Project
93//purpose :
94//=======================================================================
95
96gp_Parab2d ProjLib::Project(const gp_Pln& Pl, const gp_Parab& P)
97{
98 ProjLib_Plane Proj( Pl, P);
99 return Proj.Parabola();
100}
101
102
103//=======================================================================
104//function : Project
105//purpose :
106//=======================================================================
107
108gp_Hypr2d ProjLib::Project(const gp_Pln& Pl, const gp_Hypr& H)
109{
110 ProjLib_Plane Proj( Pl, H);
111 return Proj.Hyperbola();
112}
113
114
115//=======================================================================
116//function : Project
117//purpose :
118//=======================================================================
119
120gp_Pnt2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Pnt& P)
121{
122 Standard_Real U, V;
123 ElSLib::Parameters(Cy, P, U, V);
124 return gp_Pnt2d(U,V);
125}
126
127
128//=======================================================================
129//function : Project
130//purpose :
131//=======================================================================
132
133gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Lin& L)
134{
135 ProjLib_Cylinder Proj( Cy, L);
136 return Proj.Line();
137}
138
139
140//=======================================================================
141//function : Project
142//purpose :
143//=======================================================================
144
145gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Circ& Ci)
146{
147 ProjLib_Cylinder Proj( Cy, Ci);
148 return Proj.Line();
149}
150
151
152//=======================================================================
153//function : Project
154//purpose :
155//=======================================================================
156
157gp_Pnt2d ProjLib::Project(const gp_Cone& Co, const gp_Pnt& P)
158{
159 Standard_Real U, V;
160 ElSLib::Parameters(Co, P, U, V);
161 return gp_Pnt2d(U,V);
162}
163
164
165//=======================================================================
166//function : Project
167//purpose :
168//=======================================================================
169
170gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Lin& L)
171{
172 ProjLib_Cone Proj( Co, L);
173 return Proj.Line();
174}
175
176
177//=======================================================================
178//function : Project
179//purpose :
180//=======================================================================
181
182gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Circ& Ci)
183{
184 ProjLib_Cone Proj( Co, Ci);
185 return Proj.Line();
186}
187
188
189//=======================================================================
190//function : Project
191//purpose :
192//=======================================================================
193
194gp_Pnt2d ProjLib::Project(const gp_Sphere& Sp, const gp_Pnt& P)
195{
196 Standard_Real U, V;
197 ElSLib::Parameters(Sp, P, U, V);
198 return gp_Pnt2d(U,V);
199}
200
201
202//=======================================================================
203//function : Project
204//purpose :
205//=======================================================================
206
207gp_Lin2d ProjLib::Project(const gp_Sphere& Sp, const gp_Circ& Ci)
208{
209 ProjLib_Sphere Proj( Sp, Ci);
210 return Proj.Line();
211}
212
213
214//=======================================================================
215//function : Project
216//purpose :
217//=======================================================================
218
219gp_Pnt2d ProjLib::Project(const gp_Torus& To, const gp_Pnt& P)
220{
221 Standard_Real U, V;
222 ElSLib::Parameters(To, P, U, V);
223 return gp_Pnt2d(U,V);
224}
225
226
227//=======================================================================
228//function : Project
229//purpose :
230//=======================================================================
231
232gp_Lin2d ProjLib::Project(const gp_Torus& To, const gp_Circ& Ci)
233{
234 ProjLib_Torus Proj( To, Ci);
235 return Proj.Line();
236}