Mesh Colorization

<< Click to Display Table of Contents >>

Navigation:  XStream® HDVR® SDK > Advanced Functionality > 3D Polygon Meshes >

Mesh Colorization

Previous pageReturn to chapter overviewNext page

C++ C++ Java Java .NET .NET

Summary

 

The XStream® HDVR® SDK provides functionality to automatically colorize the polygonal objects represented in the IVertexCallListContext or hdrcVertexCallListContext methods sourcing the same colorization profile that is used to render the current dataset. This process is based on the current transfer function of the rendering engine, dynamically obtained at runtime. This colorization method can be used to apply color to a mesh representation of the volumetric data, a dynamically constructed mesh, or a mesh loaded from a model file. Colorization involves applying a color value to the vertex that overlaps a given voxel. Refer to the section on Mesh Construction for details about how vertex colors are stored in an IVertexCallListContext class instance.

 

Two types of colorization techniques are supported by the XStream HDVR SDK. This includes transfer function based colorization (TF), and volume rendering based colorization (VR).

 

TF based colorization applies color to a vertex by copying the transfer function color value for the voxel intersecting a given vertex. This colorization method is fast, and runs in real time. This colorization method is less accurate than the VR colorization method because it does not take into account the accumulation of color that occurs during a ray casting calculation. TF colorization is recommended when execution speed is more important than color accuracy.

 

TF colorization is recommended when execution speed is more important than color accuracy.

 

VR based colorization applies a color to a vertex by performing a ray cast calculation. A ray is cast at the voxel intersecting each vertex to be colored, and parallel to the normal produced from the local gradient of the volume data. VR colorization is more accurate than TF colorization because it is based on a ray cast rendering operation and produces smooth normal gradients for each vertex. However, the VR colorization method is slower than TF colorization because it requires a ray cast render operation for each vertex. VR colorization is recommended when color accuracy is more important than execution speed.

 

VR colorization is recommended when color accuracy is more important than execution speed.

 

The first step in producing a colorized mesh is to either construct or extract a mesh from the volume dataset. Refer to the sections on Mesh Construction and Volume Extraction for more information on producing a mesh.

 

Refer to 3D file formats for more information on mesh file types. When saving colorized data, PLY is the recommended file format, since STL and OBJ files do not support vertex colors.

 

Mesh-Colorization

 

Transfer Function (TF) and Volume Rendering (VR) Colorization

 

Colorization is applied using the IVertexCallListContext::ColorizeFromVolumeData() method. This method will block while the colorization calculations are processed. This method takes three input parameters: the IRenderEngineContext is the class instance for the render engine that performs the colorization process, a floating point value, and a boolean. The floating point value determines the offset distance from the vertex position from which the ray is cast for the render operation. This value is in dataset units, typically millimeters. The final parameter determines if TF or VR colorization is to be applied. Set this value to true for VR colorization, or false for TF colorization.

 

// If VR colorization is desired, set the final parameter to true, if TF colorization is desired, set to false.

pVertexCallList->ColorizeFromVolumeData(pRenderEngineContext, 100, true);

 

// Do a render pass to view the colorized data.

pRenderEngineContext->Render(&renderSettings, &renderResult);

 

Colorization is applied using the hdrcVertexCallListContext.colorizeFromVolumeData() method. This method will block while the colorization calculations are processed. This method takes three input parameters: the IRenderEngineContext is the class instance for the render engine that performs the colorization process, a floating point value, and a boolean. The floating point value determines the offset distance from the vertex position from which the ray is cast for the render operation. This value is in dataset units, typically millimeters. The final parameter determines if TF or VR colorization is to be applied. Set this value to true for VR colorization, or false for TF colorization.

 

// If VR colorization is desired, set the final parameter to true, if TF colorization is desired, set to false.

vertexCallList.colorizeFromVolumeData(renderEngineContext, 100, true);

 

// Do a render pass to view the colorized data.

renderEngineContext.render(renderSettings, renderResult);