OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / include / vtk / vtkPoints.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkPoints.h,v $
5   Language:  C++
6   Date:      $Date: 2002/12/26 18:24:21 $
7   Version:   $Revision: 1.63 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 // .NAME vtkPoints - represent and manipulate 3D points
19 // .SECTION Description
20 // vtkPoints represents 3D points. The data model for vtkPoints is an 
21 // array of vx-vy-vz triplets accessible by (point or cell) id.
22
23 #ifndef __vtkPoints_h
24 #define __vtkPoints_h
25
26 #include "vtkObject.h"
27
28 #include "vtkDataArray.h" // Needed for inline methods
29
30 class vtkIdList;
31 class vtkPoints;
32
33 class VTK_COMMON_EXPORT vtkPoints : public vtkObject
34 {
35 public:
36 //BTX
37   static vtkPoints *New(int dataType);
38 //ETX
39   static vtkPoints *New();
40
41   vtkTypeRevisionMacro(vtkPoints,vtkObject);
42   void PrintSelf(ostream& os, vtkIndent indent);
43
44   // Description:
45   // Allocate initial memory size.
46   virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
47   
48   // Description:
49   // Return object to instantiated state.
50   virtual void Initialize();
51
52 #ifndef VTK_REMOVE_LEGACY_CODE
53   // Description:
54   // For legacy compatibility.  Do not use.
55   vtkPoints* MakeObject();
56 #endif
57
58   // Description:
59   // Set/Get the underlying data array. This function must be implemented
60   // in a concrete subclass to check for consistency. (The tuple size must
61   // match the type of data. For example, 3-tuple data array can be assigned to
62   // a vector, normal, or points object, but not a tensor object, which has a 
63   // tuple dimension of 9. Scalars, on the other hand, can have tuple dimension
64   //  from 1-4, depending on the type of scalar.)
65   virtual void SetData(vtkDataArray *);
66   vtkDataArray *GetData() {return this->Data;};
67
68   // Description:
69   // Return the underlying data type. An integer indicating data type is 
70   // returned as specified in vtkSetGet.h.
71   virtual int GetDataType();
72
73   // Description:
74   // Specify the underlying data type of the object.
75   virtual void SetDataType(int dataType);
76   void SetDataTypeToBit() {this->SetDataType(VTK_BIT);};
77   void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);};
78   void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);};
79   void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);};
80   void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);};
81   void SetDataTypeToInt() {this->SetDataType(VTK_INT);};
82   void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);};
83   void SetDataTypeToLong() {this->SetDataType(VTK_LONG);};
84   void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);};
85   void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);};
86   void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);};
87
88   // Description:
89   // Return a void pointer. For image pipeline interface and other 
90   // special pointer manipulation.
91   void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);};
92
93   // Description:
94   // Reclaim any extra memory.
95   virtual void Squeeze() {this->Data->Squeeze();};
96
97   // Description:
98   // Make object look empty but do not delete memory.  
99   virtual void Reset() {this->Data->Reset();};
100
101   // Description:
102   // Different ways to copy data. Shallow copy does reference count (i.e.,
103   // assigns pointers and updates reference count); deep copy runs through
104   // entire data array assigning values.
105   virtual void DeepCopy(vtkPoints *ad);
106   virtual void ShallowCopy(vtkPoints *ad);
107
108   // Description:
109   // Return the memory in kilobytes consumed by this attribute data. 
110   // Used to support streaming and reading/writing data. The value 
111   // returned is guaranteed to be greater than or equal to the 
112   // memory required to actually represent the data represented 
113   // by this object. The information returned is valid only after
114   // the pipeline has been updated.
115   unsigned long GetActualMemorySize();
116
117   // Description:
118   // Return number of points in array.
119   vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();};
120
121   // Description:
122   // Return a pointer to a float point x[3] for a specific id.
123   float *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);};
124
125   // Description:
126   // Copy point components into user provided array v[3] for specified
127   // id.
128   void GetPoint(vtkIdType id, float x[3]) { this->Data->GetTuple(id,x);};
129   void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x);};
130
131   // Description:
132   // Insert point into object. No range checking performed (fast!).
133   // Make sure you use SetNumberOfPoints() to allocate memory prior
134   // to using SetPoint().
135   void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x);};
136   void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x);};
137   void SetPoint(vtkIdType id, double x, double y, double z);
138
139   // Description:
140   // Insert point into object. Range checking performed and memory
141   // allocated as necessary.
142   void InsertPoint(vtkIdType id, const float x[3])
143     { this->Data->InsertTuple(id,x);};
144   void InsertPoint(vtkIdType id, const double x[3])
145     {this->Data->InsertTuple(id,x);};
146   void InsertPoint(vtkIdType id, double x, double y, double z);
147   
148   // Description:
149   // Insert point into next available slot. Returns id of slot.
150   vtkIdType InsertNextPoint(const float x[3]) { 
151     return this->Data->InsertNextTuple(x);};
152   vtkIdType InsertNextPoint(const double x[3]) { 
153     return this->Data->InsertNextTuple(x);};
154   vtkIdType InsertNextPoint(double x, double y, double z);
155
156   // Description:
157   // Specify the number of points for this object to hold. Does an
158   // allocation as well as setting the MaxId ivar. Used in conjunction with
159   // SetPoint() method for fast insertion.
160   void SetNumberOfPoints(vtkIdType number);
161
162   // Description:
163   // Given a list of pt ids, return an array of points.
164   void GetPoints(vtkIdList *ptId, vtkPoints *fp);
165
166   // Description:
167   // Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
168   virtual void ComputeBounds();
169
170   // Description:
171   // Return the bounds of the points.
172   float *GetBounds();
173
174   // Description:
175   // Return the bounds of the points.
176   void GetBounds(float bounds[6]);
177
178 protected:
179   vtkPoints(int dataType=VTK_FLOAT);
180   ~vtkPoints();
181
182   float Bounds[6];
183   vtkTimeStamp ComputeTime; // Time at which bounds computed
184   vtkDataArray *Data;  // Array which represents data
185
186 private:
187   vtkPoints(const vtkPoints&);  // Not implemented.
188   void operator=(const vtkPoints&);  // Not implemented.
189 };
190
191 inline void vtkPoints::SetNumberOfPoints(vtkIdType number)
192 {
193   this->Data->SetNumberOfComponents(3);
194   this->Data->SetNumberOfTuples(number);
195 }
196
197 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
198 {
199   double p[3];
200   p[0] = x;
201   p[1] = y;
202   p[2] = z;
203   this->Data->SetTuple(id,p);
204 }
205
206 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
207 {
208   double p[3];
209
210   p[0] = x;
211   p[1] = y;
212   p[2] = z;
213   this->Data->InsertTuple(id,p);
214 }
215
216 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
217 {
218   double p[3];
219
220   p[0] = x;
221   p[1] = y;
222   p[2] = z;
223   return this->Data->InsertNextTuple(p);
224 }
225
226 #endif
227