Buscar

KDtree - Arvore KD-tree, insere e Busca (NN Search) Em C

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

EDIIApKdtree/.dep.inc
# This code depends on make tool being used
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
EDIIApKdtree/ADTTree.h
/* 
 * File: ADTTree.h
 * Author: joao
 *
 * Created on 23 de Novembro de 2016, 19:36
 */
#ifndef ADTTREE_H
#define	ADTTREE_H
#include <string.h>
#include <math.h>
#ifdef	__cplusplus
extern "C" {
#endif
 struct Point {
 int pX, pY;
 char Tag[30];
 };
 typedef struct Point point;
 struct KDNode {
 point info;
 char discriminator;
 struct KDNode *esq, *dir;
 };
 typedef struct KDNode No;
 /*Tipo abstrato para pilha auxiliar*/
 struct Stack {
 No *info;
 struct Stack *prox;
 };
 typedef struct Stack st;
 /*------------------------------------------------------------------------*/
 Point criaP(int x, int y, char *info); //retorna uma nova estrutura do tipo point
 No* criaNo(Point p, char disc); //Retorna uma nova estrutura do tipo No da KDtree
 void init(No **raiz); //Inicializa uma estrtura do tipo KDtree
 void insereKD(No **raiz, Point p); //Insere um novo ponto na Arvore KDtreee
 int comparaPontos(Point pA, Point pB, char disc); //Copara duas estruturas Point dado seu discriminador
 void exibeNo(No *node);
 void inOrden(No *raiz);
 void showTree(No *raiz, int y, int x, int dist); //Exibe uma Arvore no formato de diagrama
 void busca(No *raiz, Point centro, int raio, No **p);
 int distEuclidiana(Point pA, Point pB);
 void initStack(st **pilha);
 void push(st **p, No *info);
 void pop(st **p, No **info);
 char isEmpty(st *st);
 long map(long x, long in_min, long in_max, long out_min, long out_max);
 void drawPoint(Point p);
 void drawPointAndLine(Point p);
 void plotGraph(No *raiz, No *pAux, Point centro);
 /*------------------------------------------------------------------------*/
 /* Retorna uma estrutura do tipo Point devidamente preenchida
 * Point criaP(int , int , char *)
 * x coordenada do ponto X
 * y coordenada do ponto Y
 * info Tag ou informação relativa oa ponto
 */
 Point criaP(int x, int y, char *info) {
 Point novo;
 novo.pX = x;
 novo.pY = y;
 strcpy(novo.Tag, info);
 return novo;
 }
 /*------------------------------------------------------------------------*/
 /* Retorna uma estrutura do tipo ponteiro No* para um novo no da KDtree
 * No* criaNo(Point, char )
 * p estrutura do tipo Point com as coordenasdas e a Tag do nó
 * disc Discriminador para insercao e comparacao (0 p/X e 1 p/Y)
 */
 No* criaNo(Point p, char disc) {
 No *np = (No*) malloc(sizeof (No));
 np->esq = np->dir = NULL;
 np->info = p;
 np->discriminator = disc;
 return np;
 }
 /* Inicializa uma estrutura do tipo KDtree
 * void init(No **)
 * raiz estrutura do tipo ponteiro *No
 */
 /*------------------------------------------------------------------------*/
 void init(No **raiz) {
 *raiz = NULL;
 }
 /* Insere um novo Ponto na arvore KDtree
 * void insereKD(No **, Point )
 * raiz estrutura do tipo ponteiro *No
 * p estutura do tipo Point com as Coordenadas e a Tag
 */
 /*------------------------------------------------------------------------*/
 void insereKD(No **raiz, Point p) {
 No *pAux, *pAnt = NULL;
 if (*raiz == NULL) {
 *raiz = criaNo(p, 0);
 } else {
 pAux = *raiz;
 while (pAux != NULL) {
 pAnt = pAux;
 if (comparaPontos(p, pAnt->info, pAnt->discriminator) != -1) {
 pAnt = pAux;
 pAux = pAux->dir;
 } else {
 pAnt = pAux;
 pAux = pAux->esq;
 }
 }
 if (comparaPontos(p, pAnt->info, pAnt->discriminator) != -1) {
 pAnt->dir = criaNo(p, !pAnt->discriminator);
 } else {
 pAnt->esq = criaNo(p, !pAnt->discriminator);
 }
 }
 }
 /*------------------------------------------------------------------------*/
 /* Exibe as informacoes de uma estrutura de um No
 * void exibeNo(No *)
 * node
 * p estutura do tipo Point com as Coordenadas e a Tag
 */
 void exibeNo(No *node) {
 printw("(%.2d,%.2d) -[%s]", node->info.pX, node->info.pY, node->info.Tag);
 }
 /*------------------------------------------------------------------------*/
 void inOrden(No *raiz) {
 if (raiz != NULL) {
 inOrden(raiz->esq);
 exibeNo(raiz);
 inOrden(raiz->dir);
 }
 }
 /*------------------------------------------------------------------------*/
 /* Retorna a comparacao de duas estruturas tipo Point dado seu Discriminador
 * int comparaPontos(Point, Point, char )
 * pA estrutura do tipo Point com as coordenasdas e a Tag 
 * pB estrutura do tipo Point com as coordenasdas e a Tag
 * disc Discriminador para comparacao (0 p/X e 1 p/Y)
 * Retorna 0 se pA==pB,1 Se pA>pB,-1 se Pa < pB
 */
 int comparaPontos(Point pA, Point pB, char disc) {
 if (disc == 1) {
 if (pA.pY == pB.pY)
 return 0;
 else {
 return (pA.pY > pB.pY) ? 1 : -1;
 }
 } else {
 if (pA.pX == pB.pX)
 return 0;
 else {
 return (pA.pX > pB.pX) ? 1 : -1;
 }
 }
 }
 /*------------------------------------------------------------------------*/
 /* Exibe uma arvore KDTree em Forma de Diagram de arvore
 * void showTree(No *, int , int , int )
 * raiz ponteiro para uma estrutura do tipo raiz 
 * y linha para inicio da impressao do diagrama
 * x coluna para inicio da impressao do diagrama
 * dist distancia de incremento das colunas entre os nós
 */
 void showTree(No *raiz, int y, int x, int dist) {
 if (raiz != NULL) {
 move(y, x);
 attron(COLOR_PAIR((14)));
 //printw("(%.2d,%.2d)", raiz->info.pX, raiz->info.pY);
 printw("[%s]", raiz->info.Tag);
 if (raiz->esq != NULL) {
 move(y + 1, x - dist / 2);
 printw("/");
 }
 if (raiz->dir != NULL) {
 move(y + 1, x + dist / 2);
 printw("\\");
 }
 showTree(raiz->esq, y + 2, x - dist, dist / 2);
 showTree(raiz->dir, y + 2, x + dist, dist / 2);
 }
 refresh();
 }
 /*------------------------------------------------------------------------*/
 void busca(No *raiz, Point centro, int raio, No **p) {
 int r;
 if (raiz != NULL) {
 r = distEuclidiana(raiz->info, centro);
 if (r < raio) {//ponto pertence a circumferência (disntancia menor ou igual ao raio)
 *p = raiz;
 } else {
 if (raiz->discriminator == 0) {//discriminador par (nivel par)
 if ((centro.pX - raio) < raiz->info.pX)
 busca(raiz->esq, centro, raio, &*p);
 else
 if ((centro.pX + raio) >= raiz->info.pX)
 busca(raiz->dir, centro, raio, &*p);
 } else {//discriminador impar (nivel impar)
 if ((centro.pY - raio) < raiz->info.pY)
 busca(raiz->esq, centro, raio, &*p);
 else
 if ((centro.pY + raio) >= raiz->info.pY)
 busca(raiz->dir, centro, raio, &*p);
 }
 }
 }
 }
/*----------------------------------------------------------------------------*/
 int distEuclidiana(Point pA, Point pB) {
 int ppa=(pA.pX - pB.pX),ppb=(pA.pY - pB.pY);
 ppa*=ppa;ppb*=ppb;
 return (int) sqrt(ppa+ppb);
 
 }
 /*------------------------------------------------------------------------*/
 void initStack(st **pilha) {
 *pilha = NULL;
 }
 /*------------------------------------------------------------------------*/
 char isEmpty(st *st) {
 return st == NULL;
 }
 /*------------------------------------------------------------------------*/
 void push(st **p, No *info) {
 st *nova = (st*) malloc(sizeof (st));
 nova->info = info;
 nova->prox = *p;
 *p = nova;
 }
 /*------------------------------------------------------------------------*/
 void pop(st **p, No **info) {
 st *aux;
 if (!isEmpty(*p)) {
 aux = *p;
 *info = (*p)->info;
 *p = (*p)->prox;
 free(aux);
 } else {
 *info = NULL;
 }
 }
 /*------------------------------------------------------------------------*/
 void listAsTable(No *raiz, int *cLine) {
 st *p;
 int line = 0;
 initStack(&p);
 push(&p, raiz);
 //move(2,2+line);
 //printf("TAG - ( X , Y )");
 while (!isEmpty(p)) {
 if (raiz != NULL) {
 pop(&p, &raiz);
 while (raiz != NULL) {
 push(&p, raiz);
 raiz = raiz->esq;
 }
 }
 pop(&p, &raiz);
 move(2 + line, 2);
 printw("[%s] - (%2d,%2d) ", raiz->info.Tag, raiz->info.pX, raiz->info.pY);
 line++;
 raiz = raiz->dir;
 if (raiz != NULL)
 push(&p, raiz);
 }
 *cLine += line;
 }
 /*------------------------------------------------------------------------*/
 void killKD(No **raiz) {
 if (*raiz != NULL) {
 killKD(&(*raiz)->esq);
 killKD(&(*raiz)->dir);
 free(*raiz);
 *raiz = NULL;
 }
 }
 /*------------------------------------------------------------------------*/
 void plotGraph(No *raiz, No *pAux, Point centro) {
 st *p;
 int line = 0;
 initStack(&p);
 push(&p, raiz);
 while (!isEmpty(p)) {
 if (raiz != NULL) {
 pop(&p, &raiz);
 while (raiz != NULL) {
 push(&p, raiz);
 raiz = raiz->esq;
 }
 }
 pop(&p, &raiz);
 drawPointAndLine(raiz->info);
 line++;
 raiz = raiz->dir;
 if (raiz != NULL)
 push(&p, raiz);
 }
 //*cLine += line;
 }
 /*------------------------------------------------------------------------*/
 void drawPoint(Point p) {
 long px = map(p.pX, 0, 100, 6, 77), py = map(p.pY, 0, 100, 2, 20);
 move(21 - py, px);
 printw("[%s] (%d,%d)", p.Tag, p.pX, p.pY);
 }
 /*------------------------------------------------------------------------*/
 void drawPointAndLine(Point p) {
 long px = map(p.pX, 0, 100, 6, 77), py = map(p.pY, 0, 100, 2, 20);
 move(21 - py, px + 1);
 printw("[%s] (%d,%d)", p.Tag, p.pX, p.pY);
 for (int i = (21 - py); i < 20; i++) {
 move(i, px);
 addch(ACS_VLINE);
 }
 for (int i = 6; i < px; i++) {
 move(21 - py, i);
 addch(ACS_HLINE);
 }
 move(21 - py, px);
 addch(ACS_URCORNER);
 move(21 - py, 6);
 addch(ACS_LTEE);
 move(20, px);
 addch(ACS_BTEE);
 }
 /*------------------------------------------------------------------------*/
 long map(long x, long in_min, long in_max, long out_min, long out_max) {
 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
 }
#ifdef	__cplusplus
}
#endif
#endif	/* ADTTREE_H */
EDIIApKdtree/Forms.h
/* 
 * File: Forms.h
 * Author: joao
 *
 * Created on 23 de Novembro de 2016, 17:27
 */
#ifndef FORMS_H
#define	FORMS_H
#include<time.h>
#include"boxCurses.h"
#include "ADTTree.h"
void stampDate(char mes[], char dia[], char ano[], char hora[], char minuto[], char segundo[], int op);
void formIsertPoint();
void clearDBComand();
#ifdef	__cplusplus
extern "C" {
#endif
 /*----------------------------------------------------------------------------*/
 void menuForm() {
 char m[4], d[3], a[5];
 char h[3], mm[3], s[5];
 attron(COLOR_PAIR((11)));
 move(0, 57);
 stampDate(m, d, a, h, mm, s, 1);
 refresh();
 move(22, 0);
 spc(80, 1);
 move(22, 20);
 printw("||");
 move(22, 26);
 printw("||");
 move(22, 44);
 printw("||");
 move(22, 68);
 printw("||");
 attron(COLOR_PAIR((14)));
 move(23, 0);
 spc(79, 1);
 displayMsgCenter(23, "Enter a valid UNIX comand line or type <HELP>.");
 refresh();
 }
}
/*----------------------------------------------------------------------------*/
void clearDBComand() {
 attron(COLOR_PAIR((17)));
 for (int i = 0; i < 22; i++) {
 move(i, 0);
 spc(80, 1);
 }
 refresh();
 menuForm();
 move(1, 1);
 refresh();
}
/*----------------------------------------------------------------------------*/
void formIsertPoint() {
 move(2, 20);
 attron(COLOR_PAIR((3)));
 printw("Point Tag - X Cord - Y Cord");
 for (int i = 0; i < 32; i++) {
 move(3, 20 + i);
 addch(ACS_HLINE);
 }
 attron(COLOR_PAIR((11)));
}
/*----------------------------------------------------------------------------*/
void getNewPoint(No **r) {
 Point p[20];
 int px, py, tlAux = 0;
 char flag = 1;
 do {
 move(3 + tlAux, 20);
 attron(COLOR_PAIR((3)));
 printw("[");
 move(3 + tlAux, 21);
 spc(30, 1);
 move(3 + tlAux, 51);
 attron(COLOR_PAIR((3)));
 printw("]");
 move(3 + tlAux, 21);
 flushinp();
 getstr(p[tlAux].Tag);
 if (p[tlAux].Tag[0] != 'q') {
 move(3 + tlAux, 58);
 scanw("%d", &px);
 move(3 + tlAux, 66);
 scanw("%d", &py);
 p[tlAux].pX = px;
 p[tlAux].pY = py;
 tlAux++;
 } else {
 flag = 0;
 tlAux--;
 }
 } while (flag && tlAux < 20);
 for (int i = 0; i < tlAux; i++) {
 insereKD(&*r, p[i]);
 }
 clearDBComand();
}
/*----------------------------------------------------------------------------*/
void stampDate(char mes[], char dia[], char ano[], char hora[], char minuto[], char segundo[], int op) {
 time_t currentTime;
 struct tm *timeinfo;
 char *diaSemana[] = {"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"};
 /* Pega a hora atual do sistema e a converte em uma estrutura tm. */
 time(&currentTime);
 timeinfo = localtime(&currentTime);
 /* Atualiza os valores dia, mes e ano da estrutura. */
 sprintf(dia, "%d", timeinfo->tm_mday);
 sprintf(mes, "%d", timeinfo->tm_mon + 1);
 sprintf(ano, "%d", timeinfo->tm_year + 1900);
 //strcpy(diaS, diaSemana[timeinfo->tm_wday]);
 sprintf(hora, "%d", timeinfo->tm_hour);
 sprintf(minuto, "%d", timeinfo->tm_min);
 sprintf(segundo, "%d", timeinfo->tm_sec);
 if (op == 1)
 printw("%s/%s/%s - %s:%s:%s ", dia, mes, ano, hora, minuto, segundo);
 refresh();
}
/*----------------------------------------------------------------------------*/
void formAbout() {
 char strMSg[18][79];
 strcpy(strMSg[0], "C++ LiKe LaRGe SHiT MaKeR KD-TRee BaSeD DaTa BaSe SYSTeM VeRSioN 1.0");
 strcpy(strMSg[1], "This Software is Licensed to:");
 strcpy(strMSg[2], "Unoeste FIPP Lab Estrutura de Dados II");
 strcpy(strMSg[3], "João André MarTins Dias e Silva");
 strcpy(strMSg[4], "RA:0261234021");
 strcpy(strMSg[5], "Copyright(c) João André Martins Dias e Silva (2016).All Rights Reservd. ");
 strcpy(strMSg[6], "This program is free software: you can redistribute it and/or modify ");
 strcpy(strMSg[7], "it under the terms of the GNU General Public License as published by ");
 strcpy(strMSg[8], "the Free Software Foundation, either version 3 of the License, ");
 strcpy(strMSg[9], "or any later version. ");
 strcpy(strMSg[10], "This program is distributed in the hope that it will be useful, ");
 strcpy(strMSg[11], "but WITHOUT ANY WARRANTY; without even the implied warranty of ");
 strcpy(strMSg[12], "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ");
 strcpy(strMSg[13], "GNU General Public License for more details. ");
 strcpy(strMSg[14], "You should have received a copy of the GNU General Public License ");
 strcpy(strMSg[15], "along with this program. If not, see <http://www.gnu.org/licenses/>. ");
 strcpy(strMSg[16], "Contact: ");
 strcpy(strMSg[17], "e-mail:jamdes@hotmail.com ");
 move(1, 0);
 clearDBComand();
 attron(COLOR_PAIR((14)));
 for (int i = 0; i < 18; i++)
 displayMsgCenter(i + 1, strMSg[i]);
 refresh();
}
/*----------------------------------------------------------------------------*/
void formSearch() {
 makeWindow(16, 4, 64, 18, 3);
 attron(COLOR_PAIR((15)));
 displayMsgCenter(5, "*** Coordenadas para Busca ***");
 move(7, 19);
 printw("Ponto Central: (x,y)");
 move(8, 19);
 printw("X:[ ] Y[ ]");
 move(10, 19);
 printw("Raio de busca:");
 move(11, 19);
 printw("R:[ ]");
}
/*----------------------------------------------------------------------------*/
void formShowSearch(No *p, Point Centro, int raio) {
 char msg[3][30];
 strcpy(msg[0], "[Resultado Encontrado!]");
 strcpy(msg[1], "[Resultado nao Encontrado!]");
 makeWindow(20, 12, 60, 16, 3);
 if (p != NULL) {
 attron(COLOR_PAIR((15)));
 displayMsgCenter(12, msg[0]);
 move(13, 21);
 attron(COLOR_PAIR((11)));
 spc(39, 1);
 move(13, 21);
 exibeNo(p);
 move(14, 21);
 spc(39, 1);
 move(14, 21);
 printw("Distancia entre [%s] e C(%2d,%2d) e [%2d]", p->info.Tag, Centro.pX, Centro.pY, distEuclidiana(p->info, Centro));
 } else {
 attron(COLOR_PAIR((15)));
 displayMsgCenter(12, msg[1]);
 move(13, 21);
 attron(COLOR_PAIR((11)));
 spc(39, 1);
 move(13, 21);
 printw("Nenhuma ocorrencia em R[%2d] p/ C(%2d,%2d)", raio, Centro.pX, Centro.pY);
 }
}
/*----------------------------------------------------------------------------*/
Point getParamSearch(int *raio) {
 int px, py;
 attron(COLOR_PAIR((15)));
 move(8, 22);
 scanw("%d", &px);
 move(8, 29);
 scanw("%d", &py);
 move(11, 22);
 scanw("%d", &*raio);
 return criaP(px, py, "Centro");
}
/*----------------------------------------------------------------------------*/
void drwBase(int MaxPx, int MaxPy, int step) {
 clearDBComand();
 attron(COLOR_PAIR((10)));
 move(2, 6);
 for (int i = 2; i < 21; i++) {
 move(i, 6);
 addch(ACS_VLINE);
 }
 move(20, 6);
 for (int i = 6; i < 78; i++) {
 move(20, i);
 addch(ACS_HLINE);
 }
 move(20, 6);
 addch(ACS_LLCORNER);
 attron(COLOR_PAIR((15)));
 move(0, 2);
 printw("(%2d,%2d)", 0, MaxPy);
 move(21, 70);
 printw("(%2d,%2d)", MaxPx, 0);
 attron(COLOR_PAIR((10)));
 move(8, 2);
 printw("^");
 move(9, 2);
 addch(ACS_VLINE);
 move(10, 2);
 addch(ACS_VLINE);
 move(11, 2);
 printw("Y");
 move(21, 35);
 printw("X --->");
 attron(COLOR_PAIR((15)));
}
/*----------------------------------------------------------------------------*/
#ifdef	__cplusplus
#endif
#endif	/* FORMS_H */
EDIIApKdtree/KDtree.cpp
/* 
 * File: KDtree.cpp
 * Author: joao
 *
 * Created on 23 de Novembro de 2016, 16:51
 */
#include <stdlib.h>
#include "Forms.h"
#include "ADTTree.h"
/*----------------------------------------------------------------------------*/
char buscaStr(char line[], char strSearch[]);
char isParameterComnad(char linha[]);
char login(char login[], char password[], int *line);
void splitLine(char line[], char tokens[], char auxStr[20][60], int *tl);
void commandIterpreter();
void performTest(No **raiz);
/*----------------------------------------------------------------------------*/
//using namespace std;
/*
 * 
 */
int main(int argc, char** argv) {
 //------------------
 initSetup();
 noecho();
 keypad(stdscr, TRUE);
 commandIterpreter();
 //------------------
 return 0;
}
void commandIterpreter() {
 int lineConsole = 1, raio;
 char strComando[30], userLogin[20], userPassword[9], userMachine[11],userCommand = -1;
 char mes[4], dia[3], ano[5], hora[3], minuto[3], segundo[5],end = 1;
 
 No *MainTree=NULL, *auxNode = NULL;
 Point pAux;
 
 strcpy(userMachine, "unixServer");
 echo();
 flushinp();
 formAbout();
 getch();
 clearDBComand();
 login(userLogin, userPassword, &lineConsole);
 while (end) {
 attron(COLOR_PAIR((14)));
 move(lineConsole++, 1);
 printw("%s@%s:~$", userLogin, userMachine);
 flushinp();
 getstr(strComando);
 userCommand = isParameterComnad(strComando);
 if (userCommand != -1) {
 switch (userCommand) {
 case 0:
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("createdb");
 if (MainTree == NULL)
 init(&MainTree);
 else {
 attron(COLOR_PAIR((14)));
 lineConsole++;
 move(lineConsole, 1);
 printw("Use kill to destroy the ramaining data in active database!");
 lineConsole++;
 }
 attron(COLOR_PAIR((14)));
 break;
 case 1:
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("insertdata");
 clearDBComand();
 formIsertPoint();
 getNewPoint(&MainTree);
 
 attron(COLOR_PAIR((14)));
 break;
 case 2:
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("list");
 attron(COLOR_PAIR((14)));
 if (MainTree == NULL) {
 lineConsole++;
 move(lineConsole, 1);
 printw("No data or active database in memory!");
 lineConsole++;
 } else {
 attron(COLOR_PAIR((14)));
 clearDBComand();
 listAsTable(MainTree, &lineConsole);
 lineConsole++;
 }
 break;
 case 3:
 attron(COLOR_PAIR((11)));
move(22, 1);
 printw("listastree");
 attron(COLOR_PAIR((14)));
 if (MainTree == NULL) {
 lineConsole++;
 move(lineConsole, 1);
 printw("No data or active database in memory!");
 lineConsole++;
 } else {
 attron(COLOR_PAIR((11)));
 clearDBComand();
 showTree(MainTree, 2, 40, 12);
 lineConsole++;
 }
 break;
 case 4:
 clearDBComand();
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("searchnear");
 attron(COLOR_PAIR((14)));
 formSearch();
 pAux = getParamSearch(&raio);
 //printw("<%d> (%d,%d)", raio, pAux.pX, pAux.pY);
 busca(MainTree, pAux, raio, &auxNode);
 formShowSearch(auxNode, pAux, raio);
 free(auxNode);
 auxNode = NULL;
 lineConsole = 17;
 break;
 case 5:
 killKD(&MainTree);
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("kill");
 attron(COLOR_PAIR((14)));
 break;
 case 6:
 attron(COLOR_PAIR((11)));
 clearDBComand();
 lineConsole = 1;
 move(22, 1);
 printw("clear");
 attron(COLOR_PAIR((14)));
 lineConsole = 1;
 break;
 case 7:
 clearDBComand();
 drwBase(100, 100, 100);
 plotGraph(MainTree,NULL,pAux);
 //drawPoint(criaP(100,100,"A"));
 flushinp();
 getch();
 break;
 case 8:
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("runtest");
 performTest(&MainTree);
 clearDBComand();
 
 attron(COLOR_PAIR((14)));
 break;
 case 9:
 attron(COLOR_PAIR((11)));
 move(22, 1);
 printw("exit");
 clearDBComand();
 end = 0;
 attron(COLOR_PAIR((14)));
 break;
 }
 move(0, 57);
 stampDate(mes, dia, ano, hora, minuto, segundo, 1);
 attron(COLOR_PAIR((14)));
 refresh();
 } else {
 move(lineConsole++, 1);
 printw("Comando ou nome de arquivo invalido!\n");
 userCommand = -1;
 attron(COLOR_PAIR((11)));
 move(0, 57);
 stampDate(mes, dia, ano, hora, minuto, segundo, 1);
 attron(COLOR_PAIR((14)));
 refresh();
 }
 move(0, 57);
 stampDate(mes, dia, ano, hora, minuto, segundo, 1);
 attron(COLOR_PAIR((14)));
 refresh();
 }
 refresh();
}
char isParameterComnad(char linha[]) {
 char tipo = -1;
 char tipos[10][12] = {"createdb", "insertdata", "list", "listasatree", "searchnear", "kill", "clear", "plotgraph","runtest","exit"};
 for (int i = 0; i < 10; i++)
 if (buscaStr(linha, tipos[i]))
 tipo = i;
 return tipo;
}
char buscaStr(char line[], char strSearch[]) {
 char auxL[40];
 char* busca = NULL;
 strcpy(auxL, line);
 busca = strstr(auxL, strSearch);
 return (busca != NULL);
}
char login(char login[], char password[], int *line) {
 int cont = 0;
 move(*line, 0);
 printw("login:");
 getstr(login);
 *line = *line + 1;
 move(*line, 0);
 printw("password:");
 noecho();
 while (cont < 8) {
 flushinp();
 password[cont++] = getch();
 move(*line, 9 + cont);
 printw("*");
 }
 flushinp();
 echo();
 password[cont] = '\0';
 *line = *line + 1;
 move(*line, 0);
 printw("login[%s] password:[%s]", login, password);
 *line = *line + 1;
}
/*----------------------------------------------------------------------------*/
/* splitLine By Joao Andre Martins copyleft C 2016
 * void splitLine(char[],char[],char[][],*int)
 * line =(linha original que se deseja quebrar em substrings
 * tokens =caracteres delimitadores das substrings
 * auxStr[20][30] vetor de strings, contem as substrings
 * tl =tamanho lógico do vetor de substrings, (numero de palavras)
 */
void splitLine(char line[], char tokens[], char auxStr[20][60], int *tl) {
 char *lineAux, *strBroke;
 int cont = 0;
 lineAux = line;
 strBroke = strtok(lineAux, tokens);
 while (strBroke != NULL) {
 strcpy(auxStr[cont++], strBroke);
 strBroke = strtok(NULL, tokens);
 }
 *tl = cont;
}
/*----------------------------------------------------------------------------*/
void performTest(No **raiz) {
 Point points[8];
 /*-----------------------------*/
 points[0] = criaP(50, 30, "A");
 points[1] = criaP(22, 63, "B");
 points[2] = criaP(80, 15, "C");
 points[3] = criaP(34, 10, "D");
 points[4] = criaP(10, 96, "E");
 points[5] = criaP(68, 45, "F");
 points[6] = criaP(53, 73, "G");
 points[7] = criaP(60, 88, "H");
 /*-----------------------------*/
 for (int i = 0; i < 8; i++)
 insereKD(&*raiz, points[i]);
}
EDIIApKdtree/Makefile
#
# There exist several targets which are by default empty and which can be 
# used for execution of your targets. These targets are usually executed 
# before and after some main targets. They are: 
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
# 
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
# 
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF}
name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment 
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# build tests
build-tests: .build-tests-post
.build-tests-pre:
# Add your pre 'build-tests' code here...
.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...
# run tests
test: .test-post
.test-pre: build-tests
# Add your pre 'test' code here...
.test-post: .test-impl
# Add your post 'test' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk
EDIIApKdtree/boxCurses.h
/* 
 * File: boxCurses.h
 * Author: joao
 * API de manipulação de tela atraves da biblioteca nccurses
 * Criaçao de molduras, definicao de cores ,exibição de mensagens
 * Created on 24 de Agosto de 2016, 19:03
 */
#ifndef BOXCURSES_H
#define	BOXCURSES_H
#include<ncurses.h>
#include<string.h>
#endif	/* BOXCURSES_H */
//--------------------
void initSetup();
void exitWin();
void makeWindow(int rowStart,int lineStart,int rowEnd,int lineEnd,int color);
void displayMsgCenter(int line,char mesg[]);
void spc(register int nSpcs,register int typeBlock);
//---------------------------------------------------------------------------
void displayMsgCenter(int line,char mesg[]){
 int row,col;
 getmaxyx(stdscr,row,col);
 move(line,(col-strlen(mesg))/2);
 printw("%s",mesg);
 refresh();
}
//----------------------------------------------------------------------------
void makeWindow(int rowStart,int lineStart,int rowEnd,int lineEnd,int color){
 attron(COLOR_PAIR((color)));
 move(lineStart,rowStart);
 addch(ACS_ULCORNER);
 move(lineStart,rowEnd);
 addch(ACS_URCORNER);
 move(lineEnd,rowStart);
 addch(ACS_LLCORNER);
 move(lineEnd,rowEnd);
 addch(ACS_LRCORNER);
 for(int i=lineStart+1;i<lineEnd;i++){
 move(i,rowStart);
 addch(ACS_VLINE);
 move(i,rowEnd);
 addch(ACS_VLINE);
 }
 for(int i=rowStart+1;i<rowEnd;i++){
 move(lineStart,i);
 addch(ACS_HLINE);
 move(lineEnd,i);
 addch(ACS_HLINE);
 }
 refresh();
}
//--------------------
void spc(register int nSpcs,register int typeBlock){
 for(register int i=0;i<nSpcs;i++)
 if (typeBlock==0)
 addch(ACS_CKBOARD);
 else
 printw(" ");
refresh();
}
//--------------------
void initSetup(){
 initscr();
 start_color();
 use_default_colors();
 init_pair(1,COLOR_WHITE,COLOR_BLUE);
 init_pair(2,COLOR_BLUE,COLOR_WHITE);
 init_pair(3,COLOR_BLUE,COLOR_BLACK);
 init_pair(4,COLOR_BLUE,COLOR_BLUE);
 init_pair(5,COLOR_CYAN,COLOR_BLUE);
 init_pair(6,COLOR_BLUE,COLOR_CYAN);
 init_pair(7,COLOR_CYAN,COLOR_CYAN);
 init_pair(8,COLOR_BLACK,COLOR_WHITE);
 init_pair(9,COLOR_WHITE,COLOR_WHITE);
 init_pair(10,COLOR_WHITE,COLOR_BLACK);
 init_pair(11,COLOR_WHITE,COLOR_RED);
 init_pair(12,COLOR_RED,COLOR_BLUE);
 init_pair(13,COLOR_RED,COLOR_BLACK);
 init_pair(14,COLOR_GREEN,COLOR_BLACK);
 init_pair(15,COLOR_YELLOW,COLOR_BLACK);
 init_pair(16,COLOR_GREEN,COLOR_BLUE);
 init_pair(17,COLOR_BLACK,COLOR_BLACK);
 init_pair(18,COLOR_RED,COLOR_RED);
 init_pair(19,COLOR_YELLOW,COLOR_RED);
 init_pair(20,COLOR_YELLOW,COLOR_BLUE);
 init_pair(21,COLOR_YELLOW,COLOR_BLACK);
 init_pair(22,COLOR_BLACK,COLOR_YELLOW);
 init_pair(23,COLOR_RED,COLOR_WHITE);
 init_pair(24,COLOR_WHITE,COLOR_CYAN);
}
//--------------------
void exitWin(){
 endwin();
}
EDIIApKdtree/build/Debug/GNU-Linux-x86/KDtree.o
EDIIApKdtree/build/Debug/GNU-Linux-x86/KDtree.o.d
build/Debug/GNU-Linux-x86/KDtree.o: KDtree.cpp Forms.h boxCurses.h \
 ADTTree.h
Forms.h:
boxCurses.h:
ADTTree.h:
EDIIApKdtree/dist/Debug/GNU-Linux-x86/ediiapkdtree
EDIIApKdtree/nbproject/Makefile-Debug.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux-x86
CND_DLIB_EXT=so
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
	${OBJECTDIR}/KDtree.o
# C Compiler Flags
CFLAGS=-lcurses
# CC Compiler Flags
CCFLAGS=-lcurses
CXXFLAGS=-lcurses
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
	"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree: ${OBJECTFILES}
	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/KDtree.o: KDtree.cpp 
	${MKDIR} -p ${OBJECTDIR}
	${RM} "$@.d"
	$(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/KDtree.o KDtree.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
	${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
EDIIApKdtree/nbproject/Makefile-Release.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux-x86
CND_DLIB_EXT=so
CND_CONF=Release
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
	${OBJECTDIR}/KDtree.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
	"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree: ${OBJECTFILES}
	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/KDtree.o: KDtree.cpp 
	${MKDIR} -p ${OBJECTDIR}
	${RM} "$@.d"
	$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/KDtree.o KDtree.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
	${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
EDIIApKdtree/nbproject/Makefile-impl.mk
# 
# Generated Makefile - do not edit! 
# 
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=EDIIApKdtree
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release 
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber 
.clobber-impl: .clobber-pre .depcheck-impl
	@#echo "=> Running $@..."
	for CONF in ${ALLCONFS}; \
	do \
	 "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
	done
# all 
.all-impl: .all-pre .depcheck-impl
	@#echo "=> Running $@..."
	for CONF in ${ALLCONFS}; \
	do \
	 "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
	done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
	@echo "# This code depends on make tool being used" >.dep.inc
	@if [ -n "${MAKE_VERSION}" ]; then \
	 echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
	 echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
	 echo "include \$${DEPFILES}" >>.dep.inc; \
	 echo "endif" >>.dep.inc; \
	else \
	 echo ".KEEP_STATE:" >>.dep.inc; \
	 echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
	fi
# configuration validation
.validate-impl:
	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
	then \
	 echo ""; \
	 echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
	 echo "See 'make help' for details."; \
	 echo "Current directory: " `pwd`; \
	 echo ""; \
	fi
	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
	then \
	 exit 1; \
	fi
# help
.help-impl: .help-pre
	@echo "This makefile supports the following configurations:"
	@echo " ${ALLCONFS}"
	@echo ""
	@echo "and the following targets:"
	@echo " build (default target)"
	@echo " clean"
	@echo " clobber"
	@echo " all"
	@echo " help"
	@echo ""
	@echo "Makefile Usage:"
	@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
	@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
	@echo " make [SUB=no] clobber"
	@echo " make [SUB=no] all"
	@echo " make help"
	@echo ""
	@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
	@echo " also build subprojects."
	@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
	@echo " also clean subprojects."
	@echo "Target 'clobber' will remove all built files from all configurations and,"
	@echo " unless 'SUB=no', also from subprojects."
	@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
	@echo " also build subprojects."
	@echo "Target 'help' prints this message."
	@echo ""
EDIIApKdtree/nbproject/Makefile-variables.mk
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=GNU-Linux-x86
CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux-x86
CND_ARTIFACT_NAME_Debug=ediiapkdtree
CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/ediiapkdtree
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package
CND_PACKAGE_NAME_Debug=ediiapkdtree.tar
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/ediiapkdtree.tar
# Release configuration
CND_PLATFORM_Release=GNU-Linux-x86
CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux-x86
CND_ARTIFACT_NAME_Release=ediiapkdtree
CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux-x86/ediiapkdtree
CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package
CND_PACKAGE_NAME_Release=ediiapkdtree.tar
CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/ediiapkdtree.tar
#
# include compiler specific variables
#
# dmake command
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
	(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
#
# gmake command
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
#
include nbproject/private/Makefile-variables.mk
EDIIApKdtree/nbproject/Package-Debug.bash
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=GNU-Linux-x86
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
CND_DLIB_EXT=so
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
OUTPUT_BASENAME=ediiapkdtree
PACKAGE_TOP_DIR=ediiapkdtree/
# Functions
function checkReturnCode
{
 rc=$?
 if [ $rc != 0 ]
 then
 exit $rc
 fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
 mkdir -p "$1"
 checkReturnCode
 if [ "$2" != "" ]
 then
 chmod $2 "$1"
 checkReturnCode
 fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
 cp "$1" "$2"
 checkReturnCode
 if [ "$3" != "" ]
 then
 chmod $3 "$2"
 checkReturnCode
 fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/ediiapkdtree/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ediiapkdtree.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ediiapkdtree.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${NBTMPDIR}
EDIIApKdtree/nbproject/Package-Release.bash
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=GNU-Linux-x86
CND_CONF=Release
CND_DISTDIR=dist
CND_BUILDDIR=build
CND_DLIB_EXT=so
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ediiapkdtree
OUTPUT_BASENAME=ediiapkdtree
PACKAGE_TOP_DIR=ediiapkdtree/
# Functions
function checkReturnCode
{
 rc=$?
 if [ $rc != 0 ]
 then
 exit $rc
 fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
 mkdir -p "$1"
 checkReturnCode
 if [ "$2" != "" ]
 then
 chmod $2 "$1"
 checkReturnCode
 fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
 cp "$1" "$2"
 checkReturnCode
 if [ "$3" != "" ]
 then
 chmod $3 "$2"
 checkReturnCode
 fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/ediiapkdtree/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ediiapkdtree.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ediiapkdtree.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${NBTMPDIR}
EDIIApKdtree/nbproject/configurations.xml
 
 
 
 ADTTree.h
 Forms.h
 boxCurses.h
 
 
 KDtree.cpp
 
 
 
 
 
 
 Makefile
 
 
 Makefile
 
 
 
 default
 true
 false
 
 
 
 -lcurses
 
 
 -lcurses
 
 
 
 
 
 
 
 
 
 
 
 
 
 default
 true
 false
 
 
 
 5
 
 
 5
 
 
 5
 
 
 5
 
 
 
 
 
 
 
 
 
 
 
 
EDIIApKdtree/nbproject/private/Makefile-variables.mk
#
# Generated - do not edit!
#
# NOCDDL
#
# Debug configuration
# Release configuration
EDIIApKdtree/nbproject/private/configurations.xml
 
 Makefile
 
 
 
 localhost
 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 gdb
 
 
 
 "${OUTPUT_PATH}"
 
 "${OUTPUT_PATH}"
 
 true
 1
 2
 0
 
 
 
 
 
 
 localhost
 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 gdb
 
 
 
 "${OUTPUT_PATH}"
 
 "${OUTPUT_PATH}"
 
 true
 0
 0
 
 
 
 
 
EDIIApKdtree/nbproject/private/launcher.properties
# Launchers File syntax:
#
# [Must-have property line] 
# launcher1.runCommand=<Run Command>
# [Optional extra properties] 
# launcher1.displayName=<Display Name, runCommand by default>
# launcher1.buildCommand=<Build Command, Build Command specified in project properties by default>
# launcher1.runDir=<Run Directory, ${PROJECT_DIR} by default>
# launcher1.symbolFiles=<Symbol Files loaded by debugger, ${OUTPUT_PATH} by default>
# launcher1.env.<Environment variable KEY>=<Environment variable VALUE>
# (If this value is quoted with ` it is handled as a native command which execution result will become the value)
# [Common launcher properties]
# common.runDir=<Run Directory>
# (This value is overwritten by a launcher specific runDir value if the latter exists)
# common.env.<Environment variable KEY>=<Environment variable VALUE>
# (Environment variables from common launcher are merged with launcher specific variables)
# common.symbolFiles=<Symbol Files loaded by debugger>
# (This value is overwritten by a launcher specific symbolFiles value if the latter exists)
#
# In runDir, symbolFiles and env fields you can use these macroses:
# ${PROJECT_DIR} - project directory absolute path
# ${OUTPUT_PATH} - linker output path (relative to project directory path)
# ${OUTPUT_BASENAME}- linker output filename
# ${TESTDIR} - test files directory (relative to project directory path)
# ${OBJECTDIR} - object files directory (relative to project directory path)
# ${CND_DISTDIR} - distribution directory (relative to project directory path)
# ${CND_BUILDDIR} - build directory (relative to project directory path)
# ${CND_PLATFORM} - platform name
# ${CND_CONF} - configuration name
# ${CND_DLIB_EXT} - dynamic library extension
#
# All the project launchers must be listed in the file!
#
# launcher1.runCommand=...
# launcher2.runCommand=...
# ...
# common.runDir=...
# common.env.KEY=VALUE
# launcher1.runCommand=<type your run command here>
EDIIApKdtree/nbproject/private/private.xml
 
 
 1
 0
 
 
 
 
 
EDIIApKdtree/nbproject/project.xml
 
 org.netbeans.modules.cnd.makeproject
 
 
 EDIIApKdtree
 
 cpp
 h
 UTF-8
 
 
 
 
 Debug
 1
 
 
 Release
 1
 
 
 
 false
 
 
 
KDTree/.dep.inc
# This code depends on make tool being used
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
KDTree/ADTKDTree.h
/* 
 * File: ADTKDTree.h
 * Author: joao
 *
 * Created on 10 de Novembro de 2016, 22:31
 */
#ifndef ADTKDTREE_H
#define	ADTKDTREE_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef	__cplusplus
extern "C" {
#endif
 /*Tipo abstrato para Coordenada cartesiana*/
 struct Point {
 int pX, pY;
 char Tag[30];
 };
 typedef struct Point point;
 /*Tipo abstrato para No da KDtreer*/
 struct KDNode {
 point info;
 char discriminator;
 struct KDNode *esq, *dir;
 };
 typedef struct KDNode No;
 /*Tipo abstrato para pilha auxiliar*/
 struct Stack {
 No *info;
 struct Stack *prox;
 };
 typedef struct Stack st;
 /*------------------------------------------------------------------------*/
 Point criaP(int x, int y, char *info);
 No* criaNo(Point p, char disc);
 void init(No **raiz);
 void insereKD(No **raiz, Point p);
 int comparaPontos(Point pA, Point pB, char disc);
 void exibeNo(No *node);
 void inOrden(No *raiz);
 float distEuclidiana(Point pA, Point pB);
 void initStack(st **pilha);
 void push(st **p, No *info);
 void pop(st **p, No **info);
 char isEmpty(st *st);
 /*------------------------------------------------------------------------*/
 /* Retorna uma estrutura do tipo Point devidamente preenchida
 * Point criaP(int , int , char *)
 * x coordenada do ponto X
 * y coordenada do ponto Y
 * info Tag ou informação relativa oa ponto
 */
 Point criaP(int x, int y, char *info) {
 Point novo;
 novo.pX = x;
 novo.pY = y;
 strcpy(novo.Tag, info);
 return novo;
 }
 /*------------------------------------------------------------------------*/
 /* Retorna uma estrutura do tipo ponteiro
No* para um novo no da KDtree
 * No* criaNo(Point, char )
 * p estrutura do tipo Point com as coordenasdas e a Tag do nó
 * disc Discriminador para insercao e comparacao (0 p/X e 1 p/Y)
 */
 No* criaNo(Point p, char disc) {
 No *np = (No*) malloc(sizeof (No));
 np->esq = np->dir = NULL;
 np->info = p;
 np->discriminator = disc;
 return np;
 }
 /* Inicializa uma estrutura do tipo KDtree
 * void init(No **)
 * raiz estrutura do tipo ponteiro *No
 */
 /*------------------------------------------------------------------------*/
 void init(No **raiz) {
 *raiz = NULL;
 }
 /*------------------------------------------------------------------------*/
 /* Classifica no da arvore como folha ou nao folha
 * no estrutura do tipo ponteiro *No
 * retorna 1 se no folha e 0 não folha
 */
 char eFolha(No *no) {
 return (no->dir == NULL && no->esq == NULL);
 }
 /*------------------------------------------------------------------------*/
 /* Insere um novo Ponto na arvore KDtree
 * void insereKD(No **, Point )
 * raiz estrutura do tipo ponteiro *No
 * p estutura do tipo Point com as Coordenadas e a Tag
 */
 void insereKD(No **raiz, Point p) {
 No *pAux, *pAnt = NULL;
 if (*raiz == NULL) {
 *raiz = criaNo(p, 0);
 } else {
 pAux = *raiz;
 while (pAux != NULL) {
 pAnt = pAux;
 if (comparaPontos(p, pAnt->info, pAnt->discriminator) != -1) {
 pAnt = pAux;
 pAux = pAux->dir;
 } else {
 pAnt = pAux;
 pAux = pAux->esq;
 }
 }
 if (comparaPontos(p, pAnt->info, pAnt->discriminator) != -1) {
 pAnt->dir = criaNo(p, !pAnt->discriminator);
 } else {
 pAnt->esq = criaNo(p, !pAnt->discriminator);
 }
 }
 }
 /*------------------------------------------------------------------------*/
 /* Exibe as informacoes de uma estrutura de um No
 * void exibeNo(No *)
 * node
 * p estutura do tipo Point com as Coordenadas e a Tag
 */
 void exibeNo(No *node) {
 printf("(%.2d,%.2d) -[%s]\n", node->info.pX, node->info.pY, node->info.Tag);
 }
 /*------------------------------------------------------------------------*/
 void inOrden(No *raiz) {
 if (raiz != NULL) {
 inOrden(raiz->esq);
 exibeNo(raiz);
 inOrden(raiz->dir);
 }
 }
 /*------------------------------------------------------------------------*/
 /* Retorna a comparacao de duas estruturas tipo Point dado seu Discriminador
 * int comparaPontos(Point, Point, char )
 * pA estrutura do tipo Point com as coordenasdas e a Tag 
 * pB estrutura do tipo Point com as coordenasdas e a Tag
 * disc Discriminador para comparacao (0 p/X e 1 p/Y)
 * Retorna 0 se pA==pB,1 Se pA>pB,-1 se Pa < pB
 */
 int comparaPontos(Point pA, Point pB, char disc) {
 if (disc == 1) {
 if (pA.pY == pB.pY)
 return 0;
 else {
 return (pA.pY > pB.pY) ? 1 : -1;
 }
 } else {
 if (pA.pX == pB.pX)
 return 0;
 else {
 return (pA.pX > pB.pX) ? 1 : -1;
 }
 }
 }
 /*------------------------------------------------------------------------*/
 /* Busca o ponto mais proximo para uma determinada chave
 * void busca(No *,Point ,int,No **)
 * raiz - ponteiro para a raiz da arvore KDtree
 * chave- estrutura do tipo Point com as coordenasdas da busca
 * r - valor do raio para a partir do ponto chave
 * p - no da arvore com o conteudo da busca == NULL chave não encontrada
 */
 void busca(No *raiz, Point centro, int raio, float menor, No **p) {
 float r;
 // printf("%d,%d",raiz->info.pX,raiz->info.pY);
 if (raiz != NULL) {
 
 r = distEuclidiana(raiz->info, centro);
 if (r < raio) {//ponto pertence a circumferência (disntancia menor ou igual ao raio)
 *p = raiz;
 } else {
 //menor = (r < menor) ? r : menor;
 if (raiz->discriminator == 0) {//discriminador par nivel par
 if ((centro.pX - raio) < raiz->info.pX)
 busca(raiz->esq, centro, raio, menor, &*p);
 else
 if ((centro.pX + raio) >= raiz->info.pX)
 busca(raiz->dir, centro, raio, menor, &*p);
 } else {//discriminador impar (nivel impar)
 if ((centro.pY - raio) < raiz->info.pY)
 busca(raiz->esq, centro, raio, menor, &*p);
 else
 if ((centro.pY + raio) >= raiz->info.pY)
 busca(raiz->dir, centro, raio, menor, &*p);
 }
 }
 }
 }
 /*----------------------------------------------------------------------------*/
 /* Retorna a distância euclidiana entre dois pontos
 float distEuclidiana(Point, Point)
 * pA- estrutura do tipo Point com as coordenasdas do ponto a ser testado
 * pB -estrutura do tipo Point com as coordenasdas do centro do circulo
 */
 float distEuclidiana(Point pA, Point pB) {
 return sqrt(pow((pA.pX - pB.pX), 2) + pow((pA.pY - pB.pY), 2));
 }
 /*----------------------------------------------------------------------------*/
 void initStack(st **pilha) {
 *pilha = NULL;
 }
 /*------------------------------------------------------------------------*/
 char isEmpty(st *st) {
 return st == NULL;
 }
 /*------------------------------------------------------------------------*/
 void push(st **p, No *info) {
 st *nova = (st*) malloc(sizeof (st));
 nova->info = info;
 nova->prox = *p;
 *p = nova;
 }
 /*------------------------------------------------------------------------*/
 void pop(st **p, No **info) {
 st *aux;
 if (!isEmpty(*p)) {
 aux = *p;
 *info = (*p)->info;
 *p = (*p)->prox;
 free(aux);
 } else {
 *info = NULL;
 }
 }
 /*------------------------------------------------------------------------*/
 void listAsTable(No *raiz) {
 st *p;
 int line = 0;
 initStack(&p);
 push(&p, raiz);
 //move(2,2+line);
 //printf("TAG - ( X , Y )");
 while (!isEmpty(p)) {
 if (raiz != NULL) {
 pop(&p, &raiz);
 while (raiz != NULL) {
 push(&p, raiz);
 raiz = raiz->esq;
 }
 }
 pop(&p, &raiz);
 //move(2,2+line);
 // printw("[%s] - (%2d,%2d) ",raiz->info.Tag, raiz->info.pX,raiz->info.pY);
 line++;
 raiz = raiz->dir;
 if (raiz != NULL)
 push(&p, raiz);
 }
 }
/*----------------------------------------------------------------------------*/
 void buscann(No *raiz, Point centro, int raio, float menor, No **p) {
 float r;
 Point cMenor,cMaior;
 cMenor.pX=(raiz->info.pX-raio); cMenor.pY=(raiz->info.pY-raio);
 cMaior.pX=(raiz->info.pX+raio); cMaior.pY=(raiz->info.pY+raio);
 
 if (raiz != NULL) {
 r = distEuclidiana(raiz->info, centro);
 if (r < raio) {//ponto pertence a circumferência (disntancia menor ou igual ao raio)
 *p = raiz;
 } else
{
 //menor = (r < menor) ? r : menor;
 if (raiz->discriminator == 0) {//discriminador par nivel par
 if ((centro.pX - r) < raiz->info.pX)
 busca(raiz->esq, centro, raio, menor, &*p);
 else
 if ((centro.pX + r) >= raiz->info.pX)
 busca(raiz->dir, centro, raio, menor, &*p);
 } else {//discriminador impar (nivel impar)
 if ((centro.pY - r) < raiz->info.pY)
 busca(raiz->esq, centro, raio, menor, &*p);
 else
 if ((centro.pY + r) >= raiz->info.pY)
 busca(raiz->dir, centro, raio, menor, &*p);
 }
 }
 }
 }
#ifdef	__cplusplus
}
#endif
#endif	/* ADTKDTREE_H */
KDTree/Makefile
#
# There exist several targets which are by default empty and which can be 
# used for execution of your targets. These targets are usually executed 
# before and after some main targets. They are: 
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
# 
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
# 
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment 
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# build tests
build-tests: .build-tests-post
.build-tests-pre:
# Add your pre 'build-tests' code here...
.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...
# run tests
test: .test-post
.test-pre: build-tests
# Add your pre 'test' code here...
.test-post: .test-impl
# Add your post 'test' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk
KDTree/build/Debug/GNU-Linux-x86/main.o
KDTree/build/Debug/GNU-Linux-x86/main.o.d
build/Debug/GNU-Linux-x86/main.o: main.cpp ADTKDTree.h
ADTKDTree.h:
KDTree/dist/Debug/GNU-Linux-x86/kdtree
KDTree/main.cpp
/* 
 * File: main.cpp
 * Author: joao
 *
 * Created on 10 de Novembro de 2016, 22:30
 */
#include"ADTKDTree.h"
/*
 * 
 */
int main(int argc, char** argv) {
 No *arvore, *aux = NULL;
 Point points[9];
 char resp[20], disc;
 init(&arvore);
 points[0] = criaP(50, 30, "A");
 points[1] = criaP(22, 63, "B");
 points[2] = criaP(80, 15, "C");
 points[3] = criaP(34, 10, "D");
 points[4] = criaP(10, 96, "E");
 points[5] = criaP(68, 45, "F");
 points[6] = criaP(53, 73, "G");
 points[7] = criaP(60, 88, "H");
 points[8] = criaP(70, 60, "i");
 
 for( int i=0;i<8;i++)
 insereKD(&arvore, points[i]);
 // inOrden(arvore);
 for( int i=1;i<20;i++){
 busca(arvore, points[8],i ,0, &aux);
 if (aux != NULL) {
 printf("--------------------------\n");
 exibeNo(aux);
 printf("\n--------------------------");
 } else
 printf("\nNao encontrado ");
 }
}
KDTree/nbproject/Makefile-Debug.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux-x86
CND_DLIB_EXT=so
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
	${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
	"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree: ${OBJECTFILES}
	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp 
	${MKDIR} -p ${OBJECTDIR}
	${RM} "$@.d"
	$(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
	${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
KDTree/nbproject/Makefile-Release.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux-x86
CND_DLIB_EXT=so
CND_CONF=Release
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
	${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
	"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree: ${OBJECTFILES}
	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp 
	${MKDIR} -p ${OBJECTDIR}
	${RM} "$@.d"
	$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
	${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
KDTree/nbproject/Makefile-impl.mk
# 
# Generated Makefile - do not edit! 
# 
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=KDTree
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release 
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber 
.clobber-impl: .clobber-pre .depcheck-impl
	@#echo "=> Running $@..."
	for CONF in ${ALLCONFS}; \
	do \
	 "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
	done
# all 
.all-impl: .all-pre .depcheck-impl
	@#echo "=> Running $@..."
	for CONF in ${ALLCONFS}; \
	do \
	 "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
	done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
	@#echo "=> Running $@... Configuration=$(CONF)"
	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
	@echo "# This code depends on make tool being used" >.dep.inc
	@if [ -n "${MAKE_VERSION}" ]; then \
	 echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
	 echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
	 echo "include \$${DEPFILES}" >>.dep.inc; \
	 echo "endif" >>.dep.inc; \
	else \
	 echo ".KEEP_STATE:" >>.dep.inc; \
	 echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
	fi
# configuration validation
.validate-impl:
	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
	then \
	 echo ""; \
	 echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
	 echo "See 'make help' for details."; \
	 echo "Current directory: " `pwd`; \
	 echo ""; \
	fi
	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
	then \
	 exit 1; \
	fi
# help
.help-impl: .help-pre
	@echo "This makefile supports the following configurations:"
	@echo " ${ALLCONFS}"
	@echo ""
	@echo "and the following targets:"
	@echo " build (default target)"
	@echo " clean"
	@echo " clobber"
	@echo " all"
	@echo " help"
	@echo ""
	@echo "Makefile Usage:"
	@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
	@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
	@echo " make [SUB=no] clobber"
	@echo " make [SUB=no] all"
	@echo " make help"
	@echo ""
	@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
	@echo " also build subprojects."
	@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
	@echo " also clean subprojects."
	@echo "Target 'clobber' will remove all built files from all configurations and,"
	@echo " unless 'SUB=no', also from subprojects."
	@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
	@echo " also build subprojects."
	@echo "Target 'help' prints this message."
	@echo ""
KDTree/nbproject/Makefile-variables.mk
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=GNU-Linux-x86
CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux-x86
CND_ARTIFACT_NAME_Debug=kdtree
CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/kdtree
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package
CND_PACKAGE_NAME_Debug=kdtree.tar
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/kdtree.tar
# Release configuration
CND_PLATFORM_Release=GNU-Linux-x86
CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux-x86
CND_ARTIFACT_NAME_Release=kdtree
CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux-x86/kdtree
CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package
CND_PACKAGE_NAME_Release=kdtree.tar
CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/kdtree.tar
#
# include compiler specific variables
#
# dmake command
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
	(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
#
# gmake command
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
#
include nbproject/private/Makefile-variables.mk
KDTree/nbproject/Package-Debug.bash
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=GNU-Linux-x86
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
CND_DLIB_EXT=so
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/kdtree
OUTPUT_BASENAME=kdtree
PACKAGE_TOP_DIR=kdtree/
# Functions
function checkReturnCode
{
 rc=$?
 if [ $rc != 0 ]
 then
 exit $rc
 fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
 mkdir -p "$1"
 checkReturnCode
 if [ "$2" != "" ]
 then
 chmod $2 "$1"
 checkReturnCode
 fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
 cp "$1" "$2"
 checkReturnCode
 if [ "$3" != "" ]
 then
 chmod $3 "$2"
 checkReturnCode
 fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Continue navegando