Measuring oriented bounding box axes with ParaView’s Bounding Ruler

June 12, 2018

Paraview’s Bounding Ruler filter has for some time been able to measure the X, Y, or Z axis of the axis-aligned bounding box of a data set. With ParaView 5.6, the Bounding Ruler filter will now be able to measure the major, medium, and minor axes of a data set’s oriented bounding box. These axes are available as new options in the Axis property of the Bounding Ruler filter.

An oriented bounding box is a rectangular prism that fits tightly around a data set. To fit tightly, the oriented bounding box may be rotated arbitrarily. Because the axes of the box do not correspond to the axes of the X, Y, and Z axes of the Cartesian coordinate system in which the data set is defined, we name the axes of the bounding box “major” (the longest side), “minor” (the shortest side) and “medium” (the side that is neither longest or shortest).

Oriented bounding box axes

These new axes can be useful in cases where you want to measure an object that is not oriented along the standard Cartesian X, Y, and Z axes. For example, set the Axis property to “Oriented Bounding Box Major Axis” to measure the length of an arbitrarily oriented cylindrical data set as demonstrated below (the red cube that the cylinder passes through is aligned with the Cartesian axes to show the orientation of the cylinder).

As another example, one can use ParaView’s selection capabilities and the Extract Selection filter to extract two points of interest. Applying the Bounding Ruler filter with the Axis property set to “Oriented Bounding Box Major Axis” to measure the distance between these points. This measurement will automatically update if the points move over time.

One caveat to these new options is that all the points in a data set need to be copied to a single rank to compute the oriented bounding box. When used with a data set distributed over ranks in a parallel pvserver, this may be slow or lead to memory exhaustion if the data set does not fit onto one rank.

Acknowledgements

The work was funded by Sandia National Laboratories. For design discussion that led to this implementation, please see the feature request here.

Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-NA0003525.

11 comments to Measuring oriented bounding box axes with ParaView’s Bounding Ruler

  1. This is brilliant. Thanks. Is there a VTK equivalent? Also, how to probe the length through something like pvpython?

    1. The filter is available in the ParaView source code under ParaViewCore/VTKExtensions/Default/vtkRulerLineForInput.h and should be usable in a VTK application.

      To see how to probe a length in pvpython, I suggest using the Python Trace functionality in ParaView (available under Tools -> Python Trace). See section 1.6.2 of the ParaView Guide for additional information on Python tracing. Doing this will show you how to set up this filter using Python.

      1. So I am struggling with this a little as tracing will only translate GUI interactions and I would like to print the value of length or points on thousands of objects. I will look at the code in VTKExtensions for inspiration. My current workaround is to SaveData and recover two points, but this is as “around” as workarounds get.

        1. Ah, yes. You can use

          import paraview.servermanager as sm
          ruler = sm.Fetch(boundingRuler)
          print(ruler.GetPoint(0))
          print(ruler.GetPoint(1))

          This fetches the data from the server side to the client (even when running in builtin server mode) and gives you access to the data via a vtkPolyData object. The object has two points, the end points of the ruler line. From that you can compute distance.

          See Section 14.10 of the ParaView Guide for more on the Fetch function.

          1. This is really awesome. The Fetch was the missing bit for me and I was actually after ruler.GetLength(). Thanks for the hint to the guide. This made my evening!

          2. Ah, that link is to an older version of the guide. I’ll update it. In the meantime, grab the latest ParaView Guide, updated for 5.6, from this link.

  2. Hi

    “One caveat to these new options is that all the points in a data set need to be copied to a single rank to compute the oriented bounding box. When used with a data set distributed over ranks in a parallel pvserver, this may be slow or lead to memory exhaustion if the data set does not fit onto one rank.”

    Do you have an example of how to do this? I’m struggling to do this in the GUI

    Matt

    1. Moving the data to one rank? Use the Aggregate Dataset filter to move all the data to one rank. Leave the Number of Target Processes property to the default value 1.

Leave a Reply