Skip to content

Instantly share code, notes, and snippets.

@soma-arc
Created December 23, 2017 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soma-arc/5f2b003e998e6d699124430e4c0feb1f to your computer and use it in GitHub Desktop.
Save soma-arc/5f2b003e998e6d699124430e4c0feb1f to your computer and use it in GitHub Desktop.
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