CmUtils::ViewNormal

Sets the view of a named window normal to a plane defined by 4 nodes in an .exnode file.

VERSION

1.03 (17 December 2003) =head1 CHANGES

1.03

Added updateViewNormal which uses the Cmiss direct interface modules to interrogate the scene viewer and try and maintain a consistent interest point when changing slices. The routine compiles conditionally so that this Digitise module will still compile and fall back to the old behaviour if the function does not initialise.

1.02

Added computeNormal to compute normals from a exnode file without changing windows - in essence prefilling the cache. This node file may contain multiple node groups, and each one is computed.

1.01

Added caching of nodal information in a hash %info.

VARIABLES

$CmUtils::ViewNormal::Scale
Scaling for viewing image. By default, Scale is 100.
$CmUtils::ViewNormal::ViewRange
Range for near and far clipping planes. By default, ViewRange is 10.

viewNormal(filename [,window] [,scale] [,viewrange])

By default, the window to set is "Window 1". For example

  use CmUtils::ViewNormal;
  viewNormal("axial10");

sets window 1 so that axial10.exnode (which may have axial10.rgb drawn in it) is normal to the view. Used so far to give a view normal to echo images.

The Scale and ViewRange can also be overridden for this call only. Neither can be zero;

updateViewNormal(filename [,window] [,scale] [,viewrange])

By default, the window to set is "Window 1". For example

  use CmUtils::ViewNormal;
  updateViewNormal("axial10");

sets window 1 so that axial10.exnode (which may have axial10.rgb drawn in it) is normal to the view. Used so far to give a view normal to echo images.

The Scale and ViewRange can also be overridden for this call only. Neither can be zero;

This version is a replacement for viewNormal which maintains the same viewing range when you change planes and ensures that the centre of the new view is the intersection of the previous viewing direction and this plane.

computeNormal(filename)

Reads node file filename and computes and stores normals for all node groups in the file.

  use CmUtils::ViewNormal qw(computeNormal);
  computeNormal("file.exnode");

Other routines

The above routines call the following (unexported) routines.

checkNodes(group)

Checks that nodal information in a group is valid, and puts the nodal coordinates into the array as vectors. Requires a single fieldset, with 4 nodes of 3 coordinates each.

calculateNormal(nodelist)

Calculates the normal to the plane by taking the cross-product of two vectors in the plane. Returns a normal vector as a CmUtils::Vector.

  $normal = calculateNormal(@nodes);

calculateCentre(nodelist)

Calculates the centre of the nodes.

  $centre = calculateCentre(@nodes);

calculateUp(nodelist)

Calculates the up-vector of the image (node 3 - node 1).

  $up = calculateUp(@nodes);

rotateView(window, info, scale, viewrange)

Rotates the view to align with a vector, centred on a point, with a given up-vector.

  rotateView(1, $info);

rotates window 1 so that the interest point is $info->{centre}, and the view direction is defined by $info->{normal} and an up-vector of $info->{up}.