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_DistShapeShape_HeaderFile
0015 #define _BRepExtrema_DistShapeShape_HeaderFile
0016 
0017 #include <Bnd_Array1OfBox.hxx>
0018 #include <BRepExtrema_SeqOfSolution.hxx>
0019 #include <BRepExtrema_SolutionElem.hxx>
0020 #include <BRepExtrema_SupportType.hxx>
0021 #include <Extrema_ExtAlgo.hxx>
0022 #include <Extrema_ExtFlag.hxx>
0023 #include <Message_ProgressRange.hxx>
0024 #include <TopoDS_Shape.hxx>
0025 #include <Standard_OStream.hxx>
0026 #include <Standard_DefineAlloc.hxx>
0027 #include <TopTools_IndexedMapOfShape.hxx>
0028 
0029 //! This class  provides tools to compute minimum distance 
0030 //! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex).
0031 class BRepExtrema_DistShapeShape
0032 {
0033  public:
0034 
0035   DEFINE_STANDARD_ALLOC
0036 
0037   //! create empty tool
0038   Standard_EXPORT BRepExtrema_DistShapeShape();
0039 
0040   //! create tool and computation of the minimum distance (value and pair of points) 
0041   //! using default deflection in single thread mode. <br>
0042   //! Default deflection value is Precision::Confusion(). <br>
0043   //! @param Shape1 - the first shape for distance computation
0044   //! @param Shape2 - the second shape for distance computation
0045   //! @param F and @param A are not used in computation and are obsolete.
0046   //! @param theRange - the progress indicator of algorithm
0047   Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
0048                                              const TopoDS_Shape& Shape2,
0049                                              const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
0050                                              const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad,
0051                                              const Message_ProgressRange& theRange = Message_ProgressRange());
0052   //! create tool and computation of the minimum distance 
0053   //! (value and pair of points) in single thread mode. <br>
0054   //! Default deflection value is Precision::Confusion(). <br>
0055   //! @param Shape1 - the first shape for distance computation
0056   //! @param Shape2 - the second shape for distance computation
0057   //! @param theDeflection - the presition of distance computation
0058   //! @param F and @param A are not used in computation and are obsolete.
0059   //! @param theRange - the progress indicator of algorithm
0060   Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
0061                                              const TopoDS_Shape& Shape2,
0062                                              const Standard_Real theDeflection,
0063                                              const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
0064                                              const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad,
0065                                              const Message_ProgressRange& theRange = Message_ProgressRange());
0066   
0067   //! Sets deflection to computation of the minimum distance <br>
0068   void SetDeflection(const Standard_Real theDeflection)
0069   {
0070     myEps = theDeflection;
0071   }
0072 
0073   //! load first shape into extrema <br>
0074   Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
0075 
0076   //! load second shape into extrema <br>
0077   Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
0078 
0079   //! computation of  the minimum  distance  (value  and <br>
0080   //!          couple  of points). Parameter theDeflection is used <br>
0081   //!          to specify a maximum deviation of extreme distances <br>
0082   //!          from the minimum one. <br>
0083   //!          Returns IsDone status. <br>
0084   //! theRange - the progress indicator of algorithm
0085   Standard_EXPORT Standard_Boolean Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
0086 
0087   //! True if the minimum distance is found. <br>
0088   Standard_Boolean IsDone() const
0089   { 
0090     return myIsDone;
0091   }
0092 
0093   //! Returns the number of solutions satisfying the minimum distance. <br>
0094   Standard_Integer NbSolution() const
0095   { 
0096     return mySolutionsShape1.Length();
0097   }
0098 
0099   //! Returns the value of the minimum distance. <br>
0100   Standard_EXPORT Standard_Real Value() const;
0101 
0102   //! True if one of the shapes is a solid and the other shape <br>
0103   //! is completely or partially inside the solid. <br>
0104   Standard_Boolean InnerSolution() const
0105   { 
0106     return myInnerSol;
0107   }
0108 
0109   //! Returns the Point corresponding to the <N>th solution on the first Shape <br>
0110   const gp_Pnt & PointOnShape1(const Standard_Integer N) const
0111   { 
0112     return mySolutionsShape1.Value(N).Point();
0113   }
0114 
0115   //! Returns the Point corresponding to the <N>th solution on the second Shape <br>
0116   const gp_Pnt & PointOnShape2(const Standard_Integer N) const
0117   { 
0118     return mySolutionsShape2.Value(N).Point();
0119   }
0120 
0121   //! gives the type of the support where the Nth solution on the first shape is situated: <br>
0122   //!   IsVertex => the Nth solution on the first shape is a Vertex <br>
0123   //!   IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
0124   //!   IsInFace => the Nth solution on the first shape is inside a face <br>
0125   //! the corresponding support is obtained by the method SupportOnShape1 <br>
0126   BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
0127   { 
0128     return mySolutionsShape1.Value(N).SupportKind();
0129   }
0130 
0131   //! gives the type of the support where the Nth solution on the second shape is situated: <br>
0132   //!   IsVertex => the Nth solution on the second shape is a Vertex <br>
0133   //!   IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
0134   //!   IsInFace => the Nth solution on the second shape is inside a face <br>
0135   //! the corresponding support is obtained by the method SupportOnShape2 <br>
0136   BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
0137   { 
0138     return mySolutionsShape2.Value(N).SupportKind();
0139   }
0140 
0141   //! gives the support where the Nth solution on the first shape is situated. <br>
0142   //! This support can be a Vertex, an Edge or a Face. <br>
0143   Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
0144 
0145   //! gives the support where the Nth solution on the second shape is situated. <br>
0146   //! This support can be a Vertex, an Edge or a Face. <br>
0147   Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const;
0148 
0149   //! gives the corresponding parameter t if the Nth solution <br>
0150   //! is situated on an Edge of the first shape <br>
0151   Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
0152 
0153   //! gives the corresponding parameter t if the Nth solution <br>
0154   //! is situated on an Edge of the first shape <br>
0155   Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
0156 
0157   //! gives the corresponding parameters (U,V) if the Nth solution <br>
0158   //! is situated on an face of the first shape <br>
0159   Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
0160 
0161   //! gives the corresponding parameters (U,V) if the Nth solution <br>
0162   //! is situated on an Face of the second shape <br>
0163   Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
0164 
0165   //! Prints on the stream o information on the current state of the object. <br>
0166   Standard_EXPORT void Dump(Standard_OStream& o) const;
0167 
0168   //! Sets unused parameter
0169   //! Obsolete 
0170   void SetFlag(const Extrema_ExtFlag F)
0171   {
0172     myFlag = F;
0173   }
0174 
0175   //! Sets unused parameter
0176   //! Obsolete 
0177   void SetAlgo(const Extrema_ExtAlgo A)
0178   {
0179     myAlgo = A;
0180   }
0181 
0182   //! If isMultiThread == Standard_True then computation will be performed in parallel.
0183   void SetMultiThread(Standard_Boolean theIsMultiThread)
0184   {
0185     myIsMultiThread = theIsMultiThread;
0186   }
0187 
0188   //! Returns Standard_True then computation will be performed in parallel
0189   //! Default value is Standard_False
0190   Standard_Boolean IsMultiThread() const
0191   {
0192     return myIsMultiThread;
0193   }
0194 
0195 private:
0196 
0197   //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
0198   Standard_Boolean DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,
0199                                   const TopTools_IndexedMapOfShape& Map2,
0200                                   const Bnd_Array1OfBox&            LBox1,
0201                                   const Bnd_Array1OfBox&            LBox2,
0202                                   const Message_ProgressRange&      theRange);
0203 
0204   //! computes the minimum distance between two maps of vertices <br>
0205   Standard_Boolean DistanceVertVert(const TopTools_IndexedMapOfShape& theMap1,
0206                                     const TopTools_IndexedMapOfShape& theMap2,
0207                                     const Message_ProgressRange& theRange);
0208 
0209   Standard_Boolean SolidTreatment(const TopoDS_Shape& theShape,
0210                                   const TopTools_IndexedMapOfShape& theMap,
0211                                   const Message_ProgressRange& theRange);
0212 
0213 private:
0214 
0215   Standard_Real myDistRef;
0216   Standard_Boolean myIsDone;
0217   BRepExtrema_SeqOfSolution mySolutionsShape1;
0218   BRepExtrema_SeqOfSolution mySolutionsShape2;
0219   Standard_Boolean myInnerSol;
0220   Standard_Real myEps;
0221   TopoDS_Shape myShape1;
0222   TopoDS_Shape myShape2;
0223   TopTools_IndexedMapOfShape myMapV1;
0224   TopTools_IndexedMapOfShape myMapV2;
0225   TopTools_IndexedMapOfShape myMapE1;
0226   TopTools_IndexedMapOfShape myMapE2;
0227   TopTools_IndexedMapOfShape myMapF1;
0228   TopTools_IndexedMapOfShape myMapF2;
0229   Standard_Boolean myIsInitS1;
0230   Standard_Boolean myIsInitS2;
0231   Extrema_ExtFlag myFlag;
0232   Extrema_ExtAlgo myAlgo;
0233   Bnd_Array1OfBox myBV1;
0234   Bnd_Array1OfBox myBV2;
0235   Bnd_Array1OfBox myBE1;
0236   Bnd_Array1OfBox myBE2;
0237   Bnd_Array1OfBox myBF1;
0238   Bnd_Array1OfBox myBF2;
0239   Standard_Boolean myIsMultiThread;
0240 };
0241 
0242 #endif