当前位置: 首页>>代码示例>>Golang>>正文


Golang Point3d.Expand2d方法代码示例

本文整理汇总了Golang中github.com/janelia-flyem/dvid/dvid.Point3d.Expand2d方法的典型用法代码示例。如果您正苦于以下问题:Golang Point3d.Expand2d方法的具体用法?Golang Point3d.Expand2d怎么用?Golang Point3d.Expand2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/janelia-flyem/dvid/dvid.Point3d的用法示例。


在下文中一共展示了Point3d.Expand2d方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetGoogleSpec

// GetGoogleSpec returns a google-specific tile spec, which includes how the tile is positioned relative to
// scaled volume boundaries.  Not that the size parameter is the desired size and not what is required to fit
// within a scaled volume.
func (d *Data) GetGoogleSpec(scaling Scaling, plane dvid.DataShape, offset dvid.Point3d, size dvid.Point2d) (*GoogleTileSpec, error) {
	tile := new(GoogleTileSpec)
	tile.offset = offset

	// Convert combination of plane and size into 3d size.
	sizeWant, err := dvid.GetPoint3dFrom2d(plane, size, 1)
	if err != nil {
		return nil, err
	}
	tile.sizeWant = sizeWant

	// Determine which geometry is appropriate given the scaling and the shape/orientation
	tileSpec, err := GetTileSpec(scaling, plane)
	if err != nil {
		return nil, err
	}
	geomIndex, found := d.TileMap[*tileSpec]
	if !found {
		return nil, fmt.Errorf("Could not find scaled volume in %q for %s with scaling %d", d.DataName(), plane, scaling)
	}
	geom := d.Scales[geomIndex]
	tile.gi = geomIndex
	tile.channelCount = geom.ChannelCount
	tile.channelType = geom.ChannelType

	// Get the # bytes for each pixel
	switch geom.ChannelType {
	case "uint8":
		tile.bytesPerVoxel = 1
	case "float":
		tile.bytesPerVoxel = 4
	case "uint64":
		tile.bytesPerVoxel = 8
	default:
		return nil, fmt.Errorf("Unknown volume channel type in %s: %s", d.DataName(), geom.ChannelType)
	}

	// Check if the tile is completely outside the volume.
	volumeSize := geom.VolumeSize
	if offset[0] >= volumeSize[0] || offset[1] >= volumeSize[1] || offset[2] >= volumeSize[2] {
		tile.outside = true
		return tile, nil
	}

	// Check if the tile is on the edge and adjust size.
	var adjSize dvid.Point3d = sizeWant
	maxpt, err := offset.Expand2d(plane, size)
	for i := 0; i < 3; i++ {
		if maxpt[i] > volumeSize[i] {
			tile.edge = true
			adjSize[i] = volumeSize[i] - offset[i]
		}
	}
	tile.size = adjSize

	return tile, nil
}
开发者ID:hanslovsky,项目名称:dvid,代码行数:60,代码来源:googlevoxels.go


注:本文中的github.com/janelia-flyem/dvid/dvid.Point3d.Expand2d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。