当前位置: 首页>>代码示例>>C#>>正文


C# MeshBuilder.AddTube方法代码示例

本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddTube方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddTube方法的具体用法?C# MeshBuilder.AddTube怎么用?C# MeshBuilder.AddTube使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HelixToolkit.Wpf.MeshBuilder的用法示例。


在下文中一共展示了MeshBuilder.AddTube方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Tessellate

        /// <summary>
        /// Do the tessellation and return the <see cref="MeshGeometry3D"/> .
        /// </summary>
        /// <returns>
        /// A triangular mesh geometry.
        /// </returns>
        protected override MeshGeometry3D Tessellate()
        {
            if (this.Path == null || this.Path.Count < 2)
            {
                return null;
            }

            // See also "The GLE Tubing and Extrusion Library":
            // http://linas.org/gle/
            // http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=18864
            var builder = new MeshBuilder(false, this.TextureCoordinates != null);

            var sectionXAxis = this.SectionXAxis;
            if (sectionXAxis.Length < 1e-6)
            {
                sectionXAxis = new Vector3D(1, 0, 0);
            }

            var forward = this.Path[1] - this.Path[0];
            var up = Vector3D.CrossProduct(forward, sectionXAxis);
            if (up.LengthSquared < 1e-6)
            {
                sectionXAxis = forward.FindAnyPerpendicular();
            }

            builder.AddTube(
                this.Path,
                this.Angles,
                this.TextureCoordinates,
                this.Diameters,
                this.Section,
                sectionXAxis,
                this.IsPathClosed,
                this.IsSectionClosed);

            // Add Caps if wanted and needed
            if (this.AddCaps && !this.IsPathClosed && builder.Positions.Count >= Section.Count)
            {
                var sCount = Section.Count;
                var normals = new Vector3D[sCount];
                var vertices = new Point3D[sCount];
                var pCount = Path.Count;

                //Add back cap
                var circleBack = builder.Positions.Skip(builder.Positions.Count - sCount).Take(sCount).ToArray();
                var normal = Path[pCount - 1] - Path[pCount - 2];
                normal.Normalize();
                for (int i = 0; i < normals.Length; ++i)
                {
                    normals[i] = normal;
                }
                builder.AddTriangleFan(circleBack, normals);
                //Add front cap
                var circleFront = builder.Positions.Take(sCount).ToArray();
                normal = Path[0] - Path[1];
                normal.Normalize();

                for (int i = 0; i < normals.Length; ++i)
                {
                    normals[i] = normal;
                }
                builder.AddTriangleFan(circleFront, normals);
            }

            return builder.ToMesh();
        }
开发者ID:helix-toolkit,项目名称:helix-toolkit,代码行数:72,代码来源:TubeVisual3D.cs

示例2: CreateModel

        private void CreateModel()
        {
            const double dt = 0.1;
            const int nSteps = 100;
            var mb = new MeshBuilder(true, true);
            for (double y0 = -5; y0 <= 5; y0 += 0.25)
            {
                var p0 = new Point(-3, y0);
                Point[] pts = Solve(Velocity, p0, dt, nSteps);
                var vel = new double[pts.Length];
                var diam = new double[pts.Length];
                int i = 0;
                var pts3d = new Point3D[pts.Length];
                double vmax = 0;
                foreach (Point pt in pts)
                {
                    pts3d[i] = new Point3D(pt.X, pt.Y, 0);
                    double v = Velocity(pt.X, pt.Y).Length;
                    if (v > vmax) vmax = v;
                    vel[i++] = v;
                }
                for (int j = 0; j < vel.Length; j++)
                    vel[j] /= vmax;
                for (int j = 0; j < vel.Length; j++)
                    diam[j] = 0.075;

                mb.AddTube(pts3d, vel, diam, 12, false);
            }

            this.StreamLinesModel = new GeometryModel3D();
            this.StreamLinesModel.Geometry = mb.ToMesh();
            this.StreamLinesModel.Material = Materials.Hue;
            this.StreamLinesModel.BackMaterial = Materials.Hue;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:34,代码来源:MainWindow.xaml.cs

示例3: AddTube

        void AddTube(List<Point3D> path, Color color)
        {
            var mb = new MeshBuilder();

            mb.AddTube(path, 0.1, 3, false);
            var geom = new GeometryModel3D { Geometry = mb.ToMesh(true), Material = MaterialHelper.CreateMaterial(color) };          // create a model
            var model = new ModelVisual3D();
            model.Content = geom;
            _Helix.Children.Add(model);
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:10,代码来源:MainWindow.xaml.cs

示例4: TubeSegment

        public TubeSegment(Point3D startPoint, Point3D endPoint, double d1, double d2)
        {
            var meshBuilder = new MeshBuilder(false, false);

            var h1 = 0.1*d1;
            var h2 = 0.1*d2;

            var deltaStart = GeometryHelper.GetDeltaPoint(startPoint, endPoint, h1);
            var deltaEnd = GeometryHelper.GetDeltaPoint(endPoint, startPoint, h2);
            var points = new List<Point3D>() { deltaStart, deltaEnd };
            //var points = new List<Point3D>() { startPoint, endPoint };

            var dd1 = d1*0.9;
            var dd2 = d2*0.9;

            var diameters = new[] { dd1, dd2 };
            //var diameters = new[] { d1, d2 };
            meshBuilder.AddTube(points, new double[] { 0, 0 }, diameters, 10, false);

            Model = meshBuilder.ToMesh();
        }
开发者ID:rsemenov,项目名称:cave,代码行数:21,代码来源:TubeSegment.cs

示例5: CreateOriginTube

        /// <summary>
        /// Place a tube down the center of the plot
        /// so all the arrows will connect to a center point (origin).
        /// </summary>
        /// <param name="numBins">Number of bins in the plot.</param>
        /// <returns>3D model of the center tube.</returns>
        private GeometryModel3D CreateOriginTube(int numBins)
        {
            double tubeDia = ARROW_HEAD_SIZE;       // Tube Diameter.  Same as Arrows.      Min = 0.1 Max = 1.0
            int tubeTheta = 30;                     // Tube ThetaDiv.                       Min = 3 Max = 100

            double xAxisLoc = 0;
            double yAxisLoc = 0;
            double zAxisLoc = 0;

            if (YAxis)
            {
                yAxisLoc = -numBins * TRANSLATION_SCALE;
            }
            else
            {
                xAxisLoc = numBins * TRANSLATION_SCALE;
            }

            // Create 2 points, the top and bottom
            List<Point3D> pts = new List<Point3D>();
            pts.Add(new Point3D(0, 0, 0));
            pts.Add(new Point3D(xAxisLoc, yAxisLoc, zAxisLoc));

            // Create the tube based off the points
            var mb = new MeshBuilder(false, false);
            mb.AddTube(pts, tubeDia, tubeTheta, true);
            Geometry3D geometry = mb.ToMesh();

            // Set the color
            Material material = MaterialHelper.CreateMaterial(Color.FromArgb(255, 255,250,213));
            material.Freeze();

            var model = new GeometryModel3D(geometry, material);

            return model;
        }
开发者ID:rowetechinc,项目名称:AverageWaterColumn,代码行数:42,代码来源:BinPlot3D.cs

示例6: CreateModel

        private Model3D CreateModel()
        {
            var plotModel = new Model3DGroup();

            int rows = Points.GetUpperBound(0) + 1;
            int columns = Points.GetUpperBound(1) + 1;
            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;
            double minZ = double.MaxValue;
            double maxZ = double.MinValue;
            double minColorValue = double.MaxValue;
            double maxColorValue = double.MinValue;
            for (int i = 0; i < rows; i++)
                for (int j = 0; j < columns; j++)
                {
                    double x = Points[i, j].X;
                    double y = Points[i, j].Y;
                    double z = Points[i, j].Z;
                    maxX = Math.Max(maxX, x);
                    maxY = Math.Max(maxY, y);
                    maxZ = Math.Max(maxZ, z);
                    minX = Math.Min(minX, x);
                    minY = Math.Min(minY, y);
                    minZ = Math.Min(minZ, z);
                    if (ColorValues != null)
                    {
                        maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]);
                        minColorValue = Math.Min(minColorValue, ColorValues[i, j]);
                    }
                }

            // make color value 0 at texture coordinate 0.5
            if (Math.Abs(minColorValue) < Math.Abs(maxColorValue))
                minColorValue = -maxColorValue;
            else
                maxColorValue = -minColorValue;

            // set the texture coordinates by z-value or ColorValue
            var texcoords = new Point[rows,columns];
            for (int i = 0; i < rows; i++)
                for (int j = 0; j < columns; j++)
                {
                    double u = (Points[i, j].Z - minZ)/(maxZ - minZ);
                    if (ColorValues != null)
                        u = (ColorValues[i, j] - minColorValue)/(maxColorValue - minColorValue);
                    texcoords[i, j] = new Point(u, u);
                }

            var surfaceMeshBuilder = new MeshBuilder();
            surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);

            var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
                                                   MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
            surfaceModel.BackMaterial = surfaceModel.Material;

            var axesMeshBuilder = new MeshBuilder();
            for (double x = minX; x <= maxX; x += IntervalX)
            {
                double j = (x - minX)/(maxX - minX)*(columns - 1);
                var path = new List<Point3D> {new Point3D(x, minY, minZ)};
                for (int i = 0; i < rows; i++)
                {
                    path.Add(BilinearInterpolation(Points, i, j));
                }
                path.Add(new Point3D(x, maxY, minZ));

                axesMeshBuilder.AddTube(path, LineThickness, 9, false);
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize,
                                                                           new Point3D(x, minY - FontSize*2.5, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize,
                                                                           new Point3D((minX + maxX)*0.5,
                                                                                       minY - FontSize*6, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            for (double y = minY; y <= maxY; y += IntervalY)
            {
                double i = (y - minY)/(maxY - minY)*(rows - 1);
                var path = new List<Point3D> {new Point3D(minX, y, minZ)};
                for (int j = 0; j < columns; j++)
                {
                    path.Add(BilinearInterpolation(Points, i, j));
                }
                path.Add(new Point3D(maxX, y, minZ));

                axesMeshBuilder.AddTube(path, LineThickness, 9, false);
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize,
                                                                           new Point3D(minX - FontSize*3, y, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }
            {
//.........这里部分代码省略.........
开发者ID:BEEden,项目名称:Diplomarbeit,代码行数:101,代码来源:SurfacePlotVisual3D.cs

示例7: BuildRailing

        private static void BuildRailing(
            MeshBuilder railingBuilder,
            List<Point3D> bases,
            double height,
            double diameter,
            int railings)
        {
            foreach (var point in bases)
            {
                railingBuilder.AddCylinder(point, point + new Vector3D(0, 0, height), diameter, 10);
            }

            for (int i = 1; i <= railings; i++)
            {
                var h = height * i / railings;
                var path = bases.Select(p => p + new Vector3D(0, 0, h)).ToArray();
                railingBuilder.AddTube(path, diameter, 10, false);
            }
        }
开发者ID:JeremyAnsel,项目名称:helix-toolkit,代码行数:19,代码来源:SiloVisual3D.cs

示例8: SetToVisual

        /// <summary>
        /// Creates a rather ugly visual representatino of the polyline.
        /// Fixed in size with respect to the model.
        /// </summary>
        /// <param name="highlighted">The destination visual component to replace the content of.</param>
        internal void SetToVisual(MeshVisual3D highlighted)
        {
            if (_geomPoints == null)
                return;

            var lines = new LinesVisual3D { Color = Colors.Yellow };
            var axesMeshBuilder = new MeshBuilder();

            List<Point3D> path = new List<Point3D>();
            foreach (var item in _geomPoints)
            {
                axesMeshBuilder.AddSphere(item.Point, 0.1);
                path.Add(item.Point);
            }
            if (_geomPoints.Count > 1)
            {
                double lineThickness = 0.05;
                axesMeshBuilder.AddTube(path, lineThickness, 9, false);
            }
            highlighted.Content = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow);
        }
开发者ID:tnesser,项目名称:XbimWindowsUI,代码行数:26,代码来源:PolylineGeomInfo.cs

示例9: AppearanceChanged

        private void AppearanceChanged()
        {
            var builder = new MeshBuilder(false, true);

            // hard code a kerb section
            var section = new PointCollection();
            int m = 41;
            double n = 4;
            double a = this.Width / 2;
            double b = this.Height;
            for (int i = 0; i < m; i++)
            {
                double t = Math.PI * i / (m - 1);
                section.Add(new Point(
                    a * Math.Sign(Math.Cos(t)) * Math.Pow(Math.Abs(Math.Cos(t)), 2 / n),
                    -b * Math.Sign(Math.Sin(t)) * Math.Pow(Math.Abs(Math.Sin(t)), 2 / n)));
            }

            // calculate the texture coordinates
            var values = new List<double> { 0 };
            for (int i = 1; i < this.Positions.Count; i++)
            {
                var d = this.Positions[i - 1].DistanceTo(this.Positions[i]);
                values.Add(values[values.Count - 1] + (d / this.Length));
            }

            // create the extruded geometry
            builder.AddTube(this.Positions, null, values, null, section, new Vector3D(1, 0, 0), false, false);

            this.kerbModel.Geometry = builder.ToMesh();
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:31,代码来源:KerbVisual3D.cs

示例10: CreateModel

        private Model3D CreateModel()
        {
            if (Points == null || Points.Length == 0) return null;


            var plotModel = new Model3DGroup();

            int rows = Points.GetUpperBound(0) + 1;
            int columns = Points.GetUpperBound(1) + 1;
            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;
            double minZ = double.MaxValue;
            double maxZ = double.MinValue;
            double minColorValue = double.MaxValue;
            double maxColorValue = double.MinValue;
            minX = Points.OfType<Point3D>().Min(x => x.X);
            maxX = Points.OfType<Point3D>().Max(x => x.X);
            minY = Points.OfType<Point3D>().Min(x => x.Y);
            maxY = Points.OfType<Point3D>().Max(x => x.Y);
            minZ = Points.OfType<Point3D>().Min(x => x.Z);
            maxZ = Points.OfType<Point3D>().Max(x => x.Z);
            if (ColorValues != null) minColorValue = ColorValues.OfType<double>().Min(x => x);
            if (ColorValues != null) maxColorValue = ColorValues.OfType<double>().Max(x => x);

            if (Functions.Abs(minColorValue) < Functions.Abs(maxColorValue))
                minColorValue = -maxColorValue;
            else
                maxColorValue = -minColorValue;

            BitmapPixelMaker bm_maker =
                new BitmapPixelMaker(columns, rows);

            for (int ix = 0; ix < columns; ix++)
            {
                for (int iy = 0; iy < rows; iy++)
                {
                    try
                    {
                        byte red, green, blue;
                        MapRainbowColor(Points[ix, iy].Z, minZ, maxZ,
                            out red, out green, out blue);
                        bm_maker.SetPixel(ix, iy, red, green, blue, 255);
                    }
                    catch
                    {

                    }
                }
            }

            var texcoords = new Point[rows, columns];
            for (int i = 0; i < rows; i++)
                for (int j = 0; j < columns; j++)
                {
                    texcoords[i, j] = new Point(i, j);
                }

            var surfaceMeshBuilder = new MeshBuilder();
            surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
            var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
                MaterialHelper.CreateMaterial(new ImageBrush(bm_maker.MakeBitmap(128, 128)), null, null, 1, 0));
            surfaceModel.BackMaterial = surfaceModel.Material;

            var axesMeshBuilder = new MeshBuilder();
            for (double x = minX; x <= maxX; x += IntervalX)
            {
                double j = (x - minX) / (maxX - minX) * (columns - 1);
                var path = new List<Point3D> {new Point3D(x, minY, minZ)};
                for (int i = 0; i < rows; i++)
                {
                    path.Add(BilinearInterpolation(Points, i, j));
                }
                path.Add(new Point3D(x, maxY, minZ));

                axesMeshBuilder.AddTube(path, LineThickness, 9, false);
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true,
                    FontSize * 3,
                    new Point3D(x, minY - FontSize * 2.5, minZ),
                    new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe réel", Brushes.Black, true,
                    FontSize * 10,
                    new Point3D((minX + maxX) * 0.25,
                        minY - FontSize * 6 - 0.5, minZ),
                    new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }
            for (double y = minY; y <= maxY; y += IntervalY)
            {
                double i = (y - minY) / (maxY - minY) * (rows - 1);
                var path = new List<Point3D> {new Point3D(minX, y, minZ)};
                for (int j = 0; j < columns; j++)
                {
                    path.Add(BilinearInterpolation(Points, i, j));
                }
                path.Add(new Point3D(maxX, y, minZ));
//.........这里部分代码省略.........
开发者ID:zdimension,项目名称:IMPression,代码行数:101,代码来源:GraphComplex3DWindow.xaml.cs

示例11: CreateModel

        /// <summary>
        /// This function contains all the "business logic" for constructing a SurfacePlot 3D. 
        /// </summary>
        /// <returns>A Model3DGroup containing all the component models (mesh, surface definition, grid objects, etc).</returns>
        private Model3DGroup CreateModel()
        {
            var newModelGroup = new Model3DGroup();
            double lineThickness = 0.01;
            double axesOffset = 0.05;

            // Get relevant constaints from the DataPoints object
            int numberOfRows = DataPoints.GetUpperBound(0) + 1;
            int numberOfColumns = DataPoints.GetUpperBound(1) + 1;

            // Determine the x, y, and z ranges of the DataPoints collection
            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;
            double minZ = double.MaxValue;
            double maxZ = double.MinValue;

            double minColorValue = double.MaxValue;
            double maxColorValue = double.MinValue;

            for (int i = 0; i < numberOfRows; i++)
            {
                for (int j = 0; j < numberOfColumns; j++)
                {
                    double x = DataPoints[i, j].X;
                    double y = DataPoints[i, j].Y;
                    double z = DataPoints[i, j].Z;
                    maxX = Math.Max(maxX, x);
                    maxY = Math.Max(maxY, y);
                    maxZ = Math.Max(maxZ, z);
                    minX = Math.Min(minX, x);
                    minY = Math.Min(minY, y);
                    minZ = Math.Min(minZ, z);
                    if (ColorValues != null)
                    {
                        maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]);
                        minColorValue = Math.Min(minColorValue, ColorValues[i, j]);
                    }
                }
            }

            /* TEMP */
            int numberOfXAxisTicks = 10;
            int numberOfYAxisTicks = 10;
            int numberOfZAxisTicks = 5;
            double XAxisInterval = (maxX - minX) / numberOfXAxisTicks;
            double YAxisInterval = (maxY - minY) / numberOfYAxisTicks;
            double ZAxisInterval = (maxZ - minZ) / numberOfZAxisTicks;
            /* /TEMP */

            // Set color value to 0 at texture coordinate 0.5, with an even spread in either direction
            if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; }
            else                                                   { maxColorValue = -minColorValue; }

            // Set the texture coordinates by either z-value or ColorValue
            var textureCoordinates = new Point[numberOfRows, numberOfColumns];
            for (int i = 0; i < numberOfRows; i++)
            {
                for (int j = 0; j < numberOfColumns; j++)
                {
                    double tc;
                    if (ColorValues != null) { tc = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); }
                    else                     { tc = (DataPoints[i, j].Z - minZ) / (maxZ - minZ); }
                    textureCoordinates[i, j] = new Point(tc, tc);
                }
            }

            // Build the surface model (i.e. the coloured surface model)
            MeshBuilder surfaceModelBuilder = new MeshBuilder();
            surfaceModelBuilder.AddRectangularMesh(DataPoints, textureCoordinates);

            GeometryModel3D surfaceModel = new GeometryModel3D(surfaceModelBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
            surfaceModel.BackMaterial = surfaceModel.Material;

            // Instantiate MeshBuilder objects for the Grid and SurfaceMeshLines meshes
            MeshBuilder surfaceMeshLinesBuilder = new MeshBuilder();
            MeshBuilder surfaceContourLinesBuilder = new MeshBuilder();
            MeshBuilder gridBuilder = new MeshBuilder();

            // Build the axes labels model (i.e. the object that holds the axes labels and ticks)
            ModelVisual3D axesLabelsModel = new ModelVisual3D();

            // Loop through x intervals - for the surface meshlines, the grid, and X axes ticks
            for (double x = minX; x <= maxX + 0.0001; x += XAxisInterval)
            {
                // Add surface mesh lines which denote intervals along the x-axis
                var surfacePath = new List<Point3D>();
                double i = (x - minX) / (maxX - minX) * (numberOfColumns - 1);
                for (int j = 0; j < numberOfColumns; j++)
                {
                    surfacePath.Add(DoBilinearInterpolation(DataPoints, i, j));
                }
                surfaceMeshLinesBuilder.AddTube(surfacePath, lineThickness, 9, false);

                // Axes labels
//.........这里部分代码省略.........
开发者ID:brittanywelsh,项目名称:wpf-surfaceplot3d,代码行数:101,代码来源:SurfacePlotVisual3D.cs

示例12: CreateSolutionGeometry

        /// <summary>
        /// The create solution geometry.
        /// </summary>
        /// <param name="solution">The solution.</param>
        /// <param name="height">The height.</param>
        /// <param name="diameter">The diameter.</param>
        /// <returns>The solution tube geometry.</returns>
        private MeshGeometry3D CreateSolutionGeometry(IEnumerable<Cell> solution, double height = 0.25, double diameter = 0.25)
        {
            var builder = new MeshBuilder();
            var path = solution.Select(cell => this.GetPosition(cell, height)).ToList();

            var spline = CanonicalSplineHelper.CreateSpline(path, 0.7, null, false, 0.05);
            builder.AddTube(spline, diameter, 13, false);
            return builder.ToMesh();
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:16,代码来源:MainViewModel.cs

示例13: Tessellate

        /// <summary>
        /// Do the tessellation and return the <see cref="MeshGeometry3D"/> .
        /// </summary>
        /// <returns>
        /// A triangular mesh geometry.
        /// </returns>
        protected override MeshGeometry3D Tessellate()
        {
            if (this.Path == null || this.Path.Count < 2)
            {
                return null;
            }

            // See also "The GLE Tubing and Extrusion Library":
            // http://linas.org/gle/
            // http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=18864
            var builder = new MeshBuilder(false, this.TextureCoordinates != null);

            var sectionXAxis = this.SectionXAxis;
            if (sectionXAxis.Length < 1e-6)
            {
                sectionXAxis = new Vector3D(1, 0, 0);
            }

            var forward = this.Path[1] - this.Path[0];
            var up = Vector3D.CrossProduct(forward, sectionXAxis);
            if (up.LengthSquared < 1e-6)
            {
                sectionXAxis = forward.FindAnyPerpendicular();
            }

            builder.AddTube(
                this.Path,
                this.Angles,
                this.TextureCoordinates,
                this.Diameters,
                this.Section,
                sectionXAxis,
                this.IsPathClosed,
                this.IsSectionClosed);
            return builder.ToMesh();
        }
开发者ID:ondrej11,项目名称:o106,代码行数:42,代码来源:ExtrudedVisual3D.cs

示例14: UpdateModel

        private void UpdateModel()
        {
            // http://en.wikipedia.org/wiki/Lorenz_attractor
            Func<double[], double[]> lorenzAttractor = x =>
                                                           {
                                                               var dx = new double[3];
                                                               dx[0] = sigma * (x[1] - x[0]);
                                                               dx[1] = x[0] * (rho - x[2]) - x[1];
                                                               dx[2] = x[0] * x[1] - beta * x[2];
                                                               return dx;
                                                           };
            // solve the ODE
            var x0 = new[] { 0, 1, 1.05 };
            IEnumerable<double[]> solution = EulerSolver(lorenzAttractor, x0, 25);
            // todo: should have a better ODE solver (R-K(4,5)? http://www.mathworks.com/help/techdoc/ref/ode45.html)
            List<Point3D> path = solution.Select(x => new Point3D(x[0], x[1], x[2])).ToList();

            // create the WPF3D model
            var m = new Model3DGroup();
            var gm = new MeshBuilder();
            gm.AddTube(path, 0.8, 10, false);
            if (directionArrows)
            {
                // sphere at the initial point
                gm.AddSphere(path[0], 1);
                // arrow heads every 100 point
                for (int i = 100; i + 1 < path.Count; i += 100)
                {
                    gm.AddArrow(path[i], path[i + 1], 0.8);
                }
                // arrow head at the end
                Point3D p0 = path[path.Count - 2];
                Point3D p1 = path[path.Count - 1];
                var d = new Vector3D(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
                d.Normalize();
                Point3D p2 = p1 + d * 2;
                gm.AddArrow(p1, p2, 0.8);
            }

            m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold));

            Model = m;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:43,代码来源:MainViewModel.cs

示例15: CreateModel


//.........这里部分代码省略.........
            //RealmaxY = maxY;
            //RealminY = minY;
            //RealmaxZ = maxZ;
            //RealminZ = minZ;
            maxX *= ScaleX;
            minX *= ScaleX;
            maxY *= ScaleY;
            minY *= ScaleY;
            maxZ *= ScaleZ;
            minZ *= ScaleZ;

            IntervalX = (maxX - minX) / SubAxisCount;
            IntervalY = (maxY - minY) / SubAxisCount;
            IntervalZ = (maxZ - minZ) / SubAxisCount;
            
            #region eje x

            var axesMeshBuilder = new MeshBuilder();
            for (double x = minX; x <= maxX; x += IntervalX)
            {
                double j = (x - minX)/(maxX - minX)*(columns - 1);
                //var path = new List<Point3D> { new Point3D(x , minY , minZ) };
                var path = new List<Point3D> { new Point3D(x, minY , minZ) };
                for (int i = 0; i < rows; i++)
                {
                    Point3D p = BilinearInterpolation(Points, i, j);
                    p.X *= ScaleX;
                    p.Y *= ScaleY;
                    p.Z *= ScaleZ;
                    path.Add(p);
                }
                path.Add(new Point3D(x, maxY, minZ));

                axesMeshBuilder.AddTube(path, LineThickness, 9, false);
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(x / ScaleX), Brushes.Black, true, FontSize,
                                                                           new Point3D(x, minY - FontSize * 2.5, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize,
                                                                           new Point3D((minX + maxX)*0.5,
                                                                                       minY - FontSize * 6, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            #endregion


            #region eje y

            for (double y = minY; y <= maxY; y += IntervalY)
            {
                double i = (y - minY)/(maxY - minY)*(rows - 1);
                var path = new List<Point3D> {new Point3D(minX, y, minZ)};
                for (int j = 0; j < columns; j++)
                {
                    Point3D p = BilinearInterpolation(Points, i, j);
                    p.X *= ScaleX;
                    p.Y *= ScaleY;
                    p.Z *= ScaleZ;
                    path.Add(p);
                }
                path.Add(new Point3D(maxX, y, minZ));
开发者ID:gaesquivel,项目名称:Simulador-de-Circuitos,代码行数:67,代码来源:SurfacePlotVisual3D.cs


注:本文中的HelixToolkit.Wpf.MeshBuilder.AddTube方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。