VTK  9.6.20260329
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 VTK_DEPRECATED_IN_9_7_0("Use Reserve() to allocate or Initialize() to deallocate.")
153 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
154
158 virtual void Initialize();
159
168 virtual void SetData(vtkDataArray*);
169 vtkDataArray* GetData() { return this->Data; }
170
175 virtual int GetDataType() const;
176
181 virtual void SetDataType(int dataType);
193
198 VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
199 void* GetVoidPointer(const int id)
200 {
201 return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
202 }
203
207 virtual void Squeeze() { this->Data->Squeeze(); }
208
212 virtual void Reset();
213
215
220 virtual void DeepCopy(vtkPoints* ad);
221 virtual void ShallowCopy(vtkPoints* ad);
223
232 unsigned long GetActualMemorySize();
233
238 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
239
248 {
249 return this->Data->GetTuple(id);
250 }
251
257 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
258 VTK_SIZEHINT(3)
259 {
260 this->Data->GetTuple(id, x);
261 }
262
270 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
271 {
272 this->Data->SetTuple(id, x);
273 }
275 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
276 {
277 this->Data->SetTuple(id, x);
278 }
280 void SetPoint(vtkIdType id, double x, double y, double z)
281 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
282
284
288 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
289 {
290 this->Data->InsertTuple(id, x);
291 }
292 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
293 {
294 this->Data->InsertTuple(id, x);
295 }
296 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
298
305 {
306 this->Data->InsertTuples(dstIds, srcIds, source->Data);
307 }
308
315 {
316 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
317 }
318
322 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
323 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
324 vtkIdType InsertNextPoint(double x, double y, double z);
325
332 void SetNumberOfPoints(vtkIdType numPoints);
333
339 VTK_DEPRECATED_IN_9_7_0("Use Reserve, Squeeze or Initialize")
341
350 vtkTypeBool Reserve(vtkIdType numPoints);
351
355 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
356
360 virtual void ComputeBounds();
361
366
370 void GetBounds(double bounds[6]);
371
376
382 void Modified() override;
383
384protected:
385 vtkPoints(int dataType = VTK_FLOAT);
386 ~vtkPoints() override;
387
388 double Bounds[6];
389 vtkTimeStamp ComputeTime; // Time at which bounds computed
390 vtkDataArray* Data; // Array which represents data
391
392private:
393 vtkPoints(const vtkPoints&) = delete;
394 void operator=(const vtkPoints&) = delete;
395};
396
397inline void vtkPoints::Reset()
398{
399 this->Data->Reset();
400 this->Modified();
401}
402
404{
405 if (numPoints != this->Data->GetNumberOfTuples())
406 {
407 this->Data->SetNumberOfComponents(3);
408 this->Data->SetNumberOfTuples(numPoints);
409 this->Modified();
410 }
411}
412
414{
415 if (numPoints != this->Data->GetNumberOfTuples())
416 {
417 this->Data->SetNumberOfComponents(3);
418 this->Modified();
419 return this->Data->ReserveTuples(numPoints);
420 }
421 return 1;
422}
423
424inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
425{
426 double p[3] = { x, y, z };
427 this->Data->SetTuple(id, p);
428}
429
430inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
431{
432 double p[3] = { x, y, z };
433 this->Data->InsertTuple(id, p);
434}
435
436inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
437{
438 double p[3] = { x, y, z };
439 return this->Data->InsertNextTuple(p);
440}
441
442VTK_ABI_NAMESPACE_END
443#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:135
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:186
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:270
void SetDataTypeToChar()
Definition vtkPoints.h:183
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:292
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:187
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
vtkTypeBool Reserve(vtkIdType numPoints)
Reserve the internal array to the requested number of points and preserve data.
Definition vtkPoints.h:413
virtual void Reset()
Make object look empty but do not delete memory.
Definition vtkPoints.h:397
void SetDataTypeToLong()
Definition vtkPoints.h:189
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:304
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:207
vtkTimeStamp ComputeTime
Definition vtkPoints.h:389
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:190
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:184
static vtkPoints * New(int dataType)
vtkDataArray * Data
Definition vtkPoints.h:390
vtkDataArray * GetData()
Definition vtkPoints.h:169
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:247
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:188
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:199
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:185
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:238
void SetDataTypeToDouble()
Definition vtkPoints.h:192
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:403
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:288
void SetDataTypeToBit()
Definition vtkPoints.h:182
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
double Bounds[6]
Definition vtkPoints.h:388
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:322
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:314
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:191
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:323
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)