Hide menu
Loading...
Searching...
No Matches
Basic Measurements

MTK supports computation of basic geometric measurements for 3D objects:

See the corresponding sections and class references for usage details and limitations.

Bounding Box

A bounding box is a box that fully contains a 3D model or one of its components.

MTK supports two kinds of bounding boxes:

  • axis-aligned bounding box (AABB), whose axes are aligned with the global coordinate axes;
  • oriented bounding box (OBB), whose axes may be rotated to better fit the input geometry.

Axis-Aligned Bounding Box

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:

ModelData.Shape aShape = ...;
ModelData.Box aBox = new ModelData.Box();
Geom.Transformation aTrsf = new Geom.Transformation();
Measurements.BoundingBox.Compute(aShape, aTrsf, aBox);

Oriented 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() :

ModelData.Shape aShape = ...;
ModelData.Box aBox = new ModelData.Box();
Geom.Transformation aTrsf = new Geom.Transformation();
Measurements.BoundingBox.ComputeMin(aShape, aBox, aTrsf);

Bounding Cylinder

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:

ModelData.Shape aShape = ...;
Measurements.Cylinder aCylinder = Measurements.BoundingCylinder.ComputeOrientedCylinder(aShape);

Surface Area

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:

ModelData.Shape aShape = ...;
double aSurfaceArea = Measurements.SurfaceArea.Compute(aShape);

Volume

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:

ModelData.Shape aShape = ...;
double aVolume = Measurements.Volume.Compute(aShape);

Distance

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:

ModelData.Shape aFirstShape = ...;
ModelData.Shape aSecondShape = ...;
double aDistance = Measurements.Distance.Compute(aFirstShape, aSecondShape);

Angle

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:

ModelData.Face aFirstFace = ...;
ModelData.Face aSecondFace = ...;
double anAngle = Measurements.Angle.Compute(aFirstFace, aSecondFace);

Validation Properties

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:

ModelData.Shape aShape = ...;
Measurements.ValidationPropertyData aProperties = Measurements.ValidationProperties.Compute(aShape);
double aSurfaceArea = aProperties.SurfaceArea();
double aVolume = aProperties.Volume();
Geom.Point aCentroid = aProperties.Centroid();
Geom.Direction aFirstAxis = aProperties.FirstAxisOfInertia();
Geom.Direction aSecondAxis = aProperties.SecondAxisOfInertia();
Geom.Direction aThirdAxis = aProperties.ThirdAxisOfInertia();

Centroid

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:

ModelData.Shape aShape = ...;
Geom.Point aCentroid = Measurements.ValidationProperties.ComputeCentroid(aShape);