// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::R3Mesh(gaps::R3Mesh const&)
R3Mesh::
R3Mesh(const R3Mesh& mesh)
  : vertex_block(NULL),
    edge_block(NULL),
    face_block(NULL),
    vbo_face_position_buffer(0),
    vbo_face_normal_buffer(0),
    vbo_face_texcoord_buffer(0),
    vbo_face_rgb_color_buffer(0),
    vbo_face_pick_color_buffer(0),
    vbo_vertex_position_buffer(0),
    vbo_vertex_normal_buffer(0),
    vbo_vertex_texcoord_buffer(0),
    vbo_vertex_rgb_color_buffer(0),
    vbo_vertex_pick_color_buffer(0),
    bbox(mesh.bbox),
    data(NULL)
{
  // Copy vertices 
  vertex_block = new R3MeshVertex [ mesh.NVertices() ];
  for (int i = 0; i < mesh.NVertices(); i++) {
    R3MeshVertex *vertex = mesh.Vertex(i);
    const R3Point& position = mesh.VertexPosition(vertex);
    const R3Vector& normal = mesh.VertexNormal(vertex);
    const RNRgb& color = mesh.VertexColor(vertex);
    const R2Point& texcoords = mesh.VertexTextureCoords(vertex);
    R3MeshVertex *copy_vertex = this->CreateVertex(position, normal, color, texcoords, &vertex_block[i] );
    if (this->VertexID(copy_vertex) != i) RNAbort("Mismatching vertex id"); 
  }

  // Copy edges
  edge_block = new R3MeshEdge [ mesh.NEdges() ];
  for (int i = 0; i < mesh.NEdges(); i++) {
    R3MeshEdge *edge = mesh.Edge(i);
    R3MeshVertex *v0 = mesh.VertexOnEdge(edge, 0);
    R3MeshVertex *v1 = mesh.VertexOnEdge(edge, 1);
    int i0 = mesh.VertexID(v0);
    int i1 = mesh.VertexID(v1);
    R3MeshVertex *copy_v0 = this->Vertex(i0);
    R3MeshVertex *copy_v1 = this->Vertex(i1);
    R3MeshEdge *copy_edge = this->CreateEdge(copy_v0, copy_v1, &edge_block[i] );
    if (this->EdgeID(copy_edge) != i) RNAbort("Mismatching edge id"); 
  }

  // Copy faces
  face_block = new R3MeshFace [ mesh.NFaces() ];
  for (int i = 0; i < mesh.NFaces(); i++) {
    R3MeshFace *face = mesh.Face(i);
    R3MeshVertex *v0 = mesh.VertexOnFace(face, 0);
    R3MeshVertex *v1 = mesh.VertexOnFace(face, 1);
    R3MeshVertex *v2 = mesh.VertexOnFace(face, 2);
    int i0 = mesh.VertexID(v0);
    int i1 = mesh.VertexID(v1);
    int i2 = mesh.VertexID(v2);
    R3MeshVertex *copy_v0 = this->Vertex(i0);
    R3MeshVertex *copy_v1 = this->Vertex(i1);
    R3MeshVertex *copy_v2 = this->Vertex(i2);
    R3MeshFace *copy_face = this->CreateFace(copy_v0, copy_v1, copy_v2, &face_block[i]);
    if (this->FaceID(copy_face) != i) RNAbort("Mismatching face id"); 
    this->SetFaceMaterial(copy_face, mesh.FaceMaterial(face));
    this->SetFaceSegment(copy_face, mesh.FaceSegment(face));
    this->SetFaceCategory(copy_face, mesh.FaceCategory(face));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
movq %rdi, %rbp
leaq 0xc5557(%rip), %rax     # 0xd6410
movq %rax, (%rdi)
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x6630a
leaq 0x18(%rbp), %r14
movq %r14, %rdi
callq 0x6630a
leaq 0x28(%rbp), %r15
movq %r15, %rdi
callq 0x6630a
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movl $0xf8, %esi
leaq (%rsi,%rbp), %rdi
addq %r13, %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rbp)
movups %xmm0, 0x58(%rbp)
movups %xmm0, 0x48(%rbp)
movups %xmm0, 0x38(%rbp)
movq %rdi, 0x20(%rsp)
callq 0x24b3e
andq $0x0, 0x130(%rbp)
movslq 0x14(%r13), %r15
movl $0x98, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rbx
seto %al
addq $0x8, %rbx
pushq $-0x1
popq %rcx
cmovbq %rcx, %rbx
testb %al, %al
cmovneq %rcx, %rbx
movq %rbx, %rdi
callq 0xe030
movq %r15, (%rax)
movq %rax, 0x28(%rsp)
addq $0x8, %rax
movq %rax, 0x30(%rsp)
testl %r15d, %r15d
je 0x10f8e
imulq $-0x98, %r15, %r14
xorl %r12d, %r12d
movq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x2108c
addq $-0x98, %r12
addq $0x98, %r15
cmpq %r12, %r14
jne 0x10f73
leaq 0x38(%rbp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x822f3(%rip), %rbx     # 0x93294
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x14(%r13), %rax
cmpq %rax, %r12
jge 0x11005
movq 0x8(%r13), %rax
movq (%rax,%r12,8), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x21234
leaq 0x18(%r14), %rsi
leaq 0x58(%r14), %rcx
addq $0x48, %r14
movq 0x38(%rbp), %r9
addq %r15, %r9
movq (%rbp), %r10
movq %rbp, %rdi
movq %rax, %rdx
movq %r14, %r8
callq *0x38(%r10)
movl 0x70(%rax), %eax
cmpq %rax, %r12
je 0x10ff9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x680f0
incq %r12
addq $0x98, %r15
jmp 0x10fa7
movl 0x24(%r13), %r14d
movslq %r14d, %rbx
pushq $0x58
popq %rcx
movq %rbx, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
pushq $-0x1
popq %rdx
cmovbq %rdx, %rax
testb %cl, %cl
cmovneq %rdx, %rax
movq %rax, %rdi
callq 0xe030
movq %rbx, (%rax)
addq $0x8, %rax
testl %ebx, %ebx
je 0x1107e
imulq $0x58, %rbx, %rcx
xorl %edx, %edx
leaq 0xc56e7(%rip), %rsi     # 0xd6730
xorps %xmm0, %xmm0
movq %rsi, (%rax,%rdx)
andq $0x0, 0x28(%rax,%rdx)
orl $-0x1, 0x30(%rax,%rdx)
andq $0x0, 0x50(%rax,%rdx)
movups %xmm0, 0x8(%rax,%rdx)
movups %xmm0, 0x18(%rax,%rdx)
andl $0x0, 0x48(%rax,%rdx)
movups %xmm0, 0x38(%rax,%rdx)
addq $0x58, %rdx
cmpq %rdx, %rcx
jne 0x1104c
movq %rax, 0x40(%rbp)
leaq 0x82221(%rip), %rbx     # 0x932aa
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq %r14d, %rax
cmpq %rax, %r12
jge 0x110ec
movq 0x18(%r13), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rax), %rax
movq (%rbp), %r8
movq 0x8(%rbp), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rdx,%rax,8), %rdx
movq 0x40(%rbp), %rcx
addq %r15, %rcx
movq %rbp, %rdi
callq *0x40(%r8)
movl 0x30(%rax), %eax
cmpq %rax, %r12
je 0x110df
movq %rbx, %rdi
xorl %eax, %eax
callq 0x680f0
incq %r12
movl 0x24(%r13), %r14d
addq $0x58, %r15
jmp 0x1108f
movslq 0x34(%r13), %r15
movl $0xc8, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rbx
seto %al
addq $0x8, %rbx
pushq $-0x1
popq %rcx
cmovbq %rcx, %rbx
testb %al, %al
cmovneq %rcx, %rbx
movq %rbx, %rdi
callq 0xe030
movq %r15, (%rax)
movq %rax, 0x28(%rsp)
addq $0x8, %rax
movq %rax, 0x30(%rsp)
testl %r15d, %r15d
je 0x1115a
imulq $-0xc8, %r15, %r14
xorl %r12d, %r12d
movq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x21186
addq $-0xc8, %r12
addq $0xc8, %r15
cmpq %r12, %r14
jne 0x1113f
movq 0x30(%rsp), %rax
movq %rax, 0x48(%rbp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x34(%r13), %rax
cmpq %rax, %r12
jge 0x111fe
movq 0x28(%r13), %rax
movq (%rax,%r12,8), %rbx
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rdx
movslq 0x70(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rdx), %rdi
movq (%rbp), %r9
movq 0x8(%rbp), %r8
movq (%r8,%rax,8), %rsi
movq (%r8,%rcx,8), %rdx
movq (%r8,%rdi,8), %rcx
movq 0x48(%rbp), %r8
addq %r15, %r8
movq %rbp, %rdi
callq *0x48(%r9)
movq %rax, %r14
movl 0xa4(%rax), %eax
cmpq %rax, %r12
je 0x111d4
leaq 0x820f1(%rip), %rdi     # 0x932be
xorl %eax, %eax
callq 0x680f0
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r14)
movl 0xa0(%rbx), %eax
movl %eax, 0xa0(%r14)
incq %r12
addq $0xc8, %r15
jmp 0x11169
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
jmp 0x112bb
movq %rax, %r13
jmp 0x112c3
movq %rax, %r13
jmp 0x112cb
jmp 0x1129f
movq %rax, %r13
testq %r12, %r12
je 0x1128a
negq %r12
movq 0x28(%rsp), %r14
addq $-0xc0, %r14
leaq (%r14,%r12), %rdi
callq 0x21208
addq $-0xc8, %r12
jne 0x1124d
jmp 0x1128a
movq %rax, %r13
testq %r12, %r12
je 0x1128a
negq %r12
movq 0x28(%rsp), %r14
addq $-0x90, %r14
leaq (%r14,%r12), %rdi
callq 0x21124
addq $-0x98, %r12
jne 0x11278
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0xe8f0
jmp 0x112a2
jmp 0x1129f
jmp 0x1129f
jmp 0x1129f
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %rdi
callq 0x25832
movq %r15, %rdi
callq 0x66378
movq %r14, %rdi
callq 0x66378
movq %rbx, %rdi
callq 0x66378
movq %r13, %rdi
callq 0xe810
nop