mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
Added lots of comments to get rid of the compiler warnings that appeared after turning XML docs on.
This commit is contained in:
parent
637955f2b7
commit
a71f28f5e4
@ -8,6 +8,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents any Object or collection of objects that becomes am
|
||||
/// an OpenSCAD script when converted to a string.
|
||||
/// </summary>
|
||||
public abstract class OSCADObject
|
||||
{
|
||||
#region Transforms
|
||||
@ -137,7 +141,7 @@ namespace OSCADSharp
|
||||
/// <summary>
|
||||
/// Creates a minkowski sum of child nodes (including this object)
|
||||
/// </summary>
|
||||
/// <param name="nodes">Nodes to sum with</param>
|
||||
/// <param name="objects">Nodes to sum with</param>
|
||||
/// <returns>A minkowski sum</returns>
|
||||
public OSCADObject Minkowski(params OSCADObject[] objects)
|
||||
{
|
||||
@ -147,7 +151,7 @@ namespace OSCADSharp
|
||||
/// <summary>
|
||||
/// Creates a conved hull from child nodes (including this object)
|
||||
/// </summary>
|
||||
/// <param name="nodes">Nodes to hull</param>
|
||||
/// <param name="objects">Nodes to hull</param>
|
||||
/// <returns>Hull of nodes</returns>
|
||||
public OSCADObject Hull(params OSCADObject[] objects)
|
||||
{
|
||||
@ -235,8 +239,11 @@ namespace OSCADSharp
|
||||
return this.ToString() == other.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Internal collection of children for this object
|
||||
/// </summary>
|
||||
protected List<OSCADObject> children = new List<OSCADObject>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all children of this OSCADObject
|
||||
/// </summary>
|
||||
|
||||
@ -6,15 +6,42 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Constants and conversions for units for us imperial-minded folks.
|
||||
/// </summary>
|
||||
public class Sizes
|
||||
{
|
||||
/// <summary>
|
||||
/// One imperial inch
|
||||
/// </summary>
|
||||
public const double OneInch = 25.4;
|
||||
|
||||
/// <summary>
|
||||
/// Half of an imperial inch
|
||||
/// </summary>
|
||||
public const double HalfInch = OneInch / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Quarter of an imperial inch
|
||||
/// </summary>
|
||||
public const double QuarterInch = HalfInch / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Eigth of an imperial inch
|
||||
/// </summary>
|
||||
public const double EigthInch = QuarterInch / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Sixteenth of an imperial inch
|
||||
/// </summary>
|
||||
public const double SixteenthInch = EigthInch / 2;
|
||||
|
||||
public double InchesToMilimeters(double inches)
|
||||
/// <summary>
|
||||
/// Converts inches to millimeters
|
||||
/// </summary>
|
||||
/// <param name="inches">Number of inches</param>
|
||||
/// <returns>Equivalent value in milimeters</returns>
|
||||
public double InchesToMillimeters(double inches)
|
||||
{
|
||||
return inches * 0.03937008;
|
||||
}
|
||||
|
||||
@ -62,12 +62,20 @@ namespace OSCADSharp.Solids
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Converts this object to an OpenSCAD script
|
||||
/// </summary>
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("cube(size = [{0}, {1}, {2}], center = {3});",
|
||||
this.Size.X.ToString(), this.Size.Y.ToString(), this.Size.Z.ToString(), this.Center.ToString().ToLower()); ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of this object that is a new instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new Cube()
|
||||
@ -77,6 +85,11 @@ namespace OSCADSharp.Solids
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of this object's center (origin) in
|
||||
/// world space
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Vector3 Position()
|
||||
{
|
||||
Vector3 position;
|
||||
|
||||
@ -107,6 +107,7 @@ namespace OSCADSharp.Solids
|
||||
/// Creates a cylinder with the specified diameter and centering
|
||||
/// </summary>
|
||||
/// <param name="diameter">Diameter of the cylinder</param>
|
||||
/// <param name="height">Height of the cylinder</param>
|
||||
/// <param name="center">Determines whether the cylinder should be centered on the z-axis, if false the base will start on the Z axis</param>
|
||||
public Cylinder(double diameter = 2, double height = 1, bool center = false)
|
||||
{
|
||||
@ -117,6 +118,11 @@ namespace OSCADSharp.Solids
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
|
||||
/// <summary>
|
||||
/// Converts this object to an OpenSCAD script
|
||||
/// </summary>
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("cylinder($fn = {0}, $fa = {1}, $fs = {2}, h = {3}, r1 = {4}, r2 = {5}, center = {6});",
|
||||
@ -124,6 +130,10 @@ namespace OSCADSharp.Solids
|
||||
Height.ToString(), Radius1.ToString(), Radius2.ToString(), Center.ToString().ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of this object that is a new instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new Cylinder()
|
||||
@ -138,6 +148,11 @@ namespace OSCADSharp.Solids
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of this object's center (origin) in
|
||||
/// world space
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Vector3 Position()
|
||||
{
|
||||
Vector3 position;
|
||||
|
||||
@ -63,6 +63,10 @@ namespace OSCADSharp.Solids
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Converts this object to an OpenSCAD script
|
||||
/// </summary>
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("sphere($fn = {0}, $fa = {1}, $fs = {2}, r = {3});",
|
||||
@ -70,6 +74,10 @@ namespace OSCADSharp.Solids
|
||||
this.MinimumFragmentSize.ToString(), this.Radius.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of this object that is a new instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new Sphere()
|
||||
@ -81,6 +89,11 @@ namespace OSCADSharp.Solids
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of this object's center (origin) in
|
||||
/// world space
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Vector3 Position()
|
||||
{
|
||||
return new Vector3();
|
||||
|
||||
@ -27,22 +27,10 @@ namespace OSCADSharp.Solids
|
||||
/// <summary>
|
||||
/// The name of the font that should be used. This is not the name of the font file,
|
||||
/// but the logical font name (internally handled by the fontconfig library). This can also include a style parameter, see below.
|
||||
/// A list of installed fonts & styles can be obtained using the font list dialog (Help -> Font List).
|
||||
/// A list of installed fonts and styles can be obtained using the font list dialog (Help -> Font List).
|
||||
/// </summary>
|
||||
public string Font { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// The horizontal alignment for the text. Possible values are "left", "center" and "right". Default is "left".
|
||||
/// </summary>
|
||||
/// TODO: Implement alignments
|
||||
//public string HorizontalAlignment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The vertical alignment for the text. Possible values are "top", "center", "baseline" and "bottom". Default is "baseline".
|
||||
/// </summary>
|
||||
/// TODO: Implement alignments
|
||||
// public string VerticalAlignment { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Factor to increase/decrease the character spacing. The default value of 1 will result in the normal spacing for the font, giving a value greater than 1 will cause the letters to be spaced further apart.
|
||||
/// </summary>
|
||||
@ -79,10 +67,14 @@ namespace OSCADSharp.Solids
|
||||
{
|
||||
this.Text = text;
|
||||
this.Size = size;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Gets a copy of this object that is a new instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new Text3D()
|
||||
@ -106,7 +98,11 @@ namespace OSCADSharp.Solids
|
||||
sb.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Converts this object to an OpenSCAD script
|
||||
/// </summary>
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@ -15,11 +15,28 @@ namespace OSCADSharp
|
||||
public class Vector3
|
||||
{
|
||||
#region Attributes
|
||||
/// <summary>
|
||||
/// X component of this vector
|
||||
/// </summary>
|
||||
public double X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Y component of this vector
|
||||
/// </summary>
|
||||
public double Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Z component of this vector
|
||||
/// </summary>
|
||||
public double Z { get; set; }
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Vector with the specified X/Y/Z values
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="z"></param>
|
||||
public Vector3(double x = 0, double y = 0, double z = 0)
|
||||
{
|
||||
this.X = x;
|
||||
@ -87,22 +104,42 @@ namespace OSCADSharp
|
||||
return new Vector3(this.X / sum, this.Y / sum, this.Z / sum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Dot product of two vectors
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
public double Dot(Vector3 other)
|
||||
{
|
||||
return this.X * other.X + this.Y * other.Y + this.Z * other.Z;
|
||||
}
|
||||
|
||||
#region Operators/Overrides
|
||||
/// <summary>
|
||||
/// Compares this vector to another object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return this.GetHashCode() == obj.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a hashcode that's based on the the string for this vector
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.ToString().GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two vectors
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator ==(Vector3 left, Vector3 right)
|
||||
{
|
||||
return left.X == right.X &&
|
||||
@ -110,6 +147,12 @@ namespace OSCADSharp
|
||||
left.Z == right.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does a negated comparison of two vectors
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator !=(Vector3 left, Vector3 right)
|
||||
{
|
||||
return !(left.X == right.X &&
|
||||
@ -117,26 +160,56 @@ namespace OSCADSharp
|
||||
left.Z == right.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 operator +(Vector3 left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two vectors
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 operator -(Vector3 left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two vectors together
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 operator *(Vector3 left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left.X * right.X, left.Y * right.Y, left.Z * right.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies (scales) a vector by a double
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 operator *(Vector3 left, double right)
|
||||
{
|
||||
return new Vector3(left.X * right, left.Y * right, left.Z * right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Muptiplies (scales) a vector by a double
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 operator *(double left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left * right.X, left * right.Y, left * right.Z);
|
||||
@ -149,6 +222,10 @@ namespace OSCADSharp
|
||||
return new Matrix(coords, 4, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this object to an OpenSCAD script
|
||||
/// </summary>
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("[X: {0}, Y: {1}, Z: {2}]", this.X.ToString(), this.Y.ToString(), this.Z.ToString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user