コード例 #1
0
        protected override void DrawOverlay(Rhino.Display.DrawEventArgs e)
        {
            base.DrawOverlay(e);
            Rhino.Display.RhinoView     myViewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
            Rhino.Display.RhinoViewport viewport   = myViewport.ActiveViewport;

            for (int i = 0; i < Ids.Count; i++)
            {
                RhinoObject foundObject                   = Rhino.RhinoDoc.ActiveDoc.Objects.Find(Ids[i]);
                Rhino.Geometry.BoundingBox bbox           = foundObject.Geometry.GetBoundingBox(true);
                Rhino.Geometry.Plane       myFrustumPlane = new Rhino.Geometry.Plane();
                //viewport.GetFrustumFarPlane(out myFrustumPlane);
                //myFrustumPlane.Origin = bbox.Center;
                //Rhino.Geometry.Circle myFrustumCircle = new Rhino.Geometry.Circle();
                //myFrustumCircle.Plane = myFrustumPlane;
                //myFrustumCircle.Radius = bbox.Diagonal.Length / 2;
                //Rhino.Geometry.Curve myFrustumCurve = myFrustumCircle.ToNurbsCurve();

                //myFrustumCurve.Domain = new Rhino.Geometry.Interval(0.0,1.0);



                //e.Display.DrawDot(myFrustumCurve.PointAtNormalizedLength(0.4), i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
            }
            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }
コード例 #2
0
        camera camFromVP(Rhino.Display.RhinoViewport vp)
        {
            camera c = new camera();

            c.location    = vp.CameraLocation;
            c.target      = vp.CameraTarget;
            c.up          = vp.CameraUp;
            c.lens        = vp.Camera35mmLensLength;
            c.parallel    = vp.IsParallelProjection;
            c.size        = vp.Size;
            c.displayMode = vp.DisplayMode;
            return(c);
        }
コード例 #3
0
 void setCamera(camera c, Rhino.Display.RhinoViewport vp)
 {
     if (c.parallel)
     {
         vp.ChangeToParallelProjection(true);
     }
     else
     {
         vp.ChangeToPerspectiveProjection(false, c.lens);
     }
     vp.SetCameraLocations(c.target, c.location);
     vp.CameraUp             = c.up;
     vp.Camera35mmLensLength = c.lens;
     vp.Size        = c.size;
     vp.DisplayMode = c.displayMode;
 }
コード例 #4
0
 public RhinoViewport(RhinoViewport other)
 {
   IntPtr pOther = other.ConstPointer();
   m_ptr = UnsafeNativeMethods.CRhinoViewport_New(pOther);
   m_bDeletePtr = true;
 }
コード例 #5
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam));
            }

            if (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_KEYUP)
            {
                bool IsKeyDown   = wParam == (IntPtr)WM_KEYDOWN;
                Keys key         = (Keys)Marshal.ReadInt32(lParam);
                bool hideOverlay = true;

                if (key == Keys.Escape)
                {
                    StopWASD();
                }
                else if (key == Keys.Q)
                {
                    Q = IsKeyDown;
                }
                else if (key == Keys.W || key == Keys.Up)
                {
                    W = IsKeyDown;
                }
                else if (key == Keys.E)
                {
                    E = IsKeyDown;
                }
                else if (key == Keys.A || key == Keys.Left)
                {
                    A = IsKeyDown;
                }
                else if (key == Keys.S || key == Keys.Down)
                {
                    S = IsKeyDown;
                }
                else if (key == Keys.D || key == Keys.Right)
                {
                    D = IsKeyDown;
                }
                else if (key == Keys.LShiftKey || key == Keys.RShiftKey || key == Keys.Shift || key == Keys.ShiftKey)
                {
                    Shift = IsKeyDown;
                }
                else if (key == Keys.F1 && IsKeyDown)
                {
                    RhinoHelpers.PreviousNamedView();
                }
                else if (key == Keys.F2 && IsKeyDown)
                {
                    RhinoHelpers.NextNamedView();
                }
                else if (key == Keys.F3 && IsKeyDown)
                {
                    RhinoHelpers.SaveNamedView();
                }
                else if (key == Keys.F12 && IsKeyDown)
                {
                    RhinoHelpers.CustomScreenshot();
                }
                else if (key == Keys.Escape)
                {
                    Esc = IsKeyDown;
                }
                else if (key == Keys.Enter)
                {
                    hideOverlay = false;
                    if (IsKeyDown)
                    {
                        if (Overlay.ImageVisible)
                        {
                            Overlay.ShowImage(null);
                        }
                        else
                        {
                            Overlay.ShowImage(Properties.Resources.Info);
                        }
                    }
                }
                else if (key == Keys.PrintScreen)
                {
                    return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam)); // forward PrintScreen Key
                }
                else
                {
                    hideOverlay = false;
                }

                if (hideOverlay && Overlay.ImageVisible)
                {
                    Overlay.ShowImage(null);
                }

                //RhinoApp.WriteLine("KEY:" + key);
            }
            else if (wParam == (IntPtr)WM_MOUSEMOVE)
            {
                NativeMethods.MSLLHOOKSTRUCT data = NativeMethods.GetData((IntPtr)lParam);
                Rhino.Display.RhinoViewport  vp   = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport;
                MouseOffset = new System.Drawing.Point(data.pt.x - MidPoint.X, data.pt.y - MidPoint.Y);
            }
            else if (wParam == (IntPtr)WM_MOUSEWHEEL)
            {
                int delta = NativeMethods.GetDelta(lParam) / 120;
                if (Shift)
                {
                    RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength += delta;
                    double llength = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength;
                    Overlay.ShowMessage("lens length " + (int)Math.Round(llength));
                    RhinoDoc.ActiveDoc.Views.Redraw();
                }
                else
                {
                    if (speed + delta / 10.0 >= 0.1 && speed + delta / 10.0 <= 1.0)
                    {
                        speed += delta / 10.0;
                    }

                    else if (speed + delta >= 1 && speed + delta <= 50)
                    {
                        speed += delta;
                    }

                    Properties.Settings.Default.Speed = speed;
                    Properties.Settings.Default.Save();
                    Overlay.ShowMessage("speed " + Math.Round(speed, 1));
                }
            }
            else if ((int)wParam >= WM_LBUTTONDOWN && (int)wParam <= WM_RBUTTONUP)
            {
                //RhinoApp.WriteLine("CLICK " + DateTime.Now.Ticks);
            }
            else
            {
                return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam));
            }


            return(new IntPtr(-1));
        }
コード例 #6
0
 /// <summary>
 /// Draw a given viewport to an off-screen bitmap.
 /// </summary>
 /// <param name="viewport">Viewport to draw.</param>
 /// <param name="width">Width of target image.</param>
 /// <param name="height">Height of target image.</param>
 /// <returns>A bitmap containing the given view, or null on error.</returns>
 public static System.Drawing.Bitmap DrawToBitmap(RhinoViewport viewport, int width, int height)
 {
   if (null == viewport)
     return null;
   IntPtr pViewport = viewport.ConstPointer();
   IntPtr hBitmap = UnsafeNativeMethods.CRhinoDisplayPipeline_DrawToBitmap(pViewport, width, height);
   if (IntPtr.Zero == hBitmap)
     return null;
   return System.Drawing.Image.FromHbitmap(hBitmap);
 }
コード例 #7
0
        void RhinoApp_KeyboardEvent(int key)
        {
            //Debug.WriteLine(key);

            //myKeyPressed = key == 16;

            //return;
            if (key == 17) // ctrl key pressed
            {
                Rhino.RhinoApp.WriteLine("Fire");

                System.Drawing.Point myloc = System.Windows.Forms.Cursor.Position;
                Rhino.UI.MouseCursor.SetToolTip("heywassup");
                //Rhino.RhinoApp.WriteLine(myloc.X.ToString()+","+myloc.Y.ToString());
                Rhino.Display.RhinoView  myViewport       = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
                System.Drawing.Rectangle view_screen_rect = myViewport.ScreenRectangle;

                double XCoor = myloc.X - view_screen_rect.Left;
                double YCoor = myloc.Y - view_screen_rect.Top;
                //Rhino.RhinoApp.WriteLine(XCoor + "," + YCoor);


                Rhino.Display.RhinoViewport viewport          = myViewport.ActiveViewport;
                System.Drawing.Point        view_client_point = new System.Drawing.Point();
                view_client_point.X = (int)XCoor;
                view_client_point.Y = (int)YCoor;

                Rhino.Geometry.Line myLine = new Rhino.Geometry.Line();
                bool gotline = viewport.GetFrustumLine(view_client_point.X, view_client_point.Y, out myLine);
                if (gotline == true)
                {
                    List <Guid> myGuids        = myInterop.allGuids;
                    List <Guid> myHoveredGuids = new List <Guid>();

                    foreach (Guid guid in myGuids)
                    {
                        Rhino.DocObjects.RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
                        Rhino.Geometry.Curve[]       myCrvs;
                        Rhino.Geometry.Point3d[]     myPts;
                        bool cbx = Rhino.Geometry.Intersect.Intersection.CurveBrep(myLine.ToNurbsCurve(), foundObject.Geometry.GetBoundingBox(true).ToBrep(), 0.01, out myCrvs, out myPts);
                        if (myPts.Length > 0)
                        {
                            myHoveredGuids.Add(foundObject.Id);
                        }
                    }

                    if (myHoveredGuids.Count > 0)
                    {
                        List <double> allDists = new List <double>();
                        foreach (Guid guid in myHoveredGuids)
                        {
                            Rhino.DocObjects.RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
                            Rhino.Geometry.Point3d       myCe        = foundObject.Geometry.GetBoundingBox(true).Center;
                            double dist = myLine.To.DistanceTo(myCe);
                            allDists.Add(dist);
                        }
                        var sorted = allDists
                                     .Select((x, i) => new KeyValuePair <double, int>(x, i))
                                     .OrderBy(x => x.Key)
                                     .ToList();

                        List <double> B   = sorted.Select(x => x.Key).ToList();
                        List <int>    idx = sorted.Select(x => x.Value).ToList();
                        Rhino.RhinoApp.WriteLine(myHoveredGuids[idx[0]].ToString());
                        RhinoApp.Idle += OnIdleHover;
                    }
                    else
                    {
                        Rhino.RhinoApp.WriteLine("C'est la dech");
                    }
                }
                else
                {
                    Rhino.RhinoApp.WriteLine("no keys");
                }
            }
        }
コード例 #8
0
ファイル: PlaneGetter.cs プロジェクト: olitur/Bowerbird
        private static void DrawPlane(DisplayPipeline di, RhinoViewport vp, Plane plane)
        {
            double num;

            if (!vp.GetWorldToScreenScale(plane.Origin, out num))
                return;

            var unit = 10.0;

            if ((unit * num) < 20.0)
                unit = 20.0 / num;

            unit *= 0.2;

            var min = -5;
            var max = 5;

            for (var x = min; x <= max; x++)
            {
                var p0 = plane.PointAt(min * unit, x * unit);
                var p1 = plane.PointAt(max * unit, x * unit);

                if (x == 0)
                {
                    var origin = plane.Origin;
                    di.DrawLine(p0, origin, Color.Gray);
                    di.DrawLine(origin, p1, Color.DarkRed, 3);
                    di.DrawArrowHead(p1, p1 - origin, Color.DarkRed, 0.0, 1.0 * unit);
                }
                else
                {
                    di.DrawLine(p0, p1, Color.Gray);
                }
            }

            for (var y = min; y <= max; y++)
            {
                var p0 = plane.PointAt(y * unit, min * unit);
                var p1 = plane.PointAt(y * unit, max * unit);

                if (y == 0)
                {
                    var origin = plane.Origin;
                    di.DrawLine(p0, origin, Color.Gray);
                    di.DrawLine(origin, p1, Color.DarkGreen, 3);
                    di.DrawArrowHead(p1, p1 - origin, Color.DarkGreen, 0.0, 1.0 * unit);
                }
                else
                {
                    di.DrawLine(p0, p1, Color.Gray);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <Plane> camPlanes = new List <Plane>();

            DA.GetDataList <Plane>(0, camPlanes);

            string folder = string.Empty;

            DA.GetData <string>(1, ref folder);
            folder = Path.GetFullPath(folder);
            if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                folder += Path.DirectorySeparatorChar;
            }

            string prefix = string.Empty;

            DA.GetData <string>(2, ref prefix);

            int imageWidth = 0;

            DA.GetData <int>(3, ref imageWidth);
            imageWidth = imageWidth / 4;
            Size size = new Size(imageWidth, imageWidth);

            string displayMode = string.Empty;

            DA.GetData <string>(4, ref displayMode);

            bool run = false;

            DA.GetData <bool>(5, ref run);

            int pad = camPlanes.Count.ToString().Length;

            List <string> cubemaps = new List <string>();

            ///Save the intial camera
            saveCam = camFromVP(Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport);

            ///Set the display mode to be used for bitmaps
            DisplayModeDescription viewMode = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.DisplayMode;

            if (DisplayModeDescription.FindByName(displayMode) != null)
            {
                viewMode = DisplayModeDescription.FindByName(displayMode);
            }

            Message = viewMode.EnglishName;

            if (run)
            {
                for (int i = 0; i < camPlanes.Count; i++)
                {
                    ///Setup camera
                    Rhino.Display.RhinoView     view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
                    Rhino.Display.RhinoViewport vp   = view.ActiveViewport;

                    ///Get the bounding box of all visible object in the doc for use in setting up the camera
                    ///target so that the far frustrum plane doesn't clip anything
                    double zoomDistance = Rhino.RhinoDoc.ActiveDoc.Objects.BoundingBoxVisible.Diagonal.Length;

                    Plane    camPlane = camPlanes[i];
                    Point3d  camPoint = camPlane.Origin;
                    Vector3d camDir   = camPlane.YAxis;
                    Point3d  tarPoint = Transform.Translation(camDir * zoomDistance / 2) * camPoint;


                    vp.ChangeToPerspectiveProjection(false, 12.0);
                    //vp.Size = size;
                    vp.DisplayMode = viewMode;
                    //view.Redraw();


                    ///Set up final bitmap
                    Bitmap cubemap = new Bitmap(imageWidth * 4, imageWidth * 3);

                    ///Place the images on cubemap bitmap
                    using (Graphics gr = Graphics.FromImage(cubemap))
                    {
                        ///Grab bitmap

                        ///Set up camera directions
                        Point3d        tarLeft    = Transform.Translation(-camPlane.XAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarFront   = Transform.Translation(camPlane.YAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarRight   = Transform.Translation(camPlane.XAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarBack    = Transform.Translation(-camPlane.YAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarUp      = Transform.Translation(camPlane.ZAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarDown    = Transform.Translation(-camPlane.ZAxis * zoomDistance / 2) * camPoint;
                        List <Point3d> camTargets = new List <Point3d>()
                        {
                            tarLeft, tarFront, tarRight, tarBack, tarUp, tarDown
                        };

                        ///Loop through pano directions
                        int insertLoc = 0;
                        for (int d = 0; d < 4; d++)
                        {
                            ///Set camera direction
                            vp.SetCameraLocations(camTargets[d], camPoint);

                            ///Redraw
                            //view.Redraw();

                            gr.DrawImage(view.CaptureToBitmap(size, viewMode), insertLoc, imageWidth);

                            insertLoc = insertLoc + imageWidth;
                        }

                        ///Get up and down views
                        ///Get up view
                        vp.SetCameraLocations(tarUp, camPoint);
                        ///Redraw
                        view.Redraw();
                        var bmTop = view.CaptureToBitmap(size, viewMode);
                        bmTop.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        gr.DrawImage(bmTop, imageWidth, 0);

                        ///Get down view
                        vp.SetCameraLocations(tarDown, camPoint);

                        ///Redraw
                        view.Redraw();
                        var bmBottom = view.CaptureToBitmap(size, viewMode);
                        gr.DrawImage(view.CaptureToBitmap(size, viewMode), imageWidth, imageWidth * 2);
                    }
                    ///End cubemap construction loop

                    ///Save cubemap bitmap
                    string s        = i.ToString().PadLeft(pad, '0');
                    string saveText = folder + prefix + "_" + s + ".png";
                    cubemap.Save(saveText, System.Drawing.Imaging.ImageFormat.Png);
                    cubemaps.Add(saveText);
                    cubemap.Dispose();
                }
            }

            ///Restore initial camera
            setCamera(saveCam, Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport);
            Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();

            DA.SetDataList(0, cubemaps);
        }
コード例 #10
0
 IntPtr m_ptr; //CRhinoZBuffer*
 public ZBufferCapture(RhinoViewport viewport)
 {
   IntPtr pViewport = IntPtr.Zero;
   if( viewport!=null )
     pViewport = viewport.ConstPointer();
   m_ptr = UnsafeNativeMethods.CRhinoZBuffer_New(pViewport);
 }
コード例 #11
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <Plane> camPlanes = new List <Plane>();

            DA.GetDataList <Plane>(0, camPlanes);

            string folder = string.Empty;

            DA.GetData <string>(1, ref folder);
            bool saveCubemaps = !string.IsNullOrEmpty(folder);

            if (saveCubemaps)
            {
                folder = Path.GetFullPath(folder);
                if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    folder += Path.DirectorySeparatorChar;
                }
            }

            string prefix = string.Empty;

            DA.GetData <string>(2, ref prefix);

            int imageWidth = 0;

            DA.GetData <int>(3, ref imageWidth);
            imageWidth = imageWidth / 4;
            Size size = new Size(imageWidth, imageWidth);

            string displayMode = string.Empty;

            DA.GetData <string>(4, ref displayMode);

            List <Color> colors = new List <Color>();

            DA.GetDataList <Color>(5, colors);
            bool filterColors = colors.Any();

            GH_Structure <GH_Mesh> ghObstacles = new GH_Structure <GH_Mesh>();

            DA.GetDataTree <GH_Mesh>(6, out ghObstacles);

            ///Flatten obstacle meshes and join them into one mesh
            ghObstacles.FlattenData();
            Mesh obstacles = new Mesh();
            bool showRays  = false;

            if (ghObstacles.DataCount > 0)
            {
                showRays = true;
                foreach (var obstacle in ghObstacles)
                {
                    Mesh temp = new Mesh();
                    GH_Convert.ToMesh(obstacle, ref temp, GH_Conversion.Primary);
                    obstacles.Append(temp);
                }
            }


            bool run = false;

            DA.GetData <bool>(7, ref run);

            int pad = camPlanes.Count.ToString().Length;

            List <string> cubemaps = new List <string>();

            GH_Structure <GH_Line>   rayTree   = new GH_Structure <GH_Line>();
            GH_Structure <GH_Colour> colorTree = new GH_Structure <GH_Colour>();

            ///Save the intial camera
            saveCam = camFromVP(Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport);

            ///Set the display mode to be used for bitmaps
            ///TODO: Add menu item to use "Heron View Analysis" display mode
            DisplayModeDescription viewMode = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.DisplayMode;

            if (DisplayModeDescription.FindByName(displayMode) != null)
            {
                viewMode = DisplayModeDescription.FindByName(displayMode);
            }

            Message = viewMode.EnglishName;

            if (run)
            {
                for (int i = 0; i < camPlanes.Count; i++)
                {
                    ///TODO: setup ability to save cameras to the Rhino doc
                    ///Setup camera
                    Rhino.Display.RhinoView     view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
                    Rhino.Display.RhinoViewport vp   = view.ActiveViewport;

                    ///Get the bounding box of all visible object in the doc for use in setting up the camera
                    ///target so that the far frustrum plane doesn't clip anything
                    double zoomDistance = Rhino.RhinoDoc.ActiveDoc.Objects.BoundingBoxVisible.Diagonal.Length;

                    Plane    camPlane = camPlanes[i];
                    Point3d  camPoint = camPlane.Origin;
                    Vector3d camDir   = camPlane.YAxis;
                    Point3d  tarPoint = Transform.Translation(camDir * zoomDistance / 2) * camPoint;


                    vp.ChangeToPerspectiveProjection(false, 12.0);
                    vp.Size        = size;
                    vp.DisplayMode = viewMode;
                    //view.Redraw();

                    ///Set up final bitmap
                    Bitmap cubemap = new Bitmap(imageWidth * 4, imageWidth * 3);

                    ///Place the images on cubemap bitmap
                    using (Graphics gr = Graphics.FromImage(cubemap))
                    {
                        ///Grab bitmap

                        ///Set up camera directions
                        Point3d        tarLeft    = Transform.Translation(-camPlane.XAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarFront   = Transform.Translation(camPlane.YAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarRight   = Transform.Translation(camPlane.XAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarBack    = Transform.Translation(-camPlane.YAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarUp      = Transform.Translation(camPlane.ZAxis * zoomDistance / 2) * camPoint;
                        Point3d        tarDown    = Transform.Translation(-camPlane.ZAxis * zoomDistance / 2) * camPoint;
                        List <Point3d> camTargets = new List <Point3d>()
                        {
                            tarLeft, tarFront, tarRight, tarBack, tarUp, tarDown
                        };

                        ///Loop through pano directions
                        int insertLoc = 0;
                        for (int d = 0; d < 4; d++)
                        {
                            ///Set camera direction
                            vp.SetCameraLocations(camTargets[d], camPoint);
                            //view.Redraw();

                            Bitmap bitmap = new Bitmap(view.CaptureToBitmap(size, viewMode));

                            if (saveCubemaps)
                            {
                                gr.DrawImage(bitmap, insertLoc, imageWidth);
                            }

                            if (showRays)
                            {
                                GH_MemoryBitmap sampler = new GH_MemoryBitmap(bitmap);
                                Color           col     = Color.Transparent;
                                for (int x = 0; x < bitmap.Width; x++)
                                {
                                    for (int y = 0; y < bitmap.Height; y++)
                                    {
                                        if (sampler.Sample(x, y, ref col))
                                        {
                                            if (colors.Contains(col))
                                            {
                                                GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                                Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                                Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                                double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                                Point3d rayIntersection = ray.PointAt(rayEnd);
                                                Line    ln = new Line(camPoint, rayIntersection);

                                                if (ln.IsValid & rayEnd > 0)
                                                {
                                                    rayTree.Append(new GH_Line(ln), path);
                                                    colorTree.Append(new GH_Colour(col), path);
                                                }
                                            }
                                            else if (!filterColors)
                                            {
                                                colors.Add(col);
                                                GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                                Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                                Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                                double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                                Point3d rayIntersection = ray.PointAt(rayEnd);
                                                Line    ln = new Line(camPoint, rayIntersection);

                                                if (ln.IsValid & rayEnd > 0)
                                                {
                                                    rayTree.Append(new GH_Line(ln), path);
                                                    colorTree.Append(new GH_Colour(col), path);
                                                }
                                            }
                                        }
                                    }
                                }
                                sampler.Release(false);
                            }

                            insertLoc = insertLoc + imageWidth;

                            bitmap.Dispose();
                        }


                        ///Get up and down views

                        ///Get up view
                        vp.SetCameraLocations(tarUp, camPoint);
                        view.Redraw();

                        Bitmap bitmapUp = new Bitmap(view.CaptureToBitmap(size, viewMode));

                        if (showRays)
                        {
                            GH_MemoryBitmap sampler = new GH_MemoryBitmap(bitmapUp);
                            Color           col     = Color.Transparent;
                            for (int x = 0; x < bitmapUp.Width; x++)
                            {
                                for (int y = 0; y < bitmapUp.Height; y++)
                                {
                                    if (sampler.Sample(x, y, ref col))
                                    {
                                        if (colors.Contains(col))
                                        {
                                            GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                            Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                            Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                            double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                            Point3d rayIntersection = ray.PointAt(rayEnd);
                                            Line    ln = new Line(camPoint, rayIntersection);

                                            if (ln.IsValid & rayEnd > 0)
                                            {
                                                rayTree.Append(new GH_Line(ln), path);
                                                colorTree.Append(new GH_Colour(col), path);
                                            }
                                        }
                                        else if (!filterColors)
                                        {
                                            colors.Add(col);
                                            GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                            Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                            Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                            double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                            Point3d rayIntersection = ray.PointAt(rayEnd);
                                            Line    ln = new Line(camPoint, rayIntersection);

                                            if (ln.IsValid & rayEnd > 0)
                                            {
                                                rayTree.Append(new GH_Line(ln), path);
                                                colorTree.Append(new GH_Colour(col), path);
                                            }
                                        }
                                    }
                                }
                            }
                            sampler.Release(false);
                        }

                        bitmapUp.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        if (saveCubemaps)
                        {
                            gr.DrawImage(bitmapUp, imageWidth, 0);
                        }

                        bitmapUp.Dispose();


                        ///Get down view
                        vp.SetCameraLocations(tarDown, camPoint);
                        view.Redraw();

                        Bitmap bitmapDown = new Bitmap(view.CaptureToBitmap(size, viewMode));

                        if (saveCubemaps)
                        {
                            gr.DrawImage(bitmapDown, imageWidth, imageWidth * 2);
                        }

                        if (showRays)
                        {
                            GH_MemoryBitmap sampler = new GH_MemoryBitmap(bitmapDown);
                            Color           col     = Color.Transparent;
                            for (int x = 0; x < bitmapDown.Width; x++)
                            {
                                for (int y = 0; y < bitmapDown.Height; y++)
                                {
                                    if (sampler.Sample(x, y, ref col))
                                    {
                                        if (colors.Contains(col))
                                        {
                                            GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                            Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                            Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                            double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                            Point3d rayIntersection = ray.PointAt(rayEnd);
                                            Line    ln = new Line(camPoint, rayIntersection);

                                            if (ln.IsValid & rayEnd > 0)
                                            {
                                                rayTree.Append(new GH_Line(ln), path);
                                                colorTree.Append(new GH_Colour(col), path);
                                            }
                                        }

                                        else if (!filterColors)
                                        {
                                            colors.Add(col);
                                            GH_Path path = new GH_Path(i, colors.IndexOf(col));

                                            Line line = vp.ClientToWorld(new System.Drawing.Point(x, y));

                                            Ray3d   ray             = new Ray3d(vp.CameraLocation, -line.Direction);
                                            double  rayEnd          = (double)Rhino.Geometry.Intersect.Intersection.MeshRay(obstacles, ray);
                                            Point3d rayIntersection = ray.PointAt(rayEnd);
                                            Line    ln = new Line(camPoint, rayIntersection);

                                            if (ln.IsValid & rayEnd > 0)
                                            {
                                                rayTree.Append(new GH_Line(ln), path);
                                                colorTree.Append(new GH_Colour(col), path);
                                            }
                                        }
                                    }
                                }
                            }
                            sampler.Release(false);
                        }

                        bitmapDown.Dispose();
                    }
                    ///End pano directions loop

                    if (saveCubemaps)
                    {
                        ///Save cubemap bitmap
                        string s        = i.ToString().PadLeft(pad, '0');
                        string saveText = folder + prefix + "_" + s + ".png";
                        cubemap.Save(saveText, System.Drawing.Imaging.ImageFormat.Png);
                        cubemaps.Add(saveText);
                    }
                    cubemap.Dispose();
                }
            }

            ///Restore initial camera
            setCamera(saveCam, Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport);
            Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();

            DA.SetDataList(0, cubemaps);
            DA.SetDataTree(1, rayTree);
            DA.SetDataTree(2, colorTree);
        }
コード例 #12
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool    run      = false;
            Point3d location = new Point3d();
            Point3d target   = new Point3d();
            double  length   = 50;
            double  bias     = 0;
            int     type     = 0;
            Point3d uv       = new Point3d();

            Rhino.Display.RhinoViewport viewPort = null;

            DA.GetData("Run", ref run);
            DA.GetData("CameraLocation", ref location);
            DA.GetData("CameraTarget", ref target);
            DA.GetData("FocalLength", ref length);
            DA.GetData("Bias", ref bias);
            DA.GetData("CameraType", ref type);
            DA.GetData("UV", ref uv);

            string name     = "";
            bool   flag     = true;
            bool   useFrame = false;

            if (DA.GetData("ViewName", ref name))
            {
                foreach (RhinoView view in Rhino.RhinoDoc.ActiveDoc.Views)
                {
                    if (view.ActiveViewport.Name == name)
                    {
                        viewPort = view.ActiveViewport;
                        flag     = false;
                        break;
                    }
                }
            }

            if (flag)
            {
                try
                {
                    viewPort = Frame.Component.RhinoView.ActiveViewport;
                    useFrame = true;
                }
                catch
                {
                    viewPort = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport;
                }
            }
            Message = viewPort.Name;
            //viewPort.DisplayMode.DisplayAttributes.FillMode = DisplayPipelineAttributes.FrameBufferFillMode.SolidColor;
            //viewPort.DisplayMode.DisplayAttributes.SetFill()

            if (run)
            {
                //basic settings
                viewPort.SetCameraLocations(target, location);
                viewPort.CameraUp = Vector3d.ZAxis;

                switch (type)
                {
                case 0:
                    viewPort.ChangeToParallelProjection(true);
                    break;

                case 1:
                    viewPort.ChangeToTwoPointPerspectiveProjection(length);
                    break;

                case 2:
                    viewPort.ChangeToPerspectiveProjection(true, length);
                    break;

                default:
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input Type must be in 0-2!");
                    viewPort.ChangeToPerspectiveProjection(true, length);
                    break;
                }

                if (((Param_Number)Params.Input[5]).UseDegrees)
                {
                    bias = RhinoMath.ToRadians(bias);
                }
                Vector3d z = Vector3d.ZAxis;
                z.Rotate(bias, viewPort.CameraZ);
                viewPort.CameraUp = z;

                Point3d[] nearCorners = viewPort.GetNearRect();
                Point3d[] farCorners  = viewPort.GetFarRect();


                Plane  targetPl = new Plane(target, viewPort.CameraX, viewPort.CameraY);
                double param;
                Line   ln1 = new Line(nearCorners[0], farCorners[0]);
                Line   ln2 = new Line(nearCorners[3], farCorners[3]);
                Intersection.LinePlane(ln1, targetPl, out param);
                Rectangle3d rectTarget = new Rectangle3d(targetPl, ln1.PointAt(param), ln2.PointAt(param));
                Point3d     X          = rectTarget.PointAt(uv.X, uv.Y);

                viewPort.SetCameraLocations(NewTarget(location, target, X), location);

                nearCorners = viewPort.GetNearRect();
                farCorners  = viewPort.GetFarRect();
                Point3d[] corners = new Point3d[4]
                {
                    (nearCorners[0] * 0.99 + farCorners[0] * 0.01),
                    (nearCorners[1] * 0.99 + farCorners[1] * 0.01),
                    (nearCorners[2] * 0.99 + farCorners[2] * 0.01),
                    (nearCorners[3] * 0.99 + farCorners[3] * 0.01)
                };

                Plane       recPlane = new Plane(corners[0], corners[1], corners[2]);
                Rectangle3d rect     = new Rectangle3d(recPlane, corners[0], corners[3]);


                double viewRectWidth = corners[0].DistanceTo(corners[1]);
                double unitPerPx;
                if (useFrame)
                {
                    unitPerPx = viewRectWidth / (Frame.Component.Play ? Frame.Component.PictWidth : viewPort.Size.Width);
                    Message  += "\n" + (Frame.Component.Play ? "Product" : "Preview");
                }
                else
                {
                    unitPerPx = viewRectWidth / viewPort.Size.Width;
                }



                DA.SetData("Rectangle", rect);
                DA.SetData("UnitPerPx", unitPerPx);
            }
        }
コード例 #13
0
        protected override void DrawForeground(DrawEventArgs e)
        {
            base.DrawForeground(e);



            RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(Id);

            Rhino.Display.RhinoView     myViewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
            Rhino.Display.RhinoViewport viewport   = myViewport.ActiveViewport;


            e.Display.EnableDepthWriting(false);
            switch (foundObject.ObjectType)
            {
            case Rhino.DocObjects.ObjectType.Point:
                break;

            case Rhino.DocObjects.ObjectType.Curve:
                break;

            case Rhino.DocObjects.ObjectType.Extrusion:
                Rhino.Geometry.Extrusion myExtru = (Rhino.Geometry.Extrusion)foundObject.Geometry;
                Rhino.Geometry.Brep      myBrep  = myExtru.ToBrep();
                Mesh[] extruMeshes     = Rhino.Geometry.Mesh.CreateFromBrep(myBrep);
                Mesh   globalExtruMesh = new Rhino.Geometry.Mesh();
                foreach (Mesh m in extruMeshes)
                {
                    globalExtruMesh.Append(m);
                }
                Polyline[] myExtruPoly = globalExtruMesh.GetOutlines(viewport);
                foreach (Polyline poly in myExtruPoly)
                {
                    e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                }
                break;

            case Rhino.DocObjects.ObjectType.Brep:
                Mesh[] meshes     = Rhino.Geometry.Mesh.CreateFromBrep((Brep)foundObject.Geometry);
                Mesh   globalMesh = new Rhino.Geometry.Mesh();
                foreach (Mesh m in meshes)
                {
                    globalMesh.Append(m);
                }
                Polyline[] myPolys2 = globalMesh.GetOutlines(viewport);
                foreach (Polyline poly in myPolys2)
                {
                    e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                }
                break;

            case Rhino.DocObjects.ObjectType.Mesh:
                Mesh       mesh        = foundObject.Geometry as Rhino.Geometry.Mesh;
                Polyline[] meshOutline = mesh.GetOutlines(viewport);
                foreach (Polyline poly in meshOutline)
                {
                    e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                }
                break;

            case Rhino.DocObjects.ObjectType.TextDot:
                break;

            case Rhino.DocObjects.ObjectType.Annotation:
                break;
            }
            e.Display.EnableDepthWriting(true);
            e.Display.EnableDepthWriting(false);

            if (Edges.Count > 0)
            {
                System.Drawing.Color colorKid = System.Drawing.Color.LightCoral;
                foreach (List <Guid> li in Edges)
                {
                    RhinoObject            foundObject0 = Rhino.RhinoDoc.ActiveDoc.Objects.Find(li[0]);
                    RhinoObject            foundObject1 = Rhino.RhinoDoc.ActiveDoc.Objects.Find(li[1]);
                    Rhino.Geometry.Point3d ce0          = new Rhino.Geometry.Point3d();
                    Rhino.Geometry.Point3d ce1          = new Rhino.Geometry.Point3d();

                    switch (foundObject0.ObjectType)
                    {
                    case Rhino.DocObjects.ObjectType.Point:
                        ce0 = ((Rhino.Geometry.Point)foundObject0.Geometry).Location;
                        break;

                    case Rhino.DocObjects.ObjectType.Curve:
                        Rhino.Geometry.Curve myCurve = (Rhino.Geometry.Curve)foundObject0.Geometry;
                        myCurve.Domain = new Rhino.Geometry.Interval(0, 1);
                        ce0            = myCurve.PointAtNormalizedLength(0.5);
                        break;

                    case Rhino.DocObjects.ObjectType.Extrusion:
                        Rhino.Geometry.Extrusion myExtru         = (Rhino.Geometry.Extrusion)foundObject0.Geometry;
                        Rhino.Geometry.Point3d   myExtruCentroid = Rhino.Geometry.AreaMassProperties.Compute(myExtru.ToBrep()).Centroid;
                        ce0 = myExtruCentroid;

                        Rhino.Geometry.Brep myBrep = myExtru.ToBrep();
                        Mesh[] extruMeshes         = Rhino.Geometry.Mesh.CreateFromBrep(myBrep);
                        Mesh   globalExtruMesh     = new Rhino.Geometry.Mesh();
                        foreach (Mesh m in extruMeshes)
                        {
                            globalExtruMesh.Append(m);
                        }
                        Polyline[] myExtruPoly = globalExtruMesh.GetOutlines(viewport);
                        foreach (Polyline poly in myExtruPoly)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }

                        break;

                    case Rhino.DocObjects.ObjectType.Brep:
                        Rhino.Geometry.Point3d myBrepCentroid = ((Brep)foundObject0.Geometry).GetBoundingBox(true).Center;
                        ce0 = myBrepCentroid;

                        Mesh[] meshes     = Rhino.Geometry.Mesh.CreateFromBrep((Brep)foundObject0.Geometry);
                        Mesh   globalMesh = new Rhino.Geometry.Mesh();
                        foreach (Mesh m in meshes)
                        {
                            globalMesh.Append(m);
                        }
                        Polyline[] myPolys2 = globalMesh.GetOutlines(viewport);
                        foreach (Polyline poly in myPolys2)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }

                        break;

                    case Rhino.DocObjects.ObjectType.Mesh:
                        var mesh = foundObject0.Geometry as Rhino.Geometry.Mesh;

                        Polyline[] meshOutline = mesh.GetOutlines(viewport);
                        foreach (Polyline poly in meshOutline)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }

                        Rhino.Geometry.Point3d myMeshCentroid = mesh.GetBoundingBox(true).Center;
                        ce0 = myMeshCentroid;



                        break;

                    case Rhino.DocObjects.ObjectType.TextDot:
                        // todo
                        break;

                    case Rhino.DocObjects.ObjectType.Annotation:
                        // todo
                        break;
                    }

                    switch (foundObject1.ObjectType)
                    {
                    case Rhino.DocObjects.ObjectType.Point:
                        ce1 = ((Rhino.Geometry.Point)foundObject1.Geometry).Location;
                        break;

                    case Rhino.DocObjects.ObjectType.Curve:
                        Rhino.Geometry.Curve myCurve = (Rhino.Geometry.Curve)foundObject1.Geometry;
                        myCurve.Domain = new Rhino.Geometry.Interval(0, 1);
                        ce1            = myCurve.PointAtNormalizedLength(0.5);
                        break;

                    case Rhino.DocObjects.ObjectType.Extrusion:
                        Rhino.Geometry.Extrusion myExtru         = (Rhino.Geometry.Extrusion)foundObject1.Geometry;
                        Rhino.Geometry.Point3d   myExtruCentroid = Rhino.Geometry.AreaMassProperties.Compute(myExtru.ToBrep()).Centroid;
                        ce1 = myExtruCentroid;


                        Rhino.Geometry.Brep myBrep = myExtru.ToBrep();
                        Mesh[] extruMeshes         = Rhino.Geometry.Mesh.CreateFromBrep(myBrep);
                        Mesh   globalExtruMesh     = new Rhino.Geometry.Mesh();
                        foreach (Mesh m in extruMeshes)
                        {
                            globalExtruMesh.Append(m);
                        }
                        Polyline[] myExtruPoly = globalExtruMesh.GetOutlines(viewport);
                        foreach (Polyline poly in myExtruPoly)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }

                        break;

                    case Rhino.DocObjects.ObjectType.Brep:
                        Rhino.Geometry.Point3d myBrepCentroid = ((Brep)foundObject1.Geometry).GetBoundingBox(true).Center;
                        ce1 = myBrepCentroid;

                        Mesh[] meshes     = Rhino.Geometry.Mesh.CreateFromBrep((Brep)foundObject1.Geometry);
                        Mesh   globalMesh = new Rhino.Geometry.Mesh();
                        foreach (Mesh m in meshes)
                        {
                            globalMesh.Append(m);
                        }
                        Polyline[] myPolys2 = globalMesh.GetOutlines(viewport);
                        foreach (Polyline poly in myPolys2)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }

                        break;

                    case Rhino.DocObjects.ObjectType.Mesh:
                        var mesh = foundObject1.Geometry as Rhino.Geometry.Mesh;
                        Rhino.Geometry.Point3d myMeshCentroid = mesh.GetBoundingBox(true).Center;
                        ce1 = myMeshCentroid;


                        Polyline[] meshOutline = mesh.GetOutlines(viewport);
                        foreach (Polyline poly in meshOutline)
                        {
                            e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Red, 6);
                        }


                        break;

                    case Rhino.DocObjects.ObjectType.TextDot:
                        // todo
                        break;

                    case Rhino.DocObjects.ObjectType.Annotation:
                        // todo
                        break;
                    }


                    Rhino.Geometry.Line graphEdge = new Rhino.Geometry.Line();
                    graphEdge.From = ce0;
                    graphEdge.To   = ce1;

                    e.Display.DrawLineArrow(graphEdge, System.Drawing.Color.DarkRed, 7, 4);
                }
            }
            e.Display.EnableDepthWriting(true);

            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }
コード例 #14
0
        protected override void PreDrawObjects(Rhino.Display.DrawEventArgs e)
        {
            base.PreDrawObjects(e);

            RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(Id);

            Rhino.Geometry.BoundingBox bbox = foundObject.Geometry.GetBoundingBox(true);
            bbox.Inflate(2);
            e.Display.EnableDepthWriting(false);
            List <Rhino.Geometry.Point3d> bboxCorners = bbox.GetCorners().ToList();
            List <Rhino.Geometry.Line>    bboxEdges   = bbox.GetEdges().ToList();

            //e.Display.DrawBoxCorners(bbox, System.Drawing.Color.Red, 3, 4);


            Rhino.Display.RhinoView     myViewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
            Rhino.Display.RhinoViewport viewport   = myViewport.ActiveViewport;

            e.Display.EnableDepthWriting(true);
            e.Display.EnableDepthWriting(false);
            switch (foundObject.ObjectType)
            {
            case Rhino.DocObjects.ObjectType.Point:
                e.Display.DrawPoint(((Rhino.Geometry.Point)foundObject.Geometry).Location, PointStyle.X, 2, myCol);
                break;

            case Rhino.DocObjects.ObjectType.Curve:
                e.Display.DrawCurve((Rhino.Geometry.Curve)foundObject.Geometry, myCol, 4);
                break;

            case Rhino.DocObjects.ObjectType.Extrusion:
                DisplayMaterial eMaterial = new DisplayMaterial(myCol, 0.5);
                e.Display.DrawBrepShaded(((Rhino.Geometry.Extrusion)foundObject.Geometry).ToBrep(), eMaterial);
                break;

            case Rhino.DocObjects.ObjectType.Brep:
                DisplayMaterial bMaterial = new DisplayMaterial(myCol, 0.5);
                e.Display.DrawBrepShaded((Brep)foundObject.Geometry, bMaterial);

                Mesh[] meshes     = Rhino.Geometry.Mesh.CreateFromBrep((Brep)foundObject.Geometry);
                Mesh   globalMesh = new Rhino.Geometry.Mesh();
                foreach (Mesh m in meshes)
                {
                    globalMesh.Append(m);
                }
                Polyline[] myPolys2 = globalMesh.GetOutlines(viewport);
                foreach (Polyline poly in myPolys2)
                {
                    e.Display.DrawCurve(poly.ToNurbsCurve(), Color.Black, 6);
                }
                break;

            case Rhino.DocObjects.ObjectType.Mesh:
                var mesh = foundObject.Geometry as Rhino.Geometry.Mesh;
                if (mesh.VertexColors.Count > 0)
                {
                    for (int i = 0; i < mesh.VertexColors.Count; i++)
                    {
                        mesh.VertexColors[i] = Color.FromArgb(100, mesh.VertexColors[i]);
                    }

                    e.Display.DrawMeshFalseColors(mesh);
                }
                else
                {
                    DisplayMaterial mMaterial = new DisplayMaterial(myCol, 0.5);
                    e.Display.DrawMeshShaded(mesh, mMaterial);
                }
                //e.Display.DrawMeshWires((Mesh)obj, Color.DarkGray);
                break;

            case Rhino.DocObjects.ObjectType.TextDot:
                //e.Display.Draw3dText( ((TextDot)obj).Text, Colors[count], new Plane(((TextDot)obj).Point));
                var textDot = (TextDot)foundObject.Geometry;
                e.Display.DrawDot(textDot.Point, textDot.Text, myCol, Color.White);

                break;

            case Rhino.DocObjects.ObjectType.Annotation:

                var textObj = (Rhino.Geometry.TextEntity)foundObject.Geometry;
                e.Display.Draw3dText(textObj.Text, Color.Black, textObj.Plane, textObj.TextHeight, Rhino.RhinoDoc.ActiveDoc.Fonts[textObj.FontIndex].FaceName);
                break;
            }
            e.Display.EnableDepthWriting(true);



            List <Rhino.Geometry.Line> myEdges = new List <Rhino.Geometry.Line>();

            if (Edges.Count > 0)
            {
                System.Drawing.Color colorKid = System.Drawing.Color.LightCoral;
                foreach (List <Guid> li in Edges)
                {
                    RhinoObject foundObject0 = Rhino.RhinoDoc.ActiveDoc.Objects.Find(li[0]);
                    RhinoObject foundObject1 = Rhino.RhinoDoc.ActiveDoc.Objects.Find(li[1]);
                }
            }
            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }