Exemplo n.º 1
0
        bool Receiver::operator() (const Tractography::Streamline<>& in)
        {
          auto display_func = [&](){ return printf ("%8" PRIu64 " read, %8" PRIu64 " written", total_count, count); };

          if (number && (count == number))
            return false;

          ++total_count;

          if (in.empty()) {
            writer (in);
            progress.update (display_func);
            return true;
          }

          if (in[0].valid()) {

            if (skip) {
              --skip;
              progress.update (display_func);
              return true;
            }
            writer (in);

          } else {

            // Explicitly handle case where the streamline has been cropped into multiple components
            // Worker class separates track segments using invalid points as delimiters
            Tractography::Streamline<> temp;
            temp.index = in.index;
            temp.weight = in.weight;
            for (Tractography::Streamline<>::const_iterator p = in.begin(); p != in.end(); ++p) {
              if (p->valid()) {
                temp.push_back (*p);
              } else if (temp.size()) {
                writer (temp);
                temp.clear();
              }
            }

          }

          ++count;
          progress.update (display_func);
          return (!(number && (count == number)));

        }