Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-19 08:28:21

0001 // Created on: 1994-03-10
0002 // Created by: Laurent BUCHARD
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 _BRepClass3d_SolidExplorer_HeaderFile
0018 #define _BRepClass3d_SolidExplorer_HeaderFile
0019 
0020 #include <Bnd_Box.hxx>
0021 #include <BRepAdaptor_Surface.hxx>
0022 #include <BRepClass3d_BndBoxTree.hxx>
0023 #include <BRepClass3d_MapOfInter.hxx>
0024 #include <TopAbs_State.hxx>
0025 #include <TopExp_Explorer.hxx>
0026 #include <TopoDS_Shape.hxx>
0027 #include <TopTools_IndexedMapOfShape.hxx>
0028 
0029 class gp_Pnt;
0030 class TopoDS_Face;
0031 class gp_Vec;
0032 class TopoDS_Shell;
0033 class gp_Lin;
0034 class IntCurvesFace_Intersector;
0035 
0036 //! Provide an exploration of a BRep Shape for the classification.
0037 //! Provide access to the special UB tree to obtain fast search.
0038 class BRepClass3d_SolidExplorer
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   Standard_EXPORT BRepClass3d_SolidExplorer();
0044 
0045   Standard_EXPORT BRepClass3d_SolidExplorer(const TopoDS_Shape& S);
0046 
0047   Standard_EXPORT virtual ~BRepClass3d_SolidExplorer();
0048 
0049   Standard_EXPORT void InitShape(const TopoDS_Shape& S);
0050 
0051   //! Should return True if P outside of bounding vol. of the shape
0052   Standard_EXPORT virtual Standard_Boolean Reject(const gp_Pnt& P) const;
0053 
0054   //! compute a point P in the face  F. Param is a Real in
0055   //! ]0,1[ and   is  used to  initialise  the algorithm. For
0056   //! different values , different points are returned.
0057   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F,
0058                                                               gp_Pnt&            P,
0059                                                               Standard_Real&     Param);
0060 
0061   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F,
0062                                                               gp_Pnt&            P,
0063                                                               Standard_Real&     u,
0064                                                               Standard_Real&     v,
0065                                                               Standard_Real&     Param);
0066 
0067   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F,
0068                                                               gp_Pnt&            P,
0069                                                               Standard_Real&     u,
0070                                                               Standard_Real&     v,
0071                                                               Standard_Real&     Param,
0072                                                               gp_Vec&            theVecD1U,
0073                                                               gp_Vec&            theVecD1V);
0074 
0075   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F,
0076                                                               gp_Pnt&            P,
0077                                                               Standard_Real&     u,
0078                                                               Standard_Real&     v);
0079 
0080   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F, gp_Pnt& P);
0081 
0082   Standard_EXPORT static Standard_Boolean FindAPointInTheFace(const TopoDS_Face& F,
0083                                                               Standard_Real&     u,
0084                                                               Standard_Real&     v);
0085 
0086   Standard_EXPORT Standard_Boolean PointInTheFace(const TopoDS_Face& F,
0087                                                   gp_Pnt&            P,
0088                                                   Standard_Real&     u,
0089                                                   Standard_Real&     v,
0090                                                   Standard_Real&     Param,
0091                                                   Standard_Integer&  Index) const;
0092 
0093   Standard_EXPORT Standard_Boolean PointInTheFace(const TopoDS_Face&                 F,
0094                                                   gp_Pnt&                            P,
0095                                                   Standard_Real&                     u,
0096                                                   Standard_Real&                     v,
0097                                                   Standard_Real&                     Param,
0098                                                   Standard_Integer&                  Index,
0099                                                   const Handle(BRepAdaptor_Surface)& surf,
0100                                                   const Standard_Real                u1,
0101                                                   const Standard_Real                v1,
0102                                                   const Standard_Real                u2,
0103                                                   const Standard_Real                v2) const;
0104 
0105   //! <Index> gives point index  to  search from and returns
0106   //! point index of succeseful search
0107   Standard_EXPORT Standard_Boolean PointInTheFace(const TopoDS_Face&                 F,
0108                                                   gp_Pnt&                            P,
0109                                                   Standard_Real&                     u,
0110                                                   Standard_Real&                     v,
0111                                                   Standard_Real&                     Param,
0112                                                   Standard_Integer&                  Index,
0113                                                   const Handle(BRepAdaptor_Surface)& surf,
0114                                                   const Standard_Real                u1,
0115                                                   const Standard_Real                v1,
0116                                                   const Standard_Real                u2,
0117                                                   const Standard_Real                v2,
0118                                                   gp_Vec&                            theVecD1U,
0119                                                   gp_Vec& theVecD1V) const;
0120 
0121   //! Starts an exploration of the shells.
0122   Standard_EXPORT void InitShell();
0123 
0124   //! Returns True if there is a current shell.
0125   Standard_EXPORT Standard_Boolean MoreShell() const;
0126 
0127   //! Sets the explorer to the next shell.
0128   Standard_EXPORT void NextShell();
0129 
0130   //! Returns the current shell.
0131   Standard_EXPORT TopoDS_Shell CurrentShell() const;
0132 
0133   //! Returns True if the Shell is rejected.
0134   Standard_EXPORT virtual Standard_Boolean RejectShell(const gp_Lin& L) const;
0135 
0136   //! Starts an exploration of the faces of the current shell.
0137   Standard_EXPORT void InitFace();
0138 
0139   //! Returns True if current face in current shell.
0140   Standard_EXPORT Standard_Boolean MoreFace() const;
0141 
0142   //! Sets the explorer to the next Face of the current shell.
0143   Standard_EXPORT void NextFace();
0144 
0145   //! Returns the current face.
0146   Standard_EXPORT TopoDS_Face CurrentFace() const;
0147 
0148   //! returns True if the face is rejected.
0149   Standard_EXPORT virtual Standard_Boolean RejectFace(const gp_Lin& L) const;
0150 
0151   //! Returns  in <L>, <Par>  a segment having at least
0152   //! one  intersection  with  the  shape  boundary  to
0153   //! compute  intersections.
0154   Standard_EXPORT Standard_Integer Segment(const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
0155 
0156   //! Returns  in <L>, <Par>  a segment having at least
0157   //! one  intersection  with  the  shape  boundary  to
0158   //! compute  intersections.
0159   //!
0160   //! The First Call to this method returns a line which
0161   //! point to a point of the first face of the shape.
0162   //! The Second Call provide a line to the second face
0163   //! and so on.
0164   Standard_EXPORT Standard_Integer OtherSegment(const gp_Pnt& P, gp_Lin& L, Standard_Real& Par);
0165 
0166   //! Returns the index of face for which
0167   //! last segment is calculated.
0168   Standard_EXPORT Standard_Integer GetFaceSegmentIndex() const;
0169 
0170   Standard_EXPORT virtual void DumpSegment(const gp_Pnt&       P,
0171                                            const gp_Lin&       L,
0172                                            const Standard_Real Par,
0173                                            const TopAbs_State  S) const;
0174 
0175   Standard_EXPORT const Bnd_Box& Box() const;
0176 
0177   Standard_EXPORT const TopoDS_Shape& GetShape() const;
0178 
0179   Standard_EXPORT IntCurvesFace_Intersector& Intersector(const TopoDS_Face& F) const;
0180 
0181   //! Return UB-tree instance which is used for edge / vertex checks.
0182   const BRepClass3d_BndBoxTree& GetTree() { return myTree; }
0183 
0184   //! Return edge/vertices map for current shape.
0185   const TopTools_IndexedMapOfShape& GetMapEV() { return myMapEV; }
0186 
0187   Standard_EXPORT void Destroy();
0188 
0189 private:
0190   Standard_EXPORT BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth);
0191 
0192 protected:
0193   Standard_EXPORT TopAbs_State ClassifyUVPoint(const IntCurvesFace_Intersector&   theIntersector,
0194                                                const Handle(BRepAdaptor_Surface)& theSurf,
0195                                                const gp_Pnt2d&                    theP2d) const;
0196 
0197 private:
0198   Bnd_Box                    myBox;
0199   TopoDS_Shape               myShape;
0200   Standard_Boolean           myReject;
0201   Standard_Integer           myFirstFace;
0202   Standard_Real              myParamOnEdge;
0203   TopExp_Explorer            myShellExplorer;
0204   TopExp_Explorer            myFaceExplorer;
0205   BRepClass3d_MapOfInter     myMapOfInter;
0206   BRepClass3d_BndBoxTree     myTree;
0207   TopTools_IndexedMapOfShape myMapEV;
0208 };
0209 
0210 #endif // _BRepClass3d_SolidExplorer_HeaderFile