Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

How to migrate to bonsairobo/my-stack? #52

Description

@wlinna

Hello,

could you give some pointers on how to migrate to the new stack?

I used building-blocks in my project some time ago, and now I'm wondering how to migrate to bonsairobo/my-stack. I'm not sure what is the best way to do that, and I'm not very familiar with some concepts, such as localize_points_array . I don't even know which crates to use.

Here are some of the structs, impls and functions I use. I mostly just use building_blocks to generate grids and iterate through them.

  • PointN (ilattice?)
  • Extent2i::from_min_and_shape, Extent3i::from_min_and_shape (ilattice)
  • Extent3i::from_min_and_max (ilattice)
  • Array2x1::fill, Array3x1::fill
  • Array::extent
  • Point3::axis_component_mut
  • Local::localize_points_array(&Point3i::MOORE_OFFSETS)
  • Array::strides_from_local_points
  • Array::for_each

Extents and Points seem to be covered by ilattice, but what about strides? It seems like I might need ndshape-rs. And do these new libraries work with WebAssembly (Never used that before, but I'm intending to) ?

I have code like this. I don't suppose there are drop-in replacements for something like this? (Note: I'm not asking you to rewrite the code for me, I'm just putting it here so that you could give me some pointers):

        let offsets = Local::localize_points_array(&Point3i::MOORE_OFFSETS);
        let mut neighbor_strides = [Stride(0); Point3i::MOORE_OFFSETS.len()];
        self.array.strides_from_local_points(&offsets, &mut neighbor_strides);

        let mut make_surfaces = Vec::new();

        let iter_ext = Extent3i::from_min_and_max(Point3i::fill(1), arr_ext.max() - Point3i::fill(1));

        self.array.for_each(&iter_ext, |stride: Stride, value| {
            if value != NON_EMPTY {
                return;
            }

            for offset in neighbor_strides.iter() {
                let adjacent_value = self.array.get(stride + *offset);
                if adjacent_value == OUTSIDE {
                    make_surfaces.push(stride);
                    return;
                }
            }
        });

        for stride in make_surfaces {
            let val = self.array.get_mut(stride);
            *val = SURFACE;
        }

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions