예제 #1
0
        /// <summary>
        /// Calculates a polycurve that defines the rectangular base of the transition section.
        /// </summary>
        /// <returns>The geometry of the rectangular section</returns>
        private Polycurve GetRectangularSection()
        {
            // Note: The scale factor for the corner radius is chosen arbitrarily
            double cornerRadius = Math.Min(this.RectangularHeight, this.RectangularWidth) / 12.0;

            double halfWidth  = this.RectangularWidth / 2.0;
            double halfHeight = this.RectangularHeight / 2.0;
            double XLength    = this.RectangularWidth - 2.0 * cornerRadius;
            double YLength    = this.RectangularHeight - 2.0 * cornerRadius;

            var positiveXSegment = new LineSegment(new Point(halfWidth, -YLength / 2.0, 0),
                                                   new Point(halfWidth, YLength / 2.0, 0));

            var polycurveInLocal = new PolycurveGeometryBuilder()
                                   .Append(positiveXSegment)
                                   .AppendTangentArc(new Point(halfWidth - cornerRadius, halfHeight, 0.0))
                                   .AppendTangentSegment(XLength)
                                   .AppendTangentArc(new Point(-halfWidth, halfHeight - cornerRadius, 0.0))
                                   .AppendTangentSegment(YLength)
                                   .AppendTangentArc(new Point(-(halfWidth - cornerRadius), -halfHeight, 0.0))
                                   .AppendTangentSegment(XLength)
                                   .AppendTangentArc(new Point(halfWidth, -(halfHeight - cornerRadius), 0.0))
                                   .GetPolycurve();

            return(this.TransformToGlobal(polycurveInLocal));
        }
예제 #2
0
 public static dynamic GetTSObject(PolycurveGeometryBuilder dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
예제 #3
0
        /// <summary>
        /// Calculates four arcs that can be used to connect to the chamfered corners of the rectangular section for
        /// the transition section. The order of the arcs is the same as the order of the arcs in the rectangular
        /// section.
        /// </summary>
        /// <returns>Four arcs that form the circular section.</returns>
        private Polycurve GetCircularSection()
        {
            var centerPoint        = new Point(0, 0, this.TransitionLength);
            var topRightStartPoint = new Point(this.CircularRadius, 0, this.TransitionLength);
            var normalInLocal      = new Vector(0, 0, 1);

            var topRightArc = new Arc(centerPoint, topRightStartPoint, normalInLocal, Math.PI / 2.0);

            var polycurveInLocal = new PolycurveGeometryBuilder()
                                   .Append(topRightArc)
                                   .AppendTangentArc(new Point(-this.CircularRadius, 0, this.TransitionLength))
                                   .AppendTangentArc(new Point(0, -this.CircularRadius, this.TransitionLength))
                                   .AppendTangentArc(topRightStartPoint)
                                   .GetPolycurve();

            return(this.TransformToGlobal(polycurveInLocal));
        }
예제 #4
0
        /// <summary>
        /// Transforms a given polycurve in the local coordsys to global.
        /// </summary>
        /// <param name="curveInLocal">Curve in local coordinates.</param>
        /// <returns>The transformed polycurve in global coordinates.</returns>
        private Polycurve TransformToGlobal(Polycurve curveInLocal)
        {
            var coordSys = GetBaseCoordsys(this.BaseCentroid, this.Normal);
            var toGlobal = MatrixFactory.FromCoordinateSystem(coordSys);

            var transformedCurves = curveInLocal.Select(c => TransformGeometryByMatrix(c, toGlobal));
            var builder           = new PolycurveGeometryBuilder();

            foreach (var curve in transformedCurves)
            {
                if (curve is Arc arc)
                {
                    builder.Append(arc);
                }
                else if (curve is LineSegment segment)
                {
                    builder.Append(segment);
                }
            }

            return(builder.GetPolycurve());
        }