///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();
              go.SetCommandPrompt("Select curve");
              go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object);
              go.EnableSubObjectSelect(false);
              go.GetObjects(1, 1);
              if (go.CommandResult() != IRhinoCommand.result.success)
            return go.CommandResult();

              IOnCurve curve = go.Object(0).Curve();
              if (null == curve)
            return IRhinoCommand.result.failure;

              // Several types of OnCurve objects can have the form of a polyline,
              // including OnLineCurve, a degree 1 OnNurbsCurve, ON_PolylineCurve,
              // and ON_PolyCurve (whose segments form a polyline). OnCurve.IsPolyline
              // tests a curve to see if it can be represented as a polyline.
              ArrayOn3dPoint points = new ArrayOn3dPoint(64);
              int point_count = curve.IsPolyline(points);
              if (point_count > 0)
              {
            string point_str = string.Empty;
            for (int i = 0; i < point_count; i++)
            {
              point_str = string.Empty;
              RhUtil.RhinoFormatPoint(points[i], ref point_str);
              RhUtil.RhinoApp().Print(string.Format("Point {0} = {1}\n", i, point_str));
            }
              }

              return IRhinoCommand.result.success;
        }
Example #2
0
 public SampleCsSurfaceDirectionConduit()
     : base(new MSupportChannels(MSupportChannels.SC_DRAWOVERLAY), false)
 {
     m_brep    = null;
     m_bFlip   = false;
     m_points  = new ArrayOn3dPoint();
     m_normals = new ArrayOn3dVector();
 }
Example #3
0
            public VoxelGrid(RhCommon_Scene ModelSurfaces, List <IOn3dPoint> Pts, int VG_Domain)
            {
                VoxelCT        = VG_Domain;
                VoxelInventory = new List <int> [VoxelCT, VoxelCT, VoxelCT];
                Voxel          = new List <On3dPoint> [VoxelCT, VoxelCT, VoxelCT];
                IRhinoObject[] Surfaces = new IRhinoObject[ModelSurfaces.Count()];

                OnBoundingBox  TightOBox = new OnBoundingBox();
                On3dPoint      BoxMin    = new On3dPoint();
                On3dPoint      BoxMax    = new On3dPoint();
                ArrayOn3dPoint Points    = new ArrayOn3dPoint();

                for (int i = 0; i < Pts.Count; i++)
                {
                    Points.Append(Pts[i]);
                }

                RhUtil.RhinoGetTightBoundingBox(Surfaces, ref TightOBox, false, null);
                TightOBox.Set(Points, true);
                OverallBBox = new OnBoundingBox(new On3dPoint(TightOBox.Min().x - 1, TightOBox.Min().y - 1, TightOBox.Min().z - 1), new On3dPoint(TightOBox.Max().x + 1, TightOBox.Max().y + 1, TightOBox.Max().z + 1));

                this.X_Incr = (OverallBBox.Max().x - OverallBBox.Min().x) / VoxelCT;
                this.Y_Incr = (OverallBBox.Max().y - OverallBBox.Min().y) / VoxelCT;
                this.Z_Incr = (OverallBBox.Max().z - OverallBBox.Min().z) / VoxelCT;

                //For((int XBox = 0; XBox < VoxelCT; XBox++)
                Parallel.For(0, VoxelCT, XBox =>
                {
                    RhUtil.RhinoApp().SetStatusBarMessagePane(string.Format("Voxelizing: {0}%", Math.Round((double)XBox / VoxelCT - 1, 2) * 100));
                    for (int YBox = 0; YBox < VoxelCT; YBox++)
                    {
                        for (int ZBox = 0; ZBox < VoxelCT; ZBox++)
                        {
                            BoxMin = new On3dPoint((OverallBBox.Min().x + this.X_Incr * XBox) - X_Incr / 10, (OverallBBox.Min().y + this.Y_Incr * YBox) - Y_Incr / 10, (OverallBBox.Min().z + this.Z_Incr * ZBox) - Z_Incr / 10);
                            BoxMax = new On3dPoint((OverallBBox.Min().x + this.X_Incr * (XBox + 1)) + X_Incr / 10, (OverallBBox.Min().y + this.Y_Incr * (YBox + 1)) + Y_Incr / 10, (OverallBBox.Min().z + this.Z_Incr * (ZBox + 1)) + X_Incr / 10);
                            this.Voxel[XBox, YBox, ZBox] = new List <On3dPoint>();
                            this.Voxel[XBox, YBox, ZBox].Add(BoxMin);
                            this.Voxel[XBox, YBox, ZBox].Add(BoxMax);
                            this.VoxelInventory[XBox, YBox, ZBox] = new List <int>();
                            for (int Index = 0; Index < ModelSurfaces.Count(); Index++)
                            {
                                OnBoundingBox TestBox = new OnBoundingBox();
                                TestBox = new OnBoundingBox(this.Voxel[XBox, YBox, ZBox][0], this.Voxel[XBox, YBox, ZBox][1]);
                                if (BoxIntersection(ModelSurfaces, TestBox, Index))
                                {
                                    this.VoxelInventory[XBox, YBox, ZBox].Add(Index);
                                }
                            }
                        }
                    }
                });
            }
            public VoxelGrid(RhCommon_Scene ModelSurfaces, List<IOn3dPoint> Pts, int VG_Domain)
            {
                VoxelCT = VG_Domain;
                VoxelInventory = new List<int>[VoxelCT, VoxelCT, VoxelCT];
                Voxel = new List<On3dPoint>[VoxelCT, VoxelCT, VoxelCT];
                IRhinoObject[] Surfaces = new IRhinoObject[ModelSurfaces.Count()];

                OnBoundingBox TightOBox = new OnBoundingBox();
                On3dPoint BoxMin = new On3dPoint();
                On3dPoint BoxMax = new On3dPoint();
                ArrayOn3dPoint Points = new ArrayOn3dPoint();

                for (int i = 0; i < Pts.Count; i++)
                {
                    Points.Append(Pts[i]);
                }

                RhUtil.RhinoGetTightBoundingBox(Surfaces, ref TightOBox, false, null);
                TightOBox.Set(Points, true);
                OverallBBox = new OnBoundingBox(new On3dPoint(TightOBox.Min().x - 1, TightOBox.Min().y - 1, TightOBox.Min().z - 1), new On3dPoint(TightOBox.Max().x + 1, TightOBox.Max().y + 1, TightOBox.Max().z + 1));

                this.X_Incr = (OverallBBox.Max().x - OverallBBox.Min().x) / VoxelCT;
                this.Y_Incr = (OverallBBox.Max().y - OverallBBox.Min().y) / VoxelCT;
                this.Z_Incr = (OverallBBox.Max().z - OverallBBox.Min().z) / VoxelCT;

                //For((int XBox = 0; XBox < VoxelCT; XBox++)
                Parallel.For(0, VoxelCT, XBox =>
                {
                    RhUtil.RhinoApp().SetStatusBarMessagePane(string.Format("Voxelizing: {0}%", Math.Round((double)XBox / VoxelCT-1, 2) * 100));
                    for (int YBox = 0; YBox < VoxelCT; YBox++)
                    {
                        for (int ZBox = 0; ZBox < VoxelCT; ZBox++)
                        {
                            BoxMin = new On3dPoint((OverallBBox.Min().x + this.X_Incr * XBox) - X_Incr / 10, (OverallBBox.Min().y + this.Y_Incr * YBox) - Y_Incr / 10, (OverallBBox.Min().z + this.Z_Incr * ZBox) - Z_Incr / 10);
                            BoxMax = new On3dPoint((OverallBBox.Min().x + this.X_Incr * (XBox + 1)) + X_Incr / 10, (OverallBBox.Min().y + this.Y_Incr * (YBox + 1)) + Y_Incr / 10, (OverallBBox.Min().z + this.Z_Incr * (ZBox + 1)) + X_Incr / 10);
                            this.Voxel[XBox, YBox, ZBox] = new List<On3dPoint>();
                            this.Voxel[XBox, YBox, ZBox].Add(BoxMin);
                            this.Voxel[XBox, YBox, ZBox].Add(BoxMax);
                            this.VoxelInventory[XBox, YBox, ZBox] = new List<int>();
                            for (int Index = 0; Index < ModelSurfaces.Count(); Index++)
                            {
                                OnBoundingBox TestBox = new OnBoundingBox();
                                TestBox = new OnBoundingBox(this.Voxel[XBox, YBox, ZBox][0], this.Voxel[XBox, YBox, ZBox][1]);
                                if (BoxIntersection(ModelSurfaces, TestBox, Index))
                                {
                                    this.VoxelInventory[XBox, YBox, ZBox].Add(Index);
                                }
                            }
                        }
                    }
                });
            }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();

            go.SetCommandPrompt("Select curve");
            go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object);
            go.EnableSubObjectSelect(false);
            go.GetObjects(1, 1);
            if (go.CommandResult() != IRhinoCommand.result.success)
            {
                return(go.CommandResult());
            }

            IOnCurve curve = go.Object(0).Curve();

            if (null == curve)
            {
                return(IRhinoCommand.result.failure);
            }

            // Several types of OnCurve objects can have the form of a polyline,
            // including OnLineCurve, a degree 1 OnNurbsCurve, ON_PolylineCurve,
            // and ON_PolyCurve (whose segments form a polyline). OnCurve.IsPolyline
            // tests a curve to see if it can be represented as a polyline.
            ArrayOn3dPoint points      = new ArrayOn3dPoint(64);
            int            point_count = curve.IsPolyline(points);

            if (point_count > 0)
            {
                string point_str = string.Empty;
                for (int i = 0; i < point_count; i++)
                {
                    point_str = string.Empty;
                    RhUtil.RhinoFormatPoint(points[i], ref point_str);
                    RhUtil.RhinoApp().Print(string.Format("Point {0} = {1}\n", i, point_str));
                }
            }

            return(IRhinoCommand.result.success);
        }
 public SampleCsSurfaceDirectionConduit()
     : base(new MSupportChannels(MSupportChannels.SC_DRAWOVERLAY), false)
 {
     m_brep = null;
       m_bFlip = false;
       m_points = new ArrayOn3dPoint();
       m_normals = new ArrayOn3dVector();
 }