コード例 #1
0
ファイル: read_polygon.hpp プロジェクト: respu/brig
void read_polygon(uint8_t byte_order, InputIterator& itr, polygon& poly)
{
  const size_t count(brig::detail::ogc::read<uint32_t>(byte_order, itr));
  if (count == 0) return;
  read_line(byte_order, itr, poly.outer());
  poly.inners().resize(count - 1);
  for (size_t i(0); i < poly.inners().size(); ++i)
    read_line(byte_order, itr, poly.inners()[i]);
}
コード例 #2
0
ファイル: meshing.cpp プロジェクト: floored/torchlab
//score polygon by scoring each line
float scorePoly(polygon p)
{
    float poly_score = 0;
    std::vector<boost_point> const& points = p.outer();
    for (int i = 0; i < points.size() -1; ++i)
    {
        poly_score += scoreLine(cvPointFromBoostPoint(points[i]), cvPointFromBoostPoint(points[i+1]));
    }

    if(cvPointFromBoostPoint(points[points.size()-1]) != cvPointFromBoostPoint(points[0]))
        poly_score += scoreLine(cvPointFromBoostPoint(points[points.size()-1]), cvPointFromBoostPoint(points[0]));

    return poly_score;
}
コード例 #3
0
ファイル: meshing.cpp プロジェクト: floored/torchlab
void drawPoly(polygon poly, Mat img, Scalar color)
{
    std::vector<boost_point> const& points = poly.outer();

    if(points.size()>3)
    {
        for (int i = 0; i < points.size() -1; ++i)
        {
            line( img, cvPointFromBoostPoint(points[i]), cvPointFromBoostPoint(points[i+1]), color, 2, CV_AA);
            //cout<<cvPointFromBoostPoint(points[i]);
        }

        if(cvPointFromBoostPoint(points[points.size()-1]) != cvPointFromBoostPoint(points[0]))
        {
            line( img, cvPointFromBoostPoint(points[points.size()-1]), cvPointFromBoostPoint(points[0]), color, 2, CV_AA);
            //cout<<cvPointFromBoostPoint(points[points.size()-1])<<endl;
        }
    }
}
コード例 #4
0
ファイル: meshing.cpp プロジェクト: floored/torchlab
//write polygon to obj file
void poly_to_obj(polygon p, float z1, float z2, ofstream& file)
{
    std::vector<boost_point> const& points = p.outer();

    int vctr = 1;

    for (int i = 0; i < points.size() -1; ++i)
    {
        file<<"v "<<points[i].x()*scale<<" "<<points[i].y()*scale*-1<<" "<<z1<<endl;
        file<<"v "<<points[i].x()*scale<<" "<<points[i].y()*scale*-1<<" "<<z2<<endl;
        file<<"v "<<points[i+1].x()*scale<<" "<<points[i+1].y()*scale*-1<<" "<<z1<<endl;
        file<<"v "<<points[i+1].x()*scale<<" "<<points[i+1].y()*scale*-1<<" "<<z2<<endl;

        file<<"f "<<vctr<<" "<<vctr+2<<" "<<vctr+1<<endl;
        file<<"f "<<vctr+2<<" "<<vctr+3<<" "<<vctr+1<<endl;

        vctr += 4;
    }

// 	if(cvPointFromBoostPoint(points[points.size()-1]) != cvPointFromBoostPoint(points[0]))
// 	{
// 		line( img, cvPointFromBoostPoint(points[points.size()-1]), cvPointFromBoostPoint(points[0]), color, 2, CV_AA);
// 	}
}
コード例 #5
0
void painter::rasterize_polygon_border(FIBITMAP* bitmap, polygon& p)
{
	for (unsigned int i = 0; i < p.outer().size() - 1; ++i)
		rasterize_line(bitmap, p.outer()[i], p.outer()[i + 1]);
	rasterize_line(bitmap, p.outer()[0], p.outer()[p.outer().size() - 1]);
}