Class: SolidBuilder

SolidBuilder is a factory class for creating solid primitives -- boxes, spheres, cylinders, cones, tori, and lofted shapes. All methods are static, so you never need to instantiate the class; just call SolidBuilder.box(...) directly.

When to use

  • Creating basic 3D shapes -- start with primitives and refine them with boolean operations, fillets, or transformations.
  • Rapid prototyping -- quickly assemble geometry from boxes, cylinders, and spheres before moving to complex surface modeling.
  • Building blocks for booleans -- create cutters, pockets, and bosses to combine with Solid.union, Solid.difference, and Solid.intersection.

Quick start

import { SolidBuilder, Vector } from '@beegraphy/opencascade';

// Box: origin, width, length, height
const box = SolidBuilder.box(new Vector(0, 0, 0), 20, 30, 10);

// Sphere: origin, radius
const sphere = SolidBuilder.sphere(new Vector(0, 0, 0), 15);

// Cylinder: origin, radius, height
const cyl = SolidBuilder.cylinder(new Vector(0, 0, 0), 5, 20);

// Cone: origin, bottomRadius, topRadius, height
const cone = SolidBuilder.cone(new Vector(0, 0, 0), 10, 3, 15);

// Torus: origin, majorRadius, minorRadius
const torus = SolidBuilder.torus(new Vector(0, 0, 0), 20, 5);

// Combine shapes
const result = box.difference([cyl, sphere]);

Key methods

MethodDescription
box(origin, width, length, height)Create a rectangular box solid
box2Pnt(point1, point2)Create a box defined by two corner points
sphere(origin, radius)Create a sphere solid
cylinder(origin, radius, height)Create a cylinder solid
cone(origin, radius1, radius2, height)Create a cone or frustum solid
torus(origin, radius1, radius2)Create a torus (donut) solid
loft(surfaces, degree)Create a lofted solid from an array of surfaces

Static Method: box

Creates a box solid with the specified dimensions.

Parameters

  • origin (IVector): The origin point of the box.
  • width (number): The width of the box.
  • length (number): The length of the box.
  • height (number): The height of the box.

Returns

A Solid object representing the box.

Example

const origin = new Vector(1, 1, 1);
const width = 0.5;
const length = 10;
const height = 0.5;
SolidBuilder.box(origin, width, length, height);

Static Method: box2Pnt

Creates a solid box between two points.

Parameters

  • point1 (IVector): The first point defining the box.
  • point2 (IVector): The second point defining the box.

Returns

A Solid object representing the created box.

Example

const point1 = new Vector(1, 1, 1);
const point2 = new Vector(1, 1, 1);
SolidBuilder.box2Pnt(point1, point2);

Static Method: sphere

Creates a sphere solid with the given origin and radius.

Parameters

  • origin (IVector): The origin point of the sphere.
  • radius (number): The radius of the sphere.

Returns

A Solid object representing the sphere.

Example

const origin = new Vector(1, 1, 1);
const radius = 10;
SolidBuilder.sphere(origin, radius);

Static Method: cone

Creates a cone solid.

Parameters

  • origin (IVector): The origin point of the cone.
  • radius1 (number): The radius of the base of the cone.
  • radius2 (number): The radius of the top of the cone.
  • height (number): The height of the cone.

Returns

A Solid object representing the cone.

Example

const origin = new Vector(1, 1, 1);
const radius1 = 0.5;
const radius2 = 0.5;
const height = 0.5;
SolidBuilder.cone(origin, radius1, radius2, height);

Static Method: cylinder

Creates a cylinder solid with the specified origin, radius, and height.

Parameters

  • origin (IVector): The origin point of the cylinder.
  • radius (number): The radius of the cylinder.
  • height (number): The height of the cylinder.

Returns

A Solid object representing the cylinder.

Example

const origin = new Vector(1, 1, 1);
const radius = 10;
const height = 0.5;
SolidBuilder.cylinder(origin, radius, height);

Static Method: torus

Creates a torus solid.

Parameters

  • origin (IVector): The origin of the torus.
  • radius1 (number): The major radius of the torus.
  • radius2 (number): The minor radius of the torus.

Returns

A Solid object representing the torus.

Example

const origin = new Vector(1, 1, 1);
const radius1 = 0.5;
const radius2 = 0.5;
SolidBuilder.torus(origin, radius1, radius2);

Static Method: loft

Creates a lofted solid from the given array of surfaces.

Parameters

  • surfaces (ISurface[]): The array of surfaces to loft.
  • degree (number): The degree of the lofted solid.

Returns

A new Solid object representing the lofted solid.

Example

const surfaces = /* specify a surfaces */;
const degree = 0.5;
SolidBuilder.loft(surfaces, degree);