03-16-2012 08:59 PM
I tried adding a pcurve to a coedge by the following code:
COEDGE * coedgg = (COEDGE*)coedgList;
const pcurve* pcr = &(coedgg->geometry()->equation());
SPAinterval pcrRange = pcr->param_range();
But the last line of the code gives an exception saying:
"Unhandled exception at 0x02090ee1 (SpaACISd.dll)
0xC00000005: Access violation reading location 0xfeeeff42
I have attached the .sat file of the model.
Any suggestions regarding why this is failing will be highly appreciated.
03-20-2012 09:43 PM
I think the problem here is that you took the address of a temporary. PCURVE::equation returns a pcurve by value, not the const& to a pcurve. In the line where you assign pcurve const* pcur = &(coedge->geometry()->equation()) I think the destructor for the temprorary is being called before you access the pointer (c++ compilers are able to call the destructor as soon as they can prove a temporary is out of scope).
I tried the same thing in scheme and it worked, so I am reasonably confident that this is the problem. The interface is wierd, especially given how CURVE::equation and SURFACE::equation return references rather than objects. Part of the issue is that we don't really have first class pcurves (i.e., they are not polymorphic) so we don't need to pass back references. I can't really come up with a better explanation for the wierdness of it than that.
hope this helps
03-20-2012 11:34 PM
I have checked own sources and met code with this feature. As C++ programmers explained, C++ standard allow this.
PCURVE* pUVCurve = pCoEdge->geometry(); ... pcurve const & uvcurve = pUVCurve->equation(); ...
So TC can use a constant reference to temporary object instead of a pointer.