Beispiel #1
0
bool WorldDownloadManager::marchingCubes(TsdfCloud::Ptr cloud, std::vector<Mesh::Ptr> &output_meshes) const
{
  try
  {
   // Creating world model object
    pcl::kinfuLS::WorldModel<pcl::PointXYZI> wm;

    //Adding current cloud to the world model
    wm.addSlice (cloud);

    std::vector<pcl::PointCloud<pcl::PointXYZI>::Ptr> clouds;
    std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > transforms;

    //Get world as a vector of cubes
    wm.getWorldAsCubes (pcl::device::kinfuLS::VOLUME_X, clouds, transforms, 0.025); // 2.5% overlapp (12 cells with a 512-wide cube)

    //Creating the standalone marching cubes instance
    float volume_size = pcl::device::kinfuLS::VOLUME_SIZE;

    std::cout << "Processing world with volume size set to " << volume_size << "meters\n";

    pcl::gpu::kinfuLS::StandaloneMarchingCubes<pcl::PointXYZI> marching_cubes (pcl::device::kinfuLS::VOLUME_X,
      pcl::device::kinfuLS::VOLUME_Y, pcl::device::kinfuLS::VOLUME_Z, volume_size);

    marching_cubes.getMeshesFromTSDFVectorMemory(clouds,transforms,output_meshes);

    std::cout << "Done!\n";
    return true;
  }
  catch (const pcl::PCLException& /*e*/) { PCL_ERROR ("PCLException... Exiting...\n"); return false; }
  catch (const std::bad_alloc& /*e*/) { PCL_ERROR ("Bad alloc... Exiting...\n"); return false; }
  catch (const std::exception& /*e*/) { PCL_ERROR ("Exception... Exiting...\n"); return false; }
}
Beispiel #2
0
void InitGL()
{
    glEnable(GL_DEPTH_TEST);
    glClearColor(0.2, 0.2 , 0.6, 0.0);

    projection = mat4_create(projection);

    view = mat4_create(view);

    model = mat4_create(model);
    model = mat4_identity(model);

    scan_data data = load_scan_data(filename, data_width, data_height, data_length, bit_rate);
    marching_cubes(threshold, &data, debug, &g);
    model = mat4_translate(model, g.center, model);
    free(data.data);
}
static void
animate_lava (ModeInfo *mi)
{
  lavalite_configuration *bp = &bps[MI_SCREEN(mi)];
  int wire = MI_IS_WIREFRAME(mi);
  Bool just_started_p = bp->just_started_p;

  double isolevel = 0.3;

  /* Maybe bubble a new blobby to the surface.
   */
  if (just_started_p ||
      frand(1.0) < bp->launch_chance)
    {
      bp->just_started_p = False;
      launch_balls (mi);

      if (do_impatient && just_started_p)
        while (1)
          {
            int i;
            move_balls (mi);
            for (i = 0; i < bp->nballs; i++)
              {
                metaball *b = &bp->balls[i];
                if (b->alive_p && !b->static_p && !b->leader &&
                    b->z > 0.5)
                  goto DONE;
              }
          }
      DONE: ;
    }

  move_balls (mi);

  glNewList (bp->ball_list, GL_COMPILE);
  glPushMatrix();

  glMaterialfv (GL_FRONT, GL_SPECULAR,            lava_spec);
  glMateriali  (GL_FRONT, GL_SHININESS,           lava_shininess);
  glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, lava_color);

  /* For the blobbies, the origin is on the axis at the bottom of the
     glass bottle; and the top of the bottle is +1 on Z.
   */
  glTranslatef (0, 0, -0.5);

  mi->polygon_count = 0;
  {
    double s;
    if (bp->grid_size == 0) bp->grid_size = 1;  /* first time through */
    s = 1.0/bp->grid_size;

    glPushMatrix();
    glTranslatef (-0.5, -0.5, 0);
    glScalef (s, s, s);
    marching_cubes (resolution, isolevel, wire, do_smooth,
                    obj_init, obj_compute, obj_free, bp,
                    &mi->polygon_count);
    glPopMatrix();
  }

  mi->polygon_count += bp->bottle_poly_count;

  glPopMatrix();
  glEndList ();
}