diff --git a/OSCADSharp/OSCADSharp/OSCADObject.cs b/OSCADSharp/OSCADSharp/OSCADObject.cs
index cdcd2e0..7bfe919 100644
--- a/OSCADSharp/OSCADSharp/OSCADObject.cs
+++ b/OSCADSharp/OSCADSharp/OSCADObject.cs
@@ -1,4 +1,5 @@
using OSCADSharp.Booleans;
+using OSCADSharp.Spatial;
using OSCADSharp.Transforms;
using System;
using System.Collections.Generic;
@@ -226,7 +227,13 @@ namespace OSCADSharp
/// of the position.
///
///
- public abstract Vector3 Position();
+ public abstract Vector3 Position();
+
+ ///
+ /// Returns the approximate boundaries of this OpenSCAD object
+ ///
+ ///
+ public abstract Bounds Bounds();
///
/// Creates a copy of this object and all of its children
diff --git a/OSCADSharp/OSCADSharp/OSCADSharp.csproj b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
index 8722bbe..17885d9 100644
--- a/OSCADSharp/OSCADSharp/OSCADSharp.csproj
+++ b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
@@ -44,6 +44,7 @@
+
diff --git a/OSCADSharp/OSCADSharp/Scripting/MultiBlockStatementObject.cs b/OSCADSharp/OSCADSharp/Scripting/MultiBlockStatementObject.cs
index c3a4cea..03a1d33 100644
--- a/OSCADSharp/OSCADSharp/Scripting/MultiBlockStatementObject.cs
+++ b/OSCADSharp/OSCADSharp/Scripting/MultiBlockStatementObject.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Scripting
{
@@ -49,5 +50,10 @@ namespace OSCADSharp.Scripting
var positions = this.children.Select(child => child.Position());
return Vector3.Average(positions.ToArray());
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cube.cs b/OSCADSharp/OSCADSharp/Solids/Cube.cs
index 1b764f2..3f45dec 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cube.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cube.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Solids
{
@@ -105,6 +106,15 @@ namespace OSCADSharp.Solids
return position;
}
+
+ ///
+ /// Returns the approximate boundaries of this OpenSCAD object
+ ///
+ ///
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
#endregion
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
index 14f0a7c..4e4a150 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Solids
{
@@ -118,7 +119,6 @@ namespace OSCADSharp.Solids
#endregion
#region Overrides
-
///
/// Converts this object to an OpenSCAD script
///
@@ -167,6 +167,15 @@ namespace OSCADSharp.Solids
return position;
}
+
+ ///
+ /// Returns the approximate boundaries of this OpenSCAD object
+ ///
+ ///
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
#endregion
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
index 6f32c4b..cf9f083 100644
--- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Solids
{
@@ -98,6 +99,15 @@ namespace OSCADSharp.Solids
{
return new Vector3();
}
+
+ ///
+ /// Returns the approximate boundaries of this OpenSCAD object
+ ///
+ ///
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
#endregion
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Text3D.cs b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
index f71cfa8..3a507b9 100644
--- a/OSCADSharp/OSCADSharp/Solids/Text3D.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Solids
{
@@ -140,6 +141,15 @@ namespace OSCADSharp.Solids
{
return new Vector3();
}
+
+ ///
+ /// Returns the approximate boundaries of this OpenSCAD object
+ ///
+ ///
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
#endregion
}
}
diff --git a/OSCADSharp/OSCADSharp/Spatial/Bounds.cs b/OSCADSharp/OSCADSharp/Spatial/Bounds.cs
new file mode 100644
index 0000000..fb21e39
--- /dev/null
+++ b/OSCADSharp/OSCADSharp/Spatial/Bounds.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSCADSharp.Spatial
+{
+ ///
+ /// A set of boundaries
+ ///
+ public class Bounds
+ {
+ ///
+ /// Creates a set of boundaries with the corners specified
+ /// to define its extremities
+ ///
+ ///
+ ///
+ public Bounds(Vector3 bottomLeft, Vector3 topRight)
+ {
+ this.BottomLeft = bottomLeft;
+ this.TopRight = topRight;
+ }
+
+ #region Public Properties
+ ///
+ /// Represents the top-right corner of the bounds (prior to any transforms)
+ ///
+ public Vector3 TopRight { get; private set; }
+
+ ///
+ /// Represents the bottom-left corner of the bounds (prior to any transforms)
+ ///
+ public Vector3 BottomLeft { get; private set; }
+
+ ///
+ /// X position with the greatest value
+ ///
+ public double X_Max { get { return TopRight.X > BottomLeft.X ? TopRight.X : BottomLeft.X; } }
+
+ ///
+ /// X position with the smallest value
+ ///
+ public double X_Min { get { return TopRight.X < BottomLeft.X ? TopRight.X : BottomLeft.X; } }
+
+ ///
+ /// Y position with the greatest value
+ ///
+ public double Y_Max { get { return TopRight.Y > BottomLeft.Y ? TopRight.Y : BottomLeft.Y; } }
+
+ ///
+ /// Y position with the smallest value
+ ///
+ public double Y_Min { get { return TopRight.Y < BottomLeft.Y ? TopRight.Y : BottomLeft.Y; } }
+
+ ///
+ /// Z position with the greatest value
+ ///
+ public double Z_Max { get { return TopRight.Z > BottomLeft.Z ? TopRight.Z : BottomLeft.Z; } }
+
+ ///
+ /// Z position with the smallest value
+ ///
+ public double Z_Min { get { return TopRight.Z < BottomLeft.Z ? TopRight.Z : BottomLeft.Z; } }
+ #endregion
+ }
+}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
index 6c6a047..d763ee2 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Transforms
{
@@ -55,5 +56,10 @@ namespace OSCADSharp.Transforms
{
return this.obj.Position();
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/LinearExtrudedObject.cs b/OSCADSharp/OSCADSharp/Transforms/LinearExtrudedObject.cs
index d1506b2..ee21a6d 100644
--- a/OSCADSharp/OSCADSharp/Transforms/LinearExtrudedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/LinearExtrudedObject.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Transforms
{
@@ -52,5 +53,10 @@ namespace OSCADSharp.Transforms
{
throw new NotSupportedException();
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
index 05f4dc7..d8164c8 100644
--- a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
@@ -74,5 +74,10 @@ namespace OSCADSharp.Transforms
return (this.Normal.X != 0 && (this.Normal.Y != 0 || this.Normal.Z != 0)) ||
(this.Normal.Y != 0 && (this.Normal.X != 0 || this.Normal.Z != 0));
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
index 29837c8..cececcc 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Transforms
{
@@ -53,5 +54,10 @@ namespace OSCADSharp.Transforms
{
throw new NotSupportedException("Position is not supported on Resized objects.");
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
index c83aa95..d93bff3 100644
--- a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
@@ -54,5 +54,10 @@ namespace OSCADSharp.Transforms
{
return Matrix.GetRotatedPoint(this.obj.Position(), this.Angle.X, this.Angle.Y, this.Angle.Z);
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
index fcba7c7..6d7606d 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Transforms
{
@@ -53,5 +54,10 @@ namespace OSCADSharp.Transforms
{
return obj.Position() * this.ScaleFactor;
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
index e9f0c81..5ba946a 100644
--- a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using OSCADSharp.Spatial;
namespace OSCADSharp.Transforms
{
@@ -50,5 +51,10 @@ namespace OSCADSharp.Transforms
{
return this.obj.Position() + this.Vector;
}
+
+ public override Bounds Bounds()
+ {
+ throw new NotImplementedException();
+ }
}
}