Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:19:44

0001 // Copyright (c) 1994-1999 Matra Datavision
0002 // Copyright (c) 1999-2016 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _BRepClass3d_BndBoxTree_HeaderFile
0016 #define _BRepClass3d_BndBoxTree_HeaderFile
0017 
0018 #include <NCollection_Sequence.hxx>
0019 #include <NCollection_UBTreeFiller.hxx>
0020 #include <NCollection_UBTree.hxx>
0021 #include <TopTools_ShapeMapHasher.hxx>
0022 #include <NCollection_IndexedMap.hxx>
0023 #include <TopoDS_Edge.hxx>
0024 #include <TopoDS_Vertex.hxx>
0025 #include <Geom_Line.hxx>
0026 #include <Bnd_Box.hxx>
0027 #include <GeomAdaptor_Curve.hxx>
0028 #include <Precision.hxx>
0029 
0030 // Typedef to reduce code complexity.
0031 
0032 // Class representing tree selector for point object.
0033 class BRepClass3d_BndBoxTreeSelectorPoint : public NCollection_UBTree<int, Bnd_Box>::Selector
0034 {
0035 public:
0036   BRepClass3d_BndBoxTreeSelectorPoint(
0037     const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& theMapOfShape)
0038       : myMapOfShape(theMapOfShape)
0039   {
0040   }
0041 
0042   bool Reject(const Bnd_Box& theBox) const override { return (theBox.IsOut(myP)); }
0043 
0044   bool Accept(const int& theObj) override;
0045 
0046   // Sets current point for boxes-point collisions.
0047   void SetCurrentPoint(const gp_Pnt& theP) { myP = theP; }
0048 
0049 private:
0050   BRepClass3d_BndBoxTreeSelectorPoint(const BRepClass3d_BndBoxTreeSelectorPoint&) = delete;
0051   BRepClass3d_BndBoxTreeSelectorPoint& operator=(const BRepClass3d_BndBoxTreeSelectorPoint&) =
0052     delete;
0053 
0054 private:
0055   const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>&
0056          myMapOfShape; // shapes (vertices + edges)
0057   gp_Pnt myP;
0058 };
0059 
0060 // Class representing tree selector for line object.
0061 class BRepClass3d_BndBoxTreeSelectorLine : public NCollection_UBTree<int, Bnd_Box>::Selector
0062 {
0063 public:
0064   struct EdgeParam
0065   {
0066     TopoDS_Edge myE;
0067     double      myParam;  // par on myE
0068     double      myLParam; // par on line
0069   };
0070 
0071   struct VertParam
0072   {
0073     TopoDS_Vertex myV;
0074     double        myLParam; // par on line
0075   };
0076 
0077 public:
0078   BRepClass3d_BndBoxTreeSelectorLine(
0079     const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& theMapOfShape)
0080       : myMapOfShape(theMapOfShape),
0081         myIsValid(true)
0082   {
0083   }
0084 
0085   bool Reject(const Bnd_Box& theBox) const override { return (theBox.IsOut(myL)); }
0086 
0087   bool Accept(const int& theObj) override;
0088 
0089   // Sets current line for boxes-line collisions
0090   void SetCurrentLine(const gp_Lin& theL, const double theMaxParam)
0091   {
0092     myL = theL;
0093     myLC.Load(new Geom_Line(theL), -Precision::PConfusion(), theMaxParam);
0094   }
0095 
0096   void GetEdgeParam(const int i, TopoDS_Edge& theOutE, double& theOutParam, double& outLParam) const
0097   {
0098     const EdgeParam& EP = myEP.Value(i);
0099     theOutE             = EP.myE;
0100     theOutParam         = EP.myParam;
0101     outLParam           = EP.myLParam;
0102   }
0103 
0104   void GetVertParam(const int i, TopoDS_Vertex& theOutV, double& outLParam) const
0105   {
0106     const VertParam& VP = myVP.Value(i);
0107     theOutV             = VP.myV;
0108     outLParam           = VP.myLParam;
0109   }
0110 
0111   int GetNbEdgeParam() const { return myEP.Length(); }
0112 
0113   int GetNbVertParam() const { return myVP.Length(); }
0114 
0115   void ClearResults()
0116   {
0117     myEP.Clear();
0118     myVP.Clear();
0119     myIsValid = true;
0120   }
0121 
0122   //! Returns TRUE if correct classification is possible
0123   bool IsCorrect() const { return myIsValid; }
0124 
0125 private:
0126   BRepClass3d_BndBoxTreeSelectorLine(const BRepClass3d_BndBoxTreeSelectorLine&)            = delete;
0127   BRepClass3d_BndBoxTreeSelectorLine& operator=(const BRepClass3d_BndBoxTreeSelectorLine&) = delete;
0128 
0129 private:
0130   const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>&
0131                                   myMapOfShape; // shapes (vertices + edges)
0132   gp_Lin                          myL;
0133   NCollection_Sequence<EdgeParam> myEP; // output result (edge vs line)
0134   NCollection_Sequence<VertParam> myVP; // output result (vertex vs line)
0135   GeomAdaptor_Curve               myLC;
0136   bool                            myIsValid;
0137 };
0138 
0139 #endif