00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "std/config.H"
00014 #include "mi.H"
00015
00016 int
00017 main(int argc, char *argv[])
00018 {
00019 if (argc != 2)
00020 {
00021 err_msg("Usage: %s input-mesh.sm", argv[0]);
00022 return 1;
00023 }
00024
00025 ifstream fin;
00026 fin.open(argv[1]);
00027 if (!fin) {
00028 err_ret( "%s: Error: Could not open file %s", argv[0], argv[1]);
00029 return 0;
00030 }
00031
00032
00033
00034 char mesh_name[1024];
00035 strcpy(mesh_name, argv[1]);
00036 int n = strlen(mesh_name);
00037 if (n < 4)
00038 {
00039 err_msg("%s: Can't decipher name %s", argv[0], mesh_name);
00040 return 1;
00041 }
00042 mesh_name[n - 3] = 0;
00043
00044 str_ptr mesh_path = str_ptr(mesh_name);
00045
00046 BMESHptr mesh = BMESH::read_jot_stream(fin);
00047 if (!mesh || mesh->empty())
00048 return 1;
00049 fin.close();
00050
00051
00052 mesh->remove_duplicate_vertices(false);
00053
00054
00055 ARRAY<BMESH*> meshes = mesh->split_components();
00056
00057 err_msg("got %d meshes", meshes.num());
00058
00059 str_ptr out_mesh = mesh_path + str_ptr(0) + str_ptr(".sm");
00060 cerr << "\nwriting " << **out_mesh << endl;
00061 if (Config::get_var_bool("JOT_RECENTER"))
00062 mesh->recenter();
00063 mesh->write_file(**out_mesh);
00064
00065 for (int i=0; i<meshes.num(); i++) {
00066 out_mesh = mesh_path + str_ptr(i + 1) + str_ptr(".sm");
00067 cerr << "\nwriting " << **out_mesh << endl;
00068 if (Config::get_var_bool("JOT_RECENTER"))
00069 meshes[i]->recenter();
00070 meshes[i]->write_file(**out_mesh);
00071 }
00072
00073 return 0;
00074 }
00075
00076