在对工程图中所有尺寸进行自动球标标注时,对尺寸位置的排序是一个很关键的问题。基本思路:
bool SortByView(const DimensionStruct &td1, const DimensionStruct &td2)
{
DimensionStruct d1, d2;
d1 = td1;
d2 = td2;
float vcx1, vcx2, vcy1, vcy2;
vcx1 = d1.GetViewCenter()->get(0);
vcx2 = d2.GetViewCenter()->get(0);
vcy1 = d1.GetViewCenter()->get(1);
vcy2 = d2.GetViewCenter()->get(1);
if (vcx1 > vcx2)
{
return false; //视图中心:d1在d2的右侧
}
else if (IsEqual(vcx1, vcx2) && (vcy1 < vcy2))
{
return false; //视图中心:d1在d2的下方
}
return true;
}