# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from digitaleye_msgs/Block.msg. Do not edit."""
import codecs
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct

import digitaleye_msgs.msg

class Block(genpy.Message):
  _md5sum = "47206f681db2029f782bdc617f1644c7"
  _type = "digitaleye_msgs/Block"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# Block definition

# unique id
uint32 id

# linked ids
uint32[] link_ids

# Volume definition
digitaleye_msgs/Volume volume

# category of allocations allowed, use BLOCK_CAT_ in ConstantsAllocations
uint32[] allowed_categories

================================================================================
MSG: digitaleye_msgs/Volume
# Volume definition

# Volume shape, use SHAPE_
uint32 shape

uint32 SHAPE_PRISM=1
uint32 SHAPE_SPHERE=2
uint32 SHAPE_CYLINDER=3

# Dimensions of volume
float64[] dimensions

# Prism: dimension is 1 + 2*PRISM_POINTS*PRISM_DIM_POINTS_SIZE
# (1 for number of points, and number of points * number of coordinates per point  * 2 for top and bottom)
# same number of points (PRISM_POINTS) for bottom and top polygon, points counter clockwise
uint32 PRISM_POINTS=0
uint32 PRISM_X=1
uint32 PRISM_Y=2
uint32 PRISM_Z=3
uint32 PRISM_DIM_POINTS_SIZE=3

# sphere: radius, centre point (x,y,z)
uint32 SPHERE_RADIUS=0
uint32 SPHERE_CENTRE_X=1
uint32 SPHERE_CENTRE_Y=2
uint32 SPHERE_CENTRE_Z=3
uint32 SPHERE_DIM_SIZE=4

# cylinder: duplicate for bottom and top: centre point (x,y,z), radius, end: spherical/flat (use END_)
uint32 CYLINDER_BOT_X=0
uint32 CYLINDER_BOT_Y=1
uint32 CYLINDER_BOT_Z=2
uint32 CYLINDER_BOT_RADIUS=3
uint32 CYLINDER_BOT_END=4
uint32 CYLINDER_TOP_X=5
uint32 CYLINDER_TOP_Y=6
uint32 CYLINDER_TOP_Z=7
uint32 CYLINDER_TOP_RADIUS=8
uint32 CYLINDER_TOP_END=9
uint32 CYLINDER_DIM_SIZE=10

# end of volume, spherical or flat
uint32 END_SPHERE=1
uint32 END_FLAT=2
"""
  __slots__ = ['id','link_ids','volume','allowed_categories']
  _slot_types = ['uint32','uint32[]','digitaleye_msgs/Volume','uint32[]']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.

    The available fields are:
       id,link_ids,volume,allowed_categories

    :param args: complete set of field values, in .msg order
    :param kwds: use keyword arguments corresponding to message field names
    to set specific fields.
    """
    if args or kwds:
      super(Block, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.id is None:
        self.id = 0
      if self.link_ids is None:
        self.link_ids = []
      if self.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      if self.allowed_categories is None:
        self.allowed_categories = []
    else:
      self.id = 0
      self.link_ids = []
      self.volume = digitaleye_msgs.msg.Volume()
      self.allowed_categories = []

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      _x = self.id
      buff.write(_get_struct_I().pack(_x))
      length = len(self.link_ids)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(struct.Struct(pattern).pack(*self.link_ids))
      _x = self.volume.shape
      buff.write(_get_struct_I().pack(_x))
      length = len(self.volume.dimensions)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(struct.Struct(pattern).pack(*self.volume.dimensions))
      length = len(self.allowed_categories)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(struct.Struct(pattern).pack(*self.allowed_categories))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    :param str: byte array of serialized message, ``str``
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      end = 0
      start = end
      end += 4
      (self.id,) = _get_struct_I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.link_ids = s.unpack(str[start:end])
      start = end
      end += 4
      (self.volume.shape,) = _get_struct_I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sd'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.volume.dimensions = s.unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.allowed_categories = s.unpack(str[start:end])
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    :param buff: buffer, ``StringIO``
    :param numpy: numpy python module
    """
    try:
      _x = self.id
      buff.write(_get_struct_I().pack(_x))
      length = len(self.link_ids)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(self.link_ids.tostring())
      _x = self.volume.shape
      buff.write(_get_struct_I().pack(_x))
      length = len(self.volume.dimensions)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(self.volume.dimensions.tostring())
      length = len(self.allowed_categories)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(self.allowed_categories.tostring())
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    :param str: byte array of serialized message, ``str``
    :param numpy: numpy python module
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      end = 0
      start = end
      end += 4
      (self.id,) = _get_struct_I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.link_ids = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
      start = end
      end += 4
      (self.volume.shape,) = _get_struct_I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sd'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.volume.dimensions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.allowed_categories = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill

_struct_I = genpy.struct_I
def _get_struct_I():
    global _struct_I
    return _struct_I
