# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A primitive representing a set of triangles or a surface tiled by triangles
class TriangleListPrimitive(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = TriangleListPrimitive()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsTriangleListPrimitive(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # TriangleListPrimitive
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Origin of triangles relative to reference frame
    # TriangleListPrimitive
    def Pose(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Pose import Pose
            obj = Pose()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Vertices to use for triangles, interpreted as a list of triples (0-1-2, 3-4-5, ...)
    # TriangleListPrimitive
    def Points(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from .Point3 import Point3
            obj = Point3()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # TriangleListPrimitive
    def PointsLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TriangleListPrimitive
    def PointsIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # Solid color to use for the whole shape. One of `color` or `colors` must be provided.
    # TriangleListPrimitive
    def Color(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Color import Color
            obj = Color()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Per-vertex colors (if specified, must have the same length as `points`). One of `color` or `colors` must be provided.
    # TriangleListPrimitive
    def Colors(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from .Color import Color
            obj = Color()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # TriangleListPrimitive
    def ColorsLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TriangleListPrimitive
    def ColorsIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0

    # Indices into the `points` and `colors` attribute arrays, which can be used to avoid duplicating attribute data.
    # 
    # If omitted or empty, indexing will not be used. This default behavior is equivalent to specifying [0, 1, ..., N-1] for the indices (where N is the number of `points` provided).
    # TriangleListPrimitive
    def Indices(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return 0

    # TriangleListPrimitive
    def IndicesAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o)
        return 0

    # TriangleListPrimitive
    def IndicesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TriangleListPrimitive
    def IndicesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        return o == 0

def TriangleListPrimitiveStart(builder): builder.StartObject(5)
def Start(builder):
    return TriangleListPrimitiveStart(builder)
def TriangleListPrimitiveAddPose(builder, pose): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pose), 0)
def AddPose(builder, pose):
    return TriangleListPrimitiveAddPose(builder, pose)
def TriangleListPrimitiveAddPoints(builder, points): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(points), 0)
def AddPoints(builder, points):
    return TriangleListPrimitiveAddPoints(builder, points)
def TriangleListPrimitiveStartPointsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartPointsVector(builder, numElems):
    return TriangleListPrimitiveStartPointsVector(builder, numElems)
def TriangleListPrimitiveAddColor(builder, color): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(color), 0)
def AddColor(builder, color):
    return TriangleListPrimitiveAddColor(builder, color)
def TriangleListPrimitiveAddColors(builder, colors): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(colors), 0)
def AddColors(builder, colors):
    return TriangleListPrimitiveAddColors(builder, colors)
def TriangleListPrimitiveStartColorsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartColorsVector(builder, numElems):
    return TriangleListPrimitiveStartColorsVector(builder, numElems)
def TriangleListPrimitiveAddIndices(builder, indices): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(indices), 0)
def AddIndices(builder, indices):
    return TriangleListPrimitiveAddIndices(builder, indices)
def TriangleListPrimitiveStartIndicesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartIndicesVector(builder, numElems):
    return TriangleListPrimitiveStartIndicesVector(builder, numElems)
def TriangleListPrimitiveEnd(builder): return builder.EndObject()
def End(builder):
    return TriangleListPrimitiveEnd(builder)