查看单个帖子
旧 2009-05-06, 08:38 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】odgenurbcurve3devalpoint for closed spline

odgenurbcurve3d::evalpoint for closed spline
odgenurbcurve3d::evalpoint for closed spline
hi,
i am using odgenurbcurve3d to get splinefitted and curvefitted points.. for a 2dpolyline.. i am creating odgenurbcurve3d by knots and control points..
code:
odgepoint3darray cntrlpoints;
oddbobjectiteratorptr pvertiter = ppoly->vertexiterator();
for (; !pvertiter->done(); pvertiter->step())
{
oddb2dvertexptr pvertex = pvertiter->entity( oddb::kforwrite);
cntrlpoints.push_back( pvertex->position());
}
odgedoublearray knots, weights;
if( bisclosed)//for closed 2dpolyline
{
knots.resize( nvertex);
for( int i = 0; i < nvertex; i++)
knots[i] = i;
}
else
{
knots.resize( nvertex + ndegree + 1);
for( int i = 0; i <= ndegree; i++)
knots[i] = 0;
for( i = ndegree+1; i <= nvertex; i++)
knots[i] = i - ndegree;
for( i = nvertex+1; i < nvertex + ndegree + 1; i++)
knots[i] = nvertex - ndegree;
nstartknotindex = ndegree;
}
odgeknotvector knotvector( knots);
weights.resize( nvertex, 1.0);
//now creating nurbcurve ......
odgenurbcurve3d gespline( ndegree, knotvector, cntrlpoints, weights, bisclosed);
// after spline is created... evalpoint() is called at some for tha parameters.....
odgepoint3d point = gespline.evalpoint( paramt);
......
...
now evalpoint() funtion is working fine for open gespline but when i am called it when bisclosed is true..(for closed polyline..) then it is throwing error as "not applicable
please help me... how do i get the correct spline fitted vertices for closed one... thank you alot.........
.................................................. .........................


please note these two facts:
1) the number of knots, control points and degree of nurbs curve must be under the following formula:
number of knots = number of control points + degree + 1;
2) the start parameter for nurbs curve is knots[degree]. the end parameter is knots[number of knots - degree - 1]. attempting to call evalpoint() with argument out of these bounds will cause enotapplicable exception.
hope this helps.
sincerely yours,
george udov
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)