Ejemplo n.º 1
0
QString suiScHelper::stringIdtf(const ScUri &uri, const ScUri &langUri) const
{
    // get all identifiers
    ScUriVector idtfs;
    allIdtfs(uri, idtfs);

    // iterate all identifiers and trying to find with specified language
    for (ScUriVector::iterator it = idtfs.begin(); it != idtfs.end(); ++it)
    {
        ScUri idtfUri = *it;
        // check language
        if (checkInclusion(idtfUri, langUri))
        {
            QString res;
            QIODevice *device = mMemoryInterface->open_content(idtfUri);

            if (device == 0)
                SuiExcept(SuiExceptionInvalidParameters,
                          QString("Can't open content for sc-element with uri = %1").arg(idtfUri.value()),
                          "QString suiScHelper::stringIdtf(const ScUri &uri, const ScUri &langUri) const");

            res = mMemoryInterface->decode_str_content(*device);
            mMemoryInterface->close_content(device);

            return res;
        }
    }

    return QString();
}
Ejemplo n.º 2
0
// visiting implies that site has already been determined to be included
void visit(int _i, int _j, int _k)
{
  recursion_matrix[_i][_j][_k] = 1; // mark the visited point
  test_x = verlet_center_x + (_i - 128) * resolution;
  test_y = verlet_center_y + (_j - 128) * resolution;
  test_z = verlet_center_z + (_k - 128) * resolution;
  printf("%06d\t%f\t%f\t%f\n", rattler, test_x, test_y, test_z);

  // check each neighbor for inclusion, and if included, then visit it...
  test_x = verlet_center_x + (_i - 129) * resolution;
  if (!recursion_matrix[_i - 1][_j][_k] && checkInclusion(test_x, test_y, test_z)) visit(_i - 1, _j, _k);
  test_x = verlet_center_x + (_i - 127) * resolution;
  if (!recursion_matrix[_i + 1][_j][_k] && checkInclusion(test_x, test_y, test_z)) visit(_i + 1, _j, _k);

  test_x = verlet_center_x + (_i - 128) * resolution;
  test_y = verlet_center_y + (_j - 129) * resolution;
  if (!recursion_matrix[_i][_j - 1][_k] && checkInclusion(test_x, test_y, test_z)) visit(_i, _j - 1, _k);
  test_y = verlet_center_y + (_j - 127) * resolution;
  if (!recursion_matrix[_i][_j + 1][_k] && checkInclusion(test_x, test_y, test_z)) visit(_i, _j + 1, _k);
  
  test_y = verlet_center_y + (_j - 128) * resolution;
  test_z = verlet_center_z + (_k - 129) * resolution;
  if (!recursion_matrix[_i][_j][_k - 1] && checkInclusion(test_x, test_y, test_z)) visit(_i, _j, _k - 1);
  test_z = verlet_center_z + (_k - 127) * resolution;
  if (!recursion_matrix[_i][_j][_k + 1] && checkInclusion(test_x, test_y, test_z)) visit(_i, _j, _k + 1);
}
Ejemplo n.º 3
0
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;

  setCommandLineParameters(argc, argv);
  if (getFlagParam("-usage"))
  {
    printf("usage:  cv [ -randomize ]\n\n");
    printf("        will return MC volume of list of spheres entered, box size determined automatically.\n");
    printf("\n");
    printf("// Reads a centered cluster and determines the volume of it.\n");
    printf("// Will deliver an erroneous result if cluster is not centered or percolates.\n");
    printf("\n");
    printf("// More generally, it will give the volume of all the cavities, whether clustered or not.\n");
    printf("\n");
    printf("// In:  one cluster; 1 or more records in .cav format \n");
    printf("// Out: .dst (reports one value of volume) \n");
    exit(1);
  }
  if (getFlagParam("-randomize")) initializeRandomNumberGenerator2(-1);
  else initializeRandomNumberGenerator2(0);

  instream = stdin;
  readInputStream();

  findMinimumBoxSize();

  successes=0;

  for (attempts=0; successes<N_SUCCESSES; attempts++)
  {
    // pick a point and check inclusion

    tx = rnd2() * box_x;
    ty = rnd2() * box_y;
    tz = rnd2() * box_z;

    successes += checkInclusion(tx, ty, tz);
    if (attempts > 100000000)
    {
      printf("too many attempts.");
      exit(1);
    }
  }

  volume = (box_x * box_y * box_z * successes)/attempts;

  printf("%lf\n", volume);
  return 0;
}
Ejemplo n.º 4
0
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;

  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  if (getFlagParam("-randomize")) initializeRandomNumberGenerator2(-1);
  else initializeRandomNumberGenerator2(0);

  readInputStream();

  successes=0;

  for (attempts=0; successes<N_SUCCESSES; attempts++)
  {
    // pick a point and check inclusion

    tx = rnd2() * box_x;
    ty = rnd2() * box_y;
    tz = rnd2() * box_z;

    successes += checkInclusion(tx, ty, tz);
    if (attempts > 100000000)
    {
      printf("too many attempts.");
      exit(1);
    }
  }

  volume = (box_x * box_y * box_z * successes)/attempts;

  printf("%lf\n", volume);
  return 0;
}
Ejemplo n.º 5
0
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;
  int centers;
  int i;
  double dx, dy, dz, dd;
  double zero_x, zero_y, zero_z;

  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  getIntParam("-n_centers", &n_centers);
  getIntParam("-n_attempts", &n_attempts);

  if (getFlagParam("-usage")) 
  {
    printf("usage:\t-box [ 10 10 10 ]\n");
    printf("      \t-n_centers [ 1000 ]\n");
    printf("      \t-n_attempts [ 1000 ]\n");
    exit(0);
  }

  rnd_step_x=box_x*rnd_step;
  rnd_step_y=box_y*rnd_step;
  rnd_step_z=box_z*rnd_step;

srand(15);

  instream = stdin;
  readInputStream();

  successes=0;

  for (centers=0; centers<n_centers; centers++)
  {
    center_x=rand()*rnd_step_x;
    center_y=rand()*rnd_step_y;
    center_z=rand()*rnd_step_z;
  
    /* build Verlet list */
    number_of_close=0;
    for (i=0; i<number_of_cavities; i++)
    {
      dx=center_x-x[i];
      dy=center_y-y[i];
      dz=center_z-z[i];
  
      dd = dx*dx + dy*dy + dz*dz;
      if (4*dd < (d_max + d[i])*(d_max + d[i]))
      {
        close_x[number_of_close] = x[i];
        close_y[number_of_close] = y[i];
        close_z[number_of_close] = z[i];
        close_d[number_of_close] = d[i];
        number_of_close++;
      }
    }

    zero_x=center_x-(d_max*0.69336127435063470484335227478596*.5);
    zero_y=center_y-(d_max*0.69336127435063470484335227478596*.5);
    zero_z=center_z-(d_max*0.69336127435063470484335227478596*.5);
    
    if (number_of_close>0) for (attempts=0; attempts<n_attempts; attempts++)
    {
      // pick a point and check inclusion

      tx = zero_x + rand() * rnd_step_center;
      ty = zero_y + rand() * rnd_step_center;
      tz = zero_z + rand() * rnd_step_center;

      successes += checkInclusion(tx, ty, tz);
    }
  }

  volume = (box_x * box_y * box_z * successes)/(n_centers*n_attempts);

  printf("%lf\n", volume);
  return 0;
}