Esempio n. 1
0
        /// <summary>
        /// Subdivide this node along the principal axis of its child objects
        /// </summary>
        public void Subdivide()
        {
            if (_Children != null && _Children.Count > 1)
            {
                double         max;
                double         min;
                CoordinateAxis largest = LargestDimension(_Children, out min, out max);

                int divisions = Math.Min(_Children.Count, Math.Min(_Tree.MaxDivisions, (int)Math.Floor(max - min / _Tree.MinCellSize) + 1));
                if (divisions > 1)
                {
                    _CellSize       = (max - min) / (divisions - 1);
                    _Origin         = min - _CellSize / 2;
                    _SplitDimension = largest;
                    _Branches       = new DDTreeNode <T> [divisions];
                    //Add all children to branches:
                    foreach (T child in _Children)
                    {
                        AddToBranch(child, false);
                    }
                    //Subdivide children:
                    for (int i = 0; i < _Branches.Length; i++)
                    {
                        DDTreeNode <T> node = _Branches[i];
                        if (node != null &&
                            node.Children.Count < Children.Count)
                        {
                            node.Subdivide();
                        }
                    }
                }
            }
        }
    public void Rebuild()
    {
        if (_axis != null)
        {
            Destroy(_axis.gameObject);
        }

        _axis = CoordinateAxis.Build(_axisLength, _threshold, _markWidth);
    }
Esempio n. 3
0
        private void BuildMesh()
        {
            this.commandObjects.GetGraphicsCommandList.Reset(commandObjects.GetCommandAllocator, null);

            var index = 0;

            this.meshes.Add(new Grid(device, commandObjects.GetGraphicsCommandList, PrimitiveTopology.LineList, 20, 40, 50.01f, Color.Black, ref index));
            this.meshes.Add(new Sphere(device, commandObjects.GetGraphicsCommandList, PrimitiveTopology.TriangleList, new Vector3(150, -150, 0), 10, 10, 10, Color.Red, ref index));
            this.meshes.AddRange(CoordinateAxis.New(device, commandObjects.GetGraphicsCommandList, PrimitiveTopology.TriangleList, ref index));

            this.commandObjects.GetGraphicsCommandList.Close();
            this.commandObjects.GetCommandQueue.ExecuteCommandList(commandObjects.GetGraphicsCommandList);
        }
Esempio n. 4
0
        /*
         * /// <summary>
         * /// Returns the minimum squared distance between two entries in the tree.
         * /// Should be overridden to deal with the specific tree type
         * /// </summary>
         * /// <param name="entryA"></param>
         * /// <param name="entryB"></param>
         * /// <returns></returns>
         * public override double MinDistanceSquaredBetween(Node entryA, Node entryB)
         * {
         *  return entryA.DistanceToSquared(entryB);
         * }
         */

        /// <summary>
        /// Get the nominal position of the specified entry in the tree the specified dimensional axis.
        /// Should be overridden to deal with the specific tree type
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public override double PositionInDimension(CoordinateAxis dimension, Node entry)
        {
            switch (dimension)
            {
            case CoordinateAxis.X:
                return(entry.Position.X);

            case CoordinateAxis.Y:
                return(entry.Position.Y);

            default:
                return(entry.Position.Z);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Find the maximum position of the specified entry in the tree in the
        /// specified axis
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public double MaxInDimension(CoordinateAxis dimension, T entry)
        {
            switch (dimension)
            {
            case CoordinateAxis.X:
                return(MaxXOf(entry));

            case CoordinateAxis.Y:
                return(MaxYOf(entry));

            default:
                return(MaxZOf(entry));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Get the position of the specified point along the specified dimension's axis
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="pt"></param>
        /// <returns></returns>
        public double PositionInDimension(CoordinateAxis dimension, Vector pt)
        {
            switch (dimension)
            {
            case CoordinateAxis.X:
                return(pt.X);

            case CoordinateAxis.Y:
                return(pt.Y);

            default:
                return(pt.Z);
            }
        }
Esempio n. 7
0
        private void DrawSignature(DrawSettings settings, CoordinateAxis axis, CoordinateSystemSignature signature)
        {
            float value  = settings.StartValue;
            float indent = settings.LineWidth / (settings.CountPoints * signature.Font.Size);

            for (int i = settings.StartPoint; i <= settings.CountPoints; i++,
                 value += (float)settings.MaxValue / (float)settings.CountPoints)
            {
                (float x, float y) = axis.SettingScale(settings.Direction.X, settings.Direction.Y, indent, i);

                graphics.DrawString(Convert.ToInt32(value).ToString(), signature.Font,
                                    signature.Brush, x + settings.Offset.X, y + settings.Offset.Y, signature.StringFormat);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Get the interval of values in the specified dimension
 /// </summary>
 /// <param name="dimension"></param>
 /// <returns></returns>
 public Interval IntervalInDimension(CoordinateAxis dimension)
 {
     if (dimension == CoordinateAxis.X)
     {
         return(X);
     }
     else if (dimension == CoordinateAxis.Y)
     {
         return(Y);
     }
     else
     {
         return(Z);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Get the maximum value in the specified dimension
 /// </summary>
 /// <param name="dimension"></param>
 /// <returns></returns>
 public double MaxInDimension(CoordinateAxis dimension)
 {
     if (dimension == CoordinateAxis.X)
     {
         return(MaxX);
     }
     else if (dimension == CoordinateAxis.Y)
     {
         return(MaxY);
     }
     else
     {
         return(MaxZ);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Get the minimum value in the specified dimension
 /// </summary>
 /// <param name="dimension"></param>
 /// <returns></returns>
 public double MinInDimension(CoordinateAxis dimension)
 {
     if (dimension == CoordinateAxis.X)
     {
         return(MinX);
     }
     else if (dimension == CoordinateAxis.Y)
     {
         return(MinY);
     }
     else
     {
         return(MinZ);
     }
 }
Esempio n. 11
0
        public void SetEntityKind(Entitykind Kind)
        {
            Entities = Kind;

            if (Entities != Entitykind.CtrlRectangle)
            {
                if (CRect != null)
                {
                    CRect.Device = null;
                }
            }
            switch (Entities)

            {
            case Entitykind.Boxentity:
            {
                Box = new BoxEntity(new xyz(0, 0, 0), new xyz(4, 5, 6));

                break;
            }

            case Entitykind.PolyCurveExtruder:
            {
                PolyCurveEx = new PolyCurveExtruder();
                Loca       _Loca   = new Loca();
                CurveArray Curves0 = new CurveArray();
                Curves0.Count = 4;
                Curves0[0]    = new Line(new xy(-3, -3), new xy(-3, 4));
                Curves0[1]    = new Line(new xy(-3, 4), new xy(4, 4));
                Curves0[2]    = new Line(new xy(4, 4), new xy(4, -3));
                Curves0[3]    = new Line(new xy(4, -3), new xy(-3, -3));

                _Loca.Add(Curves0);
                OpenGlDevice.CheckError();
                CurveArray Curves1 = new CurveArray();
                Curves1.Count = 4;
                Curves1[0]    = new Line(new xy(0, 0), new xy(1, 0));
                Curves1[1]    = new Line(new xy(1, 0), new xy(1, 1));
                Curves1[2]    = new Line(new xy(1, 1), new xy(0, 1));
                Curves1[3]    = new Line(new xy(0, 1), new xy(0, 0));
                _Loca.Add(Curves1);

                PolyCurveEx.DownPlane     = new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1));
                PolyCurveEx.UpPlane       = new Plane(new xyz(0, 0, 4), new xyz(0, 0.5, 1));
                PolyCurveEx.Loca          = _Loca;
                PolyCurveEx.ShowUpPlane   = true;
                PolyCurveEx.ShowDownPlane = true;
                PolyCurveEx.Height        = -1;
                PolyCurveEx.Direction     = new xyz(0, 1, 1);
                break;
            }

            case Entitykind.CoordinateAxis:
            {
                Axis                   = new CoordinateAxis();
                Axis.FullSize          = true;
                Axis.ShowText          = true;
                Axis.TextHeight        = 1;
                Axis.Color             = Color.Black;
                Axis.Size              = new xyz(10, 20, 30);
                Axis.Devider           = new xyz(4, 4, 4);
                Axis.DeviderLineLength = 0.3;
                Axis.LeftAndRight      = true;
                Axis.Dim3d             = true;
                Axis.ShowDevider       = true;
                break;
            }

            case Entitykind.TextEntity:
            {
                Text      = new TextEntity();
                Text.Text = "Drawing3d";

                Text.Size     = 4;
                Text.Italic   = true;
                Text.Position = new xyz(-5, 0, 0);
                break;
            }

            case Entitykind.Interpolator:

            {
                Interpolator        = new Interpolator3D();
                Interpolator.Points = new xyz[, ]
                {
                    { new xyz(-3, -3, 0), new xyz(-3, 0, 2), new xyz(-3, 3, 0), new xyz(-3, 6, -2) },
                    { new xyz(0, -3, 2), new xyz(0, 0, 3), new xyz(0, 3, 2), new xyz(0, 6, -2) },
                    { new xyz(3, -3, 3), new xyz(3, 0, 2), new xyz(3, 3, 1), new xyz(3, 6, -2) },
                    { new xyz(6, -3, 2), new xyz(6, 0, 0), new xyz(6, 3, 0), new xyz(6, 6, -2) }
                };

                break;
            };



            case Entitykind.Zoom:

            {
                Zoom        = new RectCtrlZoom(this);
                Zoom.Device = this;
                Zoom.Color  = Color.White;
                break;
            }

            case Entitykind.CtrlRectangle:

            {
                CRect               = new CtrlRectangle(this);
                CRect.Color         = Color.Black;
                CRect.MarkerColor   = Color.Red;
                CRect.Creating      = false;
                CRect.Rectangle     = new RectangleF(-1, -1, 6, 5);
                CRect.CompileEnable = false;
                Triangle            = new xyArray();
                Triangle.data       = new xy[] { new xy(0, 0), new xy(2, 2), new xy(4, 0), new xy(0, 0) };
                CRect.TransformItems.Add(Triangle);

                // S = new SphereEntity(new xyz(0, 0, 0), 2);
                //S = new BoxEntity(new xyz(0, 0, 0), new xyz(4, 4, 4));
                //S.CompileEnable = false;
                // CRect.TransformItems.Add(S);
                // CRect.LiveTransform = true;
                break;
            }

            case Entitykind.Profiler:

            {
                xyzArray A = new xyzArray();
                A.data = new xyz[] { new xyz(-3, 0, 0), new xyz(-3, -4, 0), new xyz(3, -4, 0), new xyz(3, 0, 0) };
                Loca       _Loca   = new Loca();
                CurveArray Curves0 = new CurveArray();
                Curves0.Count = 4;
                Curves0[0]    = new Line(new xy(-1, -1), new xy(-1, 2));
                Curves0[1]    = new Line(new xy(-1, 2), new xy(2, 2));
                Curves0[2]    = new Line(new xy(2, 2), new xy(2, -1));
                Curves0[3]    = new Line(new xy(2, -1), new xy(-1, -1));
                _Loca.Add(Curves0);
                OpenGlDevice.CheckError();
                CurveArray Curves1 = new CurveArray();
                Curves1.Count = 4;
                Curves1[0]    = new Line(new xy(0, 0), new xy(1, 0));
                Curves1[1]    = new Line(new xy(1, 0), new xy(1, 1));
                Curves1[2]    = new Line(new xy(1, 1), new xy(0, 1));
                Curves1[3]    = new Line(new xy(0, 1), new xy(0, 0));
                _Loca.Add(Curves1);
                Profil = new Profiler();
                Profil.CompileEnable = false;
                Profil.Trace         = A;
                Profil.Transverse    = _Loca;
                Profil.CloseFirst    = true;
                Profil.CloseLast     = true;
                break;
            }

            case Entitykind.ActiveCursor:
            {
                //  ActiveC.CrossColor = Color.Red;
                break;
            }

            case Entitykind.SphereEntity:
            {
                Sphere = new SphereEntity(new xyz(3, 2, 1), 4);
                //  Sphere.CompileEnable = false;
                //  Sphere = new SphereEntity(new xyz(0, 0, 0), 4);
                break;
            }

            case Entitykind.Cone:
            {
                Cone = new Cone(3, 5);
                break;
            }

            case Entitykind.Arrow:
            {
                Arrow = new Arrow();
                Arrow.Transformation = Matrix.Translation(new xyz(5, 0, 0));
                Arrow.SetShaftAndTop(new xyz(-10, 0, 0), new xyz(0, 0, 0));
                Arrow.Size = 8;
                drawSphere(new xyz(0, 0, 0), 0.5);
                break;
            }
            }


            Selector.RefreshSnapBuffer();
        }
Esempio n. 12
0
        /*
         * /// <summary>
         * /// Returns the minimum squared distance between two entries in the tree.
         * /// Should be overridden to deal with the specific tree type
         * /// </summary>
         * /// <param name="entryA"></param>
         * /// <param name="entryB"></param>
         * /// <returns></returns>
         * public abstract double MinDistanceSquaredBetween(T entryA, T entryB);
         */

        /// <summary>
        /// Get the nominal position of the specified entry in the tree the specified dimensional axis.
        /// Should be overridden to deal with the specific tree type
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public abstract double PositionInDimension(CoordinateAxis dimension, T entry);
Esempio n. 13
0
 public override double PositionInDimension(CoordinateAxis dimension, MeshFace entry)
 {
     return(entry.AverageDelegateValue(i => i.Position[dimension]));
 }
Esempio n. 14
0
 public override double PositionInDimension(CoordinateAxis dimension, T entry)
 {
     return(entry.Position[dimension]);
 }
Esempio n. 15
0
 /// <summary>
 /// Coordinates for movement actions
 /// </summary>
 /// <param name="axis">The correspondent axis</param>
 /// <param name="value">The value of the coordinate</param>
 public Coordinate(CoordinateAxis axis, int value)
 {
     this.Value = value;
     this.Axis = axis;
 }