Skip to content

Query: Profile

Profile queries — read-only geometric questions about a profile (an ordered loop or chain of curves) and the relationships between two profiles. Accessed via snaptrude.core.geom.query.profile.

Every method takes an opaque ProfileHandle (plus point handles Vec3Handle where relevant) and returns plain values — points as Vec3Components, areas/perimeters/distances as number, predicates as boolean, the bounding box as BBoxComponents. Methods that enumerate the profile's child curves return fresh CurveHandle[]. No query mutates its inputs.

Passing an invalid, stale, or foreign handle rejects the call with HandleInvalidError (code HANDLE_INVALID).

Types

Vec3Components

Plain read-out of a 3D point or vector.

PropertyTypeDescription
xnumberX component
ynumberY component
znumberZ component

BBoxComponents

Axis-aligned bounding box as plain components.

PropertyTypeDescription
minVec3ComponentsMinimum corner of the box
maxVec3ComponentsMaximum corner of the box

Functions

listPoints(profile)

List the tessellated points along a profile.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: Vec3Components[] — The profile points
ts
const points = await snaptrude.core.geom.query.profile.listPoints(profile);
for (const p of points) {
  console.log(p.x, p.y, p.z);
}

listCurves(profile)

List the curves that make up a profile. Host API call — mints fresh handles.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: CurveHandle[] — The profile's curves
ts
const curves = await snaptrude.core.geom.query.profile.listCurves(profile);

getArea(profile)

Get the (approximate) enclosed area of a profile.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: number — The area, in Snaptrude units (see snaptrude.core.units.convert(value, from, to))

getPerimeter(profile)

Get the perimeter (total curve length) of a profile.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: number — The perimeter, in Snaptrude units (see snaptrude.core.units.convert(value, from, to))

getBoundingBox(profile)

Get the axis-aligned bounding box of a profile.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: BBoxComponents — The bounding box

getNormal(profile)

Get the unit normal vector of a profile's plane.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: Vec3Components | null — The normal, or null if the profile has no well-defined normal

getNearestPoint(profile, point)

Get the point on a profile nearest to an arbitrary point.

  • Parameters:
    • profile: ProfileHandle — The profile to query
    • point: Vec3Handle — The reference point
  • Returns: Vec3Components — The nearest point on the profile

hasPoint(profile, point)

Test whether a point lies inside a profile.

  • Parameters:
    • profile: ProfileHandle — The profile to query
    • point: Vec3Handle — The point to test
  • Returns: booleantrue if the point is inside the profile, otherwise false
ts
const point = await snaptrude.core.math.vec3.new(5, 0, 5);
const inside = await snaptrude.core.geom.query.profile.hasPoint(profile, point);

isOnBoundary(profile, point)

Test whether a point lies on a profile's boundary.

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

isClosed(profile)

Test whether a profile forms a closed loop.

  • Parameters:
    • profile: ProfileHandle — The profile to query
  • Returns: booleantrue if the profile is closed, otherwise false

isPlanar(profile)

Test whether a profile is planar.

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

isClockwise(profile)

Test whether a profile is wound clockwise on the XZ plane.

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

isSelfIntersecting(profile)

Test whether a profile intersects itself.

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

isEmpty(profile)

Test whether a profile contains no curves.

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

isEqual(profileA, profileB)

Test whether two profiles are geometrically equal.

  • Parameters:
    • profileA: ProfileHandle — First profile
    • profileB: ProfileHandle — Second profile
  • Returns: booleantrue if the profiles are equal, otherwise false

Errors

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

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

Every other read is total — misses come back as data (getNormalnull), not as errors. Check isEmpty before asking an untrusted profile for its bounding box.