public List <Geo.Line> GetFlangeAxes()
 {
     Geo.Point  OP1         = _webAxis.StartPoint;
     Geo.Point  OP2         = _webAxis.EndPoint;
     Geo.Vector webAxisVec  = Geo.Vector.ByTwoPoints(OP1, OP2);
     Geo.Vector normal      = _webNormal.Normalized().Scale(0.75);;
     Geo.Vector lateral     = webAxisVec.Cross(normal).Normalized().Scale(1.75);
     Geo.Line   flangeLine1 = Geo.Line.ByStartPointEndPoint(OP1.Add(normal.Add(lateral)), OP2.Add(normal.Add(lateral)));
     lateral = webAxisVec.Cross(normal).Normalized().Scale(-1.75);
     Geo.Line flangeLine2 = Geo.Line.ByStartPointEndPoint(OP1.Add(normal.Add(lateral)), OP2.Add(normal.Add(lateral)));
     return(new List <Geo.Line> {
         flangeLine1, flangeLine2
     });
 }
        public static Dictionary <string, object> Draw(hMember member)
        {
            Geo.Point OP1 = member._webAxis.StartPoint;
            Geo.Point OP2 = member._webAxis.EndPoint;

            Geo.Vector webAxis = Geo.Vector.ByTwoPoints(OP1, OP2);
            Geo.Vector normal  = member._webNormal;
            Geo.Vector lateral = webAxis.Cross(normal);
            lateral = lateral.Normalized();
            lateral = lateral.Scale(1.75);
            normal  = normal.Normalized();
            normal  = normal.Scale(1.5);
            Geo.Vector lateralR = Geo.Vector.ByCoordinates(lateral.X * -1, lateral.Y * -1, lateral.Z * -1);

            Geo.Point p0 = OP1.Add(normal.Add(lateral));
            Geo.Point p1 = OP2.Add(normal.Add(lateral));
            Geo.Point p2 = OP1.Add(lateral);
            Geo.Point p3 = OP2.Add(lateral);
            Geo.Point p6 = OP1.Add(normal.Add(lateralR));
            Geo.Point p7 = OP2.Add(normal.Add(lateralR));
            Geo.Point p4 = OP1.Add(lateralR);
            Geo.Point p5 = OP2.Add(lateralR);

            Geo.Point[] pts = { p0, p1, p2, p1, p2, p3, p2, p3, p4, p3, p4, p5, p4, p5, p6, p5, p6, p7 };

            Geo.IndexGroup g0 = Geo.IndexGroup.ByIndices(0, 1, 2);
            Geo.IndexGroup g1 = Geo.IndexGroup.ByIndices(3, 4, 5);
            Geo.IndexGroup g2 = Geo.IndexGroup.ByIndices(6, 7, 8);
            Geo.IndexGroup g3 = Geo.IndexGroup.ByIndices(9, 10, 11);
            Geo.IndexGroup g4 = Geo.IndexGroup.ByIndices(12, 13, 14);
            Geo.IndexGroup g5 = Geo.IndexGroup.ByIndices(15, 16, 17);

            Geo.IndexGroup[] ig = { g0, g1, g2, g3, g4, g5 };

            Geo.Mesh mesh = Geo.Mesh.ByPointsFaceIndices(pts, ig);

            var points = new List <Geo.Point>();

            foreach (hOperation op in member.operations)
            {
                points.Add(member._webAxis.PointAtParameter(op._loc / member._webAxis.Length));
            }

            return(new Dictionary <string, object>
            {
                { "member", mesh },
                { "operations", points }
            });
        }
        /// <summary>
        /// Callback method when gizmo is moved by user action.
        /// </summary>
        /// <param name="gizmoInAction">Gizmo that moved.</param>
        /// <param name="offset">Offset by which the gizmo has moved.</param>
        protected override void OnGizmoMoved(IGizmo gizmoInAction, Vector offset)
        {
            var offsetPos = origin.Add(offset);

            origin.Dispose();
            origin = offsetPos;
        }
Esempio n. 4
0
        /// <summary>
        /// Callback method when gizmo is moved by user action.
        /// </summary>
        /// <param name="gizmo">Gizmo that moved.</param>
        /// <param name="offset">Offset by which the gizmo has moved.</param>
        /// <returns>New expected position of the Gizmo</returns>
        protected override Point OnGizmoMoved(IGizmo gizmo, Vector offset)
        {
            expectedPosition = origin.Add(offset);

            foreach (var item in indexedAxisNodePairs)
            {
                // When more than one input is connected to the same slider, this
                // method will decompose the axis corresponding to each input.
                var v      = GetFirstAxisComponent(item.Value.Item1);
                var amount = Math.Round(offset.Dot(v), 3);
                if (Math.Abs(amount) > 0.001)
                {
                    ModifyInputNode(item.Value.Item2, amount);
                }
            }

            return(expectedPosition);
        }
Esempio n. 5
0
        /// <summary>
        /// Implements the MouseMove event handler for the manipulator
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        protected virtual void MouseMove(object sender, MouseEventArgs mouseEventArgs)
        {
            if (!IsEnabled())
            {
                return;
            }

            var clickRay = BackgroundPreviewViewModel.GetClickRay(mouseEventArgs);

            if (clickRay == null)
            {
                return;
            }

            if (GizmoInAction == null)
            {
                HighlightGizmoOnRollOver(clickRay);
                return;
            }

            var offset = GizmoInAction.GetOffset(clickRay.GetOriginPoint(), clickRay.GetDirectionVector());

            if (offset.Length < 0.01)
            {
                return;
            }

            if (originAfterMove != null)
            {
                var offsetPos = originAfterMove.Add(offset);
                originAfterMove.Dispose();
                originAfterMove = offsetPos;
            }

            // Update input nodes attached to manipulator node
            // Doing this triggers a graph update on scheduler thread
            OnGizmoMoved(GizmoInAction, offset);

            // redraw manipulator at new position synchronously
            var packages = BuildRenderPackage();

            BackgroundPreviewViewModel.AddGeometryForRenderPackages(packages);
        }
Esempio n. 6
0
        /// <summary>
        /// Callback method when gizmo is moved by user action.
        /// </summary>
        /// <param name="gizmoInAction">Gizmo that moved.</param>
        /// <param name="offset">Offset by which the gizmo has moved.</param>
        protected override void OnGizmoMoved(IGizmo gizmoInAction, Vector offset)
        {
            var offsetPos = origin.Add(offset);

            origin.Dispose();
            origin = offsetPos;

            foreach (var item in indexedAxisNodePairs)
            {
                // When more than one input is connected to the same slider, this
                // method will decompose the axis corresponding to each input.
                using (var v = GetFirstAxisComponent(item.Value.Item1))
                {
                    var amount = offset.Dot(v);

                    if (Math.Abs(amount) > 0.001)
                    {
                        ModifyInputNode(item.Value.Item2, amount);
                    }
                }
            }
        }
Esempio n. 7
0
 public static Line ToOriginCenteredLine(Point origin, Vector axis)
 {
     return(Line.ByStartPointEndPoint(origin.Add(axis.Scale(-axisScaleFactor)),
                                      origin.Add(axis.Scale(axisScaleFactor))));
 }
 public static Line ToOriginCenteredLine(Point origin, Vector axis)
 {
     return Line.ByStartPointEndPoint(origin.Add(axis.Scale(-axisScaleFactor)),
         origin.Add(axis.Scale(axisScaleFactor)));
 }
Esempio n. 9
0
        /// <summary>
        /// Create a Revit Floor given it's curve outline and Level
        /// </summary>
        /// <param name="outline">The outline.</param>
        /// <param name="floorType">Type of the floor.</param>
        /// <param name="level">The level.</param>
        /// <param name="structural">if set to <c>true</c> [structural].</param>
        /// <returns>
        /// The floor
        /// </returns>
        public static SlopedFloor ByOutlineTypeAndLevel(Autodesk.DesignScript.Geometry.PolyCurve outline, Revit.Elements.FloorType floorType, Revit.Elements.Level level, bool structural)
        {
            Utils.Log(string.Format("SlopedFloor.ByOutlineTypeAndLevel started...", ""));

            try
            {
                var profile = new CurveArray();

                Autodesk.DesignScript.Geometry.Plane plane = Autodesk.DesignScript.Geometry.Plane.ByBestFitThroughPoints(
                    outline.Curves().Cast <Autodesk.DesignScript.Geometry.Curve>().Select(x => x.StartPoint));

                Vector normal = plane.Normal;
                if (normal.Dot(Vector.ZAxis()) <= 0)
                {
                    normal = normal.Reverse();
                }

                Autodesk.DesignScript.Geometry.Point origin     = plane.Origin;
                Autodesk.DesignScript.Geometry.Point end        = origin.Add(normal);
                Autodesk.DesignScript.Geometry.Point projection = Autodesk.DesignScript.Geometry.Point.ByCoordinates(end.X, end.Y, -1000);
                end = Autodesk.DesignScript.Geometry.Point.ByCoordinates(end.X, end.Y, end.Z + 1000);
                Autodesk.DesignScript.Geometry.Point intersection = null;
                var result = plane.Intersect(Autodesk.DesignScript.Geometry
                                             .Line.ByStartPointEndPoint(end, projection));

                if (result.Length > 0)
                {
                    intersection = result[0] as Autodesk.DesignScript.Geometry.Point;
                }
                else
                {
                    var message = "Couldn't find intersection";

                    Utils.Log(string.Format("ERROR: SlopedFloor.ByOutlineTypeAndLevel {0}", message));

                    throw new Exception(message);
                }

                Autodesk.DesignScript.Geometry.Curve temp = Autodesk.DesignScript.Geometry.Line.ByBestFitThroughPoints(new Autodesk.DesignScript.Geometry.Point[] { origin, intersection });

                PolyCurve flat = PolyCurve.ByJoinedCurves(outline.PullOntoPlane(Autodesk.DesignScript.Geometry.Plane.XY()
                                                                                .Offset(temp.StartPoint.Z)).Explode().Cast <Autodesk.DesignScript.Geometry.Curve>().ToList());

                Autodesk.DesignScript.Geometry.Curve flatLine = temp.PullOntoPlane(Autodesk.DesignScript.Geometry.Plane.XY().Offset(temp.StartPoint.Z));

                if (Math.Abs(Math.Abs(plane.Normal.Dot(Vector.ZAxis())) - 1) < 0.00001)
                {
                    var f = Revit.Elements.Floor.ByOutlineTypeAndLevel(flat, floorType, level);
                    f.InternalElement.Parameters.Cast <Autodesk.Revit.DB.Parameter>()
                    .First(x => x.Id.IntegerValue.Equals(Autodesk.Revit.DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL))
                    .Set(structural ? 1 : 0);

                    plane.Dispose();
                    flatLine.Dispose();
                    flat.Dispose();
                    origin.Dispose();
                    end.Dispose();
                    projection.Dispose();
                    intersection.Dispose();
                    temp.Dispose();

                    return(new SlopedFloor(f.InternalElement as Autodesk.Revit.DB.Floor));
                }

                double slope = (temp.EndPoint.Z - temp.StartPoint.Z) / flatLine.Length;

                foreach (Autodesk.DesignScript.Geometry.Curve c in flat.Curves())
                {
                    profile.Append(c.ToRevitType());
                }

                Autodesk.Revit.DB.Line slopeArrow = flatLine.ToRevitType() as Autodesk.Revit.DB.Line;

                var ft  = floorType.InternalElement as Autodesk.Revit.DB.FloorType;
                var lvl = level.InternalElement as Autodesk.Revit.DB.Level;

                var floor = new SlopedFloor(profile, slopeArrow, slope, ft, lvl, structural);

                floor.Level      = level;
                floor.Floortype  = floorType;
                floor.Structural = structural;

                //DocumentManager.Regenerate();

                plane.Dispose();
                flatLine.Dispose();
                flat.Dispose();
                origin.Dispose();
                end.Dispose();
                projection.Dispose();
                intersection.Dispose();
                temp.Dispose();

                Utils.Log(string.Format("SlopedFloor.ByOutlineTypeAndLevel completed.", ""));

                return(floor);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: SlopedFloor.ByOutlineTypeAndLevel {0}", ex.Message));

                throw ex;
            }
        }
        public void Tessellate(IRenderPackage package, TessellationParameters parameters)
        {
            package.RequiresPerVertexColoration = true;

            Geo.Point OP1 = this._webAxis.StartPoint;
            Geo.Point OP2 = this._webAxis.EndPoint;

            Geo.Vector webAxis = Geo.Vector.ByTwoPoints(OP1, OP2);
            Geo.Vector normal  = _webNormal;
            Geo.Vector lateral = webAxis.Cross(normal);
            lateral = lateral.Normalized();
            lateral = lateral.Scale(1.75);
            normal  = normal.Normalized();
            normal  = normal.Scale(1.5);
            Geo.Vector lateralR = Geo.Vector.ByCoordinates(lateral.X * -1, lateral.Y * -1, lateral.Z * -1);
            Geo.Vector webAxisR = Geo.Vector.ByCoordinates(webAxis.X * -1, webAxis.Y * -1, webAxis.Z * -1);
            Geo.Vector normalR  = Geo.Vector.ByCoordinates(normal.X * -1, normal.Y * -1, normal.Z * -1);

            Geo.Point p0 = OP1.Add(normal.Add(lateral));
            Geo.Point p1 = OP2.Add(normal.Add(lateral));
            Geo.Point p2 = OP1.Add(lateral);
            Geo.Point p3 = OP2.Add(lateral);
            Geo.Point p6 = OP1.Add(normal.Add(lateralR));
            Geo.Point p7 = OP2.Add(normal.Add(lateralR));
            Geo.Point p4 = OP1.Add(lateralR);
            Geo.Point p5 = OP2.Add(lateralR);
            lateral  = lateral.Normalized().Scale(1.25);
            lateralR = lateralR.Normalized().Scale(1.25);
            Geo.Point p8  = OP1.Add(lateralR).Add(normal);
            Geo.Point p9  = OP2.Add(lateralR).Add(normal);
            Geo.Point p10 = OP1.Add(lateral).Add(normal);
            Geo.Point p11 = OP2.Add(lateral).Add(normal);
            ////////////        //          //          //          //          //          //          //           //            //          //
            Geo.Point[]  pts     = { p0, p1, p2, p1, p2, p3, p2, p3, p4, p3, p4, p5, p4, p5, p6, p5, p6, p7, p0, p1, p10, p1, p10, p11, p6, p7, p8, p7, p8, p9 };
            Geo.Vector[] vectors = { lateral, normal, lateral.Reverse(), normal.Reverse(), normal.Reverse() };
            byte[]       colors  = { 100, 100, 100, 100, 110, 110, 110, 110, 110, 110 };

            var faces = new List <List <int> >
            {
                new List <int> {
                    0, 1, 2
                },
                new List <int> {
                    3, 4, 5
                },
                new List <int> {
                    6, 7, 8
                },
                new List <int> {
                    9, 10, 11
                },
                new List <int> {
                    12, 13, 14
                },
                new List <int> {
                    15, 16, 17
                },
                new List <int> {
                    18, 19, 20
                },
                new List <int> {
                    21, 22, 23
                },
                new List <int> {
                    24, 25, 26
                },
                new List <int> {
                    27, 28, 29
                }
            };

            for (int i = 0; i < faces.Count; i++)
            {
                package.AddTriangleVertex(pts[faces[i][0]].X, pts[faces[i][0]].Y, pts[faces[i][0]].Z);
                package.AddTriangleVertex(pts[faces[i][1]].X, pts[faces[i][1]].Y, pts[faces[i][1]].Z);
                package.AddTriangleVertex(pts[faces[i][2]].X, pts[faces[i][2]].Y, pts[faces[i][2]].Z);
                package.AddTriangleVertexColor(colors[i], colors[i], colors[i], 255);
                package.AddTriangleVertexColor(colors[i], colors[i], colors[i], 255);
                package.AddTriangleVertexColor(colors[i], colors[i], colors[i], 255);
                package.AddTriangleVertexNormal(vectors[i / 2].X, vectors[i / 2].Y, vectors[i / 2].Z);
                package.AddTriangleVertexNormal(vectors[i / 2].X, vectors[i / 2].Y, vectors[i / 2].Z);
                package.AddTriangleVertexNormal(vectors[i / 2].X, vectors[i / 2].Y, vectors[i / 2].Z);
                package.AddTriangleVertexUV(0, 0);
                package.AddTriangleVertexUV(0, 0);
                package.AddTriangleVertexUV(0, 0);
            }

            foreach (hOperation op in operations)
            {
                Geo.Point opPoint = this._webAxis.PointAtParameter(op._loc / this._webAxis.Length);
                byte      r       = 255;
                byte      g       = 66;
                byte      b       = 57;
                byte      a       = 255;
                switch (op._type)
                {
                case Operation.WEB:
                    package.AddPointVertex(opPoint.X, opPoint.Y, opPoint.Z);
                    package.AddPointVertexColor(r, g, b, a);

                    lateral  = lateral.Normalized().Scale(15.0 / 16.0);
                    lateralR = lateralR.Normalized().Scale(15.0 / 16.0);

                    package.AddPointVertex(opPoint.Add(lateral).X, opPoint.Add(lateral).Y, opPoint.Add(lateral).Z);
                    package.AddPointVertexColor(r, g, b, a);
                    package.AddPointVertex(opPoint.Add(lateralR).X, opPoint.Add(lateralR).Y, opPoint.Add(lateralR).Z);
                    package.AddPointVertexColor(r, g, b, a);
                    break;

                case Operation.DIMPLE:
                    lateral  = lateral.Normalized().Scale(1.0);
                    lateralR = lateralR.Normalized().Scale(1.0);
                    normal   = normal.Normalized().Scale(0.75);

                    package.AddLineStripVertex(opPoint.Add(lateral.Add(normal)).X, opPoint.Add(lateral.Add(normal)).Y, opPoint.Add(lateral.Add(normal)).Z);
                    lateral = lateral.Normalized().Scale(2.5);
                    package.AddLineStripVertex(opPoint.Add(lateral.Add(normal)).X, opPoint.Add(lateral.Add(normal)).Y, opPoint.Add(lateral.Add(normal)).Z);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexCount(2);

                    lateral = lateral.Normalized().Scale(1.75);
                    package.AddPointVertex(opPoint.Add(lateral.Add(normal)).X, opPoint.Add(lateral.Add(normal)).Y, opPoint.Add(lateral.Add(normal)).Z);
                    package.AddPointVertexColor(r, g, b, a);

                    package.AddLineStripVertex(opPoint.Add(lateralR.Add(normal)).X, opPoint.Add(lateralR.Add(normal)).Y, opPoint.Add(lateralR.Add(normal)).Z);
                    lateralR = lateralR.Normalized().Scale(2.5);
                    package.AddLineStripVertex(opPoint.Add(lateralR.Add(normal)).X, opPoint.Add(lateralR.Add(normal)).Y, opPoint.Add(lateralR.Add(normal)).Z);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexCount(2);

                    lateralR = lateralR.Normalized().Scale(1.75);
                    package.AddPointVertex(opPoint.Add(lateralR.Add(normal)).X, opPoint.Add(lateralR.Add(normal)).Y, opPoint.Add(lateralR.Add(normal)).Z);
                    package.AddPointVertexColor(r, g, b, a);
                    break;

                case Operation.SWAGE:
                    lateral  = lateral.Normalized().Scale(1.25);
                    lateralR = lateralR.Normalized().Scale(1.25);
                    webAxis  = webAxis.Normalized().Scale(.875);
                    webAxisR = webAxisR.Normalized().Scale(.875);

                    package.AddLineStripVertex(opPoint.Add(lateral.Add(webAxis)).X, opPoint.Add(lateral.Add(webAxis)).Y, opPoint.Add(lateral.Add(webAxis)).Z);
                    package.AddLineStripVertex(opPoint.Add(lateral.Add(webAxisR)).X, opPoint.Add(lateral.Add(webAxisR)).Y, opPoint.Add(lateral.Add(webAxisR)).Z);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexCount(2);

                    package.AddLineStripVertex(opPoint.Add(lateralR.Add(webAxis)).X, opPoint.Add(lateralR.Add(webAxis)).Y, opPoint.Add(lateralR.Add(webAxis)).Z);
                    package.AddLineStripVertex(opPoint.Add(lateralR.Add(webAxisR)).X, opPoint.Add(lateralR.Add(webAxisR)).Y, opPoint.Add(lateralR.Add(webAxisR)).Z);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexColor(r, g, b, a);
                    package.AddLineStripVertexCount(2);
                    break;

                case Operation.BOLT:
                    lateral  = lateral.Normalized().Scale(0.25);
                    lateralR = lateralR.Normalized().Scale(0.25);
                    webAxis  = webAxis.Normalized().Scale(0.25);
                    webAxisR = webAxisR.Normalized().Scale(0.25);
                    normal   = normal.Normalized().Scale(0.01);
                    normalR  = normalR.Normalized().Scale(0.01);

                    Geo.Point[] boltPts = { opPoint.Add(lateral.Add(webAxis.Add(normal))), opPoint.Add(lateral.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxis.Add(normal))) };
                    package.AddTriangleVertex(boltPts[0].X, boltPts[0].Y, boltPts[0].Z);
                    package.AddTriangleVertex(boltPts[1].X, boltPts[1].Y, boltPts[1].Z);
                    package.AddTriangleVertex(boltPts[2].X, boltPts[2].Y, boltPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(boltPts[0].X, boltPts[0].Y, boltPts[0].Z);
                    package.AddTriangleVertex(boltPts[2].X, boltPts[2].Y, boltPts[2].Z);
                    package.AddTriangleVertex(boltPts[3].X, boltPts[3].Y, boltPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    boltPts = new Geo.Point[] { opPoint.Add(lateral.Add(webAxis.Add(normalR))), opPoint.Add(lateral.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxis.Add(normalR))) };
                    package.AddTriangleVertex(boltPts[0].X, boltPts[0].Y, boltPts[0].Z);
                    package.AddTriangleVertex(boltPts[1].X, boltPts[1].Y, boltPts[1].Z);
                    package.AddTriangleVertex(boltPts[2].X, boltPts[2].Y, boltPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(boltPts[0].X, boltPts[0].Y, boltPts[0].Z);
                    package.AddTriangleVertex(boltPts[2].X, boltPts[2].Y, boltPts[2].Z);
                    package.AddTriangleVertex(boltPts[3].X, boltPts[3].Y, boltPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    break;

                case Operation.SERVICE_HOLE:
                    lateral  = lateral.Normalized().Scale(0.5);
                    lateralR = lateralR.Normalized().Scale(0.5);
                    webAxis  = webAxis.Normalized().Scale(0.5);
                    webAxisR = webAxisR.Normalized().Scale(0.5);
                    normal   = normal.Normalized().Scale(0.01);
                    normalR  = normalR.Normalized().Scale(0.01);

                    Geo.Point[] servicePts = new Geo.Point[] { opPoint.Add(lateral.Add(webAxis.Add(normal))), opPoint.Add(lateral.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxis.Add(normal))) };
                    package.AddTriangleVertex(servicePts[0].X, servicePts[0].Y, servicePts[0].Z);
                    package.AddTriangleVertex(servicePts[1].X, servicePts[1].Y, servicePts[1].Z);
                    package.AddTriangleVertex(servicePts[2].X, servicePts[2].Y, servicePts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(servicePts[0].X, servicePts[0].Y, servicePts[0].Z);
                    package.AddTriangleVertex(servicePts[2].X, servicePts[2].Y, servicePts[2].Z);
                    package.AddTriangleVertex(servicePts[3].X, servicePts[3].Y, servicePts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    servicePts = new Geo.Point[] { opPoint.Add(lateral.Add(webAxis.Add(normalR))), opPoint.Add(lateral.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxis.Add(normalR))) };
                    package.AddTriangleVertex(servicePts[0].X, servicePts[0].Y, servicePts[0].Z);
                    package.AddTriangleVertex(servicePts[1].X, servicePts[1].Y, servicePts[1].Z);
                    package.AddTriangleVertex(servicePts[2].X, servicePts[2].Y, servicePts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(servicePts[0].X, servicePts[0].Y, servicePts[0].Z);
                    package.AddTriangleVertex(servicePts[2].X, servicePts[2].Y, servicePts[2].Z);
                    package.AddTriangleVertex(servicePts[3].X, servicePts[3].Y, servicePts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    break;


                case Operation.NOTCH:
                    lateral  = lateral.Normalized().Scale(1.75);
                    lateralR = lateralR.Normalized().Scale(1.75);
                    webAxis  = webAxis.Normalized().Scale(0.875);
                    webAxisR = webAxisR.Normalized().Scale(0.875);
                    normal   = normal.Normalized().Scale(0.01);
                    normalR  = normalR.Normalized().Scale(0.01);

                    Geo.Point[] notchPts = { opPoint.Add(lateral.Add(webAxis.Add(normal))), opPoint.Add(lateral.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxisR.Add(normal))), opPoint.Add(lateralR.Add(webAxis.Add(normal))) };
                    package.AddTriangleVertex(notchPts[0].X, notchPts[0].Y, notchPts[0].Z);
                    package.AddTriangleVertex(notchPts[1].X, notchPts[1].Y, notchPts[1].Z);
                    package.AddTriangleVertex(notchPts[2].X, notchPts[2].Y, notchPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(notchPts[0].X, notchPts[0].Y, notchPts[0].Z);
                    package.AddTriangleVertex(notchPts[2].X, notchPts[2].Y, notchPts[2].Z);
                    package.AddTriangleVertex(notchPts[3].X, notchPts[3].Y, notchPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);


                    notchPts = new Geo.Point[] { opPoint.Add(lateral.Add(webAxis.Add(normalR))), opPoint.Add(lateral.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxisR.Add(normalR))), opPoint.Add(lateralR.Add(webAxis.Add(normalR))) };
                    package.AddTriangleVertex(notchPts[0].X, notchPts[0].Y, notchPts[0].Z);
                    package.AddTriangleVertex(notchPts[1].X, notchPts[1].Y, notchPts[1].Z);
                    package.AddTriangleVertex(notchPts[2].X, notchPts[2].Y, notchPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(notchPts[0].X, notchPts[0].Y, notchPts[0].Z);
                    package.AddTriangleVertex(notchPts[2].X, notchPts[2].Y, notchPts[2].Z);
                    package.AddTriangleVertex(notchPts[3].X, notchPts[3].Y, notchPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    break;

                case Operation.LIP_CUT:
                    lateral  = lateral.Normalized().Scale(1.75);
                    lateralR = lateralR.Normalized().Scale(1.75);
                    webAxis  = webAxis.Normalized().Scale(0.875);
                    webAxisR = webAxisR.Normalized().Scale(0.875);
                    normal   = normal.Normalized().Scale(1.51);
                    normalR  = normalR.Normalized().Scale(0.01);
                    Geo.Vector lateral2  = lateral.Normalized().Scale(1.25);
                    Geo.Vector lateral2R = lateralR.Normalized().Scale(1.25);

                    Geo.Point[] lipPts = { opPoint.Add(webAxis).Add(lateral).Add(normal), opPoint.Add(webAxisR).Add(lateral).Add(normal), opPoint.Add(webAxis).Add(lateral2).Add(normal), opPoint.Add(webAxisR).Add(lateral2).Add(normal) };
                    package.AddTriangleVertex(lipPts[0].X, lipPts[0].Y, lipPts[0].Z);
                    package.AddTriangleVertex(lipPts[1].X, lipPts[1].Y, lipPts[1].Z);
                    package.AddTriangleVertex(lipPts[2].X, lipPts[2].Y, lipPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(lipPts[1].X, lipPts[1].Y, lipPts[1].Z);
                    package.AddTriangleVertex(lipPts[2].X, lipPts[2].Y, lipPts[2].Z);
                    package.AddTriangleVertex(lipPts[3].X, lipPts[3].Y, lipPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);


                    lipPts = new Geo.Point[] { opPoint.Add(webAxis).Add(lateralR).Add(normal), opPoint.Add(webAxisR).Add(lateralR).Add(normal), opPoint.Add(webAxis).Add(lateral2R).Add(normal), opPoint.Add(webAxisR).Add(lateral2R).Add(normal) };
                    package.AddTriangleVertex(lipPts[0].X, lipPts[0].Y, lipPts[0].Z);
                    package.AddTriangleVertex(lipPts[1].X, lipPts[1].Y, lipPts[1].Z);
                    package.AddTriangleVertex(lipPts[2].X, lipPts[2].Y, lipPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    package.AddTriangleVertex(lipPts[1].X, lipPts[1].Y, lipPts[1].Z);
                    package.AddTriangleVertex(lipPts[2].X, lipPts[2].Y, lipPts[2].Z);
                    package.AddTriangleVertex(lipPts[3].X, lipPts[3].Y, lipPts[3].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexNormal(normal.X, normal.Y, normal.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    break;


                case Operation.END_TRUSS:
                    lateral  = lateral.Normalized().Scale(1.76);
                    lateralR = lateralR.Normalized().Scale(1.76);
                    if (opPoint.DistanceTo(this._webAxis.StartPoint) < opPoint.DistanceTo(this._webAxis.EndPoint))
                    {
                        webAxis = webAxis.Normalized().Scale(0.5);
                    }
                    else
                    {
                        webAxis = webAxisR.Normalized().Scale(0.5);
                    }

                    normal = normal.Normalized().Scale(1.50);
                    Geo.Vector normal2 = normal.Normalized().Scale(1.0);
                    Geo.Vector normal3 = normal.Normalized().Scale(0.5);
                    normalR   = normalR.Normalized().Scale(0.01);
                    lateral2  = lateral.Normalized().Scale(1.25);
                    lateral2R = lateralR.Normalized().Scale(1.25);

                    Geo.Point[] endTrussPts = { opPoint.Add(lateral).Add(normal2), opPoint.Add(lateral).Add(normal).Add(webAxis), opPoint.Add(lateral).Add(normal) };
                    package.AddTriangleVertex(endTrussPts[0].X, endTrussPts[0].Y, endTrussPts[0].Z);
                    package.AddTriangleVertex(endTrussPts[1].X, endTrussPts[1].Y, endTrussPts[1].Z);
                    package.AddTriangleVertex(endTrussPts[2].X, endTrussPts[2].Y, endTrussPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    endTrussPts = new Geo.Point[] { opPoint.Add(lateral).Add(normal3), opPoint.Add(lateral).Add(webAxis), opPoint.Add(lateral) };
                    package.AddTriangleVertex(endTrussPts[0].X, endTrussPts[0].Y, endTrussPts[0].Z);
                    package.AddTriangleVertex(endTrussPts[1].X, endTrussPts[1].Y, endTrussPts[1].Z);
                    package.AddTriangleVertex(endTrussPts[2].X, endTrussPts[2].Y, endTrussPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexNormal(lateral.X, lateral.Y, lateral.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    endTrussPts = new Geo.Point[] { opPoint.Add(lateralR).Add(normal2), opPoint.Add(lateralR).Add(normal).Add(webAxis), opPoint.Add(lateralR).Add(normal) };
                    package.AddTriangleVertex(endTrussPts[0].X, endTrussPts[0].Y, endTrussPts[0].Z);
                    package.AddTriangleVertex(endTrussPts[1].X, endTrussPts[1].Y, endTrussPts[1].Z);
                    package.AddTriangleVertex(endTrussPts[2].X, endTrussPts[2].Y, endTrussPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);

                    endTrussPts = new Geo.Point[] { opPoint.Add(lateralR).Add(normal3), opPoint.Add(lateralR).Add(webAxis), opPoint.Add(lateralR) };
                    package.AddTriangleVertex(endTrussPts[0].X, endTrussPts[0].Y, endTrussPts[0].Z);
                    package.AddTriangleVertex(endTrussPts[1].X, endTrussPts[1].Y, endTrussPts[1].Z);
                    package.AddTriangleVertex(endTrussPts[2].X, endTrussPts[2].Y, endTrussPts[2].Z);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexColor(r, g, b, a);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexNormal(lateralR.X, lateralR.Y, lateralR.Z);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    package.AddTriangleVertexUV(0, 0);
                    break;

                default:
                    package.AddPointVertex(opPoint.X, opPoint.Y, opPoint.Z);
                    package.AddPointVertexColor(r, g, b, a);
                    break;
                }
            }
        }