- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-16-2012 08:59 PM
Hi,
I tried adding a pcurve to a coedge by the following code:
__________________________________________________
api_get_coedges(body, coedgList);
COEDGE * coedgg = (COEDGE*)coedgList[3];
sg_add_pcurve_to_coedge(coedgg, true);
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.
Thanks,
Jinesh.
Re: Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-18-2012 07:59 PM
Documentation mentions that sg_add_pcurve_to_coedge will put a pcurve on coedge "if necessary".
Did you check if pcr != NULL?
AR
Re: Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 09:35 PM
Hello AR,
Yes I did check. pcr is not NULL.
Thanks,
jinesh
Re: Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 09:43 PM
Hi Jinesh
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
Eric
Re: Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 11:34 PM
Nice answer!
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.
Re: Adding pcurve to a coedge
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-27-2012 09:25 PM
Thanks Asdf and Vi2.
That solved my problem.
Regards,
Jinesh.

