Example #1
0
void JitGrid::setGrid<FloatGrid>(const FloatGrid::Ptr& ptr) {
	if(gridType != GridFloat || planecount != 1) {
		destroyGrid();
		gridType = GridFloat;
		planecount = 1;
	}
	float1Grid = ptr;
	voxelSize = ptr->transform().voxelSize()[0];
}
Example #2
0
void VDB::doDifference(VDB & vdb) {
	const math::Transform
		&sourceXform = vdb.grid->transform(),
		&targetXform = grid->transform();
	FloatGrid::Ptr cGrid = createLevelSet<FloatGrid>(grid->voxelSize()[0]);
	cGrid->transform() = grid->transform();
	// Compute a source grid to target grid transform.
	openvdb::Mat4R xform =
		sourceXform.baseMap()->getAffineMap()->getMat4() *
		targetXform.baseMap()->getAffineMap()->getMat4().inverse();
	// Create the transformer.
	openvdb::tools::GridTransformer transformer(xform);

	// Resample using trilinear interpolation.
	transformer.transformGrid<openvdb::tools::BoxSampler, openvdb::FloatGrid>(
		*vdb.grid, *cGrid);
	csgDifference(*grid, *cGrid);
	isUpdated = false;
}