// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::segmentChannel(ATOM_NETWORK*)
void FEATURE::segmentChannel(ATOM_NETWORK *uc){
int i;

cout << "Current channel has " << nodes.size() << " nodes" << "\n";

for(i=0;i<(int)nodes.size();i++)
   {
   segments.push_back(-1);
   };
nsegments=0;

while(segment_findMaxNode()>-1)
   {
//   segment_growSegment_start(uc,segment_findMaxNode());
   segment_distBasedSegmentation(uc);
   };

cout << "Initial number of segments (minima) " << nsegments << "\n";

/*
fstream output1;
output1.open("segments.zvis",fstream::out);
segment_saveVis(output1);
output1.close();
*/

//segment_identify_connections(); // analyzes connectivity of each segment to find segment's 'faces' - connection between segments 



//merge_segments(); // analyze segments and merge if neccesary

//merge_nothing(); // this function copies segments into features

merge_singlenode_segments();


//calculateVolumeForAllFeatures(); // calculate volume of each segment


/* Print results */
cout << "\n" << "Segment info (ID - r):"<<"\n";
for(i=0;i<(int)segment_max_r.size();i++)
   {
   cout << i<< "   " << segment_max_r[i]  << "\n";
   };
cout << "\n" << "Segment connection info (from to radii merge_stat):"<<"\n";

/*
for(i=0;i<(int)segment_conn.size();i++)
   {
   cout << segment_conn.at(i).from_seg << "   " << segment_conn.at(i).to_seg << "   " <<segment_conn.at(i).max_radius << "   " << segment_conn.at(i).merged << "\n";
   };

cout << "\n" << "Total number of segment connecting edges :  "<< segment_conn_fulllist.size()  <<"\n";

cout << "\n" << "Segment info vs features (segment ID - feature ID):"<<"\n";
for(i=0;i<nsegments;i++)
   {
   cout << i<< "   " << segment_merge_list[i]  << "\n";
   };
*/
cout << "\n" << "Features info (ID - r - volume):"<<"\n";
for(i=0;i<(int)feature_max_r.size();i++)
   {
//   cout << i<< "   " << feature_max_r[i]  << "   " << feature_volume[i] << "\n";
   cout << i<< "   " << feature_max_r[i]   << "\n";
   };
/*
cout << "\n" << "Features connection info (from to radii ):"<<"\n";
for(i=0;i<(int)feature_conn.size();i++)
   {
   cout << feature_conn.at(i).from_seg << "   " << feature_conn.at(i).to_seg << "   " <<feature_conn.at(i).max_radius << "\n";
   };
*/

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0xf5c0c(%rip), %rdi     # 0x14ffc0
leaq 0xa98e6(%rip), %rsi     # 0x103ca1
callq 0x4480
movq %rax, %rdi
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
pushq $0x48
popq %r13
cqto
idivq %r13
movq %rax, %rsi
callq 0x42e0
leaq 0xa670d(%rip), %rsi     # 0x100af0
movq %rax, %rdi
callq 0x4480
leaq 0xa818c(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0x140(%rbx), %r15
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
cqto
idivq %r13
cmpl %eax, %ebp
jge 0x5a42d
orl $-0x1, 0x4(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x10324
incl %ebp
jmp 0x5a408
andl $0x0, 0x138(%rbx)
movq %rbx, %rdi
callq 0x5bcfc
testl %eax, %eax
js 0x5a44d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5bd8a
jmp 0x5a434
movq 0xf5b6c(%rip), %r14     # 0x14ffc0
leaq 0xa985b(%rip), %rsi     # 0x103cb6
movq %r14, %rdi
callq 0x4480
movl 0x138(%rbx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xa8106(%rip), %r15     # 0x10257e
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
movq %rbx, %rdi
callq 0x5c03a
movq %r14, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xa983e(%rip), %rsi     # 0x103cdb
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
xorl %r12d, %r12d
leaq 0xa2014(%rip), %r13     # 0xfc4ce
movq 0x240(%rbx), %rax
subq 0x238(%rbx), %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r12
jge 0x5a50e
movq %r14, %rdi
movl %r12d, %esi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movq 0x238(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
incq %r12
jmp 0x5a4ba
movq 0xf5aab(%rip), %r14     # 0x14ffc0
leaq 0xa8062(%rip), %r15     # 0x10257e
movq %r14, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xa97c4(%rip), %rsi     # 0x103cf2
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
movq %r14, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xa97d3(%rip), %rsi     # 0x103d26
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
xorl %r12d, %r12d
leaq 0xa1f5e(%rip), %r13     # 0xfc4ce
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r12
jge 0x5a5c4
movq %r14, %rdi
movl %r12d, %esi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movq 0x250(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
incq %r12
jmp 0x5a570
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop