// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::Transform(gaps::R3Affine const&, int)
void R3SurfelScene::
Transform(const R3Affine& transformation, RNBoolean update_surfels)
{
  // Check if should update surfels
  if (update_surfels) {
    // Compute total transformation
    R3Affine t = R3identity_affine;
    t.Transform(transformation);
    t.Transform(this->transformation);
    this->transformation = R3identity_affine;
    
    // Transform all nodes                                                                                                     
    R3SurfelTree *tree = Tree();
    for (int i = 0; i < tree->NNodes(); i++) {
      R3SurfelNode *node = tree->Node(i);
      node->Transform(t);
    }

    // Transform all scans                                                                                                
    for (int i = 0; i < NScans(); i++) {
      R3SurfelScan *scan = Scan(i);
      scan->Transform(t);
    }

    // Transform all image poses                                                                                               
    for (int i = 0; i < NImages(); i++) {
      R3SurfelImage *image = Image(i);
      image->Transform(t);
    }
  }
  else {
    // Update transformation only
    R3Affine t = R3identity_affine;
    t.Transform(transformation);
    t.Transform(this->transformation);
    this->transformation = t;
  }

  // Mark scene as dirty
  flags.Add(R3_SURFEL_SCENE_DIRTY_FLAG);
}

// Assembly:
subq $0x2e8, %rsp            # imm = 0x2E8
movq %rdi, 0x2e0(%rsp)
movq %rsi, 0x2d8(%rsp)
movl %edx, 0x2d4(%rsp)
movq 0x2e0(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpl $0x0, 0x2d4(%rsp)
je 0x1e046
leaq 0x1df680(%rip), %rsi    # 0x1fd470
leaq 0x1c0(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x309e0
movq 0x50(%rsp), %rdi
movq 0x2d8(%rsp), %rsi
callq 0xd47f0
jmp 0x1de16
movq 0x58(%rsp), %rsi
addq $0xb0, %rsi
leaq 0x1c0(%rsp), %rdi
callq 0xd47f0
jmp 0x1de31
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
leaq 0x1df62c(%rip), %rsi    # 0x1fd470
callq 0x30970
jmp 0x1de4b
movq 0x58(%rsp), %rdi
callq 0x16ce0
movq %rax, 0x48(%rsp)
jmp 0x1de5c
movq 0x48(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movl $0x0, 0x1a4(%rsp)
movl 0x1a4(%rsp), %eax
movl %eax, 0x40(%rsp)
movq 0x1a8(%rsp), %rdi
callq 0x16cf0
movl %eax, 0x44(%rsp)
jmp 0x1de92
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1df23
movq 0x1a8(%rsp), %rdi
movl 0x1a4(%rsp), %esi
callq 0x30a90
movq %rax, 0x38(%rsp)
jmp 0x1debd
movq 0x38(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
leaq 0x1c0(%rsp), %rsi
callq *%rax
jmp 0x1dee5
jmp 0x1dee7
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0x1de74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0xd4520
jmp 0x1e102
movl $0x0, 0x194(%rsp)
movq 0x58(%rsp), %rdi
movl 0x194(%rsp), %eax
movl %eax, 0x30(%rsp)
callq 0x16ca0
movl %eax, 0x34(%rsp)
jmp 0x1df49
movl 0x30(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1dfaa
movq 0x58(%rsp), %rdi
movl 0x194(%rsp), %esi
callq 0x307d0
movq %rax, 0x28(%rsp)
jmp 0x1df6d
movq 0x28(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rdi
movq (%rdi), %rax
movq 0x70(%rax), %rax
leaq 0x1c0(%rsp), %rsi
callq *%rax
jmp 0x1df95
jmp 0x1df97
movl 0x194(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x194(%rsp)
jmp 0x1df2e
movl $0x0, 0x184(%rsp)
movq 0x58(%rsp), %rdi
movl 0x184(%rsp), %eax
movl %eax, 0x20(%rsp)
callq 0x16cc0
movl %eax, 0x24(%rsp)
jmp 0x1dfd0
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1e034
movq 0x58(%rsp), %rdi
movl 0x184(%rsp), %esi
callq 0x30800
movq %rax, 0x18(%rsp)
jmp 0x1dff4
movq 0x18(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rdi
movq (%rdi), %rax
movq 0xe8(%rax), %rax
leaq 0x1c0(%rsp), %rsi
callq *%rax
jmp 0x1e01f
jmp 0x1e021
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x1dfb5
leaq 0x1c0(%rsp), %rdi
callq 0xd4520
jmp 0x1e0cc
leaq 0x1df423(%rip), %rsi    # 0x1fd470
leaq 0x68(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x309e0
movq 0x10(%rsp), %rdi
movq 0x2d8(%rsp), %rsi
callq 0xd47f0
jmp 0x1e070
movq 0x58(%rsp), %rsi
addq $0xb0, %rsi
leaq 0x68(%rsp), %rdi
callq 0xd47f0
jmp 0x1e088
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
leaq 0x68(%rsp), %rsi
callq 0x30970
jmp 0x1e0a0
leaq 0x68(%rsp), %rdi
callq 0xd4520
jmp 0x1e0cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd4520
jmp 0x1e102
movq 0x58(%rsp), %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, 0x8(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x1, %esi
callq 0x1b970
movq 0x8(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1c2d0
addq $0x2e8, %rsp            # imm = 0x2E8
retq
movq 0x1b8(%rsp), %rdi
callq 0x13970
nop