Table of Contents

Class DemoStl

Namespace
Sample.Disp
Assembly
Hi.Sample.Wpf.dll

Demonstrates the loading, manipulation, and display of STL (stereolithography) files in HiAPI. Shows operations like loading STL data, transforming geometries, and basic visualization.

public static class DemoStl
Inheritance
DemoStl
Inherited Members

Remarks

Source Code

using Hi.Disp;
using Hi.Geom;
using Hi.WpfPlus.Disp;
using System;

namespace Sample.Disp
{
    /// <summary>
    /// Demonstrates the loading, manipulation, and display of STL (stereolithography) files in HiAPI.
    /// Shows operations like loading STL data, transforming geometries, and basic visualization.
    /// </summary>
    /// <remarks>
    /// ### Source Code
    /// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoStl.cs)]
    /// </remarks>
    public static class DemoStl
    {
        internal static void TransformStl()
        {
            #region DocSite.TransformStl
            Stl stl;

            stl = new Stl("Demo/cubic.stl");
            //scale the stl to 100x.
            stl.Transform(new Mat4d(100));
            //create a new stl file.
            stl.WriteBin("big_cubic.stl");

            stl = new Stl("Demo/cubic.stl");
            //move the stl by (100,0,0)
            stl.Transform(new Mat4d(new Vec3d(100, 0, 0)));
            //create a new stl file.
            stl.WriteBin("offset_x100_cubic.stl");
            #endregion
        }

        internal static void DemoCommonUsage()
        {
            #region DocSite.CommonUsage
            Stl stl = new Stl("Disp/cubic.stl");
            Box3d bouindingbox = new Box3d(stl);
            Console.WriteLine("bouindingbox.Min: " + bouindingbox.Min);
            Console.WriteLine("bouindingbox.Max: " + bouindingbox.Max);
            Console.WriteLine("bouindingbox.Center: " + bouindingbox.Center);
            DispFrameUtil.Call("DemoForm", stl.ToFaceDrawing());
            #endregion
        }

        static void Main()
        {
            DemoCommonUsage();
        }
    }
}