Appearance
Query: Contour
Contour queries — read-only geometric questions about a contour (an outer profile plus zero or more inner profiles that act as holes) and the relationships between two contours. Every method takes an opaque ContourHandle (plus point handles Vec3Handle where relevant) and returns plain values — points as Vec3Components, areas/perimeters/counts as number, predicates as boolean, the bounding box as BBoxComponents. Methods that enumerate the contour's child profiles return fresh ProfileHandles. No query mutates its inputs. Accessed via snaptrude.core.geom.query.contour.
Functions
getOuterProfile(contour)
Get the outer (boundary) profile of a contour. Host API call — mints a fresh handle.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
ProfileHandle | null— The outer profile, ornullif the contour has no outer profile
ts
const contour = await snaptrude.core.geom.create.contourFromProfiles(outer, [hole]);
const boundary = await snaptrude.core.geom.query.contour.getOuterProfile(contour);listHoles(contour)
List the inner profiles (holes) of a contour. Host API call — mints fresh handles.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
ProfileHandle[]— The contour's holes
getHoleCount(contour)
Get the number of inner profiles (holes) in a contour.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
number— The hole count
getArea(contour)
Get the (approximate) net enclosed area of a contour — the outer profile area minus the area of every hole.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
number— The area
ts
// Net area (outer minus holes), in Snaptrude units
const area = await snaptrude.core.geom.query.contour.getArea(contour);getPerimeter(contour)
Get the perimeter (total length of every curve) of a contour, including holes.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
number— The perimeter
getBoundingBox(contour)
Get the axis-aligned bounding box of a contour.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
BBoxComponents— The bounding box as{ min, max }(each aVec3Components{ x, y, z })
getNormal(contour)
Get the unit normal vector of a contour's plane.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
Vec3Components | null— The normal as{ x, y, z }, ornullif the contour has no well-defined normal
getNearestPoint(contour, point)
Get the point on a contour nearest to an arbitrary point.
- Parameters:
contour:ContourHandle— The contour to querypoint:Vec3Handle— The reference point
- Returns:
Vec3Components— The nearest point on the contour as{ x, y, z }
ts
const probe = await snaptrude.core.math.vec3.new(5, 0, 5);
const nearest = await snaptrude.core.geom.query.contour.getNearestPoint(contour, probe);hasPoint(contour, point)
Test whether a point lies inside a contour (inside the outer profile and outside every hole).
- Parameters:
contour:ContourHandle— The contour to querypoint:Vec3Handle— The point to test
- Returns:
boolean—trueif the point is inside the contour, otherwisefalse
isOnBoundary(contour, point)
Test whether a point lies on a contour's boundary (any of its curves).
- Parameters:
contour:ContourHandle— The contour to querypoint:Vec3Handle— The point to test
- Returns:
boolean—trueif the point is on the boundary, otherwisefalse
isClockwise(contour)
Test whether a contour's outer profile is wound clockwise on the XZ plane.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
boolean—trueif the contour is clockwise, otherwisefalse
isPlanar(contour)
Test whether a contour is planar.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
boolean—trueif the contour is planar, otherwisefalse
isEmpty(contour)
Test whether a contour is empty (its outer profile contains no curves).
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
boolean—trueif the contour is empty, otherwisefalse
isSelfIntersecting(contour)
Test whether a contour intersects itself.
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
boolean—trueif the contour is self-intersecting, otherwisefalse
isOrientationValid(contour)
Test whether a contour's orientation is valid (outer profile and holes are wound consistently).
- Parameters:
contour:ContourHandle— The contour to query
- Returns:
boolean—trueif the orientation is valid, otherwisefalse
isEqual(contourA, contourB)
Test whether two contours are geometrically equal.
- Parameters:
contourA:ContourHandle— First contourcontourB:ContourHandle— Second contour
- Returns:
boolean—trueif the contours are equal, otherwisefalse
Errors
Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:
| Code | Thrown by | When | details |
|---|---|---|---|
PRECONDITION_FAILED | getBoundingBox | The contour is empty — there are no points to bound | handles — the offending contour |
HANDLE_INVALID | all methods | The contour or point handle cannot be resolved | — |
Every other read is total — misses come back as data (getOuterProfile → null, listHoles → []), not as errors. Check isEmpty before asking an untrusted contour for its bounding box.