Measurements

CAD Exchanger SDK allows to compute some key properties of a 3D model:

- bounding box;
- surface area;
- volume;
- centroid (center of mass).

Each property can be computed either for an entire model (ModelData_Model) or for any assembly, part, instance, or part representation.

Bounding box is an axis-aligned bounding box which encompasses a 3D model (or its component).

The following example demonstrates computation of a part's bounding box:

In addition to traditional bounding boxes, CAD Exchanger also allows to compute minimum bounding box which is not necessarily axis-aligned:

ModelData_Part aPart = ...;

ModelData_Box aMinBox;

ModelData_Transformation aTrsfToApply;

ModelAlgo_BoundingBox::Compute (aPart, aMinBox, aTrsfToApply);

aMinBox contains an axis-aligned box which would be returned if the part were transformed with the help of returned transformation.

- Note
- The computation of minimum boxes is currently in feature preview state. Its API may change, so binary compatibility can be broken.

Surface area only can be computed for parts having a solid or sheet body in their B-Rep representation.

The following example demonstrates computation of a part's surface area:

ModelData_Part aPart = ...;

double r = ModelAlgo_ValidationProperty::ComputeSurfaceArea (aPart);

Volume can only be computed for parts having a solid body in their B-Rep representation.

The following example demonstrates computation of a part's volume:

ModelData_Part aPart = ...;

double r = ModelAlgo_ValidationProperty::ComputeVolume (aPart);

Centroid (center of mass) can only be computed for parts having B-Rep representations.

The following example demonstrates computation of a part's centroid:

ModelData_Part aPart = ...;

ModelData_Point aCentroid;

ModelAlgo_ValidationProperty::ComputeCentroid (aPart, aCentroid);