Beispiel #1
0
        /// <summary>
        /// Constructs a new NURBS surfaces from cone data.
        /// </summary>
        /// <param name="cone">A cone value.</param>
        /// <returns>A new NURBS surface, or null on error.</returns>
        public static NurbsSurface CreateFromCone(Cone cone)
        {
            IntPtr pNurbsSurface = UnsafeNativeMethods.ON_Cone_GetNurbForm(ref cone);

            if (IntPtr.Zero == pNurbsSurface)
            {
                return(null);
            }
            return(new NurbsSurface(pNurbsSurface, null));
        }
        /// <summary>
        /// Constructs a new surface of revolution from the values of a cone.
        /// </summary>
        /// <param name="cone">A cone.</param>
        /// <returns>A new surface of revolution, or null if any of the inputs is invalid or on error.</returns>
        /// <since>5.0</since>
        public static RevSurface CreateFromCone(Cone cone)
        {
            IntPtr pRevSurface = UnsafeNativeMethods.ON_Cone_RevSurfaceForm(ref cone);

            if (IntPtr.Zero == pRevSurface)
            {
                return(null);
            }
            return(new RevSurface(pRevSurface, null));
        }
Beispiel #3
0
 public static Rhino.Commands.Result AddCone(Rhino.RhinoDoc doc)
 {
   Rhino.Geometry.Plane plane = Rhino.Geometry.Plane.WorldXY;
   double height = 10;
   double radius = 5;
   Rhino.Geometry.Cone cone = new Rhino.Geometry.Cone(plane, height, radius);
   if (cone.IsValid)
   {
     bool cap_bottom = true;
     Rhino.Geometry.Brep cone_brep = cone.ToBrep(cap_bottom);
     if (cone_brep!=null)
     {
       doc.Objects.AddBrep(cone_brep);
       doc.Views.Redraw();
     }
   }
   return Rhino.Commands.Result.Success;
 }
 /// <summary>Tests a surface to see if it is a portion of a cone and returns the cone.</summary>
 /// <param name="cone">On success, the cone parameters are filled in.</param>
 /// <param name="tolerance">tolerance to use when checking.</param>
 /// <returns>true if the surface is a portion of a cone.</returns>
 public bool TryGetCone(out Cone cone, double tolerance)
 {
   cone = new Cone();
   IntPtr pThis = ConstPointer();
   return UnsafeNativeMethods.ON_Surface_IsCone(pThis, ref cone, tolerance, true);
 }
 /// <summary>Tests a surface to see if it is a portion of a cone within RhinoMath.ZeroTolerance and return the cone.</summary>
 /// <param name="cone">On success, the cone parameters are filled in.</param>
 /// <returns>true if the surface is a portion of a cone.</returns>
 public bool TryGetCone(out Cone cone)
 {
   return TryGetCone(out cone, RhinoMath.ZeroTolerance);
 }
 /// <summary>Determines if the surface is a portion of a cone within a given tolerance.</summary>
 /// <param name="tolerance">tolerance to use when checking.</param>
 /// <returns>true if the surface is a portion of a cone.</returns>
 public bool IsCone(double tolerance)
 {
   Cone cone = new Cone();
   IntPtr pThis = ConstPointer();
   return UnsafeNativeMethods.ON_Surface_IsCone(pThis, ref cone, tolerance, false);
 }
 /// <summary>
 /// Draw a wireframe cone.
 /// </summary>
 /// <param name="cone">Cone to draw.</param>
 /// <param name="color">Color to draw with.</param>
 /// <param name="thickness">Thickness (in pixels) of Cone wires.</param>
 public void DrawCone(Cone cone, System.Drawing.Color color, int thickness)
 {
   int argb = color.ToArgb();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawCone(m_ptr, ref cone, argb, thickness);
 }
 /// <summary>
 /// Constructs a new surface of revolution from the values of a cone.
 /// </summary>
 /// <param name="cone">A cone.</param>
 /// <returns>A new surface of revolution, or null if any of the inputs is invalid or on error.</returns>
 public static RevSurface CreateFromCone(Cone cone)
 {
   IntPtr pRevSurface = UnsafeNativeMethods.ON_Cone_RevSurfaceForm(ref cone);
   if (IntPtr.Zero == pRevSurface)
     return null;
   return new RevSurface(pRevSurface, null);
 }
Beispiel #9
0
        /***************************************************/
        /**** Public Methods - Solids                   ****/
        /***************************************************/

        public static void RenderRhinoWires(RHG.Cone cone, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness)
        {
            pipeline.DrawCone(cone, bhColour);
        }
Beispiel #10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // INPUTS

            // import Silkworm Movement
            List<GH_ObjectWrapper> s_Movement = new List<GH_ObjectWrapper>();

            if (!DA.GetDataList(0, s_Movement)) { return; }

            int res = new int();
            //if (!DA.GetData(4, ref res)) { }

            double startPrev = 0.0;
            if (!DA.GetData(1, ref startPrev)) { }
            double endPrev = 1.0;
            if (!DA.GetData(2, ref endPrev)) { }

            bool showlogistics = false;
            if (!DA.GetData(3, ref showlogistics)) { }

            bool showvalues = false;
            if (!DA.GetData(4, ref showvalues)) { }

            bool showmesh = false;
            if (!DA.GetData(5, ref showmesh)) { }

            bool showprinter = false;
            if (!DA.GetData(6, ref showprinter)) { }
            #endregion

            //Initialise these properties as soon as solveinstance begins
            if (DA.Iteration == 0)
            {
                //Visualise Print Logistics
                displayLogistics = new bool();
                startPoints = new List<Line>();
                endPoints = new List<Line>();
                DelimitMarkers = new List<Line>();

                //Visualise Print Values
                displayValues = new bool();
                lineThicknesses = new List<double>();
                Colors = new List<Color>();
                Movements = new List<Line>();
                blobPts = new List<Point3d>();
                blobDiameter = new List<double>();

                //Visualise Print Realistic
                displayMesh = new bool();
                //m_meshes = new List<Mesh>();

                //Visualise Printer
                displayPrinter = new bool();
                bboxAll = new BoundingBox();
                extclearance = new Mesh();
                xcarriage = new List<Mesh>();
                vizmaterial = new DisplayMaterial(Color.Yellow, 0.5);
                printArea = new List<Point3d>();

            }

            //Output Holders

            Mesh sMesh = new Mesh();

            displayLogistics = showlogistics;
            displayValues = showvalues;
            displayMesh = showmesh;
            displayPrinter = showprinter;

            List<Point3d>  startPts = new List<Point3d>();
            List<Point3d> endPts = new List<Point3d>();

            //Sort through input geometry, check that it is a Silkworm Model
            foreach (GH_ObjectWrapper movement in s_Movement)
            {
                if (movement.Value is SilkwormModel)
                {
                    SilkwormModel sModel = (SilkwormModel)movement.Value;
                    printArea.Add(new Point3d(0,0,0));
                    printArea.Add(new Point3d(0, sModel.bed_size.Y, 0));
                    printArea.Add(new Point3d(sModel.bed_size.X, sModel.bed_size.Y, 0));
                    printArea.Add(new Point3d(sModel.bed_size.X, 0, 0));

                    bboxAll = new BoundingBox(new Point3d(0, 0, 0), new Point3d(sModel.bed_size.X, sModel.bed_size.Y, sModel.bed_size.Z));
                    sModel.displayModel(startPrev, endPrev, showmesh, res,
                        out Movements,
                        out lineThicknesses,
                        out DelimitMarkers,
                        out blobPts,
                        out blobDiameter,
                        out Colors,
                        out sMesh,
                        out startPts,
                        out endPts);

                    //Create Clearance Visualisation Geometry
                    Point3d endPt = Movements[Movements.Count - 1].To;

                    Plane plane = new Plane(endPt,Plane.WorldXY.ZAxis);
                    Cone extcl = new Cone(plane, sModel.extruder_clearance_height, sModel.extruder_clearance_radius);
                    extclearance = Mesh.CreateFromCone(extcl, 12, 30);

                    double roddiameter = 8;
                    Point3d PtA1 = new Point3d(0, endPt.Y + ((sModel.xbar_width / 2) - (roddiameter / 2)), endPt.Z + (roddiameter / 2) + sModel.extruder_clearance_height);
                    Point3d PtA2 = new Point3d(0, endPt.Y - ((sModel.xbar_width / 2) - (roddiameter / 2)), endPt.Z + (roddiameter / 2)+sModel.extruder_clearance_height);

                    Cylinder clyA = new Cylinder(new Circle(new Plane(PtA1, Plane.WorldYZ.ZAxis), roddiameter/2), sModel.bed_size.X);
                    Cylinder clyB = new Cylinder(new Circle(new Plane(PtA2, Plane.WorldYZ.ZAxis), roddiameter/2), sModel.bed_size.X);

                    Mesh cylA = Mesh.CreateFromCylinder(clyA,12,30);
                    Mesh cylB = Mesh.CreateFromCylinder(clyB, 12,30);
                    xcarriage.AddRange(new Mesh[] {cylA,cylB});

                    foreach (Point3d point in startPts)
                    {
                        startPoints.Add(new Line(point, Plane.WorldXY.ZAxis, 0.01));
                    }
                    foreach (Point3d point in endPts)
                    {
                        endPoints.Add(new Line(point, Plane.WorldXY.ZAxis, 0.01));
                    }

               }

                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please Input Only Silkworm Models");
                    continue;
                }

            }

            //GH_Mesh outPipes = new GH_Mesh(sMesh);

            //DA.SetData(0, outPipes);
        }
        /***************************************************/
        /**** Public Methods - Solids                   ****/
        /***************************************************/

        public static void RenderRhinoMeshes(RHG.Cone cone, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material)
        {
            pipeline.DrawBrepShaded(cone.ToBrep(true), material);
        }
    /// <summary>
    /// Call this method to get a box at the specified index.
    /// </summary>
    /// <param name="index">
    /// The zero based index of the item in the list.  Valid values are greater
    /// than or equal to 0 and less than Count.
    /// </param>
    /// <param name="cone">
    /// Will contain the cone at the requested index if the index is in range
    /// and the primitive at the requested index is a box.
    /// </param>
    /// <param name="truncation">
    /// </param>
    /// <returns>
    /// Return true if the index is in range and the primitive at the requested
    /// index is a box otherwise returns false.
    /// </returns>
    public bool TryGetCone(int index, out Cone cone, out Plane truncation)
    {
      var origin = new Point3d();
      var xaxis = new Vector3d();
      var yaxis = new Vector3d();

      var height = 0.0;
      var radius = 0.0;

      var t_origin = new Point3d();
      var t_xaxis = new Vector3d();
      var t_yaxis = new Vector3d();


      if (UnsafeNativeMethods.Rdk_CustomMeshes_Cone(ConstPointer(), index, 
                                                    ref origin, 
                                                    ref xaxis, 
                                                    ref yaxis, 
                                                    ref height,
                                                    ref radius,
                                                    ref t_origin,
                                                    ref t_xaxis,
                                                    ref t_yaxis))
      {
        cone = new Cone(new Plane(origin, xaxis, yaxis), height, radius);
        truncation = new Plane(t_origin, t_xaxis, t_yaxis);
        return true;
      }
      cone = new Cone();
      truncation = new Plane();
      return false;
    }
 /// <summary>
 /// Add primitive cone and material.
 /// </summary>
 /// <param name="cone">Cone to add.</param>
 /// <param name="truncation">
 /// The plane used to cut the cone (the non-apex end is kept). Should be
 /// equal to cone.plane if not truncated.
 /// </param>
 /// <param name="material">
 /// Material to add, may be null if not needed.
 /// </param>
 public void Add(Cone cone, Plane truncation, RenderMaterial material)
 {
   var material_pointer = (null == material ? IntPtr.Zero : material.ConstPointer());
   var pointer = NonConstPointer();
   UnsafeNativeMethods.Rdk_CustomMeshes_AddCone(pointer,
                                                cone.BasePoint, 
                                                cone.Plane.XAxis, 
                                                cone.Plane.YAxis, 
                                                cone.Height,
                                                cone.Radius,
                                                truncation.Origin, 
                                                truncation.XAxis, 
                                                truncation.YAxis,
                                                material_pointer);
 }
Beispiel #14
0
        /***************************************************/

        public static BHG.Cone FromRhino(this RHG.Cone cone)
        {
            return(new BHG.Cone {
                Centre = cone.BasePoint.FromRhino(), Axis = cone.Axis.FromRhino() * -1.0, Radius = cone.Radius, Height = cone.Height
            });
        }
Beispiel #15
0
        /***************************************************/
        /**** Public Methods - Solids                   ****/
        /***************************************************/

        public static RHG.Mesh CreatePreviewMesh(RHG.Cone cone, RHG.MeshingParameters parameters)
        {
            return(CreatePreviewMesh(cone.ToBrep(true), parameters));
        }