Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:19:50

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 <BRepAdaptor_Surface.hxx>
0021 #include <BRepClass3d_BndBoxTree.hxx>
0022 #include <TopoDS_Shape.hxx>
0023 #include <TopTools_ShapeMapHasher.hxx>
0024 #include <NCollection_DataMap.hxx>
0025 #include <TopAbs_State.hxx>
0026 #include <TopExp_Explorer.hxx>
0027 #include <NCollection_IndexedMap.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 bool 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 bool FindAPointInTheFace(const TopoDS_Face& F, gp_Pnt& P, double& Param);
0058 
0059   Standard_EXPORT static bool FindAPointInTheFace(const TopoDS_Face& F,
0060                                                   gp_Pnt&            P,
0061                                                   double&            u,
0062                                                   double&            v,
0063                                                   double&            Param);
0064 
0065   Standard_EXPORT static bool FindAPointInTheFace(const TopoDS_Face& F,
0066                                                   gp_Pnt&            P,
0067                                                   double&            u,
0068                                                   double&            v,
0069                                                   double&            Param,
0070                                                   gp_Vec&            theVecD1U,
0071                                                   gp_Vec&            theVecD1V);
0072 
0073   Standard_EXPORT static bool FindAPointInTheFace(const TopoDS_Face& F,
0074                                                   gp_Pnt&            P,
0075                                                   double&            u,
0076                                                   double&            v);
0077 
0078   Standard_EXPORT static bool FindAPointInTheFace(const TopoDS_Face& F, gp_Pnt& P);
0079 
0080   Standard_EXPORT static bool FindAPointInTheFace(const TopoDS_Face& F, double& u, double& v);
0081 
0082   Standard_EXPORT bool PointInTheFace(const TopoDS_Face& F,
0083                                       gp_Pnt&            P,
0084                                       double&            u,
0085                                       double&            v,
0086                                       double&            Param,
0087                                       int&               Index) const;
0088 
0089   Standard_EXPORT bool PointInTheFace(const TopoDS_Face&                      F,
0090                                       gp_Pnt&                                 P,
0091                                       double&                                 u,
0092                                       double&                                 v,
0093                                       double&                                 Param,
0094                                       int&                                    Index,
0095                                       const occ::handle<BRepAdaptor_Surface>& surf,
0096                                       const double                            u1,
0097                                       const double                            v1,
0098                                       const double                            u2,
0099                                       const double                            v2) const;
0100 
0101   //! <Index> gives point index to search from and returns
0102   //! point index of succeseful search
0103   Standard_EXPORT bool PointInTheFace(const TopoDS_Face&                      F,
0104                                       gp_Pnt&                                 P,
0105                                       double&                                 u,
0106                                       double&                                 v,
0107                                       double&                                 Param,
0108                                       int&                                    Index,
0109                                       const occ::handle<BRepAdaptor_Surface>& surf,
0110                                       const double                            u1,
0111                                       const double                            v1,
0112                                       const double                            u2,
0113                                       const double                            v2,
0114                                       gp_Vec&                                 theVecD1U,
0115                                       gp_Vec&                                 theVecD1V) const;
0116 
0117   //! Starts an exploration of the shells.
0118   Standard_EXPORT void InitShell();
0119 
0120   //! Returns True if there is a current shell.
0121   Standard_EXPORT bool MoreShell() const;
0122 
0123   //! Sets the explorer to the next shell.
0124   Standard_EXPORT void NextShell();
0125 
0126   //! Returns the current shell.
0127   Standard_EXPORT TopoDS_Shell CurrentShell() const;
0128 
0129   //! Returns True if the Shell is rejected.
0130   Standard_EXPORT virtual bool RejectShell(const gp_Lin& L) const;
0131 
0132   //! Starts an exploration of the faces of the current shell.
0133   Standard_EXPORT void InitFace();
0134 
0135   //! Returns True if current face in current shell.
0136   Standard_EXPORT bool MoreFace() const;
0137 
0138   //! Sets the explorer to the next Face of the current shell.
0139   Standard_EXPORT void NextFace();
0140 
0141   //! Returns the current face.
0142   Standard_EXPORT TopoDS_Face CurrentFace() const;
0143 
0144   //! returns True if the face is rejected.
0145   Standard_EXPORT virtual bool RejectFace(const gp_Lin& L) const;
0146 
0147   //! Returns in <L>, <Par> a segment having at least
0148   //! one intersection with the shape boundary to
0149   //! compute intersections.
0150   Standard_EXPORT int Segment(const gp_Pnt& P, gp_Lin& L, double& Par);
0151 
0152   //! Returns in <L>, <Par> a segment having at least
0153   //! one intersection with the shape boundary to
0154   //! compute intersections.
0155   //!
0156   //! The First Call to this method returns a line which
0157   //! point to a point of the first face of the shape.
0158   //! The Second Call provide a line to the second face
0159   //! and so on.
0160   Standard_EXPORT int OtherSegment(const gp_Pnt& P, gp_Lin& L, double& Par);
0161 
0162   //! Returns the index of face for which
0163   //! last segment is calculated.
0164   Standard_EXPORT int GetFaceSegmentIndex() const;
0165 
0166   Standard_EXPORT virtual void DumpSegment(const gp_Pnt&      P,
0167                                            const gp_Lin&      L,
0168                                            const double       Par,
0169                                            const TopAbs_State S) const;
0170 
0171   Standard_EXPORT const TopoDS_Shape& GetShape() const;
0172 
0173   Standard_EXPORT IntCurvesFace_Intersector& Intersector(const TopoDS_Face& F) const;
0174 
0175   //! Return UB-tree instance which is used for edge / vertex checks.
0176   const NCollection_UBTree<int, Bnd_Box>& GetTree() { return myTree; }
0177 
0178   //! Return edge/vertices map for current shape.
0179   const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& GetMapEV()
0180   {
0181     return myMapEV;
0182   }
0183 
0184   Standard_EXPORT void Destroy();
0185 
0186 private:
0187   BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth) = delete;
0188 
0189 protected:
0190   Standard_EXPORT TopAbs_State ClassifyUVPoint(const IntCurvesFace_Intersector& theIntersector,
0191                                                const occ::handle<BRepAdaptor_Surface>& theSurf,
0192                                                const gp_Pnt2d& theP2d) const;
0193 
0194 private:
0195   TopoDS_Shape                                                      myShape;
0196   bool                                                              myReject;
0197   int                                                               myFirstFace;
0198   double                                                            myParamOnEdge;
0199   TopExp_Explorer                                                   myShellExplorer;
0200   TopExp_Explorer                                                   myFaceExplorer;
0201   NCollection_DataMap<TopoDS_Shape, void*, TopTools_ShapeMapHasher> myMapOfInter;
0202   NCollection_UBTree<int, Bnd_Box>                                  myTree;
0203   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>     myMapEV;
0204 };
0205 
0206 #endif // _BRepClass3d_SolidExplorer_HeaderFile