static void CompleteImageExample(MIL_ID MilSystem, MIL_ID MilDisplay) { MIL_ID MilImage = MIL.M_NULL; // Image buffer identifier. MIL_ID GraphicList = MIL.M_NULL; // Graphic list identifier. MIL_ID MilCalibration = MIL.M_NULL; // Calibration context MIL_ID MilMetrolContext = MIL.M_NULL; // Metrology Context MIL_ID MilMetrolResult = MIL.M_NULL; // Metrology Result MIL_ID MilModelFinderContext = MIL.M_NULL; // Model Finder Context MIL_ID MilModelFinderResult = MIL.M_NULL; // Model Finder Result double Status = 0.0; double Value = 0.0; MIL_INT[] MinDistanceFeatureLabels = new MIL_INT[2]; MIL_INT[] AngularityFeatureLabels = new MIL_INT[2]; MIL_INT[] MaxDistanceFeatureLabels = new MIL_INT[2]; MIL_INT[] MaxDistanceFeatureIndices = new MIL_INT[2]; MinDistanceFeatureLabels[0] = CIRCLE1_LABEL; MinDistanceFeatureLabels[1] = CIRCLE2_LABEL; AngularityFeatureLabels[0] = SEGMENT1_LABEL; AngularityFeatureLabels[1] = SEGMENT2_LABEL; MaxDistanceFeatureLabels[0] = POINT1_LABEL; MaxDistanceFeatureLabels[1] = POINT1_LABEL; MaxDistanceFeatureIndices[0] = 0; MaxDistanceFeatureIndices[1] = 1; // Restore and display the source image. MIL.MbufRestore(METROL_COMPLETE_IMAGE_FILE, MilSystem, ref MilImage); MIL.MdispSelect(MilDisplay, MilImage); // Restore and associate calibration context to source image MIL.McalRestore(METROL_CALIBRATION_FILE, MilSystem, MIL.M_DEFAULT, ref MilCalibration); MIL.McalAssociate(MilCalibration, MilImage, MIL.M_DEFAULT); // Allocate a graphic list to hold the subpixel annotations to draw. MIL.MgraAllocList(MilSystem, MIL.M_DEFAULT, ref GraphicList); // Associate the graphic list to the display for annotations. MIL.MdispControl(MilDisplay, MIL.M_ASSOCIATED_GRAPHIC_LIST_ID, GraphicList); // Allocate metrology context and result. MIL.MmetAlloc(MilSystem, MIL.M_DEFAULT, ref MilMetrolContext); MIL.MmetAllocResult(MilSystem, MIL.M_DEFAULT, ref MilMetrolResult); // Add a first measured circle feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_CIRCLE, CIRCLE1_LABEL, MIL.M_DEFAULT, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(CIRCLE1_LABEL), MIL.M_DEFAULT, MIL.M_RING, RING1_POSITION_X, RING1_POSITION_Y, RING1_START_RADIUS, RING1_END_RADIUS, MIL.M_NULL, MIL.M_NULL); // Add a second measured circle feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_CIRCLE, CIRCLE2_LABEL, MIL.M_DEFAULT, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(CIRCLE2_LABEL), MIL.M_DEFAULT, MIL.M_RING, RING2_POSITION_X, RING2_POSITION_Y, RING2_START_RADIUS, RING2_END_RADIUS, MIL.M_NULL, MIL.M_NULL); // Add a first measured segment feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_SEGMENT, SEGMENT1_LABEL, MIL.M_DEFAULT, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_DEFAULT, MIL.M_RECTANGLE, RECT1_POSITION_X, RECT1_POSITION_Y, RECT1_WIDTH, RECT1_HEIGHT, RECT1_ANGLE, MIL.M_NULL); MIL.MmetControl(MilMetrolContext, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_EDGEL_ANGLE_RANGE, 10); // Add a second measured segment feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_SEGMENT, SEGMENT2_LABEL, MIL.M_INNER_FIT, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(SEGMENT2_LABEL), MIL.M_DEFAULT, MIL.M_RECTANGLE, RECT2_POSITION_X, RECT2_POSITION_Y, RECT2_WIDTH, RECT2_HEIGHT, RECT2_ANGLE, MIL.M_NULL); // Add a measured point feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_POINT, POINT1_LABEL, MIL.M_DEFAULT, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(POINT1_LABEL), MIL.M_DEFAULT, MIL.M_SEGMENT, SEG1_START_X, SEG1_START_Y, SEG1_END_X, SEG1_END_Y, MIL.M_NULL, MIL.M_NULL); MIL.MmetControl(MilMetrolContext, MIL.M_FEATURE_LABEL(POINT1_LABEL), MIL.M_FILTER_MODE, MIL.M_KERNEL); // Set the polarity and the maximum number of points to detect along the segment region MIL.MmetControl(MilMetrolContext, MIL.M_FEATURE_LABEL(POINT1_LABEL), MIL.M_EDGEL_RELATIVE_ANGLE, MIL.M_SAME_OR_REVERSE); MIL.MmetControl(MilMetrolContext, MIL.M_FEATURE_LABEL(POINT1_LABEL), MIL.M_NUMBER_MAX, 2); // Add minimum distance tolerance MIL.MmetAddTolerance(MilMetrolContext, MIL.M_DISTANCE_MIN, MIN_DISTANCE_LABEL, MIN_DISTANCE_VALUE_MIN, MIN_DISTANCE_VALUE_MAX, MinDistanceFeatureLabels, MIL.M_NULL, 2, MIL.M_DEFAULT); // Add angularity tolerance MIL.MmetAddTolerance(MilMetrolContext, MIL.M_ANGULARITY, ANGULARITY_LABEL, ANGULARITY_VALUE_MIN, ANGULARITY_VALUE_MAX, AngularityFeatureLabels, MIL.M_NULL, 2, MIL.M_DEFAULT); // Add maximum distance tolerance MIL.MmetAddTolerance(MilMetrolContext, MIL.M_DISTANCE_MAX, MAX_DISTANCE_LABEL, MAX_DISTANCE_VALUE_MIN, MAX_DISTANCE_VALUE_MAX, MaxDistanceFeatureLabels, MaxDistanceFeatureIndices, 2, MIL.M_DEFAULT); // Calculate MIL.MmetCalculate(MilMetrolContext, MilImage, MilMetrolResult, MIL.M_DEFAULT); // Draw features MIL.MgraColor(MIL.M_DEFAULT, REGION_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_REGION, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Regions used to calculate measured features:\n"); Console.Write("- two measured circle features\n"); Console.Write("- two measured segment features\n"); Console.Write("- one measured points feature\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); MIL.MgraColor(MIL.M_DEFAULT, FEATURE_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_FEATURE, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Calculated features:\n"); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(CIRCLE1_LABEL), MIL.M_RADIUS, ref Value); Console.Write("- first measured circle: radius={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(CIRCLE2_LABEL), MIL.M_RADIUS, ref Value); Console.Write("- second measured circle: radius={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_LENGTH, ref Value); Console.Write("- first measured segment: length={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(SEGMENT2_LABEL), MIL.M_LENGTH, ref Value); Console.Write("- second measured segment: length={0:0.00}mm\n", Value); Console.Write("- two measured points\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Get angularity tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Angularity value: {0:0.00} degrees.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Angularity value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_DEFAULT); // Get min distance tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Min distance tolerance value: {0:0.00} mm.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Min distance tolerance value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_DEFAULT); // Get max distance tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Max distance tolerance value: {0:0.00} mm.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Max distance tolerance value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_DEFAULT); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); // Restore the model finder context and calibrate it MIL.MmodRestore(METROL_MODEL_FINDER_FILE, MilSystem, MIL.M_DEFAULT, ref MilModelFinderContext); MIL.MmodControl(MilModelFinderContext, 0, MIL.M_ASSOCIATED_CALIBRATION, MilCalibration); // Allocate a result buffer MIL.MmodAllocResult(MilSystem, MIL.M_DEFAULT, ref MilModelFinderResult); // Find object occurrence MIL.MmodPreprocess(MilModelFinderContext, MIL.M_DEFAULT); MIL.MmodFind(MilModelFinderContext, MilImage, MilModelFinderResult); // Get number of found occurrences MIL.MmodGetResult(MilModelFinderResult, MIL.M_GENERAL, MIL.M_NUMBER, ref Value); if (Value == 1) { MIL.MmodDraw(MIL.M_DEFAULT, MilModelFinderResult, GraphicList, MIL.M_DRAW_POSITION + MIL.M_DRAW_BOX, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Found occurrence using MIL Model Finder.\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); // Set the new context position MIL.MmetSetPosition(MilMetrolContext, MIL.M_DEFAULT, MIL.M_RESULT, MilModelFinderResult, 0, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT); // Calculate MIL.MmetCalculate(MilMetrolContext, MilImage, MilMetrolResult, MIL.M_DEFAULT); // Draw features MIL.MgraColor(MIL.M_DEFAULT, REGION_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_REGION, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Regions used to calculate measured features at the new location.\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); MIL.MgraColor(MIL.M_DEFAULT, FEATURE_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_FEATURE, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Calculated features.\n"); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(CIRCLE1_LABEL), MIL.M_RADIUS, ref Value); Console.Write("- first measured circle: radius={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(CIRCLE2_LABEL), MIL.M_RADIUS, ref Value); Console.Write("- second measured circle: radius={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_LENGTH, ref Value); Console.Write("- first measured segment: length={0:0.00}mm\n", Value); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(SEGMENT2_LABEL), MIL.M_LENGTH, ref Value); Console.Write("- second measured segment: length={0:0.00}mm\n", Value); Console.Write("- two measured points\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Get angularity tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Angularity value: {0:0.00} degrees.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Angularity value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(ANGULARITY_LABEL), MIL.M_DEFAULT); // Get min distance tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Min distance tolerance value: {0:0.00} mm.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Min distance tolerance value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(MIN_DISTANCE_LABEL), MIL.M_DEFAULT); // Get max distance tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Max distance tolerance value: {0:0.00} mm.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Max distance tolerance value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(MAX_DISTANCE_LABEL), MIL.M_DEFAULT); Console.Write("Press <Enter> to quit.\n\n"); Console.ReadKey(); } else { Console.Write("Occurrence not found.\n"); Console.Write("Press <Enter> to quit.\n\n"); Console.ReadKey(); } // Free all allocations. MIL.MgraFree(GraphicList); MIL.MmodFree(MilModelFinderContext); MIL.MmodFree(MilModelFinderResult); MIL.MmetFree(MilMetrolResult); MIL.MmetFree(MilMetrolContext); MIL.McalFree(MilCalibration); MIL.MbufFree(MilImage); }
static void CompleteImageExample(MIL_ID MilSystem, MIL_ID MilDisplay) { MIL_ID MilImage = MIL.M_NULL; // Image buffer identifier. MIL_ID GraphicList = MIL.M_NULL; // Graphic list identifier. MIL_ID MilCalibration = MIL.M_NULL; // Calibration context MIL_ID MilMetrolContext = MIL.M_NULL; // Metrology Context MIL_ID MilMetrolResult = MIL.M_NULL; // Metrology Result MIL_ID MilModelFinderContext = MIL.M_NULL; // Model Finder Context MIL_ID MilModelFinderResult = MIL.M_NULL; // Model Finder Result double Status = 0.0; double Value = 0.0; MIL_INT[] LengthLabels = new MIL_INT[1]; LengthLabels[0] = SEGMENT1_LABEL; // Restore and display the source image. MIL.MbufRestore(METROL_COMPLETE_IMAGE_FILE, MilSystem, ref MilImage); MIL.MdispSelect(MilDisplay, MilImage); // Allocate a graphic list to hold the subpixel annotations to draw. MIL.MgraAllocList(MilSystem, MIL.M_DEFAULT, ref GraphicList); // Associate the graphic list to the display for annotations. MIL.MdispControl(MilDisplay, MIL.M_ASSOCIATED_GRAPHIC_LIST_ID, GraphicList); // Allocate metrology context and result. MIL.MmetAlloc(MilSystem, MIL.M_DEFAULT, ref MilMetrolContext); MIL.MmetAllocResult(MilSystem, MIL.M_DEFAULT, ref MilMetrolResult); // Add a first measured circle feature to context and set its search region // Add a first measured segment feature to context and set its search region MIL.MmetAddFeature(MilMetrolContext, MIL.M_MEASURED, MIL.M_SEGMENT, SEGMENT1_LABEL, MIL.M_DEFAULT, MIL.M_NULL, MIL.M_NULL, 0, MIL.M_DEFAULT); MIL.MmetSetRegion(MilMetrolContext, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_DEFAULT, MIL.M_RECTANGLE, RECT1_POSITION_X, RECT1_POSITION_Y, RECT1_WIDTH, RECT1_HEIGHT, RECT1_ANGLE, MIL.M_NULL); MIL.MmetControl(MilMetrolContext, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_EDGEL_ANGLE_RANGE, 10); // Add minimum distance tolerance MIL.MmetAddTolerance(MilMetrolContext, MIL.M_LENGTH, LENGTH_LABEL, LENGTH_VALUE_MIN, LENGTH_VALUE_MAX, LengthLabels, MIL.M_NULL, 1, MIL.M_DEFAULT); // Restore the model finder context and calibrate it MIL.MmodRestore(METROL_MODEL_FINDER_FILE, MilSystem, MIL.M_DEFAULT, ref MilModelFinderContext); //MIL.MmodControl(MilModelFinderContext, 0, MIL.M_ASSOCIATED_CALIBRATION, MilCalibration); // Allocate a result buffer MIL.MmodAllocResult(MilSystem, MIL.M_DEFAULT, ref MilModelFinderResult); // Find object occurrence MIL.MmodPreprocess(MilModelFinderContext, MIL.M_DEFAULT); MIL.MmodFind(MilModelFinderContext, MilImage, MilModelFinderResult); // Get number of found occurrences MIL.MmodGetResult(MilModelFinderResult, MIL.M_GENERAL, MIL.M_NUMBER, ref Value); if (Value == 1) { MIL.MmodDraw(MIL.M_DEFAULT, MilModelFinderResult, GraphicList, MIL.M_DRAW_POSITION + MIL.M_DRAW_BOX, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Found occurrence using MIL Model Finder.\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); // Set the new context position MIL.MmetSetPosition(MilMetrolContext, MIL.M_DEFAULT, MIL.M_RESULT, MilModelFinderResult, 0, MIL.M_NULL, MIL.M_NULL, MIL.M_DEFAULT); // Calculate MIL.MmetCalculate(MilMetrolContext, MilImage, MilMetrolResult, MIL.M_DEFAULT); // Draw features MIL.MgraColor(MIL.M_DEFAULT, REGION_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_REGION, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Regions used to calculate measured features at the new location.\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Clear annotations. MIL.MgraClear(MIL.M_DEFAULT, GraphicList); MIL.MgraColor(MIL.M_DEFAULT, FEATURE_COLOR); MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_FEATURE, MIL.M_DEFAULT, MIL.M_DEFAULT); Console.Write("Calculated features.\n"); MIL.MmetGetResult(MilMetrolResult, MIL.M_FEATURE_LABEL(SEGMENT1_LABEL), MIL.M_LENGTH, ref Value); Console.Write("- first measured segment: length={0:0.00}mm\n", Value); Console.Write("- two measured points\n"); Console.Write("Press <Enter> to continue.\n\n"); Console.ReadKey(); // Get min distance tolerance status and value MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(LENGTH_LABEL), MIL.M_STATUS, ref Status); MIL.MmetGetResult(MilMetrolResult, MIL.M_TOLERANCE_LABEL(LENGTH_LABEL), MIL.M_TOLERANCE_VALUE, ref Value); if (Status == MIL.M_PASS) { MIL.MgraColor(MIL.M_DEFAULT, PASS_COLOR); Console.Write("Min distance tolerance value: {0:0.00} mm.\n", Value); } else { MIL.MgraColor(MIL.M_DEFAULT, FAIL_COLOR); Console.Write("Min distance tolerance value - Fail.\n"); } MIL.MmetDraw(MIL.M_DEFAULT, MilMetrolResult, GraphicList, MIL.M_DRAW_TOLERANCE, MIL.M_TOLERANCE_LABEL(LENGTH_LABEL), MIL.M_DEFAULT); Console.Write("Press <Enter> to quit.\n\n"); Console.ReadKey(); } else { Console.Write("Occurrence not found.\n"); Console.Write("Press <Enter> to quit.\n\n"); Console.ReadKey(); } // Free all allocations. MIL.MgraFree(GraphicList); MIL.MmodFree(MilModelFinderContext); MIL.MmodFree(MilModelFinderResult); MIL.MmetFree(MilMetrolResult); MIL.MmetFree(MilMetrolContext); //MIL.McalFree(MilCalibration); MIL.MbufFree(MilImage); }