Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:23:49

0001 // Created on: 2005-02-14
0002 // Created by: Alexey MORENOV
0003 // Copyright (c) 2005-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef ShapeAnalysis_BoxBndTree_HeaderFile
0017 #define ShapeAnalysis_BoxBndTree_HeaderFile
0018 
0019 #include <NCollection_UBTree.hxx>
0020 #include <Bnd_Box.hxx>
0021 #include <gp_Pnt.hxx>
0022 #include <Standard_Transient.hxx>
0023 #include <TopoDS_Shape.hxx>
0024 #include <NCollection_Array1.hxx>
0025 #include <NCollection_HArray1.hxx>
0026 
0027 #include <ShapeExtend.hxx>
0028 #include <ShapeExtend_Status.hxx>
0029 #include <TopoDS_Vertex.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <NCollection_Map.hxx>
0032 
0033 class ShapeAnalysis_BoxBndTreeSelector : public NCollection_UBTree<int, Bnd_Box>::Selector
0034 {
0035 public:
0036   ShapeAnalysis_BoxBndTreeSelector(occ::handle<NCollection_HArray1<TopoDS_Shape>> theSeq,
0037                                    bool                                           theShared)
0038       : mySeq(theSeq),
0039         myShared(theShared),
0040         myNb(0),
0041         myTol(1e-7),
0042         myMin3d(1e-7),
0043         myArrIndices(1, 2),
0044         myStatus(ShapeExtend::EncodeStatus(ShapeExtend_OK))
0045   {
0046     myArrIndices.Init(0);
0047   }
0048 
0049   void DefineBoxes(const Bnd_Box& theFBox, const Bnd_Box& theLBox)
0050   {
0051     myFBox = theFBox;
0052     myLBox = theLBox;
0053     myArrIndices.Init(0);
0054   }
0055 
0056   void DefineVertexes(TopoDS_Vertex theVf, TopoDS_Vertex theVl)
0057   {
0058     myFVertex = theVf;
0059     myLVertex = theVl;
0060     myStatus  = ShapeExtend::EncodeStatus(ShapeExtend_OK);
0061   }
0062 
0063   void DefinePnt(const gp_Pnt& theFPnt, const gp_Pnt& theLPnt)
0064   {
0065     myFPnt   = theFPnt;
0066     myLPnt   = theLPnt;
0067     myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK);
0068   }
0069 
0070   int GetNb() { return myNb; }
0071 
0072   void SetNb(int theNb) { myNb = theNb; }
0073 
0074   void LoadList(int elem) { myList.Add(elem); }
0075 
0076   void SetStop() { myStop = false; }
0077 
0078   void SetTolerance(double theTol)
0079   {
0080     myTol    = theTol;
0081     myMin3d  = theTol;
0082     myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK);
0083   }
0084 
0085   bool ContWire(int nbWire) { return myList.Contains(nbWire); }
0086 
0087   inline bool LastCheckStatus(const ShapeExtend_Status theStatus) const
0088   {
0089     return ShapeExtend::DecodeStatus(myStatus, theStatus);
0090   }
0091 
0092   bool Reject(const Bnd_Box& theBnd) const override;
0093   bool Accept(const int&) override;
0094 
0095 private:
0096   Bnd_Box                                        myFBox;
0097   Bnd_Box                                        myLBox;
0098   occ::handle<NCollection_HArray1<TopoDS_Shape>> mySeq;
0099   bool                                           myShared;
0100   int                                            myNb;
0101   TopoDS_Vertex                                  myFVertex;
0102   TopoDS_Vertex                                  myLVertex;
0103   gp_Pnt                                         myFPnt;
0104   gp_Pnt                                         myLPnt;
0105   NCollection_Map<int>                           myList;
0106   double                                         myTol;
0107   double                                         myMin3d;
0108   NCollection_Array1<int>                        myArrIndices;
0109   int                                            myStatus;
0110 };
0111 
0112 #endif