コード例 #1
0
 static typename edge_capacity_value<Graph, P, T, R>::type
 apply
 (Graph& g,
  typename graph_traits<Graph>::vertex_descriptor src,
  typename graph_traits<Graph>::vertex_descriptor sink,
  PredMap pred,
  const bgl_named_params<P, T, R>& params,
  detail::error_property_not_found)
 {
   typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
   typedef typename graph_traits<Graph>::vertices_size_type size_type;
   size_type n = is_default_param(get_param(params, vertex_color)) ?
     num_vertices(g) : 1;
   std::vector<default_color_type> color_vec(n);
   return edmunds_karp_max_flow
     (g, src, sink, 
      choose_const_pmap(get_param(params, edge_capacity), g, edge_capacity),
      choose_pmap(get_param(params, edge_residual_capacity), 
                  g, edge_residual_capacity),
      choose_const_pmap(get_param(params, edge_reverse), g, edge_reverse),
      make_iterator_property_map(color_vec.begin(), choose_const_pmap
                                 (get_param(params, vertex_index),
                                  g, vertex_index), color_vec[0]),
      pred);
 }
コード例 #2
0
// color control callbacks
void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl)
{
	LLWLParamManager::getInstance()->mAnimator.deactivate();

	LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl);
	LLVector4 color_vec(swatch->get().mV);

	// Set intensity to maximum of the RGB values.
	color_vec.mV[3] = llmax(color_vec.mV[0], llmax(color_vec.mV[1], color_vec.mV[2]));

	// Multiply RGB values by the appropriate factor.
	F32 k = WL_CLOUD_SLIDER_SCALE;
	if (color_ctrl->isSunOrAmbientColor)
	{
		k = WL_SUN_AMBIENT_SLIDER_SCALE;
	}
	if (color_ctrl->isBlueHorizonOrDensity)
	{
		k = WL_BLUE_HORIZON_DENSITY_SCALE;
	}

	color_vec *= k; // intensity isn't affected by the multiplication

	// Apply the new RGBI value.
	*color_ctrl = color_vec;
	color_ctrl->update(LLWLParamManager::getInstance()->mCurParams);
	LLWLParamManager::getInstance()->propagateParameters();
}
コード例 #3
0
ファイル: undirected_dfs.hpp プロジェクト: 0xDEC0DE8/mcsema
 static void
 apply(const Graph& g, DFSVisitor vis, Vertex start_vertex,
       const bgl_named_params<P, T, R>& params,
       EdgeColorMap edge_color,
       param_not_found)
 {
   std::vector<default_color_type> color_vec(num_vertices(g));
   default_color_type c = white_color; // avoid warning about un-init
   undirected_dfs
     (g, vis, make_iterator_property_map
      (color_vec.begin(),
       choose_const_pmap(get_param(params, vertex_index),
                         g, vertex_index), c),
      edge_color,
      start_vertex);
 }
コード例 #4
0
int main(int argc, char ** argv)
{

	if(argc>1)
	{
   	// Test with the normal order
		Graph g(0);
		vertex_index_map m_index = get(boost::vertex_index, g);
		vertex_name_map m_name = get(boost::vertex_name, g);
		vertex_color_map m_color = get(boost::vertex_color, g);


		boost::dynamic_properties dp;
		
		// dp.property("node_id", m_index);
		// dp.property("label", m_name);
		
		dp.property("node_id", m_name);
		
		std::fstream infile(argv[1], std::ios::in);

		bool status = boost::read_graphviz(infile, g, dp, std::string("node_id"));

		std::vector<vertices_size_type> color_vec(num_vertices(g));
 
    	boost::iterator_property_map<vertices_size_type*, vertex_index_map> color(&color_vec.front(), boost::get(boost::vertex_index, g));
    	vertices_size_type num_colors = boost::sequential_vertex_coloring(g, color);


		int k=0;
		boost::graph_traits<Graph>::vertex_iterator v, v_end;
		for(boost::tie(v,v_end) = boost::vertices(g); v!=v_end; v++)
		{	
			m_color[*v]=static_cast<boost::default_color_type>(color_vec[k++]);
		}
	
		write_graphviz(std::cout, g, 
		graph_coloring::make_label_writer(m_name, m_color),
		boost::default_writer(),
		graph_coloring::graph_property_with_label_writer<vertices_size_type>(num_colors));
	}
	else 
		std::cout << "Put right args list!" << std::endl;

	return 0;
}
コード例 #5
0
ファイル: voxel.cpp プロジェクト: Dakror/voxie
unsigned char VoxelFile::get_closest_index(RGBColor c)
{
    load_palette();
    vec3 color_vec(c.r, c.g, c.b);
    bool is_set = false;
    float dist;
    unsigned char current_index = 0;
    for (int i = 0; i < 256; i++) {
        RGBColor & pal_color = global_palette[i];
        vec3 new_vec(pal_color.r, pal_color.g, pal_color.b);
        float new_dist = glm::distance(color_vec, new_vec);
        if (is_set && new_dist >= dist)
            continue;
        is_set = true;
        dist = new_dist;
        current_index = i;
    }
    return current_index;
}
コード例 #6
0
 static void apply
 (VertexListGraph& g,
  typename graph_traits<VertexListGraph>::vertex_descriptor s,
  const bgl_named_params<P, T, R>& params,
  detail::error_property_not_found)
 {
   std::vector<default_color_type> color_vec(num_vertices(g));
   default_color_type c = white_color;
   null_visitor null_vis;
   
   bfs_helper
     (g, s, 
      make_iterator_property_map
      (color_vec.begin(), 
       choose_const_pmap(get_param(params, vertex_index), 
                         g, vertex_index), c),
      choose_param(get_param(params, graph_visitor),
                   make_bfs_visitor(null_vis)),
      params);
 }
コード例 #7
0
ファイル: s52references.cpp プロジェクト: zappa672/RLIDisplay
void S52References::fillColorTables2() {
  int current_index = 0;
  QList<QString> table_names = color_tables.keys();

  // Loop 1, filling color_indices
  for (int i = 0; i < table_names.size(); i++) {
    QString table_ref = table_names[i];
    QList<QString> color_names = color_tables[table_ref]->colors.keys();

    for (int j = 0; j < color_names.size(); j++)
      if (!color_indices.contains(color_names[j]))
          color_indices.insert(color_names[j], current_index++);
  }

  QList<QString> color_names = color_indices.keys();
  // Loop 2, filling color_tables2
  for (int i = 0; i < table_names.size(); i++) {
    QString table_ref = table_names[i];
    ColorTable* tbl = color_tables[table_ref];
    std::vector<float> color_vec(3*color_indices.size());

    for (int j = 0; j < color_names.size(); j++) {
      int index = color_indices[color_names[j]];

      if (tbl->colors.contains(color_names[j])) {
        color_vec[3*index+0] = tbl->colors[color_names[j]].redF();
        color_vec[3*index+1] = tbl->colors[color_names[j]].greenF();
        color_vec[3*index+2] = tbl->colors[color_names[j]].blueF();
      } else {
        color_vec[3*index+0] = 0;
        color_vec[3*index+1] = 0;
        color_vec[3*index+2] = 0;
      }
    }

    color_tables2.insert(table_ref, color_vec);
  }

  return;
}
コード例 #8
0
ファイル: gui_plugin.cpp プロジェクト: tue-robotics/ed
void GUIPlugin::publishMapImage()
{
    // clear image
    map_image_ = cv::Mat(map_image_.rows, map_image_.cols, CV_8UC3, cv::Scalar(10, 10, 10));

    // Draw world model shapes

    cv::Mat z_buffer(map_image_.rows, map_image_.cols, CV_32FC1, 0.0);

    for(ed::WorldModel::const_iterator it_entity = world_model_->begin(); it_entity != world_model_->end(); ++it_entity)
    {
        const ed::EntityConstPtr& e = *it_entity;

        if (e->shape() && e->id() != "floor")
        {
            cv::Scalar color = idToColor(e->id());
            cv::Vec3b color_vec(0.5 * color[0], 0.5 * color[1], 0.5 * color[2]);

            geo::Pose3D pose = projector_pose_.inverse() * e->pose();
            geo::RenderOptions opt;
            opt.setMesh(e->shape()->getMesh(), pose);

            ColorRenderResult res(map_image_, z_buffer, color_vec, projector_pose_.t.z - 3, projector_pose_.t.z + 1);

            // Render
            projector_.render(opt, res);
        }
    }

    for(ed::WorldModel::const_iterator it_entity = world_model_->begin(); it_entity != world_model_->end(); ++it_entity)
    {
        const ed::EntityConstPtr& e = *it_entity;

        const pcl::PointCloud<pcl::PointXYZ>& chull_points = e->convexHull().chull;

        cv::Scalar color = idToColor(e->id());
        int thickness = 1;
        if (selected_id_ == e->id())
            thickness = 3;

        // draw the polygon
        if (!chull_points.empty())
        {
            // Lower polygon
            for(unsigned int i = 0; i < chull_points.size(); ++i)
            {
                int j = (i + 1) % chull_points.size();

                const pcl::PointXYZ& p1 = chull_points[i];
                const pcl::PointXYZ& p2 = chull_points[j];

                cv::line(map_image_,
                         coordinateToPixel(p1.x, p1.y, e->convexHull().min_z),
                         coordinateToPixel(p2.x, p2.y, e->convexHull().min_z),
                         0.3 * color, thickness);
            }

            // Edges in between
            for(unsigned int i = 0; i < chull_points.size(); ++i)
            {
                const pcl::PointXYZ p = chull_points[i];
                cv::line(map_image_,
                         coordinateToPixel(p.x, p.y, e->convexHull().min_z),
                         coordinateToPixel(p.x, p.y, e->convexHull().max_z),
                         0.5 * color, thickness);
            }


            // Upper polygon
            for(unsigned int i = 0; i < chull_points.size(); ++i)
            {
                int j = (i + 1) % chull_points.size();

                const pcl::PointXYZ& p1 = chull_points[i];
                const pcl::PointXYZ& p2 = chull_points[j];

                cv::line(map_image_,
                         coordinateToPixel(p1.x, p1.y, e->convexHull().max_z),
                         coordinateToPixel(p2.x, p2.y, e->convexHull().max_z),
                         color, thickness);
            }

            if (e->type() == "person")
            {

                cv::circle(map_image_, coordinateToPixel(e->convexHull().center_point), 15, cv::Scalar(255, 0, 0), 10);
            }
        }
    }

    // Find the global most recent measurement
    ed::MeasurementConstPtr last_measurement;
    for(ed::WorldModel::const_iterator it_entity = world_model_->begin(); it_entity != world_model_->end(); ++it_entity)
    {
        const ed::EntityConstPtr& e = *it_entity;
        if (e->lastMeasurement() && (!last_measurement || e->lastMeasurement()->timestamp() > e->lastMeasurement()->timestamp()))
            last_measurement = e->lastMeasurement();
    }

    if (last_measurement)
    {
        const geo::Pose3D& sensor_pose = last_measurement->sensorPose();

        // Draw sensor origin
        const geo::Vector3& p = sensor_pose.getOrigin();
        cv::Point2i p_2d = coordinateToPixel(p);

        cv::circle(map_image_, p_2d, 10, cv::Scalar(255, 255, 255));

        rgbd::View view(*last_measurement->image(), 100); // width doesnt matter; we'll go back to world coordinates anyway
        geo::Vector3 p1 = view.getRasterizer().project2Dto3D(0, 0) * 3;
        geo::Vector3 p2 = view.getRasterizer().project2Dto3D(view.getWidth() - 1, 0) * 3;
        geo::Vector3 p3 = view.getRasterizer().project2Dto3D(0, view.getHeight() - 1) * 3;
        geo::Vector3 p4 = view.getRasterizer().project2Dto3D(view.getWidth() - 1, view.getHeight() - 1) * 3;

        cv::Point2i p1_2d = coordinateToPixel(sensor_pose * p1);
        cv::Point2i p2_2d = coordinateToPixel(sensor_pose * p2);
        cv::Point2i p3_2d = coordinateToPixel(sensor_pose * p3);
        cv::Point2i p4_2d = coordinateToPixel(sensor_pose * p4);

        cv::Scalar fustrum_color(100, 100, 100);

        cv::line(map_image_, p_2d, p1_2d, fustrum_color);
        cv::line(map_image_, p_2d, p2_2d, fustrum_color);
        cv::line(map_image_, p_2d, p3_2d, fustrum_color);
        cv::line(map_image_, p_2d, p4_2d, fustrum_color);

        cv::line(map_image_, p1_2d, p2_2d, fustrum_color);
        cv::line(map_image_, p1_2d, p3_2d, fustrum_color);
        cv::line(map_image_, p2_2d, p4_2d, fustrum_color);
        cv::line(map_image_, p3_2d, p4_2d, fustrum_color);
    }

    if (t_last_click_ > ros::Time(0) && t_last_click_ > ros::Time::now() - ros::Duration(1))
    {
        cv::circle(map_image_, p_click_, 20, cv::Scalar(0, 0, 255), 5);
    }

    // Convert to binary
    tue_serialization::Binary msg;
    if (imageToBinary(map_image_, msg.data, IMAGE_COMPRESSION_PNG))
    {
        pub_image_map_.publish(msg);
    }

//    cv::imshow("gui", map_image_);
//    cv::waitKey(3);
}
コード例 #9
0
ファイル: isomorphism.hpp プロジェクト: 4eek/xtractorfan
      bool test_isomorphism()
      {
        {
          std::vector<invar1_value> invar1_array;
          BGL_FORALL_VERTICES_T(v, G1, Graph1)
            invar1_array.push_back(invariant1(v));
          sort(invar1_array);
        
          std::vector<invar2_value> invar2_array;
          BGL_FORALL_VERTICES_T(v, G2, Graph2)
            invar2_array.push_back(invariant2(v));
          sort(invar2_array);
          if (! equal(invar1_array, invar2_array))
            return false;
        }
        
        std::vector<vertex1_t> V_mult;
        BGL_FORALL_VERTICES_T(v, G1, Graph1)
          V_mult.push_back(v);
        {
          std::vector<size_type> multiplicity(max_invariant, 0);
          BGL_FORALL_VERTICES_T(v, G1, Graph1)
            ++multiplicity[invariant1(v)];
          sort(V_mult, compare_multiplicity(invariant1, &multiplicity[0]));
        }
        
        std::vector<default_color_type> color_vec(num_vertices(G1));
        safe_iterator_property_map<std::vector<default_color_type>::iterator,
                                   IndexMap1
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
                                   , default_color_type, default_color_type&
#endif /* BOOST_NO_STD_ITERATOR_TRAITS */
                                   >
          color_map(color_vec.begin(), color_vec.size(), index_map1);
        record_dfs_order dfs_visitor(dfs_vertices, ordered_edges);
        typedef color_traits<default_color_type> Color;
        for (vertex_iter u = V_mult.begin(); u != V_mult.end(); ++u) {
          if (color_map[*u] == Color::white()) {
            dfs_visitor.start_vertex(*u, G1);
            depth_first_visit(G1, *u, dfs_visitor, color_map);
          }
        }
        // Create the dfs_num array and dfs_num_map
        dfs_num_vec.resize(num_vertices(G1));
        dfs_num = make_safe_iterator_property_map(dfs_num_vec.begin(),
                                                  dfs_num_vec.size(), 
                                                  index_map1
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
                                                  , dfs_num_vec.front()
#endif /* BOOST_NO_STD_ITERATOR_TRAITS */
                                                  );
        size_type n = 0;
        for (vertex_iter v = dfs_vertices.begin(); v != dfs_vertices.end(); ++v)
          dfs_num[*v] = n++;
        
        sort(ordered_edges, edge_cmp(G1, dfs_num));
        
    
        int dfs_num_k = -1;
        return this->match(ordered_edges.begin(), dfs_num_k);
      }