void VortexTransition::ConstructSequence()
{
  for (int i=_ts; i<_ts+_tl-1; i++) {
    // fprintf(stderr, "=====t=%d\n", i);

    VortexTransitionMatrix tm = Matrix(i);
    assert(tm.Valid());

    if (i == _ts) { // initial
      for (int k=0; k<tm.n0(); k++) {
        int gid = NewVortexSequence(i);
        _seqs[gid].tl ++;
        _seqs[gid].lids.push_back(k);
        _seqmap[std::make_pair(i, k)] = gid;
        _invseqmap[std::make_pair(i, gid)] = k;
      }
    }

    for (int k=0; k<tm.NModules(); k++) {
      int event;
      std::set<int> lhs, rhs;
      tm.GetModule(k, lhs, rhs, event);

      if (lhs.size() == 1 && rhs.size() == 1) { // ordinary case
        int l = *lhs.begin(), r = *rhs.begin();
        int gid = _seqmap[std::make_pair(i, l)];
        _seqs[gid].tl ++;
        _seqs[gid].lids.push_back(r);
        _seqmap[std::make_pair(i+1, r)] = gid;
        _invseqmap[std::make_pair(i+1, gid)] = r;
      } else { // some events, need re-ID
        for (std::set<int>::iterator it=rhs.begin(); it!=rhs.end(); it++) {
          int r = *it; 
          int gid = NewVortexSequence(i+1);
          _seqs[gid].tl ++;
          _seqs[gid].lids.push_back(r);
          _seqmap[std::make_pair(i+1, r)] = gid;
          _invseqmap[std::make_pair(i+1, gid)] = r;
        }
      }

      // build events
      // if (event >= VORTEX_EVENT_MERGE) {
      if (event > VORTEX_EVENT_DUMMY) {
        VortexEvent e;
        e.frame = i;
        e.type = event;
        e.lhs = lhs;
        e.rhs = rhs;
        _events.push_back(e);
      }
    }
  }

  // RandomColorSchemes();
  SequenceGraphColoring(); 
}
Exemplo n.º 2
0
static void compute_moving_speed(
    int f0, int f1, 
    std::vector<VortexLine>& vlines0, // moving speed will be written in vlines
    const std::vector<VortexLine>& vlines1,
    const VortexTransitionMatrix& mat)
{
  int event; 
  std::set<int> lhs, rhs;
  for (int i=0; i<mat.NModules(); i++) {
    mat.GetModule(i, lhs, rhs, event);
    if (event != VORTEX_EVENT_DUMMY) continue; // cannot compute moving speed for events

    const int llvid = *lhs.begin(), rlvid = *rhs.begin();
    const float A = AreaL(vlines0[llvid], vlines1[rlvid]);
    vlines0[llvid].moving_speed = A;
    // fprintf(stderr, "f0=%d, f1=%d, llvid=%d, rlvid=%d, A=%f\n", 
    //     f0, f1, llvid, rlvid, A);
  }
}