MIL_ID Context3dmetId,  //in 
MIL_ID SrcContainerOrImageBufId,  //in 
MIL_INT GeometryType,  //in 
MIL_ID Result3dmetId,  //in 
MIL_DOUBLE OutlierDistance,  //in 
MIL_INT64 ControlFlag  //in 
This function fits a 3D geometry to a point cloud or depth map using an iterative fit operation. The function starts from an initial fit estimate of the size and position of the 3D geometry. The function then internally iterates through better estimates of the correct size and position of the 3D geometry until a specified stop condition is reached. Upon each iteration, the function calculates the average rootmeansquare (RMS) error per inlier, until a stop condition is met.
The initial fit estimate is calculated according to the mode specified using M3dmetControl() with M_ESTIMATION_MODE. A set of inlier points is then defined according to OutlierDistance, and a new size and placement for the 3D geometry, which reduces the average RMS error per inlier, is calculated. This process then repeats until a stop condition is met.
If the initial fit estimate mode is set to M_FROM_GEOMETRY, the fit operation will use the specified geometry in the fit 3D metrology context. By default, the context contains an undefined geometry. If you try to initiate the fit operation and use the undefined geometry to determine an initial fit estimate, an error will occur. You can use M3dmetCopy() to copy a defined 3D geometry object into the fit 3D metrology context.
If you perform a fit operation using a depth map, it is possible to specify a ROI in raster format, where only the values inside the ROI will be used in the fit. Note that missing data (or invalid points) in the depth map (or point cloud) are ignored when fitting.
When fitting, it is also possible to specify an outlier distance, beyond which no input data is considered for the fit operation.
After calling M3dmetFit(), you can inquire whether the operation was successful using M3dmetGetResult() with M_STATUS, along with several other metrics. To retrieve the calculated best fit 3D geometry or the inliers, use M3dmetCopyResult().
Note that the fit operation does not support 3D box geometry objects. All other 3D geometry objects are supported.
Specifies the fit 3D metrology context.
For specifying the 3D metrology fit
context


Value  Description  
M_DEFAULT 
Specifies to perform the fit operation using all the default settings specified for fit 3D metrology contexts in M3dmetControl(). 

Fit 3D metrology context identifier 
Specifies the identifier of a fit 3D metrology context. 
Specifies the point cloud or depth map to which to fit the 3D geometry.
For specifying the point cloud or depth
map


Value  Description  
Depth map image buffer identifier 
Specifies the identifier of an image buffer that contains a fully corrected depth map. 

Point cloud container identifier 
Specifies the identifier of the container containing a 3Dprocessable point cloud. 
Specifies the type of 3D geometry object to use in the fit operation. Note that 3D box geometry objects are not supported.
Specifies the type of geometry to fit onto the source
container


Value  Description  
M_CYLINDER 
Specifies to fit a 3D cylinder geometry to the point cloud or depth map. 

M_LINE 
Specifies to fit a 3D line geometry to the point cloud or depth map. 

M_PLANE 
Specifies to fit a 3D plane geometry to the point cloud or depth map. 

M_SPHERE 
Specifies to fit a 3D sphere geometry to the point cloud or depth map. 
Specifies the identifier of the fit 3D metrology result buffer in which to store the results of the fit operation. The result buffer must have been previously allocated using M3dmetAllocResult() with M_FIT_RESULT. To retrieve statistics for the fit operation, use M3dmetGetResult().
Specifies the distance from the 3D geometry, beyond which points are considered outliers and will be ignored during the fit operation.
For specifying the distance beyond which points
become outliers


Value  Description  
M_DEFAULT 
Same as M_INFINITE. 

M_INFINITE 
Specifies that no points in the point cloud are outliers, and all points will be considered inliers in every iteration of the fit operation. 

Value >= 0.0 
Specifies the distance from the 3D geometry, beyond which points are considered outliers and will be ignored during the fit operation. 
Header  Include mil.h. 
Library  Use mil.lib; mil3dmet.lib. 
DLL  Requires mil.dll; mil3dmet.dll. 