- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I have an example where acdbWcs2Ucs seems to overwrite memory:
bool GetDwgViewExtents(AcGePoint2d &acadPtTL, AcGePoint2d &acadPtBR)
{
// First retrieves the extents with GetWindowRect, ScreenToClient and acedCoordFromPixelToWorld into the following
acedDwgPoint dwgPtTL, dwgPtBR;
// I have tried using the acedDwgPoints directly, but the same happens, so this was an effort to try something else
AcGePoint2d acadPtTLorg, acadPtBRorg;
acadPtTLorg.set(dwgPtTL[0], dwgPtTL[1]);
acadPtBRorg.set(dwgPtBR[0], dwgPtBR[1]);
acdbWcs2Ucs(asDblArray(acadPtTLorg), asDblArray(acadPtTL), false); // acadPtTL correctly set to {x=-15058.342090026275 y=1177968.0167071891 }
acdbWcs2Ucs(asDblArray(acadPtBRorg), asDblArray(acadPtBR), false); // acadPtBR correctyl set to {x=-14905.579798326420 y=1177905.8325202183 }
// BUT: in the last call, acadPtTL[0] is unexpectedly changed to 0.0!
}
The really strange thing is, I added the following after this code, to compare in debug what happens:
ads_point tl, br;
tl[0] = dwgPtTL[0];
tl[1] = dwgPtTL[1];
br[0] = dwgPtBR[0];
br[1] = dwgPtBR[1];
acdbWcs2Ucs(tl, tl, false);
acdbWcs2Ucs(br, br, false);
acadPtTL.set(tl[0], tl[1]);
acadPtBR.set(br[0], br[1]);
this code works just fine, but when compiling with this code there, also the first version suddenly works fine!
Any tips on what is going on here are appreciated!
One concrete question is that the definition of asDblArray is:
inline double*
asDblArray(const AcGePoint2d& pnt)
{
return (double*)&pnt;
}
where as far as I can tell, AcGePoint2d has no explicit conversion to a double *. It has some functions and only the 2 member variables:
double x,y;
But is it really safe to assume that simply converting with a (double*) changes the pointer to an AcGePoint2d to a valid double[3] pointer?
Could this be the problem here, could it be a compiler error or am I missing something?
Best regards,
Knut
Solved! Go to Solution.

