VTK  9.6.20260214
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
125
126#ifndef vtkPoints_h
127#define vtkPoints_h
128
129#include "vtkCommonCoreModule.h" // For export macro
130#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
131#include "vtkObject.h"
132#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
133
134#include "vtkDataArray.h" // Needed for inline methods
135
136VTK_ABI_NAMESPACE_BEGIN
137class vtkIdList;
138
139class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
140{
141public:
142 static vtkPoints* New(int dataType);
143
144 static vtkPoints* New();
145
146 vtkTypeMacro(vtkPoints, vtkObject);
147 void PrintSelf(ostream& os, vtkIndent indent) override;
148
152 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
153
157 virtual void Initialize();
158
167 virtual void SetData(vtkDataArray*);
168 vtkDataArray* GetData() { return this->Data; }
169
174 virtual int GetDataType() const;
175
180 virtual void SetDataType(int dataType);
192
197 VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
198 void* GetVoidPointer(const int id)
199 {
200 return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
201 }
202
206 virtual void Squeeze() { this->Data->Squeeze(); }
207
211 virtual void Reset();
212
214
219 virtual void DeepCopy(vtkPoints* ad);
220 virtual void ShallowCopy(vtkPoints* ad);
222
231 unsigned long GetActualMemorySize();
232
237 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
238
247 {
248 return this->Data->GetTuple(id);
249 }
250
256 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
257 VTK_SIZEHINT(3)
258 {
259 this->Data->GetTuple(id, x);
260 }
261
269 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
270 {
271 this->Data->SetTuple(id, x);
272 }
274 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
275 {
276 this->Data->SetTuple(id, x);
277 }
279 void SetPoint(vtkIdType id, double x, double y, double z)
280 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
281
283
287 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
288 {
289 this->Data->InsertTuple(id, x);
290 }
291 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
292 {
293 this->Data->InsertTuple(id, x);
294 }
295 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
297
304 {
305 this->Data->InsertTuples(dstIds, srcIds, source->Data);
306 }
307
314 {
315 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
316 }
317
321 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
322 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
323 vtkIdType InsertNextPoint(double x, double y, double z);
324
331 void SetNumberOfPoints(vtkIdType numPoints);
332
338 vtkTypeBool Resize(vtkIdType numPoints);
339
343 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
344
348 virtual void ComputeBounds();
349
354
358 void GetBounds(double bounds[6]);
359
364
370 void Modified() override;
371
372protected:
373 vtkPoints(int dataType = VTK_FLOAT);
374 ~vtkPoints() override;
375
376 double Bounds[6];
377 vtkTimeStamp ComputeTime; // Time at which bounds computed
378 vtkDataArray* Data; // Array which represents data
379
380private:
381 vtkPoints(const vtkPoints&) = delete;
382 void operator=(const vtkPoints&) = delete;
383};
384
385inline void vtkPoints::Reset()
386{
387 this->Data->Reset();
388 this->Modified();
389}
390
392{
393 if (numPoints != this->Data->GetNumberOfTuples())
394 {
395 this->Data->SetNumberOfComponents(3);
396 this->Data->SetNumberOfTuples(numPoints);
397 this->Modified();
398 }
399}
400
402{
403 if (numPoints != this->Data->GetNumberOfTuples())
404 {
405 this->Data->SetNumberOfComponents(3);
406 this->Modified();
407 return this->Data->Resize(numPoints);
408 }
409 return 1;
410}
411
412inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
413{
414 double p[3] = { x, y, z };
415 this->Data->SetTuple(id, p);
416}
417
418inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
419{
420 double p[3] = { x, y, z };
421 this->Data->InsertTuple(id, p);
422}
423
424inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
425{
426 double p[3] = { x, y, z };
427 return this->Data->InsertNextTuple(p);
428}
429
430VTK_ABI_NAMESPACE_END
431#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
virtual void Modified()
Update the modification time for this object.
vtkPoints(int dataType=VTK_FLOAT)
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:185
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:269
void SetDataTypeToChar()
Definition vtkPoints.h:182
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:291
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:186
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:385
void SetDataTypeToLong()
Definition vtkPoints.h:188
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:303
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:206
vtkTimeStamp ComputeTime
Definition vtkPoints.h:377
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:189
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:183
static vtkPoints * New(int dataType)
vtkDataArray * Data
Definition vtkPoints.h:378
vtkDataArray * GetData()
Definition vtkPoints.h:168
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:246
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:187
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:198
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:184
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:237
void SetDataTypeToDouble()
Definition vtkPoints.h:191
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:391
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:401
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:287
void SetDataTypeToBit()
Definition vtkPoints.h:181
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
double Bounds[6]
Definition vtkPoints.h:376
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:321
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:313
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:190
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:322
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
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_SHORT
Definition vtkType.h:37
int vtkIdType
Definition vtkType.h:363
#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:318
#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)