| MIL 10 Reference
| Customize Help
| Save Settings

MmodDefineFromFile



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
None.
Synopsis
Defines a model from a file and adds it to a Model Finder context.
Syntax
void MmodDefineFromFile(
MIL_ID ContextModId, //in
MIL_INT64 FileType, //in
MIL_CONST_TEXT_PTR FileName, //in
MIL_INT64 ControlFlag //in
)
Description

This function defines a model from a file and adds it to a Model Finder context. Models defined from a file are CAD-type synthetic models; use MmodDefine() to add other types of models to the Model Finder context. This function does not support M_SHAPE_CIRCLE type of Model Finder contexts.

You must preprocess the Model Finder context after you add a model.

By default, synthetic models are defined to have a 10% margin around the bounding box of their active edges. When finding an occurrence, any extra edges found in this area will reduce the target score. You can change the size of the margins with the MmodControl() M_BOX_MARGIN_... control types.

When the model is added to the Model Finder context from a CAD DXF file, the model will retain the CAD-file's coordinate system (the origin and the axis). Specify the ratio between model units and pixel units using MmodControl() with M_PIXEL_SCALE.

Note that if the model is used to search in a calibrated target, you must also associate the calibration context of the target with the model, using M_ASSOCIATED_CALIBRATION. MIL needs the calibration context for internal purposes at preprocessing time. MIL will not use the calibration context to compensate for inconguencies between the model and the target, nor will MIL map the model's coordinate system to that of the target.

If the target is calibrated, the model units should be the same as the calibrated units. If the target is calibrated, M_PIXEL_SCALE will be used for draw operations, but not for the match nor the returned results.

Most CAD DXF files are oriented so that the Y-axis is positive going up, whereas the coordinate system MIL uses is oriented with the Y-axis positive going down. So if you take the edge coordinates of an object from a CAD DXF file and put them in an image, the imaged object will look flipped when compared to the original object. This is also the case for a model defined from a CAD DXF file. This means that, unless the object is symmetrical, the match will not be made. You can use M_CAD_Y_AXIS to set the Y-axis in the appropriate direction.

To delete a model from a Model Finder context, use MmodDefine() with M_DELETE.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
ContextModId

Specifies the identifier of the Model Finder context. For this parameter, you can only specify M_GEOMETRIC or M_GEOMETRIC_CONTROLLED type of Model Finder contexts.

FileType

Specifies the type of file from which to define the model.

This parameter can be set to the following value:

function map For specifying the type of file
CollapseValue Description
Collapse M_DXF_FILE

Defines the model from the entities in the specified CAD DXF file. This function does not support all entities that are possible in a CAD DXF file. If there are unsupported entities in the file, they are ignored, and the rest of the entities are read. The supported entities are as follows: LINE, POLYLINE, LWPOLYLINE, CIRCLE, ARC, ELLIPSE, INSERT, and BLOCK.

A model defined from a CAD DXF file has no polarity.

(summarize)
FileName

Specifies the name and path of the file from which to define the model. The function handles (internally) the opening and closing of the file.

This parameter can be set to the following value:

function map For specifying the file name and path
CollapseValue Description
Collapse MIL_TEXT("FileName") 1

Specifies the drive, directory, and name of the file (for example, "C:\mydirectory\myfile").

To specify a file on a remote computer (under Distributed MIL), prefix the specified file name string with "remote:///", for example: "remote:///C:\mydirectory\myfile".

(summarize)

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

ControlFlag

Reserved for future expansion. Set this parameter to M_DEFAULT.

Compilation information
Header Include mil.h.
Library Use mil.lib; milmod.lib.
DLL Requires mil.dll; milmod.dll.
DXF FILE