{0 OCADml}

OCADml is a collection of types and functions built on top of
{{:https://erratique.ch/software/gg} 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.

{1 Usage}

{[
  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"
]}

{%html: <img src="_assets/vacuum_connector.png" style="width:125mm;" /> %}

{1:api API}

- {!module-OCADml} -- top level library interface
- {!module-PolyText} -- point representations of text (only installed if cairo is available)

{2 Vectors and transformations}
- {{!OCADml.V2} [V2]} -- 2d vector operations
- {{!OCADml.V3} [V3]} -- 3d vector operations
- {{!OCADml.Affine2} [Affine2]} -- 2d affine transformation matrices
- {{!OCADml.Affine3} [Affine3]} -- 3d affine transformation matrices
- {{!OCADml.Quaternion} [Quaternion]} --
 {{:https://en.wikipedia.org/wiki/Quaternion} quaternion} manipulation andl application
- {{!OCADml.Plane} [Plane]} -- normalized cartesian plane operations

{2 2d paths and polygons}
- {{!OCADml.Path2} [Path2]} -- generation and manipulation of 2d paths
- {{!OCADml.Bezier2} [Bezier2]} -- 2d bezier curves, patches, and splines
- {{!OCADml.CubicSpline} [CubicSpline]} -- cubic spline interpolation of 2d paths
- {{!OCADml.Poly2} [Poly2]} -- 2d polygons (outer, and zero or more inner paths)
- {{!PolyText} [PolyText]} -- point representations of text (via cairo)

{2 3d paths, coplanar polygons, and meshes}
- {{!OCADml.Path3} [Path3]} -- generation and manipulation of 3d paths
- {{!OCADml.Bezier3} [Bezier3]} -- 3d bezier curves, patches, and splines
- {{!OCADml.Poly3} [Poly3]} -- planar 3d polygons (outer, and zero or more inner paths)
- {{!OCADml.Mesh} [Mesh]} -- triangular mesh generation

{2 Utilities}
- {{!OCADml.Math} [Math]} -- float and 2d matrix operations
- {{!OCADml.BallTree2} [BallTree2]} -- 2d vector space partitioning search tree
- {{!OCADml.BallTree3} [BallTree3]} -- 3d vector space partitioning search tree

{1:toplevel Using OCaml top-level}

As this library uses vector types from {{:https://erratique.ch/software/gg} Gg},
the associated pretty printing functionality can be unlocked in the top-level
via [#require "gg.top";;].

{1:cad 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.

{2 OSCADml}
- {{:https://github.io/OSCADml } github}
- {{:https://ocadml.github.io/OSCADml/OSCADml/index.html} docs}
- {{:https://ocadml.github.io/OSCADml/OSCADml/index.html#examples} examples}

{1:ppx \[@@deriving cad\]}

There is a companion ppx, {{:https://github.com/OCADml/ppx_deriving_cad} \[@@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 ({{!OCADml.V2.t} [V2.t]} or {{!OCADml.V3.t} [V3.t]})
(and those composed of them) provided in this library.
