Commit | Line | Data |
---|---|---|
ceae62f0 A |
1 | #ifndef _Select3D_PointData_HeaderFile |
2 | #define _Select3D_PointData_HeaderFile | |
3 | ||
4 | #include <Select3D_Pnt.hxx> | |
5 | #include <Select3D_Pnt2d.hxx> | |
6 | ||
7 | // A framework for safe management of Select3D_SensitivePoly polygons of 3D and 2D points | |
8 | class Select3D_PointData { | |
9 | ||
10 | public: | |
11 | ||
12 | // Constructs internal arrays of 2D and 3D points defined | |
13 | // by number of points theNbPoints | |
14 | Select3D_PointData (const Standard_Integer theNbPoints) | |
15 | { | |
16 | if (theNbPoints <= 0) | |
17 | Standard_ConstructionError::Raise("Select3D_PointData"); | |
18 | ||
19 | mynbpoints = theNbPoints; | |
20 | mypolyg3d = new Select3D_Pnt[mynbpoints]; | |
21 | mypolyg2d = new Select3D_Pnt2d[mynbpoints]; | |
22 | } | |
23 | ||
24 | // Destructor | |
25 | ~Select3D_PointData () | |
26 | { | |
27 | delete [] mypolyg3d; | |
28 | delete [] mypolyg2d; | |
29 | } | |
30 | ||
31 | // Sets Select3D_Pnt to internal array | |
32 | // of 3D points if theIndex is valid | |
33 | void SetPnt (const Standard_Integer theIndex, | |
34 | const Select3D_Pnt& theValue) | |
35 | { | |
36 | if (theIndex < 0 || theIndex >= mynbpoints) | |
37 | Standard_OutOfRange::Raise("Select3D_PointData::SetPnt"); | |
38 | mypolyg3d[theIndex] = theValue; | |
39 | } | |
40 | ||
41 | // Sets gp_Pnt to internal array | |
42 | // of 3D points if theIndex is valid | |
43 | void SetPnt (const Standard_Integer theIndex, | |
44 | const gp_Pnt& theValue) | |
45 | { | |
46 | if (theIndex < 0 || theIndex >= mynbpoints) | |
47 | Standard_OutOfRange::Raise("Select3D_PointData::SetPnt"); | |
48 | mypolyg3d[theIndex] = theValue; | |
49 | } | |
50 | ||
51 | // Sets Select3D_Pnt2d to internal array | |
52 | // of 2D points if theIndex is valid | |
53 | void SetPnt2d (const Standard_Integer theIndex, | |
54 | const Select3D_Pnt2d& theValue) | |
55 | { | |
56 | if (theIndex < 0 || theIndex >= mynbpoints) | |
57 | Standard_OutOfRange::Raise("Select3D_PointData::SetPnt2d"); | |
58 | mypolyg2d[theIndex] = theValue; | |
59 | } | |
60 | ||
61 | // Sets gp_Pnt2d to internal array | |
62 | // of 2D points if theIndex is valid | |
63 | void SetPnt2d (const Standard_Integer theIndex, | |
64 | const gp_Pnt2d& theValue) | |
65 | { | |
66 | if (theIndex < 0 || theIndex >= mynbpoints) | |
67 | Standard_OutOfRange::Raise("Select3D_PointData::SetPnt2d"); | |
68 | mypolyg2d[theIndex] = theValue; | |
69 | } | |
70 | ||
71 | // Returns 3D point from internal array | |
72 | // if theIndex is valid | |
73 | Select3D_Pnt Pnt (const Standard_Integer theIndex) const | |
74 | { | |
75 | if (theIndex < 0 || theIndex >= mynbpoints) | |
76 | Standard_OutOfRange::Raise("Select3D_PointData::Pnt"); | |
77 | return mypolyg3d[theIndex]; | |
78 | } | |
79 | ||
80 | // Returns 2D point from internal array | |
81 | // if theIndex is valid | |
82 | Select3D_Pnt2d Pnt2d (const Standard_Integer theIndex) const | |
83 | { | |
84 | if (theIndex < 0 || theIndex >= mynbpoints) | |
85 | Standard_OutOfRange::Raise("Select3D_PointData::Pnt2d"); | |
86 | return mypolyg2d[theIndex]; | |
87 | } | |
88 | ||
89 | // Returns size of internal arrays | |
90 | const Standard_Integer Size () const | |
91 | { | |
92 | return mynbpoints; | |
93 | } | |
94 | ||
95 | private: | |
96 | ||
97 | // Default constructor | |
98 | Select3D_PointData () {}; | |
99 | ||
100 | Select3D_Pnt* mypolyg3d; | |
101 | Select3D_Pnt2d* mypolyg2d; | |
102 | Standard_Integer mynbpoints; | |
103 | }; | |
104 | ||
105 | #endif |