// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3MeshProperty.cpp
// Function: gaps::R3MeshProperty::Dilate(double)
void R3MeshProperty::
Dilate(RNScalar radius)
{
  // Copy property
  R3MeshProperty copy(*this);
  
  // Clear property
  Clear(0);
 
  // For every vertex with non-zero value
  for (int i = 0; i < mesh->NVertices(); i++) {
    if (copy.VertexValue(i) == 0) continue;
    if (copy.VertexValue(i) == RN_UNKNOWN) continue;
    R3MeshVertex *vertex = mesh->Vertex(i);

    // Find neighborhood of vertex
    RNArray<R3MeshVertex *> neighbor_vertices;
    RNLength *distances = mesh->DijkstraDistances(vertex, radius, neighbor_vertices);
    delete [] distances;

    // Set value of vertices within neighborhood
    for (int j = 0; j < neighbor_vertices.NEntries(); j++) {
      R3MeshVertex *neighbor_vertex = neighbor_vertices.Kth(j);
      if (VertexValue(neighbor_vertex) == RN_UNKNOWN) continue;
      SetVertexValue(neighbor_vertex, 1);
    }
  }

  // Reset statistics
  ResetStatistics();
}

// Assembly:
subq $0x4e8, %rsp            # imm = 0x4E8
movq %rdi, 0x4e0(%rsp)
movsd %xmm0, 0x4d8(%rsp)
movq 0x4e0(%rsp), %rsi
movq %rsi, 0x48(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x6c4c0
movq 0x48(%rsp), %rdi
xorps %xmm0, %xmm0
callq 0x6e1d0
jmp 0x6fa21
movl $0x0, 0x80(%rsp)
movq 0x48(%rsp), %rax
movl 0x80(%rsp), %ecx
movl %ecx, 0x40(%rsp)
movq (%rax), %rdi
callq 0x2abd0
movl %eax, 0x44(%rsp)
jmp 0x6fa4a
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0x6fc43
movl 0x80(%rsp), %esi
leaq 0x90(%rsp), %rdi
callq 0x2b0a0
movsd %xmm0, 0x38(%rsp)
jmp 0x6fa76
movsd 0x38(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x6faa5
jp 0x6faa5
jmp 0x6fc2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x6fc64
movl 0x80(%rsp), %esi
leaq 0x90(%rsp), %rdi
callq 0x2b0a0
movsd %xmm0, 0x30(%rsp)
jmp 0x6fac1
movsd 0x30(%rsp), %xmm0
movsd 0x126551(%rip), %xmm1   # 0x196020
ucomisd %xmm1, %xmm0
jne 0x6fadc
jp 0x6fadc
jmp 0x6fc2d
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movl 0x80(%rsp), %esi
callq 0x2abf0
movq %rax, 0x28(%rsp)
jmp 0x6faf7
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x712b0
jmp 0x6fb0d
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movq 0x78(%rsp), %rsi
movsd 0x4d8(%rsp), %xmm0
xorl %eax, %eax
movl %eax, %ecx
leaq 0x68(%rsp), %rdx
callq 0x9a840
movq %rax, 0x20(%rsp)
jmp 0x6fb38
movq 0x20(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x6fb5c
movq 0x18(%rsp), %rdi
callq 0x22d80
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x2ac70
movl %eax, 0x14(%rsp)
jmp 0x6fb7c
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jge 0x6fc23
movl 0x5c(%rsp), %esi
leaq 0x68(%rsp), %rdi
callq 0x712c0
movq %rax, 0x8(%rsp)
jmp 0x6fba1
movq 0x48(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rsi
callq 0x2b020
movsd %xmm0, (%rsp)
jmp 0x6fbc1
movsd (%rsp), %xmm0
movsd 0x126452(%rip), %xmm1   # 0x196020
ucomisd %xmm1, %xmm0
jne 0x6fbf8
jp 0x6fbf8
jmp 0x6fc13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x712e0
jmp 0x6fc64
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movsd 0x12645e(%rip), %xmm0   # 0x196068
callq 0x6f4b0
jmp 0x6fc11
jmp 0x6fc13
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x6fb64
leaq 0x68(%rsp), %rdi
callq 0x712e0
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x6fa2c
movq 0x48(%rsp), %rdi
callq 0x6c450
jmp 0x6fc4f
leaq 0x90(%rsp), %rdi
callq 0x6c640
addq $0x4e8, %rsp            # imm = 0x4E8
retq
leaq 0x90(%rsp), %rdi
callq 0x6c640
movq 0x88(%rsp), %rdi
callq 0x23270
nop