48 const unsigned long value = std::strtoul(text, &end, 10);
49 if (end == text
or *end !=
'\0' or value == 0
50 or value > std::numeric_limits<std::size_t>::max())
52 return static_cast<std::size_t
>(
value);
57 const double cz = 0.5 *
static_cast<double>(
grid.size(0) - 1);
58 const double cy = 0.5 *
static_cast<double>(
grid.size(1) - 1);
59 const double cx = 0.5 *
static_cast<double>(
grid.size(2) - 1);
60 const double radius = 0.28 *
static_cast<double>(
61 std::min(
grid.size(0), std::min(
grid.size(1),
grid.size(2))));
67 const double dz =
static_cast<double>(z) -
cz;
68 const double dy =
static_cast<double>(
y) - cy;
69 const double dx =
static_cast<double>(x) - cx;
70 if (std::sqrt(dx * dx + dy * dy +
dz *
dz) <= radius)
86 count +=
grid.at_safe({z +
dz,
y + dy, x + dx}) != 0 ? 1 : 0;
101 const bool current =
cur.at({
iz,
iy,
ix}) != 0;
102 const int value = (current
and alive >= 5
and alive <= 10)
103 or (
not current
and alive == 6) ? 1 : 0;
113 const std::filesystem::path
out_dir =
argc >= 2 ?
argv[1] :
"ca3d_vtk_output";
116 std::filesystem::create_directories(
out_dir);
124 opts.scalar_name =
"alive";
126 for (std::size_t step = 0; step <=
steps; ++step)
128 const auto path =
out_dir / (
"ca3d_" + std::to_string(step) +
".vtk");
129 std::ofstream
out(path);
135 std::cout <<
"Wrote " << (
steps + 1) <<
" VTK frames to " <<
out_dir <<
'\n';
136 std::cout <<
"Open ca3d_0.vtk in ParaView and enable file-series loading.\n";
size_t size_t int32_t value
size_t size_t int32_t * out
VTK legacy writer for scientific CA visualisation.
Lattice that adds boundary-aware access on top of a storage.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void write_vtk_legacy(std::ostream &out, const Lattice &frame, const VTK_Write_Options &opts={})
Write a 2D or 3D lattice as VTK legacy STRUCTURED_POINTS.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
and
Check uniqueness with explicit hash + equality functors.
void next()
Advance all underlying iterators (bounds-checked).
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Out-of-range neighbours behave as if the lattice ended.
Options for VTK legacy output.
std::string title
VTK header title.
Cellular automata lattice with pluggable boundary policies.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).