AddRevolvedGeometry() public method

Adds a surface of revolution.
See http://en.wikipedia.org/wiki/Surface_of_revolution.
public AddRevolvedGeometry ( IList points, System.Windows.Media.Media3D.Point3D origin, System.Windows.Media.Media3D.Vector3D direction, int thetaDiv ) : void
points IList /// The points (x coordinates are radius, y coordinates are distance from the origin along the axis of revolution) ///
origin System.Windows.Media.Media3D.Point3D /// The origin of the revolution axis. ///
direction System.Windows.Media.Media3D.Vector3D /// The direction of the revolution axis. ///
thetaDiv int /// The number of divisions around the mesh. ///
return void
示例#1
0
        public static MeshGeometry3D GetDiskMesh(Tool tool, Point3D position, Vector3D direction)
        {
            var t       = tool as DiskTool;
            var builder = new HelixToolkit.Wpf.MeshBuilder();
            var d       = Math.Abs(t.BodyThickness - t.CuttingThickness) / 2.0;
            var r1      = t.Diameter / 2.0 - t.CuttingRadialThickness;
            var profile = new Point[]
            {
                new Point(t.BodyThickness, 10.0),
                new Point(t.BodyThickness, r1),
                new Point(t.BodyThickness + d, r1),
                new Point(t.BodyThickness + d, t.Diameter / 2.0),
                new Point(-d, t.Diameter / 2.0),
                new Point(-d, r1),
                new Point(0.0, r1),
                new Point(0.0, 10.0)
            };

            builder.AddRevolvedGeometry(profile, null, position, direction, 100);

            return(builder.ToMesh());
        }
        /// <summary>
        /// The create geometry.
        /// </summary>
        private void CreateGeometry()
        {
            double r = this.Diameter / 2;
            double l = this.HeadLength * this.Diameter;

            // arrowhead
            var pc = new PointCollection { new Point(-l, r), new Point(-l, r * 2), new Point(0, 0) };

            var headBuilder = new MeshBuilder(false, false);
            headBuilder.AddRevolvedGeometry(pc, null, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), this.ThetaDiv);
            this.head = headBuilder.ToMesh();
            this.head.Freeze();

            // body
            pc = new PointCollection { new Point(0, 0), new Point(0, r), new Point(1, r) };

            var bodyBuilder = new MeshBuilder(false, false);
            bodyBuilder.AddRevolvedGeometry(pc, null, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), this.ThetaDiv);
            this.body = bodyBuilder.ToMesh();
            this.body.Freeze();
        }
示例#3
0
文件: 3DView.cs 项目: litdev1/LitDev
        /// <summary>
        /// Add a revolute geometry object.  This is a surface starting at (0,0,0) and pointing up.
        /// Its shape is defined by a set points (Y,Z) where Y is the vertical distance along the surface from 0 and Z is the radius of revolution.
        /// </summary>
        /// <param name="shapeName">The 3DView object.</param>
        /// <param name="path">A space or colon deliminated list of 2D point coordinates describing the revolute shape.</param>
        /// <param name="divisions">The radial divisions, default 10 (affects number of triangles and smoothness).</param>
        /// <param name="colour">A colour or gradient brush for the object.</param>
        /// <param name="materialType">A material for the object.
        /// The available options are:
        /// "E" Emmissive - constant brightness.
        /// "D" Diffusive - affected by lights.
        /// "S" Specular  - specular highlights.
        /// </param>
        /// <returns>The 3DView Geometry name.</returns>
        public static Primitive AddRevolute(Primitive shapeName, Primitive path, Primitive divisions, Primitive colour, Primitive materialType)
        {
            UIElement obj;

            try
            {
                if (_objectsMap.TryGetValue((string)shapeName, out obj))
                {
                    InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                    {
                        try
                        {
                            if (obj.GetType() == typeof(Viewport3D))
                            {
                                MeshBuilder builder = new MeshBuilder(true, true);
                                List<Point> points = new List<Point>();
                                string[] s = Utilities.getString(path).Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                                for (int i = 0; i < s.Length; i += 2)
                                {
                                    points.Add(new Point(Utilities.getDouble(s[i]), Utilities.getDouble(s[i + 1])));
                                }
                                int thetaDiv = divisions < 2 ? 10 : (int)divisions;
                                builder.AddRevolvedGeometry(points, new Point3D(0, 0, 0), new Vector3D(0, 1, 0), thetaDiv);
                                MeshGeometry3D mesh = builder.ToMesh();

                                Viewport3D viewport3D = (Viewport3D)obj;
                                return AddGeometry(viewport3D, mesh.Positions, mesh.TriangleIndices, mesh.Normals, mesh.TextureCoordinates, colour, materialType);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        }
                        return "";
                    });
                    return FastThread.InvokeWithReturn(ret).ToString();
                }
                else
                {
                    Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
            return "";
        }