这个函数主要是用于将xld轮廓进行延长,在一些显示轮廓的地方可以 用到。
1、函数原理
主要是利用XLD的开始和结束点位,还有XLD的角度。然后根据需要延长的长度在两边分别进
行延长。
2、函数代码
内部代码:
*对轮廓进行延长
*Contour输入轮廓,ExtendContour输出轮廓,Length延长长度
try
*获得点位
get_contour_xld (Contour, Row, Column)
line_orientation (Row[0], Column[0], Row[|Row| - 1], Column[|Column| - 1], Phi)
*通过角度判断
if (Phi > rad(0) and Phi < rad(90))
*判断起始点
if (Row[0] < Row[|Row| - 1] and Column[0] > Column[|Column| - 1])
RowBegin := Row[0]
ColumnBgein := Column[0]
RowEnd := Row[|Row| - 1]
ColumnEnd := Column[|Column| - 1]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein + Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd - Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendBegin
ColumnXldBegin := ColumnExtendBegin
RowXldEnd := RowExtendEnd
ColumnXldEnd := ColumnExtendEnd
elseif (Row[0] > Row[|Row| - 1] and Column[0] < Column[|Column| - 1])
RowBegin := Row[|Row| - 1]
ColumnBgein := Column[|Column| - 1]
RowEnd := Row[0]
ColumnEnd := Column[0]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein + Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd - Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendEnd
ColumnXldBegin := ColumnExtendEnd
RowXldEnd := RowExtendBegin
ColumnXldEnd := ColumnExtendBegin
endif
elseif (Phi < rad(0) and Phi > rad(-90))
*判断起始点
if (Row[0] < Row[|Row| - 1] and Column[0] < Column[|Column| - 1])
RowBegin := Row[0]
ColumnBgein := Column[0]
RowEnd := Row[|Row| - 1]
ColumnEnd := Column[|Column| - 1]
*进行计算延长
RowExtendBegin := RowBegin + Length * sin(Phi)
ColumnExtendBegin := ColumnBgein - Length * cos(Phi)
RowExtendEnd := RowEnd - Length * sin(Phi)
ColumnExtendEnd := ColumnEnd + Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendBegin
ColumnXldBegin := ColumnExtendBegin
RowXldEnd := RowExtendEnd
ColumnXldEnd := ColumnExtendEnd
elseif (Row[0] > Row[|Row| - 1] and Column[0] > Column[|Column| - 1])
RowBegin := Row[|Row| - 1]
ColumnBgein := Column[|Column| - 1]
RowEnd := Row[0]
ColumnEnd := Column[0]
*进行计算延长
RowExtendBegin := RowBegin + Length * sin(Phi)
ColumnExtendBegin := ColumnBgein - Length * cos(Phi)
RowExtendEnd := RowEnd - Length * sin(Phi)
ColumnExtendEnd := ColumnEnd + Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendEnd
ColumnXldBegin := ColumnExtendEnd
RowXldEnd := RowExtendBegin
ColumnXldEnd := ColumnExtendBegin
endif
elseif (Phi == rad(0))
*判断起始点
if (Column[0] > Column[|Column| - 1])
RowBegin := Row[0]
ColumnBgein := Column[0]
RowEnd := Row[|Row| - 1]
ColumnEnd := Column[|Column| - 1]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein + Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd - Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendBegin
ColumnXldBegin := ColumnExtendBegin
RowXldEnd := RowExtendEnd
ColumnXldEnd := ColumnExtendEnd
elseif (Column[0] < Column[|Column| - 1])
RowBegin := Row[|Row| - 1]
ColumnBgein := Column[|Column| - 1]
RowEnd := Row[0]
ColumnEnd := Column[0]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein + Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd - Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendEnd
ColumnXldBegin := ColumnExtendEnd
RowXldEnd := RowExtendBegin
ColumnXldEnd := ColumnExtendBegin
endif
elseif (Phi == rad(90))
*判断起始点
if (Row[0] > Row[|Row| - 1])
RowBegin := Row[0]
ColumnBgein := Column[0]
RowEnd := Row[|Row| - 1]
ColumnEnd := Column[|Column| - 1]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein - Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd + Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendBegin
ColumnXldBegin := ColumnExtendBegin
RowXldEnd := RowExtendEnd
ColumnXldEnd := ColumnExtendEnd
elseif (Row[0] < Row[|Row| - 1])
RowBegin := Row[|Row| - 1]
ColumnBgein := Column[|Column| - 1]
RowEnd := Row[0]
ColumnEnd := Column[0]
*进行计算延长
RowExtendBegin := RowBegin - Length * sin(Phi)
ColumnExtendBegin := ColumnBgein - Length * cos(Phi)
RowExtendEnd := RowEnd + Length * sin(Phi)
ColumnExtendEnd := ColumnEnd + Length * cos(Phi)
*调整方向与原有相同
RowXldBegin := RowExtendEnd
ColumnXldBegin := ColumnExtendEnd
RowXldEnd := RowExtendBegin
ColumnXldEnd := ColumnExtendBegin
endif
endif
*生成轮廓
gen_contour_polygon_xld (ExtendContour, [RowXldBegin, RowXldEnd], [ColumnXldBegin, ColumnXldEnd])
catch (Exception)
gen_empty_obj (ExtendContour)
endtry
return ()