コード例 #1
0
//        public MainViewModel(IFileDialogService fds, HelixViewport3D hv, ModelVisual3D rootModel)
        public MainViewModel(IFileDialogService fds, HelixViewport3D hv, MainWindow window)
        {
            Expansion              = 1;
            FileDialogService      = fds;
            HelixView              = hv;
            FileOpenCommand        = new DelegateCommand(FileOpen);
            FileOpenRawCommand     = new DelegateCommand(FileOpenRaw);
            FileExportCommand      = new DelegateCommand(FileExport);
            FileExportRawCommand   = new DelegateCommand(FileExportRaw);
            FileExitCommand        = new DelegateCommand(FileExit);
            ViewZoomExtentsCommand = new DelegateCommand(ViewZoomExtents);
            EditCopyXamlCommand    = new DelegateCommand(CopyXaml);
            EditClearAreaCommand   = new DelegateCommand(ClearArea);
            FileExportStlCommand   = new DelegateCommand(StlFileExport);


            ApplicationTitle = "Dental.Smile - 3D Viewer";

            ModelToBaseMarker = new Dictionary <Model3D, BaseMarker>();
            OriginalMaterial  = new Dictionary <Model3D, Material>();

            //Elements = new List<VisualElement>();
            //foreach (var c in hv.Children) Elements.Add(new VisualElement(c));

            DB         = DentalSmileDBFactory.GetInstance();
            Treatment  = new Treatment();
            SmileFile  = new SmileFile();
            Patient    = new Patient();
            JawVisual  = new JawVisual3D(Patient);
            RootVisual = window.vmodel;
            app        = Application.Current as App;

            RootVisual.Children.Add(JawVisual);
            this.window = window;
        }
コード例 #2
0
        internal void cutMesh()
        {
            if (RawVisual != null)
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                GeometryModel3D gumModel = RawVisual.cutByPlane();
                if (JawVisual == null)
                {
                    Patient p = App.patient;
                    if (p == null)
                    {
                        p = new Patient();
                    }
                    JawVisual = new JawVisual3D(p);
                }
                JawVisual.replaceGum(gumModel);
                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);
                MessageBox.Show("Processing is done ( " + elapsedTime + " ).", "Cutting Mesh");
            }
        }
コード例 #3
0
        public GumVisual3D(JawVisual3D p, Color color, string id)
        {
            this.parent = p;
            gc = this.parent.gc;
            tc = this.parent.tc;
            bc = this.parent.bc;
            wc = this.parent.wc;
            if (id == null)
                Id = "gum" + p.gums.Count.ToString("00") + "." + p.patient.Id;
            else
                Id = id;

            sample(color);

            teethDictionaries = new Dictionary<int, string>();
            braceDictionaries = new Dictionary<string, BraceVisual3D>();
            braces = new List<BraceVisual3D>();

        }
コード例 #4
0
        public GumVisual3D(JawVisual3D p, Color color, string id)
        {
            this.parent = p;
            gc          = this.parent.gc;
            tc          = this.parent.tc;
            bc          = this.parent.bc;
            wc          = this.parent.wc;
            if (id == null)
            {
                Id = "gum" + p.gums.Count.ToString("00") + "." + p.patient.Id;
            }
            else
            {
                Id = id;
            }

            sample(color);

            teethDictionaries = new Dictionary <int, string>();
            braceDictionaries = new Dictionary <string, BraceVisual3D>();
            braces            = new List <BraceVisual3D>();
        }
コード例 #5
0
        private void LoadJawFile(string CurrentModelPath)
        {
            try
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                JawVisual3D jv = null;
                jv = (JawVisual3D)SmileModelImporter.Load(CurrentModelPath);
                if (jv != null)
                {
                    if (RootVisual.Children.Contains(JawVisual))
                    {
                        RootVisual.Children.Remove(JawVisual);
                    }
                    JawVisual = null;
                    JawVisual = jv;
                    RootVisual.Children.Add(JawVisual);
                    smileMode = "JAW";

                    if (JawVisual.selectedGum != null)
                    {
                        drawWires();
                    }

                    //if (!HelixView.Viewport.Children.Contains(RootVisual))                    HelixView.Viewport.Children.Add(RootVisual);
                    window.chartPanel.Visibility = Visibility.Visible;
                    ApplicationTitle             = String.Format(TitleFormatString, CurrentModelPath);
                }

                HelixView.ZoomExtents(100);
                showStatus(stopWatch, "Loaded");
            }
            catch (FileNotFoundException fnfe)
            {
                MessageBox.Show("File not found. Make sure your Path Setting is correct.");
            }
        }
コード例 #6
0
 public GumVisual3D(JawVisual3D parent, string id)
     : this(parent, Colors.BurlyWood, id)
 {
 }
コード例 #7
0
        internal void cutMesh()
        {
            if (RawVisual != null)
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                GeometryModel3D gumModel = RawVisual.cutByPlane();
                if (JawVisual == null)
                {
                    Patient p = App.patient;
                    if (p == null) p = new Patient();
                    JawVisual = new JawVisual3D(p);
                }
                JawVisual.replaceGum(gumModel);
                stopWatch.Stop();
                TimeSpan ts = stopWatch.Elapsed;
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds,
                ts.Milliseconds / 10);
                MessageBox.Show("Processing is done ( "+elapsedTime+" ).", "Cutting Mesh");
            }

        }
コード例 #8
0
//        public MainViewModel(IFileDialogService fds, HelixViewport3D hv, ModelVisual3D rootModel)
        public MainViewModel(IFileDialogService fds, HelixViewport3D hv, MainWindow window)
        {
            Expansion = 1;
            FileDialogService = fds;
            HelixView = hv;
            FileOpenCommand = new DelegateCommand(FileOpen);
            FileOpenRawCommand = new DelegateCommand(FileOpenRaw);
            FileExportCommand = new DelegateCommand(FileExport);
            FileExportRawCommand = new DelegateCommand(FileExportRaw);
            FileExitCommand = new DelegateCommand(FileExit);
            ViewZoomExtentsCommand = new DelegateCommand(ViewZoomExtents);
            EditCopyXamlCommand = new DelegateCommand(CopyXaml);
            EditClearAreaCommand = new DelegateCommand(ClearArea);
            FileExportStlCommand = new DelegateCommand(StlFileExport);            


            ApplicationTitle = "Dental.Smile - 3D Viewer";

            ModelToBaseMarker = new Dictionary<Model3D, BaseMarker>();
            OriginalMaterial = new Dictionary<Model3D, Material>();

            //Elements = new List<VisualElement>();
            //foreach (var c in hv.Children) Elements.Add(new VisualElement(c));

            DB = DentalSmileDBFactory.GetInstance();
            Treatment = new Treatment();
            SmileFile = new SmileFile();
            Patient = new Patient();
            JawVisual = new JawVisual3D(Patient);
            RootVisual = window.vmodel;
            app = Application.Current as App;

            RootVisual.Children.Add(JawVisual);
            this.window = window;

        }
コード例 #9
0
 public GumVisual3D(JawVisual3D parent, string id)
     : this(parent, Colors.BurlyWood, id)
 {
    
 }
コード例 #10
0
 private GumVisual3D getGumVisualFromJaw(string p, JawVisual3D jaw)
 {
     GumVisual3D gum = null;
     jaw.gums.TryGetValue(p, out gum);
     if (gum == null)
     {
         gum = jaw.addNewGum(p);
         //jaw.Children.Add(gum);
     }
     return gum;
 }
コード例 #11
0
            public ModelVisual3D BuildModelVisual()
            {
                Dictionary<String, JawVisual3D> jaws = new Dictionary<String, JawVisual3D>();
                JawVisual3D jaw = null;
                foreach (var g in this.Groups)
                {
                    var gs = g.Name.Split('_');
                    if(gs[0].StartsWith("jaw"))
                    {
                        jaws.TryGetValue(gs[0], out jaw);
                        if (jaw == null)
                        {
                            var dp = gs[1].Split('.');
                            
                            Patient p = new Patient();
                            if (dp.Length > 1)
                                p.Name = dp[1];
                            else p.Name = "Default";
                            jaw = new JawVisual3D(p);
                            jaws.Add(gs[0], jaw);
                        }
                    }
                    if (jaw != null)
                    {
                        //GUM
                        if (gs[1].StartsWith("gum"))
                        {
                            GumVisual3D gum = null;
                            gum = getGumVisualFromJaw(gs[1], jaw);
                            gum.Id = gs[1];

                            if (gs.Length > 2 && gs[2].StartsWith("teeth"))
                            {
                                TeethVisual3D teeth = null;
                                if (gs.Length > 3 && gs[3].StartsWith("brace"))
                                {
                                    teeth = getTeethVisualFromGum(gs[2], gum);
                                    if (teeth == null)
                                    {
                                        teeth = new TeethVisual3D(gum);
                                        teeth.Id = gs[1] + "_" + gs[2];
                                        //gum.Children.Add(teeth);
                                        gum.tc.Children.Add(teeth);
                                    }
                                    BraceVisual3D brace = new BraceVisual3D(teeth, false);
                                    brace.Id = gs[1] + "_" + gs[2] + "_" + gs[3];

                                    var mg = new Model3DGroup();
                                    foreach (var gm in g.CreateModels())
                                    {
                                        mg.Children.Add(gm);
                                    }
                                    brace.Content = mg;
                                    //teeth.Children.Add(brace);
                                    teeth.bc.Children.Add(brace);
                                    gum.braces.Add(brace);
                                    gum.braceDictionaries.Add(teeth.Id, brace);
                                }
                                else
                                {
                                    teeth = getTeethVisualFromGum(gs[2], gum);
                                    if (teeth == null)
                                    {
                                        teeth = new TeethVisual3D(gum);
                                        teeth.Id = gs[1] + "_" + gs[2];

                                        //gum.Children.Add(teeth);
                                        gum.tc.Children.Add(teeth);
                                    }

                                    var modelGroup = new Model3DGroup();
                                    foreach (var gm in g.CreateModels())
                                    {
                                        modelGroup.Children.Add(gm);
                                    }
                                    teeth.Content = modelGroup;

                                }
                            }
                            else
                            {
                                var modelGroup = new Model3DGroup();
                                foreach (var gm in g.CreateModels())
                                {
                                    modelGroup.Children.Add(gm);
                                }
                                gum.Content = modelGroup;
                            }
                        }

                        //TEETH
                        if (gs[1].StartsWith("teeth"))
                        {
                            GumVisual3D gum = null;
                            if (gs[2].StartsWith("gum"))
                            {
                                gum = getGumVisualFromJaw(gs[2], jaw);
                                gum.Id = gs[2];
                            }
                            TeethVisual3D teeth = null;
                            if (gs.Length > 3 && gs[3].StartsWith("brace"))
                            {
                                teeth = getTeethVisualFromGum(gs[1], gum);
                                if (teeth == null)
                                {
                                    teeth = new TeethVisual3D(gum);
                                    teeth.Id = gs[1] + "_" + gs[2];
                                    //gum.Children.Add(teeth);
                                    gum.tc.Children.Add(teeth);
                                }
                                BraceVisual3D brace = new BraceVisual3D(teeth, false);
                                brace.Id = gs[1] + "_" + gs[2] + "_" + gs[3];

                                var mg = new Model3DGroup();
                                foreach (var gm in g.CreateModels())
                                {
                                    mg.Children.Add(gm);
                                }
                                brace.Content = mg;
                                //teeth.Children.Add(brace);
                                teeth.bc.Children.Add(brace);
                                gum.braces.Add(brace);
                                gum.braceDictionaries.Add(teeth.Id, brace);
                            }
                            else
                            {
                                teeth = getTeethVisualFromGum(gs[1], gum);
                                if (teeth == null)
                                {
                                    teeth = new TeethVisual3D(gum);
                                    teeth.Id = gs[1] + "_" + gs[2];

                                    //gum.Children.Add(teeth);
                                    gum.tc.Children.Add(teeth);
                                } 
                                //teeth = new TeethVisual3D(gum);
                                //teeth.Id = gs[1] + "_" + gs[2];

                                var modelGroup = new Model3DGroup();
                                foreach (var gm in g.CreateModels())
                                {
                                    modelGroup.Children.Add(gm);
                                }
                                teeth.Content = modelGroup;
                                //gum.Children.Add(teeth);
                                if(!gum.tc.Children.Contains(teeth)) 
                                    gum.tc.Children.Add(teeth);
                            }

                        }

                        //BRACE
                        if (gs[1].StartsWith("brace"))
                        {
                            TeethVisual3D teeth = null;
                            GumVisual3D gum = null;
                            if (gs[2].StartsWith("gum"))
                            {
                                gum = getGumVisualFromJaw(gs[2], jaw);
                                gum.Id = gs[2];
                                if (gs[3].StartsWith("teeth"))
                                {
                                    teeth = getTeethVisualFromGum(gs[3], gum);
                                }
                            }else if(gs[2].StartsWith("teeth"))
                            {
                                if (gs[3].StartsWith("gum"))
                                {
                                    gum = getGumVisualFromJaw(gs[3], jaw);
                                    gum.Id = gs[3];
                                }
                                teeth = getTeethVisualFromGum(gs[2], gum);
                            }
                            
                            BraceVisual3D brace = new BraceVisual3D(teeth, false);
                            brace.Id = gs[1] + "_" + gs[2] + "_"+gs[3];

                            var modelGroup = new Model3DGroup();
                            foreach (var gm in g.CreateModels())
                            {
                                modelGroup.Children.Add(gm);
                            }
                            brace.Content = modelGroup;
                            //teeth.Children.Add(brace);
                            teeth.bc.Children.Add(brace);
                        }
                    }
                }

                return jaw;
            }