0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / Select3D / Select3D_SensitivePoly.cxx
1 #include <Select3D_SensitivePoly.ixx>
2 #include <gp_Pnt2d.hxx>
3 #include <gp_Pnt.hxx>
4 #include <Select3D_Pnt.hxx>
5 #include <Select3D_Pnt2d.hxx>
6 #include <Select3D_Box2d.hxx>
7 #include <TopLoc_Location.hxx>
8
9
10 //==================================================
11 // Function: faire disparaitre ce constructeur a la prochaine version...
12 // Purpose : simplement garde pour ne pas perturber la version update
13 //==================================================
14
15 Select3D_SensitivePoly::
16 Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
17                        const TColgp_Array1OfPnt& ThePoints):
18 Select3D_SensitiveEntity(OwnerId),
19 mypolyg(ThePoints.Upper()-ThePoints.Lower()+1)
20 {
21   for (Standard_Integer theIndex = 0 ; theIndex < mypolyg.Size(); ++theIndex)
22     mypolyg.SetPnt(theIndex, ThePoints.Value(ThePoints.Lower()+theIndex));
23 }
24
25 //==================================================
26 // Function: Creation
27 // Purpose :
28 //==================================================
29
30 Select3D_SensitivePoly::
31 Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
32                        const Handle(TColgp_HArray1OfPnt)& ThePoints):
33 Select3D_SensitiveEntity(OwnerId),
34 mypolyg(ThePoints->Upper()-ThePoints->Lower()+1)
35 {
36   for (Standard_Integer theIndex = 0; theIndex < mypolyg.Size(); theIndex++)
37     mypolyg.SetPnt(theIndex, ThePoints->Value(ThePoints->Lower()+theIndex));
38 }
39
40 //==================================================
41 // Function: Creation
42 // Purpose :
43 //==================================================
44
45 Select3D_SensitivePoly::
46 Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId, 
47                        const Standard_Integer NbPoints):
48 Select3D_SensitiveEntity(OwnerId),
49 mypolyg(NbPoints)
50 {
51 }
52
53 //==================================================
54 // Function: Project
55 // Purpose :
56 //==================================================
57
58 void Select3D_SensitivePoly::Project(const Handle(Select3D_Projector)& aProj)
59 {
60   Select3D_SensitiveEntity:: Project (aProj); // to set the field last proj...
61   mybox2d.SetVoid();
62
63   Standard_Boolean hasloc = HasLocation();
64   gp_Pnt2d aPnt2d;
65   gp_Pnt aPnt;
66   for (Standard_Integer theIndex = 0; theIndex < mypolyg.Size(); ++theIndex)
67   {
68     aPnt = mypolyg.Pnt(theIndex);
69     if (hasloc)
70     {
71       aProj->Project(aPnt.Transformed(Location().Transformation()), aPnt2d);
72     }
73     else
74     {
75       aProj->Project(aPnt, aPnt2d);
76     }
77     mybox2d.Update(aPnt2d);
78     mypolyg.SetPnt2d(theIndex, aPnt2d);
79   }
80 }
81
82 //==================================================
83 // Function: Areas
84 // Purpose :
85 //==================================================
86 void Select3D_SensitivePoly
87 ::Areas(SelectBasics_ListOfBox2d& aSeq)
88 {
89   aSeq.Append(mybox2d);
90 }
91