// File: /workspace/github_cpp_makefile_star2_O1/jingdao[P]PointCloudApp/descriptor.cpp
// Function: Descriptor::LoadFromDir(char const*)
Descriptor* Descriptor::LoadFromDir(const char* dir) {
	Descriptor* res = new Descriptor();

	char buffer[1024];
	int ndir = strlen(dir);
	strncpy(buffer,dir,ndir);
	char* buffer_c = buffer + ndir;
	*buffer_c++ = '/';

	std::vector<double> measurements;
	int j;
	for (j=0;;j++) {
		snprintf(buffer_c,64,"%d-cloud.pcd",j);
		PCD cloud(buffer);
		if (cloud.numPoints==0)
			break;
		Descriptor desc(&cloud);
		double lambda[3],v[9];
		desc.getPCA_XY(lambda,v);
		desc.setPCA(lambda,v);
		measurements.push_back(desc.principalLengths[0]); //length;
		measurements.push_back(desc.principalLengths[1]); //width;
		measurements.push_back(desc.principalLengths[2]); //height;
	}

	//set data
	res->numPoints = j;
	res->dimension = 3;
	res->data = new float[res->numPoints * res->dimension];
	for (size_t i=0;i<measurements.size();i++) {
		res->data[i] = measurements[i];
	}

	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5a8, %rsp            # imm = 0x5A8
movq %rdi, %rbx
movl $0x90, %edi
callq 0x2200
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, 0x28(%rsp)
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
callq 0x20c0
movslq %eax, %r14
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x20e0
leaq (%rsp,%r14), %r15
addq $0x1a1, %r15            # imm = 0x1A1
movb $0x2f, -0x1(%r15)
movq %rsp, %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0xd8(%rsp), %rbx
leaq 0x150(%rsp), %r12
xorl %r14d, %r14d
xorl %r13d, %r13d
movl $0x40, %esi
movq %r15, %rdi
leaq 0x2977(%rip), %rdx      # 0xb92c
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2340
movq %rbx, %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x3182
movl 0x138(%rsp), %ebp
testl %ebp, %ebp
je 0x90cf
movl $0x1, 0x30(%rsp)
movq %rbx, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movq %r12, %rdx
callq 0x919c
leaq 0x30(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movq %r12, %rdx
callq 0x92b6
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x903f
movsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x904c
movq %rsp, %rdi
leaq 0x48(%rsp), %rdx
callq 0x9af4
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x906d
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x907a
movq %rsp, %rdi
leaq 0x50(%rsp), %rdx
callq 0x9af4
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x909b
movsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x90a8
movq %rsp, %rdi
leaq 0x58(%rsp), %rdx
callq 0x9af4
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x90b7
callq 0x2260
movq %rbx, %rdi
callq 0x348e
testl %ebp, %ebp
je 0x90dc
incl %r13d
addl $0x3, %r14d
jmp 0x8fa6
leaq 0xd8(%rsp), %rdi
callq 0x348e
movq 0x28(%rsp), %rbx
movl %r13d, (%rbx)
movl $0x3, 0x4(%rbx)
movl %r14d, %edi
shlq $0x2, %rdi
callq 0x2040
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
movq (%rsp), %rdi
movq 0x8(%rsp), %rcx
subq %rdi, %rcx
je 0x9130
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsd2ss (%rdi,%rdx,8), %xmm0
movss %xmm0, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x911b
testq %rdi, %rdi
je 0x9142
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rax
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9159
movq %rax, %rbx
jmp 0x917d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x9170
callq 0x2260
leaq 0xd8(%rsp), %rdi
callq 0x348e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9193
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x23a0
nop