0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Geom2dAPI / Geom2dAPI_ProjectPointOnCurve.hxx
CommitLineData
42cf5bc1 1// Created on: 1994-03-23
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 _Geom2dAPI_ProjectPointOnCurve_HeaderFile
18#define _Geom2dAPI_ProjectPointOnCurve_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Boolean.hxx>
25#include <Standard_Integer.hxx>
26#include <Extrema_ExtPC2d.hxx>
27#include <Geom2dAdaptor_Curve.hxx>
42cf5bc1 28class Standard_OutOfRange;
29class StdFail_NotDone;
30class gp_Pnt2d;
31class Geom2d_Curve;
32class Extrema_ExtPC2d;
33
34
35
36//! This class implements methods for computing all the orthogonal
37//! projections of a 2D point onto a 2D curve.
38class Geom2dAPI_ProjectPointOnCurve
39{
40public:
41
42 DEFINE_STANDARD_ALLOC
43
44
45 //! Constructs an empty projector algorithm. Use an Init
46 //! function to define the point and the curve on which it is going to work.
47 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve();
48
49 //! Create the projection of a point <P> on a curve
50 //! <Curve>
51 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve);
52
53 //! Create the projection of a point <P> on a curve
54 //! <Curve> limited by the two points of parameter Umin and Usup.
55 //! Warning
56 //! Use the function NbPoints to obtain the number of solutions. If
57 //! projection fails, NbPoints returns 0.
09324e85 58 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
42cf5bc1 59
60 //! Initializes this algorithm with the given arguments, and
61 //! computes the orthogonal projections of a point <P> on a curve <Curve>
62 Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve);
63
64 //! Initializes this algorithm with the given arguments, and
65 //! computes the orthogonal projections of the point P onto the portion
66 //! of the curve Curve limited by the two points of parameter Umin and Usup.
09324e85 67 Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
42cf5bc1 68
69 //! return the number of of computed
70 //! orthogonal projectionn points.
71 Standard_EXPORT Standard_Integer NbPoints() const;
72Standard_EXPORT operator Standard_Integer() const;
73
74 //! Returns the orthogonal projection
75 //! on the curve. Index is a number of a computed point.
76 //! Exceptions
77 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
78 //! NbPoints is the number of solution points.
79 Standard_EXPORT gp_Pnt2d Point (const Standard_Integer Index) const;
80
81 //! Returns the parameter on the curve
82 //! of a point which is the orthogonal projection. Index is a number of a
83 //! computed projected point.
84 //! Exceptions
85 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
86 //! NbPoints is the number of solution points.
09324e85 87 Standard_EXPORT Standard_Real Parameter (const Standard_Integer Index) const;
42cf5bc1 88
89 //! Returns the parameter on the curve
90 //! of a point which is the orthogonal projection. Index is a number of a
91 //! computed projected point.
92 //! Exceptions
93 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
94 //! NbPoints is the number of solution points
09324e85 95 Standard_EXPORT void Parameter (const Standard_Integer Index, Standard_Real& U) const;
42cf5bc1 96
97 //! Computes the distance between the
98 //! point and its computed orthogonal projection on the curve. Index is a
99 //! number of computed projected point.
100 //! Exceptions
101 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
102 //! NbPoints is the number of solution points.
09324e85 103 Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
42cf5bc1 104
105 //! Returns the nearest orthogonal projection of the point on the curve.
106 //! Exceptions
107 //! StdFail_NotDone if this algorithm fails.
108 Standard_EXPORT gp_Pnt2d NearestPoint() const;
109Standard_EXPORT operator gp_Pnt2d() const;
110
111 //! Returns the parameter on the curve
112 //! of the nearest orthogonal projection of the point.
113 //! Exceptions
114 //! StdFail_NotDone if this algorithm fails.
09324e85 115 Standard_EXPORT Standard_Real LowerDistanceParameter() const;
42cf5bc1 116
117 //! Computes the distance between the
118 //! point and its nearest orthogonal projection on the curve.
119 //! Exceptions
120 //! StdFail_NotDone if this algorithm fails.
09324e85 121 Standard_EXPORT Standard_Real LowerDistance() const;
42cf5bc1 122Standard_EXPORT operator Standard_Real() const;
123
124 //! return the algorithmic object from Extrema
125 const Extrema_ExtPC2d& Extrema() const;
126
42cf5bc1 127private:
128
42cf5bc1 129 Standard_Boolean myIsDone;
130 Standard_Integer myIndex;
131 Extrema_ExtPC2d myExtPC;
132 Geom2dAdaptor_Curve myC;
133
134
135};
136
137
138#include <Geom2dAPI_ProjectPointOnCurve.lxx>
139
140
141
142
143
144#endif // _Geom2dAPI_ProjectPointOnCurve_HeaderFile