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