Ejemplo n.º 1
0
        public BraceVisual3D(Color color, TeethVisual3D p, bool generatedSample)
        {
            if (p != null)
            {
                this.parent = p;
                gc          = this.parent.gc;
                tc          = this.parent.tc;
                bc          = this.parent.bc;
                wc          = this.parent.wc;

                Id = p.Id + "_brace" + bc.Children.Count.ToString("00") + "." + p.Parent.Parent.patient.Id;;

                if (model == null)
                {
                    model = new Brace();
                }
                model.Id       = Id;
                model.Location = (IsOuterBrace ? Smile.OUTERBRACE : Smile.INNERBRACE);

                if (generatedSample)
                {
                    sample(color);
                }

                Bind(parent);
                //BindingOperations.SetBinding(this, TransformProperty, new Binding("TargetTransform") { Source = this });
                //BindingOperations.SetBinding(this.Manipulator,CombinedManipulator.TargetTransformProperty,new Binding("TargetTransform") { Source = this });
            }
        }
Ejemplo n.º 2
0
        public TeethRootVisual3D(Color color, TeethVisual3D p)
        {
            if (p != null)
            {
                this.parent = p;
                gc          = this.parent.gc;
                tc          = this.parent.tc;
                bc          = this.parent.bc;
                wc          = this.parent.wc;

                Id = p.Id + "_rootth" + tc.Children.Count.ToString("00") + "." + p.Parent.Parent.patient.Id;

                if (model == null)
                {
                    model = new Teeth();
                }
                model.Id     = Id;
                model.Length = 0.0;

                sample(color);

                //Adding Teeth Label
                //TextVisual3D text = new TextVisual3D();
                //text.Text = Id.ToString();
                //this.Children.Add(text);

                //showHideBoundingBox();
            }
        }
        public TeethRootVisual3D(Color color, TeethVisual3D p)
        {
            if (p != null)
            {
                this.parent = p;
                gc = this.parent.gc;
                tc = this.parent.tc;
                bc = this.parent.bc;
                wc = this.parent.wc;

                Id = p.Id + "_rootth" + tc.Children.Count.ToString("00") + "." + p.Parent.Parent.patient.Id;
                
                if (model == null) model = new Teeth();
                model.Id = Id;
                model.Length = 0.0;

                sample(color);

                //Adding Teeth Label
                //TextVisual3D text = new TextVisual3D();
                //text.Text = Id.ToString();
                //this.Children.Add(text);
                
                //showHideBoundingBox();
            }

        }
Ejemplo n.º 4
0
 public virtual void Bind(TeethVisual3D source)
 {
     BindingOperations.SetBinding(this, TargetTeethTransformProperty, new Binding("Transform")
     {
         Source = source
     });
 }
Ejemplo n.º 5
0
        internal TeethVisual3D addNewTeeth(Material material)
        {
            TeethVisual3D t = new TeethVisual3D(this);

            tc.Children.Add(t);

            if (selectedPoint != null)
            {
                Transform3DGroup transformGroup = new Transform3DGroup();
                transformGroup.Children.Add(new TranslateTransform3D(selectedPoint.ToVector3D()));
                t.Transform = transformGroup;
            }

            int intID = getTeethIDint(t.Id);

            teethDictionaries.Add(intID, t.Id);

            if (material == null)
            {
                material = MaterialHelper.CreateMaterial(TeethVisual3D.getTeethColor(intID));
            }
            ((GeometryModel3D)t.Content).Material     = material;
            ((GeometryModel3D)t.Content).BackMaterial = material;

            selectedTeeth = t;
            return(t);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// @Deprecated
        /// Not used anymore since changes in CONTAINER design.
        /// <see cref="findTeeth"/>
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        internal TeethVisual3D selectTeeth(int p)
        {
            TeethVisual3D teeth = null;
            String        pStr  = p.ToString("00");

            foreach (var g in gums)
            {
                GumVisual3D gum = g.Value;
                if (gum != null)
                {
                    foreach (var t in gum.Children)
                    {
                        if (t is TeethVisual3D)
                        {
                            teeth = (TeethVisual3D)t;
                            //Console.WriteLine(teeth.Id);
                            if (Regex.IsMatch(teeth.Id, @"teeth" + pStr))
                            //if (teeth.Id.StartsWith("teeth" + pStr))
                            {
                                //teeth.showHideManipulator();
                                selectedGum       = gum;
                                gum.selectedTeeth = teeth;
                                break;
                            }
                        }
                    }
                }
            }
            return(teeth);
        }
Ejemplo n.º 7
0
 protected static void TargetTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     //detect
     if (d is TeethVisual3D)
     {
         TeethVisual3D dt  = (TeethVisual3D)d;
         GumVisual3D   gum = dt.Parent;
         foreach (var t in gum.Children)
         {
             if (t is TeethVisual3D)
             {
                 TeethVisual3D teeth = (TeethVisual3D)t;
                 if (!teeth.Equals(d))
                 {
                     if (teeth.IsInside(dt))
                     {
                         Console.WriteLine(dt.Id + "TargetTransformChanged. TODO: detect collision detections" + teeth.Id);
                     }
                 }
             }
             else
             if (t is BraceVisual3D)
             {
             }
         }
     }
 }
Ejemplo n.º 8
0
        internal void showHideManipulator(TeethVisual3D teeth)
        {
            JawVisual.selectedGum = teeth.Parent;
            JawVisual.selectedGum.selectedTeeth = teeth;

            //teeth.showHideManipulator();
            teeth.displayManipulator();
        }
Ejemplo n.º 9
0
        internal TeethVisual3D selectTeeth(int p)
        {
            TeethVisual3D r = null;

            if (JawVisual != null)
            {
                //r = JawVisual.selectTeeth(p);
                r = JawVisual.findTeeth(p);
            }
            return(r);
        }
Ejemplo n.º 10
0
        private void Traverse <T>(Visual3D visual, Transform3D transform, Action <T, Transform3D> action)
            where T : Model3D
        {
            var childTransform = Transform3DHelper.CombineTransform(visual.Transform, transform);
            var model          = GetModel(visual);

            if (model != null)
            {
                if (jawVisual != null)
                {
                }
                else if (rawVisual != null)
                {
                }

                if (visual is TeethVisual3D)
                {
                    TeethVisual3D t = (TeethVisual3D)visual;
                    this.writer.WriteLine(string.Format("g jaw_{0}", t.Id));
                }
                else if (visual is GumVisual3D)
                {
                    GumVisual3D t = (GumVisual3D)visual;
                    this.writer.WriteLine(string.Format("g jaw_{0}", t.Id));
                }
                else if (visual is BraceVisual3D)
                {
                    BraceVisual3D t = (BraceVisual3D)visual;
                    this.writer.WriteLine(string.Format("g jaw_{0}", t.Id));
                }
                else if (visual is WireVisual3D)
                {
                }
                else
                {
                    this.writer.WriteLine(string.Format("g jaw_group{0}", this.groupNo++));
                }

                if (visual is Manipulator || visual is BoundingBoxWireFrameVisual3D)
                {
                }
                else
                {
                    TraverseModel(model, childTransform, action);
                }
            }

            foreach (var child in GetChildren(visual))
            {
                Traverse(child, childTransform, action);
            }
        }
Ejemplo n.º 11
0
        public TeethVisual3D addTeeth(Point3D center)
        {
            TeethVisual3D teeth = null;

            if (selectedGum != null)
            {
                selectedGum.selectedPoint = center;
                //return selectedGum.addTeeth();
                teeth = selectedGum.addNewTeeth();
            }

            return(teeth);
        }
Ejemplo n.º 12
0
        public void deleteTeeth()
        {
            if (selectedTeeth != null)
            {
                selectedTeeth.clearManipulator();
                tc.Children.Remove(selectedTeeth);

                int intID = getTeethIDint(selectedTeeth.Id);
                teethDictionaries.Remove(intID);

                selectedTeeth = null;
            }
        }
Ejemplo n.º 13
0
        public void addRow(TeethVisual3D teeth, string type)
        {
            string teeth_name   = teeth.Model.Id;
            double teeth_length = Math.Round(teeth.Model.Length, 2);

            if (type == "auto")
            {
                this.dgTMeasurement.Rows.Add(teeth.Model.TeethNumber, teeth_name, teeth_length);
            }
            else
            {
                this.dgTMeasurement.Rows.Add(teeth.Model.TeethNumber, teeth.Model.Id, teeth.Model.StartPosition, teeth.Model.EndPosition, teeth.Model.Length);
            }
            this.Show();
            return;
        }
Ejemplo n.º 14
0
        public void addRow(TeethVisual3D teeth, string type)
        {
            
            string teeth_name = teeth.Model.Id;
            double teeth_length = Math.Round(teeth.Model.Length, 2);

            if (type == "auto")
            { 
                this.dgTMeasurement.Rows.Add(teeth.Model.TeethNumber,teeth_name, teeth_length); 
            }
            else { 
                this.dgTMeasurement.Rows.Add(teeth.Model.TeethNumber,teeth.Model.Id,teeth.Model.StartPosition,teeth.Model.EndPosition,teeth.Model.Length); 
            }
            this.Show();
            return;
        }
Ejemplo n.º 15
0
        internal List <GeometryModel3D> manualSegment(Point3DCollection points, Vector3DCollection vectors)
        {
            List <GeometryModel3D> models = new List <GeometryModel3D>();
            //MeshGeometry3D worldMesh = GetMesh();//ToWorldMesh();
            MeshGeometry3D worldMesh = ToWorldMesh();

            for (var i = 1; i < points.Count; i++)
            {
                Point3D  p0 = points[i - 1];
                Vector3D n0 = vectors[i - 1];
                Point3D  pi = points[i];
                Vector3D ni = vectors[i];

                Point3D  pp = new Point3D(0, 0, 0);
                Vector3D nn = Point3D.Subtract(p0, pp);
                if (i == 1)
                {
                    nn = Point3D.Subtract(pi, pp);
                }
                var g1 = MeshGeometryHelper.Cut(worldMesh, pp, nn);
                this.Children.Add(new RectangleVisual3D {
                    Origin = ToLocal(pp), Normal = nn, Fill = new SolidColorBrush(Colors.LightGoldenrodYellow), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Blue))
                });

                if (i > 1)
                {
                    n0.Negate();
                }
                //var geo = MeshGeometryHelper.Cut(worldMesh, p0, n0);
                var geo = MeshGeometryHelper.Cut(g1, p0, n0);
                this.Children.Add(new RectangleVisual3D {
                    Origin = ToLocal(p0), Normal = n0, Fill = new SolidColorBrush(Colors.LightGoldenrodYellow), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Blue))
                });
                //Console.WriteLine(i+" = "+p0.ToString());
                var geo1 = MeshGeometryHelper.Cut(geo, pi, ni);
                this.Children.Add(new RectangleVisual3D {
                    Origin = ToLocal(pi), Normal = ni, Fill = new SolidColorBrush(Color.FromArgb(80, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green))
                });

                //var geo2 = ToLocalMesh(geo1);

                var model = new GeometryModel3D(geo1, MaterialHelper.CreateMaterial(TeethVisual3D.getTeethColor(i)));
                models.Add(model);
            }
            return(models);
        }
Ejemplo n.º 16
0
 internal void updateTeethMap(string oldid, string newid)
 {
     //find the existing new id
     foreach (var t in tc.Children)
     {
         if (t is TeethVisual3D)
         {
             TeethVisual3D teeth = (TeethVisual3D)t;
             if (teeth.Id.Equals(newid))
             {
                 teeth.Id = oldid;
                 selectedGum.selectedTeeth.Id = newid;
                 break;
             }
         }
     }
 }
Ejemplo n.º 17
0
        //Using Container
        internal TeethVisual3D findTeeth(int p)
        {
            TeethVisual3D teeth = null;
            String        pStr  = p.ToString("00");

            foreach (var t in tc.Children)
            {
                if (t is TeethVisual3D)
                {
                    teeth = (TeethVisual3D)t;
                    if (Regex.IsMatch(teeth.Id, @"teeth" + pStr))
                    {
                        //teeth.showHideManipulator();
                        selectedGum = teeth.Parent;
                        selectedGum.selectedTeeth = teeth;
                        break;
                    }
                }
            }
            return(teeth);
        }
Ejemplo n.º 18
0
        public BraceVisual3D(Material material, TeethVisual3D p)
        {
            if (p != null)
            {
                this.parent = p;
                gc = this.parent.gc;
                tc = this.parent.tc;
                bc = this.parent.bc;
                wc = this.parent.wc;

                Id = p.Id + "_brace" + p.Children.Count.ToString("00") + "." + p.Parent.Parent.patient.Id; ;

                if (model == null) model = new Brace();
                model.Id = Id;
                model.Location = (IsOuterBrace ? Smile.OUTERBRACE : Smile.INNERBRACE);

                //sample(material);
                //BindingOperations.SetBinding(this, TransformProperty, new Binding("TargetTransform") { Source = this });
                //BindingOperations.SetBinding(this.Manipulator,CombinedManipulator.TargetTransformProperty,new Binding("TargetTransform") { Source = this });

            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// @Deprecated
 /// <see cref="updateTeethMap"/>
 /// </summary>
 /// <param name="oldid"></param>
 /// <param name="newid"></param>
 internal void updateTeethMapOld(string oldid, string newid)
 {
     //find the existing new id
     foreach (var g in gums)
     {
         GumVisual3D gum = g.Value;
         if (gum != null)
         {
             foreach (var t in gum.Children)
             {
                 if (t is TeethVisual3D)
                 {
                     TeethVisual3D teeth = (TeethVisual3D)t;
                     if (teeth.Id.Equals(newid))
                     {
                         teeth.Id = oldid;
                         selectedGum.selectedTeeth.Id = newid;
                         break;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 public void hide(TeethVisual3D t)
 {
     this.Children.Remove(t);
 }
Ejemplo n.º 21
0
 public void show(TeethVisual3D t)
 {
     this.Children.Add(t);
 }
Ejemplo n.º 22
0
 public BraceVisual3D(TeethVisual3D parent, bool generatedSample)
     : this(Colors.Pink, parent, generatedSample)
 {
 }
Ejemplo n.º 23
0
        internal void showHideManipulator(TeethVisual3D teeth)
        {
            JawVisual.selectedGum = teeth.Parent;
            JawVisual.selectedGum.selectedTeeth = teeth;

            //teeth.showHideManipulator();
            teeth.displayManipulator();
        }
Ejemplo n.º 24
0
        public void deleteTeeth()
        {
            if (selectedTeeth != null)
            {
                selectedTeeth.clearManipulator();
                tc.Children.Remove(selectedTeeth);

                int intID = getTeethIDint(selectedTeeth.Id);
                teethDictionaries.Remove(intID);

                selectedTeeth = null;
            }
        }
Ejemplo n.º 25
0
 internal void addNewTeeth(GeometryModel3D model)
 {
     selectedTeeth = addNewTeeth(model.Material);
     selectedTeeth.Content = model;
 }
Ejemplo n.º 26
0
        internal TeethVisual3D addNewTeeth(Material material)
        {
            TeethVisual3D t = new TeethVisual3D(this);
            tc.Children.Add(t);

            if (selectedPoint != null)
            {
                Transform3DGroup transformGroup = new Transform3DGroup();
                transformGroup.Children.Add(new TranslateTransform3D(selectedPoint.ToVector3D()));
                t.Transform = transformGroup;
            }

            int intID = getTeethIDint(t.Id);
            teethDictionaries.Add(intID, t.Id);

            if (material == null)
            {
                material = MaterialHelper.CreateMaterial(TeethVisual3D.getTeethColor(intID));
            }
            ((GeometryModel3D)t.Content).Material = material;
            ((GeometryModel3D)t.Content).BackMaterial = material;

            selectedTeeth = t;
            return t;
        }
Ejemplo n.º 27
0
 public virtual void Bind(TeethVisual3D source)
 {
     BindingOperations.SetBinding(this, TargetTeethTransformProperty, new Binding("Transform") { Source = source });
 }
Ejemplo n.º 28
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;
            }
Ejemplo n.º 29
0
 public void show(TeethVisual3D t)
 {
     this.Children.Add(t);
 }
Ejemplo n.º 30
0
 public TeethRootVisual3D(TeethVisual3D parent)
     : this(Colors.Pink, parent)
 {
 }
Ejemplo n.º 31
0
 public void hide(TeethVisual3D t)
 {
     this.Children.Remove(t);
 }
Ejemplo n.º 32
0
 internal void addNewTeeth(GeometryModel3D model)
 {
     selectedTeeth         = addNewTeeth(model.Material);
     selectedTeeth.Content = model;
 }
Ejemplo n.º 33
0
 private void showTeethProperty(TeethVisual3D teeth)
 {
     _propertyGrid.Visibility = System.Windows.Visibility.Visible;
     _propertyGrid.SelectedObject = CustomAttributeEditorTeeth.CreateCustomAttributEditorTeeth(teeth.Model);
 }
Ejemplo n.º 34
0
 public BraceVisual3D(TeethVisual3D parent, bool generatedSample)
     : this(Colors.Pink, parent, generatedSample)
 {
 }
Ejemplo n.º 35
0
 public TeethRootVisual3D(TeethVisual3D parent)
     : this(Colors.Pink, parent)
 {
 }