Node* init_tree(float radius, float height, float fac1, float fac2) // fac1 percenatge of the top and trunck of the tree, fac3 radius { Node *head = new Node[3]; //------------- //memory manage head->gar=garb; garb=head; //------------- mat4 m(1.0f); head[0] = Node(m,blank,NULL,&head[1]); m = Translate(0,0,fac1*height); head[1] = Node(m,blank,&head[2], tree_top(4,fac2*radius,(1.0f-fac1)*height ,mat4(1.0))); m = Translate(0,0,0); head[2] = Node(m,blank,NULL, tree_trunk(50,radius,0.5f*height ,mat4(1.0))); return head; // head->sibling = tree_top(90, 0.9, 3.0, Translate(0,0,1.5)); // head->sibling->sibling = tree_trunk(90, 0.3, 3.0, Translate(0,0,0.0)); }
/* * routine that parses the valueset part of a ldapset boundary condition * returns a three structure with the individual elements */ scnode_t * scnode_get(octet_t * op, spocp_result_t * rc) { char *cp, *sp, c, in[32]; scnode_t *psc = 0, *nsc; int d, striprdn=0; *rc = 0; memset( in, 0, 32 ); if (op == 0 || op->len == 0) return 0; for( sp = op->val ; *sp == ' '; sp++) ; for ( ; *sp && (*sp != '}' && *sp != ')') ;) { #ifdef AVLUS traceLog(LOG_DEBUG,"Next: %s",sp); #endif switch (*sp) { case '&': case '|': nsc = scnode_new(2); *(nsc->str) = *sp; psc = tree_top(psc); nsc->right = psc; psc->up = nsc; psc = nsc; sp++; break; case '/': case '%': case '$': if (psc == 0) { /* can't be */ *rc = SC_SYNTAXERROR; return 0; } nsc = scnode_new(2); *(nsc->str) = *sp; ++sp; psc = tree_top(psc); nsc->right = psc; psc->up = nsc; psc = nsc; break; case '(': case '{': nsc = scnode_new(3); nsc->str[0] = *sp; if (*sp == '(') nsc->str[1] = ')'; else { nsc->str[1] = '}'; cp = find_balancing( sp+1, '{', '}' ); #ifdef AVLUS traceLog(LOG_DEBUG,"Find balancin in: %s",sp+1); traceLog(LOG_DEBUG,"Find balancin out: %s",cp); #endif if (cp == NULL) { traceLog(LOG_ERR,"Could not find balancing '}' at \"%s\"", sp); *rc = SC_SYNTAXERROR; return 0; } striprdn = 0; cp++; while( *cp == '.' && *(cp+1) == '.' ) { striprdn++; cp += 2; if (*cp == '/' || *cp == '$' \ || *cp == '%') { cp++; } } #ifdef AVLUS traceLog(LOG_DEBUG,"striprdn: %d",striprdn); #endif nsc->striprdn = striprdn; } sp++; while(*sp == ' ') sp++; op->len -= (sp - op->val); op->val = sp; nsc->right = scnode_get(op, rc); if (*rc) { scnode_free(nsc); scnode_free(tree_top(psc)); return 0; } sp = op->val; #ifdef AVLUS traceLog(LOG_DEBUG,"\"%s\"", sp); #endif if ( *sp == '.' && *(sp+1) == '.' ) { sp += 2; while ( *sp == '/' && *(sp+1) == '.' \ && *(sp+2) == '.') { sp += 3; } } #ifdef AVLUS traceLog(LOG_DEBUG,"skipped to \"%s\"", sp ); #endif if (psc) { psc->left = nsc; nsc->up = psc; } else psc = nsc; break; case '\\': nsc = scnode_new(3); nsc->str[0] = *sp; nsc->str[1] = *++sp; if (psc) { psc->left = nsc; nsc->up = psc; } else psc = nsc; ++sp; break; case '"': case '<': default: /* * NULL Strings, not allowed */ #ifdef AVLUS traceLog(LOG_DEBUG, "A string: \"%s\"", sp); #endif if (( *sp == '"' && *(sp+1) == '"') || (*sp == '<' && *(sp+1) == '>')) { scnode_free(tree_top(psc)); *rc = SC_SYNTAXERROR; return 0; } c = *sp; d = 0; /* go to end marker */ if(c == '"'||c =='<'){ for (cp = ++sp ; *cp && (*cp != c) ; cp++); if (*cp == '\0') { traceLog(LOG_ERR, "Missing end marker"); scnode_free(tree_top(psc)); *rc = SC_SYNTAXERROR; return 0; } cp++; d = 1; } else { #ifdef AVLUS traceLog(LOG_DEBUG, "All: \"%s\"", sp); #endif for (cp = sp; *cp && !SC_SPEC(*cp); cp++); #ifdef AVLUS traceLog(LOG_DEBUG,"-[%s]-", cp ); #endif } nsc = scnode_new(cp - sp + 1); strncpy(nsc->str, sp, cp - sp - d); if (psc) { psc->left = nsc; nsc->up = psc; } else psc = nsc; sp = cp; break; } while (*sp == ' ') sp++; #ifdef AVLUS if( nsc ) { char in[256] ; memset(in,0,256); scnode_print( nsc, in ); } #endif } if( *sp == '}' || *sp == ')' ) sp++; op->len -= (sp - op->val); op->val = sp; return tree_top(psc); }