Module fj_core::objects

source ·
Expand description

Objects of a shape

Objects, in Fornjot parlance, are the elements that make up shapes. Objects can reference each other, forming a directed acyclic graph (DAG).

There are two top-level objects (Sketch and Solid) which represent whole shapes (2D and 3D, respectively), while all other objects are referenced (directly or indirectly) by these top-level objects.

All objects are stored in centralized storage (see Objects) and referred to through a Handle.

Object Equality vs Object Identity

Most objects have Eq/PartialEq implementations that can be used to determine equality. Those implementations are derived, meaning two objects are equal, if all of their fields are equal. This can be used to compare objects structurally. Handle’s own Eq/PartialEq implementations defer to those of the object it references.

However, that two objects are equal does not mean they are identical. See Handle’s documentation for an explanation of this distinction.

This distinction is relevant, because non-identical objects that are supposed to be equal can end up being equal, if they are created based on simple input data (as you might have in a unit test). But they might end up slightly different, if they are created based on complex input data (as you might have in the real world). This situation would most likely result in a bug that is not easily caught in testing.

Validation Must Use Identity

To prevent such situations, where everything looked fine during development, but you end up with a bug in production, any validation code that compares objects and expects them to be the same, must do that comparison based on identity, not equality. That way, this problem can never happen, because we never expect non-identical objects to be the same.

Structs

  • Implementation of Form for bare objects
  • Implementation of Form for objects behind a handle
  • A cycle of connected half-edges
  • A face of a shape
  • A collection of faces
  • An undirected edge, defined in global (3D) coordinates
  • A directed edge, defined in a surface’s 2D space
  • A graph of objects and their relationships
  • The available object stores
  • A single, continuous 2d region, may contain holes
  • A 3-dimensional closed shell
  • A 2-dimensional shape
  • A 3-dimensional shape, built from Shells. Many Solids will contains only one shell, but if the Solid contains cavities they will be represented by a shell each, as well as a shell for the outside.
  • A two-dimensional shape
  • Store for Surfaces
  • A vertex, defined in global (3D) coordinates
  • Implementation of Form for objects that are paired with their handle

Enums

Traits

  • The form that an object can take

Type Definitions