VTK
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 =========================================================================*/
29 #ifndef vtkPoints_h
30 #define vtkPoints_h
31 
32 #include "vtkCommonCoreModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 #include "vtkDataArray.h" // Needed for inline methods
36 
37 class vtkIdList;
38 
39 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
40 {
41 public:
42 
43  static vtkPoints *New(int dataType);
44 
45  static vtkPoints *New();
46 
47  vtkTypeMacro(vtkPoints,vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
49 
53  virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
54 
58  virtual void Initialize();
59 
68  virtual void SetData(vtkDataArray *);
69  vtkDataArray *GetData() { return this->Data; }
70 
75  virtual int GetDataType();
76 
80  virtual void SetDataType(int dataType);
81  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
82  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
83  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
84  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
85  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
86  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
87  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
88  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
89  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
90  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
91  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
92 
97  void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
98 
102  virtual void Squeeze() { this->Data->Squeeze(); }
103 
107  virtual void Reset();
108 
110 
115  virtual void DeepCopy(vtkPoints *ad);
116  virtual void ShallowCopy(vtkPoints *ad);
118 
127  unsigned long GetActualMemorySize();
128 
132  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
133 
140  double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id); }
141 
146  void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
147 
153  void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x); }
154  void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x); }
155  void SetPoint(vtkIdType id, double x, double y, double z);
156 
158 
162  void InsertPoint(vtkIdType id, const float x[3])
163  { this->Data->InsertTuple(id,x);};
164  void InsertPoint(vtkIdType id, const double x[3])
165  {this->Data->InsertTuple(id,x);};
166  void InsertPoint(vtkIdType id, double x, double y, double z);
168 
175  { this->Data->InsertTuples(dstIds, srcIds, source->Data); }
176 
182  void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
183  vtkPoints* source)
184  { this->Data->InsertTuples(dstStart, n, srcStart, source->Data); }
185 
189  vtkIdType InsertNextPoint(const float x[3])
190  { return this->Data->InsertNextTuple(x); }
191  vtkIdType InsertNextPoint(const double x[3])
192  { return this->Data->InsertNextTuple(x); }
193  vtkIdType InsertNextPoint(double x, double y, double z);
194 
200  void SetNumberOfPoints(vtkIdType numPoints);
201 
206  int Resize(vtkIdType numPoints);
207 
211  void GetPoints(vtkIdList *ptId, vtkPoints *fp);
212 
216  virtual void ComputeBounds();
217 
221  double *GetBounds();
222 
226  void GetBounds(double bounds[6]);
227 
231  vtkMTimeType GetMTime() VTK_OVERRIDE;
232 
233 protected:
234  vtkPoints(int dataType = VTK_FLOAT);
235  ~vtkPoints() VTK_OVERRIDE;
236 
237  double Bounds[6];
238  vtkTimeStamp ComputeTime; // Time at which bounds computed
239  vtkDataArray *Data; // Array which represents data
240 
241 private:
242  vtkPoints(const vtkPoints&) VTK_DELETE_FUNCTION;
243  void operator=(const vtkPoints&) VTK_DELETE_FUNCTION;
244 };
245 
246 inline void vtkPoints::Reset()
247 {
248  this->Data->Reset();
249  this->Modified();
250 }
251 
253 {
254  this->Data->SetNumberOfComponents(3);
255  this->Data->SetNumberOfTuples(numPoints);
256  this->Modified();
257 }
258 
259 inline int vtkPoints::Resize(vtkIdType numPoints)
260 {
261  this->Data->SetNumberOfComponents(3);
262  this->Modified();
263  return this->Data->Resize(numPoints);
264 }
265 
266 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
267 {
268  double p[3] = { x, y, z };
269  this->Data->SetTuple(id, p);
270 }
271 
272 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
273 {
274  double p[3] = { x, y, z };
275  this->Data->InsertTuple(id, p);
276 }
277 
278 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
279 {
280  double p[3] = { x, y, z };
281  return this->Data->InsertNextTuple(p);
282 }
283 
284 #endif
285 
void SetDataTypeToInt()
Definition: vtkPoints.h:86
void SetDataTypeToFloat()
Definition: vtkPoints.h:90
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:83
int Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:259
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:146
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:191
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints.h:132
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:154
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:174
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
void SetDataTypeToLong()
Definition: vtkPoints.h:88
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Set the tuple at dstTupleIdx in this array to the tuple at srcTupleIdx in the source array...
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:189
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:153
vtkDataArray * Data
Definition: vtkPoints.h:239
int vtkIdType
Definition: vtkType.h:287
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:87
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
void SetDataTypeToChar()
Definition: vtkPoints.h:82
#define VTK_DOUBLE
Definition: vtkType.h:59
#define VTK_FLOAT
Definition: vtkType.h:58
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:162
a simple class to control print indentation
Definition: vtkIndent.h:39
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:97
list of point or cell ids
Definition: vtkIdList.h:36
virtual int Resize(vtkIdType numTuples)=0
Resize the array to the requested number of tuples and preserve data.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual vtkMTimeType GetMTime()
Return this object's modified time.
#define VTK_SHORT
Definition: vtkType.h:52
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:89
#define VTK_CHAR
Definition: vtkType.h:49
#define VTK_LONG
Definition: vtkType.h:56
virtual void Modified()
Update the modification time for this object.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:140
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:252
vtkTimeStamp ComputeTime
Definition: vtkPoints.h:238
vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple from srcTupleIdx in the source array at the end of this array.
void Reset()
Reset to an empty state, without freeing any memory.
virtual void SetNumberOfComponents(int)
Set/Get the dimension (n) of the components.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void SetDataTypeToBit()
Definition: vtkPoints.h:81
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
void SetDataTypeToShort()
Definition: vtkPoints.h:84
#define VTK_BIT
Definition: vtkType.h:48
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:85
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array, starting at the dstStart location.
Definition: vtkPoints.h:182
virtual void SetNumberOfTuples(vtkIdType numTuples)=0
Set the number of tuples (a component group) in the array.
vtkDataArray * GetData()
Definition: vtkPoints.h:69
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:102
void SetDataTypeToDouble()
Definition: vtkPoints.h:91
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:164
#define VTK_INT
Definition: vtkType.h:54
represent and manipulate 3D points
Definition: vtkPoints.h:39