// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Utils/R3Segmentation.cpp
// Function: gaps::R3Segmentation::UpdatePoints()
int R3Segmentation::
UpdatePoints(void)
{
  // Update normal, tangent, radii, and area from neighbors
  for (int i = 0; i < points.NEntries(); i++) {
    R3SegmentationPoint *point = points.Kth(i);
    if (point->neighbors.NEntries() < 2) continue;
    if (!point->normal.IsZero() && !point->tangent.IsZero() &&
        (point->radius1 > 0) && (point->radius2 > 0)) continue;

    // Create array of neighborhood positions
    RNArray<R3Point *> positions;
    positions.Insert(&point->position);
    for (int j = 0; j < point->neighbors.NEntries(); j++) {
      positions.Insert(&point->neighbors[j]->position);
    }

    // Compute principle axes
    RNScalar variances[3];
    R3Point centroid = R3Centroid(positions);
    R3Triad axes = R3PrincipleAxes(centroid, positions, NULL, variances);
    if (RNIsZero(variances[1])) continue;

    // Update point
    point->normal = axes[2];
    point->tangent = axes[0];
    point->radius1 = sqrt(variances[0]);
    point->radius2 = sqrt(variances[1]);
    point->area = point->radius1 * point->radius2;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
xorl %ebp, %ebp
leaq 0x28(%rsp), %r15
leaq 0x80(%rsp), %rbx
movslq 0xc(%rdi), %rax
cmpq %rax, %rbp
jge 0x2a9de
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax,%rbp,8), %r13
cmpl $0x2, 0xbc(%r13)
jl 0x2a9d3
leaq 0x20(%r13), %rdi
movq %rdi, 0x8(%rsp)
callq 0x2c3fe
testl %eax, %eax
jne 0x2a8d4
leaq 0x38(%r13), %rdi
callq 0x2c3fe
testl %eax, %eax
jne 0x2a8d4
movsd 0x50(%r13), %xmm0
ucomisd 0xc378a(%rip), %xmm0    # 0xee048
jbe 0x2a8d4
movsd 0x58(%r13), %xmm0
ucomisd 0xc377a(%rip), %xmm0    # 0xee048
ja 0x2a9d3
movq %r15, %rdi
callq 0xb1eda
leaq 0x8(%r13), %rsi
movq %r15, %rdi
callq 0x1a04c
xorl %r12d, %r12d
movslq 0xbc(%r13), %rax
cmpq %rax, %r12
jge 0x2a913
movq 0xb0(%r13), %rax
movq (%rax,%r12,8), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x1a04c
incq %r12
jmp 0x2a8eb
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x63717
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
leaq 0x10(%rsp), %r8
callq 0x637bf
movsd 0x18(%rsp), %xmm0
leaq 0x131424(%rip), %rax    # 0x15bd68
movsd (%rax), %xmm1
movapd %xmm1, %xmm2
xorpd 0xc3b3c(%rip), %xmm2    # 0xee490
ucomisd %xmm2, %xmm0
jb 0x2a960
ucomisd %xmm0, %xmm1
jae 0x2a9cb
movq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x910c0
leaq 0x38(%r13), %rdi
leaq 0x38(%rsp), %rsi
callq 0x910c0
movsd 0x10(%rsp), %xmm0
ucomisd 0xc36bd(%rip), %xmm0    # 0xee048
jb 0x2a993
sqrtsd %xmm0, %xmm0
jmp 0x2a998
callq 0x154d0
movsd %xmm0, 0x50(%r13)
movsd 0x18(%rsp), %xmm0
ucomisd 0xc369c(%rip), %xmm0    # 0xee048
jb 0x2a9b4
sqrtsd %xmm0, %xmm0
jmp 0x2a9b9
callq 0x154d0
movsd %xmm0, 0x58(%r13)
mulsd 0x50(%r13), %xmm0
movsd %xmm0, 0x70(%r13)
movq %r15, %rdi
callq 0xb1f48
incq %rbp
movq %r14, %rdi
jmp 0x2a86c
pushq $0x1
popq %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a9f9
jmp 0x2a9f9
jmp 0x2a9f9
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xb1f48
movq %rbx, %rdi
callq 0x15af0