Help with saving 3D horizons

24 views
Skip to first unread message

wayne.mogg

unread,
Mar 31, 2019, 3:50:02 PM3/31/19
to OpendTect Developers
Hi,
I'm trying to make a plugin to grid Z values for an horizon defined by a combination of 2D and 3D seismic interpretation. I am able to create the interpolated horizon in memory but large swaths disappear when the horizon is saved to disk. The code I've got is shown below. If I display the generated horizon as per the last few lines I see the full horizon, left image (I presume this is being displayed from the application memory), however when I subsequently load the horizon from disk using the tree context menu the horizon is incomplete, right image. I'm thinking the problem may be due to the presence of undefined values around the edges of the horizon and how they are handled during the save process. I've tried to use the debugger to follow what is happening but it is very difficult due to the save being wrapped up inside a task. All suggestions appreciated, in particular is there a way to save the horizon to disk using just a direct method call which would be easier to observe in the debugger. I haven't found one from scouring the OpendTect source.

Thanks,
Wayne Mogg

bitmap.png



bool uiGrid2D3DHorizonMainWin::acceptOK( CallBacker*)
{
    IOPar par;
    inputgrp_->fillPar( par );
    gridgrp_->fillPar( par );
   
    FixedString method = par.find( wmGridder2D::sKeyMethod() );
    PtrMan<wmGridder2D> interpolator = wmGridder2D::create( method );
    if ( interpolator==nullptr ) {
        ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - selected interpolation method not found.");
        return false;
    }
    if (!interpolator->usePar(par)) {
        ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - error in interpolation parameters.");
        return false;
    }
   
    EM::IOObjInfo eminfo( outfld_->selIOObj()->key() );
    if (eminfo.isOK()) {
        uiString msg = tr("Horizon: %1\nalready exists."
                      "\nDo you wish to overwrite it?").arg(eminfo.name());
        if ( !uiMSG().askOverwrite(msg) )
            return false;
    }
   
    {
        uiTaskRunner uitr(this);
        if (!interpolator->prepareForGridding())
            return false;
        if (!TaskRunner::execute(&uitr, *interpolator)) {
            ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - error during gridding");
            return false;
        }
    }

    RefMan<EM::Horizon3D> hor3d = EM::Horizon3D::createWithConstZ(0.0, interpolator->getTrcKeySampling());
    if (!hor3d) {
        ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - creation of output horizon failed");
        return false;
    }
    if (!interpolator->saveGridTo(hor3d)) {
        ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - error converting grid to horizon");
        return false;
    }
   
    {
        uiTaskRunner uitr(this);
        hor3d->setMultiID(outfld_->selIOObj()->key());
        PtrMan<Executor> saver = hor3d->saver();
        if (!saver || !TaskRunner::execute(&uitr, *saver)) {
            ErrMsg("uiGrid2D3DHorizonMainWin::acceptOK - saving output horizon failed");
            return false;
        }
    }
    if (saveButtonChecked()) {
        ODMainWin()->sceneMgr().addEMItem(EM::EMM().getObjectID(hor3d->multiID()));
        ODMainWin()->sceneMgr().updateTrees();
    }
    return true;
}


wayne.mogg

unread,
Apr 2, 2019, 2:59:49 AM4/2/19
to OpendTect Developers
 I tracked this issue down to the presence of NaNs in the output horizon. Once those are removed the horizon is saves OK.

Wayne Mogg
Reply all
Reply to author
Forward
0 new messages