示例#1
0
        public static DTO.PolycurvePayload PointsToPolycurvePayload(List <Point3d> points, bool closed, double length, string layer)
        {
            DTO.Segment segment;
            var         polycurvePayload = new DTO.PolycurvePayload();

            polycurvePayload.Closed   = closed;
            polycurvePayload.Segments = new List <DTO.Segment>();

            for (int i = 0; i < points.Count - 2; i++)
            {
                segment             = new DTO.Segment();
                segment.SegmentType = SegmentType.Line;
                var linePayload = new DTO.LinePayload
                {
                    Coordinates = new List <double>
                    {
                        points[i].X,
                        points[i].Y,
                        points[i].Z,
                        points[i + 1].X,
                        points[i + 1].Y,
                        points[i + 1].Z
                    }
                };

                segment.Data = JsonConvert.SerializeObject(linePayload);
                polycurvePayload.Segments.Add(segment);
            }

            var lastIndex  = points.Count - 1;
            var properties = new Dictionary <string, dynamic>()
            {
                { "EndPoint", new DTO.PointPayload {
                      Value = new List <double> {
                          points[lastIndex].X, points[lastIndex].Y, points[lastIndex].Z
                      }
                  } },
                { "Layer", layer },
                { "Length", length },
                { "StartPoint", new DTO.PointPayload {
                      Value = new List <double> {
                          points[0].X, points[0].Y, points[0].Z
                      }
                  } },
            };

            polycurvePayload.Properties = properties;
            return(polycurvePayload);
        }
示例#2
0
        public static DTO.LinePayload ToLinePayload(this LineSegment3d line)
        {
            var o = new DTO.LinePayload
            {
                Coordinates = new List <double>
                {
                    line.StartPoint.X,
                    line.StartPoint.Y,
                    line.StartPoint.Z,
                    line.EndPoint.X,
                    line.EndPoint.Y,
                    line.EndPoint.Z
                }
            };

            return(o);
        }