MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

IO/NetCDF/vtkSLACParticleReader.cxx:259–340  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

257
258//------------------------------------------------------------------------------
259int vtkSLACParticleReader::RequestData(vtkInformation* vtkNotUsed(request),
260 vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
261{
262 vtkPolyData* output = vtkPolyData::GetData(outputVector);
263
264 if (!this->FileName)
265 {
266 vtkErrorMacro("No filename specified.");
267 return 0;
268 }
269
270 vtkSLACParticleReaderAutoCloseNetCDF ncFD(this->FileName, NC_NOWRITE);
271 if (!ncFD.Valid())
272 return 0;
273
274 VTK_CREATE(vtkPoints, points);
275
276 int particlePosVar;
277 CALL_NETCDF_INT(nc_inq_varid(ncFD(), "particlePos", &particlePosVar));
278 vtkIdType numParticles = this->GetNumTuplesInVariable(ncFD(), particlePosVar, 6);
279
280 size_t start[2], count[2];
281 start[0] = 0;
282 count[0] = numParticles;
283 start[1] = 0;
284 count[1] = 3;
285
286 VTK_CREATE(vtkDoubleArray, coords);
287 coords->SetNumberOfComponents(3);
288 coords->SetNumberOfTuples(numParticles);
289 CALL_NETCDF_INT(
290 nc_get_vars_double(ncFD(), particlePosVar, start, count, nullptr, coords->GetPointer(0)));
291 points->SetData(coords);
292 output->SetPoints(points);
293
294 VTK_CREATE(vtkDoubleArray, momentum);
295 momentum->SetName("Momentum");
296 momentum->SetNumberOfComponents(3);
297 momentum->SetNumberOfTuples(numParticles);
298 start[1] = 3;
299 CALL_NETCDF_INT(
300 nc_get_vars_double(ncFD(), particlePosVar, start, count, nullptr, momentum->GetPointer(0)));
301 output->GetPointData()->AddArray(momentum);
302
303 int particleInfoVar;
304 CALL_NETCDF_INT(nc_inq_varid(ncFD(), "particleInfo", &particleInfoVar));
305 start[1] = 0;
306 count[1] = 1;
307
308 VTK_CREATE(vtkIdTypeArray, ids);
309 ids->SetName("ParticleIds");
310 ids->SetNumberOfComponents(1);
311 ids->SetNumberOfTuples(numParticles);
312 CALL_NETCDF_INT(
313 nc_get_vars_vtkIdType(ncFD(), particleInfoVar, start, count, nullptr, ids->GetPointer(0)));
314 output->GetPointData()->SetGlobalIds(ids);
315
316 VTK_CREATE(vtkIntArray, emissionType);

Callers

nothing calls this directly

Calls 15

nc_inq_varidFunction · 0.85
nc_get_vars_doubleFunction · 0.85
nc_get_vars_intFunction · 0.85
nc_get_var_doubleFunction · 0.85
SetGlobalIdsMethod · 0.80
AllocateEstimateMethod · 0.80
SetVertsMethod · 0.80
nc_get_vars_vtkIdTypeFunction · 0.70
GetDataFunction · 0.50
ValidMethod · 0.45
SetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected