Example #1
0
/**
 * aran_solver3d_remove_point:
 * @solver: an #AranSolver3d.
 * @point: a particle.
 *
 * Removes a particle from the associated #VsgPRTree3d.
 *
 * Returns: %TRUE on success.
 */
gboolean aran_solver3d_remove_point (AranSolver3d *solver,
                                     VsgPoint3 point)
{
  g_return_val_if_fail (solver != NULL, FALSE);

  return vsg_prtree3d_remove_point (solver->prtree, point);
}
Example #2
0
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgVector3d lb = {-1., -1., -1.};
  VsgVector3d ub = {1., 1., 1.};

  VsgVector3d points[] = {
    {-0.5, -0.5, -.5},
    {0.5, -0.5, -.5},
    {-0.5, 0.5, .5},
    {0.25, 0.25, .5},
    {0.75, 0.75, .5},
    {1.75, 1.75, 1.}, /* exterior point */
    {1.75, 100.75, 1.}, /* another exterior point */
    {1.75, -100.75, 1.}, /* another exterior point */
  };

  const guint n = sizeof (points) / sizeof (VsgVector3d);

  VsgPRTree3d *tree;
  gint i;

  if (argc > 1 && g_ascii_strncasecmp (argv[1], "--version", 9) == 0)
    {
      g_print ("%s\n", PACKAGE_VERSION);
      return 0;
    }

  vsg_init_gdouble ();

  /* create the tree */
  tree =
    vsg_prtree3d_new_full (&lb, &ub,
                           (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                           (VsgPoint3dDistFunc) vsg_vector3d_dist,
                           NULL, 1);

  /* insert some points */
  for (i=0; i<n; i++)
    {
      vsg_prtree3d_insert_point (tree, &points[i]);
    }

  /* do some traversal */
  i=0;
  vsg_prtree3d_traverse (tree, G_PRE_ORDER,
                         (VsgPRTree3dFunc) traverse_point_count, &i);

  /* check the results */
  if (i != n)
    {
      g_printerr ("ERROR: traverse point count %d (should be %d)\n",
                  i, n);

      ret ++;
    }

  /* remove the points */
  for (i=0; i<n; i++)
    {
      vsg_prtree3d_remove_point (tree, &points[i]);
    }

  /* destroy the tree */
  vsg_prtree3d_free (tree);

  return ret;
}
Example #3
0
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgVector3d lb = {-1., -1., -1.};
  VsgVector3d ub = {1., 1., 1.};
  NodeCounter counter = {0, 0};
  const guint m = 100;
  const guint n = 1000;

  Pt points[m*n];

  VsgPRTree3d *tree;
  gint i;

  if (argc > 1 && g_strncasecmp (argv[1], "--version", 9) == 0)
    {
      g_print ("%s\n", PACKAGE_VERSION);
      return 0;
    }

  vsg_init_gdouble ();

  /* create the tree */
  tree = vsg_prtree3d_new (&lb, &ub, NULL);

  vsg_prtree3d_set_node_data (tree, TYPE_NODE_COUNTER, &counter);

  /* create the points */
  create_points (points, m, n);

  /* insert the points into the tree */
  for (i=0; i<m*n; i++)
    {
      vsg_prtree3d_insert_point (tree, &points[i]);
    }

/*    g_printerr ("ok depth = %d size = %d\n", */
/*                vsg_prtree3d_depth (tree), */
/*                vsg_prtree3d_point_count (tree)); */

  /* accumulate the point counts across the tree */
  vsg_prtree3d_traverse (tree, G_POST_ORDER, (VsgPRTree3dFunc) up, NULL);

  /* do some near/far traversal */
  vsg_prtree3d_near_far_traversal (tree, (VsgPRTree3dFarInteractionFunc) far,
                                   (VsgPRTree3dInteractionFunc) near,
                                   &ret);

  /*  distribute back the point counts across the tree */
  vsg_prtree3d_traverse (tree, G_PRE_ORDER, (VsgPRTree3dFunc) down, NULL);

  /* check the results */
  for (i=0; i<m*n; i++)
    {
      if (points[i].count != m*n)
        {
          g_printerr ("ERROR: wrong count on point %d: %d (should be %d).\n",
                      i, points[i].count, n);
          ret ++;
        }
    }

  /* remove the points */
  for (i=0; i<m*n; i++)
    {
      vsg_prtree3d_remove_point (tree, &points[i]);
    }

  /* destroy the tree */
  vsg_prtree3d_free (tree);

  return ret;
}
Example #4
0
gint main (gint argc, gchar ** argv)
{
  gint ret = 0;

  VsgVector3d lb = {-1., -1., -1.};
  VsgVector3d ub = {1., 1., 1.};

  VsgVector3d *points;
  gint lvl = 1;
  gint n, np;

  VsgPRTree3d *tree;
  gint i, j, k, l;

  if (argc > 1 && g_strncasecmp (argv[1], "--version", 9) == 0)
    {
      g_print ("%s\n", PACKAGE_VERSION);
      return 0;
    }

  if (argc > 1)
    {
      sscanf (argv[1], "%d", &lvl);
    }

  n = 1<<lvl;
  np = n*n*n;

  vsg_init_gdouble ();

  /* create the points */
  points = g_malloc (np * sizeof (VsgVector3d));
  l = 0;
  for (i=0; i<n; i++)
    {
      gdouble x = 2. * ((i+0.5)/n) - 1.;

      for (j=0; j<n; j++)
        {
          gdouble y = 2. * ((j+0.5)/n) - 1.;

          for (k=0; k<n; k++)
            {
              gdouble z = 2. * ((k+0.5)/n) - 1.;

              vsg_vector3d_set (&points[l], x, y, z);
              l ++;
            }
        }
    }

  /* create the tree */
  tree =
    vsg_prtree3d_new_full (&lb, &ub,
                           (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                           (VsgPoint3dDistFunc) vsg_vector3d_dist,
                           NULL, 1);

  /* configure for hilbert curve order traversal */
  vsg_prtree3d_set_children_order (tree, hilbert3_order,
                                   GINT_TO_POINTER (HK3_0_2_1));

  /* insert some points */
  for (i=0; i<np; i++)
    {
      vsg_prtree3d_insert_point (tree, &points[i]);
    }

  /* do some traversal */
  i=0;
  vsg_prtree3d_traverse (tree, G_PRE_ORDER,
                         (VsgPRTree3dFunc) traverse_point_count, &i);

  /* check the results */
  if (i != np)
    {
      g_printerr ("ERROR: traverse point count %d (should be %d)\n",
                  i, n);

      ret ++;
    }

  /* remove the points */
  for (i=0; i<np; i++)
    {
      vsg_prtree3d_remove_point (tree, &points[i]);
    }

  g_free (points);

  /* destroy the tree */
  vsg_prtree3d_free (tree);

  return ret;
}