OCADml is a collection of types and functions built on top of Gg facilitating Computer Aided Design (CAD) in OCaml. In particular, the style of design currently supported is that of 2D drawing and mesh generation via sweeping/extrusion.


open OCADml

let () =
  let fn = 128 in
  let base =
    let sq = Path3.square ~center:true (v2 2. 4.) in
    Path3.(roundover ~fn (Round.flat ~corner:(Round.circ (`Radius 0.5)) sq))
  and c r h = Path3.ztrans h @@ Path3.circle ~fn r in
  let cones = List.map (fun h -> [ c 0.6 h; c 0.5 (h +. 1.) ]) [ 4.; 5.; 6. ] in
  List.flatten ([ base; Path3.ztrans 2. base; c 0.5 3.; c 0.5 4. ] :: cones)
  |> Mesh.skin ~slices:(`Flat 0)
  |> Mesh.to_stl "vacuum_connector.stl"


Vectors and transformations

2d paths and polygons

3d paths, coplanar polygons, and meshes


Using OCaml top-level

As this library uses vector types from Gg, the associated pretty printing functionality can be unlocked in the top-level via #require "gg.top";;.

CAD Package Specific Frontends

This library only provides a means to generate point and face based geometries, in order to perform boolean operations, validation, and export (to formats other than stl), you'll need to work with a particular CAD package.


[@@deriving cad]

There is a companion ppx, [@@deriving cad] for generating transformation functions for user-defined records and abstract types composed of types for which the basic transformation functions are defined, such as vectors (V2.t or V3.t) (and those composed of them) provided in this library.