cadlib

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cadlib for Go

Go bindings for the SimScale cadlib native library: load a CAD model input to a workflow method and run geometry queries on it (volume, bounding box, tessellation, …).

[!NOTE] cadlib is meant to be used in the Docker image that implements the workflow method. It is not intended for validations.

The package is a thin cgo layer over the prebuilt cadlib native library. You need Go 1.21 or newer and a C compiler with cgo enabled (CGO_ENABLED=1): gcc or clang, and mingw-w64 gcc on Windows.

Install

1. Install the native library

Each release ships two install scripts: install-cadlib.sh for Linux and macOS, and install-cadlib.ps1 for Windows. A script downloads the native library of its own release, checks it against the SHA-256 digest embedded in the script, and installs it. Use the scripts of the release you depend on.

Linux and macOS
curl -fsSL https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/v<version>/install-cadlib.sh | sh

It installs into /usr/local by default, which usually needs sudo (… | sudo sh), and prints the follow-up step for your platform: sudo ldconfig on Linux, or the environment variables below for any other location. --dry-run prints the download URL, the digest and the install paths without changing anything; --help lists the options.

To install somewhere else, for example without sudo:

curl -fsSL https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/v<version>/install-cadlib.sh | sh -s -- --prefix "$HOME/.local"
export CGO_LDFLAGS="-L$HOME/.local/lib"                                         # where the build links it
export LD_LIBRARY_PATH="$HOME/.local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"  # where programs load it

On macOS use CGO_LDFLAGS="-L$HOME/.local/lib -Wl,-rpath,$HOME/.local/lib" and DYLD_LIBRARY_PATH instead.

Windows

cgo on Windows needs the mingw-w64 gcc; Visual Studio's compiler does not work with cgo. In PowerShell:

choco install -y mingw                     # or MSYS2, with its mingw64\bin on PATH
irm https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/v<version>/install-cadlib.ps1 | iex

It installs into %LOCALAPPDATA%\cadlib by default and prints the CGO_LDFLAGS and PATH settings to use. -Prefix installs somewhere else and -DryRun changes nothing, like --prefix and --dry-run above:

iex "& { $(irm https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/v<version>/install-cadlib.ps1) } -Prefix C:\cadlib"

To run your program on another machine, ship cadlib.dll next to the .exe; that machine also needs the VC++ 2015–2022 redistributable.

In CI

Install the library of the module version your go.mod resolves to. On a Linux runner:

V=$(go list -m -f '{{.Version}}' github.com/SimScaleGmbH/simscale-go-cadlib)  # the module version is the git tag
curl -fsSL "https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/$V/install-cadlib.sh" | sh
ldconfig

CI containers usually run as root; without root, use --prefix and the exports above. On a Windows runner, in one step:

$V = go list -m -f '{{.Version}}' github.com/SimScaleGmbH/simscale-go-cadlib
irm "https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/$V/install-cadlib.ps1" | iex
$env:CGO_LDFLAGS = "-L$($env:LOCALAPPDATA -replace '\\', '/')/cadlib/lib"
$env:PATH = "$env:LOCALAPPDATA\cadlib\lib;$env:PATH"

To download from a mirror of the release assets, set CADLIB_DOWNLOAD_BASE (the script fetches $CADLIB_DOWNLOAD_BASE/v<version>/cadlib-<platform>.tar.gz); the embedded digest still applies.

About the script
  • Needs curl or wget, and sha256sum or shasum; on Windows, the tar.exe that ships with Windows 10 1803 and later.
  • Installs lib/libcadlib.so (libcadlib.dylib on macOS, cadlib.dll and cadlib.lib on Windows), include/cadlib.h, and the licenses in share/doc/cadlib/, all under the prefix. To uninstall, delete them.
  • Updating means running the new release's script. On a checksum mismatch it installs nothing. On Linux and macOS, running programs keep the old library until they restart; on Windows, stop them first.
  • To read it before running it, download it in place of piping it to sh. A commit hash in place of the tag in the URL pins the script and its digests.
  • Errors: "Intel Macs are not supported" also shows in a Rosetta shell on an Apple silicon Mac. "cannot write to /usr/local" needs sudo or --prefix.
2. Get the module
go get github.com/SimScaleGmbH/simscale-go-cadlib@v<version>
import cadlib "github.com/SimScaleGmbH/simscale-go-cadlib"

The C header ships inside the module.

Versions must match

Each release of the module accepts exactly one native library: the one released with it. On the first Load the package compares the two and fails with an error pointing at the install scripts of the right release.

Usage

// Load the CAD model from the CAD data map entry of the method's input parameters.
cad, err := cadlib.Load(request.DataMap.Cad)
if err != nil {
	return err
}
defer cad.Close()

result, err := cad.Volume(&cadlib.VolumeParameters{EntityIDs: []string{"B1_TE5"}})
  • Load once, reuse. Each Load rebuilds the model, which is expensive, so load once and run every query on the same *Cad.
  • Close releases the native resources; call it when you no longer need the model.
  • Not safe for concurrent use. Queries on one *Cad block and must not run from several goroutines at once.
  • Errors are either a *cadlib.CadExpectedError, a known domain error with an ErrorCode, or a *cadlib.CadUnexpectedError. Use errors.As to tell them apart. The codes are listed in ERRORS.md. The exception is a failure in the bindings to marshal an argument or unmarshal a result, which is returned as a plain error wrapping the encoding/json error.

The API reference is on pkg.go.dev.

Docker

Use a glibc base image (see Supported platforms). The library has to be in both stages: the build links it, the runtime loads it.

FROM golang:1.21-bookworm AS builder
ARG CADLIB_VERSION
RUN curl -fsSL "https://raw.githubusercontent.com/SimScaleGmbH/simscale-go-cadlib/v${CADLIB_VERSION}/install-cadlib.sh" | sh \
 && ldconfig
WORKDIR /app
COPY . .
RUN CGO_ENABLED=1 go build -o /app/myservice .

FROM debian:bookworm-slim
COPY --from=builder /usr/local/lib/libcadlib.so /usr/local/lib/
RUN ldconfig
COPY --from=builder /app/myservice /usr/local/bin/myservice
ENTRYPOINT ["myservice"]

Build it with --build-arg CADLIB_VERSION=<version>, the module version you depend on without the leading v. In CI shows how to read it from your go.mod.

Without ldconfig the library is on disk but not found: cannot find -lcadlib when building, error while loading shared libraries: libcadlib.so when running.

Supported platforms

OS Architecture Native library Requires
Linux x86_64, aarch64 libcadlib.so glibc 2.28 or newer (Debian 10+, Ubuntu 20.04+, RHEL 8+)
macOS aarch64 (Apple silicon) libcadlib.dylib macOS 11 or newer
Windows x86_64 cadlib.dll + cadlib.lib Windows 10 or newer, VC++ 2015–2022 redistributable

Alpine and other musl-based distributions are not supported: the library is built for glibc and cannot load on musl. Intel Macs and Windows on Arm are not supported either.

License

MIT, see LICENSE.

Documentation

Overview

Package cadlib provides Go bindings for the SimScale cadlib native library.

The package links against the prebuilt cadlib native library over its stable C ABI (libcadlib.so plus cadlib.h). Install the native library first, see https://github.com/SimScaleGmbH/simscale-go-cadlib#install, then load a model from the CAD data map entry of the method's run request and run queries against it:

cad, err := cadlib.Load(request.DataMap.Cad)
if err != nil {
	return err
}
defer cad.Close()

resp, err := cad.Volume(&cadlib.VolumeParameters{EntityIDs: []string{"B1_TE5"}})

Without the native library, building fails with "cannot find -lcadlib" and running with "error while loading shared libraries: libcadlib.so" (or the macOS and Windows equivalents). Install it with install-cadlib.sh, or install-cadlib.ps1 on Windows, from the release matching this module's version. For a non-default prefix, set CGO_LDFLAGS=-L<prefix>/lib to build and add that directory to the platform's library path to run.

Every Cad value owns native resources, so Close must be called when the model is no longer needed. Query methods are blocking and are not safe for concurrent use on a single Cad value.

Queries fail with one of two typed errors: CadExpectedError for known domain errors (carrying a machine-readable ErrorCode) and CadUnexpectedError for internal failures. Use errors.As to tell them apart. The one exception is a failure in the bindings themselves to marshal an argument or unmarshal a result to or from JSON, which is returned as a plain error.

The model types in models.go and the query methods in cad.go are generated.

Code generated for the SimScale cadlib Go bindings. DO NOT EDIT.

Index

Constants

View Source
const (
	CadLibOK               = 0
	CadLibErrorInvalidUUID = -1
	CadLibErrorNullPointer = -2
	CadLibErrorInvalidUTF8 = -3
	CadLibErrorInvalidJSON = -4
	CadLibErrorExpected    = -5
	CadLibErrorRuntime     = -6

	// Deprecated: use CadLibErrorExpected, which matches the C name CAD_ERROR_EXPECTED.
	CadLibErrorFailed = CadLibErrorExpected
)

Error codes from the C library

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the library version string.

Types

type AllowedFacetFaultsLevel

type AllowedFacetFaultsLevel string

AllowedFacetFaultsLevel level of faults allowed in tessellation (Supported only for Parasolid models) Used in quality checks to classify the tessellation faults in three levels: mild, moderate and serious. The default is `Mild`, which allows only minor faults that do not significantly affect the quality of the tessellation. `Moderate` allows more significant faults that may affect the quality but are still acceptable for most applications. `Serious` allows all faults, including those that may result in a poor quality tessellation, and should be used with caution.

const (
	AllowedFacetFaultsLevelMild     AllowedFacetFaultsLevel = "mild"
	AllowedFacetFaultsLevelModerate AllowedFacetFaultsLevel = "moderate"
	AllowedFacetFaultsLevelSerious  AllowedFacetFaultsLevel = "serious"
)

Valid AllowedFacetFaultsLevel values.

type BoundingBoxParameters

type BoundingBoxParameters struct {
	// Ids of faces to measure in addition to the model and its bodies. When
	// given, the response also holds the box enclosing all of them and one box
	// per face
	Faces []string `json:"faces,omitempty"`
}

BoundingBoxParameters parameters for bounding box info query

type BoundingBoxResponse

type BoundingBoxResponse struct {
	// Bounding box of the entire model
	ModelBoundingBox Box `json:"modelBoundingBox"`
	// Bounding box of each solid and sheet in the model, keyed by its entity id
	BoundingBoxPerBody map[string]Box `json:"boundingBoxPerBody"`
	// Single box enclosing all the requested faces. Set only when faces were
	// requested
	FacesBoundingBox *Box `json:"facesBoundingBox,omitempty"`
	// Bounding box of each requested face, keyed by its face id. Set only when
	// faces were requested
	BoundingBoxPerFace map[string]Box `json:"boundingBoxPerFace,omitempty"`
}

BoundingBoxResponse response for bounding box query

type Box

type Box struct {
	// Minimum X coordinate
	MinX float64 `json:"minX"`
	// Minimum Y coordinate
	MinY float64 `json:"minY"`
	// Minimum Z coordinate
	MinZ float64 `json:"minZ"`
	// Maximum X coordinate
	MaxX float64 `json:"maxX"`
	// Maximum Y coordinate
	MaxY float64 `json:"maxY"`
	// Maximum Z coordinate
	MaxZ float64 `json:"maxZ"`
}

Box 3D bounding box representation

type Cad

type Cad struct {
	// contains filtered or unexported fields
}

Cad represents a handle to a CAD model state.

func Load

func Load(entry any) (*Cad, error)

Load creates a new Cad instance from the CAD data map entry of a workflow method's run request, or from anything else marshalling to the same shape (a map, a struct of your own).

cad, err := cadlib.Load(request.DataMap.Cad)

Only the entry's externalReference is required; dataType and source.type are validated when present and any other key is ignored. A caller holding raw JSON text passes it as a json.RawMessage, which marshals verbatim; a plain string would marshal to a JSON string and be rejected with invalid-cad-model-json. The error codes it can return are listed in https://github.com/SimScaleGmbH/simscale-go-cadlib/blob/main/ERRORS.md. An entry that cannot be marshalled to JSON at all returns a plain error.

func (*Cad) BoundingBox

func (c *Cad) BoundingBox(params *BoundingBoxParameters) (*BoundingBoxResponse, error)

BoundingBox computes the bounding box of the model, of each body, and of any faces given.

The box of the whole model and one box per solid and sheet are always returned. Naming faces additionally returns one box per face, keyed by face id, and a single box enclosing all of them.

Supported for Parasolid and nTop models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) CenterOfGravity

func (c *Cad) CenterOfGravity(params *CenterOfGravityParameters) (*CenterOfGravityResponse, error)

CenterOfGravity computes the center of gravity of the given faces and edges.

The selection accepts faces and edges only; any other entity type fails the query. One center of gravity is computed for the selection as a whole, not one per selected entity.

Supported only for Parasolid models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • compute-cog-entity-not-supported - A selected entity has unsupported type, it is neither a face nor an edge.

func (*Cad) Close

func (c *Cad) Close()

Close releases the resources associated with this Cad instance. After calling Close, the Cad instance should not be used.

func (*Cad) Colors

func (c *Cad) Colors(params *ColorsParameters) (*ColorsResponse, error)

Colors returns the colors defined on the model's solids and sheets.

The query takes no parameters and covers the whole model. Each entry names the entity the color is defined on and the color itself, as a hex string such as #ff0000.

Supported for Parasolid and nTop models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) DetectCommonRotation

func (c *Cad) DetectCommonRotation(params *DetectCommonRotationParameters) (*DetectCommonRotationResponse, error)

DetectCommonRotation detects the rotation axis and center shared by the given faces.

All the given faces must be rotationally aligned about a single axis; the query fails if they are not, or if no axis can be determined. The response gives the direction of that axis and a point on it.

Supported only for Parasolid models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • detect-rotation-axis-not-consistent-for-all-faces - The selected faces do not share the same rotation axis.
  • detect-rotation-could-not-detect-axis - No rotation axis could be detected for the selected faces.
  • detect-rotation-flat-faces-selected[-with-entity] - The selection contains flat faces, which have no rotation axis.
  • detect-rotation-multiple-possible-directions - More than one rotation direction fits the selected faces.

func (*Cad) DetectEnclosure

func (c *Cad) DetectEnclosure(params *DetectEnclosureParameters) (*DetectEnclosureResponse, error)

DetectEnclosure finds the solids that enclose a given point.

The response holds the id of every solid that contains it.

Supported only for Parasolid models. Other model formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) Entities

func (c *Cad) Entities() (*EntitiesResponse, error)

Entities returns the model's entities: solids, sheets, faces, edges and vertices.

The list is flat: each entity references its parents and children by their 0-based index in it. Solids and sheets are the top-level entities.

Each entity carries the entity id that the other queries take as input.

Supported for Parasolid, STL and nTop models.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) GenerateComfortMapDisc

func (c *Cad) GenerateComfortMapDisc(destDir string, params *GenerateComfortMapDiscParameters) (*GenerateComfortMapDiscResponse, error)

GenerateComfortMapDisc generates the comfort-map disc and writes the STL result into a directory.

The disc is a tessellated surface covering a region of interest: a circle of radius floor_radius around center, placed height above the ground. fineness controls how finely it is tessellated.

By default the disc is written as a single file. Asking for one of the zipped encodings in result_encoding unpacks the result into the directory instead. The directory is created if it does not exist, and files in it with the same names are overwritten.

A disc with no geometry is reported as empty-comfort-map-disc.

Supported for Parasolid and STL models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • empty-comfort-map-disc - The query returned no geometry.
  • lawson-cylinder-exceeds-size-box - floor_radius is too large for the model's size box.
  • lawson-negative-height-above-ground - height is negative.
  • lawson-roi-radius-must-be-positive - floor_radius is zero or negative.
  • lawson-tessellation-max-width-must-be-positive - fineness is zero or negative.
  • lawson-tessellation-too-fine - fineness produces more than 100 million triangles, which the query does not allow.
  • tessellation-has-error[-with-entity] - The kernel could not tessellate one or more entities.
  • tessellation-too-large - The result could not be written; the kernel ran out of disk space.

func (*Cad) MaterialPoints

func (c *Cad) MaterialPoints(params *MaterialPointsParameters) (*MaterialPointsResponse, error)

MaterialPoints computes a point inside the material, for the whole model or for each solid.

query_type chooses between the two. The response sets the field that matches it and leaves the other unset; the per-body field is keyed by entity id.

A material point is only guaranteed to lie inside the material. Which interior point is returned is unspecified, and can differ between runs.

Supported only for Parasolid models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) ModelMetrics

func (c *Cad) ModelMetrics(params *ModelMetricsParameters) (*ModelMetricsResponse, error)

ModelMetrics computes volume and surface-area metrics for the model and its entities.

Computes aggregated volume and surface area for the model, along with per-solid, per-sheet, per-face and per-edge metrics.

The query takes no parameters: the metrics always cover the whole model.

Supported for Parasolid and nTop models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

func (*Cad) PlanarPatchPrimitives

func (c *Cad) PlanarPatchPrimitives(params *PlanarPatchPrimitivesParameters) (*PlanarPatchPrimitivesResponse, error)

PlanarPatchPrimitives approximates groups of coplanar faces with a circle or rectangle primitive.

Groups the requested faces into patches of adjacent, coplanar faces and approximates each patch with the primitive — a circle or a rectangle — whose area is closest to the area of the patch. All faces of a patch belong to the same occurrence. The query fails if any of the requested faces is not planar.

Supported only for Parasolid models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • planar-patch-primitives-degenerate-patch[-with-entity] - A face has no interior point, or a patch is not two-dimensional, so no primitive fits it.
  • planar-patch-primitives-non-coplanar-faces[-with-entity] - Faces that are adjacent, and so belong to the same patch, lie on different planes.
  • planar-patch-primitives-non-planar-faces[-with-entity] - One or more of the requested faces is not planar.

func (*Cad) Tessellate

func (c *Cad) Tessellate(destDir string, params *TessellateParameters) (*TessellateResponse, error)

Tessellate tessellates the model and writes the STL files into a directory.

One STL file is written per region by default, or one per face when write_one_file_per_face is set. The directory is created if it does not exist, and files in it with the same names are overwritten.

tessellation_type, max_facet_width and allowed_facet_faults_level apply to Parasolid models, and tessellation_type has to be set explicitly; feature_size, adaptivity and max_edge_length apply to nTop models and all default when omitted. tess_surface_area is set in the response only when calculate_area is requested.

Supported for Parasolid, STL and nTop models.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • tessellation-has-error[-with-entity] - The kernel could not tessellate one or more entities.
  • tessellation-ntop-negative-adaptivity - adaptivity is negative.
  • tessellation-ntop-zero-edge-length - max_edge_length is zero.
  • tessellation-ntop-zero-feature-size - feature_size is zero.
  • tessellation-too-large - The result could not be written; the kernel ran out of disk space.

func (*Cad) TessellateFaces

func (c *Cad) TessellateFaces(destDir string, params *TessellateFacesParameters) (*TessellateFacesResponse, error)

TessellateFaces tessellates the requested faces, writing one STL file per face into a directory.

Each requested face is tessellated into its own STL file, named after the face id; a face requested more than once is tessellated only once. The response additionally carries the normal of each face, evaluated at the mid point of the face.

The faces to tessellate are required, so a query without parameters is rejected. The directory is created if it does not exist, and files in it with the same names are overwritten.

Supported only for Parasolid models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

Query errors

  • tessellation-has-error - The kernel could not tessellate one of the faces.

func (*Cad) Volume

func (c *Cad) Volume(params *VolumeParameters) (*VolumeResponse, error)

Volume computes the volume of each selected solid, and their total.

The solids and sheets to measure are given by their entity ids, as entities returns them.

volumes holds one entry per measured entity, keyed by its entity id, and total is their sum.

Supported for Parasolid and nTop models. Other formats fail with query-type-unsupported-for-cad-format.

It returns a *CadExpectedError for a known domain error, or a *CadUnexpectedError if the library fails internally. Failing to marshal the parameters or unmarshal the result returns a plain error.

type CadErrorKind

type CadErrorKind string

CadErrorKind is the discriminant for the JSON error payload.

const (
	CadErrorKindExpected   CadErrorKind = "expected"
	CadErrorKindUnexpected CadErrorKind = "unexpected"
)

Valid CadErrorKind values.

type CadExpectedError

type CadExpectedError struct {
	ErrorCode    string
	ErrorDetails map[string]any
}

CadExpectedError is returned when a known, anticipated CAD error occurs. ErrorCode is the machine-readable identifier; ErrorDetails carries structured context.

func (*CadExpectedError) Error

func (e *CadExpectedError) Error() string

type CadUnexpectedError

type CadUnexpectedError struct {
	Message string
}

CadUnexpectedError is returned when an unexpected internal error occurs in the CAD library.

func (*CadUnexpectedError) Error

func (e *CadUnexpectedError) Error() string

type CenterOfGravityParameters

type CenterOfGravityParameters struct {
	// Ids of the faces and edges to combine into a single center of gravity, as
	// `entities` returns them. Any other entity type fails the query.
	// Must not be empty
	Entities []string `json:"entities"`
}

CenterOfGravityParameters parameters for compute center of gravity query

type CenterOfGravityResponse

type CenterOfGravityResponse struct {
	// Center of gravity as a 3D vector
	Cog Vector3 `json:"cog"`
}

CenterOfGravityResponse response for compute center of gravity query

type CirclePrimitive

type CirclePrimitive struct {
	// Center of the circle
	Center Vector3 `json:"center"`
	// Radius of the circle
	Radius float64 `json:"radius"`
	// Outward normal of the patch
	Normal Vector3 `json:"normal"`
}

CirclePrimitive circle approximating a planar patch

type Color

type Color struct {
	// Id of the solid or sheet the color is defined on
	EntityID string `json:"entity_id"`
	// Color in hex format (e.g., "#ff0000")
	Color string `json:"color"`
}

Color information for an entity

type ColorsParameters

type ColorsParameters struct{}

ColorsParameters parameters for get model colors query (empty)

func (ColorsParameters) MarshalJSON

func (ColorsParameters) MarshalJSON() ([]byte, error)

MarshalJSON encodes the parameter-less query as JSON null, which is what the library expects for this schema (`"type": "null"`).

func (*ColorsParameters) UnmarshalJSON

func (*ColorsParameters) UnmarshalJSON([]byte) error

UnmarshalJSON accepts the JSON null this type marshals to.

type ColorsResponse

type ColorsResponse []Color

ColorsResponse response for get model colors query List of colors defined on solids and sheets

type DetectCommonRotationParameters

type DetectCommonRotationParameters struct {
	// Ids of the faces to check for common rotation, as `entities` returns them. The query will check if these faces are rotationally aligned and share the same rotation center and axis. Must not be empty
	Faces []string `json:"faces"`
}

DetectCommonRotationParameters parameters for detect rotation query

type DetectCommonRotationResponse

type DetectCommonRotationResponse struct {
	// Center of common rotation
	Center Vector3 `json:"center"`
	// Axis of common rotation
	Axis Vector3 `json:"axis"`
}

DetectCommonRotationResponse response for detect common rotation query

type DetectEnclosureParameters

type DetectEnclosureParameters struct {
	// Point to check for enclosure
	Point Vector3 `json:"point"`
}

DetectEnclosureParameters parameters for detect enclosure query

type DetectEnclosureResponse

type DetectEnclosureResponse []string

DetectEnclosureResponse response for detect enclosure query List of solids enclosing the input point

type EdgeMetric

type EdgeMetric struct {
	// Id of the edge
	EntityID string `json:"entityId"`
	// Length of the edge
	Length float64 `json:"length"`
}

EdgeMetric length metric for a single edge

type EntitiesResponse

type EntitiesResponse []Entity

EntitiesResponse response for entities query — a flat list of all entities.

Each entity references its parents and children by their 0-based index in the list. Solids and sheets are the top-level entities.

type Entity

type Entity struct {
	// Unique entity id, e.g. `A1_I2_B3_TE4` or `B1_TE2`
	EntityID string `json:"entityId"`
	// Human-readable entity name, e.g. `face_name@body_name`
	Name string `json:"name"`
	// Type of the entity
	Type EntityType `json:"type"`
	// Indices of the children of this entity in this list
	Children []int32 `json:"children"`
	// Indices in this list of all entities this entity is a child of.
	// Empty for top-level entities, i.e. solids and sheets.
	// An entity can have several parents: an edge is usually shared by two faces,
	// a vertex by several edges.
	Parents []int32 `json:"parents"`
}

Entity an entity in the CAD model topology (solids, sheets, faces, edges, vertices).

type EntityType

type EntityType string

EntityType type of entity. A body is never part of the topology, since it is represented by its top-level solids or sheets.

const (
	EntityTypeSolid  EntityType = "SOLID"
	EntityTypeSheet  EntityType = "SHEET"
	EntityTypeFace   EntityType = "FACE"
	EntityTypeEdge   EntityType = "EDGE"
	EntityTypeVertex EntityType = "VERTEX"
)

Valid EntityType values.

type FaceMetric

type FaceMetric struct {
	// Id of the face
	EntityID string `json:"entityId"`
	// Surface area of the face
	Area float64 `json:"area"`
}

FaceMetric surface area metric for a single face

type GenerateComfortMapDiscParameters

type GenerateComfortMapDiscParameters struct {
	// Center point of the region of interest on the ground plane. The disc will be generated in a circular region around this center point.
	Center Vector2 `json:"center"`
	// Height above ground of the region of interest (distance between the center point and the plane where the disc will be generated). Must not be negative
	Height float64 `json:"height"`
	// Radius of the region of interest on the ground plane (disc will be generated in a circular region with this radius around the center point). Must be greater than zero
	FloorRadius float64 `json:"floor_radius"`
	// Tessellation fineness parameter to control the size of the disc's tessellation,. Must be greater than zero, and large enough that the disc stays under the limit of 100 million triangles
	Fineness float64 `json:"fineness"`
	// Ids of the faces that make up the ground (optional)
	Faces []string `json:"faces,omitempty"`
	// Height of the ground plane. Defaults to 0 when omitted
	GroundLevel *float64 `json:"ground_level,omitempty"`
	// Defines the encoding of the file which contains the disc (optional). With `ascii` or `binary`, or when omitted, the disc is written as a single file; with `zipped-ascii` or `zipped-binary` the result is unpacked into the directory
	ResultEncoding *ResultEncoding `json:"result_encoding,omitempty"`
}

GenerateComfortMapDiscParameters parameters for comfort maps query

type GenerateComfortMapDiscResponse

type GenerateComfortMapDiscResponse struct {
	// Number of triangles in the tessellated disc. Always greater than zero: a
	// disc with no geometry fails the query instead
	NumberOfTriangles int32 `json:"number_of_triangles"`
	// Bounding box of the tessellated disc (optional)
	BoundingBox *Box `json:"bounding_box,omitempty"`
}

GenerateComfortMapDiscResponse response for comfort maps query

type MaterialPointsParameters

type MaterialPointsParameters struct {
	// Defines whether one point is computed for the whole model or one per solid
	// and sheet. The response sets the matching field and leaves the other unset
	QueryType MaterialPointsQueryType `json:"queryType"`
}

MaterialPointsParameters parameters for material points query

type MaterialPointsQueryType

type MaterialPointsQueryType string

MaterialPointsQueryType query type for material points

const (
	MaterialPointsQueryTypeEntireModel MaterialPointsQueryType = "entireModel"
	MaterialPointsQueryTypePerBody     MaterialPointsQueryType = "perBody"
)

Valid MaterialPointsQueryType values.

type MaterialPointsResponse

type MaterialPointsResponse struct {
	// A point inside the model's material. Set when `queryType` is `entireModel`
	ModelMaterialPoint *Vector3 `json:"modelMaterialPoint,omitempty"`
	// A point inside each solid and sheet, keyed by its entity id. Set when
	// `queryType` is `perBody`
	MaterialPointPerBody map[string]Vector3 `json:"materialPointPerBody,omitempty"`
}

MaterialPointsResponse response for material points query

type ModelMetricsParameters

type ModelMetricsParameters struct{}

ModelMetricsParameters parameters for model metrics query

type ModelMetricsResponse

type ModelMetricsResponse struct {
	// Sum of the volumes in `solids`
	ModelVolume float64 `json:"modelVolume"`
	// Aggregated surface area of all solids and sheets
	ModelSurfaceArea float64 `json:"modelSurfaceArea"`
	// Volume and surface area metrics per solid
	Solids []VolumeMetric `json:"solids"`
	// Volume and surface area metrics per sheet
	Sheets []VolumeMetric `json:"sheets"`
	// Surface area metrics per face
	Faces []FaceMetric `json:"faces"`
	// Length metrics per edge
	Edges []EdgeMetric `json:"edges"`
}

ModelMetricsResponse response for model metrics query

type PatchType

type PatchType string

PatchType the kind of primitive that approximates a planar patch

const (
	PatchTypeRectangle PatchType = "rectangle"
	PatchTypeCircle    PatchType = "circle"
)

Valid PatchType values.

type PlanarPatch

type PlanarPatch struct {
	// The faces that make up this patch
	Faces []string `json:"faces"`
	// The kind of primitive that approximates this patch
	PatchType PatchType `json:"patchType"`
	// The rectangle approximating this patch, set when `patch_type` is `rectangle`
	Rectangle *RectanglePrimitive `json:"rectangle,omitempty"`
	// The circle approximating this patch, set when `patch_type` is `circle`
	Circle *CirclePrimitive `json:"circle,omitempty"`
}

PlanarPatch one patch of adjacent, coplanar faces, together with the primitive approximating it.

`patch_type` names which primitive describes the patch: exactly one of `rectangle` and `circle` is set, the one `patch_type` names.

type PlanarPatchPrimitivesParameters

type PlanarPatchPrimitivesParameters struct {
	// Ids of the planar faces to group into patches, as `entities` returns them. The query fails if any of the given faces is not planar. Must not be empty
	Faces []string `json:"faces"`
}

PlanarPatchPrimitivesParameters parameters for planar patch primitives query

type PlanarPatchPrimitivesResponse

type PlanarPatchPrimitivesResponse struct {
	// The patches found among the requested faces
	Patches []PlanarPatch `json:"patches"`
}

PlanarPatchPrimitivesResponse response for planar patch primitives query

type RectanglePrimitive

type RectanglePrimitive struct {
	// The four corners of the rectangle, counterclockwise around `normal`
	Corners []Vector3 `json:"corners"`
	// Outward normal of the patch
	Normal Vector3 `json:"normal"`
}

RectanglePrimitive rectangle approximating a planar patch

type ResultEncoding

type ResultEncoding string

ResultEncoding encoding format for STL result data, used in some queries to control how the result is encoded (e.g. for comfort map disc)

const (
	ResultEncodingASCII        ResultEncoding = "ascii"
	ResultEncodingBinary       ResultEncoding = "binary"
	ResultEncodingZippedASCII  ResultEncoding = "zipped-ascii"
	ResultEncodingZippedBinary ResultEncoding = "zipped-binary"
)

Valid ResultEncoding values.

type TessellateFacesParameters

type TessellateFacesParameters struct {
	// Ids of the faces to tessellate, as `entities` returns them. Each face is
	// tessellated into its own STL file, named after the face id. A face
	// requested more than once is tessellated only once. Must not be empty
	Faces []string `json:"faces"`
	// Defines the tessellation strategy. Defaults to `chordTol` when omitted
	TessellationType *TessellationType `json:"tessellationType,omitempty"`
	// Maximum facet width for tessellationType=maxFacetWidth. If omitted, it is
	// derived from the size of the face
	MaxFacetWidth *float64 `json:"maxFacetWidth,omitempty"`
	// Level of faults allowed in the tessellation. Used in quality checks.
	// Defaults to `mild` when omitted
	AllowedFacetFaultsLevel *AllowedFacetFaultsLevel `json:"allowedFacetFaultsLevel,omitempty"`
}

TessellateFacesParameters parameters for the tessellate faces query.

Tessellates a chosen set of faces: each face becomes its own STL file, named after the face id. A face listed more than once is tessellated only once.

Supported only for Parasolid models.

type TessellateFacesResponse

type TessellateFacesResponse struct {
	// Unit normal of each requested face, evaluated at the mid point of the
	// face, keyed by face id
	FaceNormals map[string]Vector3 `json:"faceNormals"`
}

TessellateFacesResponse response for the tessellate faces query

type TessellateParameters

type TessellateParameters struct {
	// If true, one STL file is written per face; if false, one per region
	WriteOneFilePerFace bool `json:"writeOneFilePerFace"`
	// If true, computes the surface area of the tessellation and returns it as
	// `tess_surface_area` in the response
	CalculateArea bool `json:"calculateArea"`
	// Supported only for Parasolid models. Defines the tessellation strategy.
	// Has no default: the query fails with `invalid-parameter` if it is not set
	TessellationType *TessellationType `json:"tessellationType,omitempty"`
	// Supported only for Parasolid models. Maximum facet width, used when `tessellation_type`
	// is `maxFacetWidth`. If omitted, it is computed from the bounding box of the body
	MaxFacetWidth *float64 `json:"maxFacetWidth,omitempty"`
	// Supported only for Parasolid models. Level of faults allowed in the tessellation.
	// Used in quality checks. Defaults to `mild` when omitted
	AllowedFacetFaultsLevel *AllowedFacetFaultsLevel `json:"allowedFacetFaultsLevel,omitempty"`
	// Supported only for nTop models. Granularity at which the solid's field is sampled.
	// Make this smaller to get more triangles and lower max edge length.
	// Must be greater than zero. Defaults to 0.0015 when omitted
	FeatureSize *float64 `json:"featureSize,omitempty"`
	// Supported only for nTop models. Controls how much the mesh is decimated.
	// Make this higher to get less triangles and higher max edge length.
	// Must be greater than zero. Defaults to 10 when omitted
	Adaptivity *float64 `json:"adaptivity,omitempty"`
	// Supported only for nTop models. Specifies the maximum allowable length for any edge in the tessellated
	// mesh. During refinement, edges longer than this value are subdivided to ensure the
	// mesh respects this limit. Must be greater than zero. Defaults to 10 when omitted
	MaxEdgeLength *float64 `json:"maxEdgeLength,omitempty"`
}

TessellateParameters parameters for tessellate query

type TessellateResponse

type TessellateResponse struct {
	// Number of bodies in the tessellated geometry
	NumBodies int32 `json:"numBodies"`
	// Surface area of the tessellated geometry. Set only when `calculate_area`
	// was requested
	TessSurfaceArea *float64 `json:"tessSurfaceArea,omitempty"`
}

TessellateResponse response for tessellation query

type TessellationType

type TessellationType string

TessellationType tessellation strategy (Supported only for Parasolid models) `ChordTol` controls curve tolerance by specifying the maximum allowable distance between a true curved edge and the straight-line chords (facet edges) used to approximate it. The `MaxFacetWidth` strategy uses a maximum facet width to control the maximum size of the facets, which can be more intuitive in some cases. When using `MaxFacetWidth`, the `maxFacetWidth` parameter controls the maximum width of the facets.

const (
	TessellationTypeChordTol      TessellationType = "chordTol"
	TessellationTypeMaxFacetWidth TessellationType = "maxFacetWidth"
)

Valid TessellationType values.

type Vector2

type Vector2 struct {
	// X coordinate
	X float64 `json:"x"`
	// Y coordinate
	Y float64 `json:"y"`
}

Vector2 2D vector representation

type Vector3

type Vector3 struct {
	// X coordinate
	X float64 `json:"x"`
	// Y coordinate
	Y float64 `json:"y"`
	// Z coordinate
	Z float64 `json:"z"`
}

Vector3 3D vector representation

type VolumeMetric

type VolumeMetric struct {
	// Id of the solid or sheet
	EntityID string `json:"entityId"`
	// Volume of the entity, when applicable
	Volume float64 `json:"volume"`
	// Surface area of the entity
	SurfaceArea float64 `json:"surfaceArea"`
}

VolumeMetric volume and surface area metrics for a single solid or sheet

type VolumeParameters

type VolumeParameters struct {
	// Ids of the solids and sheets to measure, as `entities` returns them.
	// Must not be empty
	EntityIDs []string `json:"entityIds"`
}

VolumeParameters parameters for compute volume query

type VolumeResponse

type VolumeResponse struct {
	// Sum of the volumes in `volumes`
	Total float64 `json:"total"`
	// Volume of each measured entity, keyed by its entity id
	Volumes map[string]float64 `json:"volumes"`
}

VolumeResponse response for volume query

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL