Added VertexStorage offset extension method

This commit is contained in:
LarsBrubaker 2018-04-21 08:14:00 -07:00
parent f78f737154
commit caaa58a551
3 changed files with 22 additions and 2 deletions

View file

@ -78,6 +78,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
List<List<IntPoint>> intersectedPolys = new List<List<IntPoint>>();
clipper.Execute(clipType, intersectedPolys);
Clipper.CleanPolygons(intersectedPolys);
VertexStorage output = VertexSourceToClipperPolygons.CreateVertexStorage(intersectedPolys);
output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);
@ -85,6 +87,24 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return output;
}
public static VertexStorage Offset(this IVertexSource a, double distance)
{
List<List<IntPoint>> aPolys = VertexSourceToClipperPolygons.CreatePolygons(a);
ClipperOffset offseter = new ClipperOffset();
offseter.AddPaths(aPolys, JoinType.jtMiter, EndType.etClosedPolygon);
var solution = new List<List<IntPoint>>();
offseter.Execute(ref solution, distance * 1000);
Clipper.CleanPolygons(solution);
VertexStorage output = VertexSourceToClipperPolygons.CreateVertexStorage(solution);
output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);
return output;
}
public static IObject3D Plus(this IObject3D a, IObject3D b)
{
var results = new Object3D();