DInsight Home

Surfaces

# Surfaces

A solid 3D object is called linked if it consists of a single piece, more precisely if any two points in the object can be connected with a single continuous curve.

A Geometric Surface is external shell of a 3D solid linked object (Closed Surface). or part of it. In the later case it is called Open Surface.

KernelCAD Surface, or simply Surface is a Geometric Surface considered as a collection of patches joined together by edges.

Patch is a smooth (without internal corners or folded lines) linked piece of two dimensional surface. Simplest example of a patch is 3D rectangle or 3D triangle. Patch can have any number of edges or none at all (sphere). An Edge is a smooth curve, which can be closed line or line with ends. Edges are joined by ends into linked sequences called wires. A 3D rectangle has a single wire consisting of four edges. If we cut a triangular hole in a 3D rectangle the resulting shape will be a patch with two wires with four (external) and three (internal) edges respectively.

Edges inside a wire are normally indexed in CCW direction (looking from outside of the object, or in other words looking into direction oppositite to normal to the surface). So if one moves along a wire the patch always remains on the left hand side. Wires are considered as strips of curves (elements) joined by vertices (connectors). Array of wires is returned by IPatch.GetEdgeComponents()

Frequently patches are defined by  a number of parameters which can be modified programmatically or at design time to change its geometry.

A box is a surface with six patches and twelve edges. Note that a geometric surface can be subdivided into patches in different ways. Sphere can either be considered as collection of eight equal patches with eight edges or as is single patch without edges.

Normal to a patch at a point is a ray perpendicular to the patch at this point.

Point at an end of an edge is called Vertex (Vertices plural). A box has eight vertices. Each vertex in a box has three adjacent edges and three patches. Note that closed edges normally do not have ends.

Set of normals of all patches adjacent to a vertex at the point of the vertex are considered a property of the vertex. They are called normals of the vertex.

Above means that a surface can be considered as a hierarchy of patches, edges (lines) and vertices.

3DS Patches are special kinds of patches. They are limited by number of edges, which must be at least two (top and bottom edges have zero length) and maximum four. 3DS Patches can have between two and four vertices. Top and bottom edges of a 3DS patch are flat curves in plane orthogonal to z axis.

A vertex is called singular if adjacent patches have different normals at the point. For example each vertex of a box has three normals so it is singular.

An edge is called singular if either end vertex is singular. It means that adjacent patches have non-zero angle along the edge

Vertices and edges, which are not singular are called regular.

## Software Representation

KernelCAD software representation of surfaces keeps three lists for patches, edges and vertices of the surface.

Each patch keeps array of its edges and array of its vertices, both in Counter Clock Wise order if looking from the external side of the patch (side of outer normal). i-th vertex in the vertex array is a shared end of i-th and (i-1)-th edge. Edges are shared between two adjacent patches.

Each edge keeps references to its end vertices and list of all vertices, including internal ones. An edge can be accessed via IKCLine, obtained via ISurface. The list starts with the first end and ends with the last end. To access the list, query IList from the relevant IKCLine interface. Type of elements stored in the list is IVertex.

Each vertex keeps set of its normals (normals of adjacent patches). Number of normals kept by the vertex is called Rank A vertex is singular if its rank is greater than 1.

Structure of surface of a 3D object can be discovered programmatically via ISurface interface queried from the relevant ISection..

## Surface versus Mesh

Mesh of an object is a lower level representation of geometrical surface. It is designed for rendering the object quickly in 3D. Mesh is not aware of patch/edge/vertex structure of the surface.

Normally each patch of a surface is approximated by many simplexes of the mesh. Each patch edge normally consists of many simplex edges. Vertices of a surface are vertices of the underlying mesh, but normally there are many more vertices in the mesh, which do not belong to the formal hierarchy of the surface.

Mesh and surface are synchronized. Edges of patches are represented by simplex edges only. There is no simplex edge which crosses a patch edge. Patches are represented by simplexes only. There is no simplex, which geometrically belong to two different patches.

Surfaces and meshes are organized similarly. Patches act similar to simplexes and edges of surface are similar to simplex edges. One of the differences is that simplexes have fixed number of edges.

Normally surface is defined first by constructing it from patches and modifying its parameters. Meshes are generated automatically on a later stage from the surface information to approximate it. The reverse procedure is possible too. For example Mesh Section objects are constructed from mesh only. Surface structure  in this case is generated by analyzing which vertices and edges are singular (are sharp corners or edges). Surface generated in this way is called Singular Subdivision.