#include #include #include #include #include char * getCommandLineOption(int argc, char **argv, char const *option) { int slen = strlen(option); char *rv = 0; int i; for (i=0; i\n"); printf("Calculates the center location of all models in a file,\n"); printf("recenters all models around (0, 0, 0) and reports the\n"); printf("center location.\n"); exit(-1); } const char *delimiter = " "; void print_xml(void *id, double x, double y, double z, char offsets, char* name) { static int level = 1; void *xid = xmlMarkId(id); unsigned int num; num = xmlNodeGetNum(xid, "*"); if (num == 0) { if (offsets && strcasecmp(name, "offsets")) { double val = xmlGetDouble(id); if (!strcasecmp(name, "x-m")) { printf("%.3f", val-x); } else if (!strcasecmp(name, "y-m")) { printf("%.3f", val-y); } else if (!strcasecmp(name, "z-m")) { printf("%.3f", val-z); } else { printf("%.3f", val); } } else { char *s; s = xmlGetString(xid); if (s) { printf("%s", s); free(s); } } } else { unsigned int i, q; for (i=0; i", name); level++; if (!offsets) offsets = !strcasecmp(name, "offsets"); print_xml(xid, x, y, z, offsets, name); level--; printf("", name); } else printf("error\n"); } printf("\n"); for(q=1; q\n"); print_xml(rid, x, y, z, 0, ""); xmlFree(pid); } xmlClose(rid); } return 0; }