mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-15 23:48:32 +00:00
+ Added SingleStatementObject (abstract) between OSCADObject and repetetive single-objectt transforms.
+ Shifted basic parent/child/object reference assignments to SingleStatementObject
This commit is contained in:
parent
763479985b
commit
9f11c39986
@ -48,6 +48,7 @@
|
||||
<Compile Include="Files\IFileInvoker.cs" />
|
||||
<Compile Include="Files\IFileWriter.cs" />
|
||||
<Compile Include="Ids.cs" />
|
||||
<Compile Include="Scripting\SingleStatementObject.cs" />
|
||||
<Compile Include="Scripting\StatementBuilder.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Sizes.cs" />
|
||||
|
||||
25
OSCADSharp/OSCADSharp/Scripting/SingleStatementObject.cs
Normal file
25
OSCADSharp/OSCADSharp/Scripting/SingleStatementObject.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OSCADSharp.Spatial;
|
||||
|
||||
namespace OSCADSharp.Scripting
|
||||
{
|
||||
/// <summary>
|
||||
/// A statement with just one nested child node
|
||||
/// </summary>
|
||||
internal abstract class SingleStatementObject : OSCADObject
|
||||
{
|
||||
protected OSCADObject obj;
|
||||
|
||||
public SingleStatementObject(OSCADObject obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ namespace OSCADSharp.Scripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the capabilities of StringBuilder with domain-specific behavior
|
||||
/// aimed at constructing OpenSCAD commands
|
||||
/// </summary>
|
||||
internal class StatementBuilder
|
||||
{
|
||||
|
||||
@ -11,29 +11,23 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object that has color and/or opacity applied to it
|
||||
/// </summary>
|
||||
internal class ColoredObject : OSCADObject
|
||||
internal class ColoredObject : SingleStatementObject
|
||||
{
|
||||
#region Attributes
|
||||
internal string ColorName { get; set; } = "Yellow";
|
||||
internal double Opacity { get; set; } = 1.0;
|
||||
#endregion
|
||||
|
||||
private OSCADObject obj;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a colorized object
|
||||
/// </summary>
|
||||
/// <param name="obj">The object(s) to which color will be applied</param>
|
||||
/// <param name="color">The string-wise name of the color to be applied</param>
|
||||
/// <param name="opacity">Opacity from 0.0 to 1.0 </param>
|
||||
internal ColoredObject(OSCADObject obj, string color = "Yellow", double opacity = 1.0)
|
||||
internal ColoredObject(OSCADObject obj, string color = "Yellow", double opacity = 1.0) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.ColorName = color;
|
||||
this.Opacity = opacity;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@ -13,13 +13,12 @@ namespace OSCADSharp.Transforms
|
||||
///
|
||||
/// This is a limited subset of the capabilities
|
||||
/// </summary>
|
||||
internal class LinearExtrudedObject : OSCADObject
|
||||
internal class LinearExtrudedObject : SingleStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Height to extrude to
|
||||
/// </summary>
|
||||
public double Height { get; set; } = 1.0;
|
||||
private OSCADObject obj;
|
||||
|
||||
//TODO: Possibly implement everything else?
|
||||
//linear_extrude(height = fanwidth, center = true, convexity = 10, twist = -fanrot, slices = 20, scale = 1.0) {...}
|
||||
@ -29,13 +28,9 @@ namespace OSCADSharp.Transforms
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="height"></param>
|
||||
public LinearExtrudedObject(OSCADObject obj, double height)
|
||||
public LinearExtrudedObject(OSCADObject obj, double height) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.Height = height;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override OSCADObject Clone()
|
||||
|
||||
@ -11,28 +11,22 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object that's mirrored on a plane
|
||||
/// </summary>
|
||||
internal class MirroredObject : OSCADObject
|
||||
internal class MirroredObject : SingleStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The normal vector of a plane intersecting the origin of the object,
|
||||
/// through which to mirror it.
|
||||
/// </summary>
|
||||
internal Vector3 Normal { get; set; } = new Vector3();
|
||||
|
||||
private OSCADObject obj;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates an object that's mirrored on a plane
|
||||
/// </summary>
|
||||
/// <param name="obj">The object(s) to be mirrored</param>
|
||||
/// <param name="normal">The normal vector of the plane on the object's origin to mirror upon</param>
|
||||
internal MirroredObject(OSCADObject obj, Vector3 normal)
|
||||
internal MirroredObject(OSCADObject obj, Vector3 normal) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.Normal = normal;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@ -11,26 +11,21 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object that's been resized to a specified set of X/Y/Z dimensions
|
||||
/// </summary>
|
||||
internal class ResizedObject : OSCADObject
|
||||
internal class ResizedObject : SingleStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Size of the object in terms of X/Y/Z
|
||||
/// </summary>
|
||||
internal Vector3 Size { get; set; }
|
||||
private OSCADObject obj;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a resized object
|
||||
/// </summary>
|
||||
/// <param name="obj">The object(s) to be resized</param>
|
||||
/// <param name="size">The size to resize to, in terms of x/y/z dimensions</param>
|
||||
internal ResizedObject(OSCADObject obj, Vector3 size)
|
||||
internal ResizedObject(OSCADObject obj, Vector3 size) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.Size = size;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@ -11,26 +11,21 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object with rotation applied
|
||||
/// </summary>
|
||||
internal class RotatedObject : OSCADObject
|
||||
internal class RotatedObject : SingleStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The angle to rotate, in terms of X/Y/Z euler angles
|
||||
/// </summary>
|
||||
internal Vector3 Angle { get; set; } = new Vector3();
|
||||
private OSCADObject obj;
|
||||
|
||||
/// <summary>
|
||||
/// Creates an object with rotation applied
|
||||
/// </summary>
|
||||
/// <param name="obj">The object being rotated</param>
|
||||
/// <param name="angle">The angle to rotate</param>
|
||||
internal RotatedObject(OSCADObject obj, Vector3 angle)
|
||||
internal RotatedObject(OSCADObject obj, Vector3 angle) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.Angle = angle;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@ -11,26 +11,21 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object that's been rescaled
|
||||
/// </summary>
|
||||
internal class ScaledObject : OSCADObject
|
||||
internal class ScaledObject : SingleStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The scale factor to be applied
|
||||
/// </summary>
|
||||
internal Vector3 ScaleFactor { get; set; } = new Vector3(1, 1, 1);
|
||||
private OSCADObject obj;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a scaled object
|
||||
/// </summary>
|
||||
/// <param name="obj">Object(s) to be scaled</param>
|
||||
/// <param name="scale">Scale factor in x/y/z components</param>
|
||||
internal ScaledObject(OSCADObject obj, Vector3 scale)
|
||||
internal ScaledObject(OSCADObject obj, Vector3 scale) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.ScaleFactor = scale;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@ -11,23 +11,18 @@ namespace OSCADSharp.Transforms
|
||||
/// <summary>
|
||||
/// An object or objects that have been moved along the specified vector
|
||||
/// </summary>
|
||||
internal class TranslatedObject : OSCADObject
|
||||
internal class TranslatedObject : SingleStatementObject
|
||||
{
|
||||
internal Vector3 Vector { get; set; }
|
||||
private OSCADObject obj;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a translated object
|
||||
/// </summary>
|
||||
/// <param name="obj">Object(s) to translate</param>
|
||||
/// <param name="vector">Amount to translate by</param>
|
||||
internal TranslatedObject(OSCADObject obj, Vector3 vector)
|
||||
internal TranslatedObject(OSCADObject obj, Vector3 vector) : base(obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.Vector = vector;
|
||||
|
||||
this.children.Add(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user