MTK supports computation of basic geometric measurements for 3D objects:
See the corresponding sections and class references for usage details and limitations.
A bounding box is a box that fully contains a 3D model or one of its components.
MTK supports two kinds of bounding boxes:
Measurements::BoundingBox::Compute() computes an axis-aligned bounding box. Axis-aligned bounding boxes can be computed for an entire model, a model graph element, a body, a B-Rep shape, or a mesh shape.
The following example demonstrates computation of a shape axis-aligned bounding box:
Measurements::BoundingBox::ComputeMin() and Measurements::BoundingBox::ComputeOptimal() compute oriented bounding boxes. Although these methods compute an oriented bounding box, the ModelData::Box class itself can only store axis-aligned data. To bridge this gap, the method calculates the box in its own local coordinate system and returns an output transformation. This transformation defines how to rotate and position the shape to fit inside this box.
These methods use different algorithms. Measurements::BoundingBox::ComputeMin() estimates the box orientation from the principal axes of inertia. Measurements::BoundingBox::ComputeOptimal() attemps to determinate the optimal box orientation from the planar faces and linear edges of the shape. and falls back to Measurements::BoundingBox::ComputeMin() if no suitable orientation is found.
Measurements::BoundingBox::ComputeMin() can be computed for a B-Rep shape. Measurements::BoundingBox::ComputeOptimal() can be computed for an entire model, a part representation, a body, a B-Rep shape, or a mesh shape.
The following example demonstrates how to compute an oriented bounding box for a shape using Measurements::BoundingBox::ComputeMin() :
Bounding cylinder is the smallest oriented cylinder that fully contains a component of a 3D model. This can be used to find the dimensions of a cylindrical workpiece for a given part. Bounding cylinders can be computed for a part representation, a B-Rep or mesh body, a B-Rep shape, or a mesh shape.
The following example demonstrates computation of a shape bounding cylinder:
Surface area can be computed for an entire model, a model graph element, a solid or sheet body, or a shape.
The following example demonstrates computation of a shape surface area:
Volume can be computed for an entire model, a model graph element, a solid body, a shape, or an indexed triangle set.
Measurements::Volume::Compute() also provides overloads for selected manufacturing features, such as machining holes, countersinks and pockets, as well as sheet metal holes and cutouts in the context of a flat pattern. For feature overloads, the returned value represents the removed material volume in mm^3, or -1.0 if the computation fails.
The following example demonstrates computation of a shape volume:
Distance can be computed between two shapes. In addition to the distance value, MTK can also return the closest point on each shape.
The following example demonstrates the computation of the distance between two shapes:
Angle can be computed between two planar faces, between two edges, or from three vertices.
The following example demonstrates the computation of the angle between two planar faces:
Some measurements are also available through Measurements::ValidationProperties . This API computes a set of validation properties for an object and returns them as Measurements::ValidationPropertyData .
Validation properties include surface area, volume, centroid, and axes of inertia. Computing them together is more efficient than computing each value separately.
Measurements::ValidationPropertyData also provides \morph_{Measurements,ValidationPropertyData,IsValid()} to check whether the computed values are valid.
The following example demonstrates computation of validation properties for a shape:
A centroid, or center of mass, can be computed for an entire model, a model graph element, a B-Rep body, or a shape.
In MTK, centroid computation is exposed through Measurements::ValidationProperties .
The following example demonstrates computation of a shape centroid: