示例#1
0
 public virtual void Bind2(BraceVisual3D source)
 {
     BindingOperations.SetBinding(this, Target2TransformProperty, new Binding("Transform")
     {
         Source = source
     });
 }
示例#2
0
        //==============using new architecture (container) =================
        public BraceVisual3D addNewBrace()
        {
            BraceVisual3D brace = null;
            GumVisual3D   gum   = this.parent;

            gum.braceDictionaries.TryGetValue(this.Id, out brace);
            //TODO: If multiple brace in one teeth?

            if (brace == null)
            {
                brace = new BraceVisual3D(Colors.Yellow, this, true);
                bc.Children.Add(brace);
                gum.braces.Add(brace);

                gum.braceDictionaries.Add(this.Id, brace);

                /*if (selectedPoint != null)
                 * {
                 *  Transform3DGroup transformGroup = new Transform3DGroup();
                 *  transformGroup.Children.Add(new TranslateTransform3D(ToWorld(selectedPoint.ToVector3D())));
                 *  brace.Transform = transformGroup;
                 * }*/
            }

            return(brace);
        }
示例#3
0
        internal void showHideManipulator(BraceVisual3D brace)
        {
            JawVisual.selectedGum = brace.Parent.Parent;
            JawVisual.selectedGum.selectedTeeth = brace.Parent;

            //brace.showHideManipulator();
            brace.displayManipulator();
        }
示例#4
0
        public void updateBraceLocation(string braceid, int oldLocation, int newValue)
        {
            BraceVisual3D brace = findBrace(braceid);

            if (brace != null)
            {
                brace.IsOuterBrace = brace.IntToBoolOuterBrace(newValue);
            }
        }
示例#5
0
        internal BraceVisual3D addBrace(Point3D center)
        {
            BraceVisual3D brace = null;

            if (selectedGum != null)
            {
                selectedGum.selectedPoint = center;
                //return selectedGum.addBrace();
                brace = selectedGum.addNewBrace();
            }
            return(brace);
        }
示例#6
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);
            }
        }
示例#7
0
        public WireVisual3D(Brush b, BraceVisual3D p1, BraceVisual3D p2)
        {
            if (p1 != null)
            {
                Id = p1.Id + "_wire" + p1.Children.Count.ToString("00") + "." + p1.Parent.Parent.Parent.patient.Id;

                brace1 = p1;
                brace2 = p2;

                contours(b);

                Bind(p1, p2);
            }
        }
        public WireVisual3D(Brush b, BraceVisual3D p1, BraceVisual3D p2)
        {
            if (p1 != null)
            {
                Id = p1.Id + "_wire" + p1.Children.Count.ToString("00") + "." + p1.Parent.Parent.Parent.patient.Id;

                brace1 = p1;
                brace2 = p2;

                contours(b);

                Bind(p1, p2);
            }
        }
示例#9
0
 private BraceVisual3D findBrace(string braceid)
 {
     //find the existing new id
     foreach (var t in bc.Children)
     {
         if (t is BraceVisual3D)
         {
             BraceVisual3D brace = (BraceVisual3D)t;
             if (brace.Id.Equals(braceid))
             {
                 return(brace);
             }
         }
     }
     return(null);
 }
示例#10
0
        internal void deleteBrace()
        {
            BraceVisual3D brace = null;
            GumVisual3D   gum   = this.parent;

            gum.braceDictionaries.TryGetValue(this.Id, out brace);
            //TODO: If multiple brace in one teeth?

            if (brace != null)
            {
                cleanManipulator();
                bc.Children.Remove(brace);
                gum.braces.Remove(brace);
                gum.braceDictionaries.Remove(this.Id);
                gum.Parent.removeWire(brace);
                brace = null;
            }
        }
示例#11
0
        internal void drawWire(List <BraceVisual3D> bracesModel)
        {
            //clearWires();
            for (var i = 1; i < bracesModel.Count; i++)
            {
                BraceVisual3D brace1 = bracesModel[i - 1];
                BraceVisual3D brace2 = bracesModel[i];

                //brace1.SetMesh(brace1.ToWorldMesh());
                //brace2.SetMesh(brace2.ToWorldMesh());

                //brace1.SetMesh(brace1.ToLocalMesh(brace1.GetMesh()));
                //brace2.SetMesh(brace1.ToLocalMesh(brace2.GetMesh()));

                WireVisual3D wv = new WireVisual3D((i % 2 == 0? Brushes.Green: Brushes.Blue), brace1, brace2);
                //this.Children.Add(wv);
                wc.Children.Add(wv);
            }
        }
示例#12
0
        internal void removeWire(BraceVisual3D brace)
        {
            //List<Visual3D> list = this.Children.ToList();
            List <Visual3D> list = wc.Children.ToList();

            foreach (var t in list)
            {
                if (t is WireVisual3D)
                {
                    WireVisual3D wv = (WireVisual3D)t;
                    if (brace.Id == wv.Brace1.Id)
                    {
                        //this.Children.Remove(t);
                        wc.Children.Remove(t);
                    }
                    else if (brace.Id == wv.Brace2.Id)
                    {
                        //this.Children.Remove(t);
                        wc.Children.Remove(t);
                    }
                }
            }
        }
示例#13
0
        //public static readonly DependencyProperty TargetTeethTransformProperty = DependencyProperty.Register("TargetTeethTransform", typeof(Transform3D), typeof(BraceVisual3D), new FrameworkPropertyMetadata(Transform3D.Identity, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));

        protected static void TeethTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //TODO: Teeth movement affect to Brace Movement
            //Brace.Transform = Teeth.Transform - Brace.Position;
            if (d is BraceVisual3D)
            {
                BraceVisual3D brace = d as BraceVisual3D;
                if (brace != null)
                {
                    Transform3D go = e.OldValue as Transform3DGroup;
                    Transform3D gn = e.NewValue as Transform3DGroup;
                    if (go != null && gn != null)
                    {
                        Transform3D bt = brace.Transform;

                        if (gn is TranslateTransform3D)
                        {
                            Matrix3D btm = bt.Value;
                            btm.OffsetX = btm.OffsetX + (gn.Value.OffsetX - go.Value.OffsetX);
                            btm.OffsetY = btm.OffsetY + (gn.Value.OffsetY - go.Value.OffsetY);
                            btm.OffsetZ = btm.OffsetZ + (gn.Value.OffsetZ - go.Value.OffsetZ);
                            bt          = new TranslateTransform3D(btm.OffsetX, btm.OffsetY, btm.OffsetZ);
                        }
                        if (gn is RotateTransform3D)
                        {
                            //bt = new RotateTransform3D();
                        }

                        if (gn is ScaleTransform3D)
                        {
                            //bt = new ScaleTransform3D();
                        }
                        brace.Transform = bt;
                    }
                }
            }
        }
示例#14
0
 internal void removeWire(BraceVisual3D brace)
 {
     //List<Visual3D> list = this.Children.ToList();
     List<Visual3D> list = wc.Children.ToList();
     foreach (var t in list)
     {
         if (t is WireVisual3D)
         {
             WireVisual3D wv = (WireVisual3D)t;
             if (brace.Id == wv.Brace1.Id)
             {
                 //this.Children.Remove(t);
                 wc.Children.Remove(t);
             }
             else if (brace.Id == wv.Brace2.Id)
             {
                 //this.Children.Remove(t);
                 wc.Children.Remove(t);
             }
         }
     }
 
 }
示例#15
0
        //==============using new architecture (container) =================
        public BraceVisual3D addNewBrace()
        {
            BraceVisual3D brace = null;
            GumVisual3D gum = this.parent;
            gum.braceDictionaries.TryGetValue(this.Id, out brace);
            //TODO: If multiple brace in one teeth?

            if (brace == null)
            {
                brace = new BraceVisual3D(Colors.Yellow, this, true);
                bc.Children.Add(brace);
                gum.braces.Add(brace);

                gum.braceDictionaries.Add(this.Id, brace);
                
                /*if (selectedPoint != null)
                {
                    Transform3DGroup transformGroup = new Transform3DGroup();
                    transformGroup.Children.Add(new TranslateTransform3D(ToWorld(selectedPoint.ToVector3D())));
                    brace.Transform = transformGroup;
                }*/
            }

            return brace;
        }
示例#16
0
 public void hide(BraceVisual3D t)
 {
     this.Children.Remove(t);
 }
示例#17
0
 public void show(BraceVisual3D t)
 {
     this.Children.Add(t);
 }
 public void hide(BraceVisual3D t)
 {
     this.Children.Remove(t);
 }
 public void show(BraceVisual3D t)
 {
     this.Children.Add(t);
 }
示例#20
0
 public virtual void Bind2(BraceVisual3D source)
 {
     BindingOperations.SetBinding(this, Target2TransformProperty, new Binding("Transform") { Source = source });
 }
示例#21
0
 public virtual void Bind(BraceVisual3D source1, BraceVisual3D source2)
 {
     Bind1(source1);
     Bind2(source2);
 }
示例#22
0
 public virtual void Bind(BraceVisual3D source1, BraceVisual3D source2)
 {
     Bind1(source1);
     Bind2(source2);
 }
 private void showBraceProperty(BraceVisual3D brace)
 {
     _propertyGrid.Visibility = System.Windows.Visibility.Visible;
     _propertyGrid.SelectedObject = CustomAttributeEditorBrace.CreateCustomAttributEditorBrace(brace.Model);
 }
示例#24
0
        internal void showHideManipulator(BraceVisual3D brace)
        {
            JawVisual.selectedGum = brace.Parent.Parent;
            JawVisual.selectedGum.selectedTeeth = brace.Parent;

            //brace.showHideManipulator();
            brace.displayManipulator();
        }
            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;
            }