// File: npaster[P]gmsh_tools/main.cc
// Function: main
int main(int argc, char** argv)
{
  if (argc < 2)
    {
      cout << "Please, enter the name of your mesh .. " << endl;
      return 0;
    }

  gmsh::Gmesh mesh;
  const string name_mesh(argv[1]);
  mesh.readGmesh(name_mesh);

  mesh.getInfo();
  cout << endl;

  mesh.writeGmesh("test.msh", 2);

  gmsh::Gmesh mesh2(mesh);

  mesh2.convertInDiscontinuousMesh();

  std::vector<gmsh::Node> newNodes;

  for(size_t i=0; i< mesh2.getNumberofNodes(); i++){
     std::array<double, 3> newcoor = {{1.0*(rand() % 10), 1.0*(rand() % 10), 0.0}};
     gmsh::Node tmpNode(newcoor, i, 0);
     newNodes.push_back(tmpNode);
 }

  mesh2.computeDeformed(newNodes);

  mesh2.writeGmesh("test2.msh", 2);

  gmsh::NodeData data;

  data.changeNbComposante(1);

  std::vector<gmsh::Node> v_node= mesh2.getNodes();

  for (size_t i = 0; i < v_node.size(); i++) {
     std::vector<double> value = {1.0 + (rand() % 10)} ;
     std::array<double, 3> coor = {{0.1*(rand() % 10), 0.1*(rand() % 10), 0.0}};
     gmsh::Node nodetmp(coor, v_node.size() +1 +i, 1 );
     gmsh::Data dat(v_node.size() +1 +i , value);
     data.addData(v_node[i].getIndex(), value );
     //data.addSubData(dat, nodetmp);
  }

  data.saveNodeData("result5.msh", mesh2);

  gmsh::ElementData data2;

  data2.changeNbComposante(1);

  std::vector<gmsh::Triangle> v= mesh.getTriangles();

  for (size_t i = 0; i < v.size(); i++) {
     std::vector<double> value = {1.0 + i} ;
     data2.addData(v[i].getIndex(), value );
  }



  data2.saveElementData("result4.msh", mesh);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x570, %rsp            # imm = 0x570
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x1f3dd
movq 0x11c22(%rip), %rdi     # 0x30fd8
leaq 0x2bf3(%rip), %rsi      # 0x21fb0
callq 0x21b0
movq %rax, %rdi
movq 0x11bfc(%rip), %rsi     # 0x30fc8
callq 0x21e0
movl $0x0, -0x4(%rbp)
jmp 0x1fe74
leaq -0xf8(%rbp), %rdi
callq 0x4a20
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x500(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x22f0
movq -0x500(%rbp), %rsi
movq -0x4f8(%rbp), %rdx
leaq -0x118(%rbp), %rdi
callq 0x2210
jmp 0x1f427
leaq -0x119(%rbp), %rdi
callq 0x21f0
leaq -0x150(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x20d0
jmp 0x1f448
leaq -0xf8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x85f0
jmp 0x1f45d
leaq -0x150(%rbp), %rdi
callq 0x2120
leaq -0xf8(%rbp), %rdi
callq 0xc7d0
jmp 0x1f477
movq 0x11b5a(%rip), %rdi     # 0x30fd8
movq 0x11b43(%rip), %rsi     # 0x30fc8
callq 0x21e0
jmp 0x1f48c
leaq -0x171(%rbp), %rdi
movq %rdi, -0x508(%rbp)
callq 0x22f0
movq -0x508(%rbp), %rdx
leaq 0x2b2b(%rip), %rsi      # 0x21fd8
leaq -0x170(%rbp), %rdi
callq 0x2210
jmp 0x1f4bb
leaq -0xf8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl $0x2, %edx
callq 0xc6d0
jmp 0x1f4d5
leaq -0x170(%rbp), %rdi
callq 0x2120
leaq -0x171(%rbp), %rdi
callq 0x21f0
leaq -0x260(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x1bf00
jmp 0x1f502
leaq -0x260(%rbp), %rdi
callq 0xdbb0
jmp 0x1f510
leaq -0x278(%rbp), %rdi
callq 0xdcf0
movq $0x0, -0x280(%rbp)
movq -0x280(%rbp), %rax
movq %rax, -0x518(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x5a60
movq %rax, -0x510(%rbp)
jmp 0x1f54a
movq -0x518(%rbp), %rax
movq -0x510(%rbp), %rcx
cmpq %rcx, %rax
jae 0x1f6ea
callq 0x2080
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x298(%rbp)
callq 0x2080
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x290(%rbp)
movq $0x0, -0x288(%rbp)
movq -0x280(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
leaq -0x2c0(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x2590
jmp 0x1f5ee
leaq -0x278(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xef90
jmp 0x1f603
jmp 0x1f605
movq -0x280(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x280(%rbp)
jmp 0x1f527
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x119(%rbp), %rdi
callq 0x21f0
jmp 0x1fe66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x2120
jmp 0x1fe5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1f6ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x2120
leaq -0x171(%rbp), %rdi
callq 0x21f0
jmp 0x1fe5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe42
leaq -0x260(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0xdc10
jmp 0x1f6ff
leaq -0x2e1(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x22f0
movq -0x520(%rbp), %rdx
leaq 0x28c1(%rip), %rsi      # 0x21fe1
leaq -0x2e0(%rbp), %rdi
callq 0x2210
jmp 0x1f72e
leaq -0x260(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
movl $0x2, %edx
callq 0xc6d0
jmp 0x1f748
leaq -0x2e0(%rbp), %rdi
callq 0x2120
leaq -0x2e1(%rbp), %rdi
callq 0x21f0
leaq -0x348(%rbp), %rdi
callq 0x198e0
jmp 0x1f76e
leaq -0x348(%rbp), %rdi
movl $0x1, %esi
callq 0x197c0
jmp 0x1f781
leaq -0x360(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x5ac0
jmp 0x1f796
movq $0x0, -0x368(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x528(%rbp)
leaq -0x360(%rbp), %rdi
callq 0xeb00
movq %rax, %rcx
movq -0x528(%rbp), %rax
cmpq %rcx, %rax
jae 0x1fa81
callq 0x2080
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x27a1(%rip), %xmm1     # 0x21fa0
addsd %xmm1, %xmm0
movsd %xmm0, -0x398(%rbp)
leaq -0x398(%rbp), %rax
movq %rax, -0x390(%rbp)
movq $0x1, -0x388(%rbp)
leaq -0x399(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x1c210
movq -0x530(%rbp), %rcx
movq -0x390(%rbp), %rsi
movq -0x388(%rbp), %rdx
leaq -0x380(%rbp), %rdi
callq 0x1fe90
jmp 0x1f85a
leaq -0x399(%rbp), %rdi
callq 0x1c8a0
callq 0x2080
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x2711(%rip), %xmm1     # 0x21fa8
movsd %xmm1, -0x538(%rbp)
mulsd %xmm1, %xmm0
movsd %xmm0, -0x3b8(%rbp)
callq 0x2080
movsd -0x538(%rbp), %xmm1
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x3b0(%rbp)
movq $0x0, -0x3a8(%rbp)
leaq -0x360(%rbp), %rdi
callq 0xeb00
movq -0x368(%rbp), %rcx
leaq 0x1(%rax,%rcx), %rdx
leaq -0x3e0(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
movl $0x1, %ecx
callq 0x2590
jmp 0x1f925
leaq -0x360(%rbp), %rdi
callq 0xeb00
movq -0x368(%rbp), %rcx
leaq 0x1(%rax,%rcx), %rsi
leaq -0x400(%rbp), %rdi
leaq -0x380(%rbp), %rdx
callq 0x19220
jmp 0x1f952
movq -0x368(%rbp), %rsi
leaq -0x360(%rbp), %rdi
callq 0xf860
movq %rax, %rdi
callq 0x27c0
movq %rax, -0x540(%rbp)
jmp 0x1f976
movq -0x540(%rbp), %rsi
leaq -0x348(%rbp), %rdi
leaq -0x380(%rbp), %rdx
callq 0x19860
jmp 0x1f992
leaq -0x400(%rbp), %rdi
callq 0x1bc40
leaq -0x380(%rbp), %rdi
callq 0x1ba60
movq -0x368(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x368(%rbp)
jmp 0x1f7a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1f9f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x2120
leaq -0x2e1(%rbp), %rdi
callq 0x21f0
jmp 0x1fe42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x399(%rbp), %rdi
callq 0x1c8a0
jmp 0x1fe2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fa70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x1bc40
leaq -0x380(%rbp), %rdi
callq 0x1ba60
jmp 0x1fe2a
leaq -0x421(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x22f0
movq -0x548(%rbp), %rdx
leaq 0x2549(%rip), %rsi      # 0x21feb
leaq -0x420(%rbp), %rdi
callq 0x2210
jmp 0x1fab0
leaq -0x348(%rbp), %rdi
leaq -0x420(%rbp), %rsi
leaq -0x260(%rbp), %rdx
callq 0x1a410
jmp 0x1facc
leaq -0x420(%rbp), %rdi
callq 0x2120
leaq -0x421(%rbp), %rdi
callq 0x21f0
leaq -0x470(%rbp), %rdi
callq 0x1ff10
jmp 0x1faf2
leaq -0x470(%rbp), %rdi
movl $0x1, %esi
callq 0x197c0
jmp 0x1fb05
leaq -0x488(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x5b50
jmp 0x1fb1a
movq $0x0, -0x490(%rbp)
movq -0x490(%rbp), %rax
movq %rax, -0x550(%rbp)
leaq -0x488(%rbp), %rdi
callq 0xe3e0
movq %rax, %rcx
movq -0x550(%rbp), %rax
cmpq %rcx, %rax
jae 0x1fd05
movaps 0x2427(%rip), %xmm1     # 0x21f80
movq -0x490(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2423(%rip), %xmm1     # 0x21f90
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x241c(%rip), %xmm1     # 0x21fa0
addsd %xmm1, %xmm0
movsd %xmm0, -0x4c0(%rbp)
leaq -0x4c0(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movq $0x1, -0x4b0(%rbp)
leaq -0x4c1(%rbp), %rdi
movq %rdi, -0x558(%rbp)
callq 0x1c210
movq -0x558(%rbp), %rcx
movq -0x4b8(%rbp), %rsi
movq -0x4b0(%rbp), %rdx
leaq -0x4a8(%rbp), %rdi
callq 0x1fe90
jmp 0x1fbdf
leaq -0x4c1(%rbp), %rdi
callq 0x1c8a0
movq -0x490(%rbp), %rsi
leaq -0x488(%rbp), %rdi
callq 0xf840
movq %rax, %rdi
callq 0x2970
movq %rax, -0x560(%rbp)
jmp 0x1fc0f
movq -0x560(%rbp), %rsi
leaq -0x470(%rbp), %rdi
leaq -0x4a8(%rbp), %rdx
callq 0x19860
jmp 0x1fc2b
leaq -0x4a8(%rbp), %rdi
callq 0x1ba60
movq -0x490(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x490(%rbp)
jmp 0x1fb25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fc80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x2120
leaq -0x421(%rbp), %rdi
callq 0x21f0
jmp 0x1fe2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x4c1(%rbp), %rdi
callq 0x1c8a0
jmp 0x1fe12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x4a8(%rbp), %rdi
callq 0x1ba60
jmp 0x1fe12
leaq -0x4e9(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x22f0
movq -0x568(%rbp), %rdx
leaq 0x22d1(%rip), %rsi      # 0x21ff7
leaq -0x4e8(%rbp), %rdi
callq 0x2210
jmp 0x1fd34
leaq -0x470(%rbp), %rdi
leaq -0x4e8(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
callq 0x1ad50
jmp 0x1fd50
leaq -0x4e8(%rbp), %rdi
callq 0x2120
leaq -0x4e9(%rbp), %rdi
callq 0x21f0
movl $0x0, -0x4(%rbp)
leaq -0x488(%rbp), %rdi
callq 0xe440
leaq -0x470(%rbp), %rdi
callq 0x1ff30
leaq -0x360(%rbp), %rdi
callq 0xe1a0
leaq -0x348(%rbp), %rdi
callq 0x1ff50
leaq -0x278(%rbp), %rdi
callq 0xe1a0
leaq -0x260(%rbp), %rdi
callq 0x1c120
leaq -0x118(%rbp), %rdi
callq 0x2120
leaq -0xf8(%rbp), %rdi
callq 0x1c120
jmp 0x1fe74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x1fe06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x4e8(%rbp), %rdi
callq 0x2120
leaq -0x4e9(%rbp), %rdi
callq 0x21f0
leaq -0x488(%rbp), %rdi
callq 0xe440
leaq -0x470(%rbp), %rdi
callq 0x1ff30
leaq -0x360(%rbp), %rdi
callq 0xe1a0
leaq -0x348(%rbp), %rdi
callq 0x1ff50
leaq -0x278(%rbp), %rdi
callq 0xe1a0
leaq -0x260(%rbp), %rdi
callq 0x1c120
leaq -0x118(%rbp), %rdi
callq 0x2120
leaq -0xf8(%rbp), %rdi
callq 0x1c120
jmp 0x1fe80
movl -0x4(%rbp), %eax
addq $0x570, %rsp            # imm = 0x570
popq %rbp
retq
movq -0x128(%rbp), %rdi
callq 0x22e0
nopl (%rax)