3D Printer slicer

Use the following code to slice an STL model in your 3D printing application.

ReadSTL rs = new ReadSTL(@"c:\devdept\bunny.stl");
rs.DoWork();
rs.AddToScene(viewportLayout1);

Mesh m = (Mesh) rs.Entities[0];
m.ColorMethod = colorMethodType.byEntity;
m.Color = Color.Aquamarine;

Plane p = Plane.XY;

LinkedList[] edgesPerVertex;
Utility.GetEdgesWithoutDuplicates(m.Triangles, m.Vertices.Length, out edgesPerVertex);

int num = 100;

List<Entity> sections = new List<Entity>(num);

for (int iz = 0; iz < num; iz++)
{
    p.Translate(new Vector3D(0, 0, m.BoxSize.Z / num));

    ICurve[] sCurves = m.Section(p, 0, edgesPerVertex);

    foreach (Entity c in sCurves)
    {
        sections.Add(c);
    }
}

viewportLayout1.Entities.AddRange(sections, Color.Blue);

An this is the result:

slicer.png

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.