Hello,
I've been reading and looking for resources on this for a little while, and I hope someone can enlighten me.
I have an ObjectARX application where I consult a TIN surface for elevation samples. I need several thousand point's elevations in a straight line.
I have the surface declared as
CComQIPtr<IAeccTinSurface> mTINSurface;
And given coordinates (x,y) I can easily and successfully find the elevation using
//x and y are given double values double z; HRESULT result = mTINSurface->FindElevationAtXY(x, y, &z);
//+error treatment
This, however, takes a lot of time when I have to do it thousands of times inside a for-loop varying the x-coordinate. Reading the documentation on IAeccSurface I found the SAmpleElevation method (sorry I don't paste the link here, it's pointing to 'invalid HTML' and forbidding me to post). In the hopes of improving performance, this is what I tried:
SAFEARRAY* safearray; SAFEARRAYBOUND bound; bound.lLbound = 0; //zero-based bound.cElements = number_elements; //does this define the number of samples? safearray = SafeArrayCreate(VT_I8, 1, &bound); //zero based, safe array of X,Y,Z doubles
CComVariant variant(safearray); variant.vt = VT_ARRAY | VT_I8; //type: safe array of double HRESULT result = mTINSurface->SampleElevations(x,y,n_x,y,&variant); //sample in line
Forgive me for my lack of experience, but this is what I took from the description given by the documention; that the last parameter should be a "VARIANT containing a zero based, one dimensional safe array of X, Y, Z values. ". My problem is that 'result' is always E_FAIL - and I'm not sure why - and 'safearray' is filled with zeroes.
I have the following questions:
Anyway, any help would be much appreciated. Thanks in advance,
MSchmidt
You should keep your customization queries in the C3D Customization group. Most folks in the base C3D group won't know what to do with this. Welcome to the forums!
Oh, thanks, sorry!
Could someone please delete this?
I'll do some more testing, refine my questioning and post there when I'm done.
Thanks anyway and sorry again
MS
As for the method you wish to use, the documentation is not very clear, but the out parameter is not passed, instead is is given as the result, so I think your line should look like so:
HRESULT result = mTINSurface->SampleElevations(x,y,n_x,y)But I don't use c++ so this is likely not exactly correct, hopefully you get the idea.