CommitLineData
42cf5bc1 1// Created on: 1994-03-23
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1994-1999 Matra Datavision
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
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_ExtCC2d.hxx>
42cf5bc1 28class Standard_OutOfRange;
29class StdFail_NotDone;
30class Geom2d_Curve;
31class gp_Pnt2d;
32class Extrema_ExtCC2d;
33
34
35//! Describes functions for computing all the extrema
36//! between two 2D curves.
37//! An ExtremaCurveCurve algorithm minimizes or
38//! maximizes the distance between a point on the first
39//! curve and a point on the second curve. Thus, it
40//! computes the start point and end point of
41//! perpendiculars common to the two curves (an
42//! intersection point is not an extremum except where
43//! the two curves are tangential at this point).
44//! Solutions consist of pairs of points, and an extremum
45//! is considered to be a segment joining the two points of a solution.
46//! An ExtremaCurveCurve object provides a framework for:
47//! - defining the construction of the extrema,
48//! - implementing the construction algorithm, and
49//! - consulting the results.
50//! Warning
51//! In some cases, the nearest points between two
52//! curves do not correspond to one of the computed
53//! extrema. Instead, they may be given by:
54//! - a limit point of one curve and one of the following:
55//! - its orthogonal projection on the other curve,
56//! - a limit point of the other curve; or
57//! - an intersection point between the two curves.
58class Geom2dAPI_ExtremaCurveCurve
59{
60public:
61
62 DEFINE_STANDARD_ALLOC
63
64
65 //! Computes the extrema between
66 //! - the portion of the curve C1 limited by the two
67 //! points of parameter (U1min,U1max), and
68 //! - the portion of the curve C2 limited by the two
69 //! points of parameter (U2min,U2max).
70 //! Warning
71 //! Use the function NbExtrema to obtain the number
72 //! of solutions. If this algorithm fails, NbExtrema returns 0.
09324e85 73 Standard_EXPORT Geom2dAPI_ExtremaCurveCurve(const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const Standard_Real U1min, const Standard_Real U1max, const Standard_Real U2min, const Standard_Real U2max);
42cf5bc1 74
75 //! Returns the number of extrema computed by this algorithm.
76 //! Note: if this algorithm fails, NbExtrema returns 0.
77 Standard_EXPORT Standard_Integer NbExtrema() const;
78Standard_EXPORT operator Standard_Integer() const;
79
80 //! Returns the points P1 on the first curve and P2 on
81 //! the second curve, which are the ends of the
82 //! extremum of index Index computed by this algorithm.
83 //! Exceptions
84 //! Standard_OutOfRange if Index is not in the range [
85 //! 1,NbExtrema ], where NbExtrema is the
86 //! number of extrema computed by this algorithm.
87 Standard_EXPORT void Points (const Standard_Integer Index, gp_Pnt2d& P1, gp_Pnt2d& P2) const;
88
89 //! Returns the parameters U1 of the point on the first
90 //! curve and U2 of the point on the second curve, which
91 //! are the ends of the extremum of index Index
92 //! computed by this algorithm.
93 //! Exceptions
94 //! Standard_OutOfRange if Index is not in the range [
95 //! 1,NbExtrema ], where NbExtrema is the
96 //! number of extrema computed by this algorithm.
09324e85 97 Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& U1, Standard_Real& U2) const;
42cf5bc1 98
99 //! Computes the distance between the end points of the
100 //! extremum of index Index computed by this algorithm.
101 //! Exceptions
102 //! Standard_OutOfRange if Index is not in the range [
103 //! 1,NbExtrema ], where NbExtrema is the
104 //! number of extrema computed by this algorithm.
09324e85 105 Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
42cf5bc1 106
107 //! Returns the points P1 on the first curve and P2 on
108 //! the second curve, which are the ends of the shortest
109 //! extremum computed by this algorithm.
110 //! Exceptions StdFail_NotDone if this algorithm fails.
111 Standard_EXPORT void NearestPoints (gp_Pnt2d& P1, gp_Pnt2d& P2) const;
112
113 //! Returns the parameters U1 of the point on the first
114 //! curve and U2 of the point on the second curve, which
115 //! are the ends of the shortest extremum computed by this algorithm.
116 //! Exceptions
117 //! StdFail_NotDone if this algorithm fails.
09324e85 118 Standard_EXPORT void LowerDistanceParameters (Standard_Real& U1, Standard_Real& U2) const;
42cf5bc1 119
120 //! Computes the distance between the end points of the
121 //! shortest extremum computed by this algorithm.
122 //! Exceptions - StdFail_NotDone if this algorithm fails.
09324e85 123 Standard_EXPORT Standard_Real LowerDistance() const;
42cf5bc1 124Standard_EXPORT operator Standard_Real() const;
125
126 const Extrema_ExtCC2d& Extrema() const;
127
128
129
130
131protected:
132
133
134
135
136
137private:
138
139
140
141 Standard_Boolean myIsDone;
142 Standard_Integer myIndex;
143 Extrema_ExtCC2d myExtCC;