MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / initVolumeMap

Method initVolumeMap

Simulator/SimulatorBase.cpp:2512–2731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2510}
2511
2512void SimulatorBase::initVolumeMap(std::vector<Vector3r> &x, std::vector<unsigned int> &faces, const Utilities::BoundaryParameterObject *boundaryData, const bool md5, const bool isDynamic, BoundaryModel_Bender2019 *boundaryModel)
2513{
2514 Simulation *sim = Simulation::getCurrent();
2515 const std::string& sceneFile = SceneConfiguration::getCurrent()->getSceneFile();
2516 const Utilities::SceneLoader::Scene& scene = SceneConfiguration::getCurrent()->getScene();
2517 const Real supportRadius = sim->getSupportRadius();
2518 std::string scene_path = FileSystem::getFilePath(sceneFile);
2519 std::string scene_file_name = FileSystem::getFileName(sceneFile);
2520 const bool useCache = getUseParticleCaching();
2521 Discregrid::CubicLagrangeDiscreteGrid *volumeMap;
2522
2523 // if a map file is given, use this one
2524 if (boundaryData->mapFile != "")
2525 {
2526 std::string mapFileName = boundaryData->mapFile;
2527 if (FileSystem::isRelativePath(mapFileName))
2528 mapFileName = FileSystem::normalizePath(scene_path + "/" + mapFileName);
2529 volumeMap = new Discregrid::CubicLagrangeDiscreteGrid(mapFileName);
2530 boundaryModel->setMap(volumeMap);
2531 LOG_INFO << "Loaded volume map: " << mapFileName;
2532 return;
2533 }
2534
2535 string cachePath = scene_path + "/Cache";
2536
2537 // Cache map
2538 std::string mesh_base_path = FileSystem::getFilePath(boundaryData->meshFile);
2539 std::string mesh_file_name = FileSystem::getFileName(boundaryData->meshFile);
2540
2541 Eigen::Matrix<unsigned int, 3, 1> resolutionSDF = boundaryData->mapResolution;
2542 const string scaleStr = "s" + StringTools::real2String(boundaryData->scale[0]) + "_" + StringTools::real2String(boundaryData->scale[1]) + "_" + StringTools::real2String(boundaryData->scale[2]);
2543 const string resStr = "r" + to_string(resolutionSDF[0]) + "_" + to_string(resolutionSDF[1]) + "_" + to_string(resolutionSDF[2]);
2544 const string invertStr = "i" + to_string((int)boundaryData->mapInvert);
2545 const string thicknessStr = "t" + StringTools::real2String(boundaryData->mapThickness);
2546 string volumeMapFileName = "";
2547 if (isDynamic)
2548 volumeMapFileName = FileSystem::normalizePath(cachePath + "/" + mesh_file_name + "_db_vm_" + StringTools::real2String(scene.particleRadius) + "_" + scaleStr + "_" + resStr + "_" + invertStr + "_" + thicknessStr + ".cdm");
2549 else
2550 volumeMapFileName = FileSystem::normalizePath(cachePath + "/" + mesh_file_name + "_sb_vm_" + StringTools::real2String(scene.particleRadius) + "_" + scaleStr + "_" + resStr + "_" + invertStr + "_" + thicknessStr + ".cdm");
2551
2552 // check MD5 if cache file is available
2553 bool foundCacheFile = false;
2554
2555 if (useCache)
2556 foundCacheFile = FileSystem::fileExists(volumeMapFileName);
2557
2558 if (useCache && foundCacheFile && md5)
2559 {
2560 volumeMap = new Discregrid::CubicLagrangeDiscreteGrid(volumeMapFileName);
2561 boundaryModel->setMap(volumeMap);
2562 LOG_INFO << "Loaded cached volume map: " << volumeMapFileName;
2563 return;
2564 }
2565
2566 if (!useCache || !foundCacheFile || !md5)
2567 {
2568 //////////////////////////////////////////////////////////////////////////
2569 // Generate distance field of object using Discregrid

Callers 2

initBoundaryDataMethod · 0.80
initBoundaryDataMethod · 0.80

Calls 15

maxFunction · 0.85
getSupportRadiusMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
is2DSimulationMethod · 0.80
saveMethod · 0.80
to_stringFunction · 0.50
setMapMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
getParticleRadiusMethod · 0.45

Tested by

no test coverage detected