MFC下实现图形学之多边形扫描转化填充算法

本文详细介绍了如何在MFC环境下实现多边形的扫描转换填充算法,包括获取多边形顶点的最大最小Y坐标、判断极值点、边的排序、清除不满足条件的边、添加边到活动边表以及初始化和填充多边形的步骤。
摘要由CSDN通过智能技术生成

//*************************
//获取点中y坐标最大值
//*************************
int CPolygonFillView::GetMaxY()
{
 int result = points[0].y;
 for(int i = 1; i < count; i++)
  if(result < points[i].y)
          result = points[i].y;
  return result;
}
//*************************
//获取点中y坐标最小值
//*************************
int CPolygonFillView::GetMinY()
{
 int result = points[0].y;
 for(int i = 0; i < count; i++)
  if(result > points[i].y)
   result = points[i].y;
  return result;
}
//*******************************************************************************
//判断是否为极值点,参数为一条边的y较小点和其在pionts数组中的下标
//*******************************************************************************
bool CPolygonFillView::IsSuperPoint(CPoint &point,int i)
{
 if(i == 0)
  return ((points[0].y > points[1].y&&points[0].y > points[count-1].y)
  ||(points[0].y < points[1].y&& points[0].y < points[count-1].y));
    else if(i == count-1)
     return ((points[i].y > points[0].y&&points[i].y > points[i-1].y)
  ||(points[i].y < points[0].y&&points[i].y < points[i-1].y));
    else
  

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值