Beispiel #1
0
void
where_is (char * name)
{
  struct line seqname;
  int vec;
  int code;
  struct cmd_func * cmd;
  
  if (!find_function (&vec, &cmd, name, strlen(name)))
    code = cmd - the_funcs[vec];
  else if (map_id (name) >= 0)
    {
      code = map_id (name);
      vec = -1;
    }
  else
    io_error_msg ("%s is not a function.", name); /* no return */
  code = cmd - the_funcs[vec];
  init_line (&seqname);
  set_line (&seqname, "");
  
  if (!search_map_for_cmd (&seqname, the_cmd_frame->top_keymap, vec, code))
    io_info_msg ("%s is not on any keys.", name);
  else
    io_info_msg ("%s is bound to %s.", name, seqname.buf);
  
  free_line (&seqname);
}
Beispiel #2
0
void Player::changemap( PuzzleNode &puzzle )
{
    if( puzzle.solved ) {
        map_id( puzzle.map_id );
        rx( x( puzzle.x ));
        ry( y( puzzle.y ));
        moving( 0 );
        direction( puzzle.direction );
    } else {
        engine.push( new StatePuzzle( engine, puzzle ));
    }
}
Beispiel #3
0
OSErr AddToMasterFile(INTEGER from_file_rn, INTEGER master_file_rn)
{
  OSErr err;
  mapping_t mapping;
  INTEGER type_num, type_num_max;
  ResType type;
  Handle h;
  Str255 name;
  BOOLEAN save_resload;

  err = setup_map (from_file_rn, master_file_rn, &mapping);
  if (err == noEErr)
    {
      type_num_max = CountTypesRN (from_file_rn);
      save_resload = ResLoad;
      SetResLoad (false);
      for (type_num = 1; type_num <= type_num_max; ++type_num)
	{
	  GetIndTypeRN (from_file_rn, &type, type_num);
	  res_num_max = CountResourcesRN (from_file_rn, type);
	  for (res_num = 1; res_num <= res_num_max; ++res_num)
	    {
	      h = GetIndResourceRN (from_file_rn, type, res_num);
	      GetResInfo (h, &id, &t, name);
	      if (map_id (&id, from_file_rn, master_file_rn, &mapping))
		{
		  LoadResource(h);
		  DetachResource(h);
		  map_data (h, &mapping);
		  AddResourceRN (master_file_rn, h, type, id, name);
		}
	    }
	}
      SetResLoad (save_resload);
    }
}
Beispiel #4
0
void
expand_help_msg (struct info_buffer * out, struct info_buffer * in)
{
  int x;
  struct line line;
  struct line seq_buf;
  int out_offset;
  int rel_map = the_cmd_frame->top_keymap;

  if (the_cmd_frame->cmd && (the_cmd_arg.style == &keyseq_style))
    rel_map = the_cmd_arg.val.key.cmd.code;

  print_info (out, "");
  out_offset = out->len;
  out->len += in->len;
  out->text = (char **)ck_remalloc (out->text, out->len * sizeof (char *));
  init_line (&line);
  init_line (&seq_buf);
  for (x = 0; x < in->len; ++x)
    {
      char * next_burst = in->text[x];
      char * end_burst = index (next_burst, '[');
      set_line (&line, "");
      set_line (&seq_buf, "");
      while (end_burst)
	{
	  char * fn_start = end_burst + 1;
	  char * fn_end = index (fn_start, ']');
	  int vec;
	  struct cmd_func * cmd;
	  if (fn_end && (*fn_start == '[') && fn_end[1] == ']')
	    {
	      int map = map_idn (fn_start + 1, fn_end - fn_start - 1);
	      if (map < 0)
		map = map_id ("universal");
	      rel_map = map;
	      catn_line (&line, next_burst, end_burst - next_burst);
	      next_burst = fn_end + 2;
	      end_burst = index (next_burst, '[');
	    }
	  else if (   fn_end
		   && !find_function (&vec, &cmd, fn_start, fn_end - fn_start))
	    {
	      catn_line (&line, next_burst, end_burst - next_burst);
	      if (search_map_for_cmd (&seq_buf, rel_map, vec,
				      cmd - the_funcs[vec])) 
		{
		  catn_line (&line, seq_buf.buf, strlen (seq_buf.buf));
		  set_line (&seq_buf, "");
		}
	      else
		{
		  catn_line (&line, "M-x ", 4);
		  catn_line (&line, fn_start, fn_end - fn_start);
		}
	      next_burst = fn_end + 1;
	      end_burst = index (next_burst, '[');
	    }
	  else if (fn_end)
	    end_burst = index (fn_end + 1, '[');
	}
      catn_line (&line, next_burst, strlen(next_burst));
      out->text[x + out_offset] = line.buf;
      init_line (&line);
    }
  free_line (&seq_buf);
  free_line (&line);
}
std::vector<Proposals> nms( const std::vector<Proposals> & proposals, const std::vector<int> & order, float max_iou ) {
	int N = 0;
	for( const Proposals & p: proposals )
		N += p.p.rows();
	std::vector<int> s_id( N ), p_id( N );
	for( int i=0, k=0; i<proposals.size(); i++ )
		for( int j=0; j<proposals[i].p.rows(); j++, k++ ) {
			s_id[k] = i;
			p_id[k] = j;
		}

	std::vector<RMatrixXs> s;
	std::vector<int> Ns;
	for( int i=0; i<proposals.size(); i++ ) {
		s.push_back( proposals[i].s );
		Ns.push_back( proposals[i].s.maxCoeff()+1 );
	}
	const RMatrixXi ms = mergeOverSegmentations(s);
	const int Nms = ms.maxCoeff()+1;
	
	VectorXu ms_area = VectorXu::Zero( Nms );
	for( int j=0; j<ms.rows(); j++ )
		for( int i=0; i<ms.cols(); i++ )
			ms_area[ ms(j,i) ]++;
	
	std::vector<IOUSet> iou_set;
	std::vector<VectorXs> ids;
	for( int i=0; i<s.size(); i++ ) {
		iou_set.push_back( s[i] );
		ids.push_back( map_id( ms, s[i] ) );
	}
	
	std::vector<int> pb;
	pb.reserve( Nms );
	
	std::vector< std::vector< VectorXb > > r( proposals.size() );
	for( int i: order ) {
		VectorXb p = proposals[ s_id[i] ].p.row( p_id[i] );
		// Run NMS
		if( !p.any() || iou_set[ s_id[i] ].intersects(p,max_iou) )
			continue;
		
		Vector4s bbox = iou_set[ s_id[i] ].computeBBox( p );
		
		// Project each segmentation onto the common OS
		pb.clear();
		for( int j=0; j<Nms; j++ )
			if( p[ ids[ s_id[i] ][j] ] )
				pb.push_back( j );
		
		bool intersects = false;
		for( int k=0; !intersects && k<iou_set.size(); k++ ) 
			if( s_id[i] != k ){
				// Reproject the common OS to the current os
				VectorXu p_area = VectorXu::Zero( Ns[k] );
				for( int j: pb )
					p_area[ ids[ k ][j] ] += ms_area[ j ];
				// Run more NMS
				intersects = iou_set[k].intersects(p_area, bbox, max_iou);
			}
		if( !intersects ) {
			// Add the segment
			iou_set[ s_id[i] ].add( p );
			r[ s_id[i] ].push_back( p );
		}
	}
	
	
	std::vector<Proposals> res( proposals.size() );
	for( int i=0; i<proposals.size(); i++ ) {
		res[i].s = proposals[i].s;
		res[i].p = RMatrixXb( r[i].size(), proposals[i].p.cols() );
		for( int j=0; j<r[i].size(); j++ )
			res[i].p.row(j) = r[i][j];
	}
	return res;
}