MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/openvdb / setState

Method setState

openvdb/openvdb/python/pyGrid.h:1122–1142  ·  view source on GitHub ↗

Restore the given Grid to a saved state.

Source from the content-addressed store, hash-verified

1120
1121 /// Restore the given Grid to a saved state.
1122 static void setState(GridType& grid, std::tuple<nb::bytes> state)
1123 {
1124 nb::bytes bytesObj = std::get<0>(state);
1125 std::string serialized(bytesObj.c_str(), bytesObj.c_str() + bytesObj.size());
1126
1127 // Restore the internal state of the C++ object.
1128 GridPtrVecPtr grids;
1129 {
1130 std::istringstream istr(serialized, std::ios_base::binary);
1131 io::Stream strm(istr);
1132 grids = strm.getGrids(); // (note: file-level metadata is ignored)
1133 }
1134 if (grids && !grids->empty()) {
1135 if (typename GridType::Ptr savedGrid = gridPtrCast<GridType>((*grids)[0])) {
1136 new (&grid) GridType(*savedGrid);
1137 return;
1138 }
1139 }
1140
1141 new (&grid) GridType();
1142 }
1143}; // struct PickleSuite
1144
1145

Callers 2

renormalizeMethod · 0.45
resizeNarrowBandMethod · 0.45

Calls 4

c_strMethod · 0.80
sizeMethod · 0.45
getGridsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected