VTK  9.6.1
vtkPoints.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
16
17#ifndef vtkPoints_h
18#define vtkPoints_h
19
20#include "vtkCommonCoreModule.h" // For export macro
21#include "vtkObject.h"
22#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
23
24#include "vtkDataArray.h" // Needed for inline methods
25
26VTK_ABI_NAMESPACE_BEGIN
27class vtkIdList;
28
29class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
30{
31public:
32 static vtkPoints* New(int dataType);
33
34 static vtkPoints* New();
35
36 vtkTypeMacro(vtkPoints, vtkObject);
37 void PrintSelf(ostream& os, vtkIndent indent) override;
38
42 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
43
47 virtual void Initialize();
48
57 virtual void SetData(vtkDataArray*);
58 vtkDataArray* GetData() { return this->Data; }
59
64 virtual int GetDataType() const;
65
70 virtual void SetDataType(int dataType);
82
87 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
88
92 virtual void Squeeze() { this->Data->Squeeze(); }
93
97 virtual void Reset();
98
100
105 virtual void DeepCopy(vtkPoints* ad);
106 virtual void ShallowCopy(vtkPoints* ad);
108
117 unsigned long GetActualMemorySize();
118
123 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
124
133 {
134 return this->Data->GetTuple(id);
135 }
136
142 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
143 VTK_SIZEHINT(3)
144 {
145 this->Data->GetTuple(id, x);
146 }
147
155 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
156 {
157 this->Data->SetTuple(id, x);
158 }
160 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
161 {
162 this->Data->SetTuple(id, x);
163 }
165 void SetPoint(vtkIdType id, double x, double y, double z)
166 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
167
169
173 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
174 {
175 this->Data->InsertTuple(id, x);
176 }
177 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
178 {
179 this->Data->InsertTuple(id, x);
180 }
181 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
183
190 {
191 this->Data->InsertTuples(dstIds, srcIds, source->Data);
192 }
193
200 {
201 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
202 }
203
207 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
208 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
209 vtkIdType InsertNextPoint(double x, double y, double z);
210
217 void SetNumberOfPoints(vtkIdType numPoints);
218
224 vtkTypeBool Resize(vtkIdType numPoints);
225
229 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
230
234 virtual void ComputeBounds();
235
240
244 void GetBounds(double bounds[6]);
245
250
256 void Modified() override;
257
258protected:
259 vtkPoints(int dataType = VTK_FLOAT);
260 ~vtkPoints() override;
261
262 double Bounds[6];
263 vtkTimeStamp ComputeTime; // Time at which bounds computed
264 vtkDataArray* Data; // Array which represents data
265
266private:
267 vtkPoints(const vtkPoints&) = delete;
268 void operator=(const vtkPoints&) = delete;
269};
270
271inline void vtkPoints::Reset()
272{
273 this->Data->Reset();
274 this->Modified();
275}
276
278{
279 if (numPoints != this->Data->GetNumberOfTuples())
280 {
281 this->Data->SetNumberOfComponents(3);
282 this->Data->SetNumberOfTuples(numPoints);
283 this->Modified();
284 }
285}
286
288{
289 if (numPoints != this->Data->GetNumberOfTuples())
290 {
291 this->Data->SetNumberOfComponents(3);
292 this->Modified();
293 return this->Data->Resize(numPoints);
294 }
295 return 1;
296}
297
298inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
299{
300 double p[3] = { x, y, z };
301 this->Data->SetTuple(id, p);
302}
303
304inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
305{
306 double p[3] = { x, y, z };
307 this->Data->InsertTuple(id, p);
308}
309
310inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
311{
312 double p[3] = { x, y, z };
313 return this->Data->InsertNextTuple(p);
314}
315
316VTK_ABI_NAMESPACE_END
317#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:24
a simple class to control print indentation
Definition vtkIndent.h:29
virtual void Modified()
Update the modification time for this object.
vtkPoints(int dataType=VTK_FLOAT)
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:75
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:155
void SetDataTypeToChar()
Definition vtkPoints.h:72
vtkMTimeType GetMTime() override
The modified time of the points.
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition vtkPoints.h:177
void Modified() override
Update the modification time for this object and its Data.
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition vtkPoints.h:76
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
virtual void Reset()
Make object look empty but do not delete memory.
Definition vtkPoints.h:271
void SetDataTypeToLong()
Definition vtkPoints.h:78
void InsertPoints(vtkIdList *dstIds, vtkIdList *srcIds, vtkPoints *source)
Copy the points indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
Definition vtkPoints.h:189
double * GetBounds()
Return the bounds of the points.
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition vtkPoints.h:92
vtkTimeStamp ComputeTime
Definition vtkPoints.h:263
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:79
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:73
static vtkPoints * New(int dataType)
vtkDataArray * Data
Definition vtkPoints.h:264
vtkDataArray * GetData()
Definition vtkPoints.h:58
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition vtkPoints.h:132
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:77
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:87
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:74
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:123
void SetDataTypeToDouble()
Definition vtkPoints.h:81
virtual void DeepCopy(vtkPoints *ad)
Different ways to copy data.
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition vtkPoints.h:277
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:287
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:173
void SetDataTypeToBit()
Definition vtkPoints.h:71
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
double Bounds[6]
Definition vtkPoints.h:262
virtual void ShallowCopy(vtkPoints *ad)
Different ways to copy data.
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition vtkPoints.h:207
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array,...
Definition vtkPoints.h:199
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:80
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:208
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define vtkDataArray
void Reset()
Initializes the field list to empty.
virtual int GetNumberOfPoints()=0
Return the number of corner points that compose the cell.
void Resize(unsigned int width, unsigned int height)
#define VTK_SHORT
Definition vtkType.h:37
int vtkIdType
Definition vtkType.h:368
#define VTK_UNSIGNED_INT
Definition vtkType.h:40
#define VTK_DOUBLE
Definition vtkType.h:44
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:36
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:38
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:323
#define VTK_INT
Definition vtkType.h:39
#define VTK_FLOAT
Definition vtkType.h:43
#define VTK_CHAR
Definition vtkType.h:34
#define VTK_UNSIGNED_LONG
Definition vtkType.h:42
#define VTK_BIT
Definition vtkType.h:33
#define VTK_LONG
Definition vtkType.h:41
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)