VTK  9.2.6
vtkPoints.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPoints.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
138#ifndef vtkPoints_h
139#define vtkPoints_h
140
141#include "vtkCommonCoreModule.h" // For export macro
142#include "vtkObject.h"
143
144#include "vtkDataArray.h" // Needed for inline methods
145
146class vtkIdList;
147
148class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
149{
150public:
151 static vtkPoints* New(int dataType);
152
153 static vtkPoints* New();
154
155 vtkTypeMacro(vtkPoints, vtkObject);
156 void PrintSelf(ostream& os, vtkIndent indent) override;
157
161 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
162
166 virtual void Initialize();
167
176 virtual void SetData(vtkDataArray*);
177 vtkDataArray* GetData() { return this->Data; }
178
183 virtual int GetDataType() const;
184
189 virtual void SetDataType(int dataType);
190 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
191 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
192 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
193 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
194 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
195 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
196 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
197 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
198 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
199 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
200 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
201
206 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
207
211 virtual void Squeeze() { this->Data->Squeeze(); }
212
216 virtual void Reset();
217
219
224 virtual void DeepCopy(vtkPoints* ad);
225 virtual void ShallowCopy(vtkPoints* ad);
227
236 unsigned long GetActualMemorySize();
237
241 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
242
249 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
250 {
251 return this->Data->GetTuple(id);
252 }
253
258 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
259 VTK_SIZEHINT(3)
260 {
261 this->Data->GetTuple(id, x);
262 }
263
270 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
271 {
272 this->Data->SetTuple(id, x);
273 }
274 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
275 {
276 this->Data->SetTuple(id, x);
277 }
278 void SetPoint(vtkIdType id, double x, double y, double z)
279 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
280
282
286 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
287 {
288 this->Data->InsertTuple(id, x);
289 }
290 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
291 {
292 this->Data->InsertTuple(id, x);
293 }
294 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
296
303 {
304 this->Data->InsertTuples(dstIds, srcIds, source->Data);
305 }
306
313 {
314 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
315 }
316
320 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
321 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
322 vtkIdType InsertNextPoint(double x, double y, double z);
323
329 void SetNumberOfPoints(vtkIdType numPoints);
330
335 vtkTypeBool Resize(vtkIdType numPoints);
336
340 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
341
345 virtual void ComputeBounds();
346
351
355 void GetBounds(double bounds[6]);
356
360 vtkMTimeType GetMTime() override;
361
367 void Modified() override;
368
369protected:
370 vtkPoints(int dataType = VTK_FLOAT);
371 ~vtkPoints() override;
372
373 double Bounds[6];
374 vtkTimeStamp ComputeTime; // Time at which bounds computed
375 vtkDataArray* Data; // Array which represents data
376
377private:
378 vtkPoints(const vtkPoints&) = delete;
379 void operator=(const vtkPoints&) = delete;
380};
381
382inline void vtkPoints::Reset()
383{
384 this->Data->Reset();
385 this->Modified();
386}
387
389{
390 this->Data->SetNumberOfComponents(3);
391 this->Data->SetNumberOfTuples(numPoints);
392 this->Modified();
393}
394
396{
397 this->Data->SetNumberOfComponents(3);
398 this->Modified();
399 return this->Data->Resize(numPoints);
400}
401
402inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
403{
404 double p[3] = { x, y, z };
405 this->Data->SetTuple(id, p);
406}
407
408inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
409{
410 double p[3] = { x, y, z };
411 this->Data->InsertTuple(id, p);
412}
413
414inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
415{
416 double p[3] = { x, y, z };
417 return this->Data->InsertNextTuple(p);
418}
419
420#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
list of point or cell ids
Definition: vtkIdList.h:143
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:149
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:274
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:194
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:270
void SetDataTypeToChar()
Definition: vtkPoints.h:191
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:290
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:195
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition: vtkPoints.h:197
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:302
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:211
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:198
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:192
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition: vtkPoints.h:177
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:249
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:196
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:206
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:258
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:193
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:241
void SetDataTypeToDouble()
Definition: vtkPoints.h:200
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:388
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:395
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:286
void SetDataTypeToBit()
Definition: vtkPoints.h:190
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:320
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:312
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition: vtkPoints.h:199
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:321
record modification and/or execution time
Definition: vtkTimeStamp.h:55
void GetBounds(T a, double bds[6])
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SHORT
Definition: vtkType.h:48
int vtkIdType
Definition: vtkType.h:332
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
#define VTK_DOUBLE
Definition: vtkType.h:55
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_INT
Definition: vtkType.h:50
#define VTK_FLOAT
Definition: vtkType.h:54
#define VTK_CHAR
Definition: vtkType.h:45
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
#define VTK_BIT
Definition: vtkType.h:44
#define VTK_LONG
Definition: vtkType.h:52
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)