Exemplo n.º 1
0
void ompl::base::PlannerDataStorage::store(const PlannerData &pd, std::ostream &out)
{
    const SpaceInformationPtr &si = pd.getSpaceInformation();
    if (!out.good())
    {
        OMPL_ERROR("Failed to store PlannerData: output stream is invalid");
        return;
    }
    if (!si)
    {
        OMPL_ERROR("Failed to store PlannerData: SpaceInformation is invalid");
        return;
    }
    try
    {
        boost::archive::binary_oarchive oa(out);

        // Writing the header
        Header h;
        h.marker = OMPL_PLANNER_DATA_ARCHIVE_MARKER;
        h.vertex_count = pd.numVertices();
        h.edge_count = pd.numEdges();
        si->getStateSpace()->computeSignature(h.signature);
        oa << h;

        storeVertices(pd, oa);
        storeEdges(pd, oa);
    }
    catch (boost::archive::archive_exception &ae)
    {
        OMPL_ERROR("Failed to store PlannerData: %s", ae.what());
    }
}
Exemplo n.º 2
0
Obj::Obj(const std::string &f) {
  std::ifstream file;
  file.open(f);
  filename = f;

  std::string str;

  while(!file.eof()) {
    std::getline(file, str);
    if(str[0] == 'v')
      break;
  }

  int v = 0;

  while(str[0] == 'v') {
    int i = 0;

    while(true) {
      while(str[i] == ' ')
        i++;
      i += 2;
      int j = i, k = i;
      while(str[i] != ' ') {  
          i++;
          k = i;
      }
      _x[v] = atof(str.substr(j, k - j).c_str());

      while(str[i] == ' ' ) {
        i++;
      }

      int q = i, w = i;
      while(str[i] != ' ' ) {
        i++;
        w = i;
      }
      _y[v] = atof(str.substr(q, w - q).c_str());

      while(str[i] == ' ' ) {
        i++;
      }

      int a = i, s = i;
      while(str[i] != ' ' ) {
        i++;
        s = i;
      }
      _z[v] = atof(str.substr(a, s - a).c_str());
      break;
    }
    v++; 
    getline(file, str);
  }
  file.close();
  storeVertices();
  storeMap();
}
Exemplo n.º 3
0
/* set up vertices and triangles*/
void init(void) 
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);	/* don't show hidden surfaces */
    glEnable(GL_LIGHTING);		/* enable lighting explicitly */
    glEnable(GL_LIGHT0);		/* enable light source-1 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); /* use two side lighting*/

    /* set up all the vertices and its normals, and triangles */
    storeVertices();
    storeTriangles();
    initVertNormals();
    addTri2VertNormals();
    normlizeVertNormals();

    /* use array vertex */
    glEnableClientState (GL_VERTEX_ARRAY);
    glEnableClientState (GL_NORMAL_ARRAY);
    glVertexPointer (3, GL_FLOAT, 0, v);
    glNormalPointer(GL_FLOAT, 0, vn);
}