VTK  9.7.1
vtkPoints2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
14 #ifndef vtkPoints2D_h
15 #define vtkPoints2D_h
16 
17 #include "vtkCommonCoreModule.h" // For export macro
18 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
19 #include "vtkObject.h"
20 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
21 
22 #include "vtkDataArray.h" // Needed for inline methods
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkIdList;
26 
27 class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints2D : public vtkObject
28 {
29 public:
30  static vtkPoints2D* New(int dataType);
31 
32  static vtkPoints2D* New();
33 
34  vtkTypeMacro(vtkPoints2D, vtkObject);
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  VTK_DEPRECATED_IN_9_7_0("Use Reserve() to allocate or Initialize() to deallocate.")
41  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
42 
46  virtual void Initialize();
47 
56  virtual void SetData(vtkDataArray*);
57  vtkDataArray* GetData() { return this->Data; }
58 
63  virtual int GetDataType() const;
64 
68  virtual void SetDataType(int dataType);
69  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
70  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
71  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
72  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
73  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
74  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
75  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
76  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
77  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
78  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
79  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
80 
85  VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
86  void* GetVoidPointer(const int id)
87  {
88  return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
89  }
90 
94  virtual void Squeeze() { this->Data->Squeeze(); }
95 
99  virtual void Reset();
100 
102 
107  virtual void DeepCopy(vtkPoints2D* ad);
108  virtual void ShallowCopy(vtkPoints2D* ad);
110 
119  unsigned long GetActualMemorySize();
120 
125  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
126 
134  double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
135 
140  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
141 
148  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
150  void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
152  void SetPoint(vtkIdType id, double x, double y);
153 
158  void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
159  void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
160  void InsertPoint(vtkIdType id, double x, double y);
161 
165  vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
166  vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
167  vtkIdType InsertNextPoint(double x, double y);
168 
172  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
173 
180  void SetNumberOfPoints(vtkIdType numPoints);
181 
187  VTK_DEPRECATED_IN_9_7_0("Use Reserve, Squeeze or Initialize")
188  vtkTypeBool Resize(vtkIdType numPoints);
189 
198  vtkTypeBool Reserve(vtkIdType numPoints);
199 
203  void GetPoints(vtkIdList* ptId, vtkPoints2D* fp);
204 
208  virtual void ComputeBounds();
209 
213  double* GetBounds() VTK_SIZEHINT(4);
214 
218  void GetBounds(double bounds[4]);
219 
220 protected:
221  vtkPoints2D(int dataType = VTK_FLOAT);
222  ~vtkPoints2D() override;
223 
224  double Bounds[4];
225  vtkTimeStamp ComputeTime; // Time at which bounds computed
226  vtkDataArray* Data; // Array which represents data
227 
228 private:
229  vtkPoints2D(const vtkPoints2D&) = delete;
230  void operator=(const vtkPoints2D&) = delete;
231 };
232 
233 inline void vtkPoints2D::Reset()
234 {
235  this->Data->Reset();
236  this->Modified();
237 }
238 
240 {
241  this->Data->SetNumberOfComponents(2);
242  this->Data->SetNumberOfTuples(numPoints);
243  this->Modified();
244 }
245 
247 {
248  if (numPoints != this->Data->GetNumberOfTuples())
249  {
250  this->Data->SetNumberOfComponents(3);
251  this->Modified();
252  return this->Data->ReserveTuples(numPoints);
253  }
254  return 1;
255 }
256 
257 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
258 {
259  double p[2] = { x, y };
260  this->Data->SetTuple(id, p);
261 }
262 
263 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
264 {
265  double p[2] = { x, y };
266  this->Data->InsertTuple(id, p);
267 }
268 
269 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
270 {
271  double p[2] = { x, y };
272  return this->Data->InsertNextTuple(p);
273 }
274 
275 VTK_ABI_NAMESPACE_END
276 #endif
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:79
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:159
void GetBounds(T a, double bds[6])
#define VTK_UNSIGNED_INT
Definition: vtkType.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:38
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:71
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:158
record modification and/or execution time
Definition: vtkTimeStamp.h:24
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
int vtkIdType
Definition: vtkType.h:363
int vtkTypeBool
Definition: vtkABI.h:64
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:73
#define VTK_DOUBLE
Definition: vtkType.h:44
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:239
#define VTK_FLOAT
Definition: vtkType.h:43
a simple class to control print indentation
Definition: vtkIndent.h:28
represent and manipulate 2D points
Definition: vtkPoints2D.h:27
list of point or cell ids
Definition: vtkIdList.h:25
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:148
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_SHORT
Definition: vtkType.h:37
#define VTK_CHAR
Definition: vtkType.h:34
#define VTK_LONG
Definition: vtkType.h:41
virtual void Modified()
Update the modification time for this object.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:75
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:94
#define VTK_SIZEHINT(...)
void Reset()
Reset to an empty state, without freeing any memory.
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
#define VTK_MARSHALEXCLUDE(reason)
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:36
void GetPoint(int i, int j, int k, double pnt[3])
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:165
void SetDataTypeToInt()
Definition: vtkPoints2D.h:74
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:172
#define VTK_BIT
Definition: vtkType.h:33
void SetDataTypeToBit()
Definition: vtkPoints2D.h:69
vtkTypeBool Reserve(vtkIdType numPoints)
Resize the internal array to the requested number of points and preserve data.
Definition: vtkPoints2D.h:246
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:42
#define VTK_MARSHALAUTO
void SetDataTypeToChar()
Definition: vtkPoints2D.h:70
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:78
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:77
void SetDataTypeToShort()
Definition: vtkPoints2D.h:72
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:166
void SetDataTypeToLong()
Definition: vtkPoints2D.h:76
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_INT
Definition: vtkType.h:39