Example #1
0
void TwoDSceneXMLParser::loadSceneFromXML( const std::string& filename, TwoDScene& twodscene, SceneStepper** scenestepper, scalar& dt, scalar& max_t, scalar& maxfreq, std::vector<renderingutils::Color>& particle_colors, std::vector<renderingutils::Color>& edge_colors, std::vector<renderingutils::ParticlePath>& particle_paths, renderingutils::Color& bgcolor, std::string& description, std::string& scenetag, TwoDimensionalDisplayController& display)
{
  assert( *scenestepper == NULL );
  //std::cout << "Loading scene: " << filename << std::endl;
  
  // Load the xml document
  std::vector<char> xmlchars;
  rapidxml::xml_document<> doc;
  loadXMLFile( filename, xmlchars, doc );

  // Attempt to locate the root node
  rapidxml::xml_node<>* node = doc.first_node("scene");
  if( node == NULL ) 
  {
    std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl;
    exit(1);
  }    
  
  // TODO: Clear old state

  // Camera
  loadCameraLocation(node, display);

  // Scene
  loadParticles( node, twodscene );
  loadEdges( node, twodscene );
  loadSceneTag( node, scenetag );
  // Forces
  loadSpringForces( node, twodscene );
  loadSimpleGravityForces( node, twodscene );
  loadGravitationalForces( node, twodscene );
  loadDragDampingForces( node, twodscene );
  loadVorexForces( node, twodscene );
  // Integrator/solver
  loadIntegrator( node, scenestepper, dt );
  loadMaxTime( node, max_t );
  // UI
  loadMaxSimFrequency( node, maxfreq );  
  // Rendering state
  particle_colors.resize(twodscene.getNumParticles(),renderingutils::Color(0.650980392156863,0.294117647058824,0.0));
  loadParticleColors( node, particle_colors );
  edge_colors.resize(twodscene.getNumEdges(),renderingutils::Color(0.0,0.388235294117647,0.388235294117647));
  loadEdgeColors( node, edge_colors );
  loadBackgroundColor( node, bgcolor );
  loadParticlePaths( node, dt, particle_paths );
  
  std::string description_string;
  loadSceneDescriptionString( node, description );
}
Example #2
0
void ompl::base::PlannerDataStorage::load(std::istream &in, PlannerData &pd)
{
    pd.clear();

    const SpaceInformationPtr &si = pd.getSpaceInformation();
    if (!in.good())
    {
        OMPL_ERROR("Failed to load PlannerData: input stream is invalid");
        return;
    }
    if (!si)
    {
        OMPL_ERROR("Failed to load PlannerData: SpaceInformation is invalid");
        return;
    }
    // Loading the planner data:
    try
    {
        boost::archive::binary_iarchive ia(in);

        // Read the header
        Header h;
        ia >> h;

        // Checking the archive marker
        if (h.marker != OMPL_PLANNER_DATA_ARCHIVE_MARKER)
        {
            OMPL_ERROR("Failed to load PlannerData: PlannerData archive marker not found");
            return;
        }

        // Verify that the state space is the same
        std::vector<int> sig;
        si->getStateSpace()->computeSignature(sig);
        if (h.signature != sig)
        {
            OMPL_ERROR("Failed to load PlannerData: StateSpace signature mismatch");
            return;
        }

        // File seems ok... loading vertices and edges
        loadVertices(pd, h.vertex_count, ia);
        loadEdges(pd, h.edge_count, ia);
    }
    catch (boost::archive::archive_exception &ae)
    {
        OMPL_ERROR("Failed to load PlannerData: %s", ae.what());
    }
}
Example #3
0
int main() {
  utils::StopWatch sw(true);

  loadEdges();

  dijkstra();

  std::vector<int> desired = { 7, 37, 59, 82, 99, 115, 133, 165, 188, 197 };
  std::stringstream ss;
  for (auto &vertex : desired) {
    ss << distances[vertex];
    if (vertex != desired.back()) {
      ss << ",";
    }
  }
  std::cout << ss.str() << std::endl;
  utils::CopyToClipboard(ss.str());

  sw.stop();
  std::cout << sw.getLastElapsed() << std::endl;
  std::cin.ignore();
  return 0;
}