0027466: The algorithm Extrema_GenLocateExtPS gives incorrect result
[occt.git] / src / Extrema / Extrema_GenExtPS.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-07-18
2// Created by: Modelistation
3// Copyright (c) 1995-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 _Extrema_GenExtPS_HeaderFile
18#define _Extrema_GenExtPS_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_Real.hxx>
26#include <Standard_Integer.hxx>
27#include <Extrema_HArray2OfPOnSurfParams.hxx>
28#include <Extrema_HUBTreeOfSphere.hxx>
29#include <Bnd_HArray1OfSphere.hxx>
e5260e1d 30#include <Extrema_FuncPSNorm.hxx>
42cf5bc1 31#include <Adaptor3d_SurfacePtr.hxx>
32#include <Extrema_ExtFlag.hxx>
33#include <Extrema_ExtAlgo.hxx>
34#include <TColStd_HArray1OfReal.hxx>
35#include <Extrema_POnSurfParams.hxx>
36class StdFail_NotDone;
37class Standard_OutOfRange;
38class Standard_TypeMismatch;
39class gp_Pnt;
40class Adaptor3d_Surface;
41class Extrema_POnSurf;
42class Extrema_POnSurfParams;
43
44
45//! It calculates all the extremum distances
46//! between a point and a surface.
47//! These distances can be minimum or maximum.
48class Extrema_GenExtPS
49{
50public:
51
52 DEFINE_STANDARD_ALLOC
53
54
55 Standard_EXPORT Extrema_GenExtPS();
56
57 //! It calculates all the distances.
58 //! The function F(u,v)=distance(P,S(u,v)) has an
59 //! extremum when gradient(F)=0. The algorithm searchs
60 //! all the zeros inside the definition ranges of the
61 //! surface.
62 //! NbU and NbV are used to locate the close points
63 //! to find the zeros. They must be great enough
64 //! such that if there is N extrema, there will
65 //! be N extrema between P and the grid.
66 //! TolU et TolV are used to determine the conditions
67 //! to stop the iterations; at the iteration number n:
68 //! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
69 Standard_EXPORT Extrema_GenExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
70
71 //! It calculates all the distances.
72 //! The function F(u,v)=distance(P,S(u,v)) has an
73 //! extremum when gradient(F)=0. The algorithm searchs
74 //! all the zeros inside the definition ranges of the
75 //! surface.
76 //! NbU and NbV are used to locate the close points
77 //! to find the zeros. They must be great enough
78 //! such that if there is N extrema, there will
79 //! be N extrema between P and the grid.
80 //! TolU et TolV are used to determine the conditions
81 //! to stop the iterations; at the iteration number n:
82 //! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
83 Standard_EXPORT Extrema_GenExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
84
85 Standard_EXPORT void Initialize (const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real TolU, const Standard_Real TolV);
86
87 Standard_EXPORT void Initialize (const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
88
89 //! the algorithm is done with the point P.
90 //! An exception is raised if the fields have not
91 //! been initialized.
92 Standard_EXPORT void Perform (const gp_Pnt& P);
93
94 Standard_EXPORT void SetFlag (const Extrema_ExtFlag F);
95
96 Standard_EXPORT void SetAlgo (const Extrema_ExtAlgo A);
97
98 //! Returns True if the distances are found.
99 Standard_EXPORT Standard_Boolean IsDone() const;
100
101 //! Returns the number of extremum distances.
102 Standard_EXPORT Standard_Integer NbExt() const;
103
104 //! Returns the value of the Nth resulting square distance.
105 Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
106
107 //! Returns the point of the Nth resulting distance.
108 Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const;
109
110
111
112
113protected:
114
115
116
117
118
119private:
120
121
122 Standard_EXPORT Adaptor3d_SurfacePtr Bidon() const;
123
124 Standard_EXPORT void BuildTree();
125
126 Standard_EXPORT void FindSolution (const gp_Pnt& P, const Extrema_POnSurfParams& theParams);
127
128 //! Selection of points to build grid, depending on the type of surface
129 Standard_EXPORT void GetGridPoints (const Adaptor3d_Surface& theSurf);
130
131 //! Creation of grid of parametric points
132 Standard_EXPORT void BuildGrid (const gp_Pnt& thePoint);
133
134 //! Compute new edge parameters.
135 Standard_EXPORT const Extrema_POnSurfParams& ComputeEdgeParameters (const Standard_Boolean IsUEdge, const Extrema_POnSurfParams& theParam0, const Extrema_POnSurfParams& theParam1, const gp_Pnt& thePoints, const Standard_Real theDiffTol);
136
137
138 Standard_Boolean myDone;
139 Standard_Boolean myInit;
140 Standard_Real myumin;
141 Standard_Real myusup;
142 Standard_Real myvmin;
143 Standard_Real myvsup;
144 Standard_Integer myusample;
145 Standard_Integer myvsample;
146 Standard_Real mytolu;
147 Standard_Real mytolv;
148 Handle(Extrema_HArray2OfPOnSurfParams) myPoints;
149 Extrema_HUBTreeOfSphere mySphereUBTree;
150 Handle(Bnd_HArray1OfSphere) mySphereArray;
e5260e1d 151 Extrema_FuncPSNorm myF;
42cf5bc1 152 Adaptor3d_SurfacePtr myS;
153 Extrema_ExtFlag myFlag;
154 Extrema_ExtAlgo myAlgo;
155 Handle(TColStd_HArray1OfReal) myUParams;
156 Handle(TColStd_HArray1OfReal) myVParams;
157 Handle(Extrema_HArray2OfPOnSurfParams) myFacePntParams;
158 Handle(Extrema_HArray2OfPOnSurfParams) myUEdgePntParams;
159 Handle(Extrema_HArray2OfPOnSurfParams) myVEdgePntParams;
160 Extrema_POnSurfParams myGridParam;
161
162
163};
164
165
166
167
168
169
170
171#endif // _Extrema_GenExtPS_HeaderFile