The function pointed to by Fct_Metrics_Get_Pos() transform the 2D coordinate of a point in the plane of the images associated with the class in a 3D coordinate position.
If your class modify the image's resolution (such as the ROI class), then you need to have your own function hooked to the callback.
Syntax
Vect (*Fct_Metrics_Get_Pos)(
SliceO_Class *pt,
void *ima,
Vect pos_2D
)
Parameters
pt
Pointer to the class calling the function.
ima
Pointer to a Tomo_Image structure, as defined in the SliceO_File class.
pos_2D
position of a point in the 2D image plane.
Return value
This function return the 3D coordinates of a point in the image plane.
Remarks
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
Default callback for all classes except "Root"
|
// ----------------------------------------------------------------------------
//
// Class_Class_Metrics_Get_Pos
//
// Get the 3D coord of a point in the image plane
//
// We did until we reach "Root".
// The root callback will return the actual values.
//
// ----------------------------------------------------------------------------
Vect Class_Class_Metrics_Get_Pos( SliceO_Class *pt, void *ima, Vect pos )
{
// --- Apply the current transformation to the pixel's coord ---
if ( ! pt->m_ident )
pos *= pt->m_new2old ;
// --- if a parent function exist, use it! ---
SliceO_Class *parent = pt->Parent_Get_Pt() ;
return( parent->Fct_Metrics_Get_Pos( parent, ima, pos ) ) ;
}
|
|
Default callback for "Root" class
|
// ----------------------------------------------------------------------------
//
// Class_Class_Metrics_Get_Pos
//
// Get the 3D coord of a point in the image plane
//
// ----------------------------------------------------------------------------
Vect Class_Root_Metrics_Get_Pos( SliceO_Class *pt, void *pt_ima, Vect pos )
{
Tomo_Image *ima = (Tomo_Image *) pt_ima ;
Vect org ;
// --- m_org: adjust frame origin ---
if ( ima->g1.org_vect ) {
int slice = (int) pos.t * ima->z + (int) pos.z ;
org = ima->g1.org_vect[slice] ;
} else {
org = ima->g1.org + ((pos.z * ima->g1.inc.z) * ima->g1.dir_d) ;
}
org += (pos.x * ima->g1.inc.x) * ima->g1.dir_h
+ (pos.y * ima->g1.inc.y) * ima->g1.dir_v ;
return( org ) ;
}
|
|
See also