void writeToFile(const std::string &name) { if (numNonZeros == 0) updateNumNonZeros(); if (getNumZ() == 0 || getNumFeatures() == 0 || getNumY() == 0 || getNumX() == 0 || zeroZero.norm() == 0) { std::cout << "[voxel::FeatureVoxel::writeToFile] Feature Voxel has unset " "members" << std::endl; exit(1); } std::ofstream out(name, std::ios::out | std::ios::binary); int z = getNumZ(); out.write(reinterpret_cast<const char *>(&z), sizeof(z)); for (int k = 0; k < z; ++k) saveMatrixAsSparse(this->voxelGrid[k], out); int numFeatureVectors = this->featureVectors.size(); out.write(reinterpret_cast<const char *>(&numFeatureVectors), sizeof(int)); for (auto &v : this->featureVectors) saveSpareVector(*v, out); out.write(reinterpret_cast<const char *>(&nextID), sizeof(nextID)); out.write(reinterpret_cast<const char *>(&numNonZeros), sizeof(numNonZeros)); out.write(reinterpret_cast<const char *>(zeroZero.data()), sizeof(zeroZero)); };
DescripPtr getFeatureVector(int x, int y, int z) const { if (x < 0 || x >= getNumX()) return NULL; if (y < 0 || y >= getNumY()) return NULL; if (z < 0 || z >= getNumZ()) return NULL; int ID = this->voxelGrid[z](y, x); return this->getFeatureVector(ID); };
void NgonGridData::getDataProperty(int property, void **_pvData) { if (property == NUM_X) { ((int *) *_pvData)[0] = getNumX(); } else if (property == NUM_Y) { ((int *) *_pvData)[0] = getNumY(); } else if (property == NUM_Z) { ((int *) *_pvData)[0] = getNumZ(); } else if (property == X_DIMENSIONS) { *_pvData = getXDimensions(); } else if (property == Y_DIMENSIONS) { *_pvData = getYDimensions(); } else if (property == X_COORDINATES) { *_pvData = getDataX(); } else if (property == Y_COORDINATES) { *_pvData = getDataY(); } else if (property == Z_COORDINATES) { *_pvData = getDataZ(); } else if (property == Z_COORDINATES_SHIFT) { ((double *) *_pvData)[0] = getZCoordinatesShift(); } else { NgonData::getDataProperty(property, _pvData); } }
int GridSize<QC_3D>::getNumberOfNodes () const { return getNumX() * getNumY() * getNumZ(); }