0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_BoxBndTree.hxx
1 // Created on: 2005-02-14
2 // Created by: Alexey MORENOV
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef ShapeAnalysis_BoxBndTree_HeaderFile
17 #define ShapeAnalysis_BoxBndTree_HeaderFile
18
19 #include <NCollection_UBTree.hxx>
20 #include <Bnd_Box.hxx>
21 #include <gp_Pnt.hxx>
22 #include <Standard_Transient.hxx>
23 #include <TopTools_HArray1OfShape.hxx>
24
25 #include <ShapeExtend.hxx>
26 #include <ShapeExtend_Status.hxx>
27 #include <TopoDS_Vertex.hxx>
28 #include <TColStd_MapOfInteger.hxx>
29 #include <TColStd_Array1OfInteger.hxx>
30
31 typedef NCollection_UBTree <Standard_Integer , Bnd_Box> ShapeAnalysis_BoxBndTree;
32
33 class ShapeAnalysis_BoxBndTreeSelector
34   : public ShapeAnalysis_BoxBndTree::Selector
35 {
36  public:
37   ShapeAnalysis_BoxBndTreeSelector
38     (Handle (TopTools_HArray1OfShape) theSeq,
39      Standard_Boolean theShared)
40     :  mySeq(theSeq), myShared(theShared), myNb(0), myTol(1e-7), myMin3d(1e-7),myArrIndices(1,2),
41       myStatus(ShapeExtend::EncodeStatus (ShapeExtend_OK))
42       {
43         myArrIndices.Init(0);
44       }
45   
46   void DefineBoxes (const Bnd_Box& theFBox, const Bnd_Box& theLBox)
47     { myFBox = theFBox;
48       myLBox = theLBox; 
49       myArrIndices.Init(0);
50        
51   }
52   
53   void DefineVertexes (TopoDS_Vertex theVf, TopoDS_Vertex theVl)
54     { myFVertex = theVf;
55       myLVertex = theVl; 
56        myStatus=ShapeExtend::EncodeStatus (ShapeExtend_OK);
57     }
58     
59   void DefinePnt (gp_Pnt theFPnt, gp_Pnt theLPnt)
60     { myFPnt = theFPnt;
61       myLPnt = theLPnt; 
62        myStatus =ShapeExtend::EncodeStatus (ShapeExtend_OK);
63     }
64   
65   Standard_Integer GetNb ()
66     { return myNb; }
67   
68   void  SetNb (Standard_Integer theNb)
69     { myNb = theNb; }
70  
71   void LoadList(Standard_Integer elem)
72     { myList.Add(elem); }
73   
74   void SetStop ()
75     { myStop = Standard_False; }
76
77   void SetTolerance (Standard_Real theTol)
78     { 
79       myTol = theTol;
80       myMin3d = theTol; 
81       myStatus=ShapeExtend::EncodeStatus (ShapeExtend_OK);
82     }
83
84   Standard_Boolean ContWire(Standard_Integer nbWire)
85     { return myList.Contains(nbWire); }
86   
87   inline Standard_Boolean LastCheckStatus (const ShapeExtend_Status theStatus) const
88     { return ShapeExtend::DecodeStatus ( myStatus, theStatus ); }
89     
90   Standard_Boolean Reject (const Bnd_Box& theBnd) const;
91   Standard_Boolean Accept (const Standard_Integer &);
92   
93  private:
94   Bnd_Box                              myFBox;
95   Bnd_Box                              myLBox;
96   Handle (TopTools_HArray1OfShape)     mySeq;
97   Standard_Boolean                     myShared;
98   Standard_Integer                     myNb;
99   TopoDS_Vertex                        myFVertex;
100   TopoDS_Vertex                        myLVertex;
101   gp_Pnt                               myFPnt;
102   gp_Pnt                               myLPnt;
103   TColStd_MapOfInteger                 myList;
104   Standard_Real                        myTol;
105   Standard_Real                        myMin3d;
106   TColStd_Array1OfInteger              myArrIndices;
107   Standard_Integer                     myStatus;
108
109 };
110
111 #endif