0025265: Perspective projection - selecting front point of two
[occt.git] / src / Select3D / Select3D_PointData.hxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Select3D_PointData_HeaderFile
15 #define _Select3D_PointData_HeaderFile
16
17 #include <Select3D_Pnt.hxx>
18 #include <Select3D_Pnt2d.hxx>
19
20 // A framework for safe management of Select3D_SensitivePoly polygons of 3D and 2D points
21 class Select3D_PointData {
22
23 public:
24
25   // Constructs internal arrays of 2D and 3D points defined
26   // by number of points theNbPoints
27   Select3D_PointData (const Standard_Integer theNbPoints)
28   {
29     if (theNbPoints <= 0)
30       Standard_ConstructionError::Raise("Select3D_PointData");
31
32     mynbpoints = theNbPoints;
33     mypolyg3d = new Select3D_Pnt[mynbpoints];
34     mypolyg2d = new Select3D_Pnt2d[mynbpoints];
35   }
36
37   // Destructor
38   ~Select3D_PointData ()
39   {
40     delete [] mypolyg3d;
41     delete [] mypolyg2d;
42   }
43
44   // Sets Select3D_Pnt to internal array
45   // of 3D points if theIndex is valid
46   void SetPnt (const Standard_Integer theIndex,
47                const Select3D_Pnt& theValue)
48   {
49     if (theIndex < 0 || theIndex >= mynbpoints)
50       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt");
51     mypolyg3d[theIndex] = theValue;
52   }
53
54   // Sets gp_Pnt to internal array
55   // of 3D points if theIndex is valid
56   void SetPnt (const Standard_Integer theIndex,
57                const gp_Pnt& theValue)
58   {
59     if (theIndex < 0 || theIndex >= mynbpoints)
60       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt");
61     mypolyg3d[theIndex] = theValue;
62   }
63
64   // Sets Select3D_Pnt2d to internal array
65   // of 2D points if theIndex is valid
66   void SetPnt2d (const Standard_Integer theIndex,
67                  const Select3D_Pnt2d& theValue)
68   {
69     if (theIndex < 0 || theIndex >= mynbpoints)
70       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt2d");
71     mypolyg2d[theIndex] = theValue;
72   }
73
74   // Sets gp_Pnt2d to internal array
75   // of 2D points if theIndex is valid
76   void SetPnt2d (const Standard_Integer theIndex,
77                  const gp_Pnt2d& theValue)
78   {
79     if (theIndex < 0 || theIndex >= mynbpoints)
80       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt2d");
81     mypolyg2d[theIndex] = theValue;
82   }
83
84   // Returns 3D point from internal array
85   // if theIndex is valid
86   Select3D_Pnt Pnt (const Standard_Integer theIndex) const
87   {
88     if (theIndex < 0 || theIndex >= mynbpoints)
89       Standard_OutOfRange::Raise("Select3D_PointData::Pnt");
90     return mypolyg3d[theIndex];
91   }
92
93   // Returns 2D point from internal array
94   // if theIndex is valid
95   Select3D_Pnt2d Pnt2d (const Standard_Integer theIndex) const
96   {
97     if (theIndex < 0 || theIndex >= mynbpoints)
98       Standard_OutOfRange::Raise("Select3D_PointData::Pnt2d");
99     return mypolyg2d[theIndex];
100   }
101
102   // Returns size of internal arrays
103   const Standard_Integer Size () const
104   {
105     return mynbpoints;
106   }
107
108 private:
109
110   // Default constructor
111   Select3D_PointData () {}
112
113   Select3D_Pnt*    mypolyg3d;
114   Select3D_Pnt2d*  mypolyg2d;
115   Standard_Integer mynbpoints;
116 };
117
118 #endif