本文整理汇总了C++中LMESHptr::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ LMESHptr::empty方法的具体用法?C++ LMESHptr::empty怎么用?C++ LMESHptr::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LMESHptr
的用法示例。
在下文中一共展示了LMESHptr::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
main(int argc, char *argv[])
{
int num_levels = 1;
if (argc == 2)
num_levels = max(atoi(argv[1]), 0);
else if(argc != 1) {
err_msg("Usage: %s [ num_levels ] < mesh.sm > mesh-sub.sm", argv[0]);
return 1;
}
LMESHptr mesh = LMESH::read_jot_stream(cin);
if (!mesh || mesh->empty())
return 1; // didn't work
mesh->set_subdiv_loc_calc(new LoopLoc());
if (Config::get_var_bool("JOT_PRINT_MESH")) {
cerr << "input mesh:" << endl;
mesh->print();
}
if (num_levels > 0)
mesh->update_subdivision(num_levels);
if (Config::get_var_bool("JOT_PRINT_MESH")) {
cerr << "level " << num_levels << " mesh:" << endl;
mesh->cur_mesh()->print();
}
mesh->cur_mesh()->write_stream(cout);
return 0;
}
示例2: if
int
main(int argc, char *argv[])
{
bool do_gauss_seidel = 0;
if (argc == 2 && str_ptr(argv[1]) == str_ptr("-g"))
do_gauss_seidel = 1;
else if(argc != 1)
{
err_msg("Usage: %s [ -g ] < mesh.sm > mesh-fit.sm", argv[0]);
return 1;
}
LMESHptr mesh = LMESH::read_jot_stream(cin);
if (!mesh || mesh->empty())
return 1; // didn't work
fit(mesh, do_gauss_seidel);
mesh->write_stream(cout);
return 0;
}
示例3: C
void
fit(LMESHptr& mesh, bool do_gauss_seidel)
{
if (mesh->empty())
return;
// time this
stop_watch clock;
double max_err = mesh->get_bb().dim().length() * 1e-5;
int n = mesh->nverts();
// get original control point locations
Wpt_list C(n); // original control points
Wpt_list L(n); // current limit points
for (int i=0; i<n; i++) {
C += mesh->bv(i)->loc();
L += Wpt::Origin();
}
// do 50 iterations...
double prev_err = 0;
for (int k=0; k<50; k++) {
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;
mesh->lv(j)->limit_loc(limit);
Wvec delt = C[j] - limit;
err += delt.length();
mesh->bv(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++)
mesh->lv(j)->limit_loc(L[j]);
for (j=0; j<n; j++) {
Wvec delt = C[j] - L[j];
err += delt.length();
mesh->bv(j)->offset_loc(delt);
}
}
// compute the average error:
err /= n;
if (prev_err != 0) {
err_msg("Iter %d: avg error: %f, reduction: %f",
k, err, err/prev_err);
} else {
err_msg("Iter %d: avg error: %f", k, err);
}
prev_err = err;
if (err < max_err)
break;
}
err_msg("fitting took %.2f seconds", clock.elapsed_time());
}