Exemplo n.º 1
0
void pipeline::

set_stage(std::string const& program_name , std::string const& stage_path) {

  program_iterator p_it(find_program(program_name));

  if(p_it != programs_.end()) {

    stage_iterator s_it(find_stage(stage_path));

    if(s_it == stages_.end()) {

      std::shared_ptr<stage> s(std::make_shared<stage>(stage(stage_path)));

      stages_.push_back(s);

      p_it->define_stage(s);
    }

    else {

      std::shared_ptr<stage> s(*s_it);

      p_it->define_stage(s);
    }
  }

  else {

    std::cerr << std::endl
              << "program [" << program_name << "] doesn't exist"
              << std::endl;
  }
}
Exemplo n.º 2
0
void do_reverse_keyframes( curve_t<K>& c)
{
	typedef typename curve_t<K>::iterator iterator;
	
	iterator s_it( c.begin());
	iterator e_it( c.end() - 1);

	while( s_it != e_it)
	{
		s_it->swap_value( *e_it);
		++s_it;
		--e_it;
	}
}
Exemplo n.º 3
0
// Returns a binary Pix mask with a 1 pixel for every pixel within the
// block. Rotates the coordinate system by rerotation prior to rendering.
Pix* PDBLK::render_mask(const FCOORD& rerotation, TBOX* mask_box) {
  TBOX rotated_box(box);
  rotated_box.rotate(rerotation);
  Pix* pix = pixCreate(rotated_box.width(), rotated_box.height(), 1);
  if (hand_poly != nullptr) {
    // We are going to rotate, so get a deep copy of the points and
    // make a new POLY_BLOCK with it.
    ICOORDELT_LIST polygon;
    polygon.deep_copy(hand_poly->points(), ICOORDELT::deep_copy);
    POLY_BLOCK image_block(&polygon, hand_poly->isA());
    image_block.rotate(rerotation);
    // Block outline is a polygon, so use a PB_LINE_IT to get the
    // rasterized interior. (Runs of interior pixels on a line.)
    auto *lines = new PB_LINE_IT(&image_block);
    for (int y = box.bottom(); y < box.top(); ++y) {
      const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments(
          lines->get_line(y));
      if (!segments->empty()) {
        ICOORDELT_IT s_it(segments.get());
        // Each element of segments is a start x and x size of the
        // run of interior pixels.
        for (s_it.mark_cycle_pt(); !s_it.cycled_list(); s_it.forward()) {
          int start = s_it.data()->x();
          int xext = s_it.data()->y();
          // Set the run of pixels to 1.
          pixRasterop(pix, start - rotated_box.left(),
                      rotated_box.height() - 1 - (y - rotated_box.bottom()),
                      xext, 1, PIX_SET, nullptr, 0, 0);
        }
      }
    }
    delete lines;
  } else {
    // Just fill the whole block as there is only a bounding box.
    pixRasterop(pix, 0, 0, rotated_box.width(), rotated_box.height(),
                PIX_SET, nullptr, 0, 0);
  }
  if (mask_box != nullptr) *mask_box = rotated_box;
  return pix;
}
Exemplo n.º 4
0
// Assuming that the minuend and subtrahend are already sorted with
// the same comparison function, shallow clears this and then copies
// the set difference minuend - subtrahend to this, being the elements
// of minuend that do not compare equal to anything in subtrahend.
// If unique is true, any duplicates in minuend are also eliminated.
void CLIST::set_subtract(int comparator(const void*, const void*),
                         bool unique,
                         CLIST* minuend, CLIST* subtrahend) {
  shallow_clear();
  CLIST_ITERATOR m_it(minuend);
  CLIST_ITERATOR s_it(subtrahend);
  // Since both lists are sorted, finding the subtras that are not
  // minus is a case of a parallel iteration.
  for (m_it.mark_cycle_pt(); !m_it.cycled_list(); m_it.forward()) {
    void* minu = m_it.data();
    void* subtra = NULL;
    if (!s_it.empty()) {
      subtra = s_it.data();
      while (!s_it.at_last() &&
             comparator(&subtra, &minu) < 0) {
        s_it.forward();
        subtra = s_it.data();
      }
    }
    if (subtra == NULL || comparator(&subtra, &minu) != 0)
      add_sorted(comparator, unique, minu);
  }
}