// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelObjectProperty.cpp
// Function: gaps::R3SurfelObjectProperty::Draw(gaps::RNFlags) const
void R3SurfelObjectProperty::
Draw(RNFlags flags) const
{
  // Draw property based on type
  switch (type) {
  case R3_SURFEL_OBJECT_PCA_PROPERTY: 
    if (noperands == 21) {
      R3Point centroid(operands[0], operands[1], operands[2]);
      R3Vector axis1(operands[3], operands[4], operands[5]);
      R3Vector axis2(operands[6], operands[7], operands[8]);
      R3Vector axis3(operands[9], operands[10], operands[11]);
      RNScalar stddev1 = sqrt(operands[12]);
      RNScalar stddev2 = sqrt(operands[13]);
      RNScalar stddev3 = sqrt(operands[14]);
      RNScalar extent01 = operands[15];
      RNScalar extent02 = operands[16];
      RNScalar extent03 = operands[17];
      RNScalar extent11 = operands[18];
      RNScalar extent12 = operands[19];
      RNScalar extent13 = operands[20];

      // Draw normal
      glLineWidth(5);
      RNGrfxBegin(RN_GRFX_LINES);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(0, 0, 1);
      R3LoadPoint(centroid);
      R3LoadPoint(centroid + extent13*axis3);
      RNGrfxEnd();

      // Draw stddevs
      glLineWidth(2);
      RNGrfxBegin(RN_GRFX_LINES);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(1, 0, 0);
      R3LoadPoint(centroid - stddev1 * axis1);
      R3LoadPoint(centroid + stddev1 * axis1);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(0, 1, 0);
      R3LoadPoint(centroid - stddev2 * axis2);
      R3LoadPoint(centroid + stddev2 * axis2);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(0, 0, 1);
      R3LoadPoint(centroid - stddev3 * axis3);
      R3LoadPoint(centroid + stddev3 * axis3);
      RNGrfxEnd();

      // Draw extents
      glLineWidth(1);
      RNGrfxBegin(RN_GRFX_LINES);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(1, 0, 0);
      R3LoadPoint(centroid + extent01 * axis1);
      R3LoadPoint(centroid + extent11 * axis1);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(0, 1, 0);
      R3LoadPoint(centroid + extent02 * axis2);
      R3LoadPoint(centroid + extent12 * axis2);
      if (flags[R3_SURFEL_COLOR_DRAW_FLAG]) RNLoadRgb(0, 0, 1);
      R3LoadPoint(centroid + extent03 * axis3);
      R3LoadPoint(centroid + extent13 * axis3);
      RNGrfxEnd();
    }
    break; 

  case R3_SURFEL_OBJECT_AMODAL_OBB_PROPERTY: 
    if (noperands == 20) {
      // Parse operands
      R3Point centroid(operands[0], operands[1], operands[2]);
      R3Vector axis1(operands[3], operands[4], operands[5]);
      R3Vector axis2(operands[6], operands[7], operands[8]);
      R3Vector axis3(operands[9], operands[10], operands[11]);
      RNScalar radius1 = operands[12];
      RNScalar radius2 = operands[13];
      RNScalar radius3 = operands[14];
      // RNScalar confidence = operands[15];
      // int originator = (int) (operands[16] + 0.5);

      // Check if should draw nose
      RNBoolean draw_nose = TRUE;
      R3SurfelLabel *label = (object) ? object->CurrentLabel() : NULL;
      if (label && label->Flags()[R3_SURFEL_LABEL_UNORIENTABLE_FLAG]) draw_nose = FALSE;

      // Draw obb
      R3OrientedBox obb(centroid, axis1, axis2, radius1, radius2, radius3);
      obb.Outline();

      // Draw nose
      if (draw_nose) {
        double min_nose_vector_length = 0.5;
        double nose_vector_length = 0.25 * radius1;
        if (nose_vector_length < min_nose_vector_length)
          nose_vector_length = min_nose_vector_length;
        R3Point start = centroid + radius1 * axis1;
        R3Point end = start + nose_vector_length * axis1;
        R3Span(start, end).Draw();
      }
    }
    break; 
  }
}

// Assembly:
subq $0x578, %rsp            # imm = 0x578
movq %rsi, 0x570(%rsp)
movq %rdi, 0x568(%rsp)
movq 0x568(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x2c(%rax), %eax
movl %eax, 0x24(%rsp)
subl $0x1, %eax
je 0x6ee94
jmp 0x6ee82
movl 0x24(%rsp), %eax
subl $0x2, %eax
je 0x6f5ce
jmp 0x6f91b
movq 0x18(%rsp), %rax
cmpl $0x15, 0x28(%rax)
jne 0x6f5c9
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd (%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x8(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x10(%rax), %xmm2
leaq 0x550(%rsp), %rdi
callq 0xf8350
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x18(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x20(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x28(%rax), %xmm2
leaq 0x538(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x30(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x38(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x40(%rax), %xmm2
leaq 0x520(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x48(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x50(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x58(%rax), %xmm2
leaq 0x508(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movsd 0x60(%rax), %xmm0
callq 0x13420
movq 0x18(%rsp), %rax
movsd %xmm0, 0x500(%rsp)
movq 0x20(%rax), %rax
movsd 0x68(%rax), %xmm0
callq 0x13420
movq 0x18(%rsp), %rax
movsd %xmm0, 0x4f8(%rsp)
movq 0x20(%rax), %rax
movsd 0x70(%rax), %xmm0
callq 0x13420
movq 0x18(%rsp), %rax
movsd %xmm0, 0x4f0(%rsp)
movq 0x20(%rax), %rcx
movsd 0x78(%rcx), %xmm0
movsd %xmm0, 0x4e8(%rsp)
movq 0x20(%rax), %rcx
movsd 0x80(%rcx), %xmm0
movsd %xmm0, 0x4e0(%rsp)
movq 0x20(%rax), %rcx
movsd 0x88(%rcx), %xmm0
movsd %xmm0, 0x4d8(%rsp)
movq 0x20(%rax), %rcx
movsd 0x90(%rcx), %xmm0
movsd %xmm0, 0x4d0(%rsp)
movq 0x20(%rax), %rcx
movsd 0x98(%rcx), %xmm0
movsd %xmm0, 0x4c8(%rsp)
movq 0x20(%rax), %rax
movsd 0xa0(%rax), %xmm0
movsd %xmm0, 0x4c0(%rsp)
movss 0x136966(%rip), %xmm0   # 0x1a5998
callq 0x139d0
movl $0x1, %edi
callq 0x4ff50
leaq 0x4b8(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x4b8(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f07b
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x6f930
leaq 0x550(%rsp), %rdi
callq 0x50050
movsd 0x4c0(%rsp), %xmm0
leaq 0x488(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x31980
leaq 0x4a0(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x488(%rsp), %rdx
callq 0xf8910
leaq 0x4a0(%rsp), %rdi
callq 0x50050
callq 0x50070
movss 0x1368bf(%rip), %xmm0   # 0x1a599c
callq 0x139d0
movl $0x1, %edi
callq 0x4ff50
leaq 0x480(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x480(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f126
movl $0x1, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x6f930
movsd 0x500(%rsp), %xmm0
leaq 0x450(%rsp), %rdi
leaq 0x538(%rsp), %rsi
callq 0x31980
leaq 0x468(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x450(%rsp), %rdx
callq 0xf92b0
leaq 0x468(%rsp), %rdi
callq 0x50050
movsd 0x500(%rsp), %xmm0
leaq 0x420(%rsp), %rdi
leaq 0x538(%rsp), %rsi
callq 0x31980
leaq 0x438(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x420(%rsp), %rdx
callq 0xf8910
leaq 0x438(%rsp), %rdi
callq 0x50050
leaq 0x418(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x418(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f1f0
xorl %edx, %edx
movl $0x1, %esi
movl %edx, %edi
callq 0x6f930
movsd 0x4f8(%rsp), %xmm0
leaq 0x3e8(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x31980
leaq 0x400(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x3e8(%rsp), %rdx
callq 0xf92b0
leaq 0x400(%rsp), %rdi
callq 0x50050
movsd 0x4f8(%rsp), %xmm0
leaq 0x3b8(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x31980
leaq 0x3d0(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x3b8(%rsp), %rdx
callq 0xf8910
leaq 0x3d0(%rsp), %rdi
callq 0x50050
leaq 0x3b0(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x3b0(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f2ba
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x6f930
movsd 0x4f0(%rsp), %xmm0
leaq 0x380(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x31980
leaq 0x398(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x380(%rsp), %rdx
callq 0xf92b0
leaq 0x398(%rsp), %rdi
callq 0x50050
movsd 0x4f0(%rsp), %xmm0
leaq 0x350(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x31980
leaq 0x368(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x350(%rsp), %rdx
callq 0xf8910
leaq 0x368(%rsp), %rdi
callq 0x50050
callq 0x50070
movss 0x136649(%rip), %xmm0   # 0x1a59a0
callq 0x139d0
movl $0x1, %edi
callq 0x4ff50
leaq 0x348(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x348(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f3a0
movl $0x1, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x6f930
movsd 0x4e8(%rsp), %xmm0
leaq 0x318(%rsp), %rdi
leaq 0x538(%rsp), %rsi
callq 0x31980
leaq 0x330(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x318(%rsp), %rdx
callq 0xf8910
leaq 0x330(%rsp), %rdi
callq 0x50050
movsd 0x4d0(%rsp), %xmm0
leaq 0x2e8(%rsp), %rdi
leaq 0x538(%rsp), %rsi
callq 0x31980
leaq 0x300(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x2e8(%rsp), %rdx
callq 0xf8910
leaq 0x300(%rsp), %rdi
callq 0x50050
leaq 0x2e0(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x2e0(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f46a
xorl %edx, %edx
movl $0x1, %esi
movl %edx, %edi
callq 0x6f930
movsd 0x4e0(%rsp), %xmm0
leaq 0x2b0(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x31980
leaq 0x2c8(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x2b0(%rsp), %rdx
callq 0xf8910
leaq 0x2c8(%rsp), %rdi
callq 0x50050
movsd 0x4c8(%rsp), %xmm0
leaq 0x280(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x31980
leaq 0x298(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x280(%rsp), %rdx
callq 0xf8910
leaq 0x298(%rsp), %rdi
callq 0x50050
leaq 0x278(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x278(%rsp), %rsi
leaq 0x570(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
je 0x6f534
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x6f930
movsd 0x4d8(%rsp), %xmm0
leaq 0x248(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x31980
leaq 0x260(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x248(%rsp), %rdx
callq 0xf8910
leaq 0x260(%rsp), %rdi
callq 0x50050
movsd 0x4c0(%rsp), %xmm0
leaq 0x218(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x31980
leaq 0x230(%rsp), %rdi
leaq 0x550(%rsp), %rsi
leaq 0x218(%rsp), %rdx
callq 0xf8910
leaq 0x230(%rsp), %rdi
callq 0x50050
callq 0x50070
jmp 0x6f91b
movq 0x18(%rsp), %rax
cmpl $0x14, 0x28(%rax)
jne 0x6f919
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd (%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x8(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x10(%rax), %xmm2
leaq 0x200(%rsp), %rdi
callq 0xf8350
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x18(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x20(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x28(%rax), %xmm2
leaq 0x1e8(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x30(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x38(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x40(%rax), %xmm2
leaq 0x1d0(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x48(%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd 0x50(%rcx), %xmm1
movq 0x20(%rax), %rax
movsd 0x58(%rax), %xmm2
leaq 0x1b8(%rsp), %rdi
callq 0xf94b0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movsd 0x60(%rcx), %xmm0
movsd %xmm0, 0x1b0(%rsp)
movq 0x20(%rax), %rcx
movsd 0x68(%rcx), %xmm0
movsd %xmm0, 0x1a8(%rsp)
movq 0x20(%rax), %rcx
movsd 0x70(%rcx), %xmm0
movsd %xmm0, 0x1a0(%rsp)
movl $0x1, 0x19c(%rsp)
cmpq $0x0, 0x18(%rax)
je 0x6f6f2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1a020
movq %rax, 0x10(%rsp)
jmp 0x6f6fb
xorl %eax, %eax
movq %rax, 0x10(%rsp)
jmp 0x6f6fb
movq 0x10(%rsp), %rax
movq %rax, 0x190(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x190(%rsp)
movb %al, 0xf(%rsp)
je 0x6f75f
movq 0x190(%rsp), %rdi
callq 0x31320
movq %rax, 0x188(%rsp)
leaq 0x180(%rsp), %rdi
movl $0x2, %esi
callq 0x1b970
movq 0x180(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0x31a20
cmpl $0x0, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x6f769
jmp 0x6f774
movl $0x0, 0x19c(%rsp)
movsd 0x1b0(%rsp), %xmm0
movsd 0x1a8(%rsp), %xmm1
movsd 0x1a0(%rsp), %xmm2
leaq 0x100(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
leaq 0x1d0(%rsp), %rcx
callq 0xc7b10
leaq 0xf8(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
jmp 0x6f7c8
movq 0xf8(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0xccf40
jmp 0x6f7df
cmpl $0x0, 0x19c(%rsp)
je 0x6f90c
movsd 0x134963(%rip), %xmm0   # 0x1a4158
movsd %xmm0, 0xe0(%rsp)
movsd 0x1352ca(%rip), %xmm0   # 0x1a4ad0
mulsd 0x1b0(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movsd 0xd8(%rsp), %xmm1
movsd 0xe0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6f86a
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
jmp 0x6f86a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x1bd00
jmp 0x6f923
movsd 0x1b0(%rsp), %xmm0
leaq 0xa8(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x31980
jmp 0x6f88a
leaq 0xc0(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0xf8910
jmp 0x6f8a9
movsd 0xd8(%rsp), %xmm0
leaq 0x78(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x31980
jmp 0x6f8c6
leaq 0x90(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0xf8910
jmp 0x6f8e2
leaq 0x28(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0xf6d80
jmp 0x6f8fe
leaq 0x28(%rsp), %rdi
callq 0x76a70
jmp 0x6f90a
jmp 0x6f90c
leaq 0x100(%rsp), %rdi
callq 0x1bd00
jmp 0x6f91b
addq $0x578, %rsp            # imm = 0x578
retq
movq 0xf0(%rsp), %rdi
callq 0x13970