// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::SetObjectOBBProperty(gaps::R3SurfelObject*, gaps::R3OrientedBox const&, double, int)
int
SetObjectOBBProperty(R3SurfelObject *object,
  const R3OrientedBox& obb, double confidence, int originator)
{
  // Constants for OBB property
  static const int property_type = R3_SURFEL_OBJECT_AMODAL_OBB_PROPERTY;
  static const int noperands = 20;

  // Get/create object property
  R3SurfelObjectProperty *property = object->FindObjectProperty(property_type);
  if (!property) property = CreateObjectProperty(object, property_type);
  if (!property) return 0;

  // Check number of operands
  if (property->NOperands() != noperands) return 0;

  // Fill property operands
  double operands[noperands];
  operands[0] = obb.Center().X();
  operands[1] = obb.Center().Y();
  operands[2] = obb.Center().Z();
  operands[3] = obb.Axis(0).X();
  operands[4] = obb.Axis(0).Y();
  operands[5] = obb.Axis(0).Z();
  operands[6] = obb.Axis(1).X();
  operands[7] = obb.Axis(1).Y();
  operands[8] = obb.Axis(1).Z();
  operands[9] = obb.Axis(2).X();
  operands[10] = obb.Axis(2).Y();
  operands[11] = obb.Axis(2).Z();
  operands[12] = obb.Radius(0);
  operands[13] = obb.Radius(1);
  operands[14] = obb.Radius(2);
  operands[15] = confidence;
  operands[16] = originator;
  operands[17] = 0;
  operands[18] = 0;
  operands[19] = 0;

  // Set property operands
  property->ResetOperands(operands, noperands);
  
  // Return success
  return 1;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movsd %xmm0, 0xb8(%rsp)
movl %edx, 0xb4(%rsp)
movq 0xc8(%rsp), %rdi
movl $0x2, %esi
callq 0x19a40
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x375f6
movq 0xc8(%rsp), %rdi
movl $0x2, %esi
callq 0x37170
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x37611
movl $0x0, 0xd4(%rsp)
jmp 0x37844
movq 0xa8(%rsp), %rdi
callq 0x1bcd0
cmpl $0x14, %eax
je 0x37633
movl $0x0, 0xd4(%rsp)
jmp 0x37844
movq 0xc0(%rsp), %rdi
callq 0x43aa0
movq %rax, %rdi
callq 0x187b0
movsd %xmm0, (%rsp)
movq 0xc0(%rsp), %rdi
callq 0x43aa0
movq %rax, %rdi
callq 0x187c0
movsd %xmm0, 0x8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x43aa0
movq %rax, %rdi
callq 0x187a0
movsd %xmm0, 0x10(%rsp)
movq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c70
movsd %xmm0, 0x18(%rsp)
movq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c80
movsd %xmm0, 0x20(%rsp)
movq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c90
movsd %xmm0, 0x28(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c70
movsd %xmm0, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c80
movsd %xmm0, 0x38(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c90
movsd %xmm0, 0x40(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x2, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c70
movsd %xmm0, 0x48(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x2, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c80
movsd %xmm0, 0x50(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x2, %esi
callq 0x43ac0
movq %rax, %rdi
callq 0x31c90
movsd %xmm0, 0x58(%rsp)
movq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0x1c270
movsd %xmm0, 0x60(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x1c270
movsd %xmm0, 0x68(%rsp)
movq 0xc0(%rsp), %rdi
movl $0x2, %esi
callq 0x1c270
movsd %xmm0, 0x70(%rsp)
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
cvtsi2sdl 0xb4(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x90(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0xa8(%rsp), %rdi
movq %rsp, %rsi
movl $0x14, %edx
callq 0x6ed30
movl $0x1, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)