0024070: OpenGL capped object-level clipping planes
[occt.git] / src / Select3D / Select3D_SensitivePoly.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <Select3D_SensitivePoly.ixx>
19#include <gp_Pnt2d.hxx>
20#include <gp_Pnt.hxx>
21#include <Select3D_Pnt.hxx>
22#include <Select3D_Pnt2d.hxx>
23#include <Select3D_Box2d.hxx>
24#include <TopLoc_Location.hxx>
25
26
27//==================================================
28// Function: faire disparaitre ce constructeur a la prochaine version...
29// Purpose : simplement garde pour ne pas perturber la version update
30//==================================================
31
32Select3D_SensitivePoly::
33Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
ac04d101 34 const TColgp_Array1OfPnt& ThePoints):
ceae62f0
A
35Select3D_SensitiveEntity(OwnerId),
36mypolyg(ThePoints.Upper()-ThePoints.Lower()+1)
7fd59977 37{
ceae62f0
A
38 for (Standard_Integer theIndex = 0 ; theIndex < mypolyg.Size(); ++theIndex)
39 mypolyg.SetPnt(theIndex, ThePoints.Value(ThePoints.Lower()+theIndex));
7fd59977 40}
41
42//==================================================
ac04d101 43// Function: Creation
7fd59977 44// Purpose :
45//==================================================
46
47Select3D_SensitivePoly::
48Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
ac04d101 49 const Handle(TColgp_HArray1OfPnt)& ThePoints):
ceae62f0
A
50Select3D_SensitiveEntity(OwnerId),
51mypolyg(ThePoints->Upper()-ThePoints->Lower()+1)
7fd59977 52{
ceae62f0
A
53 for (Standard_Integer theIndex = 0; theIndex < mypolyg.Size(); theIndex++)
54 mypolyg.SetPnt(theIndex, ThePoints->Value(ThePoints->Lower()+theIndex));
7fd59977 55}
56
57//==================================================
ac04d101 58// Function: Creation
7fd59977 59// Purpose :
60//==================================================
61
62Select3D_SensitivePoly::
63Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
ac04d101 64 const Standard_Integer NbPoints):
ceae62f0
A
65Select3D_SensitiveEntity(OwnerId),
66mypolyg(NbPoints)
7fd59977 67{
7fd59977 68}
69
70//==================================================
ac04d101 71// Function: Project
7fd59977 72// Purpose :
73//==================================================
74
4952a30a 75void Select3D_SensitivePoly::Project(const Handle(Select3D_Projector)& aProj)
7fd59977 76{
7fd59977 77 mybox2d.SetVoid();
78
79 Standard_Boolean hasloc = HasLocation();
80 gp_Pnt2d aPnt2d;
ceae62f0
A
81 gp_Pnt aPnt;
82 for (Standard_Integer theIndex = 0; theIndex < mypolyg.Size(); ++theIndex)
83 {
84 aPnt = mypolyg.Pnt(theIndex);
85 if (hasloc)
7fd59977 86 {
ceae62f0 87 aProj->Project(aPnt.Transformed(Location().Transformation()), aPnt2d);
7fd59977 88 }
ceae62f0
A
89 else
90 {
91 aProj->Project(aPnt, aPnt2d);
92 }
93 mybox2d.Update(aPnt2d);
94 mypolyg.SetPnt2d(theIndex, aPnt2d);
95 }
7fd59977 96}
97
98//==================================================
ac04d101 99// Function: Areas
7fd59977 100// Purpose :
101//==================================================
102void Select3D_SensitivePoly
103::Areas(SelectBasics_ListOfBox2d& aSeq)
104{
105 aSeq.Append(mybox2d);
106}
107