Relation* parseRelation(xmlDocPtr doc, xmlNodePtr cur){ Relation* r = NULL; unsigned long id = -1; char *visible = "T"; ListWay* lw = initListWay(0); ListNode* ln = initListNode(0); Tag* tag = NULL; Tag* t = NULL; xmlAttr *node_attr = cur->properties; xmlNodePtr tmpcur = NULL; while(node_attr != NULL){ if( xmlStrcmp(node_attr->name,(const xmlChar *)"id") ==0 ){ id = strtoul((const char *)((node_attr->children)->content),NULL,0); } else if( xmlStrcmp(node_attr->name,(const xmlChar *)"visible") ==0 ){ visible = (char *)((node_attr->children)->content); } node_attr = node_attr->next; } tmpcur = cur->xmlChildrenNode; while(tmpcur != NULL){ if (tmpcur->type == XML_ELEMENT_NODE) { if( xmlStrcmp(tmpcur->name,(const xmlChar *)"tag") ==0 ){ t = goodTagRelation((char *)xmlGetProp(tmpcur, (const xmlChar *)"k"),(char *) xmlGetProp(tmpcur, (const xmlChar *)"v")); if(t != NULL){ tag = t; } } if( xmlStrcmp(tmpcur->name,(const xmlChar *)"member") ==0 ){ if((strcmp((char *)xmlGetProp(tmpcur, (const xmlChar *)"type"),"way") ==0)){ lw = addRefListWay(strtoul((const char *)(xmlGetProp(tmpcur, (const xmlChar *)"ref")),NULL,0),(char *)xmlGetProp(tmpcur, (const xmlChar *)"role"), lw); } if((strcmp((char *)xmlGetProp(tmpcur, (const xmlChar *)"type"),"node") ==0)){ ln = addRefListNode(strtoul((const char *)(xmlGetProp(tmpcur, (const xmlChar *)"ref")),NULL,0), ln); } } } tmpcur = tmpcur->next; } r = initRelation(id,visible, tag,lw, ln); return r; }
void RecoveryByVerNormalL0::slove() { int i, j; int maxtimes = 10; double beta = 0.07; double arpha = 2; double lambda = 0.003; initRelation(); initInfo(); p = new double[3 * (int)meshmodel->numvertices + infocnt]; v = new double[3 * (int)meshmodel->numvertices]; for(i = 0;i < 3 * (int)meshmodel->numvertices;i++) { p[i] = meshmodel->vertices[i + 3]; } for(i = 0; i < arinfocnt;i++){ p[i + 3 * (int)meshmodel->numvertices] = 0.0; } for(i = 0;i < 3 * (int)meshmodel->numvertices;i++) { v[i] = meshmodel->vertices[i + 3]; } SubSolving s_l0(relation, info, infocnt, arinfocnt , 3 * (int)meshmodel->numvertices); s_l0.init(); int cc = 1; while(cc <= maxtimes) { for(i = arinfocnt;i < infocnt;i++) { double sum = 0; for(j = 0;j < 6;j++) { sum += info[i][j].w * v[info[i][j].data]; } if(sum * sum <= lambda / beta) { p[i + (int)meshmodel->numvertices * 3] = 0.0; } else { p[i + (int)meshmodel->numvertices * 3] = sum * beta; } } s_l0.getParameter(p, v,info, beta, arpha); s_l0.update(); s_l0.getParameter(p, v,info, beta, arpha); s_l0.slove(); printf("\trecoveryByL0\t%d\ttime\tfinished\n",cc); // arpha /= 2; beta = sqrt(2) * beta; cc++; } printf("\n\n"); for(i = 0;i < 3 * (int)meshmodel->numvertices;i++) { meshmodel->vertices[i + 3] = v[i]; } }