28 #ifndef vtkPointAccumulator_h 29 #define vtkPointAccumulator_h 34 template <
typename T_CPP,
class T_VTK>
50 if (this->PtStore != 0)
61 bool Empty() {
return this->NPts == 0; }
69 const int bytesPerPoint = 3 *
sizeof(T_CPP);
72 T_CPP* newPointStore =
static_cast<T_CPP*
>(realloc(this->PtStore, newNPts * bytesPerPoint));
73 if (newPointStore == 0)
78 throw std::bad_alloc();
82 T_CPP* writePointer = newPointStore + 3 * this->NPts;
84 this->PtStore = newPointStore;
98 T_CPP* writePointer = this->
Expand(n);
100 const int bytesPerPoint = 3 *
sizeof(T_CPP);
101 memcpy(writePointer, pts, n * bytesPerPoint);
116 T_VTK* da = T_VTK::New();
117 da->SetNumberOfComponents(3);
118 da->SetArray(this->PtStore, 3 * this->NPts, 1);
135 for (
int q = 0;
q < 3; ++
q)
137 bounds[
q] =
static_cast<double>(this->PtStore[
q]);
138 bounds[
q + 1] =
static_cast<double>(this->PtStore[
q + 1]);
141 for (
vtkIdType i = 1; i < this->NPts; ++i)
145 pt[0] =
static_cast<double>(this->PtStore[ptIdx]);
146 pt[1] =
static_cast<double>(this->PtStore[ptIdx + 1]);
147 pt[2] =
static_cast<double>(this->PtStore[ptIdx + 2]);
148 if (pt[0] < bounds[0])
150 if (pt[0] > bounds[1])
152 if (pt[1] < bounds[2])
154 if (pt[1] > bounds[3])
156 if (pt[2] < bounds[4])
158 if (pt[2] > bounds[5])
173 T_CPP* pBuf = this->PtStore;
174 for (
int i = 0; i < this->NPts; ++i)
176 cerr << i <<
" (" << pBuf[0];
177 for (
int q = 1;
q < 3; ++
q)
179 cerr <<
", " << pBuf[
q];
Container class that manages appending data arrays of points.
void Accumulate(T_CPP *pts, vtkIdType n)
Adds an array of points to the end of the internal store.
void GetBounds(double bounds[6])
Compute axis-aligned bounding box.
vtkIdType GetNumberOfPoints()
Return the number of points currently in the point store.
vtkPoints * BuildVtkPoints()
Creates a vtkPoints data structure from the internal store.
void Clear()
Free resources and mark as empty.
bool Empty()
Test if there is anything in the store.
void Accumulate(T_VTK *pts)
Adds an array of points at the end of the internal store.
virtual void SetData(vtkDataArray *)
T_CPP * Expand(vtkIdType n)
Extend the internal store and get a pointer to the newly added memory.
void Print()
Print the contents of the internal store.
VTKWRAPPINGJAVA_EXPORT jlong q(JNIEnv *env, jobject obj)