Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:31

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 <NCollection_Sequence.hxx>
0018 #include <BRepExtrema_SolutionElem.hxx>
0019 #include <Extrema_ExtFlag.hxx>
0020 #include <Extrema_ExtAlgo.hxx>
0021 #include <Precision.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 
0024 class TopoDS_Shape;
0025 class Bnd_Box;
0026 class TopoDS_Vertex;
0027 class TopoDS_Edge;
0028 class TopoDS_Face;
0029 
0030 //! This class allows to compute minimum distance between two brep shapes
0031 //! (face edge vertex) and is used in DistShapeShape class.
0032 class BRepExtrema_DistanceSS
0033 {
0034 public:
0035   DEFINE_STANDARD_ALLOC
0036 
0037 public: //! @name Constructor from two shapes
0038   //! Computes the distance between two Shapes (face edge vertex).
0039   //! @param theS1 - First shape
0040   //! @param theS2 - Second shape
0041   //! @param theBox1 - Bounding box of first shape
0042   //! @param theBox2 - Bounding box of second shape
0043   //! @param theDstRef - Initial distance between the shapes to start with
0044   //! @param theDeflection - Maximum deviation of extreme distances from the minimum
0045   //!                        one (default is Precision::Confusion()).
0046   //! @param theExtFlag - Specifies which extrema solutions to look for
0047   //!                     (default is MINMAX, applied only to point-face extrema)
0048   //! @param theExtAlgo - Specifies which extrema algorithm is to be used
0049   //!                     (default is Grad algo, applied only to point-face extrema)
0050   BRepExtrema_DistanceSS(const TopoDS_Shape&   theS1,
0051                          const TopoDS_Shape&   theS2,
0052                          const Bnd_Box&        theBox1,
0053                          const Bnd_Box&        theBox2,
0054                          const double          theDstRef,
0055                          const double          theDeflection = Precision::Confusion(),
0056                          const Extrema_ExtFlag theExtFlag    = Extrema_ExtFlag_MINMAX,
0057                          const Extrema_ExtAlgo theExtAlgo    = Extrema_ExtAlgo_Grad)
0058       : myDstRef(theDstRef),
0059         myModif(false),
0060         myEps(theDeflection),
0061         myFlag(theExtFlag),
0062         myAlgo(theExtAlgo)
0063   {
0064     Perform(theS1, theS2, theBox1, theBox2);
0065   }
0066 
0067 public: //! @name Results
0068   //! Returns true if the distance has been computed, false otherwise.
0069   bool IsDone() const { return myModif; }
0070 
0071   //! Returns the distance value.
0072   double DistValue() const { return myDstRef; }
0073 
0074   //! Returns the list of solutions on the first shape.
0075   const NCollection_Sequence<BRepExtrema_SolutionElem>& Seq1Value() const { return mySeqSolShape1; }
0076 
0077   //! Returns the list of solutions on the second shape.
0078   const NCollection_Sequence<BRepExtrema_SolutionElem>& Seq2Value() const { return mySeqSolShape2; }
0079 
0080 private: //! @name private methods performing the search
0081   //! Computes the distance between two Shapes (face edge vertex).
0082   //! General method to sort out the shape types and call the specific method.
0083   Standard_EXPORT void Perform(const TopoDS_Shape& theS1,
0084                                const TopoDS_Shape& theS2,
0085                                const Bnd_Box&      theBox1,
0086                                const Bnd_Box&      theBox2);
0087 
0088   //! Computes the distance between two vertices.
0089   void Perform(const TopoDS_Vertex&                            S1,
0090                const TopoDS_Vertex&                            S2,
0091                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0092                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0093 
0094   //! Computes the minimum distance between a vertex and an edge.
0095   void Perform(const TopoDS_Vertex&                            theS1,
0096                const TopoDS_Edge&                              theS2,
0097                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0098                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0099 
0100   //! Computes the minimum distance between a vertex and a face.
0101   void Perform(const TopoDS_Vertex&                            theS1,
0102                const TopoDS_Face&                              theS2,
0103                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0104                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0105 
0106   //! Computes the minimum distance between two edges.
0107   void Perform(const TopoDS_Edge&                              theS1,
0108                const TopoDS_Edge&                              theS2,
0109                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0110                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0111 
0112   //! Computes the minimum distance between an edge and a face.
0113   void Perform(const TopoDS_Edge&                              theS1,
0114                const TopoDS_Face&                              theS2,
0115                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0116                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0117 
0118   //! Computes the minimum distance between two faces.
0119   void Perform(const TopoDS_Face&                              theS1,
0120                const TopoDS_Face&                              theS2,
0121                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape1,
0122                NCollection_Sequence<BRepExtrema_SolutionElem>& theSeqSolShape2);
0123 
0124 private:                                                         //! @name Fields
0125   NCollection_Sequence<BRepExtrema_SolutionElem> mySeqSolShape1; //!< Solutions on the first shape
0126   NCollection_Sequence<BRepExtrema_SolutionElem> mySeqSolShape2; //!< Solutions on the second shape
0127   double                                         myDstRef;       //!< The minimal distance found
0128   bool            myModif; //!< Flag indicating whether the solution was improved or not
0129   double          myEps;   //!< Deflection
0130   Extrema_ExtFlag myFlag;  //!< Extrema flag indicating what solutions to look for
0131   Extrema_ExtAlgo myAlgo;  //!< Extrema algo to be used to look for solutions
0132 };
0133 
0134 #endif