Vessel Trace

<< Click to Display Table of Contents >>

Navigation:  XStream® HDVR® SDK > Advanced Functionality >

Vessel Trace

Previous pageReturn to chapter overviewNext page

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

Summary

 

The XStream® HDVR® SDK supports a feature to automatically compute and generate a path along a vessel or other navigable channel, such as a nerve channel trace, or other path through a channel in the dataset. The path-finding feature specifies start and end points, and other path-finding operation parameters. The path-finding algorithm then sends out tracers from the start and end points that travel through the channel. If the tracers from the start and end points get within a threshold distance of each other, they will connect and a path will be established. The threshold distance and other parameters for the path-finding operation can be customized, based on the size and material type of the channel through which a path is being found.

 

CurvedMPR_Before

Path found through a curved vessel

 

Path Finding

 

The vessel trace path-finding feature is implemented with the IRenderEngineContext::FindPath() method. This method takes six parameters. The first parameter is a pointer to an empty array of VECTOR3D objects. This parameter receives an internally allocated buffer address that contains the successful path-find operation results. If the path-finding operation fails, this parameter will remain empty. The buffer should be deallocated when it is no longer needed, or a memory leak will result. The second parameter is the address of an integer that represents the number of path array elements returned in the second parameter. The third and fourth parameters are pointers to VECTOR3D objects that contain the start and end point coordinates for the path-finding operation. The fifth parameter is a pointer to a FIND_PATH_PARAMS object that contains parameters for the path-finding algorithm. Although these parameters can be manually configured, it is recommended that the default values for the FIND_PATH_PARAMS class be used. The default parameters are set to auto-calibrate the path-finding algorithm for most vessel trace operations. The values in the FIND_PATH_PARAMS object can be manually adjusted if necessary. The sixth parameter is the address of an IAllocator object used to allocate the path-finding result array returned in the second parameter.

 

The buffer containing the results of the path-finding operation should be deallocated when it is no longer needed, or a memory leak will result.

 

The IRenderEngineContext::FindPath() method is a synchronous blocking method that will not return until a path is calculated, or the FIND_PATH_PARAMS::CompletionDistance length has been exhausted and no path can be found. The vessel trace algorithm can take a number of seconds to complete, depending on the length and complexity of the path. Performing an asynchronous path finding operation will allow the application to continue while the path-finding algorithm runs.

 

// Create a render engine for use 

IRenderEngineContext *pRenderEngine; 

pServer->CreateRenderEngine(&pRenderEngine, RECID_PAR);

 

pRenderEngineContext->SetVolumeData(pVolumeData, pOctree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp;

BCOM_ZEROMEMORY(rp);

rp.Mask = RPM_RENDER_TYPE;

rp.FlagsMask = RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = RT_PERSPECTIVE;

pRenderEngineContext->SetRenderParams(&rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D *pathArray;

 

// Integer to hold the number of returned elements in the path array.

h_uint32 numPathSteps;

 

// Set start and end points for path.

VECTOR3D startPt = VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams;

 

pRenderEngineContext->FindPath(&pathArray, &numPathSteps, 

     &startPt, &endPt, &pathParams, pAlloc);

 

The vessel trace path-finding feature is implemented with the hdrcRenderEngineContext.findPath() method. This method takes three parameters. The first and second parameters are VECTOR3D objects that contain the coordinates of the start and end points for the path-finding operation. The third parameter is a FIND_PATH_PARAMS object containing parameters for the path-finding algorithm. Although these parameters can be manually configured, it is recommended that the default values for the FIND_PATH_PARAMS class be used. The default parameters are set to auto-calibrate the path-finding algorithm for most vessel trace operations. The values in the FIND_PATH_PARAMS object can be manually adjusted if necessary. If the path-finding operation successes a FIND_PATH_RESULT object will be returned, or NULL if no path is found. The FIND_PATH_RESULT object will contain a vector of VECTOR3D objects in the FIND_PATH_RESULT::path field which designates the computed path.

 

The hdrcRenderEngineContext.findPath() method is a synchronous blocking method that will not return until a path is calculated or the FIND_PATH_PARAMS.CompletionDistance length has been exhausted and no path can be found. The vessel trace algorithm can take a number of seconds to complete, depending on the length and complexity of the path. Performing an asynchronous path finding operation will allow the application to continue while the path-finding algorithm runs.

 

 

// Create a render engine for use 

hdrcRenderEngineContext renderEngine; 

renderEngine = server.createRenderEngine(hdrcDefines.RENDER_ENGINE_ID_PAR);

 

// Initialize the IRenderEngineContext object with volume and octree data.

renderEngine.setVolumeData(volumeData, octree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp = new RENDER_PARAMS();

rp.Mask = hdrcDefines.RPM_RENDER_TYPE;

rp.FlagsMask = hdrcDefines.RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = hdrcDefines.RT_PERSPECTIVE;

renderEngine.setRenderParams(rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D[] pathArray = null;

 

// Set start and end points for path.

VECTOR3D startPt = new VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = new VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams = new FIND_PATH_PARAMS();

 

FIND_PATH_RESULT result = renderEngine.FindPath(startPt, endPt, pathParams);

 

// Create a render engine for use 

hdrcRenderEngineContext renderEngine; 

renderEngine = server.createRenderEngine(hdrcDefines.__Fields.RENDER_ENGINE_ID_PAR);

 

// Initialize the IRenderEngineContext object with volume and octree data.

renderEngine.setVolumeData(volumeData, octree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp = new RENDER_PARAMS();

rp.Mask = hdrcDefines.__Fields.RPM_RENDER_TYPE;

rp.FlagsMask = hdrcDefines.__Fields.RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = hdrcDefines.__Fields.RT_PERSPECTIVE;

renderEngine.setRenderParams(rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D[] pathArray = null;

 

// Set start and end points for path.

VECTOR3D startPt = new VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = new VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams = new FIND_PATH_PARAMS();

 

FIND_PATH_RESULT result = renderEngine.FindPath(startPt, endPt, pathParams);

 

Asynchronous Path Finding

 

An asynchronous path-finding operation allows the application to continue other tasks while the server application runs the path-finding algorithm. This may be the preferred option, depending on the length and complexity of the channel trace path. Asynchronous path-finding is accomplished with the IRenderEngineContext::StartJobFindPath(), IServerContext::GetJobInfo(), and IRenderEngineContext::FinishJobFindPath() methods.

 

The IRenderEngineContext::StartJobFindPath() method begins the asynchronous path-finding process. This method takes four parameters. The first parameter is a pointer to an integer that stores the job ID associated with the path-finding process. This integer is returned as an output parameter by the IRenderEngineContext::StartJobFindPath() method. The second and third parameters are the start and end point coordinates of the path to be calculated. The final parameter is the address of a FIND_PATH_PARAMS object. See the discussion above for more information on the use of the FIND_PATH_PARAMS class.

 

The IServerContext::GetJobInfo() method returns information on the progress and status of the path-finding operation. This method takes as an input parameter the jobID value returned from the IVolumeSegmentationContext::StartJobFindPath() method, which is used to identify the asynchronous path-finding operation. The IServerContext::GetJobInfo() method returns as an output parameter a pointer to a JOBINFO structure. The JOBINFO::jobprog value stores the job progress. This value will be 0 to 100, representing a percentage of job completion, with a value of 100 indicating completion of the job. The JOBINFO::jobret value stores the return value from the path-finding operation when it has completed.

 

The IRenderEngineContext::FinishJobFindPath() method is used to finalize the path-finding operation. This method takes four parameters. The first parameter is a pointer to an empty array of VECTOR3D objects. This parameter will receive an internally allocated buffer address that contains the successful path-find operation results. If the path-finding operation fails, this parameter will remain untouched. The buffer should be deallocated when it is no longer needed, or a memory leak will result. The second parameter is the address of an integer that will get the number of elements in the path array returned in the second parameter. The third parameter is the address of an IAllocator object used to allocate the path-finding result array returned in parameter two. The final parameter is the jobID value of the asynchronous path-finding operation.

 

The buffer containing the results of the path-finding operation should be deallocated when it is no longer needed, or a memory leak will result.

 

// Create a render engine for use 

IRenderEngineContext *pRenderEngine; 

pServer->CreateRenderEngine(&pRenderEngine, RECID_PAR);

 

pRenderEngineContext->SetVolumeData(pVolumeData, pOctree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp;

BCOM_ZEROMEMORY(rp);

rp.Mask = RPM_RENDER_TYPE;

rp.FlagsMask = RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = RT_PERSPECTIVE;

pRenderEngineContext->SetRenderParams(&rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D *pathArray;

 

// Integer to hold the number of returned elements in the path array.

h_uint32 numPathSteps;

 

// Set start and end points for path.

VECTOR3D startPt = VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams;

 

// Start an asynchronous path finding operation.

h_int64 jobID;

pRenderEngineContext->StartJobFindPath(&jobID, &startPt, &endPt, &pathParams);

 

// Check the progress of the path finding operation.

JOBINFO jobInfo;

while(jobInfo.jobprog < 100) {

   // Get path finding progress

   pServerContext->GetJobInfo(jobID, &jobInfo);

 

// Finialize the path finding operation.

pRenderEngineContext->FinishJobFindPath(&pathArray, &numPathSteps, pAlloc, jobID);

 

The vessel trace algorithm can take a number of seconds to complete, depending on the length and complexity of the path. For this reason it may be desired to perform an asynchronous path-finding operation. This will allow the application to continue onto other tasks while the server application runs the path-finding algorithm. Asynchronous path-finding is accomplished with the hdrcRenderEngineContext.startJobFindPath(), hdrcServerContext.getJobInfo(), and hdrcRenderEngineContext.finishJobFindPath() methods.

 

The hdrcRenderEngineContext.startJobFindPath() method begins the asynchronous path-finding process. This method takes three parameters. The first and second parameters are the start and end point coordinates of the path to be calculated. The final parameter is the address of a FIND_PATH_PARAMS object. See the discussion above for more information on the use of the FIND_PATH_PARAMS class. The hdrcRenderEngineContext.startJobFindPath() method returns an integer used to store the job ID associated with the loading process.

 

The hdrcServerContext.getJobInfo() method returns information on the progress and status of the path-finding operation. This method takes as an input parameter the jobID value returned from the hdrcServerContext.startJobFindPath() method which is used to identify the asynchronous path-finding operation. The hdrcServerContext.getJobInfo() method returns a reference to a hdrcJobInfo structure. The hdrcJobInfo.m_prog value stores the job progress. This value will be 0 to 100, representing a percentage of job completion, with a value of 100 indicating completion of the job. The JOBINFO.m_err value stores the return value from the path-finding operation when it has completed.

 

The hdrcRenderEngineContext.finishJobFindPath() method is used to finalize the path-finding operation. This method takes as a parameter the jobID value of the asynchronous path-finding operation. If the path-finding operation successes a FIND_PATH_RESULT object will be returned, or NULL if no path is found. The FIND_PATH_RESULT object will contain a vector of VECTOR3D objects in the FIND_PATH_RESULT.path field which designates the computed path.

 

// Create a render engine for use 

hdrcRenderEngineContext renderEngine; 

renderEngine = server.createRenderEngine(hdrcDefines.RENDER_ENGINE_ID_PAR);

 

// Initialize the IRenderEngineContext object with volume and octree data.

renderEngine.setVolumeData(volumeData, octree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp = new RENDER_PARAMS();

rp.Mask = hdrcDefines.RPM_RENDER_TYPE;

rp.FlagsMask = hdrcDefines.RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = hdrcDefines.RT_PERSPECTIVE;

renderEngine.setRenderParams(rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D[] pathArray = null;

 

// Set start and end points for path.

VECTOR3D startPt = new VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = new VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams = new FIND_PATH_PARAMS();

 

// Start an asynchronous path finding operation.

long jobID = renderEngine.startJobFindPath(startPt, endPt, pathParams);

 

// Check the progress of the path finding operation.

hdrcJobInfo jobInfo;

while(jobInfo.m_prog < 100) {

   // Get path finding progress

   jobInfo = serverContext.getJobInfo(jobID);

 

// Finialize the path finding operation.

FIND_PATH_RESULT result = renderEngine.finishJobFindPath(jobID);

 

// Create a render engine for use 

hdrcRenderEngineContext renderEngine; 

renderEngine = server.createRenderEngine(hdrcDefines.__Fields.RENDER_ENGINE_ID_PAR);

 

// Initialize the IRenderEngineContext object with volume and octree data.

renderEngine.setVolumeData(volumeData, octree);

 

// Initialize render engine to perspective mode.

RENDER_PARAMS rp = new RENDER_PARAMS();

rp.Mask = hdrcDefines.__Fields.RPM_RENDER_TYPE;

rp.FlagsMask = hdrcDefines.__Fields.RF_DONT_NORMALIZE_TF;

rp.Flags = 0;

rp.RenderType = hdrcDefines.__Fields.RT_PERSPECTIVE;

renderEngine.setRenderParams(rp);

 

// Create an empty array to hold the calculated path.

VECTOR3D[] pathArray = null;

 

// Set start and end points for path.

VECTOR3D startPt = new VECTOR3D(-12.92 -17.0 31.61);

VECTOR3D endPt = new VECTOR3D(104.71 -98.0 -76.32);

 

// Create a default FIND_PATH_PARAMS object.

FIND_PATH_PARAMS pathParams = new FIND_PATH_PARAMS();

 

// Start an asynchronous path finding operation.

long jobID = segmentationContext.startJobFindPath(renderEngine, startPt, endPt, pathParams);

 

// Check the progress of the path finding operation.

hdrcJobInfo jobInfo;

while(jobInfo.m_prog < 100) {

   // Get path finding progress

   jobInfo = serverContext.getJobInfo(jobID);

 

// Finialize the path finding operation.

FIND_PATH_RESULT result = segmentationContext.finishJobFindPath(jobID);