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:

aShape : mtk.ModelData_Shape = ...
aBox = mtk.ModelData_Box()
aTrsf = mtk.Geom_Transformation()
mtk.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() :

aShape : mtk.ModelData_Shape = ...
aBox = mtk.ModelData_Box()
aTrsf = mtk.Geom_Transformation()
mtk.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:

aShape : mtk.ModelData_Shape = ...
aCylinder = mtk.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:

aShape : mtk.ModelData_Shape = ...
aSurfaceArea = mtk.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:

aShape : mtk.ModelData_Shape = ...
aVolume = mtk.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:

aFirstShape = ... # mtk.ModelData_Shape
aSecondShape = ... # mtk.ModelData_Shape
aDistance = mtk.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:

aFirstFace = ... # mtk.ModelData_Face
aSecondFace = ... # mtk.ModelData_Face
anAngle = mtk.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:

aShape : mtk.ModelData_Shape = ...
aProperties = mtk.Measurements_ValidationProperties.Compute(aShape)
aSurfaceArea = aProperties.SurfaceArea()
aVolume = aProperties.Volume()
aCentroid = aProperties.Centroid()
aFirstAxis = aProperties.FirstAxisOfInertia()
aSecondAxis = aProperties.SecondAxisOfInertia()
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:

aShape : mtk.ModelData_Shape = ...
aCentroid = mtk.Measurements_ValidationProperties.ComputeCentroid(aShape)