コード例 #1
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)
        {
            VoxelImage VoxelImage    = null;
            Point3d    Point         = new Point3d();
            int        VectorType    = 0;
            double     SegmentLength = 0.0001;
            int        Iterations    = 25000;

            if (!DA.GetData(0, ref VoxelImage))
            {
                return;
            }
            DA.GetData(1, ref Point);
            DA.GetData(2, ref VectorType);
            DA.GetData(3, ref SegmentLength);
            DA.GetData(4, ref Iterations);

            List <V2GPoint> Points      = V2GVoxel.VoxelCurvePoints(VoxelImage, V2GH.V2GPoint(Point), SegmentLength, Iterations, VectorType);
            List <Point3d>  RhinoPoints = new List <Point3d>();

            foreach (V2GPoint p in Points)
            {
                RhinoPoints.Add(new Point3d(p.X, p.Y, p.Z));
            }
            Polyline Polyline = new Polyline(RhinoPoints);

            DA.SetData(0, Polyline);
        }
コード例 #2
0
        public static Dictionary <string, object> CurveSinusoidalPointsWithVoxel(
            Autodesk.DesignScript.Geometry.Curve _Curve,
            VoxelImage Voxel,
            double WaveLength = 5.0,
            double Amplitude  = 1.0,
            double Resolution = 2.0)
        {
            VoxelChannel _VoxelChannel = Voxel.GetChannel(VoxelImageLayout.SHAPECHANNEL);

            double n     = (_Curve.Length / WaveLength) * 4 * Resolution;
            double _Span = _Curve.Length / n;
            List <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>();
            List <double> ks = new List <double>();

            for (int i = 0; i < n; i++)
            {
                Autodesk.DesignScript.Geometry.Plane pl = _Curve.PlaneAtParameter(_Curve.ParameterAtSegmentLength(i * _Span));
                Autodesk.DesignScript.Geometry.Point p  = _Curve.PointAtSegmentLength(i * _Span);
                double FieldValue = V2GVoxel.GetVoxelFieldValue(_VoxelChannel, p.X, p.Y, p.Z);

                double k = FieldValue * Amplitude * Math.Sin(i * _Span * Math.PI * 2 / WaveLength + Math.PI * 2);

                points.Add((Autodesk.DesignScript.Geometry.Point)p.Translate(pl.YAxis, k));
                ks.Add(k);
            }

            return(new Dictionary <string, object>
            {
                { "Points", points },
                { "k", ks }
            });
        }
コード例 #3
0
ファイル: V2GVoxelPoint.cs プロジェクト: yazici/Voxel2GCode
        /// <summary>
        /// Calculate voxel point properties.
        /// </summary>
        /// <param name="_Voxel"></param>
        public void SetPropertiesWith(VoxelImage _Voxel)
        {
            double delta = 0.000001;

            VoxelImage   v  = _Voxel as VoxelImage;
            VoxelChannel vc = v.GetChannel(VoxelImageLayout.SHAPECHANNEL) as VoxelChannel;

            V2GPoint x0 = this.Position - V2GPoint.XAxis * delta;
            V2GPoint x1 = this.Position + V2GPoint.XAxis * delta;
            V2GPoint y0 = this.Position - V2GPoint.YAxis * delta;
            V2GPoint y1 = this.Position + V2GPoint.YAxis * delta;
            V2GPoint z0 = this.Position - V2GPoint.ZAxis * delta;
            V2GPoint z1 = this.Position + V2GPoint.ZAxis * delta;

            double x = V2GVoxel.GetVoxelFieldValue(vc, x1) - V2GVoxel.GetVoxelFieldValue(vc, x0);
            double y = V2GVoxel.GetVoxelFieldValue(vc, y1) - V2GVoxel.GetVoxelFieldValue(vc, y0);
            double z = V2GVoxel.GetVoxelFieldValue(vc, z1) - V2GVoxel.GetVoxelFieldValue(vc, z0);

            V2GPoint UnitVector = new V2GPoint(x, y, z);

            UnitVector.Normalize();

            double   fieldValue = V2GVoxel.GetVoxelFieldValue(vc, this.Position);
            V2GPoint RealVector = UnitVector * fieldValue;

            V2GPoint UnitVectorProjected = new V2GPoint(RealVector.X, RealVector.Y, 0);
            V2GPoint UnitVectorPerpendicularProjected = V2GPoint.CrossProduct(UnitVectorProjected, V2GPoint.ZAxis);

            UnitVectorProjected.Normalize();
            UnitVectorPerpendicularProjected.Normalize();

            this.ContourVector3d = UnitVector;
            this.ContourVector   = UnitVectorPerpendicularProjected;
            this.GradientVector  = UnitVectorProjected;
            this.FieldValue      = fieldValue;
        }
コード例 #4
0
 /// <summary>
 /// Get field value of a VoxelChannel at a given point.
 /// </summary>
 /// <param name="vc"></param>
 /// <param name="p"></param>
 /// <returns name="Value"></returns>
 public static double VoxelChannelValueAtPoint(VoxelChannel vc, Autodesk.DesignScript.Geometry.Point p)
 {
     return(V2GVoxel.GetVoxelFieldValue(vc, p.X, p.Y, p.Z));
 }
コード例 #5
0
        /// <summary>
        /// Augment a point with voxel metadata.
        /// </summary>
        /// <param name="Voxel">A voxel model from Monolith.</param>
        /// <param name="Point">A point in space.</param>
        /// <returns name="VoxelPoint"></returns>
        ///

        public static V2GVoxelPoint VoxelPoint(MonolithLib.VoxelImage Voxel, Autodesk.DesignScript.Geometry.Point Point)
        {
            return(V2GVoxel.GetVoxelPoint(Voxel, new V2GPoint(Point.X, Point.Y, Point.Z)));
        }