VTK  9.5.20250712
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
232 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
233
241 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
242 {
243 return this->Data->GetTuple(id);
244 }
245
251 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
252 VTK_SIZEHINT(3)
253 {
254 this->Data->GetTuple(id, x);
255 }
256
264 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
265 {
266 this->Data->SetTuple(id, x);
267 }
269 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
270 {
271 this->Data->SetTuple(id, x);
272 }
274 void SetPoint(vtkIdType id, double x, double y, double z)
275 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
276
278
282 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
283 {
284 this->Data->InsertTuple(id, x);
285 }
286 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
287 {
288 this->Data->InsertTuple(id, x);
289 }
290 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
292
299 {
300 this->Data->InsertTuples(dstIds, srcIds, source->Data);
301 }
302
309 {
310 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
311 }
312
316 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
317 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
318 vtkIdType InsertNextPoint(double x, double y, double z);
319
326 void SetNumberOfPoints(vtkIdType numPoints);
327
333 vtkTypeBool Resize(vtkIdType numPoints);
334
338 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
339
343 virtual void ComputeBounds();
344
349
353 void GetBounds(double bounds[6]);
354
358 vtkMTimeType GetMTime() override;
359
365 void Modified() override;
366
367protected:
368 vtkPoints(int dataType = VTK_FLOAT);
369 ~vtkPoints() override;
370
371 double Bounds[6];
372 vtkTimeStamp ComputeTime; // Time at which bounds computed
373 vtkDataArray* Data; // Array which represents data
374
375private:
376 vtkPoints(const vtkPoints&) = delete;
377 void operator=(const vtkPoints&) = delete;
378};
379
380inline void vtkPoints::Reset()
381{
382 this->Data->Reset();
383 this->Modified();
384}
385
387{
388 if (numPoints != this->Data->GetNumberOfTuples())
389 {
390 this->Data->SetNumberOfComponents(3);
391 this->Data->SetNumberOfTuples(numPoints);
392 this->Modified();
393 }
394}
395
397{
398 if (numPoints != this->Data->GetNumberOfTuples())
399 {
400 this->Data->SetNumberOfComponents(3);
401 this->Modified();
402 return this->Data->Resize(numPoints);
403 }
404 return 1;
405}
406
407inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
408{
409 double p[3] = { x, y, z };
410 this->Data->SetTuple(id, p);
411}
412
413inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
414{
415 double p[3] = { x, y, z };
416 this->Data->InsertTuple(id, p);
417}
418
419inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
420{
421 double p[3] = { x, y, z };
422 return this->Data->InsertNextTuple(p);
423}
424
425VTK_ABI_NAMESPACE_END
426#endif
void GetPoint(int i, int j, int k, double pnt[3])
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 SetDataTypeToUnsignedShort()
Definition vtkPoints.h:184
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:264
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:286
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:298
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.
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
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:183
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:386
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:396
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:282
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:316
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:308
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:317
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:37
int vtkIdType
Definition vtkType.h:332
#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:287
#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)