Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:21:50

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Select3D_PointData_HeaderFile
0015 #define _Select3D_PointData_HeaderFile
0016 
0017 #include <Select3D_Pnt.hxx>
0018 
0019 // A framework for safe management of Select3D_SensitivePoly polygons of 3D points
0020 class Select3D_PointData
0021 {
0022 
0023 public:
0024   // Constructs internal array of 3D points defined
0025   // by number of points theNbPoints
0026   Select3D_PointData(const int theNbPoints)
0027       : mynbpoints(theNbPoints)
0028   {
0029     if (theNbPoints <= 0)
0030       throw Standard_ConstructionError("Select3D_PointData");
0031 
0032     mypolyg3d = new Select3D_Pnt[mynbpoints];
0033   }
0034 
0035   // Destructor
0036   ~Select3D_PointData() { delete[] mypolyg3d; }
0037 
0038   // Sets Select3D_Pnt to internal array
0039   // of 3D points if theIndex is valid
0040   void SetPnt(const int theIndex, const Select3D_Pnt& theValue)
0041   {
0042     if (theIndex < 0 || theIndex >= mynbpoints)
0043       throw Standard_OutOfRange("Select3D_PointData::SetPnt");
0044     mypolyg3d[theIndex] = theValue;
0045   }
0046 
0047   // Sets gp_Pnt to internal array
0048   // of 3D points if theIndex is valid
0049   void SetPnt(const int theIndex, const gp_Pnt& theValue)
0050   {
0051     if (theIndex < 0 || theIndex >= mynbpoints)
0052       throw Standard_OutOfRange("Select3D_PointData::SetPnt");
0053     mypolyg3d[theIndex] = theValue;
0054   }
0055 
0056   // Returns 3D point from internal array
0057   // if theIndex is valid
0058   const Select3D_Pnt& Pnt(const int theIndex) const
0059   {
0060     if (theIndex < 0 || theIndex >= mynbpoints)
0061       throw Standard_OutOfRange("Select3D_PointData::Pnt");
0062     return mypolyg3d[theIndex];
0063   }
0064 
0065   // Returns 3D point from internal array
0066   // if theIndex is valid
0067   gp_Pnt Pnt3d(const int theIndex) const
0068   {
0069     if (theIndex < 0 || theIndex >= mynbpoints)
0070       throw Standard_OutOfRange("Select3D_PointData::Pnt");
0071     return mypolyg3d[theIndex];
0072   }
0073 
0074   // Returns size of internal arrays
0075   int Size() const { return mynbpoints; }
0076 
0077 private:
0078   Select3D_PointData(const Select3D_PointData&)            = delete;
0079   Select3D_PointData& operator=(const Select3D_PointData&) = delete;
0080 
0081 private:
0082   Select3D_Pnt* mypolyg3d;
0083   int           mynbpoints;
0084 };
0085 
0086 #endif