10

求教:STEP文件解析出的曲面数据用gluNurbsSurface绘画的问题

利用空闲时间自己写了一个STEP文件解析。可是解析出来的数据用gluNurbsSurface函数绘不出图形。

这是解析出来的数据:

GLfloat CtrlPoint[15][11][3] =
{
{ { 0.396180,55.420753,-0.339999 },
{ -4.653235,55.420746,-0.340001 },
{ -9.621811,55.420780,-0.339775 },
{ -14.050525,55.420662,-0.364466 },
{ -16.463245,55.420780,-0.395637 },
{ -18.554060,55.420628,-0.431171 },
{ -20.763857,55.420708,-0.485464 },
{ -23.641211,55.420509,-0.628331 },
{ -27.128616,55.421169,-1.045857 },
{ -29.227036,55.420670,-1.575200 },
{ -30.188053,55.420795,-1.934166 } },

{ { 0.391862,55.915108,-0.340013 },
{ -4.602001,55.915131,-0.340019 },
{ -9.544586,55.915169,-0.339743 },
{ -13.987616,55.915241,-0.363895 },
{ -16.416355,55.915390,-0.394920 },
{ -18.516788,55.915371,-0.430465 },
{ -20.733881,55.915504,-0.484327 },
{ -23.617601,55.915447,-0.626374 },
{ -27.116173,55.915535,-1.043046 },
{ -29.223436,55.915161,-1.573819 },
{ -30.189358,55.914875,-1.934648 } },

{ { 0.384358,56.851002,-0.339657 },
{ -4.512877,56.851021,-0.339631 },
{ -9.421076,56.851048,-0.339272 },
{ -13.906471,56.851311,-0.362722 },
{ -16.371767,56.851555,-0.393841 },
{ -18.492149,56.851772,-0.429611 },
{ -20.722265,56.851925,-0.483436 },
{ -23.612581,56.852146,-0.625561 },
{ -27.116095,56.852062,-1.042340 },
{ -29.223709,56.853149,-1.573360 },
{ -30.188852,56.852924,-1.934337 } },

{ { 0.372935,58.179333,-0.353692 },
{ -4.376973,58.179798,-0.353618 },
{ -9.245570,58.180267,-0.353281 },
{ -13.818981,58.180782,-0.376462 },
{ -16.353870,58.181198,-0.408418 },
{ -18.512518,58.181751,-0.444851 },
{ -20.767103,58.181908,-0.500031 },
{ -23.666553,58.182644,-0.644998 },
{ -27.157047,58.184246,-1.063828 },
{ -29.238558,58.190113,-1.588565 },
{ -30.184488,58.192352,-1.941806 } },

{ { 0.360575,59.413937,-0.394705 },
{ -4.229746,59.415619,-0.394698 },
{ -9.055145,59.417278,-0.394600 },
{ -13.726094,59.418381,-0.418016 },
{ -16.339619,59.419086,-0.451076 },
{ -18.543598,59.419952,-0.488196 },
{ -20.828815,59.420158,-0.545257 },
{ -23.742640,59.421547,-0.693872 },
{ -27.216085,59.426136,-1.113946 },
{ -29.261786,59.438492,-1.626709 },
{ -30.181005,59.445297,-1.966521 } },

{ { 0.347430,60.579803,-0.476209 },
{ -4.073054,60.583607,-0.476508 },
{ -8.849333,60.587418,-0.476947 },
{ -13.620145,60.590111,-0.500861 },
{ -16.316299,60.591545,-0.534941 },
{ -18.569221,60.592880,-0.572488 },
{ -20.888618,60.593521,-0.631266 },
{ -23.820963,60.596081,-0.782867 },
{ -27.279118,60.604572,-1.201117 },
{ -29.289598,60.624355,-1.696387 },
{ -30.182413,60.637894,-2.018497 } },

{ { 0.335411,61.673443,-0.611145 },
{ -3.929763,61.680119,-0.612128 },
{ -8.664754,61.687119,-0.613495 },
{ -13.531279,61.692574,-0.637932 },
{ -16.304022,61.695259,-0.672570 },
{ -18.600494,61.697304,-0.709939 },
{ -20.948824,61.698704,-0.769575 },
{ -23.894472,61.702702,-0.922069 },
{ -27.335758,61.715443,-1.333270 },
{ -29.318361,61.742729,-1.805597 },
{ -30.192587,61.764133,-2.107212 } },

{ { 0.323835,62.690128,-0.806288 },
{ -3.792035,62.699791,-0.808431 },
{ -8.484427,62.710270,-0.811183 },
{ -13.436935,62.718651,-0.835980 },
{ -16.279263,62.722790,-0.870511 },
{ -18.614668,62.725616,-0.906930 },
{ -20.988556,62.727757,-0.966152 },
{ -23.946426,62.733250,-1.116681 },
{ -27.377441,62.751457,-1.514939 },
{ -29.346308,62.787239,-1.959615 },
{ -30.213768,62.817215,-2.239034 } },

{ { 0.311956,63.630329,-1.068795 },
{ -3.650888,63.642754,-1.072714 },
{ -8.289282,63.656456,-1.077406 },
{ -13.312265,63.667461,-1.102242 },
{ -16.216412,63.672909,-1.135769 },
{ -18.587200,63.676319,-1.170238 },
{ -20.985466,63.679043,-1.227325 },
{ -23.959078,63.685894,-1.372183 },
{ -27.395077,63.709705,-1.750528 },
{ -29.371222,63.753456,-2.163080 },
{ -30.247601,63.791500,-2.419285 } },

{ { 0.295965,64.786026,-1.506171 },
{ -3.461175,64.800629,-1.512817 },
{ -8.012814,64.816757,-1.520406 },
{ -13.105686,64.829529,-1.544819 },
{ -16.079136,64.835854,-1.575963 },
{ -18.490387,64.839409,-1.606755 },
{ -20.917952,64.842476,-1.658949 },
{ -23.916044,64.850700,-1.791643 },
{ -27.380297,64.881157,-2.134801 },
{ -29.396799,64.933273,-2.499629 },
{ -30.307966,64.979561,-2.724183 } },

{ { 0.276334,66.030304,-2.205175 },
{ -3.226525,66.043480,-2.215111 },
{ -7.642716,66.058044,-2.226399 },
{ -12.771455,66.069916,-2.250023 },
{ -15.801824,66.076218,-2.277041 },
{ -18.247419,66.079742,-2.302287 },
{ -20.702587,66.083542,-2.345565 },
{ -23.735643,66.093933,-2.455723 },
{ -27.277956,66.130859,-2.740284 },
{ -29.406607,66.187813,-3.038391 },
{ -30.406221,66.236511,-3.222476 } },

{ { 0.252621,67.186798,-3.268190 },
{ -2.947218,67.195946,-3.279870 },
{ -7.172223,67.206093,-3.293343 },
{ -12.290011,67.214943,-3.314248 },
{ -15.357754,67.219788,-3.334449 },
{ -17.827532,67.222710,-3.352131 },
{ -20.305820,67.226532,-3.382119 },
{ -23.383739,67.236305,-3.457649 },
{ -27.060328,67.267227,-3.653424 },
{ -29.380144,67.309601,-3.858564 },
{ -30.523331,67.342438,-3.986731 } },

{ { 0.232510,67.876495,-4.346978 },
{ -2.714065,67.880211,-4.353499 },
{ -6.767012,67.884476,-4.361573 },
{ -11.853099,67.888840,-4.375108 },
{ -14.939553,67.891464,-4.387467 },
{ -17.422377,67.893379,-4.398559 },
{ -19.914835,67.895996,-4.416266 },
{ -23.028887,67.902039,-4.458865 },
{ -26.829449,67.918930,-4.568076 },
{ -29.325071,67.940041,-4.685094 },
{ -30.597101,67.955116,-4.759522 } },

{ { 0.220774,68.164368,-5.096286 },
{ -2.573260,68.165863,-5.099390 },
{ -6.533067,68.167656,-5.103587 },
{ -11.618490,68.169785,-5.111461 },
{ -14.726694,68.171204,-5.118582 },
{ -17.222906,68.172356,-5.125169 },
{ -19.726410,68.173920,-5.135098 },
{ -22.859045,68.177422,-5.158138 },
{ -26.716221,68.186806,-5.216928 },
{ -29.292234,68.198242,-5.281814 },
{ -30.623497,68.206230,-5.324024 } },

{ { 0.216830,68.245834,-5.360061 },
{ -2.525938,68.246780,-5.362195 },
{ -6.456790,68.247948,-5.365202 },
{ -11.546170,68.249435,-5.371111 },
{ -14.664030,68.250473,-5.376442 },
{ -17.166023,68.251350,-5.381429 },
{ -19.673941,68.252533,-5.388788 },
{ -22.812376,68.255165,-5.405632 },
{ -26.684931,68.262115,-5.448541 },
{ -29.282665,68.270523,-5.496467 },
{ -30.630068,68.276352,-5.527918 } }};

GLint u_degree = 3;
GLint v_degree = 3;
GLint u_multiplicities[13] = { 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 };
GLint v_multiplicities[9] = { 4, 1, 1, 1, 1, 1, 1, 1, 4 };
GLfloat u_knots[13] =
{ 0., 0.071307130996859, 0.137595256562749, 0.203883382128597,
0.270171507694445,0.336459633260292, 0.40274775882614,
0.469035884392094, 0.535324009957942, 0.667900261089637,
0.800476512221333, 0.933052763353134, 1. };
GLfloat v_knots[9] =
{ 0., 0.252050094115983, 0.374749611013778,0.497449127911572,
0.55879888636047, 0.620148644809465,0.74284816170726, 0.865547678605054,1. };

下面是调用方法:
void Draw()
{
。。。
int S = 15; //CtrlPoint[15][11][3]
int T = 11; //CtrlPoint[15][11][3]
GLint S_ORDER = u_degree;
GLint T_ORDER = v_degree;
GLint S_NUMKNOTS = 13;
GLint T_NUMKNOTS = 9;
GLfloat *u_Knots = &u_knots[0];
GLfloat *v_Knots = &v_knots[0];
GLfloat *CtrlPoints = &(CtrlPoint[0][0][0]);
if (!FUnurbsObj)
{
FUnurbsObj = gluNewNurbsRenderer();
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
GLfloat specular[] = { 0.7f, 0.7f, 0.7f, 1.0f };
GLfloat shine[] = { 100.0f };
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
glMaterialfv(GL_FRONT, GL_SHININESS, shine);
glEnable(GL_AUTO_NORMAL);
gluNurbsProperty(FUnurbsObj, GLU_SAMPLING_TOLERANCE, 10.0f);//定义显示误差精度
gluNurbsProperty(FUnurbsObj, GLU_DISPLAY_MODE, (GLfloat)GLU_FILL);//填充
}
gluBeginSurface(FUnurbsObj);
gluNurbsSurface(
FUnurbsObj,
S_NUMKNOTS,
u_Knots,
T_NUMKNOTS,
v_Knots,
3 * T,
3,
CtrlPoints,
S_ORDER,
T_ORDER,
GL_MAP2_VERTEX_3);
gluEndSurface(FUnurbsObj);
。。。
}

路过的大牛们看看问题出在哪里?

查看全部
bannico
bannico
2017/06/28 06:51
  • step
  • glunurbssurface
  • opengl
  • 点赞
  • 收藏
  • 回答
    私信

0个回复