|
// ---------------------------------------------------------------------------
//
// Update_B()
//
// Update one element or the complete structure (if flag is > 0)
//
// param: flag (unsigned int) Update flag
//
// return: (void)
//
// Note: the variable update_nb and update_pt are created in the Pixel_Set_TAG
// callback. It keep track of all the pixels that have been modified.
//
// ----------------------------------------------------------------------------
int SliceO_Ortho::Update_B( UInt64 flag_update )
{
// --- we are only interested in classes whose TAGs have been modified ---
if ( ! update_nb )
return( 1 ) ;
if ( flag_update & UPDATE_DISPLAY_TAG ) {
// --- which of the 3 directions is this one ? ---
unsigned int class_id = this->Class_Id_Get() ;
unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;
// --- For all the directions of the MPR ---
for ( int i=0; i < 3; i++ ) {
// --- We do not need to "update" the original direction, it has already
// been done by sliceO ---
if ( dir != i ) {
// --- compute the region in this direction ---
SliceO_Ortho *ortho_i = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(i) ;
if ( ortho_i->Child_Get_Nb() ) {
// --- we can have more than 1 image modified per class ---
for ( int k=0; k < this->update_nb; k++ )
ortho_i->Update_Child_A( flag_update, NULL, this->update_pt[k].ima, &(this->update_pt[k].region) ) ;
}
}
}
// --- clear the region (this prevent an infinite loop) ---
FREE( update_pt ) ;
update_nb = 0 ;
}
return( 1 ) ;
}
// ---------------------------------------------------------------------------
//
// Update_Child_A()
//
// param: flag (UInt64) Update flag
// window (SliceO_Window *) Window (NULL for all)
// ima (void *) Image (NULL for all)
// region (Region_2D *) Region to update
//
// return: (void)
//
// ----------------------------------------------------------------------------
void SliceO_Ortho::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )
{
// --- which of the 3 directions is this one ? ---
unsigned int class_id = this->Class_Id_Get() ;
// --- we have reserved 3 IDs for the Ortho class, one for each direction ---
unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;
// --- original direction, nothing special ---
if ( this->m_ident ) {
// --- propagate to all chidrens ---
for ( int i=0; i < this->Child_Get_Nb(); i++ )
Child_Get_Pt(i)->Update_Child_A( flag, window, ima, region ) ;
return ;
}
// --- for the other directions, I have to transform the region.
SliceO_Ortho *ortho_0 = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(0) ;
// --- match from "ima" to slice number ---
// I need the slice number for the "z" value in the region.
int min_slice=100000, max_slice=-100000 ;
if ( ima ) {
for ( int j=0; j < ortho_0->real_files_nb; j++ ) {
if ( ortho_0->real_files_pt[j]->m_bunch_head[ortho_0->real_files_bunch[j]] != ima )
continue ;
if ( (ortho_0->real_files_z[j] < region->min_z) || (ortho_0->real_files_z[j] > region->max_z))
continue ;
if ( (ortho_0->real_files_t[j] < region->min_t) || (ortho_0->real_files_t[j] > region->max_t))
continue ;
min_slice = MIN( min_slice, j ) ;
max_slice = MAX( max_slice, j ) ;
}
} else {
min_slice = 0 ;
max_slice = ortho_0->real_files_nb ;
}
if ( max_slice < min_slice )
return ;
Region_4D reg_new(*region) ;
reg_new.min_z = (float) min_slice ;
reg_new.max_z = (float) max_slice ;
reg_new *= this->m_old2new ;
// --- propagate to all children ---
for ( int i=0; i < this->Child_Get_Nb(); i++ )
Child_Get_Pt(i)->Update_Child_A( flag, window, (void *) this->ortho_tomo_pt, ®_new ) ;
}
|