Skip to content

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, or null if 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 a Vec3Components { 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 }, or null if 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 query
    • point: 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 query
    • point: Vec3Handle — The point to test
  • Returns: booleantrue if the point is inside the contour, otherwise false

isOnBoundary(contour, point)

Test whether a point lies on a contour's boundary (any of its curves).

  • Parameters:
    • contour: ContourHandle — The contour to query
    • point: Vec3Handle — The point to test
  • Returns: booleantrue if the point is on the boundary, otherwise false

isClockwise(contour)

Test whether a contour's outer profile is wound clockwise on the XZ plane.

  • Parameters:
    • contour: ContourHandle — The contour to query
  • Returns: booleantrue if the contour is clockwise, otherwise false

isPlanar(contour)

Test whether a contour is planar.

  • Parameters:
    • contour: ContourHandle — The contour to query
  • Returns: booleantrue if the contour is planar, otherwise false

isEmpty(contour)

Test whether a contour is empty (its outer profile contains no curves).

  • Parameters:
    • contour: ContourHandle — The contour to query
  • Returns: booleantrue if the contour is empty, otherwise false

isSelfIntersecting(contour)

Test whether a contour intersects itself.

  • Parameters:
    • contour: ContourHandle — The contour to query
  • Returns: booleantrue if the contour is self-intersecting, otherwise false

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: booleantrue if the orientation is valid, otherwise false

isEqual(contourA, contourB)

Test whether two contours are geometrically equal.

  • Parameters:
    • contourA: ContourHandle — First contour
    • contourB: ContourHandle — Second contour
  • Returns: booleantrue if the contours are equal, otherwise false

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
PRECONDITION_FAILEDgetBoundingBoxThe contour is empty — there are no points to boundhandles — the offending contour
HANDLE_INVALIDall methodsThe contour or point handle cannot be resolved

Every other read is total — misses come back as data (getOuterProfilenull, listHoles[]), not as errors. Check isEmpty before asking an untrusted contour for its bounding box.