// File: tomfunkhouser[P]gaps/apps/confview/confview.cpp
// Function: DrawOverlaps(int)
static void
DrawOverlaps(int color_scheme = RGBD_INDEX_COLOR_SCHEME)
{
  // Draw vertex image overlaps
  if (vertex_image_overlaps) {
    if (configuration.NSurfaces() > 0) {
      // Find vertex closest to center
      RGBDSurface *surface = configuration.Surface(0);
      R3Mesh *mesh = surface->mesh;
      RNScalar closest_dd = 0.05;
      R3MeshVertex *closest_vertex = NULL;
      for (int i = 0; i < mesh->NVertices(); i++) {
        R3MeshVertex *vertex = mesh->Vertex(i);
        const R3Point& position = mesh->VertexPosition(vertex);
        RNScalar dd = R3SquaredDistance(position, center);
        if (dd < closest_dd) {
          closest_vertex = vertex;
          closest_dd = dd;
        }
      }

      // Draw vertex image overlaps for closest vertex
      if (closest_vertex) {
        glLineWidth(3);
        RNLoadRgb(1, 0, 0);
        RNGrfxBegin(RN_GRFX_LINES);
        int closest_id = mesh->VertexID(closest_vertex);
        const R3Point& position = mesh->VertexPosition(closest_vertex);
        for (int j = 0; j < vertex_image_overlaps[closest_id].NEntries(); j++) {
          RGBDImage *image = vertex_image_overlaps[closest_id][j];
          R3LoadPoint(image->WorldViewpoint());
          R3LoadPoint(position);
        }
        RNGrfxEnd();
        glLineWidth(1);
      }
    }
  }

  // Draw image vertex overlaps
  if (0 && image_vertex_overlaps && (selected_image_index >= 0)) {
    if (configuration.NSurfaces() > 0) {
      glPointSize(3);
      RNGrfxBegin(RN_GRFX_POINTS);
      RGBDSurface *surface = configuration.Surface(0);
      R3Mesh *mesh = surface->mesh;
      for (int j = 0; j < image_vertex_overlaps[selected_image_index].NEntries(); j++) {
        R3MeshVertex *vertex = image_vertex_overlaps[selected_image_index][j];
        R3LoadPoint(mesh->VertexPosition(vertex));
      }
      RNGrfxEnd();
      glPointSize(1);
    }
  }

  // Draw image image overlaps
  if (0 && image_image_overlaps && (selected_image_index >= 0)) {
    glLineWidth(3);
    for (int i = 0; i < image_image_overlaps->YResolution(); i++) {
      RNScalar value = image_image_overlaps->GridValue(selected_image_index, i);
      RGBDImage *image = configuration.Image(i);
      glLineWidth((value < 0.4) ? 20*value : 5);
      RNLoadRgb(5*value, 0.25 - value, 0.25 - value);
      image->DrawCamera(RGBD_NO_COLOR_SCHEME);
    }
    glLineWidth(1);
 }
}

// Assembly:
subq $0x88, %rsp
movl %edi, 0x84(%rsp)
cmpq $0x0, 0x211faa(%rip)    # 0x23be80
je 0x2a0ba
leaq 0x211cfd(%rip), %rdi    # 0x23bbe0
callq 0x2ecd0
cmpl $0x0, %eax
jle 0x2a0b8
leaq 0x211ce8(%rip), %rdi    # 0x23bbe0
xorl %esi, %esi
callq 0x2f050
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, 0x70(%rsp)
movsd 0x19d11b(%rip), %xmm0   # 0x1c7038
movsd %xmm0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x70(%rsp), %rdi
callq 0x2f0a0
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jge 0x29fc8
movq 0x70(%rsp), %rdi
movl 0x5c(%rsp), %esi
callq 0x2f0c0
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x2f0f0
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x211d45(%rip), %rsi    # 0x23bcc8
callq 0x94a60
movsd %xmm0, 0x40(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x68(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x29fb6
movq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
jmp 0x29fb8
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x29f34
cmpq $0x0, 0x60(%rsp)
je 0x2a0b6
movss 0x19d0c0(%rip), %xmm0   # 0x1c709c
callq 0x25340
movl $0x1, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x2efd0
movl $0x1, %edi
callq 0x2f110
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x2f130
movl %eax, 0x3c(%rsp)
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x2f0f0
movq %rax, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x211e4a(%rip), %rdi    # 0x23be80
movslq 0x3c(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x2ecf0
movl %eax, %ecx
movl (%rsp), %eax
cmpl %ecx, %eax
jge 0x2a0a4
movq 0x211e29(%rip), %rdi    # 0x23be80
movslq 0x3c(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movl 0x2c(%rsp), %esi
callq 0x2f150
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2eaa0
leaq 0x8(%rsp), %rdi
callq 0x2f170
movq 0x30(%rsp), %rdi
callq 0x2f170
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x2a028
callq 0x2f190
movss 0x19cfe7(%rip), %xmm0   # 0x1c7098
callq 0x25340
jmp 0x2a0b8
jmp 0x2a0ba
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)