Ejemplo n.º 1
0
gint check_deepest_dist (TestData *td)
{
  guint64 res;
  VsgPRTreeKey2d k1, k2;

  read_key (td->k1, &k1);
  read_key (td->k2, &k2);

  res = vsg_prtree_key2d_deepest_distance (&k1, &k2);

  if (res != td->ref)
    {
      g_printerr ("Error - k1 = \"%s\" -> (", td->k1);
      vsg_prtree_key2d_write (&k1, stderr);
      g_printerr (") k2 = \"%s\" -> (", td->k2);
      vsg_prtree_key2d_write (&k2, stderr);
      g_printerr (") ref=%ld != res=%ld ", td->ref, res);
      g_printerr ("\n");

      return 1;
    }
  else if (_verbose)
    {
      g_printerr ("OK - k1 = \"%s\"", td->k1);
      g_printerr (" k2 = \"%s\"", td->k2);
      g_printerr (" ref=%ld", td->ref);
      g_printerr ("\n");

    }

  return 0;
}
Ejemplo n.º 2
0
void _traverse_fg_write (VsgPRTree2dNodeInfo *node_info, FILE *file)
{
  fprintf (file, "<!-- %d: node ", rk);
  vsg_prtree_key2d_write (&node_info->id, file);
  fprintf (file, " -->\n");
  g_slist_foreach (node_info->point_list, (GFunc) _pt_write, file);
}
Ejemplo n.º 3
0
void _near (VsgPRTree2dNodeInfo *one_info,
            VsgPRTree2dNodeInfo *other_info,
            gint *err)
{
  glong one_count = 0, other_count = 0;

  if (!(one_info->isleaf && other_info->isleaf))
    {
      g_printerr ("ERROR: call for near_func on non leaf node [");
      vsg_prtree_key2d_write (&one_info->id, stderr);
      g_printerr ("]=%d / [", one_info->isleaf);
      vsg_prtree_key2d_write (&other_info->id, stderr);
      g_printerr ("]=%d\n", other_info->isleaf);
      (*err) ++;
    }

  g_slist_foreach (other_info->point_list, (GFunc) pt_get_weight,
                   &other_count);

  g_slist_foreach (one_info->point_list, (GFunc) pt_add_count,
                   &other_count);

  if (one_info != other_info)
    {
      g_slist_foreach (one_info->point_list, (GFunc) pt_get_weight,
                       &one_count);

      g_slist_foreach (other_info->point_list, (GFunc) pt_add_count,
                       &one_count);
    }

  if (one_info->point_count == 0 || other_info->point_count == 0)
    {
      g_printerr ("%d : unnecessary near call point_counts = %d/%d\n", rk,
                  one_info->point_count, other_info->point_count);
      (*err) ++;
    }

  _near_count ++;
}
Ejemplo n.º 4
0
void _traverse_fg_write (VsgPRTree2dNodeInfo *node_info, FILE *file)
{
  fprintf (file, "<!-- %d: fg node ", rk);
  vsg_prtree_key2d_write (&node_info->id, file);
  fprintf (file, " -->\n");
  /* g_slist_foreach (node_info->point_list, (GFunc) _pt_write, file); */

  /* if (!node_info->isleaf) return; */

  /* if (!_center_set) */
  /*   { */
  /*     _center_set = TRUE; */
  /*     _current_center = node_info->center; */
  /*   } */
  /* else */
  /*   { */
  /*     fprintf (file, "<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" " \ */
  /*              "style=\"stroke-linecap: round; stroke-width: 0.01; stroke: black;\"/>\n", */
  /*              _current_center.x, - _current_center.y, */
  /*              node_info->center.x, - node_info->center.y); */
  /*     _current_center = node_info->center; */
  /*   } */
}
Ejemplo n.º 5
0
void _near (VsgPRTree2dNodeInfo *one_info,
            VsgPRTree2dNodeInfo *other_info,
            gint *err)
{
  glong one_count = 0, other_count = 0;

  if (!(one_info->isleaf && other_info->isleaf))
    {
      g_printerr ("ERROR: call for near_func on non leaf node [");
      vsg_prtree_key2d_write (&one_info->id, stderr);
      g_printerr ("]=%d / [", one_info->isleaf);
      vsg_prtree_key2d_write (&other_info->id, stderr);
      g_printerr ("]=%d\n", other_info->isleaf);
      (*err) ++;
    }

  g_slist_foreach (other_info->point_list, (GFunc) pt_get_weight,
                   &other_count);

  g_slist_foreach (one_info->point_list, (GFunc) pt_add_count,
                   &other_count);

  if (one_info != other_info)
    {
      g_slist_foreach (one_info->point_list, (GFunc) pt_get_weight,
                       &one_count);

      g_slist_foreach (other_info->point_list, (GFunc) pt_add_count,
                       &one_count);
    }

  if (one_info->point_count == 0 || other_info->point_count == 0)
    {
      g_printerr ("%d : unnecessary near call point_counts = %d/%d\n", rk,
                  one_info->point_count, other_info->point_count);
      (*err) ++;
    }

  if (_do_write && VSG_PRTREE2D_NODE_INFO_IS_REMOTE (one_info))
    {
      gchar fn[1024];
      FILE *f;
      sprintf (fn, "comm-%03d.svg", rk);
      f = fopen (fn, "a");

      fprintf (f, "<!--s=%d--><polyline points=\"%g,%g %g,%g\" "        \
               "style=\"stroke:#00FF00;\"/>\n",
               rk,
               one_info->center.x, -one_info->center.y,
               other_info->center.x, -other_info->center.y);
      fclose (f);
    }

  {
    long i, j = 0;
    for (i = 0; i< _near_slowdown; i++)
      {
        j = j + i;
      }
    if (j != _near_slowdown*(_near_slowdown-1)/2) g_printerr ("oops\n");
  }
  _near_count ++;
}
Ejemplo n.º 6
0
void _traverse_bg_write (VsgPRTree2dNodeInfo *node_info, FILE *file)
{
  /* ugly colormap */
  static const gchar *colors[] = {
    "#800000",
    "#FF0000",
    "#808000",
    "#008000",
    "#00FF00",
    "#008080",
    "#00FFFF",
    "#000080",
    "#0000FF",
    "#800080",
  };

  gdouble x = node_info->lbound.x;
  gdouble y = -node_info->ubound.y;
  gdouble w = node_info->ubound.x - x;
  gdouble h = -node_info->lbound.y - y;
  const gchar *fill = "#FFFFFF";

  if (! VSG_PRTREE2D_NODE_INFO_IS_REMOTE (node_info))
    {
      fprintf (file, "<!-- %d: node ", rk);
      vsg_prtree_key2d_write (&node_info->id, file);
      fprintf (file, " in=%ld out=%ld -->\n",
                  ((NodeCounter *) node_info->user_data)->in_count,
                  ((NodeCounter *) node_info->user_data)->out_count);
    }

  if (!node_info->isleaf) return;

  if (VSG_PRTREE2D_NODE_INFO_IS_REMOTE (node_info))
    {
      gint proc = VSG_PRTREE2D_NODE_INFO_PROC (node_info) %
        (sizeof (colors) / sizeof (gchar *));
      fill = colors[proc];
    }

  fprintf (file, "<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" " \
           "rx=\"0\" style=\"stroke-width:0.001;stroke:#000000; " \
           "stroke-linejoin:miter; stroke-linecap:butt; fill:%s;\">\n",
           x, y, w, h, fill);
  fprintf (file, "<title>");
  vsg_prtree_key2d_write (&node_info->id, file);
  fprintf (file, "</title>\n");

  if (! VSG_PRTREE2D_NODE_INFO_IS_REMOTE (node_info))
    {
      fprintf (file, "<desc>in=%ld out=%ld</desc>\n",
               ((NodeCounter *) node_info->user_data)->in_count,
               ((NodeCounter *) node_info->user_data)->out_count);
    }
  else
    {
      fprintf (file, "<desc>proc=%d</desc>\n",
               VSG_PRTREE2D_NODE_INFO_PROC (node_info));
    }

  fprintf (file, "</rect>\n");
}