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

Method GetParticles

IO/AMR/vtkAMRFlashParticlesReader.cxx:153–291  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

151
152//------------------------------------------------------------------------------
153vtkPolyData* vtkAMRFlashParticlesReader::GetParticles(const char* file, int vtkNotUsed(blkidx))
154{
155 hid_t dataIdx = H5Dopen(this->Internal->FileIndex, file);
156 if (dataIdx < 0)
157 {
158 vtkErrorMacro("Could not open particles file!");
159 return nullptr;
160 }
161
162 vtkPolyData* particles = vtkPolyData::New();
163 vtkPoints* positions = vtkPoints::New();
164 positions->SetDataTypeToDouble();
165 positions->SetNumberOfPoints(this->Internal->NumberOfParticles);
166
167 vtkPointData* pdata = particles->GetPointData();
168 assert("pre: PointData is nullptr" && (pdata != nullptr));
169
170 // Load the particle position arrays by name
171 std::vector<double> xcoords;
172 std::vector<double> ycoords;
173 std::vector<double> zcoords;
174 GetParticleCoordinates(
175 dataIdx, xcoords, ycoords, zcoords, this->Internal, this->Internal->NumberOfParticles);
176
177 // Sub-sample particles
178 int TotalNumberOfParticles = static_cast<int>(xcoords.size());
179 vtkIdList* ids = vtkIdList::New();
180 ids->SetNumberOfIds(TotalNumberOfParticles);
181
182 vtkIdType NumberOfParticlesLoaded = 0;
183 for (int i = 0; i < TotalNumberOfParticles; ++i)
184 {
185 if (i % this->Frequency == 0)
186 {
187 if (this->CheckLocation(xcoords[i], ycoords[i], zcoords[i]))
188 {
189 int pidx = NumberOfParticlesLoaded;
190 ids->InsertId(pidx, i);
191 positions->SetPoint(pidx, xcoords[i], ycoords[i], zcoords[i]);
192 ++NumberOfParticlesLoaded;
193 } // END if within requested region
194 } // END if within requested interval
195 } // END for all particles
196
197 xcoords.clear();
198 ycoords.clear();
199 zcoords.clear();
200
201 ids->SetNumberOfIds(NumberOfParticlesLoaded);
202 ids->Squeeze();
203
204 positions->SetNumberOfPoints(NumberOfParticlesLoaded);
205 positions->Squeeze();
206
207 particles->SetPoints(positions);
208 positions->Squeeze();
209
210 // Create CellArray consisting of a single polyvertex

Callers 1

ReadParticlesMethod · 0.95

Calls 15

GetParticleCoordinatesFunction · 0.85
H5TcreateFunction · 0.85
H5TinsertFunction · 0.85
H5DcloseFunction · 0.85
SetNumberOfIdsMethod · 0.80
CheckLocationMethod · 0.80
InsertIdMethod · 0.80
InsertCellPointMethod · 0.80
SetVertsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected