1 // Created on: 1992-03-25
2 // Created by: Herve LEGRAND
3 // Copyright (c) 1992-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 _GCPnts_AbscissaPoint_HeaderFile
18 #define _GCPnts_AbscissaPoint_HeaderFile
19 
20 #include <CPnts_AbscissaPoint.hxx>
21 
22 class Adaptor3d_Curve;
23 class Adaptor2d_Curve2d;
24 
25 //! Provides an algorithm to compute a point on a curve
26 //! situated at a given distance from another point on the curve,
27 //! the distance being measured along the curve (curvilinear abscissa on the curve).
28 //! This algorithm is also used to compute the length of a curve.
29 //! An AbscissaPoint object provides a framework for:
30 //! -   defining the point to compute
31 //! -   implementing the construction algorithm
32 //! -   consulting the result.
33 class GCPnts_AbscissaPoint
34 {
35 public:
36 
37   DEFINE_STANDARD_ALLOC
38 
39   //! Computes the length of the 3D Curve.
40   Standard_EXPORT static Standard_Real Length (const Adaptor3d_Curve& theC);
41 
42   //! Computes the length of the 2D Curve.
43   Standard_EXPORT static Standard_Real Length (const Adaptor2d_Curve2d& theC);
44 
45   //! Computes the length of the 3D Curve with the given tolerance.
46   Standard_EXPORT static Standard_Real Length (const Adaptor3d_Curve& theC,
47                                                const Standard_Real theTol);
48 
49   //! Computes the length of the 2D Curve with the given tolerance.
50   Standard_EXPORT static Standard_Real Length (const Adaptor2d_Curve2d& theC,
51                                                const Standard_Real theTol);
52 
53   //! Computes the length of the 3D Curve.
54   Standard_EXPORT static Standard_Real Length (const Adaptor3d_Curve& theC,
55                                                const Standard_Real theU1, const Standard_Real theU2);
56 
57   //! Computes the length of the 2D Curve.
58   Standard_EXPORT static Standard_Real Length (const Adaptor2d_Curve2d& theC,
59                                                const Standard_Real theU1, const Standard_Real theU2);
60 
61   //! Computes the length of the 3D Curve with the given tolerance.
62   Standard_EXPORT static Standard_Real Length (const Adaptor3d_Curve& theC,
63                                                const Standard_Real theU1, const Standard_Real theU2,
64                                                const Standard_Real theTol);
65 
66   //! Computes the length of the Curve with the given tolerance.
67   Standard_EXPORT static Standard_Real Length (const Adaptor2d_Curve2d& theC,
68                                                const Standard_Real theU1, const Standard_Real theU2,
69                                                const Standard_Real theTol);
70 
71 public:
72 
73   //! Empty constructor.
74   Standard_EXPORT GCPnts_AbscissaPoint();
75 
76   //! The algorithm computes a point on a curve at the
77   //! distance theAbscissa from the point of parameter theU0.
78   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor3d_Curve& theC,
79                                         const Standard_Real theAbscissa,
80                                         const Standard_Real theU0);
81 
82   //! The algorithm computes a point on a curve at
83   //! the distance theAbscissa from the point of parameter
84   //! theU0 with the given tolerance.
85   Standard_EXPORT GCPnts_AbscissaPoint (const Standard_Real theTol,
86                                         const Adaptor3d_Curve& theC,
87                                         const Standard_Real theAbscissa,
88                                         const Standard_Real theU0);
89 
90   //! The algorithm computes a point on a curve at
91   //! the distance theAbscissa from the point of parameter
92   //! theU0 with the given tolerance.
93   Standard_EXPORT GCPnts_AbscissaPoint (const Standard_Real theTol,
94                                         const Adaptor2d_Curve2d& theC,
95                                         const Standard_Real theAbscissa,
96                                         const Standard_Real theU0);
97 
98   //! The algorithm computes a point on a curve at the
99   //! distance theAbscissa from the point of parameter theU0.
100   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor2d_Curve2d& theC,
101                                         const Standard_Real theAbscissa,
102                                         const Standard_Real theU0);
103 
104   //! The algorithm computes a point on a curve at the
105   //! distance theAbscissa from the point of parameter theU0.
106   //! theUi is the starting value used in the iterative process
107   //! which find the solution, it must be close to the final solution.
108   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor3d_Curve& theC,
109                                         const Standard_Real theAbscissa,
110                                         const Standard_Real theU0, const Standard_Real theUi);
111 
112   //! The algorithm computes a point on a curve at the
113   //! distance theAbscissa from the point of parameter theU0.
114   //! theUi is the starting value used in the iterative process
115   //! which find the solution, it must be closed to the final solution
116   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor2d_Curve2d& theC,
117                                         const Standard_Real theAbscissa,
118                                         const Standard_Real theU0, const Standard_Real theUi);
119 
120   //! The algorithm computes a point on a curve at the
121   //! distance theAbscissa from the point of parameter theU0.
122   //! theUi is the starting value used in the iterative process
123   //! which find the solution, it must be close to the final solution
124   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor3d_Curve& theC,
125                                         const Standard_Real theAbscissa,
126                                         const Standard_Real theU0, const Standard_Real theUi,
127                                         const Standard_Real theTol);
128 
129   //! The algorithm computes a point on a curve at the
130   //! distance theAbscissa from the point of parameter theU0.
131   //! theUi is the starting value used in the iterative process
132   //! which find the solution, it must be close to the final solution
133   Standard_EXPORT GCPnts_AbscissaPoint (const Adaptor2d_Curve2d& theC,
134                                         const Standard_Real theAbscissa,
135                                         const Standard_Real theU0, const Standard_Real theUi,
136                                         const Standard_Real theTol);
137 
138   //! True if the computation was successful, False otherwise.
139   //! IsDone is a protection against:
140   //! -   non-convergence of the algorithm
141   //! -   querying the results before computation.
IsDone() const142   Standard_Boolean IsDone () const
143   {
144     return myComputer.IsDone ();
145   }
146 
147   //! Returns the parameter on the curve of the point
148   //! solution of this algorithm.
149   //! Exceptions
150   //! StdFail_NotDone if the computation was not
151   //! successful, or was not done.
Parameter() const152   Standard_Real Parameter () const
153   {
154     return myComputer.Parameter ();
155   }
156 
157 private:
158 
159   //! Computes the length of the Curve with the optional tolerance.
160   template<class TheCurve>
161   static Standard_Real length (const TheCurve& theC,
162                                const Standard_Real theU1, const Standard_Real theU2,
163                                const Standard_Real* theTol);
164 
165   //! Performs algorithm from the point of parameter.
166   template<class TheCurve>
167   void compute (const TheCurve& theC,
168                 const Standard_Real theAbscissa,
169                 const Standard_Real theU0);
170 
171   //! Performs algorithm from the point of parameter with the given tolerance.
172   template<class TheCurve>
173   void advCompute (const Standard_Real theTol,
174                    const TheCurve& theC,
175                    const Standard_Real theAbscissa,
176                    const Standard_Real theU0);
177 
178 private:
179   CPnts_AbscissaPoint myComputer;
180 };
181 
182 #endif // _GCPnts_AbscissaPoint_HeaderFile
183