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

Method readBoundaryState

Simulator/SimulatorBase.cpp:2240–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2238
2239
2240void SimulatorBase::readBoundaryState(const std::string &fileName, BoundaryModel *bm)
2241{
2242 Simulation *sim = Simulation::getCurrent();
2243 if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Akinci2012)
2244 {
2245 if (!FileSystem::fileExists(fileName))
2246 {
2247 LOG_WARN << "File " << fileName << " does not exist.";
2248 return;
2249 }
2250
2251 BoundaryModel_Akinci2012 *model = static_cast<BoundaryModel_Akinci2012*>(bm);
2252 Partio::ParticlesDataMutable* data = Partio::read(fileName.c_str());
2253 if (!data)
2254 {
2255 LOG_WARN << "Partio file " << fileName << " not readable.";
2256 return;
2257 }
2258
2259 unsigned int pos0Index = 0xffffffff;
2260 unsigned int posIndex = 0xffffffff;
2261 unsigned int velIndex = 0xffffffff;
2262 unsigned int volIndex = 0xffffffff;
2263
2264 for (int i = 0; i < data->numAttributes(); i++)
2265 {
2266 Partio::ParticleAttribute attr;
2267 data->attributeInfo(i, attr);
2268 if (attr.name == "position0")
2269 pos0Index = i;
2270 else if (attr.name == "position")
2271 posIndex = i;
2272 else if (attr.name == "velocity")
2273 velIndex = i;
2274 else if (attr.name == "volume")
2275 volIndex = i;
2276 }
2277
2278 if ((pos0Index == 0xffffffff) ||
2279 (posIndex == 0xffffffff) ||
2280 (velIndex == 0xffffffff) ||
2281 (volIndex == 0xffffffff))
2282 {
2283 LOG_WARN << "File " << fileName << " does not has the correct attributes.";
2284 return;
2285 }
2286
2287 Partio::ParticleAttribute attrX0;
2288 Partio::ParticleAttribute attrX;
2289 Partio::ParticleAttribute attrVel;
2290 Partio::ParticleAttribute attrVol;
2291
2292 data->attributeInfo(pos0Index, attrX0);
2293 data->attributeInfo(posIndex, attrX);
2294 data->attributeInfo(velIndex, attrVel);
2295 data->attributeInfo(volIndex, attrVol);
2296
2297 model->resize(data->numParticles());

Callers

nothing calls this directly

Calls 11

numParticlesMethod · 0.80
getVelocityMethod · 0.80
setVolumeMethod · 0.80
getNeighborhoodSearchMethod · 0.80
readFunction · 0.50
c_strMethod · 0.45
resizeMethod · 0.45
releaseMethod · 0.45
getPointSetIndexMethod · 0.45
numberOfParticlesMethod · 0.45

Tested by

no test coverage detected