Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:10

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepExtrema_DistanceSS_HeaderFile
0015 #define _BRepExtrema_DistanceSS_HeaderFile
0016 
0017 #include <BRepExtrema_SeqOfSolution.hxx>
0018 #include <Extrema_ExtFlag.hxx>
0019 #include <Extrema_ExtAlgo.hxx>
0020 #include <Precision.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 class TopoDS_Shape;
0024 class Bnd_Box;
0025 class TopoDS_Vertex;
0026 class TopoDS_Edge;
0027 class TopoDS_Face;
0028 
0029 //! This class allows to compute minimum distance between two brep shapes
0030 //! (face edge vertex) and is used in DistShapeShape class.
0031 class BRepExtrema_DistanceSS
0032 {
0033 public:
0034 
0035   DEFINE_STANDARD_ALLOC
0036 
0037 public: //! @name Constructor from two shapes
0038 
0039   //! Computes the distance between two Shapes (face edge vertex).
0040   //! @param theS1 - First shape
0041   //! @param theS2 - Second shape
0042   //! @param theBox1 - Bounding box of first shape
0043   //! @param theBox2 - Bounding box of second shape
0044   //! @param theDstRef - Initial distance between the shapes to start with
0045   //! @param theDeflection - Maximum deviation of extreme distances from the minimum
0046   //!                        one (default is Precision::Confusion()).
0047   //! @param theExtFlag - Specifies which extrema solutions to look for
0048   //!                     (default is MINMAX, applied only to point-face extrema)
0049   //! @param theExtAlgo - Specifies which extrema algorithm is to be used
0050   //!                     (default is Grad algo, applied only to point-face extrema)
0051   BRepExtrema_DistanceSS(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2,
0052                          const Bnd_Box& theBox1, const Bnd_Box& theBox2,
0053                          const Standard_Real theDstRef,
0054                          const Standard_Real theDeflection = Precision::Confusion(),
0055                          const Extrema_ExtFlag theExtFlag = Extrema_ExtFlag_MINMAX,
0056                          const Extrema_ExtAlgo theExtAlgo = Extrema_ExtAlgo_Grad)
0057   :
0058     myDstRef(theDstRef),
0059     myModif(Standard_False),
0060     myEps(theDeflection),
0061     myFlag(theExtFlag),
0062     myAlgo(theExtAlgo)
0063   {
0064     Perform(theS1, theS2, theBox1, theBox2);
0065   }
0066 
0067 public: //! @name Results
0068 
0069   //! Returns true if the distance has been computed, false otherwise.
0070   Standard_Boolean IsDone() const
0071   {
0072     return myModif;
0073   }
0074 
0075   //! Returns the distance value.
0076   Standard_Real DistValue() const
0077   {
0078     return myDstRef;
0079   }
0080 
0081   //! Returns the list of solutions on the first shape.
0082   const BRepExtrema_SeqOfSolution& Seq1Value() const
0083   {
0084     return mySeqSolShape1;
0085   }
0086 
0087   //! Returns the list of solutions on the second shape.
0088   const BRepExtrema_SeqOfSolution& Seq2Value() const
0089   {
0090     return mySeqSolShape2;
0091   }
0092 
0093 private: //! @name private methods performing the search
0094 
0095   //! Computes the distance between two Shapes (face edge vertex).
0096   //! General method to sort out the shape types and call the specific method.
0097   Standard_EXPORT void Perform(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2,
0098                                const Bnd_Box& theBox1,    const Bnd_Box& theBox2);
0099 
0100   //! Computes the distance between two vertices.
0101   void Perform(const TopoDS_Vertex& S1, const TopoDS_Vertex& S2,
0102                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0103                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0104 
0105   //! Computes the minimum distance between a vertex and an edge.
0106   void Perform(const TopoDS_Vertex& theS1, const TopoDS_Edge& theS2,
0107                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0108                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0109 
0110   //! Computes the minimum distance between a vertex and a face.
0111   void Perform(const TopoDS_Vertex& theS1, const TopoDS_Face& theS2,
0112                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0113                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0114 
0115   //! Computes the minimum distance between two edges.
0116   void Perform(const TopoDS_Edge& theS1, const TopoDS_Edge& theS2,
0117                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0118                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0119 
0120   //! Computes the minimum distance between an edge and a face.
0121   void Perform(const TopoDS_Edge& theS1, const TopoDS_Face& theS2,
0122                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0123                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0124 
0125   //! Computes the minimum distance between two faces.
0126   void Perform(const TopoDS_Face& theS1, const TopoDS_Face& theS2,
0127                BRepExtrema_SeqOfSolution& theSeqSolShape1,
0128                BRepExtrema_SeqOfSolution& theSeqSolShape2);
0129 
0130 private: //! @name Fields
0131 
0132   BRepExtrema_SeqOfSolution mySeqSolShape1; //!< Solutions on the first shape
0133   BRepExtrema_SeqOfSolution mySeqSolShape2; //!< Solutions on the second shape
0134   Standard_Real myDstRef;   //!< The minimal distance found
0135   Standard_Boolean myModif; //!< Flag indicating whether the solution was improved or not
0136   Standard_Real myEps;      //!< Deflection
0137   Extrema_ExtFlag myFlag;   //!< Extrema flag indicating what solutions to look for
0138   Extrema_ExtAlgo myAlgo;   //!< Extrema algo to be used to look for solutions
0139 };
0140 
0141 #endif