예제 #1
0
        /// <summary>
        /// Add a line in world coordinates to a voxelgrid
        /// </summary>
        /// <param name="line"></param>
        /// <param name="vg"></param>
        private void AddLine(Line line, ref VoxelGrid3D vg)
        {
            var start = vg.ClosestPoint(line.From);
            var end   = vg.ClosestPoint(line.To);

            foreach (var pt in InterateLine(start, end))
            {
                if (pt < Point3i.Origin || pt >= vg.SizeUVW)
                {
                    continue;
                }
                vg[pt] = true;
            }
        }
예제 #2
0
 /// <summary>
 ///   Add point to the grid.
 /// </summary>
 /// <param name="pt">Point in world space</param>
 /// <param name="vg">Voxelgrid</param>
 public void AddPt(Point3d pt, ref VoxelGrid3D vg)
 {
     if (Distance < RhinoMath.ZeroTolerance)
     {
         var pti = vg.ClosestPoint(pt);
         if (pti >= Point3i.Origin && pti <= vg.SizeUVW)
         {
             vg.SetValue(pti, true);
         }
     }
     else
     {
         var bb = new BoundingBox(new [] { pt });
         bb.Inflate(Distance * 1.1);
         foreach (var subPt in vg.PointsInBox(bb))
         {
             if (vg.PointInGrid(subPt) &&
                 !vg[subPt] &&
                 vg.EvaluatePoint(subPt).DistanceTo(pt) < Distance)
             {
                 vg[subPt] = true;
             }
         }
     }
 }