diff --git a/Components/SliceGeometry.cs b/Components/SliceGeometry.cs index fd32258..2db2963 100644 --- a/Components/SliceGeometry.cs +++ b/Components/SliceGeometry.cs @@ -218,9 +218,9 @@ protected override void SolveInstance(IGH_DataAccess DA) { } private static bool IsOnEdgeUnitized(Point3d geometryPoint) { - return Math.Abs(Math.Abs(geometryPoint.X % 1) - 0.5) <= RhinoMath.SqrtEpsilon - || Math.Abs(Math.Abs(geometryPoint.Y % 1) - 0.5) <= RhinoMath.SqrtEpsilon - || Math.Abs(Math.Abs(geometryPoint.Z % 1) - 0.5) <= RhinoMath.SqrtEpsilon; + return Math.Abs(Math.Abs(geometryPoint.X % 1) - 0.5) <= Config.EPSILON + || Math.Abs(Math.Abs(geometryPoint.Y % 1) - 0.5) <= Config.EPSILON + || Math.Abs(Math.Abs(geometryPoint.Z % 1) - 0.5) <= Config.EPSILON; } /// @@ -281,17 +281,18 @@ private static IEnumerable PopulateCurve(double distance, Curve curve) /// entirely inside mesh volume. private static List CentersFromMeshVolume(Mesh mesh) { var pointsInsideMesh = new List(); - var boundingBox = mesh.GetBoundingBox(false); + var boundingBox = mesh.GetBoundingBox(true); var slotInterval = new Interval(-0.5, 0.5); + var plane = Plane.WorldXY; for (var z = Math.Floor(boundingBox.Min.Z - 1); z < Math.Ceiling(boundingBox.Max.Z + 1); z++) { for (var y = Math.Floor(boundingBox.Min.Y - 1); y < Math.Ceiling(boundingBox.Max.Y + 1); y++) { for (var x = Math.Floor(boundingBox.Min.X - 1); x < Math.Ceiling(boundingBox.Max.X + 1); x++) { var testSlotCenter = new Point3d(x, y, z); - var plane = Plane.WorldXY; plane.Origin = testSlotCenter; var box = new Box(plane, slotInterval, slotInterval, slotInterval); var boxPoints = box.GetCorners(); - if (boxPoints.All(point => mesh.IsPointInside(point, RhinoMath.SqrtEpsilon, false))) { + if (boxPoints.All(point => mesh.IsPointInside(point, Config.EPSILON, false) + || point.DistanceTo(mesh.ClosestPoint(point)) < Config.EPSILON)) { pointsInsideMesh.Add(new Point3i(testSlotCenter)); } } @@ -312,15 +313,15 @@ private static List CentersFromMeshVolumeAndSurface(Mesh mesh) { var pointsInsideMesh = new List(); var boundingBox = mesh.GetBoundingBox(false); var slotInterval = new Interval(-0.5, 0.5); + var plane = Plane.WorldXY; for (var z = Math.Floor(boundingBox.Min.Z - 1); z < Math.Ceiling(boundingBox.Max.Z + 1); z++) { for (var y = Math.Floor(boundingBox.Min.Y - 1); y < Math.Ceiling(boundingBox.Max.Y + 1); y++) { for (var x = Math.Floor(boundingBox.Min.X - 1); x < Math.Ceiling(boundingBox.Max.X + 1); x++) { var testSlotCenter = new Point3d(x, y, z); - var plane = Plane.WorldXY; plane.Origin = testSlotCenter; var box = new Box(plane, slotInterval, slotInterval, slotInterval); var boxPoints = box.GetCorners(); - if (boxPoints.Any(point => mesh.IsPointInside(point, Rhino.RhinoMath.SqrtEpsilon, false))) { + if (boxPoints.Any(point => mesh.IsPointInside(point, Config.EPSILON, false) || point.DistanceTo(mesh.ClosestPoint(point)) < Config.EPSILON)) { pointsInsideMesh.Add(new Point3i(testSlotCenter)); } } @@ -340,16 +341,16 @@ private static List CentersFromMeshSurface(Mesh mesh) { var pointsInsideMesh = new List(); var boundingBox = mesh.GetBoundingBox(false); var slotInterval = new Interval(-0.5, 0.5); + var plane = Plane.WorldXY; for (var z = Math.Floor(boundingBox.Min.Z - 1); z < Math.Ceiling(boundingBox.Max.Z + 1); z++) { for (var y = Math.Floor(boundingBox.Min.Y - 1); y < Math.Ceiling(boundingBox.Max.Y + 1); y++) { for (var x = Math.Floor(boundingBox.Min.X - 1); x < Math.Ceiling(boundingBox.Max.X + 1); x++) { var testSlotCenter = new Point3d(x, y, z); - var plane = Plane.WorldXY; plane.Origin = testSlotCenter; var box = new Box(plane, slotInterval, slotInterval, slotInterval); var boxPoints = box.GetCorners(); var boxcornersInside = boxPoints - .Count(point => mesh.IsPointInside(point, RhinoMath.SqrtEpsilon, false)); + .Count(point => mesh.IsPointInside(point, Config.EPSILON, false) || point.DistanceTo(mesh.ClosestPoint(point)) < Config.EPSILON); if (boxcornersInside > 0 && boxcornersInside < 6) { pointsInsideMesh.Add(new Point3i(testSlotCenter)); } diff --git a/bin/Monoceros.pdb b/bin/Monoceros.pdb index 5114ecf..a84201c 100644 Binary files a/bin/Monoceros.pdb and b/bin/Monoceros.pdb differ