示例#1
0
        /// <summary>
        /// Convert to <see cref="Point3D"/> from a <see cref="Bspline.Core.Location.Point3D"/> using a offset
        /// </summary>
        /// <param name="source"></param>
        /// <param name="width">conversion width</param>
        /// <param name="height">conversion height</param>
        /// <returns></returns>
        internal static Point3D To3DPoint(this Bspline.Core.Location.Point3D source, double width, double height)
        {
            Point3D result = new Point3D();

            result.X = ((2 * source.X) / width) - 1;
            result.Y = ((2 * source.Y) / height) - 1;
            result.Z = source.Z;
            return(result);
        }
示例#2
0
 /// <summary>
 /// Convert to <see cref="Point"/> from a <see cref="Bspline.Core.Location.Point3D"/>
 /// </summary>
 /// <param name="source">the point to convert</param>
 /// <returns></returns>
 internal static Point To2DPoint(this Bspline.Core.Location.Point3D source)
 {
     return(new Point(source.X, source.Y));
 }
示例#3
0
 /// <summary>
 /// Convert to <see cref="Point"/> from a <see cref="Bspline.Core.Location.Point3D"/> using a offset
 /// </summary>
 /// <param name="source">the source point</param>
 /// <param name="offX">x offset</param>
 /// <param name="offY">y offset</param>
 /// <returns></returns>
 internal static Point To2DPoint(this Bspline.Core.Location.Point3D source, int offX, int offY)
 {
     return(new Point(source.X + offX, source.Y + offY));
 }
        /// <summary>
        /// <see cref="RendererBase"/>
        /// </summary>
        protected override void RenderOverride()
        {
            this.Main.Paint3D.Visibility = Visibility.Visible;
            this.Main.Paint3D.MouseDown += PointMouseLeftButtonDown;
            this.Main.Paint3D.MouseMove += PointMouseMove;
            this.Main.Paint3D.MouseUp   += PointMouseLeftButtonUp;

            // Define 3D mesh object
            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int j = 0; j < this.AlgInfoResult.KMatrix.Columns; j++)
            {
                this.AlgInfoResult.KMatrix[0, j].Z = 1;
                this.AlgInfoResult.KMatrix[1, j].Z = 0.3;
                this.AlgInfoResult.KMatrix[2, j].Z = -0.3;
                this.AlgInfoResult.KMatrix[3, j].Z = -1;
            }


            for (int i = 0; i < this.AlgInfoResult.KMatrix.Columns; i++)
            {
                for (int j = 0; j < this.AlgInfoResult.KMatrix.Rows; j++)
                {
                    Point3D point = this.AlgInfoResult.KMatrix[j, i];
                    mesh.Positions.Add(point.To3DPoint(this.WidthFactor, this.HeightFactor));

                    //mesh.Normals.Add( new Vector3D( 0, 0, 1 ) );
                }
            }
            for (int i = 0; i < mesh.Positions.Count; i += 4)
            {
                mesh.TriangleIndices.Add(i);
                mesh.TriangleIndices.Add(i + 1);
                mesh.TriangleIndices.Add(i + 4);

                mesh.TriangleIndices.Add(i + 1);
                mesh.TriangleIndices.Add(i + 5);
                mesh.TriangleIndices.Add(i + 4);

                mesh.TriangleIndices.Add(i + 1);
                mesh.TriangleIndices.Add(i + 2);
                mesh.TriangleIndices.Add(i + 5);

                mesh.TriangleIndices.Add(i + 2);
                mesh.TriangleIndices.Add(i + 6);
                mesh.TriangleIndices.Add(i + 5);

                mesh.TriangleIndices.Add(i + 2);
                mesh.TriangleIndices.Add(i + 3);
                mesh.TriangleIndices.Add(i + 6);

                mesh.TriangleIndices.Add(i + 3);
                mesh.TriangleIndices.Add(i + 7);
                mesh.TriangleIndices.Add(i + 6);
            }


            _geometry = new GeometryModel3D(mesh, new DiffuseMaterial(Brushes.YellowGreen));

            _geometry.Transform = new Transform3DGroup();
            this.Main.Group.Children.Add(_geometry);
        }