Пример #1
0
        private void ProcessFilename(string filename)
        {
            IsValidModel  = false;
            IsValidEntity = false;
            IsBusy        = true;

            OriginalModelSize = new BindableSize3DModel(0, 0, 0);
            NewModelSize      = new BindableSize3DIModel(0, 0, 0);
            Position          = new BindablePoint3DModel(0, 0, 0);

            if (File.Exists(filename))
            {
                // validate file is a real model.
                // read model properties.
                Model3D model;
                _originalBounds = Modelling.PreviewModelVolmetic(filename, out model);

                if (!_originalBounds.IsEmpty && _originalBounds.SizeX != 0 && _originalBounds.SizeY != 0 && _originalBounds.SizeZ != 0)
                {
                    Model = model;
                    var rotateTransform = MeshHelper.TransformVector(new System.Windows.Media.Media3D.Vector3D(0, 0, 0), -RotateRoll, RotateYaw - 90, RotatePitch + 90);
                    var bounds          = _originalBounds;
                    if (rotateTransform != null)
                    {
                        bounds = rotateTransform.TransformBounds(bounds);
                    }

                    OriginalModelSize = new BindableSize3DModel(bounds);
                    IsValidModel      = true;
                    ProcessModelScale();
                }
            }

            IsBusy = false;
        }
Пример #2
0
        private void ProcessModelScale()
        {
            if (IsValidModel)
            {
                var rotateTransform = MeshHelper.TransformVector(new System.Windows.Media.Media3D.Vector3D(0, 0, 0), -RotateRoll, RotateYaw - 90, RotatePitch + 90);
                var bounds          = _originalBounds;
                if (rotateTransform != null)
                {
                    bounds = rotateTransform.TransformBounds(bounds);
                }

                var newSize = new BindableSize3DModel(bounds);

                if (IsMaxLengthScale)
                {
                    var factor = MaxLengthScale / Math.Max(Math.Max(newSize.Height, newSize.Width), newSize.Depth);

                    NewModelSize.Height = (int)(factor * newSize.Height);
                    NewModelSize.Width  = (int)(factor * newSize.Width);
                    NewModelSize.Depth  = (int)(factor * newSize.Depth);
                }
                else if (IsMultipleScale)
                {
                    NewModelSize.Height = (int)(MultipleScale * newSize.Height);
                    NewModelSize.Width  = (int)(MultipleScale * newSize.Width);
                    NewModelSize.Depth  = (int)(MultipleScale * newSize.Depth);
                }

                NewModelScale = new BindablePoint3DModel(NewModelSize.Width, NewModelSize.Height, NewModelSize.Depth);
            }
        }
        private void ProcessFilename(string filename)
        {
            IsValidModel = false;
            IsBusy       = true;

            OriginalModelSize = new BindableSize3DModel(0, 0, 0);
            NewModelSize      = new BindableSize3DIModel(0, 0, 0);
            Position          = new BindablePoint3DModel(0, 0, 0);

            if (File.Exists(filename))
            {
                // validate file is a real model.
                // read model properties.
                Model3D model;
                var     bounds = Modelling.PreviewModelVolmetic(filename, out model);
                var     size   = new BindableSize3DModel(bounds);
                Model = model;

                if (size != null && size.Height != 0 && size.Width != 0 && size.Depth != 0)
                {
                    OriginalModelSize = size;
                    BuildDistance     = 10;
                    IsValidModel      = true;
                    ProcessModelScale();
                }
            }

            IsBusy = false;
        }