I modified the function about the writing NURBS surface.
Like this:
static bool write_surfaces_example( FILE* fp, int version )
{
const int bIsRational = false;
const int dim = 3;
const int u_degree = 2;
const int v_degree = 2;
const int u_cv_count = 3;
const int v_cv_count = 3;
double u_knot[ u_cv_count + u_degree - 1 ];
double v_knot[ v_cv_count + v_degree - 1 ];
u_knot[0] = u_knot[1] = 0;
u_knot[2] = u_knot[3] = 1;
v_knot[0] = v_knot[1] = 0;
v_knot[2] = v_knot[3] = 1;
ON_NurbsSurface nurbs_surface( dim, bIsRational, u_degree+1, v_degree+1, u_cv_count, v_cv_count );
nurbs_surface.SetKnot(0 , 0 , 0);
nurbs_surface.SetKnot(0 , 1 , 0);
nurbs_surface.SetKnot(0 , 2 , 1);
nurbs_surface.SetKnot(0 , 3 , 1);
nurbs_surface.SetKnot(1 , 0 , 0);
nurbs_surface.SetKnot(1 , 1 , 0);
nurbs_surface.SetKnot(1 , 2 , 1);
nurbs_surface.SetKnot(1 , 3 , 1);
nurbs_surface.SetCV(0 , 0 , ON_3dPoint(0 , 0 , 1));
nurbs_surface.SetCV(0 , 1 , ON_3dPoint(1 , 0 , 1));
nurbs_surface.SetCV(0 , 2 , ON_3dPoint(2 , 0 , 1));
nurbs_surface.SetCV(1 , 0 , ON_3dPoint(0 , 1 , 1));
nurbs_surface.SetCV(1 , 1 , ON_3dPoint(1 , 1 , 1));
nurbs_surface.SetCV(1 , 2 , ON_3dPoint(2 , 1 , 1));
nurbs_surface.SetCV(2 , 0 , ON_3dPoint(0 , 2 , 1));
nurbs_surface.SetCV(2 , 1 , ON_3dPoint(1 , 2 , 1));
nurbs_surface.SetCV(2 , 2 , ON_3dPoint(2 , 2 , 1));
bool ok = false;
if ( nurbs_surface.IsValid() )
{
ON_BinaryFile archive( ON::write3dm, fp );
ok = ON_WriteOneObjectArchive( archive, version, nurbs_surface );
}
return ok;
}
but,whatever the function provided by the example_write.cpp and my modified function running. the result is a plane all the time.
like this.
I wonder know why. I have spend much time on this.
Best Regards
–Jeff