示例#1
0
文件: roi.go 项目: tartavull/dvid
// ImmutableBySpec returns an Immutable ROI (or nil if not available) given
// a name and uuid using string format "<roiname>,<uuid>"
func ImmutableBySpec(spec string) (*Immutable, error) {
	d, v, found, err := DataBySpec(spec)
	if err != nil {
		return nil, err
	}
	if !found {
		return nil, nil
	}

	// Read the ROI from this version.
	spans, err := d.GetSpans(v)
	if err != nil {
		return nil, err
	}

	// Setup the immutable.
	im := Immutable{
		version:   v,
		blockSize: d.BlockSize,
		blocks:    make(map[dvid.IZYXString]struct{}),
	}
	for _, span := range spans {
		z, y, x0, x1 := span[0], span[1], span[2], span[3]
		for x := x0; x <= x1; x++ {
			c := dvid.ChunkPoint3d{x, y, z}
			izyx := c.ToIZYXString()
			im.blocks[izyx] = struct{}{}
		}
	}
	return &im, nil
}