Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qinv.C

Go to the documentation of this file.
00001 /**********************************************************************
00002  * qinv.C:
00003  *
00004  *   Do quasi-interlopolation using Loop subdivision
00005  **********************************************************************/
00006 #include "std/config.H"
00007 #include "mi.H"
00008 #include "lmesh.H"
00009 
00010 inline Wpt
00011 qinv_loc(CBvert* v)
00012 {
00013    return v->loc() + (v->loc() - LoopLoc().limit_val(v));
00014 }
00015 
00016 inline Wpt_list
00017 qinv_locs(LMESHptr mesh)
00018 {
00019    assert(mesh);
00020    Wpt_list ret(mesh->nverts());
00021    for (int i=0; i<mesh->nverts(); i++) {
00022       ret += qinv_loc(mesh->bv(i));
00023    }
00024    return ret;
00025 }
00026 
00027 inline Wpt_list
00028 limit_locs(LMESHptr mesh)
00029 {
00030    assert(mesh);
00031    Wpt_list ret(mesh->nverts());
00032    for (int i=0; i<mesh->nverts(); i++) {
00033       ret += LoopLoc().limit_val(mesh->bv(i));
00034    }
00035    return ret;
00036 }
00037 
00038 inline void
00039 set_locs(LMESHptr mesh, CWpt_list& pts)
00040 {
00041    assert(mesh && mesh->nverts() == pts.num());
00042 
00043    for (int i=0; i<mesh->nverts(); i++)
00044       mesh->bv(i)->set_loc(pts[i]);
00045    mesh->changed(BMESH::VERT_POSITIONS_CHANGED);
00046 }
00047 
00048 int 
00049 main(int argc, char *argv[])
00050 {
00051    // if -l flag is used, output limit locations
00052    bool do_limit = false;
00053    if (argc == 2 && str_ptr("-l") == argv[1]) {
00054       do_limit = true;
00055    } else if (argc != 1) {
00056       err_msg("Usage: %s < mesh.sm > mesh-qinv.sm", argv[0]);
00057       return 1;
00058    }
00059 
00060    LMESHptr mesh = LMESH::read_jot_stream(cin);
00061    if (!mesh || mesh->empty())
00062       return 1; // didn't work
00063    mesh->set_subdiv_loc_calc(new LoopLoc());
00064 
00065    if (Config::get_var_bool("JOT_PRINT_MESH")) {
00066       cerr << "input mesh:" << endl;
00067       mesh->print();
00068    }
00069    if (do_limit) {
00070       cerr << "outputting limit positions" << endl;
00071       set_locs(mesh, limit_locs(mesh));
00072    } else {
00073       set_locs(mesh, qinv_locs(mesh));
00074    }
00075 
00076    mesh->write_stream(cout);
00077 
00078    return 0;
00079 }
00080 
00081 // end of file qinv.C

Generated on Mon Sep 18 11:39:33 2006 for jot by  doxygen 1.4.4