Class StlDataStructure


public class StlDataStructure extends Object

Data structure used to store 3D objects that is native to the STL file format [1,2]. One deviation is that vertexes are stored as an integer reference. This is done to reduce storage size and make verifying the correctness of a solid easier.

All Facets have exactly 3 vertexes.

Rules from specification:

  • Vertex-to-vertex rule. Each triangle must share two vertices with each of its adjacent triangles. In other words, a vertex of one triangle cannot lie on the side of another.
  • Facet orientation. The facets define the surface of a 3-dimensional object. As such, each facet is part of the boundary between the interior and the exterior of the object. The orientation of the facets (which way is “out” and which way is “in”) is specified redundantly in two ways which must be consistent. First, the direction of the normal is outward. Second, the vertices are listed in counterclockwise order when looking at the object from the outside (right-hand rule).

[1] StereoLithography Interface Specification, 3D Systems, Inc., October 1989

[2] The STL Format

  • Field Details

    • vertexes

      public final PackedBigArrayPoint3D_F64 vertexes
      3D location of each vertex
    • normals

      public final PackedBigArrayPoint3D_F64 normals
      Normals stored in a compact format
    • facetVertsIdx

      public DogArray_I32 facetVertsIdx
      Mapping from vertex in a Facet to the value of a vertex in 3D stored in vertexes
    • name

      public String name
      What's the name of this Solid
  • Constructor Details

    • StlDataStructure

      public StlDataStructure()
  • Method Details

    • reset

      public void reset()
    • setTo

      public StlDataStructure setTo(StlDataStructure src)
    • addFacet

      public void addFacet(Point3D_F64 v1, Point3D_F64 v2, Point3D_F64 v3, Vector3D_F64 normal)
      Adds the facet with the provided normal vector
    • addFacet

      public void addFacet(Point3D_F64 v1, Point3D_F64 v2, Point3D_F64 v3)
      Adds the facet. Computes the normal vector using cross product on the input points
    • addFacet

      public void addFacet(int vertIdx1, int vertIdx2, int vertIdx3, Vector3D_F64 normal)
    • facetCount

      public int facetCount()
      Number of Facets in this solid
    • size

      public int size()
      Same as facetCount()
    • getFacet

      public void getFacet(int which, Vector3D_F64 outNormal, DogArray<Point3D_F64> outVertexes)
      Retrieves the 3D structure of a facet
      which - Which facet in this solid is being requested.
      outNormal - The normal vector of the facet
      outVertexes - All the vertexes for this facet
    • toMesh

      public VertexMesh toMesh(@Nullable @Nullable VertexMesh out)
      Converts this into a VertexMesh. Information about normals and the name are discarded.
      out - Storage for output mesh. Can be null.
      The converted mesh.
    • toAccess

      public MeshPolygonAccess toAccess()
      Wraps the data structure inside MeshPolygonAccess.