/// <summary> /// 获取上翼板是向两边弯曲时的零件标记; /// </summary> /// <returns></returns> public CMrMark GetPartMarkMiddle() { CMrPart topBeam = CMrBeamDoorManager.GetInstance().mTopBeam; CMrPart leftBeam = CMrBeamDoorManager.GetInstance().mLeftBeam; CMrPart rightBeam = CMrBeamDoorManager.GetInstance().mRightBeam; CMrPart leftBottomBeam = CMrBeamDoorManager.GetInstance().mLeftBottomBeam; CMrPart rightBottomBeam = CMrBeamDoorManager.GetInstance().mRightBottomBeam; Vector leftTopVector = CMrBeamDoorManager.GetInstance().mLeftTopVector; Vector rightTopVector = CMrBeamDoorManager.GetInstance().mRightTopVector; Point midMaxPoint = CMrBeamDoorManager.GetInstance().mMidMaxPoint; Vector leftDirectionVector = new Vector(midMaxPoint.X - topBeam.mLeftTopPoint.X, midMaxPoint.Y - topBeam.mLeftTopPoint.Y, 0); Vector rightDirectionVector = new Vector(midMaxPoint.X - topBeam.mRightTopPoint.X, midMaxPoint.Y - topBeam.mRightTopPoint.Y, 0); Point minY = mMrPart.GetMinYPoint(); Point maxY = mMrPart.GetMaxYPoint(); Vector normal = mMrPart.mNormal; CMrMark mrMark = new CMrMark(); double dblAngle = CCommonPara.mPartMarkAngle; mrMark.mModelObject = mMrPart.mPartInDrawing; if (mMrPart == leftBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 1.8 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.8 * CCommonPara.mPartMarkLength; return(mrMark); } else if (mMrPart == rightBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 1.8 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.8 * CCommonPara.mPartMarkLength; return(mrMark); } else if (mMrPart == leftBottomBeam || mMrPart == rightBottomBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 1.8 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.8 * CCommonPara.mPartMarkLength; return(mrMark); } else if (mMrPart == topBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 0.5 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 0.5 * CCommonPara.mPartMarkLength; return(mrMark); } //如果向量与Z轴平行; if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 0, 1))) { //如果是在上翼板的左上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, topBeam.mLeftTopPoint, midMaxPoint) > 0) { //如果是靠左侧挡板的那块板; if (CDimTools.GetInstance().CompareTwoDoubleValue(mMrPart.GetMaxYPoint().X, leftBeam.mRightTopPoint.X) == 0) { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } else { if (mMrPart.mLeftTopPoint.X < midMaxPoint.X) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 0.8 * CCommonPara.mPartMarkLength; return(mrMark); } } } //如果在上翼板的右侧上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, midMaxPoint, topBeam.mRightTopPoint) > 0) { //如果是靠右侧挡板的那块板; if (CDimTools.GetInstance().CompareTwoDoubleValue(mMrPart.GetMaxYPoint().X, leftBeam.mRightTopPoint.X) == 0) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } else { if (mMrPart.mLeftTopPoint.X > midMaxPoint.X) { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 0.8 * CCommonPara.mPartMarkLength; return(mrMark); } } } //如果是在下翼板的下方; if (CDimTools.GetInstance().IsThePointOnLine(minY, leftBeam.mLeftTopPoint, leftBeam.mRightTopPoint) < 0) { if (CDimTools.GetInstance().CompareTwoDoubleValue(mMrPart.GetMinYPoint().X, leftBeam.mRightBottomPoint.X) == 0) { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMaxYPoint().Y - 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.4 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.4 * CCommonPara.mPartMarkLength; return(mrMark); } if (CDimTools.GetInstance().CompareTwoDoubleValue(mMrPart.GetMinYPoint().X, rightBeam.mLeftBottomPoint.X) == 0) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMaxYPoint().Y - 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.4 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.4 * CCommonPara.mPartMarkLength; return(mrMark); } } } //如果法向与X轴平行; else if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(1, 0, 0))) { if (mMrPart.mLeftBottomPoint.X < midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } else if (mMrPart.mLeftBottomPoint.X > midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } } //如果法向与Y轴平行; else if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 1, 0))) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } //如果法向量与上翼板左侧的法向垂直; else if (CDimTools.GetInstance().IsTwoVectorParallel(normal, leftDirectionVector) || CDimTools.GetInstance().IsTwoVectorParallel(normal, rightDirectionVector)) { //如果在上翼板左侧上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, topBeam.mLeftTopPoint, midMaxPoint) > 0) { if (mMrPart.mLeftTopPoint.X < midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightTopPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } //如果在下翼板左侧上方; else if (CDimTools.GetInstance().IsThePointOnLine(maxY, leftBottomBeam.mLeftTopPoint, leftBottomBeam.mRightTopPoint) > 0) { if (mMrPart.mLeftTopPoint.X < midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } //如果在上翼板右侧上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, topBeam.mRightTopPoint, midMaxPoint) > 0) { if (mMrPart.mLeftTopPoint.X > midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightTopPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } //如果在下翼板右侧上方; else if (CDimTools.GetInstance().IsThePointOnLine(maxY, rightBottomBeam.mLeftTopPoint, rightBottomBeam.mRightTopPoint) > 0) { if (mMrPart.mLeftTopPoint.X > midMaxPoint.X) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } } //如果法向与左右向上的法向平行并且有螺钉; else if ((CDimTools.GetInstance().IsTwoVectorVertical(normal, leftDirectionVector) || CDimTools.GetInstance().IsTwoVectorVertical(normal, rightDirectionVector)) && mMrPart.IsHaveBolt()) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } return(null); }
/// <summary> /// 获取上翼板左斜或者右斜时的零件标记; /// </summary> /// <returns></returns> public CMrMark GetPartMarkNormal() { CMrPart topBeam = CMrBeamDoorManager.GetInstance().mTopBeam; CMrPart bottomBeam = CMrBeamDoorManager.GetInstance().mBottonBeam; CMrPart leftBeam = CMrBeamDoorManager.GetInstance().mLeftBeam; CMrPart rightBeam = CMrBeamDoorManager.GetInstance().mRightBeam; Point minY = mMrPart.GetMinYPoint(); Point maxY = mMrPart.GetMaxYPoint(); Vector normal = mMrPart.mNormal; CMrMark mrMark = new CMrMark(); double dblAngle = CCommonPara.mPartMarkAngle; mrMark.mModelObject = mMrPart.mPartInDrawing; if (mMrPart == leftBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 1.8 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.8 * CCommonPara.mPartMarkLength; return(mrMark); } if (mMrPart == rightBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = 1.8 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.8 * CCommonPara.mPartMarkLength; return(mrMark); } if (mMrPart == topBeam || mMrPart == bottomBeam) { mrMark.mInsertPoint = mMrPart.mMidPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } //如果向量与Z轴平行; if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 0, 1))) { //如果是在上翼板的上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, topBeam.mLeftTopPoint, topBeam.mRightTopPoint) > 0) { //1.如果是靠右侧挡板的那块板; if (Math.Abs(mMrPart.GetMaxYPoint().X - rightBeam.mLeftTopPoint.X) < 5) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } //2.如果是靠左侧挡板的那块板; if (Math.Abs(mMrPart.GetMaxYPoint().X - leftBeam.mRightTopPoint.X) < 5) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } else { MrSlopeType mrSlopeType = CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), topBeam.mNormal); if (mrSlopeType == MrSlopeType.MORETHAN_ZERO) { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + 1.1 * increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 0.8 * CCommonPara.mPartMarkLength; return(mrMark); } else if (mrSlopeType == MrSlopeType.LESSTHAN_ZERO) { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMinYPoint().Y + 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - 1.1 * increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 0.8 * CCommonPara.mPartMarkLength; return(mrMark); } } } //如果在下翼板下方; if (CDimTools.GetInstance().IsThePointOnLine(minY, bottomBeam.mLeftBottomPoint, bottomBeam.mRightBottomPoint) < 0) { //1.如果是靠右侧挡板的那块板; if (Math.Abs(mMrPart.GetMinYPoint().X - rightBeam.mLeftBottomPoint.X) < 5) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMaxYPoint().Y - 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } //2.如果是靠左侧挡板的那块板; else if (Math.Abs(mMrPart.GetMinYPoint().X - leftBeam.mRightBottomPoint.X) < 5) { double x = mMrPart.GetMaxXPoint().X - 20; double y = mMrPart.GetMaxYPoint().Y - 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } else { double x = mMrPart.GetMinXPoint().X + 20; double y = mMrPart.GetMaxYPoint().Y - 20; Point insertPoint = new Point(x, y, 0); mrMark.mInsertPoint = insertPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + 1.1 * increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 0.8 * CCommonPara.mPartMarkLength; return(mrMark); } } } else if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(1, 0, 0))) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } //如果法向量与上翼板的法向垂直; else if (CDimTools.GetInstance().IsTwoVectorVertical(normal, topBeam.mNormal)) { //如果在上翼板的上方; if (CDimTools.GetInstance().IsThePointOnLine(maxY, topBeam.mLeftTopPoint, topBeam.mRightTopPoint) > 0) { MrSlopeType mrSlopeType = CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), topBeam.mNormal); if (mrSlopeType == MrSlopeType.MORETHAN_ZERO) { mrMark.mInsertPoint = mMrPart.mRightTopPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } else if (mrSlopeType == MrSlopeType.LESSTHAN_ZERO) { mrMark.mInsertPoint = mMrPart.mRightTopPoint; double increaseXDistance = 1.2 * CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X - increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y + 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } else if (CDimTools.GetInstance().IsThePointOnLine(maxY, bottomBeam.mLeftTopPoint, bottomBeam.mRightTopPoint) > 0) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - 1.2 * CCommonPara.mPartMarkLength; return(mrMark); } } else if (CDimTools.GetInstance().IsTwoVectorParallel(normal, topBeam.mNormal) && mMrPart.IsHaveBolt()) { mrMark.mInsertPoint = mMrPart.mRightBottomPoint; double increaseXDistance = CCommonPara.mPartMarkLength / Math.Tan(dblAngle); mrMark.mTextPoint.X = mrMark.mInsertPoint.X + increaseXDistance; mrMark.mTextPoint.Y = mrMark.mInsertPoint.Y - CCommonPara.mPartMarkLength; return(mrMark); } return(null); }