17 #ifndef vtkPointAccumulator_h 18 #define vtkPointAccumulator_h 26 template <
typename T_CPP,
class T_VTK>
32 this->PtStore =
nullptr;
42 if (this->PtStore !=
nullptr)
46 this->PtStore =
nullptr;
53 bool Empty() {
return this->NPts == 0; }
61 const int bytesPerPoint = 3 *
sizeof(T_CPP);
64 T_CPP* newPointStore =
static_cast<T_CPP*
>(realloc(this->PtStore, newNPts * bytesPerPoint));
65 if (newPointStore ==
nullptr)
70 throw std::bad_alloc();
74 T_CPP* writePointer = newPointStore + 3 * this->NPts;
76 this->PtStore = newPointStore;
90 T_CPP* writePointer = this->
Expand(n);
92 const int bytesPerPoint = 3 *
sizeof(T_CPP);
93 memcpy(writePointer, pts, n * bytesPerPoint);
108 T_VTK* da = T_VTK::New();
109 da->SetNumberOfComponents(3);
110 da->SetArray(this->PtStore, 3 * this->NPts, 1);
127 for (
int q = 0;
q < 3; ++
q)
129 bounds[
q] =
static_cast<double>(this->PtStore[
q]);
130 bounds[
q + 1] =
static_cast<double>(this->PtStore[
q + 1]);
133 for (
vtkIdType i = 1; i < this->NPts; ++i)
137 pt[0] =
static_cast<double>(this->PtStore[ptIdx]);
138 pt[1] =
static_cast<double>(this->PtStore[ptIdx + 1]);
139 pt[2] =
static_cast<double>(this->PtStore[ptIdx + 2]);
140 bounds[0] = std::min(bounds[0], pt[0]);
141 bounds[1] = std::max(bounds[1], pt[0]);
142 bounds[2] = std::min(bounds[2], pt[1]);
143 bounds[3] = std::max(bounds[3], pt[1]);
144 bounds[4] = std::min(bounds[4], pt[2]);
145 bounds[5] = std::max(bounds[5], pt[2]);
159 T_CPP* pBuf = this->PtStore;
160 for (
int i = 0; i < this->NPts; ++i)
162 std::cerr << i <<
" (" << pBuf[0];
163 for (
int q = 1;
q < 3; ++
q)
165 std::cerr <<
", " << pBuf[
q];
167 std::cerr <<
")" << endl;
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)