00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "std/config.H"
00013 #include "mi.H"
00014
00015 int
00016 main(int argc, char *argv[])
00017 {
00018
00019 bool do_components = false;
00020 if (argc == 2 && str_ptr(argv[1]) == str_ptr("-c")) {
00021 do_components = true;
00022 } else if (argc != 1) {
00023 err_msg("Usage: %s [ -c ] < input.sm > output.sm", argv[0]);
00024 return 1;
00025 }
00026
00027 BMESHptr mesh = BMESH::read_jot_stream(cin);
00028 if (!mesh || mesh->empty())
00029 return 1;
00030
00031 if (do_components) {
00032
00033 bool changed = false;
00034 ARRAY<Bface_list> components = mesh->get_components();
00035 for (int i=0; i<components.num(); i++) {
00036 if (components[i].volume() < 0) {
00037 err_msg("reversing component: %d faces", components[i].num());
00038 reverse_faces(components[i]);
00039 changed = true;
00040 }
00041 }
00042 if (changed) {
00043 mesh->changed();
00044 } else {
00045 err_msg("%s: nothing changed", argv[0]);
00046 }
00047 } else {
00048
00049 mesh->reverse();
00050 }
00051
00052 mesh->write_stream(cout);
00053
00054 return 0;
00055 }