本文整理汇总了C++中ARRAY::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY::empty方法的具体用法?C++ ARRAY::empty怎么用?C++ ARRAY::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARRAY
的用法示例。
在下文中一共展示了ARRAY::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: C
void
LMESH::fit(ARRAY<Lvert*>& verts, bool do_gauss_seidel)
{
static bool debug = Config::get_var_bool("DEBUG_LMESH_FIT",false);
static bool move_along_normal =
Config::get_var_bool("FITTING_MOVE_ALONG_NORMAL",false);
if (verts.empty())
return;
// calculate the bounding box of the vertices
BBOX box;
int i;
for (i=0; i<verts.num(); i++)
box.update(verts[i]->loc());
double max_err = box.dim().length() * 1e-5;
int n = verts.num();
// get original control point locations
ARRAY<Wpt> C(n); // original control points
ARRAY<Wpt> L(n); // current limit points
for (i=0; i<n; i++) {
C += verts[i]->loc();
L += Wpt::Origin();
}
if(debug) {
cerr << "LMESH::fit- fitting " << n << " vertices"<<endl;
cerr << "Max_err = " << max_err <<endl;
}
// do 50 iterations...
double prev_err = 0;
ARRAY<double> errors;
for (int k=0; k<50; k++) {
errors.clear();
double err = 0;
if (do_gauss_seidel) {
// Gauss-Seidel iteration: use updated values from the
// current iteration as they are computed...
for (int j=0; j<n; j++) {
// don't need that L[] array...
Wpt limit;
verts[j]->limit_loc(limit);
Wvec delt = C[j] - limit;
errors+=delt.length();
err += delt.length();
if(move_along_normal)
delt = delt*verts[j]->norm()*verts[j]->norm();
verts[j]->offset_loc(delt);
}
} else {
// compute the new offsets from the offsets computed in the
// previous iteration
int j;
for (j=0; j<n; j++)
verts[j]->limit_loc(L[j]);
for (j=0; j<n; j++) {
Wvec delt = C[j] - L[j];
err += delt.length();
errors+=delt.length();
if(move_along_normal)
delt = delt*verts[j]->norm()*verts[j]->norm();
verts[j]->offset_loc(delt);
}
}
// compute the average error:
err /= n;
double avg,std_d,max,min;
if (debug) {
if (prev_err != 0) {
err_msg("Iter %d: avg error: %f, reduction: %f",
k, err, err/prev_err);
statistics(errors,true,&avg,&std_d,&max,&min);
} else {
err_msg("Iter %d: avg error: %f", k, err);
statistics(errors,true,&avg,&std_d,&max,&min);
}
} else
statistics(errors,false,&avg,&std_d,&max,&min);
prev_err = err;
if (max < max_err) {
if(debug) cerr << "Terminating at " << k <<" th iterations"<<endl;
return;
}
}
}
示例2: if
/////////////////////////////////////
// add()
/////////////////////////////////////
bool
HatchingGroupFixed::add(
CNDCpt_list &pl,
const ARRAY<double>&prl,
int curve_type
)
{
int k;
double a,b;
Bface *f;
// It happens:
if (pl.empty())
{
err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - Error: point list is empty!");
return false;
}
if (prl.empty())
{
err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - Error: pressure list is empty!");
return false;
}
if (pl.num() != prl.num())
{
err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - gesture pixel list and pressure list are not same length.");
return false;
}
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - smoothing gesture.");
//Smooth the input gesture
NDCpt_list smoothpts;
ARRAY<double> smoothprl;
if (!smooth_gesture(pl, smoothpts, prl, smoothprl, _params.anim_style()))
return false;
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - clipping gesture to model.");
NDCpt_list ndcpts;
ARRAY<double> finalprl;
clip_to_patch(smoothpts,ndcpts,smoothprl,finalprl);
ndcpts.update_length();
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed::add() - Checking gesture silliness.");
if (HatchingGroupBase::is_gesture_silly(ndcpts,_params.anim_style()))
{
err_mesg(ERR_LEV_WARN, "HatchingGroupFixed::add() - Punting silly gesture...");
return false;
}
//Even if the user wants to project to create the
//hatch, we continue with plane cutting to
//generate a curve we can use to estimate
//the mesh spacing so that the final projected
//hatch is sampled evenly on the level of the mesh
//spacing
//Get the cutting line
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - fitting line.");
if (!fit_line(ndcpts,a,b)) return false;
//Slide to midpoint if desired
if (Config::get_var_bool("HATCHING_GROUP_SLIDE_FIT",false,true))
b = ndcpts.interpolate(0.5)[1] - (a*ndcpts.interpolate(0.5)[0]);
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - computing plane.");
//Find the cutting plane
Wplane wpPlane;
f = compute_cutting_plane(_patch, a, b, ndcpts, wpPlane);
if (!f) return false;
else
{
if (!f->front_facing())
{
err_mesg(ERR_LEV_WARN, "HatchingGroupFixed::add() - Nearest pt. on fit line hit backfacing surface.");
return false;
}
}
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - slicing mesh.");
//Intersect the mesh to get a 3D curve
Wpt_list wlList;
slice_mesh_with_plane(f,wpPlane,wlList);
err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - cliping curve to gesture.");
//Clip end of 3D curve to match gesture
Wpt_list wlClipList;
clip_curve_to_stroke(_patch, ndcpts, wlList, wlClipList);
wlClipList.update_length();
Wpt_list wlScaledList;
//.........这里部分代码省略.........