MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / from

Method from

splashsurf_lib/src/io/vtk_format.rs:362–398  ·  view source on GitHub ↗
(particles: Particles<'a, R>)

Source from the content-addressed store, hash-verified

360 R: Real,
361{
362 fn from(particles: Particles<'a, R>) -> Self {
363 let particles = particles.0;
364
365 let points = {
366 let mut points: Vec<R> = Vec::with_capacity(particles.len() * 3);
367 for p in particles.iter() {
368 points.extend(p.as_slice());
369 }
370 points
371 };
372
373 // Each particle has a cell of type `Vertex`
374 let cell_types = vec![CellType::Vertex; particles.len()];
375
376 let vertices = {
377 let mut vertices = Vec::with_capacity(particles.len() * (1 + 1));
378 for i in 0..particles.len() {
379 // Number of vertices of the cell
380 vertices.push(1);
381 // Vertex index
382 vertices.push(i as u32);
383 }
384 vertices
385 };
386
387 UnstructuredGridPiece {
388 points: points.into(),
389 cells: Cells {
390 cell_verts: VertexNumbers::Legacy {
391 num_cells: cell_types.len() as u32,
392 vertices,
393 },
394 types: cell_types,
395 },
396 data: Attributes::new(),
397 }
398 }
399}
400
401#[cfg(test)]

Callers

nothing calls this directly

Calls 2

lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected