Esempio n. 1
0
        /// <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>
        /// 构建垂直连接板左右侧的对称性;
        /// </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>
        /// 绘制主梁外侧法向与X轴平行的零件标注;
        /// </summary>
        private void DrawXNormalAlonePartDim()
        {
            List <CMrPart> xNormalAlonePartList = CMrCylinderDoorFrontManager.GetInstance().mXNormalAloneDimPartList;

            CMrPart leftPart          = CMrCylinderDoorFrontManager.GetInstance().mLeftPart;
            CMrPart leftTopPart       = CMrCylinderDoorFrontManager.GetInstance().mLeftTopPart;
            CMrPart leftTopMiddlePart = CMrCylinderDoorFrontManager.GetInstance().mLeftTopMiddlePart;

            CMrPart rightPart          = CMrCylinderDoorFrontManager.GetInstance().mRightPart;
            CMrPart rightTopPart       = CMrCylinderDoorFrontManager.GetInstance().mRightTopPart;
            CMrPart rightTopMiddlePart = CMrCylinderDoorFrontManager.GetInstance().mRightTopMiddlePart;

            double leftPartMinX  = leftPart.GetMinXPoint().X;
            double rightPartMaxX = rightPart.GetMaxXPoint().X;

            foreach (CMrPart mrPart in xNormalAlonePartList)
            {
                double partMinX = mrPart.GetMinXPoint().X;
                double partMaxX = mrPart.GetMaxXPoint().X;

                if (partMinX < leftPartMinX)
                {
                    PointList pointList     = new PointList();
                    Point     minXmaxYPoint = mrPart.GetMinXMaxYPoint();
                    pointList.Add(minXmaxYPoint);

                    double dimDistance = CCommonPara.mDefaultDimDistance;
                    Vector dimVector   = new Vector(0, 1, 0);

                    if (leftTopPart != null && leftTopPart.GetMinXMinYPoint().Y < minXmaxYPoint.Y)
                    {
                        pointList.Add(new Point(leftTopPart.GetMinXPoint().X, minXmaxYPoint.Y, 0));
                    }
                    else if (leftTopMiddlePart != null && leftTopMiddlePart.GetMinXMinYPoint().Y < minXmaxYPoint.Y)
                    {
                        pointList.Add(new Point(leftTopMiddlePart.GetMinXPoint().X, minXmaxYPoint.Y, 0));
                    }
                    else
                    {
                        pointList.Add(new Point(leftPartMinX, minXmaxYPoint.Y, 0));
                    }
                    CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, dimDistance, CCommonPara.mSizeDimPath);
                }
                else if (partMaxX > rightPartMaxX)
                {
                    PointList pointList     = new PointList();
                    Point     maxXmaxYPoint = mrPart.GetMaxXMaxYPoint();
                    pointList.Add(maxXmaxYPoint);
                    double dimDistance = CCommonPara.mDefaultDimDistance;
                    Vector dimVector   = new Vector(0, 1, 0);

                    if (rightTopPart != null && rightTopPart.GetMaxXMinYPoint().Y < maxXmaxYPoint.Y)
                    {
                        pointList.Add(new Point(rightTopPart.GetMaxXPoint().X, maxXmaxYPoint.Y, 0));
                    }
                    else if (rightTopMiddlePart != null && rightTopMiddlePart.GetMaxXMinYPoint().Y < maxXmaxYPoint.Y)
                    {
                        pointList.Add(new Point(rightTopMiddlePart.GetMaxXPoint().X, maxXmaxYPoint.Y, 0));
                    }
                    else
                    {
                        pointList.Add(new Point(rightPartMaxX, maxXmaxYPoint.Y, 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);
        }