Salome HOME
de5e3fcb44278ba4cddc268491dbd626665f6ffb
[modules/shaper.git] / src / GeomData / GeomData_Point2DArray.h
1 // Copyright (C) 2019-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef GeomData_Point2DArray_H_
21 #define GeomData_Point2DArray_H_
22
23 #include "GeomData.h"
24
25 #include <GeomDataAPI_Point2DArray.h>
26
27 #include <TDataStd_RealArray.hxx>
28 #include <TDF_Label.hxx>
29
30 /** \class GeomData_Point2DArray
31  *  \ingroup DataModel
32  *  \brief Attribute that contains an array of 2D points.
33  */
34 class GeomData_Point2DArray : public GeomDataAPI_Point2DArray
35 {
36   TDF_Label myLab; ///< the main label of the attribute
37   Handle_TDataStd_RealArray myArray; ///< array that keeps all coordinates of the points
38
39 public:
40   /// Copy values from another array
41   /// \return \c true if the copy was successful
42   GEOMDATA_EXPORT virtual bool assign(std::shared_ptr<GeomDataAPI_Point2DArray> theOther);
43
44   /// Returns the size of the array (zero means that it is empty)
45   GEOMDATA_EXPORT virtual int size();
46
47   /// Sets the new size of the array. The previous data is erased.
48   GEOMDATA_EXPORT virtual void setSize(const int theSize);
49
50   /// Defines the value of the array by index [0; size-1]
51   GEOMDATA_EXPORT virtual void setPnt(const int theIndex,
52                                       const double theX, const double theY);
53
54   /// Defines the value of the array by index [0; size-1]
55   GEOMDATA_EXPORT virtual void setPnt(const int theIndex,
56                                       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
57
58   /// Returns the value by the index
59   GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt(const int theIndex);
60
61 protected:
62   /// Initializes attributes
63   GEOMDATA_EXPORT GeomData_Point2DArray(TDF_Label& theLabel);
64   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
65   virtual void reinit();
66
67   friend class Model_Data;
68 };
69
70 #endif