Example #1
0
func (b Bitmaps) Unpack(res *resource.Container, col *resource.PointerCollection) error {
	for i := 0; i < cap(b); i++ {
		if err := col.Detour(res, i, func() error {
			b[i] = new(Bitmap)
			return b[i].Unpack(res)
		}); err != nil {
			return err
		}
	}
	return nil
}
Example #2
0
func (nodes *Nodes) Unpack(res *resource.Container) error {
	res.Parse(&nodes.NodesHeader)

	var err error

	nodes.Volumes = make([]*Volume, nodes.Capacity)
	volCollection := resource.PointerCollection{
		Addr:     nodes.BoundsTable,
		Count:    nodes.Count,
		Capacity: nodes.Capacity,
	}

	volInfoCollection := resource.Collection{
		Addr:     nodes.VolumeInfo,
		Count:    nodes.Count,
		Capacity: nodes.Capacity,
	}

	err = volInfoCollection.For(res, func(i int) error {
		nodes.Volumes[i] = new(Volume)
		if err := nodes.Volumes[i].VolumeInfo.Unpack(res); err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return err
	}

	err = volCollection.For(res, func(i int) error {
		return nodes.Volumes[i].Unpack(res)
	})
	if err != nil {
		return err
	}

	nodes.Model = export.NewModel()
	for _, vol := range nodes.Volumes {
		nodes.Model.AddMesh(vol.Mesh)
	}

	return nil
}