-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_write_grid.cxx
More file actions
24 lines (24 loc) · 883 Bytes
/
create_write_grid.cxx
File metadata and controls
24 lines (24 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <openvdb/openvdb.h>
#include <openvdb/tools/LevelSetSphere.h>
int main()
{
openvdb::initialize();
// Create a FloatGrid and populate it with a narrow-band
// signed distance field of a sphere.
openvdb::FloatGrid::Ptr grid =
openvdb::tools::createLevelSetSphere<openvdb::FloatGrid>(
/*radius=*/50.0, /*center=*/openvdb::Vec3f(1.5, 2, 3),
/*voxel size=*/0.5, /*width=*/4.0);
// Associate some metadata with the grid.
grid->insertMeta("radius", openvdb::FloatMetadata(50.0));
// Name the grid "LevelSetSphere".
grid->setName("LevelSetSphere");
// Create a VDB file object.
openvdb::io::File file("mygrids.vdb");
// Add the grid pointer to a container.
openvdb::GridPtrVec grids;
grids.push_back(grid);
// Write out the contents of the container.
file.write(grids);
file.close();
}