//=========================================================================== vector<shared_ptr<SplineSurface> > SurfaceCreators::separateRationalParts(const SplineSurface& sf) //=========================================================================== { bool rat = sf.rational(); ASSERT(rat); int dim= sf.dimension(); int rdim = dim + 1; vector<shared_ptr<SplineSurface> > sep_sfs; vector<double> coefs(sf.coefs_begin(), sf.coefs_end()); int nmb1 = sf.numCoefs_u(); int nmb2 = sf.numCoefs_v(); vector<double> rcoefs; int num_coefs = nmb1*nmb2; vector<double>::const_iterator rcoef_iter = sf.rcoefs_begin(); for (int ki = 0; ki < num_coefs; ++ki) { rcoefs.push_back(rcoef_iter[ki*rdim+1]); for (int kj = 0; kj < dim; ++kj) { coefs[ki*dim+kj] /= (rcoefs.back()); } } sep_sfs.push_back(shared_ptr<SplineSurface> (new SplineSurface(nmb1, nmb2, sf.order_u(), sf.order_v(), sf.basis_u().begin(), sf.basis_v().begin(), coefs.begin(), dim))); sep_sfs.push_back(shared_ptr<SplineSurface> (new SplineSurface(nmb1, nmb2, sf.order_u(), sf.order_v(), sf.basis_u().begin(), sf.basis_v().begin(), rcoefs.begin(), 1))); return sep_sfs; }