Example #1
0
 public void OnDrop(object sender, DragEventArgs e)
 {
     if (!e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         return;
     }
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     if (files != null)
     {
         foreach (string file in files)
         {
             string extension = Path.GetExtension(file)?.ToLower();
             //判斷當前的檔案副檔名是否為stl,不是的話則跳過
             if (extension != null && !extension.Equals(".stl"))
             {
                 continue;
             }
             BoneModel model = new BoneModel
             {
                 FilePath         = file,
                 MarkerId         = "",
                 BoneDiffuseColor = System.Windows.Media.Color.FromArgb(255, 40, 181, 187),
                 Transform        = new MatrixTransform3D()
             };
             model.LoadModel();
             MultiAngleViewModel.NormalModelCollection.Add(model);
         }
     }
     MultiAngleViewModel.ResetCameraPosition();
 }
Example #2
0
        /// <summary>
        /// 設定好模型之後Load進去模型資料所用
        /// </summary>
        public void Load()
        {
            Bone.FilePath         = BoneFilePath;
            Bone.MarkerId         = MarkerId;
            Bone.BoneDiffuseColor = BoneDiffuseColor;

            Osp.FilePath     = OspFilePath;
            Osp.MarkerId     = MarkerId;
            Osp.DiffuseColor = OspDiffuseColor;
            if (!Osp.IsLoaded)
            {
                Osp.LoadOsp();
            }

            if (!Bone.IsLoaded)
            {
                Bone.LoadModel();
            }
        }
Example #3
0
        public void LoadSettingModel(object o)
        {
            MainViewModel.ProjData.TargetCollection.Clear();
            MainViewModel.ProjData.BoneCollection.Clear();
            MultiAngleViewModel.OspModelCollection.Clear();
            MultiAngleViewModel.TriangleModelCollection.Clear();



            //讀取原始上下顎 加上 規劃後的轉移矩陣
            Matrix    plannedMatrix = ReadMatrixFile(_plannedMaxillaMatrix);
            BoneModel targetMaxilla = new BoneModel
            {
                FilePath         = MaxillaModel,
                IsRendering      = false,
                MarkerId         = "",
                ModelType        = ModelType.TargetMaxilla,
                BoneDiffuseColor = Color.FromArgb(255, 100, 100, 100),
                Transform        = new MatrixTransform3D(plannedMatrix.ToMatrix3D())
            };

            targetMaxilla.LoadModel();

            Matrix    plannedMandible = ReadMatrixFile(_plannedMandibleMatrix);
            BoneModel targetMandible  = new BoneModel
            {
                FilePath         = MandibleModel,
                IsRendering      = false,
                MarkerId         = "",
                ModelType        = ModelType.TargetMandible,
                BoneDiffuseColor = Color.FromArgb(255, 100, 100, 100),
                Transform        = new MatrixTransform3D(plannedMandible.ToMatrix3D())
            };

            targetMandible.LoadModel();

            //MainViewModel.Data.TargetCollection.Add(head);
            MainViewModel.ProjData.TargetCollection.Add(targetMaxilla);
            MainViewModel.ProjData.TargetCollection.Add(targetMandible);

            BoneModel head = new BoneModel
            {
                FilePath         = HeadModel,
                MarkerId         = "Head",
                ModelType        = ModelType.Head,
                BoneDiffuseColor = HeadDiffuseColor
            };

            head.LoadModel();
            BoneModel oriMaxilla = new BoneModel
            {
                FilePath         = MaxillaModel,
                ModelType        = ModelType.MovedMaxilla,
                MarkerId         = "Splint",
                BoneDiffuseColor = MaxillaDiffuseColor
            };

            oriMaxilla.LoadModel();
            BoneModel oriMandible = new BoneModel
            {
                FilePath         = MandibleModel,
                ModelType        = ModelType.MovedMandible,
                MarkerId         = "Splint",
                BoneDiffuseColor = MandibleDiffuseColor
            };

            oriMandible.LoadModel();

            MainViewModel.ProjData.BoneCollection.Add(head);
            MainViewModel.ProjData.BoneCollection.Add(oriMaxilla);
            MainViewModel.ProjData.BoneCollection.Add(oriMandible);

            //載入OSP模型
            OspModel headOsp = new OspModel
            {
                MarkerId     = "Head",
                FilePath     = HeadOsp,
                DiffuseColor = Color.FromArgb(50, 11, 243, 243)
            };

            headOsp.LoadOsp();

            OspModel mandibleOsp = new OspModel
            {
                MarkerId     = "C",
                FilePath     = MandibleOsp,
                DiffuseColor = Color.FromArgb(50, 2, 231, 2)
            };

            mandibleOsp.LoadOsp();

            //綁定下顎對稱面到下顎模型
            SetBinding(oriMandible, mandibleOsp, "Transform", HelixToolkit.Wpf.SharpDX.Model3D.TransformProperty, BindingMode.OneWay);
            MultiAngleViewModel.OspModelCollection.Add(headOsp);
            MultiAngleViewModel.OspModelCollection.Add(mandibleOsp);

            //標記屬於上顎的ID,綁定到目標上顎
            DraggableTriangle maxillaTargetTriangle = new DraggableTriangle(targetMaxilla.ModelCenter)
            {
                MarkerId    = "Maxilla",
                IsRendering = false,
                Transform   = targetMaxilla.Transform,
                ModelType   = ModelType.TargetMaxillaTriangle,
            };

            //標記屬於下顎的ID,綁定到目標下顎
            DraggableTriangle mandibleTargetTriangle = new DraggableTriangle(targetMandible.ModelCenter)
            {
                MarkerId    = "Mandible",
                IsRendering = false,
                Transform   = targetMandible.Transform,
                ModelType   = ModelType.TargetMandibleTriangle,
            };



            //將導航三角形綁定到導航的上顎
            DraggableTriangle maxillaTriangle = new DraggableTriangle(oriMaxilla.ModelCenter)
            {
                MarkerId     = "Maxilla",
                Transparency = 0.5f,
                IsRendering  = false,
                ModelType    = ModelType.MovedMaxillaTriangle,
            };

            SetBinding(oriMaxilla, maxillaTriangle, "Transform", HelixToolkit.Wpf.SharpDX.GroupModel3D.TransformProperty, BindingMode.OneWay);



            //將導航三角形綁定到導航的下顎
            DraggableTriangle mandibleTriangle = new DraggableTriangle(oriMandible.ModelCenter)
            {
                MarkerId     = "Mandible",
                Transparency = 0.5f,
                IsRendering  = false,
                ModelType    = ModelType.MovedMandibleTriangle,
            };

            SetBinding(oriMandible, mandibleTriangle, "Transform", HelixToolkit.Wpf.SharpDX.GroupModel3D.TransformProperty, BindingMode.OneWay);

            MultiAngleViewModel.TriangleModelCollection.Add(maxillaTargetTriangle);
            MultiAngleViewModel.TriangleModelCollection.Add(mandibleTargetTriangle);
            MultiAngleViewModel.TriangleModelCollection.Add(maxillaTriangle);
            MultiAngleViewModel.TriangleModelCollection.Add(mandibleTriangle);



            MultiAngleViewModel.ResetCameraPosition();

            MainViewModel.ProjData.IsNavSet = true;

            _navigateView.Hide();
        }