Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SampleElevation in ObjectARX application

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
415 Views, 3 Replies

SampleElevation in ObjectARX application

Hello,

I've been reading and looking for resources on this for a little while, and I hope someone can enlighten me.Smiley Happy

 

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:

  • Am I passing the right parameters? I have little experience with VARIANT and SAFEARRAY types.
  • Does the entire SampleElevation operation fails whenever a single elevation cannot be found? (I have sections without elevation information in the surface - I'm sure the first point (x,y) DOES have a valid elevation value, though).
  • Would I really see performance gain by using SampleElevation instead of multiple FindElevationAtXY, as I assumed?
  • When calling SampleElevation, I'm not entirely sure how the sampling is considered. Does the method recognize the size of the array and divides the distance between the initial point and ending point equally, resulting in that many samples? 

Anyway, any help would be much appreciated. Thanks in advance,
MSchmidt

3 REPLIES 3
Message 2 of 4
Jeff_M
in reply to: Anonymous

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. Smiley Happy Welcome to the forums!

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4
Anonymous
in reply to: Jeff_M

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

Message 4 of 4
Jeff_M
in reply to: Anonymous

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.
Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report