b311480e |
1 | // Created on: 1994-04-18 |
2 | // Created by: Didier PIFFAULT |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <SelectBasics_SortAlgo.ixx> |
18 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
19 | #include <TColStd_MapOfInteger.hxx> |
20 | #include <gp_Pnt2d.hxx> |
21 | |
22 | //======================================================================= |
23 | //function : SelectBasics_SortAlgo |
24 | //purpose : |
25 | //======================================================================= |
26 | SelectBasics_SortAlgo::SelectBasics_SortAlgo() |
27 | : sizeArea(0.) |
28 | {} |
29 | |
30 | //======================================================================= |
31 | //function : SelectBasics_SortAlgo |
32 | //purpose : |
33 | //======================================================================= |
34 | SelectBasics_SortAlgo::SelectBasics_SortAlgo |
35 | (const Bnd_Box2d& ClippingRectangle, |
36 | const Standard_Real sizeOfSensitiveArea, |
857ffd5e |
37 | const Handle(Bnd_HArray1OfBox2d)& theRectangles) |
7fd59977 |
38 | : clipRect(ClippingRectangle), sizeArea(sizeOfSensitiveArea) |
39 | { |
40 | sortedRect.Initialize(clipRect, theRectangles); |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : Initialize |
45 | //purpose : |
46 | //======================================================================= |
47 | void SelectBasics_SortAlgo::Initialize(const Bnd_Box2d& ClippingRectangle, |
48 | const Standard_Real sizeOfSensitiveArea, |
857ffd5e |
49 | const Handle(Bnd_HArray1OfBox2d)& theRectangles) |
7fd59977 |
50 | { |
51 | clipRect=ClippingRectangle; |
52 | sizeArea=sizeOfSensitiveArea; |
53 | sortedRect.Initialize(clipRect, theRectangles); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : Select |
58 | //purpose : |
59 | //======================================================================= |
60 | void SelectBasics_SortAlgo::InitSelect(const Standard_Real x, |
61 | const Standard_Real y) |
62 | { |
63 | Bnd_Box2d rep; |
64 | rep.Set(gp_Pnt2d(x, y)); |
65 | rep.Enlarge(sizeArea); |
66 | myMap.Clear() ; |
67 | TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rep)); |
68 | for(;It.More();It.Next()){ |
69 | myMap.Add(It.Value()); |
70 | } |
71 | curResult.Initialize(myMap); |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : Select |
76 | //purpose : |
77 | //======================================================================= |
78 | void SelectBasics_SortAlgo::InitSelect(const Bnd_Box2d& rect) |
79 | { |
80 | myMap.Clear() ; |
81 | TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rect)); |
82 | for(;It.More();It.Next()){ |
83 | myMap.Add(It.Value()); |
84 | } |
85 | curResult.Initialize(myMap); |
86 | |
87 | } |
88 | |
89 | //======================================================================= |
90 | //function : More |
91 | //purpose : |
92 | //======================================================================= |
93 | Standard_Boolean SelectBasics_SortAlgo::More() const |
94 | { |
95 | return curResult.More(); |
96 | } |
97 | |
98 | //======================================================================= |
99 | //function : Next |
100 | //purpose : |
101 | //======================================================================= |
102 | void SelectBasics_SortAlgo::Next() |
103 | { |
104 | curResult.Next(); |
105 | } |
106 | |
107 | |
108 | //======================================================================= |
109 | //function : Value |
110 | //purpose : |
111 | //======================================================================= |
112 | Standard_Integer SelectBasics_SortAlgo::Value() const |
113 | { |
114 | return curResult.Key(); |
115 | } |
116 | |