These two user macros extract selected objects from an array of input objects. The extract_objects macro extracts a new array of object. The extract_single_object macro extracts a single object.
Name | Type | Description | |
in_objs | mlink | Link to the input array of objects. | |
Name | Type | Description | UI Control |
inc_objects | int[] | Indices of objects to include in output. | Option box list |
objectnames | string[] | Names of input objects. | n/a |
Name | Type | Description | |
out_objs | mlink | Array of links to selected objects. | |
out_obj | link | Link to single selected object. | |
The V scripting language that AVS/Express uses has the ability to create and manipulate arrays of objects. This ability can be used in a variety of ways. The macros in the MODS_ARR library, that is supplied with AVS/Express, take an array of fields as an input and apply the same visualization to each field. Similarly several of the projects in the IAC repository either accept object arrays as input or output object arrays. For example the ReadDXF project outputs each DXF layer as a separate field in an array.
However using arrays does cause some problems when creating applications. One of these problems is that the user cannot easily select a sub-set of the elements in an array. The ExtractObjects project aims to solve this problem by providing a simple, general purpose way of selecting one or more objects from an array of input objects. The input objects can be any objects derived from group, module or macro types. This includes all of the commonly used structures such as Field, Mesh, Node_Data, Cell_Data and DataObject. The input objects cannot be of any of the primitive types (e.g. int, float, double etc.)
Two user macros are provided with this project. The extract_objects macro takes an array of objects as an input and allows the user to pick any number of these. The selected objects are output as an array. The extract_single_object macro similarly takes an array of objects as an input. However the user can only select a single object. The selected object is output as a link. The extract_single_object macro can be useful in situations where other modules do not take arrays as inputs.
If these user macros are not suitable for your application the low-level ExtractObjectsCore module can be used directly. Examples of now this is done can be seen in the V code for the extract_objects and extract_single_object user macros and the ReadDXF project functional and user macros.
in_objs
Array of objects that the user will select from. The input array can either be explicitly defined as an array or can be built up by making multiple connections to the in_objs port. The ExtractObjectsEg example application shows the use of both of these methods. The input objects must be derived from group, module or macro types. The input array cannot be of a primitive type.
inc_objects[]
Integer array that specifies which elements of the input array should be linked to the output array. The array contains a list of zero-based indices into the input array. Therefore a value of {0,3} means that the first and fourth elements of the input array will be included in the output array. By default no elements of the input array are selected. The ReadDXF project demonstrates one method of ensuring that all objects are selected by default.
objectnames[]
String array that specifies the names of the objects in the input array. These names are displayed in the user interface so that the user can more easily choose between the objects. By default the objects are named Object[0], Object[1] and so forth. However explicit object names can be easily specified.
out_objs
Output array containing references to the selected objects from the input array. This output is only present on the extract_objects macro.
out_obj
Output link containing a reference to the selected object from the input array. This output is only present on the extract_single_object macro.
The extract_objects and extract_single_object user macros both make use of the ExtractObjectsCore low-level module and the ExtractObjectsUI user interface. This project does not use a functional macro or a parameter block.
The ExtractObjects project includes one example application. The ExtractObjectsEg example is an adaption of the Multi_Block example that is supplied with AVS/Express. A set of data is loaded and visualized as an array of fields. extract_objects macros are used to control which fields are isosurfaced and which visualizations are displayed in the viewer.
iac_proj/ext_objs/exo_mods.v contains the V definition of the ExtractObjectsCore module.
iac_proj/ext_objs/exo_macs.v contains the V definitions of the ExtractObjectsUI user interface macro and the extract_objects and extract_single_object user macros
iac_proj/ext_objs/exo_apps.v contains the V definition of the ExtractObjectsEg example application.
The low-level ExtractObjectsMods library containing the ExtractObjectsCore module does not specify a process. By default the express process will be used.
Andrew Dodd, International AVS Centre
International AVS Centre Manchester Visualization Centre Manchester Computing University of Manchester Oxford Road Manchester United Kingdom M13 9PL