Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-06 09:20:27

0001 // Created on: 1994-03-18
0002 // Created by: Bruno DUMORTIER
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GeomAPI_ExtremaSurfaceSurface_HeaderFile
0018 #define _GeomAPI_ExtremaSurfaceSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Extrema_ExtSS.hxx>
0026 class Geom_Surface;
0027 class gp_Pnt;
0028 
0029 //! Describes functions for computing all the extrema
0030 //! between two surfaces.
0031 //! An ExtremaSurfaceSurface algorithm minimizes or
0032 //! maximizes the distance between a point on the first
0033 //! surface and a point on the second surface. Results
0034 //! are start and end points of perpendiculars common to the two surfaces.
0035 //! Solutions consist of pairs of points, and an extremum
0036 //! is considered to be a segment joining the two points of a solution.
0037 //! An ExtremaSurfaceSurface object provides a framework for:
0038 //! -   defining the construction of the extrema,
0039 //! -   implementing the construction algorithm, and
0040 //! -   consulting the results.
0041 //! Warning
0042 //! In some cases, the nearest points between the two
0043 //! surfaces do not correspond to one of the computed
0044 //! extrema. Instead, they may be given by:
0045 //! -   a point of a bounding curve of one surface and one of the following:
0046 //! -   its orthogonal projection on the other surface,
0047 //! -   a point of a bounding curve of the other surface; or
0048 //! -   any point on intersection curves between the two surfaces.
0049 class GeomAPI_ExtremaSurfaceSurface
0050 {
0051 public:
0052   DEFINE_STANDARD_ALLOC
0053 
0054   //! Constructs an empty algorithm for computing
0055   //! extrema between two surfaces. Use an Init function
0056   //! to define the surfaces on which it is going to work.
0057   Standard_EXPORT GeomAPI_ExtremaSurfaceSurface();
0058 
0059   //! Computes the extrema distances between the
0060   //! surfaces <S1> and <S2>
0061   Standard_EXPORT GeomAPI_ExtremaSurfaceSurface(const occ::handle<Geom_Surface>& S1,
0062                                                 const occ::handle<Geom_Surface>& S2);
0063 
0064   //! Computes the extrema distances between
0065   //! the portion of the surface S1 limited by the
0066   //! two values of parameter (U1min,U1max) in
0067   //! the u parametric direction, and by the two
0068   //! values of parameter (V1min,V1max) in the v
0069   //! parametric direction, and
0070   //! -   the portion of the surface S2 limited by the
0071   //! two values of parameter (U2min,U2max) in
0072   //! the u parametric direction, and by the two
0073   //! values of parameter (V2min,V2max) in the v
0074   //! parametric direction.
0075   Standard_EXPORT GeomAPI_ExtremaSurfaceSurface(const occ::handle<Geom_Surface>& S1,
0076                                                 const occ::handle<Geom_Surface>& S2,
0077                                                 const double                     U1min,
0078                                                 const double                     U1max,
0079                                                 const double                     V1min,
0080                                                 const double                     V1max,
0081                                                 const double                     U2min,
0082                                                 const double                     U2max,
0083                                                 const double                     V2min,
0084                                                 const double                     V2max);
0085 
0086   //! Initializes this algorithm with the given arguments
0087   //! and computes the extrema distances between the
0088   //! surfaces <S1> and <S2>
0089   Standard_EXPORT void Init(const occ::handle<Geom_Surface>& S1,
0090                             const occ::handle<Geom_Surface>& S2);
0091 
0092   //! Initializes this algorithm with the given arguments
0093   //! and computes the extrema distances between -
0094   //! the portion of the surface S1 limited by the two
0095   //! values of parameter (U1min,U1max) in the u
0096   //! parametric direction, and by the two values of
0097   //! parameter (V1min,V1max) in the v parametric direction, and
0098   //! -   the portion of the surface S2 limited by the two
0099   //! values of parameter (U2min,U2max) in the u
0100   //! parametric direction, and by the two values of
0101   //! parameter (V2min,V2max) in the v parametric direction.
0102   Standard_EXPORT void Init(const occ::handle<Geom_Surface>& S1,
0103                             const occ::handle<Geom_Surface>& S2,
0104                             const double                     U1min,
0105                             const double                     U1max,
0106                             const double                     V1min,
0107                             const double                     V1max,
0108                             const double                     U2min,
0109                             const double                     U2max,
0110                             const double                     V2min,
0111                             const double                     V2max);
0112 
0113   //! Returns the number of extrema computed by this algorithm.
0114   //! Note: if this algorithm fails, NbExtrema returns 0.
0115   Standard_EXPORT int NbExtrema() const;
0116   Standard_EXPORT     operator int() const;
0117 
0118   //! Returns the points P1 on the first surface and P2 on
0119   //! the second surface, which are the ends of the
0120   //! extremum of index Index computed by this algorithm.
0121   //! Exceptions
0122   //! Standard_OutOfRange if Index is not in the range [
0123   //! 1,NbExtrema ], where NbExtrema is the
0124   //! number of extrema computed by this algorithm.
0125   Standard_EXPORT void Points(const int Index, gp_Pnt& P1, gp_Pnt& P2) const;
0126 
0127   //! Returns the parameters (U1,V1) of the point on the
0128   //! first surface, and (U2,V2) of the point on the second
0129   //! surface, which are the ends of the extremum of index
0130   //! Index computed by this algorithm.
0131   //! Exceptions
0132   //! Standard_OutOfRange if Index is not in the range [
0133   //! 1,NbExtrema ], where NbExtrema is the
0134   //! number of extrema computed by this algorithm.
0135   Standard_EXPORT void Parameters(const int Index,
0136                                   double&   U1,
0137                                   double&   V1,
0138                                   double&   U2,
0139                                   double&   V2) const;
0140 
0141   //! Computes the distance between the end points of the
0142   //! extremum of index Index computed by this algorithm.
0143   //! Exceptions
0144   //! Standard_OutOfRange if Index is not in the range [
0145   //! 1,NbExtrema ], where NbExtrema is the
0146   //! number of extrema computed by this algorithm.
0147   Standard_EXPORT double Distance(const int Index) const;
0148 
0149   //! Returns True if the surfaces are parallel
0150   bool IsParallel() const { return myExtSS.IsParallel(); }
0151 
0152   //! Returns the points P1 on the first surface and P2 on
0153   //! the second surface, which are the ends of the
0154   //! shortest extremum computed by this algorithm.
0155   //! Exceptions StdFail_NotDone if this algorithm fails.
0156   Standard_EXPORT void NearestPoints(gp_Pnt& P1, gp_Pnt& P2) const;
0157 
0158   //! Returns the parameters (U1,V1) of the point on the
0159   //! first surface and (U2,V2) of the point on the second
0160   //! surface, which are the ends of the shortest extremum
0161   //! computed by this algorithm.
0162   //! Exceptions - StdFail_NotDone if this algorithm fails.
0163   Standard_EXPORT void LowerDistanceParameters(double& U1,
0164                                                double& V1,
0165                                                double& U2,
0166                                                double& V2) const;
0167 
0168   //! Computes the distance between the end points of the
0169   //! shortest extremum computed by this algorithm.
0170   //! Exceptions StdFail_NotDone if this algorithm fails.
0171   Standard_EXPORT double LowerDistance() const;
0172   Standard_EXPORT        operator double() const;
0173 
0174   //! return the algorithmic object from Extrema
0175   const Extrema_ExtSS& Extrema() const;
0176 
0177 private:
0178   bool          myIsDone;
0179   int           myIndex;
0180   Extrema_ExtSS myExtSS;
0181 };
0182 
0183 #include <GeomAPI_ExtremaSurfaceSurface.lxx>
0184 
0185 #endif // _GeomAPI_ExtremaSurfaceSurface_HeaderFile