Message 1 of 7
CurveEvaluator::GetPointAtParam failing (C++)

Not applicable
07-19-2006
04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there!
I´m using C++.
My goal is to get the tangent at a point of an Edge. To do that I´m trying to retrieve the parameter for the CurveEvaluator for that point, which I could then use with CurveEvaluator::GetTangent(...).
After trying to use CurveEvaluator::GetParamAtPoint(...) without any success (yes, I asked here at the forums) for several weeks I now decided to implement my own GetParamForPoint function just because I lack any better ideas.
So, to make things short:
That function would need to get some point on the edge for certain parameters to check for the distance to the input point. For that, the CurveEvaluator supplements a GetPointAtParam(...) function.
What I do is the following:
1. Get minimum and maximum parameters for the CurveEvaluator through GetParamExtents(...), which works fine.
2. Create a SAFEARRAY* called 'param' with one double in it. That double is a value between minimum and maximum parameters from step 1.
3. Call CurveEvaluator::GetPointAtParam(¶m, &p), where p is a SAFEARRAY* created with 'new SAFEARRAY()'. That call fails. Documentation again failed to give any clue why that call fails, as well as the HRESULT returned doesn´t help at all.
The complete block of code for that looks like this (I´ll only post the first call to GetPointAtParam(...) since the rest of them looks just the same), evalPtr is a pointer to a CurveEvaluator, paramMin and paramMax are the boundaries for valid parameters:
SAFEARRAY* p = new SAFEARRAY();
SAFEARRAY* params = SafeArrayCreateVector(VT_R8, 0, 1);
double* data;
SafeArrayAccessData(params, (void**)&data);
memcpy(data, ¶mMin, sizeof(double));
SafeArrayUnaccessData(params);
HRESULT hr = evalPtr->GetPointAtParam(¶ms, &p);
if(FAILED(hr))
{
// I always end up here, as the call to GetPointAtParam
// always fails.
}
SafeArrayAccessData(p, (void**)&data);
CVector3 v = CVector3(data[0], data[1], data[2]);
SafeArrayUnaccessData(p);
As the call already fails when using the minimum parameter for the Evaluator as input value, I guess I must have gotten something wrong about how to supply the input parameter to the function, as I think that paramMin should definitely be valid.
If anybody has ever used GetPointAtParam(...) or (even better) GetParamAtPoint(...) successfully, I´d be really really happy if he would be willing to share how he did it as I seem completely unable to get anything really useful out of that CurveEvaluator.
Thx for reading and your help
I´m using C++.
My goal is to get the tangent at a point of an Edge. To do that I´m trying to retrieve the parameter for the CurveEvaluator for that point, which I could then use with CurveEvaluator::GetTangent(...).
After trying to use CurveEvaluator::GetParamAtPoint(...) without any success (yes, I asked here at the forums) for several weeks I now decided to implement my own GetParamForPoint function just because I lack any better ideas.
So, to make things short:
That function would need to get some point on the edge for certain parameters to check for the distance to the input point. For that, the CurveEvaluator supplements a GetPointAtParam(...) function.
What I do is the following:
1. Get minimum and maximum parameters for the CurveEvaluator through GetParamExtents(...), which works fine.
2. Create a SAFEARRAY* called 'param' with one double in it. That double is a value between minimum and maximum parameters from step 1.
3. Call CurveEvaluator::GetPointAtParam(¶m, &p), where p is a SAFEARRAY* created with 'new SAFEARRAY()'. That call fails. Documentation again failed to give any clue why that call fails, as well as the HRESULT returned doesn´t help at all.
The complete block of code for that looks like this (I´ll only post the first call to GetPointAtParam(...) since the rest of them looks just the same), evalPtr is a pointer to a CurveEvaluator, paramMin and paramMax are the boundaries for valid parameters:
SAFEARRAY* p = new SAFEARRAY();
SAFEARRAY* params = SafeArrayCreateVector(VT_R8, 0, 1);
double* data;
SafeArrayAccessData(params, (void**)&data);
memcpy(data, ¶mMin, sizeof(double));
SafeArrayUnaccessData(params);
HRESULT hr = evalPtr->GetPointAtParam(¶ms, &p);
if(FAILED(hr))
{
// I always end up here, as the call to GetPointAtParam
// always fails.
}
SafeArrayAccessData(p, (void**)&data);
CVector3 v = CVector3(data[0], data[1], data[2]);
SafeArrayUnaccessData(p);
As the call already fails when using the minimum parameter for the Evaluator as input value, I guess I must have gotten something wrong about how to supply the input parameter to the function, as I think that paramMin should definitely be valid.
If anybody has ever used GetPointAtParam(...) or (even better) GetParamAtPoint(...) successfully, I´d be really really happy if he would be willing to share how he did it as I seem completely unable to get anything really useful out of that CurveEvaluator.
Thx for reading and your help