int read_data() { FILE *fp; float x, y, mass; int i; fp = fopen("data.txt", "r"); if (fp == NULL) { printf("Can't open data.txt\n"); return false; } n_bodies = 0; while (!feof(fp)) { if (fscanf(fp, "%f %f %f", &x, &y, &mass) != 3) { break; } n_bodies += 1; } malloc_bodies(); i = 0; rewind(fp); while (!feof(fp)) { if (fscanf(fp, "%f %f %f", &x, &y, &mass) != 3) { break; } create_body(i, x, y, mass); i += 1; } fclose(fp); return true; }
void create_archive_file(std::vector<fs::path> const& files, std::string const& archive_name) { using size_type = std::vector<fs::path>::size_type; auto const file_sizes = enumerate_file_sizes(files); std::ofstream archive{archive_name, std::ofstream::binary}; create_body(files, file_sizes, archive); create_header(files, file_sizes, archive); }
void Body_Impl::init(PhysicsContext &pc, const std::string &resource_id, const XMLResourceDocument &resources) { XMLResourceNode resource = resources.get_resource(resource_id); // Create body from body description BodyDescription desc(pc, resource_id, resources); create_body(desc); //Load fixture and joint parameters here. }
int main() { #if defined(_WIN32) && defined(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif Example::Geometry::Brep::Body body = create_body(); body.SetName("new name"); f1(body); std::cout << "Name: " << body.GetName() << std::endl; return EXIT_SUCCESS; }
HTTPCode SproutConnection::deregister_bindings(const bool& send_notifications, const std::vector<std::string>& default_public_ids, const std::vector<std::string>& impis, SAS::TrailId trail) { std::string path = "/registrations?send-notifications="; path += send_notifications ? "true" : "false"; std::string body = create_body(default_public_ids, impis); HTTPCode ret_code = _http->send_delete(path, trail, body); LOG_DEBUG("HTTP return code from Sprout: %d", ret_code); return ret_code; }
/* ** LOCK requests */ PRIVATE BOOL lock_request (Cmdline * arg) { HTDAVHeaders * headers = HTDAVHeaders_new(); HTRequest * request = create_request (); HTAnchor * dst = HTAnchor_findAddress(arg->request_uri); HTParentAnchor * src = NULL; HTParentAnchor * base = NULL; BOOL status = NO; char * data = NULL; if (arg->I) { HTPrint ("Adding If header %s\n",arg->I); HTDAV_setIfHeader (headers,arg->I); } if (arg->arg1) { data = create_body (arg->arg1); HTPrint ("xml body %s\n",data); /* chose the func */ if (arg->func==1) { src = HTTmpAnchor(NULL); HTAnchor_setDocument(src, data); HTAnchor_setFormat(src, HTAtom_for ("text/xml")); HTAnchor_setLength(src, strlen(data)); } } if (arg->base_str && *(arg->base_str)) base = (HTParentAnchor *) HTAnchor_findAddress(arg->base_str); if (arg->D) HTDAV_setDepthHeader (headers,arg->D); if (arg->T) HTDAV_setTimeoutHeader (headers,arg->T); HTPrint ("function %d src? %s\n",arg->func,(src)?"yes":"no"); switch (arg->func) { case 1: status = HTLOCKDocumentAnchor (request,dst,src,headers); break; case 2: status = HTLOCKAnchor (request,dst,data,headers); break; case 3: status = HTLOCKAbsolute (request,arg->request_uri,data,headers); break; case 4: status = HTLOCKRelative (request,arg->request_uri,base,data,headers); break; } return status; }
void create_body_random() { int i; float x, y, mass; srand(time(NULL)); for (i = 0; i < n_bodies; i++) { x = rand()%n_bodies; y = rand()%n_bodies; x += (rand()%10)*0.1; y += (rand()%10)*0.1; x *= rand()%2 == 0 ? 1 : -1; y *= rand()%2 == 0 ? 1 : -1; mass = (rand()%9)+11; create_body(i, x, y, mass); } }