Esempio n. 1
0
        internal void AutoSegmentMesh()
        {
            SegmentationB   b  = new SegmentationB();
            ModelVisual3D   m  = new ModelVisual3D();
            MeshBuilder     mb = new MeshBuilder(false, false);
            MeshGeometry3D  mg = b.AutoSnake(RawVisual.GetMesh(), ref mb);
            GeometryModel3D g  = new GeometryModel3D();

            g.Geometry     = mg;
            g.Material     = MaterialHelper.CreateMaterial(Brushes.Blue);
            g.BackMaterial = MaterialHelper.CreateMaterial(Brushes.Yellow);
            m.Content      = g;
            //JawVisual.gc.Children.Add(m);

            GeometryModel3D gP = new GeometryModel3D();

            gP.Geometry     = mb.ToMesh();
            gP.Material     = MaterialHelper.CreateMaterial(Brushes.Red);
            gP.BackMaterial = MaterialHelper.CreateMaterial(Brushes.Pink);
            ModelVisual3D mP = new ModelVisual3D();

            mP.Content = gP;
            //JawVisual.tc.Children.Add(mP);

            SegmentationB.drawSnakes(JawVisual.bc);
        }
Esempio n. 2
0
 internal void alignObject()
 {
     if (RawVisual != null)
     {
         RawVisual.showHideManipulator();
     }
 }
Esempio n. 3
0
 internal void addPlane()
 {
     if (RawVisual != null)
     {
         RawVisual.showHidePlane();
     }
 }
Esempio n. 4
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");
            }
        }
Esempio n. 5
0
        private void LoadRawFile(string CurrentModelPath)
        {
            try
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                CurrentModel = ModelImporter.Load(CurrentModelPath);
                Model3DGroup group = new Model3DGroup();
                if (CurrentModel != null)
                {
                    var    mb = new MeshBuilder(false, false);
                    Rect3D r  = CurrentModel.Bounds;

                    Model3DGroup g = (Model3DGroup)CurrentModel;
                    foreach (GeometryModel3D gm in g.Children)
                    {
                        MeshGeometry3D    mesh = (MeshGeometry3D)gm.Geometry;
                        Point3DCollection ind  = mesh.Positions;
                        for (int i = 0; i < ind.Count; i++)
                        {
                            var p0 = ind[i];

                            p0 = new Point3D(p0.X + (-(r.X + (r.SizeX / 2))), p0.Y + (-(r.Y + (r.SizeY / 2))), p0.Z + (-(r.Z + (r.SizeZ / 2))));

                            mb.Positions.Add(p0);
                        }

                        for (int i = 0; i < mesh.TriangleIndices.Count; i++)
                        {
                            mb.TriangleIndices.Add(mesh.TriangleIndices[i]);
                        }
                    }
                    var geom = new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(Colors.BlueViolet));
                    geom.BackMaterial = MaterialHelper.CreateMaterial(Colors.Chocolate);
                    group.Children.Add(geom);

                    CurrentModel = group;
                    if (RawVisual == null)
                    {
                        RawVisual = new RawVisual3D(RootVisual);
                    }
                    RawVisual.Content         = CurrentModel;
                    RawVisual.ShowBoundingBox = true;
                    RawVisual.showHideBoundingBox();
                    RootVisual.Children.Add(RawVisual);
                    smileMode        = "RAW";
                    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.");
            }
        }
Esempio n. 6
0
 internal void manualSegment(Point3DCollection points, Vector3DCollection vectors)
 {
     if (RawVisual != null && points.Count > 0)
     {
         Stopwatch stopWatch = new Stopwatch();
         stopWatch.Start();
         List <GeometryModel3D> models = RawVisual.manualSegment(points, vectors);
         if (JawVisual != null && models.Count > 0)
         {
             JawVisual.addTeeth(models);
             //add points as archs
             JawVisual.selectedGum.Archs = points;
         }
         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 + " ).", "Manual Segmentation");
     }
 }
Esempio n. 7
0
        private void FileOpenRaw()
        {
            CurrentModelPath = FileDialogService.OpenFileDialog("models", null, OpenFileFilter, ".3ds");
#if !DEBUG
            try
            {
#endif
            ///*
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            CurrentModel = ModelImporter.Load(CurrentModelPath);
            Model3DGroup group = new Model3DGroup();
            if (CurrentModel != null)
            {
                var    mb = new MeshBuilder(false, false);
                Rect3D r  = CurrentModel.Bounds;

                Model3DGroup g = (Model3DGroup)CurrentModel;
                foreach (GeometryModel3D gm in g.Children)
                {
                    MeshGeometry3D    mesh = (MeshGeometry3D)gm.Geometry;
                    Point3DCollection ind  = mesh.Positions;
                    for (int i = 0; i < ind.Count; i++)
                    {
                        var p0 = ind[i];

                        p0 = new Point3D(p0.X + (-(r.X + (r.SizeX / 2))), p0.Y + (-(r.Y + (r.SizeY / 2))), p0.Z + (-(r.Z + (r.SizeZ / 2))));

                        mb.Positions.Add(p0);
                    }

                    for (int i = 0; i < mesh.TriangleIndices.Count; i++)
                    {
                        mb.TriangleIndices.Add(mesh.TriangleIndices[i]);
                    }
                }
                var geom = new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(Colors.BlueViolet));
                geom.BackMaterial = MaterialHelper.CreateMaterial(Colors.Chocolate);
                group.Children.Add(geom);


                /*
                 * //ADD COUNTOUR
                 * var segments = MeshGeometryHelper.GetContourSegments(geom.Geometry as MeshGeometry3D, new Point3D(0,0,0), new Vector3D(0,0,1));
                 * foreach (var contour in MeshGeometryHelper.CombineSegments(segments, 1e-6))
                 * {
                 *  if (contour.Count == 0)
                 *      continue;
                 *  HelixView.Viewport.Children.Add(new TubeVisual3D { Diameter = 0.03, Path = new Point3DCollection(contour), Fill = Brushes.Green });
                 * }
                 * //*/
                /*
                 * //FIND EDGES
                 * var edges = MeshGeometryHelper.FindEdges(geom.Geometry as MeshGeometry3D);
                 * for (int i = 0; i < edges.Count; i+=2)
                 * {
                 *  Point3DCollection points = new Point3DCollection();
                 *  MeshGeometry3D ms = geom.Geometry as MeshGeometry3D;
                 *  Point3D p0 = ms.Positions[edges[i]];
                 *  Point3D p1 = ms.Positions[edges[i+1]];
                 *  points.Add(p0);
                 *  points.Add(p1);
                 *  HelixView.Viewport.Children.Add(new TubeVisual3D { Diameter = 0.03,  Path = new Point3DCollection(points), Fill = Brushes.Black});
                 * }
                 * //*/
                CurrentModel = group;
                //Transform3DGroup tgroup = new Transform3DGroup();
                //tgroup.Children.Add(new TranslateTransform3D(-(r.X + (r.SizeX / 2)), -(r.Y + (r.SizeY / 2)), -(r.Z + (r.SizeZ / 2))));
                //tgroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0,1,0), 45)));
                //CurrentModel.Transform = tgroup;
                //CurrentModel.Freeze();
                if (RawVisual == null)
                {
                    RawVisual = new RawVisual3D(RootVisual);
                }
                //RawVisual.Content = CurrentModel;
                RawVisual.Content         = CurrentModel;
                RawVisual.ShowBoundingBox = true;
                RawVisual.showHideBoundingBox();
                RootVisual.Children.Add(RawVisual);
                smileMode = "RAW";

                //if(!HelixView.Viewport.Children.Contains(RootVisual)) HelixView.Viewport.Children.Add(RootVisual);

                //ModelVisual3D v = new ModelVisual3D();
                //v.Content = CurrentModel;
                //RootVisual.Children.Add(v);

                //*/

                /*
                 * List<Point3D> pts = new List<Point3D>();
                 * pts.Add(new Point3D(30.4960694492679, 5.52461072334257, 9.44661196022868));
                 * pts.Add(new Point3D(28.0998337010248, 6.66945199865937, 14.4798151385421));
                 * pts.Add(new Point3D(28.2102015086476, -0.126599907551222, 19.0159875772706));
                 * pts.Add(new Point3D(29.7392389441408, -4.1789883548182, 14.8532955485325));
                 * pts.Add(new Point3D(28.4974026994517, -2.89939719282193, 8.04165108434179));
                 * pts.Add(new Point3D(24.1236797131164, 1.10693238332609, 6.46814289839299));
                 *
                 * for (var i = 0; i < pts.Count; i++)
                 * {
                 *  BoxVisual3D b = new BoxVisual3D();
                 *  b.Center = pts[i];
                 *  b.Length = 2;
                 *  b.Height = 2;
                 *  b.Width = 2;
                 *  HelixView.Viewport.Children.Add(b);
                 * }
                 */

                ApplicationTitle = String.Format(TitleFormatString, CurrentModelPath);
                HelixView.ZoomExtents(0);

                showStatus(stopWatch, "Loaded");
            }
#if !DEBUG
        }

        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
#endif
        }