17 #ifndef vtkPointAccumulator_h
18 #define vtkPointAccumulator_h
23 template <
typename T_CPP,
class T_VTK>
29 this->PtStore =
nullptr;
39 if (this->PtStore !=
nullptr)
43 this->PtStore =
nullptr;
50 bool Empty() {
return this->NPts == 0; }
58 const int bytesPerPoint = 3 *
sizeof(T_CPP);
61 T_CPP* newPointStore =
static_cast<T_CPP*
>(realloc(this->PtStore, newNPts * bytesPerPoint));
62 if (newPointStore ==
nullptr)
67 throw std::bad_alloc();
71 T_CPP* writePointer = newPointStore + 3 * this->NPts;
73 this->PtStore = newPointStore;
87 T_CPP* writePointer = this->
Expand(n);
89 const int bytesPerPoint = 3 *
sizeof(T_CPP);
90 memcpy(writePointer, pts, n * bytesPerPoint);
105 T_VTK* da = T_VTK::New();
106 da->SetNumberOfComponents(3);
107 da->SetArray(this->PtStore, 3 * this->NPts, 1);
124 for (
int q = 0;
q < 3; ++
q)
126 bounds[
q] =
static_cast<double>(this->PtStore[
q]);
127 bounds[
q + 1] =
static_cast<double>(this->PtStore[
q + 1]);
130 for (
vtkIdType i = 1; i < this->NPts; ++i)
134 pt[0] =
static_cast<double>(this->PtStore[ptIdx]);
135 pt[1] =
static_cast<double>(this->PtStore[ptIdx + 1]);
136 pt[2] =
static_cast<double>(this->PtStore[ptIdx + 2]);
137 if (pt[0] < bounds[0])
139 if (pt[0] > bounds[1])
141 if (pt[1] < bounds[2])
143 if (pt[1] > bounds[3])
145 if (pt[2] < bounds[4])
147 if (pt[2] > bounds[5])
162 T_CPP* pBuf = this->PtStore;
163 for (
int i = 0; i < this->NPts; ++i)
165 cerr << i <<
" (" << pBuf[0];
166 for (
int q = 1;
q < 3; ++
q)
168 cerr <<
", " << pBuf[
q];