"""Support for simplified access to data on nodes of type omni.kit.procedural.mesh.CreateMeshCapsule

If necessary, create a new mesh representing a capsule
"""

import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
import numpy
class OgnProceduralMeshCapsuleDatabase(og.Database):
    """Helper class providing simplified access to data on nodes of type omni.kit.procedural.mesh.CreateMeshCapsule

    Class Members:
        node: Node being evaluated

    Attribute Value Properties:
        Inputs:
            inputs.diameter
            inputs.hemisphereLatitudeResolution
            inputs.longitudeResolution
            inputs.middleLatitudeResolution
            inputs.parameterCheck
            inputs.yLength
        Outputs:
            outputs.extent
            outputs.faceVertexCounts
            outputs.faceVertexIndices
            outputs.parameterCheck
            outputs.points
            outputs.stIndices
            outputs.sts
    """
    # This is an internal object that provides per-class storage of a per-node data dictionary
    PER_NODE_DATA = {}
    # This is an internal object that describes unchanging attributes in a generic way
    # The values in this list are in no particular order, as a per-attribute tuple
    #     Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
    #     Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
    # You should not need to access any of this data directly, use the defined database interfaces
    INTERFACE = og.Database._get_interface([
        ('inputs:diameter', 'float', 0, None, 'Capsule diameter', {ogn.MetadataKeys.DEFAULT: '100'}, True, 100, False, ''),
        ('inputs:hemisphereLatitudeResolution', 'int', 0, None, 'Capsule Resolution', {ogn.MetadataKeys.DEFAULT: '10'}, True, 10, False, ''),
        ('inputs:longitudeResolution', 'int', 0, None, 'Capsule Resolution', {ogn.MetadataKeys.DEFAULT: '10'}, True, 10, False, ''),
        ('inputs:middleLatitudeResolution', 'int', 0, None, 'Capsule Resolution', {ogn.MetadataKeys.DEFAULT: '10'}, True, 10, False, ''),
        ('inputs:parameterCheck', 'int', 0, None, 'Previous crc value', {ogn.MetadataKeys.DEFAULT: '-1'}, True, -1, False, ''),
        ('inputs:yLength', 'float', 0, None, 'Capsule y extent', {ogn.MetadataKeys.DEFAULT: '200'}, True, 200, False, ''),
        ('outputs:extent', 'float3[]', 0, None, 'Extent of the mesh', {}, True, None, False, ''),
        ('outputs:faceVertexCounts', 'int[]', 0, None, 'Vertex count of faces', {}, True, None, False, ''),
        ('outputs:faceVertexIndices', 'int[]', 0, None, 'Vertex indices of faces', {}, True, None, False, ''),
        ('outputs:parameterCheck', 'int', 0, None, 'Current crc value', {}, True, None, False, ''),
        ('outputs:points', 'float3[]', 0, None, 'Points', {}, True, None, False, ''),
        ('outputs:stIndices', 'int[]', 0, None, 'Texture coordinate indices of faces', {}, True, None, False, ''),
        ('outputs:sts', 'float2[]', 0, None, 'Texture coordinate of vertices', {}, True, None, False, ''),
    ])
    class ValuesForInputs(og.DynamicAttributeAccess):
        LOCAL_PROPERTY_NAMES = {"diameter", "hemisphereLatitudeResolution", "longitudeResolution", "middleLatitudeResolution", "parameterCheck", "yLength", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
        """Helper class that creates natural hierarchical access to input attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)
            self._batchedReadAttributes = [self._attributes.diameter, self._attributes.hemisphereLatitudeResolution, self._attributes.longitudeResolution, self._attributes.middleLatitudeResolution, self._attributes.parameterCheck, self._attributes.yLength]
            self._batchedReadValues = [100, 10, 10, 10, -1, 200]

        @property
        def diameter(self):
            return self._batchedReadValues[0]

        @diameter.setter
        def diameter(self, value):
            self._batchedReadValues[0] = value

        @property
        def hemisphereLatitudeResolution(self):
            return self._batchedReadValues[1]

        @hemisphereLatitudeResolution.setter
        def hemisphereLatitudeResolution(self, value):
            self._batchedReadValues[1] = value

        @property
        def longitudeResolution(self):
            return self._batchedReadValues[2]

        @longitudeResolution.setter
        def longitudeResolution(self, value):
            self._batchedReadValues[2] = value

        @property
        def middleLatitudeResolution(self):
            return self._batchedReadValues[3]

        @middleLatitudeResolution.setter
        def middleLatitudeResolution(self, value):
            self._batchedReadValues[3] = value

        @property
        def parameterCheck(self):
            return self._batchedReadValues[4]

        @parameterCheck.setter
        def parameterCheck(self, value):
            self._batchedReadValues[4] = value

        @property
        def yLength(self):
            return self._batchedReadValues[5]

        @yLength.setter
        def yLength(self, value):
            self._batchedReadValues[5] = value

        def __getattr__(self, item: str):
            if item in self.LOCAL_PROPERTY_NAMES:
                return object.__getattribute__(self, item)
            else:
                return super().__getattr__(item)

        def __setattr__(self, item: str, new_value):
            if item in self.LOCAL_PROPERTY_NAMES:
                object.__setattr__(self, item, new_value)
            else:
                super().__setattr__(item, new_value)

        def _prefetch(self):
            readAttributes = self._batchedReadAttributes
            newValues = _og._prefetch_input_attributes_data(readAttributes)
            if len(readAttributes) == len(newValues):
                self._batchedReadValues = newValues
    class ValuesForOutputs(og.DynamicAttributeAccess):
        LOCAL_PROPERTY_NAMES = {"parameterCheck", "_batchedWriteValues"}
        """Helper class that creates natural hierarchical access to output attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)
            self.extent_size = None
            self.faceVertexCounts_size = None
            self.faceVertexIndices_size = None
            self.points_size = None
            self.stIndices_size = None
            self.sts_size = None
            self._batchedWriteValues = { }

        @property
        def extent(self):
            data_view = og.AttributeValueHelper(self._attributes.extent)
            return data_view.get(reserved_element_count=self.extent_size)

        @extent.setter
        def extent(self, value):
            data_view = og.AttributeValueHelper(self._attributes.extent)
            data_view.set(value)
            self.extent_size = data_view.get_array_size()

        @property
        def faceVertexCounts(self):
            data_view = og.AttributeValueHelper(self._attributes.faceVertexCounts)
            return data_view.get(reserved_element_count=self.faceVertexCounts_size)

        @faceVertexCounts.setter
        def faceVertexCounts(self, value):
            data_view = og.AttributeValueHelper(self._attributes.faceVertexCounts)
            data_view.set(value)
            self.faceVertexCounts_size = data_view.get_array_size()

        @property
        def faceVertexIndices(self):
            data_view = og.AttributeValueHelper(self._attributes.faceVertexIndices)
            return data_view.get(reserved_element_count=self.faceVertexIndices_size)

        @faceVertexIndices.setter
        def faceVertexIndices(self, value):
            data_view = og.AttributeValueHelper(self._attributes.faceVertexIndices)
            data_view.set(value)
            self.faceVertexIndices_size = data_view.get_array_size()

        @property
        def points(self):
            data_view = og.AttributeValueHelper(self._attributes.points)
            return data_view.get(reserved_element_count=self.points_size)

        @points.setter
        def points(self, value):
            data_view = og.AttributeValueHelper(self._attributes.points)
            data_view.set(value)
            self.points_size = data_view.get_array_size()

        @property
        def stIndices(self):
            data_view = og.AttributeValueHelper(self._attributes.stIndices)
            return data_view.get(reserved_element_count=self.stIndices_size)

        @stIndices.setter
        def stIndices(self, value):
            data_view = og.AttributeValueHelper(self._attributes.stIndices)
            data_view.set(value)
            self.stIndices_size = data_view.get_array_size()

        @property
        def sts(self):
            data_view = og.AttributeValueHelper(self._attributes.sts)
            return data_view.get(reserved_element_count=self.sts_size)

        @sts.setter
        def sts(self, value):
            data_view = og.AttributeValueHelper(self._attributes.sts)
            data_view.set(value)
            self.sts_size = data_view.get_array_size()

        @property
        def parameterCheck(self):
            value = self._batchedWriteValues.get(self._attributes.parameterCheck)
            if value:
                return value
            else:
                data_view = og.AttributeValueHelper(self._attributes.parameterCheck)
                return data_view.get()

        @parameterCheck.setter
        def parameterCheck(self, value):
            self._batchedWriteValues[self._attributes.parameterCheck] = value

        def __getattr__(self, item: str):
            if item in self.LOCAL_PROPERTY_NAMES:
                return object.__getattribute__(self, item)
            else:
                return super().__getattr__(item)

        def __setattr__(self, item: str, new_value):
            if item in self.LOCAL_PROPERTY_NAMES:
                object.__setattr__(self, item, new_value)
            else:
                super().__setattr__(item, new_value)

        def _commit(self):
            _og._commit_output_attributes_data(self._batchedWriteValues)
            self._batchedWriteValues = { }
    class ValuesForState(og.DynamicAttributeAccess):
        """Helper class that creates natural hierarchical access to state attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)
    def __init__(self, node):
        super().__init__(node)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
        self.inputs = OgnProceduralMeshCapsuleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
        self.outputs = OgnProceduralMeshCapsuleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
        self.state = OgnProceduralMeshCapsuleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
