Ejemplo n.º 1
0
void fill_t::solid_fill(point_t p,float width,float height){
	//std::cout<<"width  "<<width<<" and height "<<height<<std::endl;
	std::queue <point_t> fillQueue;
	fillQueue.push(p);
	float pointx=p.getX();
	float pointy=p.getY();
	color_t c=colorArray[(int)pointx][(int)pointy];
	
    color_t pixels;
    
    while(!fillQueue.empty()){
    	// std::cout<<c.getR()<<" ANSSS"<<std::endl;
    	// exit(0);
		p=fillQueue.front();
		pointx=p.getX();
		pointy=p.getY();
		fillQueue.pop();
		
		//Added Canvas size check
		if(pointx>=width || pointy>=height || pointx<0 || pointy<0)
			continue;
		pixels = colorArray[(int)pointx][(int)pointy];
		
		if( (pixels.getR()==c.getR()) && (pixels.getG()==c.getG()) && (pixels.getB()==c.getB()) )
		{
			
			point_t p1(pointx, pointy);
			p1.draw(pen_t(color1,1));
			fillQueue.push(point_t(pointx+1,pointy));
			fillQueue.push(point_t(pointx,pointy+1));
			fillQueue.push(point_t(pointx-1,pointy));
			fillQueue.push(point_t(pointx,pointy-1));
		}
	}
}
double calc(point_t c, double r, double a1, double a2) {
  double da = a2 - a1;
  double aa = r * r * (da - sin(da)) / 2;
  point_t p1 = point_t(cos(a1), sin(a1)) * r + c;
  point_t p2 = point_t(cos(a2), sin(a2)) * r + c;
  return cross(p1, p2) / 2 + aa;
}
Ejemplo n.º 3
0
void range_test()
{
    vector<point_t> points;
    vector<range_t> ranges;


    for (size_t i = 0; i < 1000; ++i)
    {
        const coord_t x = rand();
        const coord_t y = rand();
        points.push_back(point_t(x, y));
        points.push_back(point_t(x, rand()));
    }


    for (size_t i = 0; i < 1000; ++i)
    {
        coord_t inf = rand();
        coord_t sup = rand();
        if (sup < inf)
            std::swap(inf, sup);

        ranges.push_back(range_t(inf, sup));
    }



/*
    for (size_t i = 0; i < 10; ++i)
        points.push_back(point_t(i,  5));
*/


    const range_tree_t range_tree(points);

//    auto ind = range_tree.query(range_t(2, 8), range_t(4, 9));

    vector<bool> returned;
    for (size_t i = 0; i < ranges.size() / 2; ++i)
    {
        returned.resize(range_tree.points().size(), false);
        
        range_t x_range = ranges.at(i * 2 + 0);
        range_t y_range = ranges.at(i * 2 + 1);

        const auto indices = range_tree.query(x_range, y_range);
        BOOST_FOREACH(const auto index, indices)
        {
            returned.at(index) = true;
            const point_t point = range_tree.points().at(index);
            MY_ASSERT(point.x >= x_range.inf && point.x < x_range.sup && point.y >= y_range.inf && point.y < y_range.sup);
        }

        for (size_t index = 0; index < range_tree.points().size(); ++index)
        {
            const point_t point = range_tree.points().at(index);
            if (!returned.at(index))
                MY_ASSERT(point.x < x_range.inf || point.x >= x_range.sup || point.y < y_range.inf || point.y >= y_range.sup);
        }
    }
Ejemplo n.º 4
0
instance_t
make(const description_t& description)
{
	BOOST_LOG_TRIVIAL(debug) << "Make surface torus";

	const float max = description.major + description.minor;
	box_t box(point_t(-max, -max, -description.minor), point_t(+max, +max, +description.minor));
	model_t model(description.major, description.minor, std::move(box));
	return std::make_shared<instance_impl_t<model_t>>(description.transformation, std::move(model));
}
Ejemplo n.º 5
0
void fill_t::find_min_max(point_t p,int& YMin, int& YMax, int& XMin, int& XMax,float width,float height){
	//std::cout<<"Min max\n";
	std::queue <point_t> fmmQueue;
	fmmQueue.push(p);
	float pointx = p.getX();
	float pointy = p.getY();
	
	color_t c=colorArray[(int)pointx][(int)pointy];
    color_t pixels;
    
     while(!fmmQueue.empty()){
		p=fmmQueue.front();
		pointx=p.getX();
		pointy=p.getY();
		fmmQueue.pop();
		//Added Canvas size check
		if(pointx>=width || pointy>=height || pointx<0 || pointy<0)
			continue;
		
		pixels = colorArray[(int)pointx][(int)pointy];
		//glReadPixels(pointx,pointy,1.0,1.0,GL_RGB,GL_FLOAT,pixels);
		
		if( (pixels.getR()==c.getR()) && (pixels.getG()==c.getG()) && (pixels.getB()==c.getB()) )
		{
			if(pointy<YMin){
				YMin=pointy;
			}
			if(pointy>YMax){
				YMax=pointy;
			}
			
			if(pointx<XMin){
				XMin=pointx;
			}
			if(pointx>XMax){
				XMax=pointx;
			}
			p.draw(pen_t(color_t(0.5,0.5,0.5),1));
			//std::cout<<" let me pass!!! I am the point "<<pointx<<" and "<<pointy<<std::endl;
			fmmQueue.push(point_t(pointx+1,pointy));
			fmmQueue.push(point_t(pointx,pointy+1));
			fmmQueue.push(point_t(pointx-1,pointy));
			fmmQueue.push(point_t(pointx,pointy-1));
			// fmmQueue.push(point_t(pointx+1,pointy+1));
			// fmmQueue.push(point_t(pointx-1,pointy-1));
			// fmmQueue.push(point_t(pointx+1,pointy-1));
			// fmmQueue.push(point_t(pointx-1,pointy+1));
		}
	}
}
Ejemplo n.º 6
0
void findDoorCentroids(const cloud_t::Ptr &cloud, const std::vector<pcl::PointIndices> &indices, std::vector<point_t> &centroids) 
{
    // X-coord width in meters
    const float min_width = .8;
    const float max_width = .96;

    // Loop through clusters
    for (std::vector<pcl::PointIndices>::const_iterator it = indices.begin(); it != indices.end(); ++it) {

        // Create cluster from indices
        cloud_t::Ptr cluster(new cloud_t(*cloud, (*it).indices));        

        // Second check: door width
        point_t min;
        point_t max;
        pcl::getMinMax3D(*cluster, min, max);
        float door_width = sqrt(pow(max.x-min.x, 2.) + pow(max.y-min.y, 2.));
        //std::cout << door_width << std::endl;
        if ((door_width > min_width) && (door_width < max_width)) {
            // Return door centroid
            Eigen::Matrix<float, 4, 1> centroid;    
            pcl::compute3DCentroid(*cluster, centroid);
            centroids.push_back(point_t(centroid(0), centroid(1), centroid(2)));
            std::cout << "Found door with centroid at: " << centroid(0) << ", " << centroid(1) << ", " << centroid(2) << std::endl;
        }   
    }
}
Ejemplo n.º 7
0
void DiscretizationBlock::read(
    const H5::CommonFG &loc, const string &entry,
    const shared_ptr<Discretization> &discretization) {
  this->discretization = discretization;
  auto group = loc.openGroup(entry);
  assert(H5::readAttribute<string>(
             group, "type",
             discretization->manifold.lock()->project.lock()->enumtype) ==
         "DiscretizationBlock");
  H5::readAttribute(group, "name", name);
  assert(H5::readGroupAttribute<string>(group, "discretization", "name") ==
         discretization->name);
  if (group.attrExists("offset")) {
    vector<hssize_t> offset, shape;
    H5::readAttribute(group, "offset", offset);
    std::reverse(offset.begin(), offset.end());
    H5::readAttribute(group, "shape", shape);
    std::reverse(shape.begin(), shape.end());
    region = box_t(offset, point_t(offset) + shape);
  }
  if (group.attrExists("active")) {
    // TODO read_active<0>(group, *this, active);
    read_active<1>(group, *this, active);
    read_active<2>(group, *this, active);
    read_active<3>(group, *this, active);
    read_active<4>(group, *this, active);
  }
}
Ejemplo n.º 8
0
void				Tiles::Tmp::_buildGrid(void)
{
	ft::Vec2<float>			v;
	ft::Vec2<float> const	center(static_cast<float>(rectSize.x) / 2.f,
								   static_cast<float>(rectSize.y) / 2.f);
	ft::Vec2<float> const	scale(2.f / static_cast<float>(rectSize.x),
								  2.f / static_cast<float>(rectSize.y));

	this->grid.resize(this->gridDim.y);
	for (auto &it : this->grid)
		it.resize(this->gridDim.x, point_t());
	v.y = -this->pointRandomRadius;
	for (auto &line : this->grid)
	{
		v.x = -this->pointRandomRadius;
		for (auto &point : line)
		{
			point.first = (v + _pointDeltaPos() - center) * scale;
			if (std::rand() % 100 < this->percentGray)
				point.second = gray;
			else
				point.second = pink + _pointDeltaPink();
			v.x += this->triangleSize.x;
		}
		v.y += this->triangleSize.y;
	}
	return ;
}
Ejemplo n.º 9
0
		void calc()
		{
			point_t z = point_t(pts[v].x - pts[u].x, pts[v].y - pts[u].y);
			angle = atan2(z.y, z.x);
			if(angle < 0) angle += 2.0 * pi;

			if(!cmp(pts[u].x, pts[v].x))
				k = z.y / z.x;
			else k = 1.0e10;
		}
Ejemplo n.º 10
0
point_t incenter(const point_t& a, const point_t& b, const point_t& c)
{
	point_t p1 = b - a, p2 = c - a;
	std::swap(p1.x, p1.y);
	std::swap(p2.x, p2.y);
	p1.x = -p1.x, p2.x = -p2.x;
	point_t m1 = middle_point(a, b);
	point_t m2 = middle_point(a, c);

	double k = (m2 - m1) * p2 / (p1 * p2);
	return point_t(k * p1.x, k * p1.y) + m1;
}
Ejemplo n.º 11
0
// http://mathworld.wolfram.com/Circle-LineIntersection.html
int _crossLineCircle(point_t& pt1, point_t& pt2, const point_t& a,
                     const point_t& b, double r)
{
    point_t d(b - a);
    double d2 = d.lengthSquare();
    double dz = a.crossProduct(b);
    double z2 = dz * dz;
    double delta = r * r * d2 - z2;
    
    if (delta < 0)
        return 0;
    
    double s = sqrt(delta) / d2;
    double sx = (d.y < 0 ? -d.x : d.x) * s;
    double sy = fabs(d.y) * s;
    double tx = dz * d.y / d2;
    double ty = -dz * d.x / d2;
    
    pt1 = point_t(tx + sx, ty + sy);
    pt2 = point_t(tx - sx, ty - sy);
    
    return delta < 1e-8 ? 1 : 2;
}
    void setup( const point_t& dim )
    {
        check_coordinates( dim );

        if( dim == point_t( 0, 0 ))
        {
            _settings._dim.x = _info._width;
            _settings._dim.y = _info._height;
        }
        else
        {
            _settings._dim = dim;
        }
    }
Ejemplo n.º 13
0
//--------------------------------------------------------------------------
bool idaapi menu_callback(void *ud)
{
  graph_viewer_t *gv = (graph_viewer_t *)ud;
  mutable_graph_t *g = get_viewer_graph(gv);
  int code = askbuttons_c("Circle", "Tree", "Digraph", 1, "Please select layout type");
  bgcolor_t c = 0x44FF55;
  set_node_info(g->gid, 7, &c, NULL, "Hello from plugin!");
  g->current_layout = code + 2;
  g->circle_center = point_t(200, 200);
  g->circle_radius = 200;
  g->redo_layout();
  refresh_viewer(gv);
  return true;
}
Ejemplo n.º 14
0
inline
void read_and_convert_view( const String&    file_name
                          , const View&      view
                          , const FormatTag& tag
                          , typename enable_if< typename mpl::and_< typename is_format_tag< FormatTag >::type
                                                                  , typename detail::is_supported_path_spec< String >::type
                                                                  >::type
                                              >::type* ptr = 0
                          )
{
   read_and_convert_view( file_name
                        , view
                        , point_t( 0, 0 )
                        , default_color_converter()
                        , tag
                        );
}
Ejemplo n.º 15
0
// draws splats and "you are here" marker
void Intermission::DrawYAH()
{
    int ep = (episode - 1) % 3;

    point_t (*mapspots)[NUMMAPS] = DoomMapSpots;
    if (game.mode == gm_heretic)
        mapspots = HereticMapSpots;

    // not QUITE correct, but...
    int n = last % 10;
    for (int i = 0; i <= n; i++)
        splat->Draw(mapspots[ep][i].x, mapspots[ep][i].y, FB);

    // draw flashing ptr
    if (pointeron) // draw the destination 'X'
        yah[0]->Draw(mapspots[ep][next % 10].x, mapspots[ep][next % 10].y, FB);
}
Ejemplo n.º 16
0
void ActivityModel::computeAnchors()
{
    mAnchors.clear();

    // top
    mAnchors.push_back(point_t(mX + mWidth / 3, mY));
    mAnchors.push_back(point_t(mX + 2 * mWidth / 3, mY));

    // bottom
    mAnchors.push_back(point_t(mX + mWidth / 3, mY + mHeight));
    mAnchors.push_back(point_t(mX + 2 * mWidth / 3, mY + mHeight));

    // left
    mAnchors.push_back(point_t(mX, mY + mHeight / 3));
    mAnchors.push_back(point_t(mX, mY + 2 * mHeight / 3));

    // right
    mAnchors.push_back(point_t(mX + mWidth, mY + mHeight / 3));
    mAnchors.push_back(point_t(mX + mWidth, mY + 2 * mHeight / 3));
}
Ejemplo n.º 17
0
void get_wiis_event_data_process_events(
    std::vector< std::vector<WiiEvent> > const& event_batches,
    unsigned int current_event_index,
    std::vector<WiimoteData> const& wiimotes,
    point_t const& ir_old,
    std::vector<point_t>& irs,
    std::vector<matrix_t const*>& transforms,
    std::vector<WiiEvent>& events)
{
    // We allow all button events (hence processing those
    // right away) but only need *one* IR event
    for (unsigned int i = 0; i != event_batches.size(); ++i) {
	switch (event_batches[i][current_event_index].type) {
	    case WII_EVENT_TYPE_BUTTON:
		events.push_back( WiiEvent(event_batches[i][current_event_index].button) );
		break;
	    case WII_EVENT_TYPE_IR:
		irs.push_back(event_batches[i][current_event_index].ir);
		transforms.push_back(&wiimotes[i].transform);
		break;
	    case WII_EVENT_TYPE_NON_EVENT:
	    default:
		break;
	}
    }

    // If there are multiple valid IR events, take the closest to ir_old
    // If none of them contains valid IR event, returns INVALID_IR_POS
    int closest_ir_index = -1;
    unsigned int closest_distance = static_cast<unsigned int>(-1); // Max uint value, actually sqr(closest)
    ASSERT(irs.size() == transforms.size(), "Someone finds me a lost transformation matrix, omfgwtfbbq!!!1");
    for (std::vector<point_t>::const_iterator iter = irs.begin(); iter != irs.end(); ++iter) 
	if (iter->x != INVALID_IR_POS) {
	    unsigned int const distance = squared_distance(*iter, ir_old);
	    if ( closest_distance > distance ) {
		closest_distance = distance;
		closest_ir_index = iter - irs.begin();
		break;
	    }
	}
    if (closest_ir_index != -1)
	events.push_back( WiiEvent(irs[closest_ir_index], transforms[closest_ir_index]) );                                                                 
    else events.push_back( WiiEvent( point_t(INVALID_IR_POS, 0), 0) );
}
Ejemplo n.º 18
0
inline
void read_and_convert_view( Device&          device
                          , const View&      view
                          , const FormatTag& tag
                          , typename enable_if< typename mpl::and_< typename mpl::or_< typename detail::is_input_device< Device >::type
                                                                                     , typename detail::is_adaptable_input_device< FormatTag
                                                                                                                                 , Device
                                                                                                                                 >::type
                                                                                      >::type
                                                                   , typename is_format_tag< FormatTag >::type
                                                                   >::type
                                               >::type* ptr = 0
                          )
{
   read_and_convert_view( device
                        , view
                        , point_t( 0, 0 )
                        , default_color_converter()
                        , tag
                        );
}
Ejemplo n.º 19
0
 const point_t& u_ssfactors() const { return point_t( get_deref_fn().ux_ssfactor(), get_deref_fn().ux_ssfactor() ); }
Ejemplo n.º 20
0
point_t middle_point(const point_t& a, const point_t& b)
{
	return point_t((a.x + b.x) * 0.5, (a.y + b.y) * 0.5);
}
 point_t mean(iterator_t point_begin, iterator_t point_end) const {
   point_t sum = std::accumulate(point_begin, point_end, point_t());
   return sum / value_type(std::distance(point_begin, point_end));
 }
Ejemplo n.º 22
0
void init(textformat_t& aSettings) {
  aSettings.sendfrompath = "sendfrom.txt";
  aSettings.font = "IPAexMincho";
  aSettings.fontpath = "";
  aSettings.zipfont = "OCRB";
  aSettings.outputpath = "";
  aSettings.pagedelimiter = '|';
  aSettings.drawnenga = false;
  aSettings.sendfrom_zipframe_offset = point_t(0.000000, 0.000000);
  aSettings.sendfrom.dlmt = ';';
  aSettings.sendfrom.zipfontsize = 12.000000;
  aSettings.sendfrom.name.rect = rect_t(0.000000, 200.000000, 32.000000, 340.000000);
  aSettings.sendfrom.name.fontsize = 32.000000;
  aSettings.sendfrom.name.whitespace = 0.400000;
  aSettings.sendfrom.name.stretch = true ;
  aSettings.sendfrom.name.bottom = false;
  aSettings.sendfrom.name.linebreak = '\n';
  aSettings.sendfrom.addr.rect = rect_t(32.000000, 160.000000, 80.000000, 340.000000);
  aSettings.sendfrom.addr.fontsize = 20.000000;
  aSettings.sendfrom.addr.whitespace = 0.000000;
  aSettings.sendfrom.addr.stretch = false;
  aSettings.sendfrom.addr.bottom = true ;
  aSettings.sendfrom.addr.linebreak = '\n';
  aSettings.sendfrom.extra[0].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[0].fontsize = 20.000000;
  aSettings.sendfrom.extra[0].whitespace = 0.000000;
  aSettings.sendfrom.extra[0].stretch = false;
  aSettings.sendfrom.extra[0].bottom = true ;
  aSettings.sendfrom.extra[0].linebreak = '\n';
  aSettings.sendfrom.extra[1].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[1].fontsize = 20.000000;
  aSettings.sendfrom.extra[1].whitespace = 0.000000;
  aSettings.sendfrom.extra[1].stretch = false;
  aSettings.sendfrom.extra[1].bottom = true ;
  aSettings.sendfrom.extra[1].linebreak = '\n';
  aSettings.sendfrom.extra[2].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[2].fontsize = 0.000000;
  aSettings.sendfrom.extra[2].whitespace = 0.000000;
  aSettings.sendfrom.extra[2].stretch = false;
  aSettings.sendfrom.extra[2].bottom = false;
  aSettings.sendfrom.extra[2].linebreak = '\n';
  aSettings.sendfrom.extra[3].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[3].fontsize = 0.000000;
  aSettings.sendfrom.extra[3].whitespace = 0.000000;
  aSettings.sendfrom.extra[3].stretch = true ;
  aSettings.sendfrom.extra[3].bottom = false;
  aSettings.sendfrom.extra[3].linebreak = '\n';
  aSettings.sendfrom.extra[4].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[4].fontsize = 0.000000;
  aSettings.sendfrom.extra[4].whitespace = 0.000000;
  aSettings.sendfrom.extra[4].stretch = true ;
  aSettings.sendfrom.extra[4].bottom = true ;
  aSettings.sendfrom.extra[4].linebreak = '\n';
  aSettings.sendfrom.extra[5].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendfrom.extra[5].fontsize = 0.000000;
  aSettings.sendfrom.extra[5].whitespace = 0.000000;
  aSettings.sendfrom.extra[5].stretch = true ;
  aSettings.sendfrom.extra[5].bottom = true ;
  aSettings.sendfrom.extra[5].linebreak = '\n';
  aSettings.sendfrom.drawzipframe = false;
  aSettings.sendto.dlmt = ';';
  aSettings.sendto.zipfontsize = 16.000000;
  aSettings.sendto.name.rect = rect_t(117.732283, 80.000000, 165.732283, 360.000000);
  aSettings.sendto.name.fontsize = 32.000000;
  aSettings.sendto.name.whitespace = 0.400000;
  aSettings.sendto.name.stretch = true ;
  aSettings.sendto.name.bottom = false;
  aSettings.sendto.name.linebreak = '\n';
  aSettings.sendto.addr.rect = rect_t(219.464567, 80.000000, 283.464567, 330.000000);
  aSettings.sendto.addr.fontsize = 20.000000;
  aSettings.sendto.addr.whitespace = 0.400000;
  aSettings.sendto.addr.stretch = false;
  aSettings.sendto.addr.bottom = true ;
  aSettings.sendto.addr.linebreak = '\n';
  aSettings.sendto.extra[0].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[0].fontsize = 0.000000;
  aSettings.sendto.extra[0].whitespace = 0.000000;
  aSettings.sendto.extra[0].stretch = false;
  aSettings.sendto.extra[0].bottom = false;
  aSettings.sendto.extra[0].linebreak = '\n';
  aSettings.sendto.extra[1].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[1].fontsize = 0.000000;
  aSettings.sendto.extra[1].whitespace = 0.000000;
  aSettings.sendto.extra[1].stretch = true ;
  aSettings.sendto.extra[1].bottom = true ;
  aSettings.sendto.extra[1].linebreak = '\n';
  aSettings.sendto.extra[2].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[2].fontsize = 0.000000;
  aSettings.sendto.extra[2].whitespace = 0.000000;
  aSettings.sendto.extra[2].stretch = true ;
  aSettings.sendto.extra[2].bottom = true ;
  aSettings.sendto.extra[2].linebreak = '\n';
  aSettings.sendto.extra[3].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[3].fontsize = 0.000000;
  aSettings.sendto.extra[3].whitespace = 0.000000;
  aSettings.sendto.extra[3].stretch = true ;
  aSettings.sendto.extra[3].bottom = true ;
  aSettings.sendto.extra[3].linebreak = '\n';
  aSettings.sendto.extra[4].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[4].fontsize = 0.000000;
  aSettings.sendto.extra[4].whitespace = 0.000000;
  aSettings.sendto.extra[4].stretch = true ;
  aSettings.sendto.extra[4].bottom = true ;
  aSettings.sendto.extra[4].linebreak = '\n';
  aSettings.sendto.extra[5].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000);
  aSettings.sendto.extra[5].fontsize = 0.000000;
  aSettings.sendto.extra[5].whitespace = 0.000000;
  aSettings.sendto.extra[5].stretch = true ;
  aSettings.sendto.extra[5].bottom = true ;
  aSettings.sendto.extra[5].linebreak = '\n';
  aSettings.sendto.drawzipframe = false;
}
Ejemplo n.º 23
0
	friend point_t operator - (const point_t& a, const point_t& b)
	{
		return point_t(a.x - b.x, a.y - b.y);
	}
Ejemplo n.º 24
0
void fill_t::checkerboard_fill(point_t p,float width,float height){
	int minx=p.getX();
	int miny=p.getY();
	int maxx=p.getX();
	int maxy=p.getY();
	find_min_max(p,miny,maxy,minx,maxx,width,height);

	std::queue <point_t> fillQueue;
	fillQueue.push(p);
	float pointx=p.getX();
	float pointy=p.getY();
	color_t c=colorArray[(int)pointx][(int)pointy];
	
    color_t pixels;
    float trans_x,trans_y;
    while(!fillQueue.empty()){
    	// std::cout<<c.getR()<<" ANSSS"<<std::endl;
    	// exit(0);
		p=fillQueue.front();
		pointx=p.getX();
		pointy=p.getY();
		fillQueue.pop();
		
		//Added Canvas size check
		if(pointx>=width || pointy>=height || pointx<0 || pointy<0)
			continue;
		//glReadPixels(pointx,pointy,1.0,1.0,GL_RGB,GL_FLOAT,pixels);
		pixels = colorArray[(int)pointx][(int)pointy];
		
		if( (pixels.getR()==c.getR()) && (pixels.getG()==c.getG()) && (pixels.getB()==c.getB()) )
		{
			point_t p1(pointx, pointy);
			trans_x=pointx-minx;
			trans_y=pointy-miny;
			if((((int)trans_x/16)%2)==0){
				if((((int)trans_y/16)%2)==0){
					p1.draw(pen_t(color1,1));
				}
				else{
					p1.draw(pen_t(color2,1));
				}
			}
			else{
				if((((int)trans_y/16)%2)==0){
					p1.draw(pen_t(color2,1));
				}
				else{
					p1.draw(pen_t(color1,1));
				}
			}
			
			
			fillQueue.push(point_t(pointx+1,pointy));
			fillQueue.push(point_t(pointx,pointy+1));
			fillQueue.push(point_t(pointx-1,pointy));
			fillQueue.push(point_t(pointx,pointy-1));
		}
		
	}
	
}
Ejemplo n.º 25
0
	friend point_t operator + (const point_t& a, const point_t& b)
	{
		return point_t(a.x + b.x, a.y + b.y);
	}
Ejemplo n.º 26
0
surface::instance_t
make(const description_t& description)
{
	BOOST_LOG_TRIVIAL(debug) << "Make surface sor";

	const auto& points = description.points;
	spline_t spline = make_spline(points.begin(), points.end());
	derivations_t derivations;
	rtree_t rtree;

	for (std::size_t i = 0; i < spline.size(); ++i)
	{
		const spline_segment_t& segment = spline[i];
		const polynomial5_t derivation = differentiate(std::get<2>(segment) * std::get<2>(segment));

		const float delta = std::get<1>(segment) - std::get<0>(segment);
		float max = std::max
		(
			evaluate(std::get<2>(segment), 0.0f),
			evaluate(std::get<2>(segment), delta)
		);

		std::array<float, 5> roots;
		const auto end = solve(derivation, roots.begin());
		for (auto root = roots.begin(); root != end; ++root)
			if (*root >= 0.0f && *root <= delta)
				max = std::max
				({
					max,
					evaluate(std::get<2>(segment), *root)
				});

		const box_t box
		(
			point_t(-max, std::get<0>(segment), -max),
			point_t(+max, std::get<1>(segment), +max)
		);

		derivations.emplace_back(derivation);
		rtree.insert(value_t(box, i));
	}
/*
	const box_t box = transform
	(
		description.transformation,
		box_t// TODO: puke =>
		(
			vector_t {
				geo::get<X>(rtree.bounds().min_corner()),
				geo::get<Y>(rtree.bounds().min_corner()),
				geo::get<Z>(rtree.bounds().min_corner())
			},
			vector_t {
				geo::get<X>(rtree.bounds().max_corner()),
				geo::get<Y>(rtree.bounds().max_corner()),
				geo::get<Z>(rtree.bounds().max_corner())
			}
		)
	);

	BOOST_LOG_TRIVIAL(trace) << "Box: min = " << box.min_corner() << ", max = " << box.max_corner() << std::endl;

	const box_t box// TODO: puke =>
	(
		vector_t {
			geo::get<X>(rtree.bounds().min_corner()),
			geo::get<Y>(rtree.bounds().min_corner()),
			geo::get<Z>(rtree.bounds().min_corner())
		},
		vector_t {
			geo::get<X>(rtree.bounds().max_corner()),
			geo::get<Y>(rtree.bounds().max_corner()),
			geo::get<Z>(rtree.bounds().max_corner())
		}
	);

	BOOST_LOG_TRIVIAL(trace) << "Box: min = " << box.min_corner() << ", max = " << box.max_corner() << std::endl;
*/
	model_t model
	(
		std::move(spline),
		std::move(derivations),
		std::move(rtree),
		points.front()[X],
		points.back()[X],
		points.front()[Y],
		points.back()[Y]
//		box
	);

	return std::make_shared<instance_impl_t<model_t>>(description.transformation, std::move(model));

//	return boost::make_tuple
//	(
//		primitive::make<model>
//		(
//			description.transformation,
//			std::move(spline),
//			std::move(derivations),
//			std::move(rtree),
//			points.front()[X],
//			points.back()[X],
//			points.front()[Y],
//			points.back()[Y]
//		),
//		box,
//		3 * spline.size() + 2
//	);
}