Table of Contents
The grail.mstype module was designed to improve the handling of large point and face data throughout the MSGRAIL system. In general, the mstype module should just work without you having to do much to make it work.
In general, the mstypes will work in all cases, except for a single Known Issue. It is recommended that all new scripts enable mstypes. To allow for backward compatibility concerns, the mstypes are disabled by default.
To enable mstypes you must insert the following line into your script,
import grail.mstype_enable
this convenience module will automatically rewire the underlying mechanics with point and face data within MSGRAIL and MineSight(r) to use mstypes.
This module also provides a set of Functions that allow you to transform your data from the new mstypes to the older format, and vicea versa.
Prior to v4.00 of MSGRAIL all point data (and face data) were transformed from their efficient underlying binary structure to a less efficient Python structure. This lead to unnecessary performance penalities if you were passing point data from one MSGRAIL function to another. For example, the following call will result in too many unneccessary conversion,
points = el.get_pointlist() # (1) Binary -> Python
itIs = ag.ispointlistaline(points) # (2) Python -> Binary
In line 1, we would convert binary data to a python point list, followed by a reconversion back to the original binary data in line 2.
The purpose of mstypes is to remove the reconversion process. If mstypes are enabled, you will end up passing a reference to the underlying binary data, and the binary data will only be convert at the moment you need a python list. Even then, the conversion will only occur if you decide to do something with the mstype that doesn't make sense (for example, attempting to insert a string into a point list).
In essesence we are delaying the conversion from binary data to a python list to the very last moment.
For convenience, we provide a module that you can import to automatically enable mstypes in your script. If you do the following,
you will automatically enable mstypes. The above call effectively does the following,
Note
If you are using the convenience import grail.mstype_enable idiom, mixing the following calls in your script should be done carefully.
This will perform a YZSwap on the points in obj. It will return a new copy of obj with all its coordinates swapped. If you do not want to duplicate memory you should perfer to use the nPointList_YZSwap described below.
An example of using this routine is,
as you can see, the original point is not modified.
Occasionally you will stumble across a routine that needs to swap coordinates from XYZ (cartesian coordinate space) to XZY (graphical coordinate space), this routine will efficiently swap the Y and Z coordinates.
The change will modify the contents of obj. For example,
and if we re-run the routine we will get back our original point list.
If the obj is not a valid pointlist a TypeError exception will be generated.
See also Efficiently Swapping Y and Z Coordinates in the HowTo.
Performs a YZSwap of obj, but returns a new point without modifiying the original. If you want to efficiently modify the contents in place use nPoint_YZSwap.
An example of using this routine is,
Occasionally you will stumble across a routine that needs to swap coordinates from XYZ (cartesian coordinate space) to XZY (graphical coordinate space), this routine will efficiently swap the Y and Z coordinates.
The change will modify the contents of obj. For example,
If the obj is not a valid point a TypeError exception will be generated.
See also Efficiently Swapping Y and Z Coordinates in the HowTo.
If you do the following when mstypes are enabled,
it will not be equal to a python types.ListType. Some old scripts used the following test,
to ensure that they are getting valid data.
It is recommended that you replace the above test with,
which will confirm that aPointList is in fact a pointlist, even if it is a mstype.
The same issues apply to a point and facelist, where it is recommended that you use the Point_Check and FaceList_Check respectively.