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

Method readScene

SPlisHSPlasH/Utilities/SceneLoader.cpp:13–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13void SceneLoader::readScene(const char *fileName, Scene &scene)
14{
15 LOG_INFO << "Load scene file: " << fileName;
16
17 std::ifstream input_file(fileName);
18 if (!input_file.is_open())
19 {
20 LOG_ERR << "Cannot open file!";
21 return;
22 }
23 try
24 {
25 m_jsonData = nlohmann::json::parse(input_file);
26 }
27 catch (const std::exception& e)
28 {
29 LOG_ERR << e.what();
30 exit(1);
31 }
32
33 std::string base_path = FileSystem::getFilePath(fileName);
34
35 //////////////////////////////////////////////////////////////////////////
36 // read configuration
37 //////////////////////////////////////////////////////////////////////////
38 if (m_jsonData.find("Configuration") != m_jsonData.end())
39 {
40 nlohmann::json config = m_jsonData["Configuration"];
41
42 scene.particleRadius = 0.025;
43 readValue(config["particleRadius"], scene.particleRadius);
44
45 scene.sim2D = false;
46 readValue(config["sim2D"], scene.sim2D);
47 }
48
49 //////////////////////////////////////////////////////////////////////////
50 // read boundary models
51 //////////////////////////////////////////////////////////////////////////
52 if (m_jsonData.find("RigidBodies") != m_jsonData.end())
53 {
54 nlohmann::json boundaryModels = m_jsonData["RigidBodies"];
55 for (auto& boundaryModel : boundaryModels)
56 {
57 BoundaryParameterObject* data = new BoundaryParameterObject();
58 data->initParameters();
59 readParameterObject(boundaryModel, data);
60 data->axis.normalize();
61 if ((data->meshFile != "") || (data->samplesFile != ""))
62 scene.boundaryModels.push_back(data);
63 else
64 delete data;
65 }
66 }
67
68
69 //////////////////////////////////////////////////////////////////////////
70 // read fluid models

Callers 1

performMeshSkinningFunction · 0.45

Calls 7

parseFunction · 0.85
whatMethod · 0.45
findMethod · 0.45
endMethod · 0.45
initParametersMethod · 0.45
normalizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected