Beispiel #1
0
 public override Pointer Finish(Pointer Start)
 {
     return new Pointer(
         Start.X + 2 * Length * Math.Cos(Start.Phi + Alpha / 2) * Math.Sin(Alpha / 2) / Alpha,
         Start.Y + 2 * Length * Math.Sin(Start.Phi + Alpha / 2) * Math.Sin(Alpha / 2) / Alpha,
         Start.Phi + Alpha);
 }
Beispiel #2
0
 public override Pointer Finish(Pointer Start)
 {
     return new Pointer(
         Start.X + Length * Math.Cos(Start.Phi),
         Start.Y + Length * Math.Sin(Start.Phi),
         Start.Phi);
 }
 public override void Draw(Graphics Graphics, CanvasView View, Pointer Start, Pen Pen)
 {
     Pen.DashStyle = DashStyle;
     PointF StartF = View.TranslateF(Start);
     PointF FinishF = View.TranslateF(this.Finish(Start));
     Graphics.DrawLine(Pen, StartF, FinishF);
 }
Beispiel #4
0
 public Pointer Middle(Pointer Start)
 {
     return new Pointer(
         Start.X + Length / 2 * Math.Cos(Start.Phi + Alpha / 4) * MathEx.Si(Alpha / 4),
         Start.Y + Length / 2 * Math.Sin(Start.Phi + Alpha / 4) * MathEx.Si(Alpha / 4),
         Start.Phi + Alpha / 2);
 }
Beispiel #5
0
 public Pointer ClearancePointer(double Clearance)
 {
     Pointer P = new Pointer();
     P.Phi = Phi;
     P.X = this.X - Clearance * Math.Sin(P.Phi);
     P.Y = this.Y + Clearance * Math.Cos(P.Phi);
     return P;
 }
Beispiel #6
0
        public override void Draw(Graphics Graphics, CanvasView View, Pointer Start, Pen Pen)
        {
            Pen.DashStyle = DashStyle;
            float R = (float)(Radius * View.Zoom);
            PointF C = View.TranslateF(Center(Start));
            RectangleF RectangleF = new RectangleF(C.X - R, C.Y - R, 2 * R, 2 * R);

            Graphics.DrawArc(Pen, RectangleF,
                (float)(View.Translate(Center((Start))).Phi * 180 / Math.PI),
                -(View.Mirrow ? -1 : 1) * (float)(Alpha * 180 / Math.PI));
        }
Beispiel #7
0
 public Pointer Center(Pointer Start)
 {
     Pointer C = new Pointer();
     C.X = Start.X - Length / Alpha * Math.Sin(Start.Phi);
     C.Y = Start.Y + Length / Alpha * Math.Cos(Start.Phi);
     if (Alpha > 0)
         C.Phi = Math.PI / 2 - Start.Phi;
     else
         C.Phi = -Math.PI / 2 - Start.Phi;
     return C;
 }
Beispiel #8
0
        private void Calulate(Line Line)
        {
            double R = 0.1;
            foreach (dsLines.tbLineSectionsRow rwls in
                dsLines.tbLineSections.Select("[Код линии]=" + Line.ID.ToString()))
                rwls.Delete();
            dsLines.tbLineSections.AcceptChanges();

            foreach (dsLines.tbStartLineRow rwsl in
                            dsLines.tbStartLine.Select("[Код линии]=" + Line.ID.ToString()))
                rwsl.Delete();
            dsLines.tbStartLine.AcceptChanges();

            dsLines.tbStartLineRow srw = (dsLines.tbStartLineRow)
                dsLines.tbStartLine.NewRow();

            if (CorniceType == 3)
            {
                srw.Код_линии = Line.ID;
                srw.X = Line.FirstSide.Step;
                srw.Y = (Line.FirstSide.IsSide ? 0 : Line.ClearanceByWall((new Walls(dsWall)).FirstWall));
                srw.Phi = (Line.FirstSide.IsSide ?  0: -90);
                dsLines.tbStartLine.Rows.Add(srw);
                dsLines.tbStartLine.AcceptChanges();
                return;
            }

            if ((new Walls(dsWall)).Count == 0)
                return;

            srw.Код_линии = Line.ID;
            srw.X = 0;
            srw.Y = Line.ClearanceByWall((new Walls(dsWall)).FirstWall);
            dsLines.tbStartLine.Rows.Add(srw);
            dsLines.tbStartLine.AcceptChanges();

            Pointer Start = null;
            Pointer Finish = null;
            Pointer Delta = null;
            dsLines.tbLineSectionsRow rws;

            int i = 0;
            foreach (Wall Wall in new Walls(dsWall))
            {

                foreach (WallPartSection WallPart in Wall)
                {
                    if (
                        (Wall.LastSection.ID != WallPart.ID || Wall.NextCorner == null) &&
                        (Wall.FirstSection.ID != WallPart.ID || Wall.PrevCorner == null))
                    {
                        rws = (dsLines.tbLineSectionsRow)
                            dsLines.tbLineSections.NewRow();
                        rws.Код_линии = Line.ID;
                        rws.Номер = ++i;
                        rws.Длина = WallPart.Length - WallPart.Alpha * Line.ClearanceByWall(Wall);
                        rws.Угол = WallPart.Alpha * 180 / Math.PI;
                        dsLines.tbLineSections.Rows.Add(rws);
                        dsLines.tbLineSections.AcceptChanges();

                    }
                    else
                        if (
                            Wall.LastSection.ID == WallPart.ID && Wall.NextCorner != null &&
                            (Wall.FirstSection.ID != WallPart.ID || Wall.PrevCorner == null))
                        {
                            // только начало
                            Start = WallPart.StartPoint.Pointer.ClearancePointer
                                (Line.ClearanceByWall(Wall));
                        }
                        else
                        {
                            // только конец
                            Finish = WallPart.FinishPoint.Pointer.ClearancePointer
                                (Line.ClearanceByWall(Wall));
                            Delta = new Pointer(
                                (Finish.X - Start.X) * Math.Cos(Start.Phi) +
                                (Finish.Y - Start.Y) * Math.Sin(Start.Phi),
                                -(Finish.X - Start.X) * Math.Sin(Start.Phi) +
                                (Finish.Y - Start.Y) * Math.Cos(Start.Phi),
                                Finish.Phi - Start.Phi);

                            double LR = R * Math.Tan(Math.Abs(Delta.Phi / 2));
                            double L1 = Delta.X - Delta.Y / Math.Tan(Delta.Phi) - LR;
                            double L2 = Delta.Y / Math.Sin(Delta.Phi) - LR;

                            rws = (dsLines.tbLineSectionsRow)
                                dsLines.tbLineSections.NewRow();
                            rws.Код_линии = Line.ID;
                            rws.Номер = ++i;
                            rws.Длина = L1;
                            rws.Угол = 0;
                            dsLines.tbLineSections.Rows.Add(rws);
                            dsLines.tbLineSections.AcceptChanges();

                            rws = (dsLines.tbLineSectionsRow)
                                dsLines.tbLineSections.NewRow();
                            rws.Код_линии = Line.ID;
                            rws.Номер = ++i;
                            rws.Длина = R * Math.Abs(Delta.Phi);
                            rws.Угол = Delta.Phi * 180 / Math.PI;
                            dsLines.tbLineSections.Rows.Add(rws);
                            dsLines.tbLineSections.AcceptChanges();

                            if (
                                Wall.FirstSection.ID == WallPart.ID && Wall.PrevCorner != null &&
                                (Wall.LastSection.ID != WallPart.ID || Wall.NextCorner == null))
                            {
                                rws = (dsLines.tbLineSectionsRow)
                                    dsLines.tbLineSections.NewRow();
                                rws.Код_линии = Line.ID;
                                rws.Номер = ++i;
                                rws.Длина = L2;
                                rws.Угол = 0;
                                dsLines.tbLineSections.Rows.Add(rws);
                                dsLines.tbLineSections.AcceptChanges();
                            }
                            else
                                Start = LineSections.SectionByID(dsLines, rws.Код).FinishPiont.Pointer;
                        }

                }
                foreach (dsLines.tbLineSectionsRow rwls in
                                dsLines.tbLineSections.Select(String.Format
                                ("[Код линии]={0:G} AND [Длина]<0",Line.ID)))
                    rwls.Delete();
                dsLines.tbLineSections.AcceptChanges();

                i=0;
                foreach (dsLines.tbLineSectionsRow rwls in
                                dsLines.tbLineSections.Select(String.Format
                                ("[Код линии]={0:G}", Line.ID), "[Номер] ASC"))
                    rwls.Номер = ++i;
                dsLines.tbStartLine.AcceptChanges();

            }

            // начальние отступы и боковины

            dsLines.tbStartLine.FindByКод(Line.StartId).X = 0;
            dsLines.tbStartLine.FindByКод(Line.StartId).Y =
                Line.ClearanceByWall((new Walls(dsWall)).FirstWall);
            dsLines.tbStartLine.FindByКод(Line.StartId).Phi = 0;

            dsLines.tbLineSections.FindByКод(Line.FirstSection.ID).Длина -= Line.FirstSide.Step;
            dsLines.tbLineSections.AcceptChanges();
            dsLines.tbStartLine.FindByКод(Line.StartId).X += Line.FirstSide.Step;
            dsLines.tbStartLine.AcceptChanges();

            if (Line.FirstSide.IsSide)
            {
                double beta = Math.PI - Line.FirstSide.Alpha;
                double LR = R * Math.Tan(beta / 2);
                double C = Line.ClearanceByWall((new Walls(dsWall)).FirstWall);
                if (C < LR * Math.Sin(beta))
                {
                    beta = Math.Acos(1 - C / R);
                    LR = R * Math.Tan(beta / 2);
                }

                if (Math.Abs(C) > 0.001)
                {
                    dsLines.tbLineSections.FindByКод(Line.FirstSection.ID).Длина -=
                        LR + C * Math.Cos(beta) / Math.Sin(beta);
                    dsLines.tbLineSections.AcceptChanges();

                    foreach (dsLines.tbLineSectionsRow rwls in
                       dsLines.tbLineSections.Select("[Код линии]=" + Line.ID.ToString(), "[Номер] ASC"))
                        rwls.Номер += 2;
                    i += 2;

                    rws = (dsLines.tbLineSectionsRow)
                        dsLines.tbLineSections.NewRow();
                    rws.Код_линии = Line.ID;
                    rws.Номер = 2;
                    rws.Длина = R * beta;
                    rws.Угол = -beta * 180 / Math.PI;
                    dsLines.tbLineSections.Rows.Add(rws);
                    dsLines.tbLineSections.AcceptChanges();

                    if (C / Math.Sin(beta) - LR > 0.001)
                    {
                        rws = (dsLines.tbLineSectionsRow)
                            dsLines.tbLineSections.NewRow();
                        rws.Код_линии = Line.ID;
                        rws.Номер = 1;
                        rws.Длина = C / Math.Sin(beta) - LR;
                        rws.Угол = 0;
                        dsLines.tbLineSections.Rows.Add(rws);
                        dsLines.tbLineSections.AcceptChanges();
                    }

                    dsLines.tbStartLine.FindByКод(Line.StartId).Y -=
                        Line.ClearanceByWall((new Walls(dsWall)).FirstWall);
                    dsLines.tbStartLine.FindByКод(Line.StartId).Phi += beta * 180 / Math.PI;
                    dsLines.tbStartLine.AcceptChanges();

                    dsLines.tbLineSections.AcceptChanges();
                }
            }

            dsLines.tbLineSections.FindByКод(Line.LastSection.ID).Длина -= Line.LastSide.Step;
            dsLines.tbLineSections.AcceptChanges();

            if (Line.LastSide.IsSide)
            {
                double beta = Math.PI - Line.LastSide.Alpha;
                double C = Line.ClearanceByWall((new Walls(dsWall)).LastWall);
                double LR = R * Math.Tan(beta / 2);
                if (C < LR * Math.Sin(beta))
                {
                    beta = Math.Acos(1 - C / R);
                    LR = R * Math.Tan(beta / 2);
                }
                if (Math.Abs(C) > 0.001)
                {
                    dsLines.tbLineSections.FindByКод(Line.LastSection.ID).Длина -= LR + C / Math.Tan(beta);
                    dsLines.tbLineSections.AcceptChanges();

                    rws = (dsLines.tbLineSectionsRow)
                        dsLines.tbLineSections.NewRow();
                    rws.Код_линии = Line.ID;
                    rws.Номер = ++i;
                    rws.Длина = R * beta;
                    rws.Угол = -beta * 180 / Math.PI;
                    dsLines.tbLineSections.Rows.Add(rws);
                    dsLines.tbLineSections.AcceptChanges();

                    if (C / Math.Sin(beta) - LR > 0.001)
                    {
                        rws = (dsLines.tbLineSectionsRow)
                            dsLines.tbLineSections.NewRow();
                        rws.Код_линии = Line.ID;
                        rws.Номер = ++i;
                        rws.Длина = C / Math.Sin(beta) - LR;
                        rws.Угол = 0;
                        dsLines.tbLineSections.Rows.Add(rws);
                        dsLines.tbLineSections.AcceptChanges();
                    }

                }
            }

            i = 0;
            foreach (dsLines.tbLineSectionsRow rwls in
                            dsLines.tbLineSections.Select(String.Format
                            ("[Код линии]={0:G}", Line.ID), "[Номер] ASC"))
                rwls.Номер = ++i;
            dsLines.tbStartLine.AcceptChanges();
        }
Beispiel #9
0
 public abstract Pointer Finish(Pointer Start);
Beispiel #10
0
 public override Pointer Finish(Pointer Start)
 {
     return new Pointer(Start.X, Start.Y, Start.Phi + Alpha);
 }
Beispiel #11
0
 public void Draw(Graphics Graphics, CanvasView View, Pointer Start, Pen Pen)
 {
     foreach (SplintContour Contour in this)
     {
         Contour.Draw(Graphics, View, Start, Pen);
         Start = Contour.Finish(Start);
     }
 }
Beispiel #12
0
 public Pointer Translate(double X, double Y, double Phi)
 {
     Pointer p = new Pointer();
     p.X = (float)(this.X + Zoom * (X * Math.Cos(this.Phi) + Y * Math.Sin(this.Phi)));
     p.Y = (float)(this.Y + (Mirrow ? -1 : 1) *
                   Zoom * (X * Math.Sin(this.Phi) - Y * Math.Cos(this.Phi)));
     p.Phi = (Mirrow ? -1 : 1) * (this.Phi + Phi);
     return p;
 }
Beispiel #13
0
 public PointF TranslateF(Pointer Pointer)
 {
     return Translate(Pointer).PointF;
 }
Beispiel #14
0
 private void pn_Paint(object sender, PaintEventArgs e)
 {
     SplintComponent SplintCompontent =
         new SplintComponent(
             (Tag as TfMain).dsSplints, (Tag as TfMain).dsLines, Convert.ToInt32(lcb.SelectedValue),
             StartType, Convert.ToDouble(edValue.Value), 0, 0);
     CanvasView View = new CanvasView(20, 20, 0, 200, true);
     Pointer Start = new Pointer(0, 0, -Math.PI / 2);
     View = View.AutoZoom(SplintCompontent.Border(View, Start), pn.Width, pn.Height, 0.15, 0.25);
     View = View.AutoStart(SplintCompontent.Border(View, Start), pn.Width, pn.Height);
     SplintCompontent.Draw(e.Graphics, View, Start, new Pen(Color.Black, 2));
     DrawEx.DrawZoom(e.Graphics, View, pn.Width, pn.Height);
 }
Beispiel #15
0
 public Pointer Finish(Pointer Start)
 {
     foreach (SplintContour Contour in this)
     {
         if (Contour.Type == FinishType)
         {
             Start = Contour.Finish(Start);
             Start.Phi += Math.PI - Contour.Phi;
             break;
         }
         Start = Contour.Finish(Start);
     }
     return Start;
 }
Beispiel #16
0
 public abstract void Draw(Graphics Graphics, CanvasView View, Pointer Start, Pen Pen);
Beispiel #17
0
 public Pointer Finish(Pointer Start)
 {
     return new Pointer(
         Start.X + Length * Math.Cos(Start.Phi + Alpha / 2) * MathEx.Si(Alpha / 2),
         Start.Y + Length * Math.Sin(Start.Phi + Alpha / 2) * MathEx.Si(Alpha / 2),
         Start.Phi + Alpha + Phi);
 }
Beispiel #18
0
 public override Pointer Finish(Pointer Start)
 {
     Pointer F = Start;
     foreach (WallSection Section in this)
         F = Section.Finish(F);
     return F;
 }
Beispiel #19
0
 public Pointer Translate(Pointer Pointer)
 {
     return Translate(Pointer.X, Pointer.Y, Pointer.Phi);
 }
Beispiel #20
0
        protected override void Calc()
        {
            WallType = WallType.Wall;

            dsWall.tbWallDetailRow[] rwwc = (dsWall.tbWallDetailRow[])
                dsWall.tbWallDetail.Select(String.Format("[Код стены]={0:G}", ID));
            start = dsWall.tbWallSegment.FindByКод((rwwc[0]).Код_сегмента).Номер;
            finish = dsWall.tbWallSegment.FindByКод((rwwc[rwwc.Length - 1]).Код_сегмента).Номер + 1;
            count = rwwc.Length;

            L = 0;
            Pointer F = new Pointer();
            foreach (WallPartSection Section in this)
            {
                L += Section.Length;
                F = Section.Finish(F);
            }
            phi = Math.Atan2(F.Y, F.X);
            theta = F.Phi - phi;
            d = Math.Sqrt(F.X * F.X + F.Y * F.Y);

            F = new Pointer();
            Pointer S = new Pointer(0, 0, phi);
            foreach (WallPartSection Section in this)
            {
                if ((phi - F.Phi) * (phi - Section.Finish(F).Phi) <= 0)
                {
                    if (Section is WallLine)
                    {
                        S.X = F.X; S.Y = F.Y;
                    }
                    else
                    {
                        double alpha = phi - F.Phi;
                        S.X = F.X + (Section as WallArc).Radius * (1 - Math.Cos(alpha));
                        S.Y = F.Y + (Section as WallArc).Radius * Math.Sin(alpha);
                    }
                    h = S.X * Math.Sin(phi) - S.Y * Math.Cos(phi);
                }

                F = Section.Finish(F);
            }
        }
Beispiel #21
0
 public override Pointer Finish(Pointer Start)
 {
     double Si = Math.Sin(Alpha / 2) / (Alpha / 2);
     return new Pointer(
         Start.X + Length * Math.Cos(Start.Phi + Alpha / 2) * Si,
         Start.Y + Length * Math.Sin(Start.Phi + Alpha / 2) * Si,
         Start.Phi + Alpha);
 }
Beispiel #22
0
        public RectangleF Border(CanvasView View, Pointer Start)
        {
            RectangleF RectangleF = new RectangleF(
                (float)View.Translate(Start).X, (float)View.Translate(Start).Y, 1, 1);

            foreach (SplintContour Contour in this)
            {
                Start = Contour.Finish(Start);
                RectangleF = BorderWall(RectangleF, View.Translate(Start).PointF);
            }
            return RectangleF;
        }