void StructuredVolume::commit() { //! Some parameters can be changed after the volume has been allocated and filled. if (ispcEquivalent != NULL) return(updateEditableParameters()); //! Check for a file name. std::string filename = getParamString("filename", ""); //! The volume may be initialized from the contents of a file or from memory. if (!filename.empty()) VolumeFile::importVolume(filename, this); else getVolumeFromMemory(); //! Complete volume initialization. finish(); }
//! Allocate storage and populate the volume. void AMRVolume::commit() { updateEditableParameters(); // Make the voxel value range visible to the application. if (findParam("voxelRange") == nullptr) setParam("voxelRange", voxelRange); else voxelRange = getParam2f("voxelRange", voxelRange); auto methodStringFromEnv = utility::getEnvVar<std::string>("OSPRAY_AMR_METHOD"); std::string methodString = methodStringFromEnv.value_or(getParamString("amrMethod","current")); if (methodString == "finest" || methodString == "finestLevel") ispc::AMR_install_finest(getIE()); else if (methodString == "current" || methodString == "currentLevel") ispc::AMR_install_current(getIE()); else if (methodString == "octant") ispc::AMR_install_octant(getIE()); if (data != nullptr) //TODO: support data updates return; brickInfoData = getParamData("brickInfo"); assert(brickInfoData); assert(brickInfoData->data); brickDataData = getParamData("brickData"); assert(brickDataData); assert(brickDataData->data); data = make_unique<amr::AMRData>(*brickInfoData,*brickDataData); accel = make_unique<amr::AMRAccel>(*data); // finding coarset cell size + finest level cell width float coarsestCellWidth = 0.f; float finestLevelCellWidth = data->brick[0].cellWidth; box3i rootLevelBox = empty; for (auto &b : data->brick) { if (b.level == 0) rootLevelBox.extend(b.box); finestLevelCellWidth = min(finestLevelCellWidth, b.cellWidth); coarsestCellWidth = max(coarsestCellWidth, b.cellWidth); } vec3i rootGridDims = rootLevelBox.size() + vec3i(1); ospLogF(1) << "found root level dimensions of " << rootGridDims; ospLogF(1) << "coarsest cell width is " << coarsestCellWidth << std::endl; auto rateFromEnv = utility::getEnvVar<float>("OSPRAY_AMR_SAMPLING_STEP"); float samplingStep = rateFromEnv.value_or(0.1f * coarsestCellWidth); box3f worldBounds = accel->worldBounds; const vec3f gridSpacing = getParam3f("gridSpacing", vec3f(1.f)); const vec3f gridOrigin = getParam3f("gridOrigin", vec3f(0.f)); voxelType = getParamString("voxelType", "unspecified"); auto voxelTypeID = getVoxelType(); switch (voxelTypeID) { case OSP_UCHAR: break; case OSP_SHORT: break; case OSP_USHORT: break; case OSP_FLOAT: break; case OSP_DOUBLE: break; default: throw std::runtime_error("amrVolume unsupported voxel type '" + voxelType + "'"); } ispc::AMRVolume_set(getIE(), (ispc::box3f&)worldBounds, samplingStep, (const ispc::vec3f&)gridOrigin, (const ispc::vec3f&)gridSpacing); ispc::AMRVolume_setAMR(getIE(), accel->node.size(), &accel->node[0], accel->leaf.size(), &accel->leaf[0], accel->level.size(), &accel->level[0], voxelTypeID, (ispc::box3f &)worldBounds); tasking::parallel_for(accel->leaf.size(),[&](size_t leafID) { ispc::AMRVolume_computeValueRangeOfLeaf(getIE(), leafID); }); }