-
Notifications
You must be signed in to change notification settings - Fork 5
Underlying Structure
*** Needs Update ***
JSxCAD operates on shape objects. Each [shape]## (https://github.com/jsxcad/JSxCAD/blob/master/api/v1/Shape.js) contains a lazy geometry, and each lazy geometry contains geometry. Geometry can be an instance of assembly, solid, paths, z0Surface, or points.
Shape
lazyGeometry:
geometry:
assembly, solid, Z0Surface, paths, or points:
More information on each of these components:
A shape is the user api level wrapper for geometry which is exposed through the api. Shape provides some high level functions such as translate and scale. Built in shape primitives like cube or sphere return an instance of shape.
A lazyGeometry is a lower level wrapper for geometry. It provides its own methods for how to work with and transform the geometry such as .intersection, .union, .transform.
Geometry serves as a container for Assembly, Solid, Paths, Z0Surface. Geometry also provides functions to convert to other geometry types such as toDisjointGeometry, toGeometry, toPaths, toSolid, toZ0Surface.
Points is an array of vectors of 3 points in xyz which simply define points in 3D space.
Paths is an array of path vectors. Each path is an array of points in 3D space. A path has a direction based on the order of the points.
A Z0Surface is an array of paths on a plane. The inside of the surface is defined as the area enclosed to the left of each path. A surface can be defined by multiple co-planar non-intersecting paths to create a surface with holes.
Solid is an array of surfaces enclosing a space. A solid is enclosed meaning it has volume (ie a sphere would be a solid, but a shape with a hole in it like a fish bowl would not be a solid).
An Assembly is an array of other geometries of the above types.
You can retrieve the geometry from a shape using the provided functions like toPaths, toPoints...etc. Not that these functions will not convert between geometry types, just retrieve the geometry which is already in place so if you call toPaths on a solid without a paths geometry defined you will get nothing back.
You can convert a geometry to a disjointGeometry with the .toDisjointGeometry function. disjointGeometry is geometry with the overlapping parts removed to form an empty shell. Not that this performs a conversion and is resource intensive.
The internal structure of jsxcad is grouped into packages. Each package can import and access the features of the levels below it, but not above it.