Created
December 23, 2017 12:55
-
-
Save soma-arc/5f2b003e998e6d699124430e4c0feb1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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