// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::operator=(gaps::R3Mesh const&)
R3Mesh& R3Mesh::
operator=(const R3Mesh& mesh)
{
  // Delete everything
  Empty();
  
  // Copy bbox
  bbox = mesh.bbox;

  // 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));
  }

  // Invalidate GL buffer objects
  InvalidateGLBufferObjects();

  // Return this
  return *this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
movl $0x100, %esi            # imm = 0x100
leaq (%rbx,%rsi), %rdi
addq %r14, %rsi
callq 0x3cd94
movl $0x118, %esi            # imm = 0x118
leaq (%rbx,%rsi), %rdi
addq %r14, %rsi
callq 0x3cd94
movslq 0x14(%r14), %r13
movl $0x98, %ecx
movq %r13, %rax
mulq %rcx
movq %rax, %rdi
seto %al
addq $0x8, %rdi
movq $-0x1, %rcx
cmovbq %rcx, %rdi
testb %al, %al
cmovneq %rcx, %rdi
movq %rdi, 0x10(%rsp)
callq 0xe030
movq %rax, %r12
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq %r13, (%r12)
testq %r13, %r13
je 0x18718
imulq $-0x98, %r13, %r15
xorl %ebp, %ebp
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x23c38
addq $-0x98, %rbp
addq $0x98, %r13
cmpq %rbp, %r15
jne 0x186fd
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rbx)
cmpl $0x0, 0x14(%r14)
jle 0x1879e
leaq 0x89bb5(%rip), %r15     # 0xa22e4
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %r12
testb $0x2, 0x78(%r12)
jne 0x18753
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
callq *0x2b0(%rax)
leaq 0x18(%r12), %rsi
leaq 0x30(%r12), %rdx
leaq 0x58(%r12), %rcx
addq $0x48, %r12
movq 0x38(%rbx), %r9
addq %r13, %r9
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %r8
callq *0x38(%rax)
movl 0x70(%rax), %eax
cmpq %rax, %rbp
je 0x1878b
movq %r15, %rdi
xorl %eax, %eax
callq 0x72942
incq %rbp
movslq 0x14(%r14), %rax
addq $0x98, %r13
cmpq %rax, %rbp
jl 0x18734
movslq 0x24(%r14), %r15
movl $0x58, %ecx
movq %r15, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
movq $-0x1, %rdi
cmovbq %rdi, %rax
testb %cl, %cl
cmoveq %rax, %rdi
callq 0xe030
leaq 0x8(%rax), %rcx
movq %r15, (%rax)
testq %r15, %r15
je 0x1881e
imulq $0x58, %r15, %rax
xorl %edx, %edx
leaq 0xc8f3d(%rip), %rsi     # 0xe1720
xorps %xmm0, %xmm0
xorl %edi, %edi
movq %rsi, (%rcx,%rdi)
movq %rdx, 0x28(%rcx,%rdi)
movl $0xffffffff, 0x30(%rcx,%rdi) # imm = 0xFFFFFFFF
movq %rdx, 0x50(%rcx,%rdi)
movups %xmm0, 0x8(%rcx,%rdi)
movups %xmm0, 0x18(%rcx,%rdi)
movups %xmm0, 0x38(%rcx,%rdi)
movl $0x0, 0x48(%rcx,%rdi)
addq $0x58, %rdi
cmpq %rdi, %rax
jne 0x187e8
movq %rcx, 0x40(%rbx)
cmpl $0x0, 0x24(%r14)
jle 0x1888d
leaq 0x89aca(%rip), %r15     # 0xa22fa
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rax), %rax
movq (%rbx), %r8
movq 0x8(%rbx), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rdx,%rax,8), %rdx
movq 0x40(%rbx), %rcx
addq %r12, %rcx
movq %rbx, %rdi
callq *0x40(%r8)
movl 0x30(%rax), %eax
cmpq %rax, %r13
je 0x1887d
movq %r15, %rdi
xorl %eax, %eax
callq 0x72942
incq %r13
movslq 0x24(%r14), %rax
addq $0x58, %r12
cmpq %rax, %r13
jl 0x18836
movslq 0x34(%r14), %r13
movl $0xc8, %ecx
movq %r13, %rax
mulq %rcx
movq %rax, %rdi
seto %al
addq $0x8, %rdi
movq $-0x1, %rcx
cmovbq %rcx, %rdi
testb %al, %al
cmovneq %rcx, %rdi
movq %rdi, 0x10(%rsp)
callq 0xe030
movq %rax, %r12
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq %r13, (%r12)
testq %r13, %r13
je 0x188ff
imulq $-0xc8, %r13, %r15
xorl %ebp, %ebp
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x23d50
addq $-0xc8, %rbp
addq $0xc8, %r13
cmpq %rbp, %r15
jne 0x188e4
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rbx)
cmpl $0x0, 0x34(%r14)
jle 0x189aa
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %r15
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq 0x18(%r15), %rdx
movslq 0x70(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rdx), %rdi
movq (%rbx), %r9
movq 0x8(%rbx), %r8
movq (%r8,%rax,8), %rsi
movq (%r8,%rcx,8), %rdx
movq (%r8,%rdi,8), %rcx
movq 0x48(%rbx), %r8
addq %r13, %r8
movq %rbx, %rdi
callq *0x48(%r9)
movq %rax, %r12
movl 0xa4(%rax), %eax
cmpq %rax, %rbp
je 0x18975
leaq 0x899a0(%rip), %rdi     # 0xa230e
xorl %eax, %eax
callq 0x72942
movq 0x98(%r15), %rax
movq %rax, 0x98(%r12)
movl 0xa0(%r15), %eax
movl %eax, 0xa0(%r12)
incq %rbp
movslq 0x34(%r14), %rax
addq $0xc8, %r13
cmpq %rax, %rbp
jl 0x18918
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x290(%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0x18a33
negq %rbp
movq %r12, %r14
addq $-0x68, %r14
leaq 0xc8d5f(%rip), %r15     # 0xe1740
movq %r15, -0xc0(%r12,%rbp)
leaq (%r14,%rbp), %rdi
callq 0x28348
addq $-0xc8, %rbp
jne 0x189e1
jmp 0x18a33
movq %rax, %rbx
testq %rbp, %rbp
je 0x18a33
negq %rbp
movq %r12, %r14
addq $-0x88, %r14
leaq 0xc8ce7(%rip), %r15     # 0xe1700
movq %r15, -0x90(%r12,%rbp)
leaq (%r14,%rbp), %rdi
callq 0x70656
addq $-0x98, %rbp
jne 0x18a19
movq %r12, %rdi
movq 0x10(%rsp), %rsi
callq 0xe8c0
movq %rbx, %rdi
callq 0xe7e0