Exemplo n.º 1
0
        private PerpConstructionLines CalcOffsetPoints(float distance, PerpendicularRotation rotation, EntityType type)
        {
            PerpConstructionLines perpConstructionLines = new PerpConstructionLines(
                End,
                Start,
                End,
                Start,
                distance,
                rotation,
                type
                );

            return(perpConstructionLines);
        }
Exemplo n.º 2
0
        public override PartEntityOffset CalcOffset(float distance, PerpendicularRotation rotation, EntityType constructionType, EntityType lineType)
        {
            List <PerpConstructionLines> points = CalcOffsetPoints(distance, rotation, constructionType);
            List <PartEntityLine>        result = new List <PartEntityLine>();

            for (int i = 0; i < points.Count; i++)
            {
                PerpConstructionLines point = points[i];
                //perpendicular construction lines from origional line
                PartEntityLine lineStart = new PartEntityLine()
                {
                    Start = point.StartOfLine, End = point.StartOfLine + point.PerpEndPointStartLine, EntityType = constructionType
                };
                PartEntityLine lineEnd = new PartEntityLine()
                {
                    Start = point.EndOfLine, End = point.EndOfLine + point.PerpEndPointEndLine, EntityType = constructionType
                };
                result.Add(lineStart);
                result.Add(lineEnd);
                //line between construction start line and end line
                result.Add(new PartEntityLine()
                {
                    Start = point.StartOfLine + point.PerpEndPointStartLine, End = point.EndOfLine + point.PerpEndPointEndLine, EntityType = lineType
                });
            }
            //project to intersecions or trim to intersection
            List <PartEntityLine> saLines = result.Where(x => x.EntityType == lineType).ToList();

            for (int i = 0; i < saLines.Count; i++)
            {
                PartEntityLine line = saLines[i];
                if (i + 1 < saLines.Count)
                {
                    PartEntityLine lineNext     = saLines[i + 1];
                    Vector2        intersection = Utils.CalcIntersection(line, lineNext);
                    //TODO: check this logic
                    if (intersection != Vector2.Zero)
                    {
                        if (!float.IsNaN(intersection.X) && !float.IsNaN(intersection.Y))
                        {
                            line.End       = intersection;
                            lineNext.Start = intersection;
                        }
                    }
                }
                //System.Diagnostics.Debug.WriteLine("[" + i + "] " + line.ToString());
            }
            return(new PartEntityOffset(result));
        }
Exemplo n.º 3
0
        private List <PerpConstructionLines> CalcOffsetPoints(float distance, PerpendicularRotation rotation, EntityType type)
        {
            List <PerpConstructionLines> result = new List <PerpConstructionLines>();

            for (int i = 0; i < Lines.Count; i++)
            {
                PartEntityLine        line = Lines[i];
                PerpConstructionLines perpConstructionLines = new PerpConstructionLines(
                    line.End,
                    line.Start,
                    line.End,
                    line.Start,
                    distance,
                    rotation,
                    type
                    );
                result.Add(perpConstructionLines);
            }
            return(result);
        }
Exemplo n.º 4
0
        public override PartEntityOffset CalcOffset(float distance, PerpendicularRotation rotation, EntityType constructionType, EntityType lineType)
        {
            List <PartEntityLine> result = new List <PartEntityLine>();
            PerpConstructionLines point  = CalcOffsetPoints(distance, rotation, constructionType);
            //perpendicular construction lines from origional line
            PartEntityLine lineStart = new PartEntityLine()
            {
                Start = point.StartOfLine, End = point.StartOfLine + point.PerpEndPointStartLine, EntityType = constructionType
            };
            PartEntityLine lineEnd = new PartEntityLine()
            {
                Start = point.EndOfLine, End = point.EndOfLine + point.PerpEndPointEndLine, EntityType = constructionType
            };

            result.Add(lineStart);
            result.Add(lineEnd);
            //line between construction start line and end line
            result.Add(new PartEntityLine()
            {
                Start = point.StartOfLine + point.PerpEndPointStartLine, End = point.EndOfLine + point.PerpEndPointEndLine, EntityType = lineType
            });
            return(new PartEntityOffset(result));
        }
Exemplo n.º 5
0
        public List <PerpConstructionLines> AddDefaultSAConstructionLines(float length, PerpendicularRotation rotation, EntityType type)
        {
            List <PerpConstructionLines> listOfPerpPoints = new List <PerpConstructionLines>();
            List <PartEntity>            filtered         = GetNormalEntitys();

            for (int i = 0; i < filtered.Count; i++)
            {
                PartEntity first = filtered[i];
                PartEntity second;
                if (i + 1 < filtered.Count)
                {
                    second = filtered[i + 1];
                }
                else
                {
                    second = filtered[0];
                }

                PerpConstructionLines pcl = new PerpConstructionLines(second, second.End, first.End,
                                                                      second.End, first.End, length, rotation, type);
                listOfPerpPoints.Add(pcl);
            }
            return(listOfPerpPoints);
        }