VTK  9.4.20241202
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
126#ifndef vtkPoints_h
127#define vtkPoints_h
128
129#include "vtkCommonCoreModule.h" // For export macro
130#include "vtkObject.h"
131#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
132
133#include "vtkDataArray.h" // Needed for inline methods
134
135VTK_ABI_NAMESPACE_BEGIN
136class vtkIdList;
137
138class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
139{
140public:
141 static vtkPoints* New(int dataType);
142
143 static vtkPoints* New();
144
145 vtkTypeMacro(vtkPoints, vtkObject);
146 void PrintSelf(ostream& os, vtkIndent indent) override;
147
151 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
152
156 virtual void Initialize();
157
166 virtual void SetData(vtkDataArray*);
167 vtkDataArray* GetData() { return this->Data; }
168
173 virtual int GetDataType() const;
174
179 virtual void SetDataType(int dataType);
180 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
181 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
182 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
183 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
184 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
185 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
186 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
187 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
188 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
189 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
190 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
191
196 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
197
201 virtual void Squeeze() { this->Data->Squeeze(); }
202
206 virtual void Reset();
207
209
214 virtual void DeepCopy(vtkPoints* ad);
215 virtual void ShallowCopy(vtkPoints* ad);
217
226 unsigned long GetActualMemorySize();
227
231 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
232
239 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
240 {
241 return this->Data->GetTuple(id);
242 }
243
248 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
249 VTK_SIZEHINT(3)
250 {
251 this->Data->GetTuple(id, x);
252 }
253
260 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
261 {
262 this->Data->SetTuple(id, x);
263 }
264 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
265 {
266 this->Data->SetTuple(id, x);
267 }
268 void SetPoint(vtkIdType id, double x, double y, double z)
269 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
270
272
276 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
277 {
278 this->Data->InsertTuple(id, x);
279 }
280 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
281 {
282 this->Data->InsertTuple(id, x);
283 }
284 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
286
293 {
294 this->Data->InsertTuples(dstIds, srcIds, source->Data);
295 }
296
303 {
304 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
305 }
306
310 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
311 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
312 vtkIdType InsertNextPoint(double x, double y, double z);
313
319 void SetNumberOfPoints(vtkIdType numPoints);
320
326 vtkTypeBool Resize(vtkIdType numPoints);
327
331 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
332
336 virtual void ComputeBounds();
337
342
346 void GetBounds(double bounds[6]);
347
351 vtkMTimeType GetMTime() override;
352
358 void Modified() override;
359
360protected:
361 vtkPoints(int dataType = VTK_FLOAT);
362 ~vtkPoints() override;
363
364 double Bounds[6];
365 vtkTimeStamp ComputeTime; // Time at which bounds computed
366 vtkDataArray* Data; // Array which represents data
367
368private:
369 vtkPoints(const vtkPoints&) = delete;
370 void operator=(const vtkPoints&) = delete;
371};
372
373inline void vtkPoints::Reset()
374{
375 this->Data->Reset();
376 this->Modified();
377}
378
380{
381 this->Data->SetNumberOfComponents(3);
382 this->Data->SetNumberOfTuples(numPoints);
383 this->Modified();
384}
385
387{
388 this->Data->SetNumberOfComponents(3);
389 this->Modified();
390 return this->Data->Resize(numPoints);
391}
392
393inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
394{
395 double p[3] = { x, y, z };
396 this->Data->SetTuple(id, p);
397}
398
399inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
400{
401 double p[3] = { x, y, z };
402 this->Data->InsertTuple(id, p);
403}
404
405inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
406{
407 double p[3] = { x, y, z };
408 return this->Data->InsertNextTuple(p);
409}
410
411VTK_ABI_NAMESPACE_END
412#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:139
void SetPoint(vtkIdType id, const double x[3])
Definition vtkPoints.h:264
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:184
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:260
void SetDataTypeToChar()
Definition vtkPoints.h:181
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:280
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition vtkPoints.h:185
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition vtkPoints.h:187
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:292
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:201
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:188
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:182
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition vtkPoints.h:167
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:239
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:186
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:196
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition vtkPoints.h:248
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:183
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:231
void SetDataTypeToDouble()
Definition vtkPoints.h:190
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:379
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:386
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:276
void SetDataTypeToBit()
Definition vtkPoints.h:180
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
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:310
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:302
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:189
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:311
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 VTK_SHORT
Definition vtkType.h:36
int vtkIdType
Definition vtkType.h:315
#define VTK_UNSIGNED_INT
Definition vtkType.h:39
#define VTK_DOUBLE
Definition vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:37
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_INT
Definition vtkType.h:38
#define VTK_FLOAT
Definition vtkType.h:42
#define VTK_CHAR
Definition vtkType.h:33
#define VTK_UNSIGNED_LONG
Definition vtkType.h:41
#define VTK_BIT
Definition vtkType.h:32
#define VTK_LONG
Definition vtkType.h:40
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)
#define VTK_MARSHALAUTO