0024623: Visualization - improve selection mechanism
[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
19 // A framework for safe management of Select3D_SensitivePoly polygons of 3D points
20 class Select3D_PointData {
21
22 public:
23
24   // Constructs internal array of 3D points defined
25   // by number of points theNbPoints
26   Select3D_PointData (const Standard_Integer theNbPoints)
27   : mynbpoints(theNbPoints)
28   {
29     if (theNbPoints <= 0)
30       Standard_ConstructionError::Raise("Select3D_PointData");
31
32     mypolyg3d = new Select3D_Pnt[mynbpoints];
33   }
34
35   // Destructor
36   ~Select3D_PointData ()
37   {
38     delete [] mypolyg3d;
39   }
40
41   // Sets Select3D_Pnt to internal array
42   // of 3D points if theIndex is valid
43   void SetPnt (const Standard_Integer theIndex,
44                const Select3D_Pnt& theValue)
45   {
46     if (theIndex < 0 || theIndex >= mynbpoints)
47       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt");
48     mypolyg3d[theIndex] = theValue;
49   }
50
51   // Sets gp_Pnt to internal array
52   // of 3D points if theIndex is valid
53   void SetPnt (const Standard_Integer theIndex,
54                const gp_Pnt& theValue)
55   {
56     if (theIndex < 0 || theIndex >= mynbpoints)
57       Standard_OutOfRange::Raise("Select3D_PointData::SetPnt");
58     mypolyg3d[theIndex] = theValue;
59   }
60
61   // Returns 3D point from internal array
62   // if theIndex is valid
63   Select3D_Pnt Pnt (const Standard_Integer theIndex) const
64   {
65     if (theIndex < 0 || theIndex >= mynbpoints)
66       Standard_OutOfRange::Raise("Select3D_PointData::Pnt");
67     return mypolyg3d[theIndex];
68   }
69
70   // Returns 3D point from internal array
71   // if theIndex is valid
72   gp_Pnt Pnt3d (const Standard_Integer theIndex) const
73   {
74     if (theIndex < 0 || theIndex >= mynbpoints)
75       Standard_OutOfRange::Raise("Select3D_PointData::Pnt");
76     return mypolyg3d[theIndex];
77   }
78
79   // Returns size of internal arrays
80   const Standard_Integer Size () const
81   {
82     return mynbpoints;
83   }
84
85 private:
86   Select3D_PointData (const Select3D_PointData&);
87   Select3D_PointData& operator= (const Select3D_PointData&);
88
89 private:
90
91   Select3D_Pnt*    mypolyg3d;
92   Standard_Integer mynbpoints;
93 };
94
95 #endif