本文整理汇总了C++中SplineSurface::order_v方法的典型用法代码示例。如果您正苦于以下问题:C++ SplineSurface::order_v方法的具体用法?C++ SplineSurface::order_v怎么用?C++ SplineSurface::order_v使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplineSurface
的用法示例。
在下文中一共展示了SplineSurface::order_v方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
//===========================================================================
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;
}
示例2: main
int main(int argc, char** argv)
{
if (argc < 3) {
cerr << "Usage: " << argv[0]
<< " inputfile outputfile [max_coefs_u max_coefs_v]" << endl;
return 1;
}
ifstream in(argv[1]);
ofstream out(argv[2]);
if (!in || !out) {
cout << "Bad file(s) or filename(s)." << endl;
return 1;
}
ObjectHeader oh;
SplineSurface sf;
in >> oh >> sf;
int m = sf.numCoefs_v() - sf.order_v() + 1;
int n = sf.numCoefs_u() - sf.order_u() + 1;
if (argc >= 5) {
// Note the weird order (v then u)
m = min(atoi(argv[4])-sf.numCoefs_v(), m);
n = min(atoi(argv[3])-sf.numCoefs_u(), n);
}
int i;
vector<double> newknots_v;
vector<double> newknots_u;
for (i = 0; i < m; ++i) {
vector<double>::const_iterator it = sf.basis_v().begin();
double newknot = 0.5*it[sf.order_v()+i-1] + 0.5*it[sf.order_v()+i];
newknots_v.push_back(newknot);
}
for (i = 0; i < n; ++i) {
vector<double>::const_iterator it = sf.basis_u().begin();
double newknot = 0.5*it[sf.order_u()+i-1] + 0.5*it[sf.order_u()+i];
newknots_u.push_back(newknot);
}
sf.insertKnot_v(newknots_v);
sf.insertKnot_u(newknots_u);
out << oh << sf;
return 0;
}
示例3: splitSurfaceIntoPatches
//==========================================================================
void GeometryTools::splitSurfaceIntoPatches(const SplineSurface& sf,
vector<SplineSurface>& pat)
//==========================================================================
{
SplineSurface orig = sf;
orig.makeBernsteinKnotsU();
orig.makeBernsteinKnotsV();
int num_u = orig.numCoefs_u();
int num_v = orig.numCoefs_v();
int order_u = orig.order_u();
int order_v = orig.order_v();
int numpat_u = num_u / order_u;
int numpat_v = num_v / order_v;
pat.resize(numpat_u * numpat_v);
typedef vector<double>::const_iterator const_iter;
const_iter itu = orig.basis_u().begin();
const_iter itv;
for (int i = 0; i < numpat_u; ++i) {
itv = orig.basis_v().begin();
for (int j = 0; j < numpat_v; ++j) {
shared_ptr<SplineSurface>
new_sf(orig.subSurface(*itu, *itv,
*(itu+order_u), *(itv+order_v)));
pat[numpat_u*j + i] = *new_sf;
itv += order_v;
}
itu += order_u;
}
return;
}
示例4: cart_to_bary
//==========================================================================
void cart_to_bary(const SplineSurface& sf, const BaryCoordSystem3D& bc,
SplineSurface& sf_bc)
//==========================================================================
{
ALWAYS_ERROR_IF(sf.dimension() != 3, "Dimension must be 3.");
int nu = sf.numCoefs_u();
int nv = sf.numCoefs_v();
Vector3D cart;
Vector4D bary;
vector<double> new_coefs;
if (!sf.rational()) {
new_coefs.resize(4 * nu * nv);
for (int iv = 0; iv < nv; ++iv) {
for (int iu = 0; iu < nu; ++iu) {
int offset = nu * iv + iu;
cart = Vector3D(sf.coefs_begin() + 3 * offset);
bary = bc.cartToBary(cart);
for (int j = 0; j < 4; ++j) {
new_coefs[4*offset + j] = bary[j];
}
}
}
} else {
new_coefs.resize(5 * nu * nv);
for (int iv = 0; iv < nv; ++iv) {
for (int iu = 0; iu < nu; ++iu) {
int offset = nu * iv + iu;
cart = Vector3D(sf.coefs_begin() + 3 * offset);
bary = bc.cartToBary(cart);
double w = sf.rcoefs_begin()[4*offset + 3];
for (int j = 0; j < 4; ++j) {
new_coefs[5*offset + j] = bary[j] * w;
}
new_coefs[5*offset + 4] = w;
}
}
}
sf_bc = SplineSurface(nu, nv, sf.order_u(), sf.order_v(),
sf.basis_u().begin(), sf.basis_v().begin(),
new_coefs.begin(), 4, sf.rational());
return;
}
示例5: make_matrix
//==========================================================================
void make_matrix(const SplineSurface& surf, int deg,
vector<vector<double> >& mat)
//==========================================================================
{
// Create BernsteinMulti. In the rational case the weights are
// included in an "extra" coordinate.
int dim = surf.dimension();
bool rational = surf.rational();
vector<BernsteinMulti> beta;
spline_to_bernstein(surf, beta);
// Make vector of basis functions (with the surface plugged in) by
// using recursion
int num = (deg+1) * (deg+2) * (deg+3) / 6;
vector<BernsteinMulti> basis(num);
vector<BernsteinMulti> tmp(num);
basis[0] = BernsteinMulti(1.0);
BernsteinMulti zero_multi = BernsteinMulti(0.0);
for (int r = 1; r <= deg; ++r) {
int m = -1;
int tmp_num = (r + 1) * (r + 2) * (r + 3) / 6;
fill(tmp.begin(), tmp.begin() + tmp_num, zero_multi);
for (int i = 0; i < r; ++i) {
int k = (i + 1) * (i + 2) / 2;
for (int j = 0; j <= i; ++j) {
for (int l = 0; l <= j; ++l) {
++m;
tmp[m] += beta[0] * basis[m];
tmp[m + k] += beta[1] * basis[m];
tmp[m + 1 + j + k] += beta[2] * basis[m];
tmp[m + 2 + j + k] += beta[3] * basis[m];
}
}
}
basis.swap(tmp);
}
// Fill up the matrix mat
int deg_u = surf.order_u() - 1;
int deg_v = surf.order_v() - 1;
int numbas = (deg * deg_u + 1) * (deg * deg_v + 1);
mat.resize(numbas);
for (int row = 0; row < numbas; ++row) {
mat[row].resize(num);
for (int col = 0; col < num; ++col) {
mat[row][col] = basis[col][row];
}
}
// If rational, include diagonal scaling matrix. Dividing the
// D-matrix by the weights has the same effect as multiplying the
// basis with the same weights. (Included for numerical reasons only -
// it makes the basis a partition of unity.)
if (rational) {
BernsteinMulti weights = BernsteinMulti(1.0);
for (int i = 1; i <= deg; ++i)
weights *= beta[dim];
for (int row = 0; row < numbas; ++row) {
double scaling = 1.0 / weights[row];
for (int col = 0; col < num; ++col) {
mat[row][col] *= scaling;
}
}
}
// // Check Frobenius norm
// double norm = 0.0;
// for (int irow = 0; irow < numbas; ++irow) {
// for (int icol = 0; icol < num; ++icol) {
// norm += mat[irow][icol] * mat[irow][icol];
// }
// }
// norm = sqrt(norm);
// cout << "Frobenius norm = " << norm << endl;
return;
}