(TIP) Make a map-style Relief Map of your data from any angle

Started by prehistory, February 02, 2009, 02:39:38 PM

Previous topic - Next topic

prehistory

Ever want to create an elevation map, or "relief map" of scan data?  This is a common tool used in mapping and survey software and is easy to do by comparing the scan data to a minimum plane.  However, if the data is not "Z-up" by default, how can we easily make the relief map?

I wrote a small macro that will analyze the current view direction and make a relief map based on that.  For a relief map where X is up, orient the 3D Scene to +X and run the macro.  For a custom orientation, simply rotate the object as desired and run the macro.  You can get nice results in a second.  See macro below.

V 10.1

---------------------------------------
version "4.0"

DECLARE nb_selected
DECLARE dataname
DECLARE pt_Array
DECLARE Zi
DECLARE Zj
DECLARE Zk
DECLARE radius

WINDOW REFRESH ("Off")
FEATURE OPTIONS FEATURE_BASED_INSPECTION ( "Off" )

# Get data object

TREEVIEW DATA GET_NB_SELECTED (nb_selected)

IF $nb_selected == 0
    MACRO PAUSE ("Error", "You must select your data object")
    MACRO END
    ENDIF

TREEVIEW DATA PROPERTIES NAME GET (dataname)

# clean up
TREEVIEW SELECT NONE
TREEVIEW SELECT FROM_NAME_PATTERN ("max*", "On")
TREEVIEW SELECT FROM_NAME_PATTERN ("relief*", "On")
TREEVIEW SELECT FROM_NAME_PATTERN ("center*", "On")
EDIT OBJECT DELETE ()



# get viewer pose vector (7,1 7,2 7,3)

VIEW POSE SAVE ( "$_PWK_FILES_PATH\user-data\pose" )
DATA_FILE READ LINE_FIELD ("$_PWK_FILES_PATH\user-data\pose", 7, 1, Zi)
DATA_FILE READ LINE_FIELD ("$_PWK_FILES_PATH\user-data\pose", 7, 2, Zj)
DATA_FILE READ LINE_FIELD ("$_PWK_FILES_PATH\user-data\pose", 7, 3, Zk)

ECHO ("Vector is $Zi $Zj $Zk")


# create point at center of object

TREEVIEW OBJECT_ELEMENTS SELECT ALL ( "$dataname" )
FEATURE PRIMITIVE POINT FROM_SELECTED_ELEMENTS_AVERAGE ( "Measured", ,"center" )
FEATURE PRIMITIVE POINT GET_POINT_COORDINATES (pt_Array)
ECHO ("$pt_Array[1], $pt_Array[2], $pt_Array[3]")

# create plane at  origin and facing viewer

FEATURE PRIMITIVE PLANE CREATE FROM_POINT_AND_NORMAL ( $pt_Array[1], $pt_Array[2], $pt_Array[3], \
                                                       $Zi,$Zj,$Zk,"Measured",,"relief" )

TREEVIEW SELECT NONE


# create max circle to get bounding box

#TREEVIEW OBJECT_ELEMENTS SELECT ALL ( "$dataname" )
#FEATURE PRIMITIVE CIRCLE FIT_OPTIONS TYPE ( "Max" )
#FEATURE PRIMITIVE CIRCLE FIT_SELECTED_ELEMENTS ( "Measured", ,"max", ,  )
#TREEVIEW PRIMITIVE CIRCLE PROPERTIES RADIUS GET (radius, "max")
#TREEVIEW SELECT NONE

# or ask user for max elevation

INPUT DOUBLE (radius, "Maximum Value", "Please enter the maximum elevation", 50)

# make big plane, and move it behind the object
FEATURE PRIMITIVE GROW_AND_SHRINK ( $radius,"relief" )
FEATURE PRIMITIVE TRANSLATE_ALONG_AXIS ( EXPR($radius - ($radius * 1.5)),"relief")

# compare data to relief plane, with max distance of circle radius

VIEW VISIBILITY OBJECTS KEEP ("$dataname" )

COMPARE VIEWING_OPTIONS COLOR_SCALE SCALE_TYPE ( "rainbow240" )
COMPARE VIEWING_OPTIONS ERROR_MAP DATA ( "On" )
COMPARE VIEWING_OPTIONS ERROR_MAP SHADED ( "On" )


COMPARE OPTIONS MAX_DISTANCE ( $radius )
COMPARE OPTIONS USE_MAX_ANGLE ( "Off" )
COMPARE DATA_TO_PRIMITIVE ALL_DATA_POINTS ("relief" )

# clean up
TREEVIEW SELECT NONE
TREEVIEW SELECT FROM_NAME_PATTERN ("max*", "On")
TREEVIEW SELECT FROM_NAME_PATTERN ("center*", "On")
EDIT OBJECT DELETE ()


WINDOW REFRESH ("On")
WINDOW REFRESH NOW


FEATURE OPTIONS FEATURE_BASED_INSPECTION ( "Off" )

PW User

Hello,

A new feature in V11 may be of interest: the "Enchanced coloring" option, when applied, will add a new method for creating polylines.

You can then created polylines at the changes of color in your colormap. If you have selected your colormaps cleverly, you can have level lines (called "lignes de niveau" in french... english?) extracted.

Regards,
Bernard

prehistory

Hello Bernard,

The English translation is "topo lines" or "contour lines",

Cheers!