[OpendTect_Developers] How to work with OpendTect horizons (part 2, display and writing)
Nanne Hemstra
nanne.hemstra at dgbes.com
Mon Mar 21 08:35:42 CET 2011
Hi All,
In my previous post I described how to read OpendTect horizons (
http://lists.opendtect.org/pipermail/developers/2010-September/000202.html).
Now
I'll continue and explain how horizons can be displayed in the 3D scene and
written to disk.
I start with the assumption that you have the horizon geometry available in
one way or the other. Next step is to feed this geometry into an
EM::Horizon3D object. I can use the EMManager, the manager of all EarthModel
(EM) objects, to create this object:
<code>
EM::ObjectID emid = EM::EMM().createObject( EM::Horizon3D::typeStr(),
horizonname );
mDynamicCastGet(EM::Horizon3D*,horizon3d,EM::EMM().getObject(emid));
if ( !horizon3d ) return; // Cannot create horizon
</code>
Each EM object has this typeStr() function, so any EM object can be created
this way.
To fill the still empty horizon with Z values, we need the section id, the
BinID (inline and crossline position), and of course the z value. In code
this would become:
<code>
MyGeom mygeom; // Your object which contains the horizon geometry
EM::SectionID sid = horizon3d->sectionID( 0 );
for ( int idx=0; idx<mygeom.nrPositions(); idx++ )
{
BinID bid = mygeom.getPosition( idx );
EM::SubID subid = bid.toInt64();
float z = mygeom.getZ( idx );
horizon3d->setPos( bid, sid, subid, Coord3(0,0,z), false );
}
</code>
Note that the horizon is stored in inline/crossline space, so you don't need
to specify the X and Y coordinate in the Coord3 object. The last boolean
argument in setPos, is to specify whether you want to add this action to the
history and thus enable an undo.
When all positions have been set, you can save the horizon to disk by:
<code>
PtrMan<Executor> saver = horizon3d->saver();
if ( !saver || !saver->execute() )
return; // oops, cannot save this horizon
</code>
If you want to display the new horizon automatically in the 3D scene, you
can simply ask OpendTect's scene manager
($WORK/include/uiODMain/uiodscenemgr.h). The addEMItem function will add a
new tree item to the OpendTect tree and the treeitem will make sure the
visual horizon object is added to the scene.
<code>
ODMainWin()->sceneMgr().addEMItem( emid );
</code>
Best regards,
Nanne Hemstra
--
Nanne Hemstra
OpendTect developer
dGB Earth Sciences
304, Gateway Plaza
Hiranandani Gardens, Powai
Mumbai - 400 076, India
Phone: +91 22 25704984 , Fax: +91 22 25704977
Mobile: +91 9833452542
http://www.dgbes.com , http://www.opendtect.org
Join us on facebook<http://www.facebook.com/pages/OpendTect/116868268369067>
!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20110321/62777caa/attachment.html>
More information about the Developers
mailing list