Esempio n. 1
0
        private Spiral AlignmentSpiralToSpeckle(CivilDB.AlignmentSubEntitySpiral spiral, CivilDB.Alignment alignment)
        {
            var _spiral = new Spiral();

            _spiral.startPoint = PointToSpeckle(spiral.StartPoint);
            _spiral.endPoint   = PointToSpeckle(spiral.EndPoint);
            _spiral.length     = spiral.Length;
            _spiral.pitch      = 0;
            _spiral.spiralType = SpiralTypeToSpeckle(spiral.SpiralDefinition);

            // get plane
            var vX    = new Vector3d(System.Math.Cos(spiral.StartDirection) + spiral.StartPoint.X, System.Math.Sin(spiral.StartDirection) + spiral.StartPoint.Y, 0);
            var vY    = vX.RotateBy(System.Math.PI / 2, Vector3d.ZAxis);
            var plane = new Acad.Plane(new Point3d(spiral.RadialPoint.X, spiral.RadialPoint.Y, 0), vX, vY);

            _spiral.plane = PlaneToSpeckle(plane);

            // get turns
            int turnDirection = (spiral.Direction == CivilDB.SpiralDirectionType.DirectionLeft) ? 1 : -1;

            _spiral.turns = turnDirection * spiral.Delta / (System.Math.PI * 2);

            // create polyline display, default tessellation length is 1
            var tessellation       = 1;
            int spiralSegmentCount = System.Convert.ToInt32(System.Math.Ceiling(spiral.Length / tessellation));

            spiralSegmentCount = (spiralSegmentCount < 10) ? 10 : spiralSegmentCount;
            double         spiralSegmentLength = spiral.Length / spiralSegmentCount;
            List <Point2d> points = new List <Point2d>();

            points.Add(spiral.StartPoint);
            for (int i = 1; i < spiralSegmentCount; i++)
            {
                double x = 0;
                double y = 0;
                double z = 0;

                alignment.PointLocation(spiral.StartStation + (i * spiralSegmentLength), 0, tolerance, ref x, ref y, ref z);
                points.Add(new Point2d(x, y));
            }
            points.Add(spiral.EndPoint);
            double length = 0;

            for (int j = 1; j < points.Count; j++)
            {
                length += points[j].GetDistanceTo(points[j - 1]);
            }
            var poly = new Polyline();

            poly.value           = PointsToFlatList(points);
            poly.units           = ModelUnits;
            poly.closed          = (spiral.StartPoint != spiral.EndPoint) ? false : true;
            poly.length          = length;
            _spiral.displayValue = poly;

            return(_spiral);
        }
 internal AlignmentSpiral
     (C3dDb.AlignmentSubEntitySpiral subEntitySpiral)
     : base(subEntitySpiral)
 {
 }