当前位置: 首页>>代码示例>>C++>>正文


C++ SimulationController::environment方法代码示例

本文整理汇总了C++中shawn::SimulationController::environment方法的典型用法代码示例。如果您正苦于以下问题:C++ SimulationController::environment方法的具体用法?C++ SimulationController::environment怎么用?C++ SimulationController::environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shawn::SimulationController的用法示例。


在下文中一共展示了SimulationController::environment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawableEdgeDynamicTransmissionRange

   // ----------------------------------------------------------------------
   void
   CreateDynamicEdgesTransmissionRangeTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);
      GroupElement* all_edges = new GroupElement("all.edges");
      visualization_w().add_element(all_edges);

      std::string pref = sc.environment().
            optional_string_param("prefix",DrawableEdgeDynamic::PREFIX);
      std::string node_prefix = sc.environment().
            optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);

      std::string _source_regex = sc.environment().optional_string_param("source_regex", ".*");
      std::string _target_regex = sc.environment().optional_string_param("target_regex", ".*");

      const shawn::Node &dummy = *(visualization().world().begin_nodes());
      std::cout << "Regex: " << _source_regex << std::endl;
      DrawableEdgeDynamicTransmissionRange* ded =
                        new DrawableEdgeDynamicTransmissionRange(dummy,dummy, pref, node_prefix, _source_regex, _target_regex);
      ded->init();
      visualization_w().add_element(ded);
      all_edges->add_element(*ded);
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:26,代码来源:vis_create_dynamic_edges_transmission_range.cpp

示例2: run

   // ----------------------------------------------------------------------
   void
   CreateEstimatedEdgesTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);

      std::string pref = sc.environment().
         optional_string_param("prefix",DrawableEdgeEstimated::PREFIX);
      std::string node_prefix =
         sc.environment().
         optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);
      GroupElement* grp = group(sc);

      for( shawn::World::const_node_iterator
              it    = visualization().world().begin_nodes(),
              endit = visualization().world().end_nodes();
           it != endit; ++it )
      {
         if( it->has_est_position())
         {
            const DrawableNode* dn = drawable_node(*it, node_prefix);
            DrawableEdgeEstimated* dee = new DrawableEdgeEstimated(*it, *dn, 
               DrawableEdgeEstimated::PREFIX);
            dee->init();
            visualization_w().add_element(dee);
            if( grp != NULL )
               grp->add_element(*dee);
         }
      }
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:32,代码来源:vis_create_estimated_edges.cpp

示例3: runtime_error

   AutoElements::
   AutoElements( shawn::SimulationController& sc,
                 Visualization& vis )
      throw( std::runtime_error )
      : current_ ( NULL )
#ifdef HAVE_BOOST_REGEX
      , regex_   ( NULL )
#endif
   {
      std::string parm;

      tag_ = sc.environment().optional_string_param("tag", "");

      parm=sc.environment().optional_string_param("elem","");
      if( !parm.empty()  )
         {
            mode_=Single;
            current_ = vis.element_w(parm);
            if( current_.is_null() )
               throw std::runtime_error(std::string("no such element: ") + parm );
            return;
         }

      parm=sc.environment().optional_string_param("elem_regex","");
      std::string tagregex = sc.environment().optional_string_param("tag_regex","");
      if( !parm.empty() || (!tagregex.empty() && !tag_.empty()))
         {
#ifdef HAVE_BOOST_REGEX
            if(tag_.empty() || tagregex.empty())
               mode_=Regex;
            else
               mode_=TagRegex;

            try {
               if(mode_==Regex)
                  regex_= new boost::regex(parm);
               else
                  regex_= new boost::regex(tagregex);
            } 
            catch(...) {
               throw std::runtime_error(std::string("regular expression is bad"));
            }

            vis_cur_=vis.elements().begin();
            vis_end_=vis.elements().end();
            advance_infeasible();

            return;
#else
            throw std::runtime_error(std::string("no regexp support compiled in"));
#endif
         }
       

      throw std::runtime_error(std::string("specify elements (either $elem or $elem_regex)"));
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:56,代码来源:vis_auto_elements.cpp

示例4: run

   // ----------------------------------------------------------------------
   void
   ConstantElevationTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      double val = sc.environment().required_double_param("height");
      std::string n = sc.environment().optional_string_param("name","");

      elevation_keeper_w(sc).add( new ConstantElevation(val,n) );
   }
开发者ID:honr,项目名称:shawn,代码行数:11,代码来源:constant_elevation_task.cpp

示例5: if

   // ----------------------------------------------------------------------
   void
   XYZFileElevationTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      std::string fn       = sc.environment().required_string_param("file");
      std::string outn     = sc.environment().required_string_param("name");
      std::string xyplacen = sc.environment().optional_string_param("xy_placement",KEY_SCALE);
      std::string zplacen  = sc.environment().optional_string_param("z_placement",KEY_SCALE);
      bool xyplace_box;
      bool zplace_box;

      if( xyplacen == KEY_BOX )      xyplace_box = true;
      else if( xyplacen==KEY_SCALE ) xyplace_box = false;
      else throw runtime_error(string("$xy_placement must be ")+KEY_SCALE+string(" or ")+KEY_BOX);

      if( zplacen == KEY_BOX )      zplace_box = true;
      else if( zplacen==KEY_SCALE ) zplace_box = false;
      else throw runtime_error(string("$z_placement must be ")+KEY_SCALE+string(" or ")+KEY_BOX);

      XYZFile* data = new XYZFile;
      Vec base_point;
      Vec scale_vec;
      XYZFileElevation* elev;
      try {
         data->read(fn);

         if( (data->x_dimension()<2) || (data->y_dimension()<2) )
            {
               ostringstream oss;
               oss << "XYZ data must have at least 2x2 grid points, but "
                   << fn << " just contains "
                   << data->x_dimension() << "x" << data->y_dimension();
               throw runtime_error(oss.str());
            }

         if( xyplace_box ) xy_place_box(sc,*data,base_point,scale_vec);
         else xy_place_scale(sc,*data,base_point,scale_vec);

         if( zplace_box ) z_place_box(sc,*data,base_point,scale_vec);
         else z_place_scale(sc,*data,base_point,scale_vec);

         elev = new XYZFileElevation(data,
                                     base_point,
                                     scale_vec.x(),scale_vec.y(),scale_vec.z(),
                                     outn);
      }
      catch( runtime_error& )
	  {
         delete data;
         throw;
      }

      elevation_keeper_w(sc).add( elev );
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:56,代码来源:xyz_file_elevation_task.cpp

示例6: throw

 // ----------------------------------------------------------------------
 void
 XYZFileElevationTask::
 z_place_scale( shawn::SimulationController& sc,
               const XYZFile& f,
               shawn::Vec& bp, shawn::Vec& s )
    throw( std::runtime_error )
 {
    bp = Vec( bp.x(), bp.y(),
              sc.environment().optional_double_param("z_base",0.0) );
    s = Vec( s.x(), s.y(),
             sc.environment().optional_double_param("z_scale",1.0) );
 }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:13,代码来源:xyz_file_elevation_task.cpp

示例7:

   // --------------------------------------------------------------------
   bool
   TestbedServiceServer::
   start_server( const shawn::SimulationController& sc )
   {
      host_ = sc.environment().required_string_param( "testbedservice_server_host" );
      port_ = sc.environment().required_int_param( "testbedservice_server_port" );
      TestbedServiceServer::WorkerThread::wsdl_path =
         sc.environment().required_string_param( "testbedservice_wsdl" );

      runner_ = new boost::thread( boost::bind( &WorkerThread::run, &worker_, host_, port_ ) );
      return true;
   }
开发者ID:honr,项目名称:shawn,代码行数:13,代码来源:testbedservice_server.cpp

示例8: file_op

		// ----------------------------------------------------------------------
		void
			TreeCreationTask::
			create_tree_in_file( shawn::SimulationController& sc,
								 const std::string& filename,
								 const shawn::Node& sink,
								 int max_hops )
			throw()
		{
			// Avoid appending
			bool append = sc.environment().optional_bool_param("append",false);
			if(!append)
			{
				remove( filename.c_str() );
			}
			// Init stuff
//			double now = sink.current_time();
			NodesToExamineMap nodes_to_examine;
			TreeCreationHopsToSinkResult& result = *( new TreeCreationHopsToSinkResult( sc.world_w() ) );
			ofstream file_op(filename.c_str(),ios::app);
			// Treat the sink
			file_op << sink.id() << "\t"
					<< sink.id() << "\t"
					<< sink.id() << "\t"
					<< 0 << "\t"
					<< sink.real_position().x() << "\t"
					<< sink.real_position().y() << endl;
			result[sink].hops_ = 0;
			nodes_to_examine.insert( NodesToExamineMapValueType(0,&sink) );
			// Main loop
			while( ! nodes_to_examine.empty() )
			{
				NodesToExamineMapIterator min_it = nodes_to_examine.begin();
				const shawn::Node* min_node = min_it->second;
				nodes_to_examine.erase( min_it );
				for( World::const_adjacency_iterator adj_it = min_node->begin_adjacent_nodes();
					 adj_it != min_node->end_adjacent_nodes(); ++adj_it )
				{
					int hops = result[*min_node].hops_ + 1;
					if( hops < result[*adj_it].hops_ )
					{
						assert( result[*adj_it].hops_ == INT_MAX );
						result[*adj_it].hops_ = hops;
						file_op << adj_it->id() << "\t"
								<< sink.id() << "\t"
								<< min_node->id() << "\t"
								<< hops << "\t"
								<< adj_it->real_position().x() << "\t"
								<< adj_it->real_position().y() << endl;
						if( hops < max_hops )
						{
							nodes_to_examine.insert( NodesToExamineMapValueType( hops, &(*adj_it) ) );
						}
					}
				}
			}
			file_op.clear();
			file_op.close();
			delete &result;
		}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:60,代码来源:tree_creation_task.cpp

示例9: run

   // ----------------------------------------------------------------------
   void
   SpyglassTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
	   std::string spyglass_outfile = sc.environment().required_string_param("spyglass_file");
	   Spyglass::set_spyglass(spyglass_outfile);
   }
开发者ID:honr,项目名称:shawn,代码行数:9,代码来源:spyglass.cpp

示例10:

		// ----------------------------------------------------------------------
		void
			TreeCreationTask::
			run( shawn::SimulationController& sc )
			throw( std::runtime_error )
		{
			require_world( sc );
			bool tree_routing_set = false;
			bool filename_set = false;
			string tree_routing_instance = sc.environment().optional_string_param("routing_instance","",&tree_routing_set);
			string filename = sc.environment().optional_string_param("tree_creation_filename","",&filename_set);
			TreeRouting* routing_instance = NULL;

			if( tree_routing_set )
			{
				RoutingBaseHandle rbh = routing::routing_keeper_w(sc).find_w(tree_routing_instance);
				routing_instance = dynamic_cast<TreeRouting*>( rbh.get() );
				if( ! routing_instance )
				{
					ERROR(this->logger(),"The given routing is no TreeRouting!");
					abort();
				}
				routing_instance->init( sc.world_w() );
			}

			if( tree_routing_set && filename_set )
			{
				create_tree_from_file(sc,*routing_instance,filename);
				return;
			}
			int sink_id = sc.environment().required_int_param("sink_id");
			const Node* sink = sc.world().find_node_by_id( sink_id );

			if( tree_routing_set && ( ! filename_set ) )
			{
				create_tree_in_tree_routing( *routing_instance, *sink );
				return;
			}

			if( ( ! tree_routing_set ) && filename_set )
			{
				int max_hops = sc.environment().optional_int_param("max_hops",INT_MAX);
				create_tree_in_file( sc, filename, *sink, max_hops );
				return;
			}
		}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:46,代码来源:tree_creation_task.cpp

示例11: RectangleTopology

// ----------------------------------------------------------------------
void
RectangleTopologyTask::
run( shawn::SimulationController& sc )
throw( std::runtime_error )
{
    double x1 = sc.environment().required_double_param("x1");
    double x2 = sc.environment().required_double_param("x2");
    double y1 = sc.environment().required_double_param("y1");
    double y2 = sc.environment().required_double_param("y2");
    std::string n = sc.environment().optional_string_param("name","");

    if( x1 > x2 ) throw std::runtime_error("rectangle has negative X size");
    if( y1 > y2 ) throw std::runtime_error("rectangle has negative Y size");

    topology_keeper_w(sc).add( new RectangleTopology(Box(Vec(x1,y1,0.0),
                               Vec(x2,y2,0.0)),
                               n) );
}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:19,代码来源:rectangle_topology_task.cpp

示例12:

	// ----------------------------------------------------------------------
	void
		XMLPolygonTopologyTask::
		run( shawn::SimulationController& sc )
		throw( std::runtime_error )
	{

			std::string f = sc.environment().required_string_param("file");
			std::string n = sc.environment().required_string_param("name");
			bool create_outer =
				sc.environment().optional_bool_param("xml_create_outer_hull", false) ||
				sc.environment().optional_bool_param("create_outer_hull", false);

			bool fix_non_simple_polygons = sc.environment().optional_bool_param("fix_non_simple_polygons", false);

			XMLPolygonTopology* p = new XMLPolygonTopology;
			p->set_name(n);
			p->read(sc, f, create_outer, fix_non_simple_polygons);

			topology_keeper_w(sc).add(p);

	}
开发者ID:honr,项目名称:shawn,代码行数:22,代码来源:xml_polygon_topology_task.cpp

示例13: GroupElement

   // ----------------------------------------------------------------------
   void
   CreateGroupTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);

      GroupElement* ge =
         new GroupElement( sc.environment().required_string_param("group") );
      ge->init();
      visualization_w().add_element( ge );
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:13,代码来源:vis_create_group_task.cpp

示例14: run

   // ----------------------------------------------------------------------
   void
   CuboidTopologyTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      double x1 = sc.environment().required_double_param("x1");
      double x2 = sc.environment().required_double_param("x2");
      double y1 = sc.environment().required_double_param("y1");
      double y2 = sc.environment().required_double_param("y2");
      double z1 = sc.environment().required_double_param("z1");
      double z2 = sc.environment().required_double_param("z2");
      std::string n = sc.environment().optional_string_param("name","");

      if( x1 > x2 ) throw std::runtime_error("cuboid has negative X size");
      if( y1 > y2 ) throw std::runtime_error("cuboid has negative Y size");
      if( z1 > z2 ) throw std::runtime_error("cuboid has negative Z size");

      topology_keeper_w(sc).add( new CuboidTopology(Box(Vec(x1,y1,z1),
                                                        Vec(x2,y2,z2)),
                                                    n) );
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:22,代码来源:cuboid_topology_task.cpp

示例15: run

   // ----------------------------------------------------------------------
   void
   SingleSnapshotTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);

      double t = sc.environment().optional_double_param("time",0.0);
      int dr = sc.environment().optional_int_param("draft",0);

	   WriterFactoryHandle wfh = sc.keeper_by_name_w<WriterKeeper>("WriterKeeper")
		   ->find_w(sc.environment().optional_string_param("writer", "pdf"));
	   Writer* wr = wfh->create();

      wr->set_draft(dr);
      wr->pre_write( visualization(), sc.environment().optional_string_param("filename", "snapshot"), false );
      wr->write_frame( t );
      wr->post_write();

      delete wr;
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:22,代码来源:vis_single_snapshot.cpp


注:本文中的shawn::SimulationController::environment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。