Table of Contents

Geometry Objects

IGetStl is the single-member interface that hands back an Stl, and it is what the geometries listed below have in common — most of them reach it through IStlSource, which adds XML persistence on top of it. It does not span every geometry object: a voxel mesh reference such as CubeTreeFile persists itself and presents itself without ever answering GetStl. Code meant to accept every kind of geometry binds to the interface that group actually shares, not to IGetStl.

Several common geometry types are available:

The values underneath them — vec3d_t, box3d_t, tri3d_t — are structs, not geometries. Box3d is the box as a geometry kind: it wraps one box3d_t in its Box property and has no math members, so a box3d_t cannot fill a geometry slot (new Box3d(box) wraps it, geom.Box reads it back), the bounds of any geometry that implements IExpandToBox3d are new box3d_t(geom), and a mesh from a bare value is new Stl(box).

See Transformations for TransformationGeom.

Note

All coordinate values use standard units (millimeters, radians)

Example Usage

using System;
using System.Collections.Generic;
using Hi.Geom;
using Hi.Mech.Topo;

namespace Sample.Geom;

/// <summary>
/// Demonstrates the creation and manipulation of geometric objects in HiAPI.
/// Shows how to create and transform various geometry types including boxes, cylindroids, and STL files.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
/// </remarks>
public static class DemoBuildGeom
{
    /// <summary>
    /// Generates a collection of geometric objects for demonstration purposes.
    /// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
    /// </summary>
    /// <returns>A list of geometries implementing the IGetStl interface</returns>
    public static List<IGetStl> GenGeoms()
    {
        Box3d box = new Box3d(0, 0, -50, 70, 50, 0);
        Cylindroid cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
                                new PairZr(20,16),new PairZr(30,16)]);
        Stl stl = new Stl("geom.stl");
        StlFile stlFile = new StlFile("geom.stl");
        TransformationGeom transformationGeom = new TransformationGeom()
        {
            Transformer = new GeneralTransform(1,
                new StaticRotation(new vec3d_t(0, 0, 1), MathUtil.ToRad(15), new vec3d_t(0, 0, 0)),
                new StaticTranslation(new vec3d_t(0, 0, 0))),
            Geom = stl
        };
        GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
        return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
    }
}

See Also