// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::R3Scene::ReadFile(char const*, gaps::R3SceneNode*)
int R3Scene::
ReadFile(const char *filename, R3SceneNode *parent_node)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    RNFail("Filename %s has no extension (e.g., .txt)\n", filename);
    return 0;
  }

  // Read file of appropriate type
  if (!strncmp(extension, ".scn", 4)) {
    if (!ReadPrincetonFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".ssc", 4)) {
    if (!ReadParseFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".txt", 4)) {
    if (!ReadSupportHierarchyFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".hier", 5)) {
    if (!ReadGrammarHierarchyFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".obj", 4)) {
    if (!ReadObjFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".ply", 4)) {
    if (!ReadPlyFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".off", 4)) {
    if (!ReadMeshFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".rct", 4)) {
    if (!ReadRectangleFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".obb", 4)) {
    if (!ReadObbFile(filename, parent_node)) return 0;
  }
  else if (!strncmp(extension, ".json", 5)) {
    if (!ReadSUNCGFile(filename, parent_node)) return 0;
  }
  else {
    RNFail("Unable to read file %s (unrecognized extension: %s)\n", filename, extension);
    return 0;
  }

  // Provide default camera
  if (Camera() == R3default_camera) {
    double scene_radius = BBox().DiagonalRadius();
    R3Point scene_center = BBox().Centroid();
    R3Vector towards = R3Vector(0, 0, -1);
    R3Vector up = R3Vector(0, 1, 0);
    R3Point eye = scene_center;
    R3Camera camera(eye, towards, up, 0.25, 0.25, 0.01 * scene_radius, 100 * scene_radius);
    SetCamera(camera);
  }

  // Set filename
  SetFilename(filename);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x219c0
testq %rax, %rax
je 0x2859c
movq %rax, %r12
leaq 0x9d107(%rip), %rsi     # 0xc558b
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x213e0
testl %eax, %eax
je 0x285b4
leaq 0x9d0f2(%rip), %rsi     # 0xc5590
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x285c7
leaq 0x9d0dd(%rip), %rsi     # 0xc5595
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x285d7
leaq 0x9d0c8(%rip), %rsi     # 0xc559a
pushq $0x5
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x285e7
leaq 0x9dd84(%rip), %rsi     # 0xc6270
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x285f7
leaq 0x9d09a(%rip), %rsi     # 0xc55a0
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x28607
leaq 0x9d9f2(%rip), %rsi     # 0xc5f12
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x28617
leaq 0x9d06b(%rip), %rsi     # 0xc55a5
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x28627
leaq 0x9d056(%rip), %rsi     # 0xc55aa
pushq $0x4
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x28637
leaq 0x9d041(%rip), %rsi     # 0xc55af
pushq $0x5
popq %rdx
movq %r12, %rdi
callq 0x213e0
testl %eax, %eax
je 0x28647
leaq 0x9d02d(%rip), %rdi     # 0xc55b5
xorl %ebp, %ebp
movq %rbx, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x7e83e
jmp 0x28741
leaq 0x9cfbd(%rip), %rdi     # 0xc5560
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7e83e
jmp 0x28741
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x28756
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2a524
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2ab40
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b00e
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b58c
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b5a2
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2ba4c
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2baf6
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2c0e6
jmp 0x28655
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2c590
testl %eax, %eax
je 0x2873f
leaq 0x78(%r14), %rdi
leaq 0x10b438(%rip), %rsi    # 0x133aa0
callq 0x3bd5e
testl %eax, %eax
je 0x2872f
movq %r14, %rdi
callq 0x27352
movq %rax, %rdi
callq 0x2735a
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x27352
movq (%rax), %rcx
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq *0x68(%rcx)
leaq 0x38(%rsp), %r15
movsd 0x9ce20(%rip), %xmm2    # 0xc54d0
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r15, %rdi
callq 0x6c034
leaq 0x20(%rsp), %r13
movsd 0x9c94d(%rip), %xmm1    # 0xc5018
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r13, %rdi
callq 0x6c034
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x6b884
movsd 0x9c92f(%rip), %xmm2    # 0xc5020
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm2
mulsd 0x9c94e(%rip), %xmm3    # 0xc5050
leaq 0x68(%rsp), %r12
movsd 0x9cdc9(%rip), %xmm0    # 0xc54d8
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r13, %rcx
movaps %xmm0, %xmm1
callq 0x3b786
leaq 0x70(%r14), %rdi
movq %r12, %rsi
callq 0x39f3a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3442e
pushq $0x1
popq %rbp
jmp 0x28741
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop