Test for 0022778: Bug in BRepMesh
[occt.git] / src / SelectBasics / SelectBasics_SortAlgo.cxx
1 // Created on: 1994-04-18
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <SelectBasics_SortAlgo.ixx>
23 #include <TColStd_ListIteratorOfListOfInteger.hxx>
24 #include <TColStd_MapOfInteger.hxx>
25 #include <gp_Pnt2d.hxx>
26
27 //=======================================================================
28 //function : SelectBasics_SortAlgo
29 //purpose  : 
30 //=======================================================================
31 SelectBasics_SortAlgo::SelectBasics_SortAlgo()
32      : sizeArea(0.)
33 {}
34
35 //=======================================================================
36 //function : SelectBasics_SortAlgo
37 //purpose  : 
38 //=======================================================================
39 SelectBasics_SortAlgo::SelectBasics_SortAlgo 
40   (const Bnd_Box2d& ClippingRectangle,
41    const Standard_Real sizeOfSensitiveArea, 
42    const Handle_Bnd_HArray1OfBox2d& theRectangles)
43 : clipRect(ClippingRectangle), sizeArea(sizeOfSensitiveArea)
44 {
45   sortedRect.Initialize(clipRect, theRectangles);
46 }
47
48 //=======================================================================
49 //function : Initialize
50 //purpose  : 
51 //=======================================================================
52 void SelectBasics_SortAlgo::Initialize(const Bnd_Box2d& ClippingRectangle, 
53                                   const Standard_Real sizeOfSensitiveArea, 
54                                   const Handle_Bnd_HArray1OfBox2d& theRectangles)
55 {
56   clipRect=ClippingRectangle;
57   sizeArea=sizeOfSensitiveArea;
58   sortedRect.Initialize(clipRect, theRectangles);
59 }
60
61 //=======================================================================
62 //function : Select
63 //purpose  : 
64 //=======================================================================
65 void SelectBasics_SortAlgo::InitSelect(const Standard_Real x,
66                                   const Standard_Real y)
67 {
68   Bnd_Box2d rep;
69   rep.Set(gp_Pnt2d(x, y));
70   rep.Enlarge(sizeArea);
71   myMap.Clear() ;
72   TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rep));
73   for(;It.More();It.Next()){
74     myMap.Add(It.Value());
75   }
76   curResult.Initialize(myMap);
77 }
78
79 //=======================================================================
80 //function : Select
81 //purpose  : 
82 //=======================================================================
83 void SelectBasics_SortAlgo::InitSelect(const Bnd_Box2d& rect)
84 {
85   myMap.Clear() ;
86   TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rect));
87   for(;It.More();It.Next()){
88     myMap.Add(It.Value());
89   }
90   curResult.Initialize(myMap);
91
92 }
93
94 //=======================================================================
95 //function : More
96 //purpose  : 
97 //=======================================================================
98 Standard_Boolean SelectBasics_SortAlgo::More()  const
99 {
100   return curResult.More();
101 }
102
103 //=======================================================================
104 //function : Next
105 //purpose  : 
106 //=======================================================================
107 void SelectBasics_SortAlgo::Next() 
108 {
109   curResult.Next();
110 }
111
112
113 //=======================================================================
114 //function : Value
115 //purpose  : 
116 //=======================================================================
117 Standard_Integer SelectBasics_SortAlgo::Value() const
118 {
119   return curResult.Key();
120 }
121