int main(int argc, char **argv)
{
  if (argc < 3) {
    fprintf(stderr, "Usage: %s <dataname> <ts> <tl>\n", argv[0]);
    return EXIT_FAILURE;
  }
  
  const std::string dataname = argv[1];
  const int ts = atoi(argv[2]), 
            tl = atoi(argv[3]), 
            span = 1;

  QApplication app(argc, argv); 

  QGLFormat fmt = QGLFormat::defaultFormat();
  fmt.setSampleBuffers(true);
  fmt.setSamples(16); 
  QGLFormat::setDefaultFormat(fmt); 
  
  VortexTransition vt;
  vt.LoadFromFile(dataname, ts, tl);
  vt.ConstructSequence();

  CStorylineWidget *widget = new CStorylineWidget;
  widget->SetVortexTrasition(&vt);
  widget->show();

  return app.exec(); 
}
Beispiel #2
0
int main(int argc, char **argv)
{
  if (argc < 8) {
    fprintf(stderr, "Usage: %s <dataname> <ts> <tl> <gvid0> <gvid1> <gvid2> <gvid3>\n", argv[0]);
    return EXIT_FAILURE;
  }

  const std::string dataname = argv[1];
  const int ts = atoi(argv[2]), 
            tl = atoi(argv[3]);
  const int gvid0 = atoi(argv[4]), 
            gvid1 = atoi(argv[5]), 
            gvid2 = atoi(argv[6]), 
            gvid3 = atoi(argv[7]);

  LoadTimesteps(dataname);

  VortexTransition vt;
  vt.LoadFromFile(dataname, ts, tl);
  vt.ConstructSequence();
  // vt.PrintSequence();

  for (int frame=ts; frame<ts+tl; frame++) {
    float dist;
    const int lvid0 = vt.gvid2lvid(frame, gvid0), 
              lvid1 = vt.gvid2lvid(frame, gvid1), 
              lvid2 = vt.gvid2lvid(frame, gvid2), 
              lvid3 = vt.gvid2lvid(frame, gvid3); 
    if (lvid0 != -1 && lvid1 != -1) 
      dist = Dist(dataname, frame, lvid0, lvid1);
    else if (lvid2 != -1 && lvid3 != -1)
      dist = Dist(dataname, frame, lvid2, lvid3);
    else 
      dist = -DBL_MAX;

    if (dist >= 0)
      fprintf(stderr, "%d, %f, %f\n", frame, timesteps[frame], dist);
  }

  return 0;
}
int main(int argc, char **argv)
{
  if (argc < 2) return 1;
  infile = argv[1];
  
  FILE *fp = fopen(infile.c_str(), "rb");
  if (!fp) return 1;

#if WITH_ROCKSDB
  std::string dbname = infile + ".rocksdb";

  rocksdb::Options options;
  options.create_if_missing = true;
  // options.compression = rocksdb::kLZ4Compression;
  options.compression = rocksdb::kBZip2Compression;
  // options.write_buffer_size = 64*1024*1024; // 64 MB
  rocksdb::Status status = rocksdb::DB::Open(options, dbname.c_str(), &db);
  assert(status.ok());
#endif

  using namespace tbb::flow;
  graph g;

  int type_msg;
  vfgpu_hdr_t hdr;
  int pfcount, pecount;
  const int max_frames = 5000; // INT_MAX;
  int frame_count = 0;
  std::vector<int> frames;
  std::vector<vfgpu_hdr_t> hdrs;

  fread(&cfg, sizeof(vfgpu_cfg_t), 1, fp);

  while (!feof(fp)) {
    if (frame_count ++ > max_frames) break;
    
    // simple flow control
    __sync_fetch_and_add(&num_buffered_frames, 1);
    while (num_buffered_frames >= max_buffered_frames) 
      usleep(100000);

    size_t count = fread(&type_msg, sizeof(int), 1, fp);
    if (count != 1) break;

    if (type_msg == VFGPU_MSG_PF) {
      fread(&hdr, sizeof(vfgpu_hdr_t), 1, fp);
      fread(&pfcount, sizeof(int), 1, fp);
      
      hdrs_all[hdr.frame] = hdr;
      std::vector<vfgpu_pf_t> &pfs = pfs_all[hdr.frame];
      pfs.resize(pfcount);
      fread(pfs.data(), sizeof(vfgpu_pf_t), pfcount, fp);
      
      continue_node<continue_msg> *e = new continue_node<continue_msg>(g, extract(hdr.frame));
      e->try_put(continue_msg());
      extract_tasks[hdr.frame] = e;

      hdrs.push_back(hdr);
      frames.push_back(hdr.frame);
      // fprintf(stderr, "pushed frame %d\n", hdr.frame);
    } else if (type_msg == VFGPU_MSG_PE) {
      std::pair<int, int> interval;
      fread(&interval, sizeof(int), 2, fp);
      fread(&pecount, sizeof(int), 1, fp);

      std::vector<vfgpu_pe_t> &pes = pes_all[interval];
      pes.resize(pecount);
      fread(pes.data(), sizeof(vfgpu_pe_t), pecount, fp);
    
      continue_node<continue_msg> *t = new continue_node<continue_msg>(g, track(interval));
      track_tasks[interval] = t;
     
      make_edge(*extract_tasks[interval.first], *t);
      make_edge(*extract_tasks[interval.second], *t);
      // fprintf(stderr, "pushed interval {%d, %d}\n", interval.first, interval.second);
    }
  }

  fclose(fp);

  g.wait_for_all();
  
#if WITH_ROCKSDB
  std::string buf;
 
  diy::serialize(cfg, buf);
  db->Put(rocksdb::WriteOptions(), "cfg", buf);

  diy::serialize(hdrs, buf);
  db->Put(rocksdb::WriteOptions(), "hdrs", buf);

  fprintf(stderr, "constructing sequences...\n");
  vt.SetFrames(frames);
  vt.ConstructSequence();
  vt.PrintSequence();
  diy::serialize(vt, buf);
  db->Put(rocksdb::WriteOptions(), "trans", buf);
  
  delete db;
#endif

  fprintf(stderr, "exiting...\n");
  return 0;
}