[OpendTect_Developers] Data access & Seed point generation
David d'Angelo
david.d-angelo at iais.fraunhofer.de
Wed Nov 21 13:05:21 CET 2012
Hi Jaap,
during debugging of my problem, I accidentally a wrong call of
"tc2rgba_->createRGBA(image);" into the update function of the
TextureChannels class.
void TextureChannels::update( int channel, bool tc2rgba )
{
if ( !tc_ )
return;
SbImagei32 image;
const int curversion = channelinfo_[channel]->getCurrentVersion();
image.setValuePtr( SbVec3i32( channelinfo_[channel]->getSize(0),
channelinfo_[channel]->getSize(1),
channelinfo_[channel]->getSize(2) ), 1,
channelinfo_[channel]->mappeddata_[curversion] );
tc_->setChannelData( channel, image );
if ( tc2rgba && tc2rgba_ )
tc2rgba_->notifyChannelChange();
//THIS CAUSED THE ERROR (added by myself)
//calculate an rgba image of the data
tc2rgba_->createRGBA(image);
//some debugging code
...
}
I added a callback to OpendTect, which triggers when any
PlaneDataDisplay is updating its data.
mCBCapsuleUnpack(const visSurvey::PlaneDataDisplay&,pd,cb);
I would prefer not to change OpendTect, but to implement everything into
a plugin. Is there a way to get a notification when any SceneObject is
changed?
Cheers,
David
On 11/21/12 11:28 AM, Jaap Glas wrote:
> Dear David,
>
>
> In my previous reply I accidently wrote one erroneous line of code:
>
> >> pd->getChannels()->getChannels()->createRGBA( img );
>
> which, as you already discovered yourself, should have been:
>
> pd.getChannels()->getChannels2RGBA()->createRGBA( img );
>
>
> ================================================================
>
>
> But let's now look at your current problem:
>
> > mCBCapsuleUnpack(const visSurvey::PlaneDataDisplay&,pd,cb);
> > SbImagei32 img;
> > SbVec3i32 size;
> > int bytesPerPixel;
> > pd.getChannels()->getChannels2RGBA()->createRGBA( img );
> > unsigned char* data = img.getValue(size,bytesPerPixel);
> > int width = size[0];
> > int height = size[1];
> > int depth = size[2];
> >
> > std::cout << "image size: " << size[0] << " "<< size[1] << size[2]
> << std::endl;
> > std::cout << "bytes per pixel: " << bytesPerPixel << std::endl;
> >
> > Output:
> > PIX Image size: 360 1167
> > PIX bytesPerPixel: 1
> >
> > The strange thing is that bytesPerPixel is always 1. I assumed I
> would get 4 for
> > the RGBA image. It is also strange that I always get the same pixel
> size
> > regardless of the displayed size of the line (in my case I tried it
> with a
> > crossline). See the two attached screenshots.
>
> > Could you think of a reason for this?
>
> So far, unfortunately not. I did a test by adding your piece of code
> (below)
> to OpendTect and call it every time a visSurvey::PlaneDataDisplay is
> updated:
>
> > SbImagei32 img;
> > SbVec3i32 size;
> > int bytesPerPixel;
> > pd.getChannels()->getChannels2RGBA()->createRGBA( img );
> > unsigned char* data = img.getValue(size,bytesPerPixel);
> > int width = size[0];
> > int height = size[1];
> > int depth = size[2];
> >
> > std::cout << "image size: " << size[0] << " "<< size[1] << size[2]
> << std::endl;
> > std::cout << "bytes per pixel: " << bytesPerPixel << std::endl;
>
> If I add an inline or crossline to the scene, or use their tabs to
> resize,
> I always get returned 4 bytes per pixel and what look like to be the
> correct dimensions. So it does not seem to be a bug in OpendTect.
>
> The only line I did not use is:
>
> > mCBCapsuleUnpack(const visSurvey::PlaneDataDisplay&,pd,cb);
>
> Are you sure you receive the correct plane over there?
>
> Otherwise we may start thinking about differences in the
> OpendTect versions we use. Which version are you using?
>
>
> Best regards,
>
> Jaap Glas
>
--
David d'Angelo, M. Sc.
Adaptive Reflective Teams
Fraunhofer IAIS
Schloss Birlinghoven
53754 Sankt Augustin
Germany
Fon: +49 (0) 2241 14 3444
Fax: +49 (0) 2241 14 2040
More information about the Developers
mailing list