Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
float3 origin = float3(-2, -2, -2);
float3 n = float3(2, 2, 2);
float3 s = float3(0.01, 0.01, 0.01);
int3 dim = int3(int((n.x() - origin.x()) / s.x()),
int((n.y() - origin.y()) / s.y()),
int((n.z() - origin.z()) / s.z()));
int numPoints = dim.x() * dim.y() * dim.z();
std::vector<int> invNums;
invNums.resize(numPoints);
std::vector<float> distances;
distances.resize(numPoints);
openvdb::FloatGrid::Ptr grid =
openvdb::createLevelSet<openvdb::FloatGrid>(voxelSize, halfWidth);
openvdb::FloatGrid::Accessor accessor = grid->getAccessor();
for(int zi = 0; zi < dim.z(); zi++) {
std::cout << zi << std::endl;
for(int yi = 0; yi < dim.y(); yi++) {
for(int xi = 0; xi < dim.x(); xi++) {
if (yi == 0) {
distances[i] = 0.;
i++;
continue;
}
float3 p = float3(origin.x() + s.x() * float(xi),
origin.y() + s.y() * float(yi),
origin.z() + s.z() * float(zi));
float dist = distIIS(p, prismSpheres, prismPlanes, divPlane);
if(abs(dist) < 0.01 ) {
accessor.setValue(openvdb::Coord(xi, yi, zi), dist);
}
i++;
}
}
}
openvdb::tools::signedFloodFill(grid->tree());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.