Summary
The XStream® HDVR® SDK provides functionality to convert all or a portion of a dataset to a polygon mesh. If only a portion of the dataset is needed, an optional segmentation step can be performed. The extracted polygonal data is then created based on data in one or more of the transfer functions.
In the C++ API, an IVertexCallListContext class holds the mesh geometry. Once an IVertexCallListContext object is created, the IPolygonUtilContext::ExtractPolygons() method is called to generate the requested geometry from the volumetric data. This method takes three input parameters and returns the mesh data in a single output parameter. The input parameters are IVolumeDataContext and IOctreeContext objects representing the volume dataset used for the extraction process, and a POLYGON_EXTRACT_PARAMS object containing configuration data that controls how the volume data is converted, which includes the type of gradient, threshold value, type of extraction algorithm, and a mask that specifies which transfer functions should be included. Once the volume data is converted to a polygon mesh, it is returned as an IVertexCallListContext object output parameter.
// Create an IVertexCallListContext object
IVertexCallListContext *pVertexCallList;
pServerContext->CreateVertexCallList(&pVertexCallList);
// Set paramters for the POLYGON_EXTRACT_PARAMS structure.
POLYGON_EXTRACT_PARAMS polyExtractParams;
BCOM_ZEROMEMORY(polyExtractParams);
polyExtractParams.ComputeGradients = true;
polyExtractParams.IsUpperLimit = true;
polyExtractParams.Threshold = 1000;
polyExtractParams.TFMask[0] = 0x03; // Transfer functions 1 through 4 are active
polyExtractParams.Type = PET_MARCHING_CUBES;
// Create an IPolygonUtilContext object
IPolygonUtilContext *pPolygonUtil;
pServerContext->CreatePolygonUtil(&pPolygonUtil);
// Extract mesh geometry
pPolygonUtil->ExtractPolygons(pVertexCallList, &polyExtractParams, pVolumeDataContext, pOctreeContext);
In the Java/.NET API, a hdrcVertexCallListContext class holds the mesh geometry. Once an hdrcVertexCallListContext object is created, the hdrcPolygonUtilContext.extractPolygons() method is called to generate the requested geometry from the volumetric data. This method takes three input parameters and returns the mesh data in a single output parameter. The input parameters are hdrcVolumeDataContext and hdrcOctreeContext objects representing the volume dataset used for the extraction process, and a POLYGON_EXTRACT_PARAMS object containing configuration data to control how the volume data is converted, which includes the type of gradient, threshold value, type of extraction algorithm, and a mask that specifies which transfer functions should be included. Once the volume data is converted to a polygon mesh, it is returned as an hdrcVertexCallListContext object output parameter. All meshes extracted using this method are guaranteed to be watertight (manifold). This improves compatibility with 3D printers.
// Create an hdrcVertexCallListContext object
hdrcVertexCallListContext vertexCallList;
vertexCallList = serverContext->createVertexCallList();
// Set paramters for the POLYGON_EXTRACT_PARAMS structure.
POLYGON_EXTRACT_PARAMS polyExtractParams = new POLYGON_EXTRACT_PARAMS();
polyExtractParams.ComputeGradients = true;
polyExtractParams.IsUpperLimit = true;
polyExtractParams.Threshold = 1000;
polyExtractParams.TFMask[0] = 0x03; // Transfer functions 1 through 4 are active
polyExtractParams.Type = hdrcDefines.PET_MARCHING_CUBES;
// Create an IPolygonUtilContext object
hdrcPolygonUtilContext polygonUtil
polygonUtil = serverContext.createPolygonUtil();
// Extract mesh geometry
polygonUtil.extractPolygons(vertexCallList, polyExtractParams, volumeDataContext, octreeContext);
The .NET example code is below:
// Create an hdrcVertexCallListContext object
hdrcVertexCallListContext vertexCallList;
vertexCallList = serverContext->createVertexCallList();
// Set paramters for the POLYGON_EXTRACT_PARAMS structure.
POLYGON_EXTRACT_PARAMS polyExtractParams = new POLYGON_EXTRACT_PARAMS();
polyExtractParams.ComputeGradients = true;
polyExtractParams.IsUpperLimit = true;
polyExtractParams.Threshold = 1000;
polyExtractParams.TFMask[0] = 0x03; // Transfer functions 1 through 4 are active
polyExtractParams.Type = hdrcDefines.__Fields.PET_MARCHING_CUBES;
// Create an IPolygonUtilContext object
hdrcPolygonUtilContext polygonUtil
polygonUtil = serverContext.createPolygonUtil();
// Extract mesh geometry
polygonUtil.extractPolygons(vertexCallList, polyExtractParams, volumeDataContext, octreeContext);