0026196: Wrong result obtained by projection algorithm.
[occt.git] / src / ProjLib / ProjLib_ProjectOnPlane.hxx
1 // Created on: 1994-09-02
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _ProjLib_ProjectOnPlane_HeaderFile
18 #define _ProjLib_ProjectOnPlane_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <gp_Ax3.hxx>
25 #include <gp_Dir.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Real.hxx>
28 #include <GeomAbs_CurveType.hxx>
29 #include <Adaptor3d_Curve.hxx>
30 #include <GeomAbs_Shape.hxx>
31 #include <Standard_Integer.hxx>
32 #include <TColStd_Array1OfReal.hxx>
33 class Adaptor3d_HCurve;
34 class GeomAdaptor_HCurve;
35 class Standard_OutOfRange;
36 class Standard_NoSuchObject;
37 class Standard_DomainError;
38 class Standard_ConstructionError;
39 class Standard_NotImplemented;
40 class gp_Ax3;
41 class gp_Dir;
42 class gp_Pnt;
43 class gp_Vec;
44 class gp_Lin;
45 class gp_Circ;
46 class gp_Elips;
47 class gp_Hypr;
48 class gp_Parab;
49 class Geom_BezierCurve;
50 class Geom_BSplineCurve;
51
52
53 //! Class  used  to project  a 3d curve   on a plane.  The
54 //! result will be a 3d curve.
55 //!
56 //! You  can ask   the projected curve  to  have  the same
57 //! parametrization as the original curve.
58 //!
59 //! The projection can be done  along every direction  not
60 //! parallel to the plane.
61 class ProjLib_ProjectOnPlane  : public Adaptor3d_Curve
62 {
63 public:
64
65   DEFINE_STANDARD_ALLOC
66
67   
68   //! Empty constructor.
69   Standard_EXPORT ProjLib_ProjectOnPlane();
70   
71   //! The projection will be normal to the Plane defined
72   //! by the Ax3 <Pl>.
73   Standard_EXPORT ProjLib_ProjectOnPlane(const gp_Ax3& Pl);
74   
75   //! The projection will be  along the direction <D> on
76   //! the plane defined by the Ax3 <Pl>.
77   //! raises  if the direction  <D>  is parallel  to the
78   //! plane <Pl>.
79   Standard_EXPORT ProjLib_ProjectOnPlane(const gp_Ax3& Pl, const gp_Dir& D);
80   
81   //! Sets the  Curve  and perform  the projection.   if
82   //! <KeepParametrization> is true, the parametrization
83   //! of the Projected Curve <PC>  will  be the same  as
84   //! the parametrization of the initial  curve <C>.  It
85   //! meens: proj(C(u)) = PC(u) for  each u.  Otherwize,
86   //! the parametrization may change.
87   Standard_EXPORT void Load (const Handle(Adaptor3d_HCurve)& C, const Standard_Real Tolerance, const Standard_Boolean KeepParametrization = Standard_True);
88   
89   Standard_EXPORT const gp_Ax3& GetPlane() const;
90   
91   Standard_EXPORT const gp_Dir& GetDirection() const;
92   
93   Standard_EXPORT const Handle(Adaptor3d_HCurve)& GetCurve() const;
94   
95   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
96   
97   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
98   
99   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
100   
101   //! If necessary,  breaks the  curve in  intervals  of
102   //! continuity  <S>.    And  returns   the number   of
103   //! intervals.
104   Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
105   
106   //! Stores in <T> the  parameters bounding the intervals
107   //! of continuity <S>.
108   //!
109   //! The array must provide  enough room to  accomodate
110   //! for the parameters. i.e. T.Length() > NbIntervals()
111   Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
112   
113   //! Returns    a  curve equivalent   of  <me>  between
114   //! parameters <First>  and <Last>. <Tol>  is used  to
115   //! test for 3d points confusion.
116   //! If <First> >= <Last>
117   Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
118   
119   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
120   
121   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
122   
123   Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
124   
125   //! Computes the point of parameter U on the curve.
126   Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE;
127   
128   //! Computes the point of parameter U on the curve.
129   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
130   
131   //! Computes the point of parameter U on the curve with its
132   //! first derivative.
133   //! Raised if the continuity of the current interval
134   //! is not C1.
135   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
136   
137
138   //! Returns the point P of parameter U, the first and second
139   //! derivatives V1 and V2.
140   //! Raised if the continuity of the current interval
141   //! is not C2.
142   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
143   
144
145   //! Returns the point P of parameter U, the first, the second
146   //! and the third derivative.
147   //! Raised if the continuity of the current interval
148   //! is not C3.
149   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
150   
151
152   //! The returned vector gives the value of the derivative for the
153   //! order of derivation N.
154   //! Raised if the continuity of the current interval
155   //! is not CN.
156   //! Raised if N < 1.
157   Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
158   
159   //! Returns the parametric  resolution corresponding
160   //! to the real space resolution <R3d>.
161   Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE;
162   
163   //! Returns  the  type of the   curve  in the  current
164   //! interval :   Line,   Circle,   Ellipse, Hyperbola,
165   //! Parabola, BezierCurve, BSplineCurve, OtherCurve.
166   Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE;
167   
168   Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
169   
170   Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
171   
172   Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
173   
174   Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
175   
176   Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
177   
178   Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
179   
180   Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
181   
182   Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
183   
184   Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
185   
186   //! Warning ! this will NOT make a copy of the
187   //! Bezier Curve : If you want to modify
188   //! the Curve please make a copy yourself
189   //! Also it will NOT trim the surface to
190   //! myFirst/Last.
191   Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
192   
193   //! Warning ! this will NOT make a copy of the
194   //! BSpline Curve : If you want to modify
195   //! the Curve please make a copy yourself
196   //! Also it will NOT trim the surface to
197   //! myFirst/Last.
198   Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
199
200
201
202
203 protected:
204
205
206
207
208
209 private:
210
211
212
213   Handle(Adaptor3d_HCurve) myCurve;
214   gp_Ax3 myPlane;
215   gp_Dir myDirection;
216   Standard_Boolean myKeepParam;
217   Standard_Real myFirstPar;
218   Standard_Real myLastPar;
219   Standard_Real myTolerance;
220   GeomAbs_CurveType myType;
221   Handle(GeomAdaptor_HCurve) myResult;
222   Standard_Boolean myIsApprox;
223
224
225 };
226
227
228
229
230
231
232
233 #endif // _ProjLib_ProjectOnPlane_HeaderFile