Enumeration MeasurementType

A measurement Type.

Measurement types are modifiers to tell the way a measurement between two geometric features should be calculated.

/** 
* Sample to illustrate the measurement between a geometry and an arc of circle.
*/
import {
AABB, ArcOfCircleFeature, DataSessionInterface, FeatureManagerInterface, FeatureManagerInterfaceSignal,
FeatureType, GeometryFeature, InfiniteEngineInterface, InfiniteEvent, MeasurementType, MeasurementTypeAttachment,
Unit, Vector3
} from 'generated_files/documentation/appinfiniteapi';

// the data session
// created previously
let lDataSession : DataSessionInterface;

// created previously
let lInfiniteEngine : InfiniteEngineInterface;

// the geometric instance to compute measurement from
let lGeometricInstanceId : number;

// retrieve the `feature` manager
const lFeatureManager : FeatureManagerInterface = lInfiniteEngine.getFeatureManager();
// the measurement request id
let lMeasurementRequestId : number = 0;

// the callback called when a measurement result is ready
const onMeasurementDone = (pEvent: InfiniteEvent) : void =>
{
const lMeasurementAttachment : MeasurementTypeAttachment | undefined = pEvent.attachments;
// is this event valid ?
if(lMeasurementAttachment === undefined || lMeasurementAttachment.contactPoint0 === undefined)
{
console.log('invalid measurement attachment');
return;
}
// is this the correct request ?
if(lMeasurementAttachment.measurementRequestId !== lMeasurementRequestId)
{
// bail out
return;
}
// finally, we made it !
console.log('Found 2 contact points', JSON.stringify(lMeasurementAttachment.contactPoint0), JSON.stringify(lMeasurementAttachment.contactPoint1));

// make two fancy points on the rendering
let lApplicationId : number = lFeatureManager.createPointApplicationFeature(lMeasurementAttachment.contactPoint0);
if(lApplicationId <= 0)
{
console.log('feature creation failed');
}
lApplicationId = lFeatureManager.createPointApplicationFeature(lMeasurementAttachment.contactPoint1);
if(lApplicationId <= 0)
{
console.log('feature creation failed');
}
// and show the result, we are here for that
console.log('Measurement distance', lMeasurementAttachment.contactPoint0.distanceToVector(lMeasurementAttachment.contactPoint1));
};

// register our callback
lFeatureManager.addEventListener(FeatureManagerInterfaceSignal.MeasurementReady, onMeasurementDone);

// retrieve the DMU center
const lDmuAABB : AABB = new AABB();
lDataSession.getDmuAABB(lDmuAABB);

// retrieve the up and front vectors of the scene
const lDmuUpVector : Vector3 = new Vector3();
const lDmuFrontVector : Vector3 = new Vector3();
lInfiniteEngine.getCameraManager().getFrameReference(lDmuFrontVector, lDmuUpVector);

// the arc of circle radius in meters
const lCircleFeatureRadiusInMeters : number = 1.3;

// first `feature` is a geometry
const lFirstFeature : GeometryFeature = {
type: FeatureType.FT_Geometry,
geometricInstanceId: lGeometricInstanceId
};

// second `feature` is an arc of circle
const lSecondFeature : ArcOfCircleFeature = {
type: FeatureType.FT_ArcOfCircle,
center: lDmuAABB.mCenter,
normal: lDmuUpVector,
startDirection: lDmuFrontVector,
radius: lCircleFeatureRadiusInMeters * lDataSession.convertUnitFactor(Unit.U_Meter, lDataSession.getDmuBuildUnit()),
angle: Math.PI * 0.5
};

// and make a measurement between the geometry and the given arc of circle (do not use item centers)
// the measure is the smallest distance between the 2 elements
lMeasurementRequestId = lFeatureManager.computeMeasurement(lFirstFeature, lSecondFeature, MeasurementType.MT_Item_Item);
if(lMeasurementRequestId <= 0)
{
console.log('Failed to make measurement, is the geometric instance id correct ?');
}

Features

Enumeration Members

MT_Axis_Axis: 2

The measurement should be performed by measuring the distance of the two axes referred by the two features.

MT_Center_Center: 1

The measurement should be performed by measuring the shortest distance between the center of the two features.

MT_Center_Item: 3

The measurement should be performed by measuring the distance between the center of the first feature to the second feature.

MT_Item_Center: 4

The measurement should be performed by measuring the distance between the first feature to the center of the second feature.

MT_Item_Item: 0

The measurement should be performed by measuring the shortest distance between the two features.