pytorch3d.renderer.mesh.utils

utils

class pytorch3d.renderer.mesh.utils.Rectangle(xsize, ysize, identifier)[source]

Bases: NamedTuple

xsize: int

Alias for field number 0

ysize: int

Alias for field number 1

identifier: int

Alias for field number 2

class pytorch3d.renderer.mesh.utils.PackedRectangle(x, y, flipped, is_first)[source]

Bases: NamedTuple

x: int

Alias for field number 0

y: int

Alias for field number 1

flipped: bool

Alias for field number 2

is_first: bool

Alias for field number 3

class pytorch3d.renderer.mesh.utils.PackedRectangles(total_size, locations)[source]

Bases: NamedTuple

total_size: Tuple[int, int]

Alias for field number 0

locations: List[PackedRectangle]

Alias for field number 1

pytorch3d.renderer.mesh.utils.pack_rectangles(sizes: List[Tuple[int, int]]) PackedRectangles[source]

Naive rectangle packing in to a large rectangle. Flipping (i.e. rotating a rectangle by 90 degrees) is allowed.

This is used to join several uv maps into a single scene, see TexturesUV.join_scene.

Parameters:

sizes – List of sizes of rectangles to pack

Returns:

total_size – size of total large rectangle rectangles: location for each of the input rectangles.

This includes whether they are flipped. The is_first field is always True.

pytorch3d.renderer.mesh.utils.pack_unique_rectangles(rectangles: List[Rectangle]) PackedRectangles[source]

Naive rectangle packing in to a large rectangle. Flipping (i.e. rotating a rectangle by 90 degrees) is allowed. Inputs are deduplicated by their identifier.

This is a wrapper around pack_rectangles, where inputs come with an identifier. In particular, it calls pack_rectangles for the deduplicated inputs, then returns the values for all the inputs. The output for all rectangles with the same identifier will be the same, except that only the first one will have the is_first field True.

This is used to join several uv maps into a single scene, see TexturesUV.join_scene.

Parameters:

rectangles – List of sizes of rectangles to pack

Returns:

total_size – size of total large rectangle rectangles: location for each of the input rectangles.

This includes whether they are flipped. The is_first field is true for the first rectangle with each identifier.