Beispiel #1
0
TEST_F(model_test, bucket_management_and_forgetting) {
  static const size_t N = config_.bucket_size * 4;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  vector<weighted_point> coreset = model_->get_coreset();
  ASSERT_EQ(
      coreset.size(), static_cast<size_t>(config_.compressed_bucket_size));

  model_->push(get_points(N, D));
  coreset = model_->get_coreset();
  ASSERT_EQ(
      coreset.size(), static_cast<size_t>(config_.compressed_bucket_size));
}
Vector<Vector3> ConvexPolygonShape::_gen_debug_mesh_lines() {

	DVector<Vector3> points = get_points();

	if (points.size()>3) {

		QuickHull qh;
		Vector<Vector3> varr = Variant(points);
		Geometry::MeshData md;
		Error err = qh.build(varr,md);
		if (err==OK) {
			Vector<Vector3> lines;
			lines.resize(md.edges.size()*2);
			for(int i=0;i<md.edges.size();i++) {
				lines[i*2+0]=md.vertices[md.edges[i].a];
				lines[i*2+1]=md.vertices[md.edges[i].b];
			}
			return lines;


		}

	}

	return Vector<Vector3>();
}
Beispiel #3
0
HTMLFont *
html_font_manager_get_font (HTMLFontManager *manager,
                            gchar *face_list,
                            GtkHTMLFontStyle style)
{
	HTMLFontSet *set;
	HTMLFont *font = NULL;

	font = get_font (manager, &set, face_list, style);

	if (!font) {
		/* first try to alloc right one */
		font = alloc_new_font (manager, &set, face_list, style);
		if (!font) {
			g_assert (set);
			if (!face_list) {
				/* default font, so the last chance is to get fixed font */
				font = html_painter_alloc_font (manager->painter, NULL,
								get_real_font_size (manager, style),
								get_points (manager, style), style);
				if (!font)
					g_warning ("Cannot allocate fixed font\n");
			} else {
				/* some unavailable non-default font => use default one */

			       font = html_font_manager_get_font (manager, NULL, style);
			       html_font_ref (font, manager->painter);
			}
			if (font)
				html_font_set_font (manager, set, style, font);
		}
	}

	return font;
}
TEST_F(mixable_model_test, reduce) {
  static const size_t N = 200;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  diff_t df;
  storage_->get_diff(df);
  diff_t df2;
  storage_->mix(df, df2);
  ASSERT_EQ(df2.size(), (size_t)1);
  ASSERT_EQ(df2[0].first, name_);
  ASSERT_EQ(df2[0].second.size(), N);

  storage_->get_diff(df2);
  storage_->mix(df, df2);
  ASSERT_EQ(df2.size(), (size_t)1);
  ASSERT_EQ(df2[0].first, name_);
  ASSERT_EQ(df2[0].second.size(), 2*N);

  storage_->get_diff(df2);
  df2[0].first += "2";
  storage_->mix(df, df2);
  ASSERT_EQ(df2.size(), (size_t)2);
  ASSERT_EQ(df2[0].first, name_);
  ASSERT_EQ(df2[0].second.size(), N);
  ASSERT_EQ(df2[1].first, name_+"2");
  ASSERT_EQ(df2[1].second.size(), N);
}
Beispiel #5
0
static Uint8 move_enemy( ENEMY *e )
{
  /* If the enemy is on the screen, then set their active flag. */
  if( e->current->y + 
      e->current->surface[e->current->cur_frame]->h > 0 )
    e->flags |= E_FLAG_ACTIVE;  /* Set the active flag. */

  /* Check if the enemy has left the bottom of the screen. */
  if( e->current->y > (Sint32)screen_height() ) {
    remove_enemy( e );
    player_score -= get_points( e->type ); 
    return 0;
  }

  /* If the enemy is not active then they only scroll down.
   * once the enemy is active they follow their movement
   * pattern. */
  if( !IS_ACTIVE( e->flags ) )
    e->current->y += ENEMY_SCROLL_SPEED;

  else if( e->move_funct == NULL )
    move_enemy_down( e );

  else
    e->move_funct( e );

  return 1;
}
bool
AsciiProcessor::ins_polyline( const char * buf,
                              int fref,
                              BuilderBase * build,
                              const char * & next )
{
    int id = 0, lay = 0, fil = 0;
    RGBcolor col( 0, 0, 0 );

    if ( ! get_obj_attr( buf, id, lay, col, fil, next ) )
    {
        return CMD_ERR;
    }

    int num = get_points( next, points, next );

    if ( num < 2 )
    {
        return CMD_ERR;
    }

    build->set_cmd_insert_polyline( fref, id, points.cur_size, points.tab, lay, col );

    return CMD_OK;
}
Beispiel #7
0
void		gere_key2(int keycode, t_env *env)
{
	if (keycode == 113)
		COLOR += 0x010000;
	if (keycode == 119)
		COLOR += 0x000100;
	if (keycode == 101)
		COLOR += 0x01;
	if (keycode == 97)
		COLOR -= 0x00010000;
	if (keycode == 115)
		COLOR -= 0x00000100;
	if (keycode == 100)
		COLOR -= 0x00000001;
	if (keycode == 65456)
	{
		COEFFZ = 1;
		ANGLEX = 0;
		ANGLEZ = 0;
		CHOICE = 0;
		COLOR = DEF_COLOR;
		C = MIN(WIDTH / (MAX_X + 5), HEIGHT / (MAX_Y + 5));
		C = C ? C : 1;
		OFF = set_point(0, 0, 0);
		get_points(env);
	}
}
Beispiel #8
0
static void kill_enemy( ENEMY *e )
{
  player_score += get_points( e->type );

  new_explosion( e->current->x, e->current->y, BIG ); 

  remove_enemy( e );
}
TEST_F(mixable_model_test, get_diff) {
  static const size_t N = 200;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  diff_t df;
  storage_->get_diff(df);
  ASSERT_EQ(df.size(), (size_t)1);
  ASSERT_EQ(df[0].first, name_);
  ASSERT_EQ(df[0].second.size(), N);
}
TEST_F(model_gmm_test, push_small) {
  static const size_t N = 99;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  vector<weighted_point> coreset = model_->get_coreset();
  ASSERT_EQ(coreset.size(), N);
  ASSERT_EQ(coreset.front().data.size(), D);

  EXPECT_THROW(model_->get_k_center(), not_performed);
}
Beispiel #11
0
TEST_F(model_test, push_small) {
  static const size_t N = 100;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  vector<weighted_point> coreset = model_->get_coreset();
  ASSERT_EQ(coreset.size(), N);
  ASSERT_EQ(coreset.front().data.size(), D);

  vector<common::sfv_t> centers = model_->get_k_center();
  ASSERT_EQ(centers.size(), 0ul);
}
simple_point ClosestPointQuery::operator()(const simple_point& queryPoint, const double maxDist, int brute_force) const
{
    // find the intersection point of a line from the query point to the meshes bounding box
    simple_point hit_point = get_bb_intersection(queryPoint);

    std::cout << "\n";
    std::cout << "query point x " << queryPoint.x << " y " << queryPoint.y << " z " << queryPoint.z << " intersects mesh at hit point x " << hit_point.x << " y " << hit_point.y << " z " << hit_point.z << "\n";

    // search outwards from the intersection point up to maxDist for
    std::vector<simple_point>* pts = nullptr;
    if (brute_force)
    {
        // just for speed comparisons
        pts = get_points_brute_force(hit_point, maxDist);
    }
    else
    {
        pts = get_points(hit_point, maxDist);
    }

    if (pts != nullptr)
        std::cout << "searched " << pts->size() << " points\n";
    else
        return simple_point(-1.0, -1.0, -1.0);

    // check resulting points to confirm which one is actually closest
    simple_point best_point = simple_point(-1.0, -1.0, -1.0);
    if (pts->size() > 0)
    {
        double min_dist = -1.0;
        for (auto it = pts->begin(); it != pts->end(); ++it)
        {
            double dist = get_distance(queryPoint,*it);
            if (min_dist == -1.0)
            {
                min_dist = dist;
                best_point = *it;
            }
            else
            {
                if (dist < min_dist)
                {
                    min_dist = dist;
                    best_point = *it;
                }
            }
        }
    }

    return best_point;
}
Beispiel #13
0
void CUIFrameWindow::draw_tile_line(Frect rect, int i, bool b_horz, Fvector2 const& ts)
{
	Fvector2 LTt, RBt;
	Fvector2 LTp, RBp;

	if(b_horz)
	{
		while(rect.lt.x+EPS_L<rect.rb.x)
		{
			get_points			(rect, i, LTp, RBp, LTt, RBt);
			rect.lt.x			= RBp.x;
			draw_rect			(LTp, RBp, LTt, RBt, m_texture_color, ts);
		}
	}else
	{
		while(rect.lt.y+EPS_L<rect.rb.y)
		{
			get_points			(rect, i, LTp, RBp, LTt, RBt);
			rect.lt.y			= RBp.y;
			draw_rect			(LTp, RBp, LTt, RBt, m_texture_color, ts);
		}
	}
}
Beispiel #14
0
void	stock_coord(char *file_name, t_co *c)
{
	int		fd;
	char	*line;
	int		v;

	v = 0;
	line = NULL;
	init_coord(file_name, c);
	fd = open(file_name, O_RDONLY);
	c->coord->vert = (t_point **)malloc(sizeof(t_point *) * c->coord->to_pts);
	get_points(c, &fd, line, &v);
	close(fd);
}
Beispiel #15
0
/* get user defined size */
BOOL
gsview_usersize()
{
    TCHAR prompt[MAXSTR];
    char answer[MAXSTR];
    nHelpTopic = IDS_TOPICMEDIA;
    load_string(IDS_USERWIDTH, prompt, sizeof(prompt)/sizeof(TCHAR)-1);
    put_points(answer, sizeof(answer), (float)option.user_width);
    if (!query_string(prompt,answer))
        return FALSE;
    option.user_width = (int)(get_points(answer) + 0.5);
    load_string(IDS_USERHEIGHT, prompt, sizeof(prompt)/sizeof(TCHAR)-1);
    put_points(answer, sizeof(answer), (float)option.user_height);
    if (!query_string(prompt,answer))
        return FALSE;
    option.user_height = (int)(get_points(answer) + 0.5);
    if ((option.user_width==0) || (option.user_height == 0)) {
        option.user_width = 595;
        option.user_width = 842;
    }
    gsview_check_usersize();
    return TRUE;
}
Beispiel #16
0
void		gere_key3(int keycode, t_env *env)
{
	if (keycode == 65463)
		ANGLEX -= 0.05;
	if (keycode == 65465)
		ANGLEX += 0.05;
	if (keycode == 65459)
		ANGLEZ -= 0.05;
	if (keycode == 65457)
		ANGLEZ += 0.05;
	if (keycode == 65469 && CHOICE == 1)
	{
		CHOICE = 0;
		OFF = set_point(0, 0, 0);
		get_points(env);
	}
	if (keycode == 65455 && CHOICE == 0)
	{
		CHOICE = 1;
		OFF = set_point(0, 0, 0);
		get_points(env);
	}
}
Beispiel #17
0
std::set<Attribute> Skybox::get_attributes(size_t const size)
{
	std::set<std::tuple<GLenum, OpenGLValue>> values;

	OpenGLValue points(GL_FLOAT, get_points(size));
	OpenGLValue indices(GL_UNSIGNED_INT, get_indices(size));

	values.emplace(GL_ARRAY_BUFFER, points);
	values.emplace(GL_ELEMENT_ARRAY_BUFFER, indices);

	std::set<Attribute> attribs;
	attribs.emplace("vpoint", values);

	return attribs;
}
TEST_F(mixable_model_test, put_diff) {
  static const size_t N = 200;
  static const size_t D = 2;
  model_->push(get_points(N, D));
  diff_t df, df2;
  storage_->get_diff(df);
  storage_->get_diff(df2);
  df2[0].first = "name2";
  storage_->mix(df, df2);
  storage_->set_mixed_and_clear_diff(df2);

  wplist coreset = model_->get_coreset();
  ASSERT_EQ(coreset.size(), 2*N);
  storage_->get_diff(df);
  ASSERT_EQ(df.size(), (size_t)1);
  ASSERT_EQ(df[0].second.size(), N);
}
/**
 * USE: Provide sample points and how many to setup_hough() transformation and plot those points
 * using plot_point() with each index of points you want to convert. The use print_classifier()
 * or get_lines() to see the lines extracted.
 */
int main(int argc, char **argv) {

	// Get points from image
	SIZE_TYPE size;
	POINT_TYPE *points = NULL;
	sizep_t count = get_points("sample_small.bmp", &points, &size);

	/*
	 *  points 		: Array of points
	 *  num_points	: Number of points in the array
	 *  threshold	: Threshold to consider line intersection
	 *  tolerance_t	: Tolerance (in grades) to consider two lines are the same
	 *  tolerance_r	: Distance (in pixels) to consider two lines are the same
	 *  precision	: Precision for degrees (10 = decimals, 100 = cents...)
	 *  size		: Size of the image
	 *  max_lines	: Lines to look for (value -1 falls back to 500)
	 */
	clock_t cp = clock();
	setup_hough(points, count, 12, 15.0, 5.0, 1, size, 10000);

	// Plot every point and measure clock ticks
	int n;
	for (n=0; n<_num_points; n++) {
		plot_point(n);
	}
	printf("_plot_point() ticks: %.4f\n", ((double)(clock()-cp))/1000000l);
	print_accumulator("accumulator.bmp");
	print_classifier();//*/

	// Get lines from classifier
	LINE_TYPE *lines;
	sizep_t clines = get_lines(&lines);

	// Print lines
	print_lines("output.bmp", "sample.bmp", lines, clines, 10);
	print_lines("output_small.bmp", "sample_small.bmp", lines, clines, 1);

	// Free memory
	finish_hough();
	free(lines);
	free(points);
	printf("All clear!");

	return EXIT_SUCCESS;
}
Beispiel #20
0
TEST_F(model_test, compression_and_clusteringing) {
  static const size_t N = config_.bucket_size;
  static const size_t D = 2;
  std::cout << "total adding points : " << N << std::endl;
  model_->push(get_points(N, D));
  vector<weighted_point> coreset = model_->get_coreset();
  ASSERT_EQ(
      coreset.size(), static_cast<size_t>(config_.compressed_bucket_size));

  vector<common::sfv_t> centers = model_->get_k_center();
  ASSERT_EQ(centers.size(), static_cast<size_t>(config_.k));

  vector<wplist> core_members = model_->get_core_members();
  ASSERT_GT(core_members.size(), 0ul);

  wplist nearest_members = model_->get_nearest_members(get_point(D).data);
  ASSERT_GT(nearest_members.size(), 0ul);

  common::sfv_t nearest_center = model_->get_nearest_center(get_point(D).data);
}
Beispiel #21
0
void		gere_offset(int keycode, t_env *env)
{
	if (keycode == 65464)
		OFF.y -= 5;
	if (keycode == 65458)
		OFF.y += 5;
	if (keycode == 65462)
		OFF.x += 5;
	if (keycode == 65460)
		OFF.x -= 5;
	if (keycode == 122)
		COEFFZ++;
	if (keycode == 120)
		COEFFZ--;
	if (keycode == 65463 || keycode == 65465 || keycode == 65459 ||
		keycode == 65457)
	{
		OFF = set_point(0, 0, 0);
		get_points(env);
	}
}
Beispiel #22
0
static NV_INT32 get_lsurvey(FILE * infile, SURVEY * srv)
{
    NV_CHAR         buff[MBS];
    NV_INT32        i = (-1), n = 0;


    /* determine the id numbers of the lines & points */

    rewind(infile);
    n = 0;
    while (fgets(buff, MBS, infile) != NULL)
    {
	strtolower(buff);
	if (strncmp(buff, "line", 4) == 0)
	{
	    n += get_ids(buff, &srv->line[++i]);
	}
    }
    if (n != srv->n)
    {
	printf("get_survey:  warning got %d (!= %d) line ids\n", n, srv->n);
    }


    /* now fill in the points for each line */

    n = 0;
    for (i = 0; i < srv->n; i++)
    {
	n += get_points(infile, &srv->line[i]);
    }

    if (n != srv->n)
    {
	printf("get_dsurvey:  warning got %d (!= %d) lines\n", n, srv->n);
    }

    return n;

}				/* get_lsurvey */
Beispiel #23
0
int			gere_key(int keycode, t_env *env)
{
	if (keycode == 65307)
	{
		kill_everything(env);
		exit (1);
	}
	if (keycode == 65451)
		C++;
	if (keycode == 65453)
		C = C > 1 ? C - 1 : 1;
	if (keycode == 65461)
	{
		OFF = set_point(0, 0, 0);
		get_points(env);
	}
	gere_key2(keycode, env);
	gere_key3(keycode, env);
	gere_offset(keycode, env);
	draw(env);
	return (0);
}
void raw_kill( CHAR_DATA *victim, int absolute )
{
    int i = 0;

/*
    if(victim->fighting != NULL)
    {
	if(victim->fighting->ooc_xp_count < 2) {
	    send_to_char("You learn from your encounter.\n\r",
		 victim->fighting);
	    victim->fighting->exp += 1;
	}
	stop_fighting( victim, TRUE );
    }
*/

    if(!absolute && victim->race == race_lookup("werewolf")
	&& ((i = dice_rolls(victim, victim->max_RBPG, 8)) > 0
	    || victim->agghealth > 0))
    {
	bool tag = FALSE;

	if(victim->health < 0)
	    victim->health = 0;
	if(victim->agghealth < 0) {
	    victim->agghealth = 0;
	    tag = TRUE;
	}

	if(absolute) tag = TRUE;

	if(tag) {
	    i -= 7 - victim->health;
	    if(i > 0)
	      victim->agghealth +=
		UMIN(7 - victim->agghealth, i);
	}
	else while((victim->agghealth + victim->health - 7) <= 0)
	{
	    if(victim->health >= 7)
		victim->agghealth++;
	    else victim->health++;
	}
	send_to_char("It hurts, but your body starts to heal.\n\r", victim);
	update_pos(victim, 0);
	if((victim->agghealth + victim->health - 7) > 0)
	    return;
    }

    if(victim->clan == clan_lookup("bone gnawer")
	&& victim->disc[DISC_TRIBE] >= 5
	&& victim->max_willpower > 0)
    {
	victim->max_willpower--;
	if(victim->willpower > victim->max_willpower)
	{
	    victim->willpower = victim->max_willpower;
	}
	if(victim->health <= 0)
	    victim->health = 1;
	if(victim->agghealth <= 0)
	    victim->agghealth = 1;
	while((victim->agghealth + victim->health - 7) <= 0)
	{
	    if(victim->health >= 7)
		victim->agghealth++;
	    else victim->health++;
	}
	send_to_char("It hurts, but you'll live.\n\r", victim);
	return;
    }

    death_cry( victim );
    make_corpse( victim );

    if ( IS_NPC(victim) )
    {
	victim->pIndexData->killed++;
	extract_char( victim, TRUE );
	return;
    }

    clear_orgs(victim);
    if(victim->desc)
    victim->desc->connected = CON_DECEASED;
    SET_BIT(victim->act, ACT_REINCARNATE);

    char_from_room(victim);
    char_from_list(victim);
    send_to_char("You are DEAD!\n\r[Hit Return to Continue]\n\r", victim);
    victim->exp = get_points(victim);
    save_char_obj(victim);
    return;
}
Beispiel #25
0
CubitStatus ChollaCurve::order_edges()
{
  int i;
  bool periodic = false;
  if (NULL == startPoint)
  {
    DLIList<ChollaPoint *>  cholla_points = get_points();
    periodic = (cholla_points.size() == 1);

    ChollaPoint *chpt = cholla_points.get();
    CubitPoint *start_point = dynamic_cast<CubitPoint *> (chpt->get_facets());

    this->set_start( start_point );
    if (NULL == start_point)
      return CUBIT_FAILURE;
    start_point->set_as_feature();

    if (periodic)
    {
      this->set_end(start_point);
    }
    else
    {
      chpt = cholla_points.step_and_get();
      CubitPoint *end_point = dynamic_cast<CubitPoint *> (chpt->get_facets());
      if (NULL == end_point)
        return CUBIT_FAILURE;
      this->set_end(end_point);
      end_point->set_as_feature();
    }
  }

  assert(startPoint);  
  assert(endPoint);

  if (curveEdgeList.size() > 1)
  {    
    DLIList<CubitFacetEdge*> edges_ordered;
    CAST_LIST(curveEdgeList, edges_ordered, CubitFacetEdge);
    
    CubitStatus stat = CubitFacetEdge::order_edge_list(edges_ordered, startPoint, endPoint);

    if (CUBIT_FAILURE == stat)
      return CUBIT_FAILURE;

    // store the edges in the correct order
    clean_out_edges();    

    edges_ordered.reset();
    for (i=0; i< edges_ordered.size(); i++)
    {      
      this->add_facet(edges_ordered.get_and_step());     
    }    
  }

  
  // make sure all the edges are oriented correctly
  DLIList<FacetEntity *> flist = this->get_facet_list();
  flist.reset();
  DLIList<CubitFacetEdge *> elist;
  CAST_LIST( flist, elist, CubitFacetEdge );
  elist.reset();
  CubitPoint *cur_pt = startPoint, *tmp_pt;
  for ( i = elist.size(); i > 0; i-- ) 
  {
    CubitFacetEdge *edge_ptr = elist.get_and_step();
    CubitPoint *point0_ptr = edge_ptr->point(0);
    CubitPoint *point1_ptr = edge_ptr->point(1);
    if (point0_ptr != cur_pt)
    {
      assert( cur_pt == point1_ptr );
      edge_ptr->flip();
      tmp_pt = point0_ptr;
      point0_ptr = point1_ptr;
      point1_ptr = tmp_pt;
      assert( point0_ptr == edge_ptr->point(0) &&
             point1_ptr == edge_ptr->point(1) );
    }
    cur_pt = point1_ptr;
  }
  
  int mydebug = 0;
  if (mydebug)
  {
    int i;
    DLIList<FacetEntity *> flist = this->get_facet_list();
    flist.reset();
    DLIList<CubitFacetEdge *> elist;
    CAST_LIST( flist, elist, CubitFacetEdge );
    elist.reset();
    for ( i = elist.size(); i > 0; i-- ) {  
      CubitFacetEdge *edge = elist.get_and_step();
      CubitVector pt0_v = edge->point(0)->coordinates();
      CubitVector pt1_v = edge->point(1)->coordinates();
      GfxDebug::draw_point(pt0_v, CUBIT_GREEN );
      GfxDebug::draw_point(pt1_v, CUBIT_RED );
      GfxDebug::draw_line( pt0_v, pt1_v, CUBIT_YELLOW );
      GfxDebug::flush();
      int view = 0;
      if (view)
        dview();
    }
  }
  return CUBIT_SUCCESS;
}
Beispiel #26
0
void CUIFrameWindow::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	Fvector2 back_len			= {0.0f, 0.0f};
	u32 rect_count				= 4; //lt+rt+lb+rb
	back_len.x					= rect.width()-m_tex_rect[fmLT].width()-m_tex_rect[fmRT].width();
	back_len.y					= rect.height()-m_tex_rect[fmLT].height()-m_tex_rect[fmRB].height();
	R_ASSERT					(back_len.x+EPS_L>=0.0f && back_len.y+EPS_L>=0.0f);
	
	u32 cnt =0;
	if(back_len.x>0.0f)//top+bottom
		cnt						= 2* iCeil(back_len.x/m_tex_rect[fmT].width());
	rect_count					+= cnt;

	if(back_len.y>0.0f)//left+right
		cnt						= 2* iCeil(back_len.y/m_tex_rect[fmL].height());
	rect_count					+= cnt;
	
	if(back_len.x>0.0f && back_len.y>0.0f) //back
		cnt						= iCeil(back_len.x/m_tex_rect[fmBK].width()) * iCeil(back_len.y/m_tex_rect[fmBK].height()) ;

	rect_count					+= cnt;

	rect_count					*= 6;
	
	UIRender->StartPrimitive	(rect_count, IUIRender::ptTriList, UI().m_currentPointType);

	Fvector2 LTt, RBt;
	Fvector2 LTp, RBp;

	Frect tmp					= rect;
	get_points					(tmp, fmLT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.lt.x;
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmLB].height();
	get_points					(tmp, fmLB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRT].width();
	tmp.lt.y					= rect.lt.y;;
	get_points					(tmp, fmRT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRB].width();
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmRB].height();
	get_points					(tmp, fmRB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	if(back_len.x>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.x				+= m_tex_rect[fmLT].width();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.lt.y+m_tex_rect[fmT].height();
		draw_tile_line			(tmp, fmT, true, ts);

		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.rb.y-m_tex_rect[fmB].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.rb.y;
		draw_tile_line			(tmp, fmB, true, ts);
	}

	if(back_len.y>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.y				+= m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.lt.x+m_tex_rect[fmL].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmLB].height();
		draw_tile_line			(tmp, fmL, false, ts);

		tmp.lt.x				= rect.rb.x-m_tex_rect[fmR].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmRT].height();;
		tmp.rb.x				= rect.rb.x;
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_line			(tmp, fmR, false, ts);
	}

	if(back_len.x>0.0f && back_len.y>0.0f)
	{
		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRB].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_rect			(tmp, fmBK, ts);
	}

	UIRender->FlushPrimitive	();
}
Beispiel #27
0
 // Returns the snake path in the dynamic matrix described as a succes
 std::vector<std::pair<int, int> > compute_snake(std::string A, std::string B) {
     // We have to index the dynamic from 1
     A = " " + A;
     B = " " + B;
     // Indices for comparing texts
     int begin_i = 0;
     int begin_j = 0;
     int end_i = A.length() - 1;
     int end_j = B.length() - 1;
     
     // Maximum editing distance
     int maxD = (2 + A.length() + B.length()) / 2;
     
     // Remember positions in the "snakes"
     std::vector<std::map<int, std::pair<int, int> > > distance_begin(maxD);
     std::vector<std::map<int, std::pair<int, int> > > distance_end(maxD);
     // We need this for remembering the track of the cells
     std::map<std::pair<int, int>, std::pair<int, int> > father;
     // We use these to mark whether we reached the cell on the other corner
     std::map<std::pair<int, int>, bool> reachA;
     std::map<std::pair<int, int>, bool> reachB;
     
     forward_advance(begin_i, begin_j, A, B);
     distance_begin[0][0] = {begin_i, begin_j};
     father[{begin_i, begin_j}] = {-1, -1};
     reachA[{begin_i, begin_j}] = true;
     
     // In this case the taexts are identical
     if (begin_i == A.length() - 1 && begin_j == B.length() - 1) {
         return get_points({begin_i, begin_j}, {end_i + 1, end_j + 1}, father);
     }
     
     backward_advance(end_i, end_j, A, B);
     distance_end[0][B.length() - A.length()] = {end_i, end_j};
     father[{end_i, end_j}] = {A.length(), B.length()};
     reachB[{end_i, end_j}] = true;
     
     // Iterate through the diffing distance
     for (int d = 1; d <= maxD; d += 1) {
         // In all of the if conditions that are followed by returns it means that the 2 snakes have met
         
         // Iterate throguh the best for each diagonal starting from top-left
         for (auto &it : distance_begin[d - 1]) {
             // Advance and update by making another step
             int diagonal_decay = it.first;
             begin_i = it.second.first;
             begin_j = it.second.second;
             
             if (begin_i + 1 < A.length()) {
                 int new_decay = diagonal_decay - 1;
                 int new_i = begin_i + 1;
                 int new_j = begin_j;
                 if (reachB[{new_i, new_j}]) {
                     return get_points(it.second, {new_i, new_j}, father);
                 }
                 forward_advance(new_i, new_j, A, B);
                 reachA[distance_begin[d + 1][new_decay]] = false;
                 auto cell = distance_begin[d + 1][new_decay];
                 if (!cell.first || cell.first + cell.second < new_i + new_j) {
                     distance_begin[d + 1][new_decay] = {new_i, new_j};
                     father[{new_i, new_j}] = {begin_i, begin_j};
                 }
                 reachA[distance_begin[d + 1][new_decay]] = true;
             }
             
             if (begin_j + 1 < B.length()) {
                 int new_decay = diagonal_decay + 1;
                 int new_i = begin_i;
                 int new_j = begin_j + 1;
                 if (reachB[{new_i, new_j}]) {
                     return get_points(it.second, {new_i, new_j}, father);
                 }
                 forward_advance(new_i, new_j, A, B);
                 reachA[distance_begin[d + 1][new_decay]] = false;
                 auto cell = distance_begin[d + 1][new_decay];
                 if (!cell.first || cell.first + cell.second < new_i + new_j) {
                     distance_begin[d + 1][new_decay] = {new_i, new_j};
                     father[{new_i, new_j}] = {begin_i, begin_j};
                 }
                 reachA[distance_begin[d + 1][new_decay]] = true;
             }
         }
         // Same as previous for but starting from bottom-right
         for (auto &it : distance_end[d - 1]) {
             // Same as previous for
             int diagonal_decay = it.first;
             begin_i = it.second.first;
             begin_j = it.second.second;
             
             if (begin_i - 1 >= 0) {
                 int new_decay = diagonal_decay + 1;
                 int new_i = begin_i - 1;
                 int new_j = begin_j;
                 if (reachA[{new_i, new_j}]) {
                     return get_points({new_i, new_j}, it.second, father);
                 }
                 backward_advance(new_i, new_j, A, B);
                 reachB[distance_end[d + 1][new_decay]] = false;
                 auto cell = distance_end[d + 1][new_decay];
                 if (!cell.first || cell.first + cell.second > new_i + new_j) {
                     distance_end[d + 1][new_decay] = {new_i, new_j};
                     father[{new_i, new_j}] = {begin_i, begin_j};
                 }
                 reachB[distance_end[d + 1][new_decay]] = true;
             }
             
             if (begin_j - 1 >= 0) {
                 int new_decay = diagonal_decay - 1;
                 int new_i = begin_i;
                 int new_j = begin_j - 1;
                 if (reachA[{new_i, new_j}]) {
                     return get_points({new_i, new_j}, it.second, father);
                 }
                 backward_advance(new_i, new_j, A, B);
                 reachB[distance_end[d + 1][new_decay]] = false;
                 auto cell = distance_end[d + 1][new_decay];
                 if (!cell.first || cell.first + cell.second > new_i + new_j) {
                     distance_end[d + 1][new_decay] = {new_i, new_j};
                     father[{new_i, new_j}] = {begin_i, begin_j};
                 }
                 reachB[distance_end[d + 1][new_decay]] = true;
             }
         }
     }
     return {{0,0}};
 }
Beispiel #28
0
static gpointer
manager_alloc_font (HTMLFontManager *manager,
                    gchar *face,
                    GtkHTMLFontStyle style)
{
	return html_painter_alloc_font (manager->painter, face, get_real_font_size (manager, style), get_points (manager, style), style);
}
Beispiel #29
0
int main(int argc, char *argv[]) { /* MAIN CODE STARTS HERE */
  
  int i, /* j, */ bin;
  double val, bin_width;
  STATS stats;
  char log_name[25];

  /* Check for correct number of comand line arguments */
  if (argc != 4) {
      fprintf(stderr, 
	      "Missing comand line arguments,\nUSAGE: <program name> <config file> <points file> <wind file>\n\n");
    exit(1);
  }
  

  /* Each node opens a file for logging */
  sprintf(log_name, "%s", LOG_FILE);
  fprintf(stderr, "%s\n", log_name);
  log_file  = fopen(log_name, "w+");
  if (log_file == NULL) {
    fprintf(stderr, "Cannot open LOG file=[%s]:[%s]. Exiting.\n", 
	    log_name, strerror(errno));
    exit(1);
  }

  
  /* Initialize the global variables (see top of file) with inputs from the configuration file. */
  if ( init_globals(argv[1]) ) {
    exit(1);
  }
  
#ifdef _PRINT
  fflush(log_file); 
#endif

  /*make sure the points file exists*/
  in_points= fopen(argv[2], "r");
  if (in_points == NULL) {
    fprintf(stderr, "Cannot open points  file=[%s]:[%s]. Exiting.\n", 
	    argv[2], strerror(errno));
    exit_now(1);
  }
  
  /* Input the data points from a file using the
     get_points function. 
  */
  
  if (get_points(in_points) ) {
    exit_now(1);
  }

#ifdef _PRINT
  fflush(log_file); 
#endif
  
  /*make sure the wind file exists*/
  in_wind= fopen(argv[3], "r");
  if (in_wind == NULL) {
    fprintf(stderr, "Cannot open wind file=[%s]:[%s]. Exiting.\n", 
	    argv[3], strerror(errno));
    exit_now(1);
  }
  
  if (get_wind(in_wind) ) {
    exit_now(1);
  }
  
#ifdef _PRINT
  fflush(log_file); 
#endif
  
  set_global_values(log_file);
  
#ifdef _PRINT
  fflush(log_file); 
#endif
 

  set_eruption_values(&e, W[0]);
  for (i = 0; i < num_pts; i++)
  {/* For each location */
     tephra_calc(&e, pt+i, W[0], &stats);
  }
 #ifdef _PRINT
  fprintf(log_file, "Calculated mass...\n"); 
  for (i = 0;  i < num_pts;  i++) {
    fprintf(log_file, "[%.0f][%.0f] %g ", (pt+i)->easting, (pt+i)->northing, (pt+i)->calculated_mass) ;
    fprintf(log_file, "\n"); 
}
  fprintf(log_file, "Finished.\n");
   fflush(log_file);
    
  #endif
    
    fprintf(stderr,"\nMin Particle Fall Time = %gs\nMax Particle Fall Time = %gs\n",stats.min_falltime, stats.max_falltime);
	//printf("Mean_fall_time %15.6e\n",stats.
	/*phi_bins = (int)((erupt+j)->max_phi - (erupt+j)->min_phi); 
	if (phi_bins < 1) phi_bins = 1; */
	bin_width = (e.max_phi - e.min_phi)/PART_STEPS;
	printf("#EAST NORTH ELEV Kg/m^2 ");
	for (bin = 0; bin < PART_STEPS; bin++) 
	  printf("[%6.5f:%6.5f) ", 
		e.min_phi + bin_width*bin, 
		e.min_phi + bin_width*(bin+1));
	printf("\n");
	
	fprintf(stderr, "PART_STEPS=%d bin_width=%g\n", PART_STEPS, bin_width);
	for (i=0; i < num_pts; i++) {
	  printf("%20.8e %20.8e %20.8e %20.8e ", 
		(pt+i)->easting, 
		(pt+i)->northing,
		(pt+i)->elevation, 
		(pt+i)->calculated_mass);
	///* Print out percent of total */
	  for (bin=0; bin < PART_STEPS; bin++) {
	  	//val = ((pt+i)->calculated_phi[bin]/(pt+i)->calculated_mass);
          val = (pt+i)->calculated_phi[bin];

	  	//fprintf(stderr, "bin = %g mass = %g ", (pt+i)->phi[bin], (pt+i)->mass )
          printf("%20.8e ", val);
	     }
	  printf("\n");
	}
  print_for_stats(0); 
  fprintf(log_file, "Finished.\n");
  exit_now(0);
  return 1;
}