/// <summary> /// 获取左侧檩托板的标注集; /// </summary> /// <param name="nFlag">1:左侧;2:右侧</param> /// <returns></returns> private List <CMrDimSet> GetMrApronPlateDimSet(int nFlag) { List <CMrDimSet> mrDimSetList = new List <CMrDimSet>(); Dictionary <CMrPart, CMrApronPlate> mMapPartToApronPlate = CMrCylinderDoorTopManager.GetInstance().mMapYNormalPartToMrApronPlate; //如果是右侧; if (nFlag == 2) { foreach (CMrApronPlate mrApronPlate in mMapPartToApronPlate.Values) { CMrPart yNormalPart = mrApronPlate.mYNormalPart; double minX = yNormalPart.GetMinXPoint().X; if (minX < 0) { continue; } CMrDimSet mrDimSet = new CMrDimSet(); bool bIsUp = mrApronPlate.mIsUp; if (bIsUp) { mrDimSet.AddPoint(yNormalPart.GetMaxXMinYPoint()); } else { mrDimSet.AddPoint(yNormalPart.GetMaxXMaxYPoint()); } mrDimSetList.Add(mrDimSet); } } //如果是左侧; else if (nFlag == 1) { foreach (CMrApronPlate mrApronPlate in mMapPartToApronPlate.Values) { CMrPart yNormalPart = mrApronPlate.mYNormalPart; double maxX = yNormalPart.GetMaxXPoint().X; if (maxX > 0) { continue; } CMrDimSet mrDimSet = new CMrDimSet(); bool bIsUp = mrApronPlate.mIsUp; if (bIsUp) { mrDimSet.AddPoint(yNormalPart.GetMinXMinYPoint()); } else { mrDimSet.AddPoint(yNormalPart.GetMinXMaxYPoint()); } mrDimSetList.Add(mrDimSet); } } return(mrDimSetList); }
/// <summary> /// 绘制在中间法向与Y轴方向平行的零件标注; /// </summary> public void DrawYNormalPartDimMiddle() { CMrPart midYNormalPart = null; Point midPoint = CMrBeamDoorManager.GetInstance().mMidMaxPoint; CMrPart topBeam = CMrBeamDoorManager.GetInstance().mTopBeam; CMrPart leftBottomBeam = CMrBeamDoorManager.GetInstance().mLeftBottomBeam; CMrPart rightBottomBeam = CMrBeamDoorManager.GetInstance().mRightBottomBeam; foreach (CMrPart mrPart in mMrPartList) { if (mrPart == topBeam || mrPart == leftBottomBeam || mrPart == rightBottomBeam) { continue; } Vector normal = mrPart.mNormal; if (!CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 1, 0))) { continue; } Point minXPoint = mrPart.GetMinXPoint(); Point maxXPoint = mrPart.GetMaxXPoint(); if (minXPoint.X < midPoint.X && maxXPoint.X > midPoint.X) { if (midYNormalPart == null) { midYNormalPart = mrPart; } else if (mrPart.GetMaxYPoint().Y > midYNormalPart.GetMaxYPoint().Y) { midYNormalPart = mrPart; } } } if (midYNormalPart == null) { return; } PointList pointList = new PointList(); pointList.Add(midYNormalPart.GetMaxXMinYPoint()); pointList.Add(rightBottomBeam.GetMinXMaxYPoint()); Vector dimVector = new Vector(1, 0, 0); double length = 2 * CCommonPara.mDefaultDimDistance; CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, length, CCommonPara.mSizeDimPath); }
/// <summary> /// 构建垂直连接板左右侧的对称性; /// </summary> /// <param name="mrPart"></param> private void InitMrPart(CMrPart mrPart) { Vector normal = mrPart.mNormal; //1.板的法向与Y轴平行或者法向在XY平面内才可以进行对称性判断; if (!(CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 1, 0)) || CDimTools.GetInstance().IsVectorInXYPlane(normal))) { return; } //2.需要判断板的位置; if (mrPart.GetCylinderTopViewInfo().mPostionType == MrPositionType.LEFT) { Point maxXMaxY = mrPart.GetMaxXMaxYPoint(); Point maxXMinY = mrPart.GetMaxXMinYPoint(); String strAttribute1 = ((int)maxXMaxY.Y).ToString(); if (mDicAttributePart.ContainsKey(strAttribute1)) { CMrPart symPart = mDicAttributePart[strAttribute1]; mrPart.GetCylinderTopViewInfo().mSymPart = symPart; symPart.GetCylinderTopViewInfo().mSymPart = mrPart; } else { mDicAttributePart.Add(strAttribute1, mrPart); } } if (mrPart.GetCylinderTopViewInfo().mPostionType == MrPositionType.RIGHT) { Point minXMaxY = mrPart.GetMinXMaxYPoint(); Point minXMinY = mrPart.GetMinXMinYPoint(); String strAttribute1 = ((int)minXMaxY.Y).ToString(); if (mDicAttributePart.ContainsKey(strAttribute1)) { CMrPart symPart = mDicAttributePart[strAttribute1]; mrPart.GetCylinderTopViewInfo().mSymPart = symPart; symPart.GetCylinderTopViewInfo().mSymPart = mrPart; } else { mDicAttributePart.Add(strAttribute1, mrPart); } } }
/// <summary> /// 创建水平方向的剖面; /// </summary> /// <param name="mrSection"></param> private void CreateVerticalMiddleSection(CMrSection mrSection, CMrPart mrPart) { //判断是否需要创建该剖面或者只是添加零件标记; CMrSection mrSameSection = null; View.ViewAttributes viewAttributes = new View.ViewAttributes(); viewAttributes.LoadAttributes(CCommonPara.mSectionAttPath); SectionMarkBase.SectionMarkAttributes sectionMarkAttributes = new SectionMarkBase.SectionMarkAttributes(); sectionMarkAttributes.LoadAttributes(CCommonPara.mSectionMarkNotePath); View sectionView = null; SectionMark setionMark = null; double dblX = 50; CMrPart mTopBeam = CMrBeamDoorManager.GetInstance().mTopBeam; Point tBLeftTopPt = mTopBeam.mLeftTopPoint; Point tBRightTopPt = mTopBeam.mRightTopPoint; Point midMaxYPt = CMrBeamDoorManager.GetInstance().mMidMaxPoint; Vector leftDirectVector = new Vector(midMaxYPt.X - tBLeftTopPt.X, midMaxYPt.Y - tBLeftTopPt.Y, 0); Vector rightDirectVector = new Vector(midMaxYPt.X - tBRightTopPt.X, midMaxYPt.Y - tBRightTopPt.Y, 0); Point leftTopPt = null; Point rightTopPt = null; if (CDimTools.GetInstance().IsTwoVectorParallel(mrPart.mNormal, new Vector(0, 1, 0))) { leftTopPt = mrPart.GetMinXMaxYPoint(); rightTopPt = mrPart.GetMaxXMaxYPoint(); } else if (CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), leftDirectVector) == MrSlopeType.MORETHAN_ZERO || CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), rightDirectVector) == MrSlopeType.MORETHAN_ZERO) { leftTopPt = mrPart.GetMinXPoint(); rightTopPt = mrPart.GetMaxYPoint(); } else if (CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), leftDirectVector) == MrSlopeType.LESSTHAN_ZERO || CDimTools.GetInstance().JudgeLineSlope(new Point(0, 0, 0), rightDirectVector) == MrSlopeType.LESSTHAN_ZERO) { leftTopPt = mrPart.GetMaxYPoint(); rightTopPt = mrPart.GetMaxXPoint(); } Point newPt = new Point(rightTopPt.X + dblX, rightTopPt.Y, 0); Point startPt = CDimTools.GetInstance().ComputeFootPointToLine(newPt, leftTopPt, rightTopPt); newPt = new Point(leftTopPt.X - dblX, leftTopPt.Y, 0); Point endPt = CDimTools.GetInstance().ComputeFootPointToLine(newPt, leftTopPt, rightTopPt); if (CCommonPara.mVerticalSection == MrSectionOrientation.MrSectionDown) { Point tempPt = startPt; startPt = endPt; endPt = startPt; } bool bNeedCreateView = IsTheSectionNeedCreateView(mrSection, ref mrSameSection); if (bNeedCreateView) { mSectionMarkIndex++; mrSection.mSectionMark = mSectionMarkArray[mSectionMarkIndex]; View.CreateSectionView(mFrontView, startPt, endPt, new Point(0, 0, 0), CCommonPara.mDblSectionUpDepth , CCommonPara.mDblSectionDownDepth, viewAttributes, sectionMarkAttributes, out sectionView, out setionMark); } }
/// <summary> /// 绘制主梁上螺钉的标注,需要判断螺钉与主梁顶部的距离,如果距离超过一定的阈值只进行单独标注; /// </summary> private void DrawMainBeamBoltDim() { CMrPart mrLeftPart = CMrCylinderDoorFrontManager.GetInstance().mLeftPart; CMrPart mrRightPart = CMrCylinderDoorFrontManager.GetInstance().mRightPart; List <CMrBoltArray> mrBoltArrayList = mMainBeam.GetBoltArrayList(); foreach (CMrBoltArray mrBoltArray in mrBoltArrayList) { Vector normal = mrBoltArray.mNormal; if (!CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 0, 1))) { continue; } double distance = Math.Abs(mrBoltArray.GetMaxYPoint().Y - mMainBeam.GetMaxYPoint().Y); if (distance < 200) { //1.标注螺钉组的上侧标注; PointList pointList = new PointList(); foreach (Point point in mrBoltArray.GetMaxYPointList()) { pointList.Add(point); } pointList.Add(mrRightPart.GetMaxXMaxYPoint()); pointList.Add(mrLeftPart.GetMinXMaxYPoint()); double dimDistance = Math.Abs(mMainBeam.GetMaxYPoint().Y - pointList[0].Y) + CCommonPara.mDefaultDimDistance; Vector dimVector = new Vector(0, 1, 0); CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, dimDistance, CCommonPara.mSizeDimPath); } else { //1.标注螺钉组的上侧标注; PointList pointList = new PointList(); foreach (Point point in mrBoltArray.GetMaxYPointList()) { pointList.Add(point); } Point boltMaxYPt = mrBoltArray.GetMaxYPoint(); Vector leftPartNormal = mrLeftPart.mNormal; Vector rightPartNormal = mrRightPart.mNormal; if (CDimTools.GetInstance().IsTwoVectorParallel(leftPartNormal, new Vector(1, 0, 0))) { pointList.Add(new Point(mrLeftPart.GetMinXPoint().X, boltMaxYPt.Y, 0)); } if (CDimTools.GetInstance().IsTwoVectorParallel(rightPartNormal, new Vector(1, 0, 0))) { pointList.Add(new Point(mrRightPart.GetMaxXPoint().X, boltMaxYPt.Y, 0)); } if (pointList.Count >= 2) { double dimDistance = CCommonPara.mDefaultDimDistance; Vector dimVector = new Vector(0, 1, 0); CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, dimDistance, CCommonPara.mSizeDimPath); } } } }
/// <summary> /// 获取顶部零件的标注集; /// </summary> /// <param name="nFlag">1:左侧,2:右侧</param> /// <returns></returns> private CMrDimSet GetTopPartDimSet(int nFlag) { CMrDimSet mrDimSet = new CMrDimSet(); CMrPart mrTopPart = CMrCylinderDoorFrontManager.GetInstance().mTopPart; CMrPart mrLeftTopPart = CMrCylinderDoorFrontManager.GetInstance().mLeftTopPart; CMrPart mrRightTopPart = CMrCylinderDoorFrontManager.GetInstance().mRightTopPart; //标注顶板右侧的情况; if (nFlag == 2) { //如果顶部零件为空,则把主梁最上面的点加入进去; if (mrTopPart == null) { mrDimSet.AddPoint(mMainBeam.GetMaxYMaxXPoint()); return(mrDimSet); } Vector normal = mrTopPart.mNormal; if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 1, 0))) { mrDimSet.AddPoint(mrTopPart.GetMaxXMaxYPoint()); mrDimSet.AddPoint(mrTopPart.GetMaxXMinYPoint()); } else { if (mrLeftTopPart != null && mrRightTopPart != null) { if (mrLeftTopPart.GetMaxYPoint().Y > mrRightTopPart.GetMaxYPoint().Y) { mrDimSet.AddPoint(mrLeftTopPart.GetMaxXMaxYPoint()); } else { mrDimSet.AddPoint(mrRightTopPart.GetMaxXMaxYPoint()); } } else if (mrLeftTopPart != null) { mrDimSet.AddPoint(mrLeftTopPart.GetMaxXMaxYPoint()); } else if (mrRightTopPart != null) { mrDimSet.AddPoint(mrRightTopPart.GetMinXMaxYPoint()); } } } //标注顶板左侧的情况; else if (nFlag == 1) { if (mrTopPart == null) { mrDimSet.AddPoint(mMainBeam.GetMaxYMinXPoint()); return(mrDimSet); } Vector normal = mrTopPart.mNormal; if (CDimTools.GetInstance().IsTwoVectorParallel(normal, new Vector(0, 1, 0))) { mrDimSet.AddPoint(mrTopPart.GetMinXMaxYPoint()); mrDimSet.AddPoint(mrTopPart.GetMinXMinYPoint()); } else { if (mrLeftTopPart != null && mrRightTopPart != null) { if (mrLeftTopPart.GetMaxYPoint().Y > mrRightTopPart.GetMaxYPoint().Y) { mrDimSet.AddPoint(mrLeftTopPart.GetMaxXMaxYPoint()); } else { mrDimSet.AddPoint(mrRightTopPart.GetMinXMaxYPoint()); } } else if (mrLeftTopPart != null) { mrDimSet.AddPoint(mrLeftTopPart.GetMaxXMaxYPoint()); } else if (mrRightTopPart != null) { mrDimSet.AddPoint(mrRightTopPart.GetMinXMaxYPoint()); } } } return(mrDimSet); }