| MIL 10 Reference
| Customize Help
| Save Settings

MmodStream



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

Available on Windows
Available on Linux with restrictions

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.
Next
Synopsis
Load, restore, or save a Model Finder context from/to a file or a memory stream.
Syntax
void MmodStream(
MIL_TEXT_PTR MemPtrOrFileName, //in-out
MIL_ID SystemId, //in
MIL_INT64 Operation, //in
MIL_INT64 StreamType, //in
MIL_DOUBLE Version, //in
MIL_INT64 ControlFlag, //in
MIL_ID *ContextIdPtr, //in-out
MIL_INT *SizeByteVarPtr //out
)
Description

This function can load or restore a Model Finder context from a file or memory stream. All of the Model Finder context's settings that were in effect when the Model Finder context was saved will be restored. A loaded or restored Model Finder context is not preprocessed, therefore you must call MmodPreprocess() before performing a search with MmodFind(). If you had associated calibration contexts with the models in your Model Finder context and you did not save them with the context, you must re-associate the calibration contexts, using MmodControl() with M_ASSOCIATED_CALIBRATION.

Moreover, this function can also save a Model Finder context to a file or memory stream. All information about the previously allocated Model Finder context is saved, including all of the individual models' current settings. However, preprocessing, any associated calibration contexts and drawing control type settings are not saved.

To inquire the number of bytes necessary to save a Model Finder context to memory stream, you should call this function (MmodStream()) first with M_INQUIRE_SIZE_BYTE.

The content saved to memory stream is equivalent to the content saved to file. In addition, any file saved with MmodSave() is equivalent to a file saved using this function.

You can use this and other MIL stream functions, for example, to save all required MIL objects, as well as any other custom data, for your application to a memory stream. Once in a memory stream, you can write the stream to a single file or transfer it over a network. You are responsible for concatenating the streams and for saving the stream to file.

Using MmodStream(), you can choose to save a backwards-compatible version of the Model Finder context, which will work using a version of MIL that is up to one major release older than the current version (depending on which version is specified). For example, if you allocate a Model Finder context using MIL 9.0 and save it to version 8.0, you can restore this context on a computer where MIL 8.0 is installed. However, all settings and features unique to the higher version will be ignored when restored using the lower version. Besides saving backwards-compatible versions, you can also load or restore Model Finder contexts saved using MIL version 7.0 or above. Settings that do not exist in the lower version will be filled with default values when the Model Finder context is loaded or restored.

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
MemPtrOrFileName

Specifies the file or memory stream.

function map For specifying the name and path of a file, memory stream or opening an interactive dialog box
CollapseValue Description
Collapse M_NULL

Specifies to ignore this parameter. The parameter must be set to M_NULL when performing an M_INQUIRE_SIZE_BYTE operation.

(summarize)
Collapse M_INTERACTIVE
[This is only applicable to Windows]

Opens a dialog box from which you can interactively specify the drive, directory, and name of the file, when the StreamType parameter is set to M_FILE.

Collapse MIL_TEXT("FileName") 1

Specifies the drive, directory, and name of the file (for example, "C:\mydirectory\myfile"), when the StreamType parameter is set to M_FILE. For easier use with other Matrox Imaging software products, when saving a Model Finder context to a file, use the MMF file extension. The function internally handles the opening and closing of the file. If the file already exists, it will be overwritten when M_SAVE is performed.

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)
Collapse MemPtr

Specifies the address of the block of memory, when the StreamType parameter is set to M_MEMORY. The designated block must be large enough to stream the entire object. To ascertain the required size, call this function (MmodStream()) first with M_INQUIRE_SIZE_BYTE.

When you allocate the block of memory, the memory pointer is of type MIL_UINT8. In this case, you must cast the MIL_UINT8 pointer to a MIL_TEXT_PTR.

(summarize)

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

SystemId

Specifies the system on which to restore the Model Finder context. For an M_RESTORE operation, set this parameter to one of the following values:

function map For a restore operation
CollapseValue Description
Collapse M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

Collapse MIL system identifier

Specifies a valid system identifier, previously allocated using MsysAlloc().

For M_INQUIRE_SIZE_BYTE, M_LOAD, and M_SAVE, this parameter must be set to the following value:

function map For a load or save operation, or when inquiring the required number of bytes for a save operation
CollapseValue Description
Collapse M_NULL

Specifies that this parameter is not applicable.

Operation

Specifies the operation to perform on the Model Finder context. This parameter must be set to one of the following values:

function map For specifying the type of operation to perform
CollapseValue Description
Collapse M_INQUIRE_SIZE_BYTE

Inquires the number of bytes required to save a Model Finder context to memory stream. This operation is not supported when the StreamType parameter is set to M_FILE.

(summarize)
Collapse M_LOAD

Loads the content of a specified file or memory stream into a previously allocated Model Finder context.

Collapse M_RESTORE

Restores a Model Finder context from a file or memory stream and assigns it an identifier.

Collapse M_SAVE

Saves a Model Finder context to a specified file or memory stream.

StreamType

Specifies the type of stream in which to store/from which to restore the Model Finder context. This parameter must be set to one of the following values:

function map For specifying the type of stream
CollapseValue Description
Collapse M_FILE

Specifies a file stream.

Collapse M_MEMORY

Specifies a memory stream. You are responsible for allocating a block of memory for the stream.

(summarize)
Version

Specifies the MIL version of the Model Finder context. This parameter must be set to one of the following values.

function map For specifying the MIL version
CollapseValue Description
Collapse M_DEFAULT

Specifies the default version.

For an M_SAVE or M_INQUIRE_SIZE_BYTE operation, it sets the version to current version of MIL.

For an M_LOAD or M_RESTORE operation, it reads the file or stream for the version information. This is the only possible setting for these operations.

(summarize)
Collapse M_PROC_VERSION_90

Sets the version to MIL 9.0.

This option is available only for M_INQUIRE_SIZE_BYTE and M_SAVE operations.

(summarize)
Collapse M_PROC_VERSION_90_PP1

Sets the version to MIL 9.0 Processing Pack 1.

This option is available only for M_INQUIRE_SIZE_BYTE and M_SAVE operations.

(summarize)
Collapse M_PROC_VERSION_90_PP2

Sets the version to MIL 9.0 Processing Pack 2.

This option is available only for M_INQUIRE_SIZE_BYTE and M_SAVE operations.

(summarize)
Collapse M_PROC_VERSION_100

Sets the version to MIL 10.0.

This option is available only for M_INQUIRE_SIZE_BYTE and M_SAVE operations.

(summarize)
Collapse M_PROC_VERSION_100_PP1

Sets the version to MIL 10.0 Processing Pack 1.

This option is available only for M_INQUIRE_SIZE_BYTE and M_SAVE operations.

(summarize)
ControlFlag

Specifies whether to restore, from the file or memory stream, the calibration contexts associated with the models, or specifies to save, with the Model Finder context, the calibration contexts associated with the models.

function map For specifying whether to restore or save the calibration contexts
CollapseValue Description
Collapse M_DEFAULT

Specifies that the calibration contexts are not saved or restored.

Collapse M_WITH_CALIBRATION

Specifies that the calibration contexts are saved or restored, depending on the Operation parameter. When restored, the calibration contexts must have been previously saved with the context, using MmodSave() or MmodStream() with M_WITH_CALIBRATION. Note that the calibration contexts associated with synthetic models are not saved or restored.

The calibration information is restored from/ saved to the same file or memory stream as the Model Finder context. The calibration cannot be managed independently from the Model Finder context. When the Model Finder context is freed, the calibration is automatically freed as well.

This setting is not supported for an M_SHAPE_CIRCLE type of Model Finder context.

(summarize)
ContextIdPtr

Specifies the address of the variable in which to write or from which to read the identifier of the Model Finder context.

For M_INQUIRE_SIZE_BYTE and M_SAVE operations, ContextIdPtr specifies the address of the variable from which to read the Model Finder context identifier.

For an M_LOAD operation, the ContextIdPtr specifies the address of the variable from which to read the identifier of the Model Finder context where the file or memory stream content will be loaded.

For an M_RESTORE operation, the ContextIdPtr specifies the address in which to return the identifier of the restored Model Finder context. If the operation is not successful, M_NULL is returned.

SizeByteVarPtr

Specifies the address of the variable in which to write the size of the Model Finder context, in bytes.

If the size is not required, you can set this parameter to M_NULL.

Note that the size of a Model Finder context will vary depending on the MIL version specified.

Compilation information
Header Include mil.h.
Library Use mil.lib; milmod.lib.
DLL Requires mil.dll; milmod.dll.
NULL INTERACTIVE DEFAULT HOST NULL INQUIRE SIZE BYTE LOAD RESTORE SAVE FILE MEMORY DEFAULT PROC VERSION 90 PROC VERSION 90 PP1 PROC VERSION 90 PP2 PROC VERSION 100 PROC VERSION 100 PP1 DEFAULT WITH CALIBRATION LOAD) RESTORE) SAVE) LOAD) RESTORE) SAVE) LOAD) RESTORE) SAVE) LOAD RESTORE SAVE