void nbodyBarnesHut(particle * particles, int count, int n, double timeDiff, double eps, char * outputPath) { int step; sprintf(fileParamBuff, "%s_%%0%dd.vtk", outputPath, ((int) log10(n) + 1)); bodyptr bodies = convertStruct(particles, count); /* End converting */ /* Do the stepping */ bodyptr p; for (step = 1; step <= 1; step++) { cellptr root; real rootSize; /* Make the tree */ treeInit(&root, bodies, count, &rootSize); /* Calculate force */ calculateForce(root, eps, rootSize); /* Advance each body */ for (p = bodies; p < bodies + count; p++) { /* Advance the speed */ /* Advance the position */ } /* Free the tree */ treeFree(&root); } }
BSONObj* convertStruct(struct BSONStruct* param) { BSONObj* obj = new BSONObj(); struct BSONStruct* s = param; BSONStruct* head = s; while (s != NULL) { std::string name(s->name); __int32 type = s->type; void* value = s->value; __int32* val; float* val2; char* val3; BSONObj* inner; switch (type) { case 1: val = (__int32*)value; obj->add(name, *val); break; case 2: val2 = (float*)value; obj->add(name, *val2); break; case 3: val3 = (char*)value; obj->add(name, val3); break; case 4: struct BSONStruct* str = (struct BSONStruct*)value; inner = convertStruct(str); obj->add(name, *inner); delete inner; } s = s->next; } return obj; }