本文整理汇总了C++中SplineSurface::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ SplineSurface::clone方法的具体用法?C++ SplineSurface::clone怎么用?C++ SplineSurface::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplineSurface
的用法示例。
在下文中一共展示了SplineSurface::clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
//===========================================================================
shared_ptr<SplineSurface> SurfaceCreators::mergeRationalParts(const SplineSurface& nom_sf,
const SplineSurface& den_sf,
bool weights_in_first)
//===========================================================================
{
ASSERT((!nom_sf.rational()) && (!den_sf.rational()));
ASSERT(den_sf.dimension() == 1);
int dim = nom_sf.dimension();
// We first make sure they share spline space.
vector<shared_ptr<SplineSurface> > sfs;
sfs.push_back(shared_ptr<SplineSurface>(nom_sf.clone()));
sfs.push_back(shared_ptr<SplineSurface>(den_sf.clone()));
double knot_diff_tol = 1e-06;
GeometryTools::unifySurfaceSplineSpace(sfs, knot_diff_tol);
vector<double> rcoefs;
vector<double>::const_iterator iter = sfs[0]->coefs_begin();
vector<double>::const_iterator riter = sfs[1]->coefs_begin();
int num_coefs = sfs[0]->numCoefs_u()*sfs[0]->numCoefs_v();
for (int ki = 0; ki < num_coefs; ++ki) {
for (int kj = 0; kj < dim; ++kj) {
if (weights_in_first) {
rcoefs.push_back(iter[ki*dim+kj]);
} else {
rcoefs.push_back(iter[ki*dim+kj]*riter[ki]);
}
}
rcoefs.push_back(riter[ki]);
}
shared_ptr<SplineSurface> rat_sf(new SplineSurface
(sfs[0]->numCoefs_u(), sfs[0]->numCoefs_v(),
sfs[0]->order_u(), sfs[0]->order_v(),
sfs[0]->basis_u().begin(), sfs[0]->basis_v().begin(),
rcoefs.begin(), dim, true));
return rat_sf;
}
示例2: fabs
shared_ptr<SplineSurface>
GeometryTools::surfaceSum(const SplineSurface& sf1, double fac1,
const SplineSurface& sf2, double fac2, double num_tol)
//********************************************************************
// Addition of two signed SplineSurfaces, i.e. this function can
// also be used for subtraction. The surfaces is assumed to live on
// the same parameter domain, but may have different knot vectors.
//********************************************************************
{
// Check input
ALWAYS_ERROR_IF(fabs(sf1.startparam_u() - sf2.startparam_u()) > num_tol ||
fabs(sf1.endparam_u() - sf2.endparam_u()) > num_tol ||
fabs(sf1.startparam_v() - sf2.startparam_v()) > num_tol ||
fabs(sf1.endparam_v() - sf2.endparam_v()) > num_tol,
"Inconsistent parameter domain.");
// For the time being
if (sf1.rational() || sf2.rational()) {
THROW("Sum of rational surfaces is not implemented");
}
// Make copy of surfaces
vector<shared_ptr<SplineSurface> > surfaces;
surfaces.reserve(2);
shared_ptr<SplineSurface> sf;
// #ifdef _MSC_VER
// sf = shared_ptr<SplineSurface>(dynamic_cast<SplineSurface*>(sf1.clone()));
// #else
sf = shared_ptr<SplineSurface>(sf1.clone());
// #endif
surfaces.push_back(sf);
// #ifdef _MSC_VER
// sf = shared_ptr<SplineSurface>(dynamic_cast<SplineSurface*>(sf2.clone()));
// #else
sf = shared_ptr<SplineSurface>(sf2.clone());
// #endif
surfaces.push_back(sf);
// Make sure that the surfaces live on the same knot vector
GeometryTools::unifySurfaceSplineSpace(surfaces, num_tol);
// Add signed coefficients
vector<double> coefs;
int nmb_coefs_u = surfaces[0]->numCoefs_u();
int nmb_coefs_v = surfaces[0]->numCoefs_v();
int dim = surfaces[0]->dimension();
coefs.resize(dim*nmb_coefs_u*nmb_coefs_v);
int ki;
std::vector<double>::iterator s1 = surfaces[0]->coefs_begin();
std::vector<double>::iterator s2 = surfaces[1]->coefs_begin();
for (ki=0; ki<dim*nmb_coefs_u*nmb_coefs_v; ki++)
coefs[ki] = fac1*s1[ki] + fac2*s2[ki];
// Create output curve
shared_ptr<SplineSurface>
surfacesum(new SplineSurface(nmb_coefs_u, nmb_coefs_v,
surfaces[0]->order_u(),
surfaces[0]->order_v(),
surfaces[0]->basis_u().begin(),
surfaces[0]->basis_v().begin(),
&coefs[0], dim, false));
return surfacesum;
}