in src/PreprocessMesh.cpp [196:226]
void writeSDFToNPZ(
std::vector<Eigen::Vector3f>& xyz,
std::vector<float>& sdfs,
std::string filename,
bool print_num = false) {
unsigned int num_vert = xyz.size();
std::vector<float> pos;
std::vector<float> neg;
for (unsigned int i = 0; i < num_vert; i++) {
Eigen::Vector3f v = xyz[i];
float s = sdfs[i];
if (s > 0) {
for (int j = 0; j < 3; j++)
pos.push_back(v[j]);
pos.push_back(s);
} else {
for (int j = 0; j < 3; j++)
neg.push_back(v[j]);
neg.push_back(s);
}
}
cnpy::npz_save(filename, "pos", &pos[0], {(long unsigned int)(pos.size() / 4.0), 4}, "w");
cnpy::npz_save(filename, "neg", &neg[0], {(long unsigned int)(neg.size() / 4.0), 4}, "a");
if (print_num) {
std::cout << "pos num: " << pos.size() / 4.0 << std::endl;
std::cout << "neg num: " << neg.size() / 4.0 << std::endl;
}
}