|
OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
|
OCCT-Light: geometry primitive types and math utilities. More...


Go to the source code of this file.
Classes | |
| struct | occtl_point2_t |
| struct | occtl_vector2_t |
| struct | occtl_direction2_t |
| struct | occtl_point3_t |
| struct | occtl_vector3_t |
| struct | occtl_direction3_t |
| struct | occtl_axis1_placement_t |
| struct | occtl_axis2_placement_t |
| struct | occtl_axis3_placement_t |
| struct | occtl_transform_t |
| struct | occtl_axis2_placement2d_t |
| struct | occtl_geom_circle_t |
| struct | occtl_geom_ellipse_t |
| struct | occtl_geom_hyperbola_t |
| struct | occtl_geom_parabola_t |
| struct | occtl_geom2d_line_t |
| struct | occtl_geom2d_circle_t |
| struct | occtl_geom2d_ellipse_t |
| struct | occtl_geom2d_hyperbola_t |
| struct | occtl_geom2d_parabola_t |
| struct | occtl_geom_plane_t |
| struct | occtl_geom_cylindrical_surface_t |
| struct | occtl_geom_spherical_surface_t |
| struct | occtl_geom_conical_surface_t |
| struct | occtl_geom_toroidal_surface_t |
Typedefs | |
| typedef enum occtl_geom_continuity | occtl_geom_continuity_t |
| typedef occtl_axis1_placement_t | occtl_geom_line_t |
Enumerations | |
| enum | occtl_geom_continuity { OCCTL_GEOM_CONTINUITY_C0 = 0 , OCCTL_GEOM_CONTINUITY_G1 = 1 , OCCTL_GEOM_CONTINUITY_C1 = 2 , OCCTL_GEOM_CONTINUITY_G2 = 3 , OCCTL_GEOM_CONTINUITY_C2 = 4 , OCCTL_GEOM_CONTINUITY_C3 = 5 , OCCTL_GEOM_CONTINUITY_CN = 6 , OCCTL_GEOM_CONTINUITY_RESERVED_FUTURE = 0x7fffffff } |
OCCT-Light: geometry primitive types and math utilities.
Exposes nine POD value types — 2D/3D points, vectors, unit directions, axis-placement coordinate systems, and a 3-by-4 affine transform — together with pure-math utility functions that operate on them. All types are plain C structs; no allocation, no handles, no ownership semantics.
Type name conventions follow the design documents (full English words, not OCCT-internal abbreviations) and the ISO 10303 STEP "axis placement" terminology for coordinate-system types.
All functions in this header are thread-safe: they perform stateless floating-point arithmetic on value-typed arguments; the only shared state they touch (on failure) is the caller's thread-local error slot.
| typedef enum occtl_geom_continuity occtl_geom_continuity_t |
Continuity classification used by curve and surface handles.
Values match those of GeomAbs_Shape in OCCT (C0=0, G1=1, …). Append-only; do not reorder.
3D infinite line data.
Structurally identical to occtl_axis1_placement_t (origin + unit direction). Used as input to occtl_curve_create_line and output of occtl_curve_as_line.
Continuity classification used by curve and surface handles.
Values match those of GeomAbs_Shape in OCCT (C0=0, G1=1, …). Append-only; do not reorder.
| double occtl_direction2_angle | ( | occtl_direction2_t | a, |
| occtl_direction2_t | b | ||
| ) |
Angle from direction a to direction b, in radians, in [0, π].
| [in] | a | First direction. |
| [in] | b | Second direction. |
[0, π].\par Thread Safety Yes.
| occtl_status_t occtl_direction2_from_vector | ( | occtl_vector2_t | v, |
| occtl_direction2_t * | out_direction | ||
| ) |
Builds a 2D unit-direction from a 2D vector, normalising it.
| [in] | v | Source vector. |
| [out] | out_direction | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the normalised direction; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_direction is NULL. |
| OCCTL_GEOMETRY_INVALID | v has zero length. |
\par Thread Safety Yes.
| double occtl_direction3_angle | ( | occtl_direction3_t | a, |
| occtl_direction3_t | b | ||
| ) |
Angle between two unit directions, in radians.
Uses acos(a·b), clamped to [0, π] to avoid domain errors from floating-point rounding.
| [in] | a | First direction. |
| [in] | b | Second direction. |
[0, π].\par Thread Safety Yes.
| occtl_vector3_t occtl_direction3_cross | ( | occtl_direction3_t | a, |
| occtl_direction3_t | b | ||
| ) |
Cross product of two unit directions, returned as a free vector.
The result is the zero vector when a and b are parallel or anti-parallel.
| [in] | a | First direction. |
| [in] | b | Second direction. |
a×b as a free occtl_vector3_t.\par Thread Safety Yes.
| double occtl_direction3_dot | ( | occtl_direction3_t | a, |
| occtl_direction3_t | b | ||
| ) |
Dot product of two unit directions.
| [in] | a | First direction. |
| [in] | b | Second direction. |
[-1, 1].\par Thread Safety Yes.
| occtl_status_t occtl_direction3_from_vector | ( | occtl_vector3_t | v, |
| occtl_direction3_t * | out_direction | ||
| ) |
Builds a unit-direction from a 3D vector, normalising it.
| [in] | v | Source vector. |
| [out] | out_direction | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the normalised direction; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_direction is NULL. |
| OCCTL_GEOMETRY_INVALID | v has zero (or near-zero) length. |
\par Thread Safety Yes.
| occtl_direction3_t occtl_direction3_reversed | ( | occtl_direction3_t | d | ) |
Reverses a unit direction.
| [in] | d | Direction. |
-d.\par Thread Safety Yes.
| occtl_status_t occtl_direction3_transform | ( | occtl_direction3_t | d, |
| occtl_transform_t | t, | ||
| occtl_direction3_t * | out_direction | ||
| ) |
Applies the linear (rotation/scale) part of a transform to a unit direction, then re-normalises the result.
Translation is not applied; only the 3×3 sub-matrix of t is used.
| [in] | d | Direction to transform. |
| [in] | t | Transform. |
| [out] | out_direction | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the transformed and re-normalised direction; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_direction is NULL. |
| OCCTL_GEOMETRY_INVALID | The transform collapses the direction to zero (e.g. a zero-scale transform). |
\par Thread Safety Yes.
| double occtl_point2_distance | ( | occtl_point2_t | a, |
| occtl_point2_t | b | ||
| ) |
Euclidean distance between two 2D points.
| [in] | a | First point. |
| [in] | b | Second point. |
a == b.\par Thread Safety Yes.
| occtl_point2_t occtl_point2_midpoint | ( | occtl_point2_t | a, |
| occtl_point2_t | b | ||
| ) |
Midpoint of two 2D points.
| [in] | a | First point. |
| [in] | b | Second point. |
a and b.\par Thread Safety Yes.
| double occtl_point3_distance | ( | occtl_point3_t | a, |
| occtl_point3_t | b | ||
| ) |
Euclidean distance between two 3D points.
| [in] | a | First point. |
| [in] | b | Second point. |
a == b.\par Thread Safety Yes.
| occtl_point3_t occtl_point3_midpoint | ( | occtl_point3_t | a, |
| occtl_point3_t | b | ||
| ) |
Midpoint of two 3D points.
| [in] | a | First point. |
| [in] | b | Second point. |
a and b.\par Thread Safety Yes.
| occtl_point3_t occtl_point3_translate | ( | occtl_point3_t | p, |
| occtl_vector3_t | v | ||
| ) |
Translates a 3D point by a vector.
| [in] | p | Point to translate. |
| [in] | v | Translation vector. |
p + v.\par Thread Safety Yes.
| occtl_point3_t occtl_transform_apply_point3 | ( | occtl_transform_t | t, |
| occtl_point3_t | p | ||
| ) |
Applies the full affine transform to a 3D point (includes translation).
| [in] | t | Transform to apply. |
| [in] | p | Point to transform. |
\par Thread Safety Yes.
| occtl_vector3_t occtl_transform_apply_vector3 | ( | occtl_transform_t | t, |
| occtl_vector3_t | v | ||
| ) |
Applies only the linear (3×3) part of a transform to a 3D vector (no translation).
| [in] | t | Transform. |
| [in] | v | Vector to transform. |
\par Thread Safety Yes.
| occtl_transform_t occtl_transform_compose | ( | occtl_transform_t | first, |
| occtl_transform_t | second | ||
| ) |
Composes two transforms: applies first, then second.
Equivalent to the matrix product second * first (standard right-to-left composition convention).
| [in] | first | Transform applied first. |
| [in] | second | Transform applied second. |
\par Thread Safety Yes.
| occtl_status_t occtl_transform_from_axis2 | ( | occtl_axis2_placement_t | frame, |
| occtl_transform_t * | out_transform | ||
| ) |
Builds a transform that maps the world frame onto the given coordinate frame (occtl_axis2_placement_t).
The returned transform takes a point expressed in the world frame and produces its equivalent expressed relative to frame. The Y direction is derived from frame.x_dir and frame.x_dir_ref.
| [in] | frame | Frame to map onto. |
| [out] | out_transform | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the world→frame transform; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_transform is NULL. |
| OCCTL_GEOMETRY_INVALID | frame.x_dir and frame.x_dir_ref are parallel, or any direction has zero length. |
\par Thread Safety Yes.
| occtl_status_t occtl_transform_from_axis3 | ( | occtl_axis3_placement_t | frame, |
| occtl_transform_t * | out_transform | ||
| ) |
Builds a transform from an explicit 3-axis frame (occtl_axis3_placement_t).
The 3×3 linear part of the result is the matrix whose columns are frame.x_dir, frame.y_dir, frame.z_dir; the translation column is frame.location. Useful for round-tripping arbitrary (possibly left-handed) frames produced by an external system.
| [in] | frame | Frame to map onto. |
| [out] | out_transform | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the frame transform; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_transform is NULL. |
| OCCTL_GEOMETRY_INVALID | The three axis directions are linearly dependent (the frame is degenerate). |
\par Thread Safety Yes.
| occtl_transform_t occtl_transform_identity | ( | void | ) |
Returns the identity transform.
Applying the identity to a point or vector leaves it unchanged.
\par Thread Safety Yes.
| occtl_status_t occtl_transform_inverted | ( | occtl_transform_t | t, |
| occtl_transform_t * | out_transform | ||
| ) |
Computes the inverse of an affine transform.
| [in] | t | Transform to invert. |
| [out] | out_transform | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the inverse transform; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_transform is NULL. |
| OCCTL_GEOMETRY_INVALID | t is singular (determinant near zero). |
\par Thread Safety Yes.
| occtl_status_t occtl_transform_rotation | ( | occtl_axis1_placement_t | axis, |
| double | angle, | ||
| occtl_transform_t * | out_transform | ||
| ) |
Builds a rotation transform around an axis by an angle.
Uses the Rodrigues rotation formula. The rotation is about the line defined by axis: points on the axis are fixed; other points rotate by angle radians (right-hand rule).
| [in] | axis | Rotation axis (origin + unit direction). |
| [in] | angle | Rotation angle in radians. |
| [out] | out_transform | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the rotation transform; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_transform is NULL. |
| OCCTL_GEOMETRY_INVALID | axis.direction has zero (or near-zero) length. |
\par Thread Safety Yes.
| occtl_status_t occtl_transform_scale | ( | occtl_point3_t | center, |
| double | s, | ||
| occtl_transform_t * | out_transform | ||
| ) |
Builds a uniform-scale transform centred on a point.
| [in] | center | Centre of scaling. |
| [in] | s | Scale factor. Must not be zero. |
| [out] | out_transform | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the scale transform; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_transform is NULL. |
| OCCTL_GEOMETRY_INVALID | s is zero. |
\par Thread Safety Yes.
| occtl_transform_t occtl_transform_translation | ( | occtl_vector3_t | v | ) |
Returns a pure-translation transform.
| [in] | v | Translation vector. |
v.\par Thread Safety Yes.
| double occtl_vector2_cross | ( | occtl_vector2_t | a, |
| occtl_vector2_t | b | ||
| ) |
Signed Z-component of the cross product of two 2D vectors.
Equivalent to the determinant a.x*b.y - a.y*b.x. Positive when b is counter-clockwise from a.
| [in] | a | First vector. |
| [in] | b | Second vector. |
a×b.\par Thread Safety Yes.
| double occtl_vector2_dot | ( | occtl_vector2_t | a, |
| occtl_vector2_t | b | ||
| ) |
Dot product of two 2D vectors.
| [in] | a | First vector. |
| [in] | b | Second vector. |
a·b.\par Thread Safety Yes.
| double occtl_vector2_magnitude | ( | occtl_vector2_t | v | ) |
Euclidean magnitude of a 2D vector.
| [in] | v | Vector. |
\par Thread Safety Yes.
| occtl_status_t occtl_vector2_normalized | ( | occtl_vector2_t | v, |
| occtl_vector2_t * | out_result | ||
| ) |
Normalises a 2D vector to unit length.
| [in] | v | Vector. |
| [out] | out_result | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the unit-length vector; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_result is NULL. |
| OCCTL_GEOMETRY_INVALID | v has zero length. |
\par Thread Safety Yes.
| occtl_vector3_t occtl_vector3_add | ( | occtl_vector3_t | a, |
| occtl_vector3_t | b | ||
| ) |
Adds two 3D vectors.
| [in] | a | First vector. |
| [in] | b | Second vector. |
a + b.\par Thread Safety Yes.
| occtl_status_t occtl_vector3_angle | ( | occtl_vector3_t | a, |
| occtl_vector3_t | b, | ||
| double * | out_radians | ||
| ) |
Angle between two 3D vectors, in radians.
| [in] | a | First vector. |
| [in] | b | Second vector. |
| [out] | out_radians | Owns it (caller-allocated output slot). Must be non-NULL. On success receives a value in [0, π]; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_radians is NULL. |
| OCCTL_GEOMETRY_INVALID | Either vector has zero length. |
\par Thread Safety Yes.
| occtl_vector3_t occtl_vector3_cross | ( | occtl_vector3_t | a, |
| occtl_vector3_t | b | ||
| ) |
Cross product of two 3D vectors.
| [in] | a | First vector. |
| [in] | b | Second vector. |
a×b. Result is the zero vector when a and b are parallel.\par Thread Safety Yes.
| double occtl_vector3_dot | ( | occtl_vector3_t | a, |
| occtl_vector3_t | b | ||
| ) |
Dot product of two 3D vectors.
| [in] | a | First vector. |
| [in] | b | Second vector. |
a·b.\par Thread Safety Yes.
| double occtl_vector3_magnitude | ( | occtl_vector3_t | v | ) |
Euclidean magnitude (length) of a 3D vector.
| [in] | v | Vector. |
\par Thread Safety Yes.
| occtl_status_t occtl_vector3_normalized | ( | occtl_vector3_t | v, |
| occtl_vector3_t * | out_result | ||
| ) |
Normalises a 3D vector to unit length.
| [in] | v | Vector to normalise. |
| [out] | out_result | Owns it (caller-allocated output slot). Must be non-NULL. On success receives the unit-length vector; left unchanged on failure. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | out_result is NULL. |
| OCCTL_GEOMETRY_INVALID | v has zero (or near-zero) length. |
\par Thread Safety Yes.
| occtl_vector3_t occtl_vector3_reversed | ( | occtl_vector3_t | v | ) |
Reverses a 3D vector.
| [in] | v | Vector. |
-v.\par Thread Safety Yes.
| occtl_vector3_t occtl_vector3_scaled | ( | occtl_vector3_t | v, |
| double | s | ||
| ) |
Scales a 3D vector by a scalar.
| [in] | v | Vector. |
| [in] | s | Scalar factor. |
s*v.\par Thread Safety Yes.
| occtl_vector3_t occtl_vector3_sub | ( | occtl_vector3_t | a, |
| occtl_vector3_t | b | ||
| ) |
Subtracts two 3D vectors.
| [in] | a | Minuend. |
| [in] | b | Subtrahend. |
a - b.\par Thread Safety Yes.