Example #1
0
            public bool same(segs.Spline exist)
            {
                int count = 0;

                for (int i = 0; i < sPoints.Count; i++)
                {
                    if (sPoints[i] == exist.sPoints[i])
                    {
                        count++;
                    }
                }
                if (count == sPoints.Count)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Example #2
0
        public void storeSegments()                     //获取边(被取代)
        {
            verNum = sket.GetSketchPoints2().Length;
            adj    = new int[verNum, verNum];
            //Debug.Print("Storing segments: ");
            object[] segments = sket.GetSketchSegments();
            foreach (SketchSegment seg in segments)
            {
                bool flag = false;
                int  type = seg.GetType();
                switch (type)
                {
                case 0:
                    flag = false;
                    segs.Line  temLine = new segs.Line(seg);
                    SketchLine line    = (SketchLine)seg;
                    temLine.setPoint(addPoint(line.GetStartPoint2()), addPoint(line.GetEndPoint2()));
                    //temLine.setPoint(findPoint(line.GetStartPoint2()), findPoint(line.GetEndPoint2()));
                    for (int i = 0; i < segLin.Count; i++)
                    {
                        if (temLine.same(segLin[i]))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                    else
                    {
                        segLin.Add(temLine);
                        pois[temLine.sPoint].setNext(temLine.ePoint);
                        pois[temLine.ePoint].setNext(temLine.sPoint);

                        pois[temLine.sPoint].setNextSeg(0, segLin.Count - 1);
                        pois[temLine.ePoint].setNextSeg(0, segLin.Count - 1);

                        adj[temLine.sPoint, temLine.ePoint] = 1;
                        adj[temLine.ePoint, temLine.sPoint] = 1;
                    }
                    //Debug.Print("Segment " + count.ToString() + ": " + seg.GetType() + ", (" + findPoint(line.GetStartPoint2()) + "->" + findPoint(line.GetEndPoint2()) + ")");
                    break;

                case 1:
                    segs.Arc  temArc = new segs.Arc(seg);
                    SketchArc arc    = (SketchArc)seg;
                    temArc.setPoint(addPoint(arc.GetStartPoint2()), addPoint(arc.IGetEndPoint2()));
                    //temArc.setPoint(findPoint(arc.GetStartPoint2()), findPoint(arc.IGetEndPoint2()));
                    for (int i = 0; i < segArc.Count; i++)
                    {
                        if (temArc.same(segArc[i]))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                    else
                    {
                        segArc.Add(temArc);
                        pois[temArc.sPoint].setNext(temArc.ePoint);
                        pois[temArc.ePoint].setNext(temArc.sPoint);

                        pois[temArc.sPoint].setNextSeg(1, segArc.Count - 1);
                        pois[temArc.ePoint].setNextSeg(1, segArc.Count - 1);

                        adj[temArc.sPoint, temArc.ePoint] = 1;
                        adj[temArc.ePoint, temArc.sPoint] = 1;
                    }
                    //Debug.Print("Segment " + count.ToString() + ": " + seg.GetType() + ", (" + findPoint(arc.GetStartPoint2()) + "->" + findPoint(arc.GetEndPoint2()) + ")");
                    break;

                case 2:
                    flag = false;
                    segs.Ellipse  temEllipse = new segs.Ellipse(seg);
                    SketchEllipse ellipse    = (SketchEllipse)seg;
                    temEllipse.setPoint(addPoint(ellipse.GetStartPoint2()), addPoint(ellipse.GetEndPoint2()), addPoint(ellipse.GetCenterPoint2()));
                    //temEllipse.setPoint(findPoint(ellipse.GetStartPoint2()), findPoint(ellipse.GetEndPoint2()), findPoint(ellipse.GetCenterPoint2()));
                    for (int i = 0; i < segEll.Count; i++)
                    {
                        if (temEllipse.same(segEll[i]))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                    else
                    {
                        segEll.Add(temEllipse);
                        pois[temEllipse.sPoint].setNext(temEllipse.ePoint);
                        pois[temEllipse.ePoint].setNext(temEllipse.sPoint);

                        pois[temEllipse.sPoint].setNextSeg(2, segEll.Count - 1);
                        pois[temEllipse.ePoint].setNextSeg(2, segEll.Count - 1);

                        adj[temEllipse.sPoint, temEllipse.ePoint] = 1;
                        adj[temEllipse.ePoint, temEllipse.sPoint] = 1;
                    }
                    //Debug.Print("Segment " + count.ToString() + ": " + seg.GetType() + ", (" + findPoint(ellipse.GetStartPoint2()) + "->" + findPoint(ellipse.GetEndPoint2()) + ")");
                    break;

                case 3:
                    flag = false;
                    segs.Spline   temSpline = new segs.Spline(seg);
                    SketchSpline  spline    = (SketchSpline)seg;
                    SketchPoint[] tempoints = spline.GetPoints2();
                    for (int i = 0; i < tempoints.Length; i++)
                    {
                        int index = addPoint(tempoints[i]);
                        temSpline.setPoint(index);
                    }

                    /*
                     * for(int i = 0; i < tempoints.Length; i++)
                     * {
                     *  int index = findPoint(tempoints[i]);
                     *  temSpline.setPoint(index);
                     * }
                     */
                    for (int i = 0; i < segSpl.Count; i++)
                    {
                        if (temSpline.same(segSpl[i]))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                    else
                    {
                        segSpl.Add(temSpline);
                        pois[temSpline.sPoint].setNext(temSpline.ePoint);
                        pois[temSpline.ePoint].setNext(temSpline.sPoint);

                        pois[temSpline.sPoint].setNextSeg(3, segSpl.Count - 1);
                        pois[temSpline.ePoint].setNextSeg(3, segSpl.Count - 1);

                        adj[temSpline.sPoint, temSpline.ePoint] = 1;
                        adj[temSpline.ePoint, temSpline.sPoint] = 1;
                    }
                    //Debug.Print("Spline");
                    break;

                case 5:
                    segs.Parabola  temParabola = new segs.Parabola(seg);
                    SketchParabola parabola    = (SketchParabola)seg;
                    temParabola.setPoint(addPoint(parabola.GetStartPoint2()), addPoint(parabola.IGetEndPoint2()));
                    //temParabola.setPoint(findPoint(parabola.GetStartPoint2()), findPoint(parabola.IGetEndPoint2()));
                    for (int i = 0; i < segPar.Count; i++)
                    {
                        if (temParabola.same(segPar[i]))
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                    else
                    {
                        segPar.Add(temParabola);
                        pois[temParabola.sPoint].setNext(temParabola.ePoint);
                        pois[temParabola.ePoint].setNext(temParabola.sPoint);

                        pois[temParabola.sPoint].setNextSeg(5, segPar.Count - 1);
                        pois[temParabola.ePoint].setNextSeg(5, segPar.Count - 1);

                        adj[temParabola.sPoint, temParabola.ePoint] = 1;
                        adj[temParabola.ePoint, temParabola.sPoint] = 1;
                    }
                    //Debug.Print("Segment " + count.ToString() + ": " + seg.GetType() + ", (" + findPoint(parabola.GetStartPoint2()) + "->" + findPoint(parabola.GetEndPoint2()) + ")");
                    break;

                case 4:
                    break;
                }
            }
        }