Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/3DCP-TUe/SaladSlicer into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DerkHBos committed Aug 27, 2021
2 parents ff98346 + 1dc55c2 commit 2621582
Show file tree
Hide file tree
Showing 35 changed files with 475 additions and 142 deletions.
Binary file modified ExampleFiles/v0.1.0/01_Planar_2D_Slicer.gh
Binary file not shown.
Binary file modified ExampleFiles/v0.1.0/02_Planar_2D_Slicer_mulitple_objects.gh
Binary file not shown.
Binary file modified ExampleFiles/v0.1.0/03_Planar_3D_Slicer.gh
Binary file not shown.
34 changes: 33 additions & 1 deletion SaladSlicer/Core/CodeGeneration/AbsoluteCoordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

// System Libs
using Rhino.Geometry;
// Salad Libs
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.CodeGeneration
{
/// <summary>
/// Represents an Absolute Coordinate.
/// </summary>
public class AbsoluteCoordinate : IProgram
public class AbsoluteCoordinate : IProgram, IGeometry
{
#region fields
private Plane _plane;
Expand Down Expand Up @@ -65,6 +67,15 @@ public IProgram DuplicateProgramObject()
{
return this.Duplicate() as IProgram;
}

/// <summary>
/// Returns an exact duplicate of this Absolute Coordinater instance as an IGeometry.
/// </summary>
/// <returns> The exact duplicate of this Absolute Coordinate instance as an IGeometry. </returns>
public IGeometry DuplicateGeometryObject()
{
return this.Duplicate() as IGeometry;
}
#endregion

#region methods
Expand All @@ -85,6 +96,27 @@ public void ToSinumerik(ProgramGenerator programGenerator)
{
programGenerator.Program.Add($"X{_plane.OriginX:0.###} Y{_plane.OriginY:0.###} Z{_plane.OriginZ:0.###}");
}

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. </param>

public BoundingBox GetBoundingBox(bool accurate)
{
return BoundingBox.Empty;
}

/// <summary>
/// Transforms the geometry.
/// </summary>
/// <param name="xform"> Transformation to apply to geometry. </param>
/// <returns> True on success, false on failure. </returns>
public bool Transform(Transform xform)
{
return _plane.Transform(xform);
}
#endregion

#region properties
Expand Down
2 changes: 2 additions & 0 deletions SaladSlicer/Core/CodeGeneration/CodeLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
// Salad Libs
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.CodeGeneration
{
Expand Down
3 changes: 3 additions & 0 deletions SaladSlicer/Core/CodeGeneration/FeedRate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// Free Software Foundation. For more information and the LICENSE file,
// see <https://github.com/3DCP-TUe/SaladSlicer>.

// Salad Libs
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.CodeGeneration
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions SaladSlicer/Core/CodeGeneration/ProgramGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
// Salad Slicer Libs
using SaladSlicer.Core.Utils;
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.CodeGeneration
{
Expand Down
2 changes: 2 additions & 0 deletions SaladSlicer/Core/CodeGeneration/ProgramGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

// System Libs
using System.Collections.Generic;
// Salad Libs
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.CodeGeneration
{
Expand Down
40 changes: 40 additions & 0 deletions SaladSlicer/Core/Interfaces/IGeometry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// This file is part of SaladSlicer. SaladSlicer is licensed
// under the terms of GNU General Public License as published by the
// Free Software Foundation. For more information and the LICENSE file,
// see <https://github.com/3DCP-TUe/SaladSlicer>.

// Rhino Libs
using Rhino.Geometry;

namespace SaladSlicer.Core.Interfaces
{
/// <summary>
/// Represents the interface for all classes that can have a geometry inside.
/// </summary>
public interface IGeometry
{
#region constructors
/// <summary>
/// Returns an exact duplicate of this IGeometry.
/// </summary>
/// <returns> The exact duplicate of this IGeometry. </returns>
IGeometry DuplicateGeometryObject();
#endregion

#region methods
/// <summary>
/// Transforms the geometry.
/// </summary>
/// <param name="xform"> Transformation to apply to geometry. </param>
/// <returns> True on success, false on failure. </returns>
bool Transform(Transform xform);

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. </param>
BoundingBox GetBoundingBox(bool accurate);
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// Free Software Foundation. For more information and the LICENSE file,
// see <https://github.com/3DCP-TUe/SaladSlicer>.

namespace SaladSlicer.Core.CodeGeneration
// Salad Libs
using SaladSlicer.Core.CodeGeneration;

namespace SaladSlicer.Core.Interfaces
{
/// <summary>
/// Represents the interface for all classes that can generate code lines for a program.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Rhino.Geometry;
using SaladSlicer.Core.CodeGeneration;

namespace SaladSlicer.Core.Slicers
namespace SaladSlicer.Core.Interfaces
{
/// <summary>
/// Represents the interface for all classes that can generate code lines for a program.
Expand All @@ -18,10 +18,10 @@ public interface ISlicer
{
#region constructors
/// <summary>
/// Returns an exact duplicate of this IObject.
/// Returns an exact duplicate of this ISlicer
/// </summary>
/// <returns> The exact duplicate of this IObject. </returns>
ISlicer DuplicateObject();
/// <returns> The exact duplicate of this ISlicer. </returns>
ISlicer DuplicateSlicerObject();
#endregion

#region methods
Expand All @@ -31,13 +31,6 @@ public interface ISlicer
/// <param name="programGenerator"> The program generator. </param>
void ToSinumerik(ProgramGenerator programGenerator);

/// <summary>
/// Transforms the geometry.
/// </summary>
/// <param name="xform"> Transformation to apply to geometry. </param>
/// <returns> True on success, false on failure. </returns>
bool Transform(Transform xform);

/// <summary>
/// Returns the path.
/// </summary>
Expand All @@ -55,13 +48,6 @@ public interface ISlicer
/// </summary>
/// <returns> The linearized path. </returns>
Curve GetLinearizedPath();

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. </param>
BoundingBox GetBoundingBox(bool accurate);
#endregion

#region properties
Expand Down
40 changes: 25 additions & 15 deletions SaladSlicer/Core/Slicers/ClosedPlanar2DSlicer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
// Slicer Salad Libs
using SaladSlicer.Core.CodeGeneration;
using SaladSlicer.Core.Geometry.Seams;
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.Slicers
{
/// <summary>
/// Represents the Planar 2D Slicer class.
/// </summary>
public class ClosedPlanar2DSlicer : IProgram, ISlicer
public class ClosedPlanar2DSlicer : IProgram, ISlicer, IGeometry
{
#region fields
private Curve _baseContour;
Expand Down Expand Up @@ -115,13 +116,22 @@ public IProgram DuplicateProgramObject()
}

/// <summary>
/// Returns an exact duplicate of this Planar 2D Slicer instance as an IObject.
/// Returns an exact duplicate of this Planar 2D Slicer instance as an ISlicer.
/// </summary>
/// <returns> The exact duplicate of this Planar 2D Slicer instance as an IObject. </returns>
public ISlicer DuplicateObject()
/// <returns> The exact duplicate of this Planar 2D Slicer instance as an ISlicer. </returns>
public ISlicer DuplicateSlicerObject()
{
return this.Duplicate() as ISlicer;
}

/// <summary>
/// Returns an exact duplicate of this Planar 2D Slicer instance as an IGeometry.
/// </summary>
/// <returns> The exact duplicate of this Planar 2D Slicer instance as an IGeometry. </returns>
public IGeometry DuplicateGeometryObject()
{
return this.Duplicate() as IGeometry;
}
#endregion

#region methods
Expand Down Expand Up @@ -309,17 +319,6 @@ public Curve GetLinearizedPath()
return new PolylineCurve(this.GetPoints());
}

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. </param>

public BoundingBox GetBoundingBox(bool accurate)
{
return this.GetPath().GetBoundingBox(accurate);
}

/// <summary>
/// Returns the length of the path.
/// </summary>
Expand Down Expand Up @@ -373,6 +372,17 @@ public List<List<Point3d>> GetPointsByLayer()
return points;
}

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. </param>

public BoundingBox GetBoundingBox(bool accurate)
{
return this.GetPath().GetBoundingBox(accurate);
}

/// <summary>
/// Transforms the geometry.
/// </summary>
Expand Down
40 changes: 25 additions & 15 deletions SaladSlicer/Core/Slicers/ClosedPlanar3DSlicer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
using SaladSlicer.Core.CodeGeneration;
using SaladSlicer.Core.Geometry;
using SaladSlicer.Core.Geometry.Seams;
using SaladSlicer.Core.Interfaces;

namespace SaladSlicer.Core.Slicers
{
/// <summary>
/// Represents the Planar 3D Slicer class.
/// </summary>
public class ClosedPlanar3DSlicer : IProgram, ISlicer
public class ClosedPlanar3DSlicer : IProgram, ISlicer, IGeometry
{
#region fields
private Mesh _mesh ;
Expand Down Expand Up @@ -124,13 +125,22 @@ public IProgram DuplicateProgramObject()
}

/// <summary>
/// Returns an exact duplicate of this Planar 3D Slicer instance as an IObject.
/// Returns an exact duplicate of this Planar 3D Slicer instance as an ISlicer.
/// </summary>
/// <returns> The exact duplicate of this Planar 3D Slicer instance as an IObject. </returns>
public ISlicer DuplicateObject()
/// <returns> The exact duplicate of this Planar 3D Slicer instance as an ISlicer. </returns>
public ISlicer DuplicateSlicerObject()
{
return this.Duplicate() as ISlicer;
}

/// <summary>
/// Returns an exact duplicate of this Planar 3D Slicer instance as an IGeometry.
/// </summary>
/// <returns> The exact duplicate of this Planar 3D Slicer instance as an IGeometry. </returns>
public IGeometry DuplicateGeometryObject()
{
return this.Duplicate() as IGeometry;
}
#endregion

#region methods
Expand Down Expand Up @@ -376,17 +386,6 @@ public Curve GetLinearizedPath()
return new PolylineCurve(this.GetPoints());
}

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. </param>

public BoundingBox GetBoundingBox(bool accurate)
{
return this.GetPath().GetBoundingBox(accurate);
}

/// <summary>
/// Returns the length of the path.
/// </summary>
Expand Down Expand Up @@ -440,6 +439,17 @@ public List<List<Point3d>> GetPointsByLayer()
return points;
}

/// <summary>
/// Returns the Bounding Box of the object.
/// </summary>
/// <returns> The Bounding Box. </returns>
/// <param name="accurate"> If true, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. </param>

public BoundingBox GetBoundingBox(bool accurate)
{
return this.GetPath().GetBoundingBox(accurate);
}

/// <summary>
/// Transforms the geometry.
/// </summary>
Expand Down
Loading

0 comments on commit 2621582

Please sign in to comment.