コード例 #1
0
        public static PointProbeViewModel Create(IMachineElementViewModel parent, Point3D point, double radius = 5.0)
        {
            var t = parent.GetChainTansform();
            var p = t.Inverse.Transform(point);
            //var builder = new MeshBuilder();

            //builder.AddSphere(p, radius);

            //var vm = new PointProbeViewModel()
            //{
            //    X = p.X,
            //    Y = p.Y,
            //    Z = p.Z,
            //    Radius = radius,
            //    Parent = parent,
            //    MeshGeometry = builder.ToMesh(),
            //    Fill = Brushes.Yellow
            //};

            //vm._onIsSelectedChanged = (b) => vm.Fill = b ? Brushes.Red : Brushes.Yellow;
            //vm.PropertyChanged += (s, e) => vm.OnPropertyChanged(s, e);

            //return vm;
            //return null;

            var probe = new PointProbeViewModel()
            {
                Parent   = parent,
                Geometry = ProbesHelper.GetProbePointModel(p, radius),
                Material = PhongMaterials.Yellow,
                Visible  = true,
                X        = p.X,
                Y        = p.Y,
                Z        = p.Z
            };

            probe.Name = $"Probe point {probe.Id}";

            return(probe);
        }
コード例 #2
0
        public static PointsDistanceViewModel Create(PointProbeViewModel vm1, PointProbeViewModel vm2)
        {
            var p1  = new Point3D(vm1.X, vm1.Y, vm1.Z);
            var p2  = new Point3D(vm2.X, vm2.Y, vm2.Z);
            var t1  = vm1.GetChainTansform();
            var t2  = vm2.GetChainTansform();
            var pp2 = t1.Inverse.Transform(t2.Transform(p2));
            var p12 = pp2 - p1;

            var points = new Point3D[]
            {
                p1,
                p1 + new Vector3D(p12.X, 0.0, 0.0),
                p1 + new Vector3D(p12.X, p12.Y, 0.0),
                pp2
            };

            var pdvm = new PointsDistanceViewModel()
            {
                X = p12.X,
                Y = p12.Y,
                Z = p12.Z,
                //_vm1 = vm1,
                //_vm2 = vm2,
                Parent     = vm1,
                Visible    = true,
                Geometry   = ProbesHelper.GetProbeDistanceModel(points),
                Thickness  = 1.0,
                Smoothness = 1.0,
                Color      = Colors.Yellow
            };

            pdvm.Name = $"Probe distance {pdvm.Id}";

            return(pdvm);
        }