00001
00002
00003
00004 #include "disp/colors.H"
00005 #include "std/config.H"
00006 #include "mi.H"
00007
00008 using namespace mlib;
00009
00010 inline void
00011 set_base_colors(CBvert_list& verts, CCOLOR& col)
00012 {
00013 for (int i=0; i<verts.num(); i++)
00014 verts[i]->set_color(col, 1);
00015 }
00016
00017 inline void
00018 add_shading(CBvert_list& verts, Wvec l, CCOLOR& col, double s = 1.0)
00019 {
00020
00021
00022 l = l.normalized();
00023 for (int i=0; i<verts.num(); i++) {
00024 double a = pow(max(l * verts[i]->norm(), 0.0), s);
00025 if (a > 0)
00026 verts[i]->set_color(interp(verts[i]->color(), col, a), 1);
00027 }
00028 }
00029
00030 inline void
00031 color_verts(CBvert_list& verts)
00032 {
00033 set_base_colors(verts, Color::blue2);
00034
00035 add_shading(verts, Wvec( 1, 1, 1), Color::orange1, 2.0);
00036 add_shading(verts, Wvec(-1, 1, -1), Color::blue4, 1.0);
00037 add_shading(verts, Wvec( 0, -1, 0), Color::blue1, 1.0);
00038 }
00039
00040 int
00041 main(int argc, char *argv[])
00042 {
00043 if (argc != 1) {
00044 err_msg("Usage: %s < input.sm > output.sm", argv[0]);
00045 return 1;
00046 }
00047
00048 BMESHptr mesh = BMESH::read_jot_stream(cin);
00049 if (!mesh || mesh->empty())
00050 return 1;
00051
00052
00053 mesh->remove_duplicate_vertices(false);
00054
00055 if (Config::get_var_bool("JOT_PRINT_MESH"))
00056 mesh->print();
00057
00058 color_verts(mesh->verts());
00059
00060 mesh->write_stream(cout);
00061
00062 return 0;
00063 }
00064
00065