Selection Operation - Overview¶
Selection Operations allow mesh operation edits to be limited to specific points, edges and polygons. Before a procedural edit is performed, the selection operation is evaluated for each element on the mesh, and the result is stored in a mark mode on the mesh that can be evaluated by the mesh operation. The Selection Operation evaluation is multi-threaded, and can use any rules they want to determine if a specific element should be modified by the procedural edit.
1 2 3 4
LXxMETHOD( LxResult, SetMesh) ( LXtObjectID self, LXtObjectID mesh);
Before the selection operation is evaluated per element, this function is called to inform the selection operation which mesh that is currently being evaluated. The selection operation can cache this COM interface for easy access to the mesh during evaluation.
1 2 3 4
LXxMETHOD( LxResult, SetTransform) ( LXtObjectID self, LXtMatrix4 xfrm);
Elements on the mesh being evaluated will be in local space, however, for selection operations that read element positions, it may be more convenient for the positions to be in world space. This function is called before the selection operation is evaluated, providing the selection operation with the transform of the mesh that is being evaluated. The transform matrix should be cached, so it can be used to transform element positions into world space.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
LXxMETHOD( LxResult, TestPoint) ( LXtObjectID self, LXtPointID point); LXxMETHOD( LxResult, TestEdge) ( LXtObjectID self, LXtEdgeID edge); LXxMETHOD( LxResult, TestPolygon) ( LXtObjectID self, LXtPolygonID polygon);
The Test functions test individual elements to see if they should be selected. The element pointer is passed in, and the function should return either LXe_TRUE or LXe_FALSE if the element is selected. The implementation of these functions must be thread safe, as meshes that contain more than 100 elements are evaluated from multiple threads.
1 2 3 4 5
LXxMETHOD( LxResult, Evaluate) ( LXtObjectID self, LXtID4 type, LXtObjectID state);
Selection Operations can be combined, allowing them to be evaluated in turn, each one modifying or adding to the previous selection. This function is called before the individual test functions are called, and It can be used to modify a previous selection in the stack, or initialize any state needed to evaluate individual elements. The function is called with the selection type that is being evaluated, as well as a ILxSelectionState object. The ILxSelectionState object allows individual elements to be tested for selection, and elements to be added or removed from the selection. If this function returns LXe_TRUE, the selection operation has finished modifying the selection, and then TestPoint, TestEdge and TestPolygon functions will not be called, whereas if the function returns LXe_FALSE, the various test functions will be called.
The selection operation item provides a selection to the procedural system. It encapsulates channels that can be evaluated to determine the current selection state. This item will be evaluated prior to a procedural edit to determine which elements should be operated on. Selection Operation items all derive from a common type. This type is extremely basic and has no transforms or position in 3D space. The default channels define enable state and the output channel to which the ILxSelectionOperationID is written.
1 2 3 4
#define LXsITYPE_SELOP "selectionoperation" #define LXsICHAN_SELOP_ENABLE "enable" #define LXsICHAN_SELOP_OBJ "selopobj"
Along with Mesh Operations and Tool Operations, Selection Operations should specify the types of selection they support. This combination of selection types on both the selection operation and the mesh operation helps determine which selection operations can be used with which mesh operations.
Supported selection types are defined using the following server tag. The server is expected to provide a comma separated list of selection types. The server should implement the Test functions for any element type they support. Any other value will be treated as supporting all selection types.
1 2 3 4 5
#define LXsPMODEL_SELECTIONTYPES "selectionoperation" #define LXsSELOP_TYPE_VERTEX "VERX" #define LXsSELOP_TYPE_EDGE "EDGE" #define LXsSELOP_TYPE_POLYGON "POLY"
Similar to the Mesh Operation and Tool Operation, the Selection Operation item can provide a creation command that will be executed to handle its creation. This allows things like dialogs to be created to ask the user for input, or to create graph connections on creation. To define a creation command, the following server tag should be added to the selection operation server or item type, the value of the tag should be the command to execute.
#define LXsPKG_MESHOP_CREATECMD "meshop.create"