[brlcad-commits] SF.net SVN: brlcad:[39751] brlcad/trunk/src/conv/obj-g_new.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <r_...@us...> - 2010-06-30 15:18:46
|
Revision: 39751 http://brlcad.svn.sourceforge.net/brlcad/?rev=39751&view=rev Author: r_weiss Date: 2010-06-30 15:18:38 +0000 (Wed, 30 Jun 2010) Log Message: ----------- reversed stop-on-nmg-bomb option, added and updated function documentation Modified Paths: -------------- brlcad/trunk/src/conv/obj-g_new.c Modified: brlcad/trunk/src/conv/obj-g_new.c =================================================================== --- brlcad/trunk/src/conv/obj-g_new.c 2010-06-30 02:11:43 UTC (rev 39750) +++ brlcad/trunk/src/conv/obj-g_new.c 2010-06-30 15:18:38 UTC (rev 39751) @@ -43,27 +43,8 @@ #include "wdb.h" #include "obj_parser.h" -#if 0 -/* TODO: This logic needs to be reversed. If the user-specified - * grouping option cannot be fulfilled, the application should abort. - * It should not try to continue under a different method than the one - * they specified just because it can complete. - * - * Instead of -s to stop, perhaps a -c option to continue processing - * on nmg bomb. - */ +static char *usage = "%s -u units_str -o open_bot_type -h plate_thickness [-cipdv] [-g grouping_option] [-m mode_option] [-t distance_tolerance] [-x rt_debug_flag] [-X NMG_debug_flag] input.obj output.g\n\ \n\ - -s Stop processing on nmg bomb. If this option is set and\n\ - an nmg bomb occurs (i.e. fatal error during processing\n\ - nmg or bot-via-nmg) all processing will stop and the\n\ - converter will exit. If this option is not set, if an\n\ - nmg bomb occurs, conversion will fall back to outputing\n\ - the grouping to 'native-bot' and then continue\n\ - processing the next grouping.\n\ -#endif - -static char *usage = "%s -u units_str -o open_bot_type -h plate_thickness [-ipdv] [-g grouping_option] [-m mode_option] [-t distance_tolerance] [-x rt_debug_flag] [-X NMG_debug_flag] input.obj output.g\n\ -\n\ -u units_str Units of obj file where units_str can\n\ be any valid BRL-CAD unit such as one\n\ of the following {m|cm|mm|ft|in} or\n\ @@ -81,6 +62,14 @@ or plate-nocos bots created when the\n\ bot is not a closed volume.\n\ \n\ + -c Continue processing on nmg-bomb. If this option is set\n\ + and an nmg-bomb occurs (i.e. fatal error during\n\ + processing nmg or bot-via-nmg) conversion will fall-back\n\ + to outputing the grouping to 'native-bot' and then\n\ + continue processing the next grouping. If this option is\n\ + not set and an nmg-bomb occurs then all processing will\n\ + stop and the converter will exit.\n\ +\n\ -i Ignore normals defined in the obj file when the\n\ conversion mode is 'native-bots'.\n\ \n\ @@ -242,7 +231,7 @@ size_t num_vertex_fuse; /* number of elements in vertex_fuse_map and vertex_fuse_flag arrays */ size_t *texture_vertex_fuse_map; /* same as vertex_fuse_map but for texture vertex */ short int *texture_vertex_fuse_flag; /* same as vertex_fuse_flag but for texture vertex */ - size_t texture_vertex_fuse_offset /* same as vertex_fuse_offset but for texture vertex */ + size_t texture_vertex_fuse_offset;/* same as vertex_fuse_offset but for texture vertex */ size_t num_texture_vertex_fuse; /* same as num_vertex_fuse but for texture vertex */ }; @@ -632,7 +621,18 @@ return failed_face_count; } - +/* + * F I N D _ L A S T _ U N I Q U E _ V E R T E X + * + * Returns the number of vertices in a face where the last vertex in + * the vertex list is not the same as the first vertex. Essentially + * this function finds the last unique vertex of the face. If the + * returned count is used to indicate the number of vertices in the + * face, the result is trailing vertices in the face which are + * identical to the first vertex will be removed. This function + * is a support function for the test_face function and allows some + * cases of zero length edges to be removed from a face. + */ size_t find_last_unique_vertex(struct ga_t *ga, /* obj file global attributes */ struct gfi_t *gfi, /* grouping face indices */ @@ -692,13 +692,18 @@ * extensive test. Return codes for tests are below. Note: the stored * test result value is the return code plus one, since 0 in the * results list indicates an untested face and one indicates a valid - * face. + * face. This function also removes trailing vertices from a face + * which are identical to the first vertex in the face resulting in + * zero length edges being removed when this condition occurs. * * Returns: * 0 valid face * 1 degenerate, <3 vertices * 2 degenerate, duplicate vertex indexes * 3 degenerate, vertices too close + * + * Recommended function improvements: + * - Optionally remove all zero length edges from a face */ int test_face(struct ga_t *ga, @@ -3019,18 +3024,20 @@ return; } - /* * P R O C E S S _ N V _ M O D E _ O P T I O N * * This function is executed from main when the user selects mode * option 'n' or 'v' from the command line. The 'n' indicates output - * to nmg and 'v' indicates output to volume-mode-bot via nmg. If nmg - * or volume-mode-bot creation fails, output will be attempted to - * 'native bot'. If stop_on_nmg_bomb_flag is set to true, no primitive - * will be output if an nmg bomb occurs. A return value of 0 indicates - * no nmg bomb occured, a return of 1 indicates an nmg bomb occured - * and stop_on_nmg_bomb_flag was set to true. + * to nmg and 'v' indicates output to volume-mode-bot via nmg. If + * during nmg or volume-mode-bot creation a 'no closure' condition is + * encountered, output of the grouping will be attempted to + * 'native bot'. If during nmg or volume-mode-bot creation an nmg-bomb + * occurs then no primitive will be output unless cont_on_nmg_bomb is + * set to true which will then cause output of the grouping to be + * attempted to 'native bot'. A return value of 0 indicates no + * nmg-bomb occured, a return of 1 indicates an nmg-bomb occured + * and cont_on_nmg_bomb_flag was set to false. */ int process_nv_mode_option(struct ga_t *ga, @@ -3048,12 +3055,12 @@ int native_face_test_type, /* output_to_bot (i.e. native) face_test_type * TEST_ALL, TEST_NUM_VERT */ - int stop_on_nmg_bomb_flag) + int cont_on_nmg_bomb_flag) { int ret = 0; ret = output_to_nmg(ga, gfi, outfp, conv_factor, tol, IGNR_NORM, nmg_output_mode, nmg_face_test_type); - if ((ret == 1) || ((ret == 2) && !stop_on_nmg_bomb_flag)) { + if ((ret == 1) || ((ret == 2) && cont_on_nmg_bomb_flag)) { (void)fuse_vertex(ga, gfi, conv_factor, tol, FUSE_VERT, FUSE_WI_TOL); (void)retest_grouping_faces(ga, gfi, conv_factor, native_face_test_type, tol); if (!test_closure(ga, gfi, conv_factor, plot_mode, native_face_test_type, tol)) { @@ -3068,7 +3075,7 @@ /* convert output_to_nmg return code to process_nv_mode_option * return code */ - if ((ret == 2) && stop_on_nmg_bomb_flag) { + if ((ret == 2) && !cont_on_nmg_bomb_flag) { ret = 1; } else { ret = 0; @@ -3099,7 +3106,7 @@ double dist_tmp = 0.0; struct bn_tol tol_struct; struct bn_tol *tol; - int stop_on_nmg_bomb_flag = 0; /* default: if true, stop processing on nmg bomb */ + int cont_on_nmg_bomb_flag = 0; /* default: if true, continue processing on nmg-bomb */ int stop_processing_flag = 0; int nmg_face_test_type = TEST_NUM_VERT; /* default */ int native_face_test_type = TEST_ALL; /* default */ @@ -3139,10 +3146,10 @@ bu_exit(1, usage, argv[0]); } - while ((c = bu_getopt(argc, argv, "spidx:X:vt:h:m:u:g:o:")) != EOF) { + while ((c = bu_getopt(argc, argv, "cpidx:X:vt:h:m:u:g:o:")) != EOF) { switch (c) { - case 's': /* stop processing on nmg bomb */ - stop_on_nmg_bomb_flag = 1; + case 'c': /* continue processing on nmg bomb */ + cont_on_nmg_bomb_flag = 1; break; case 'p': /* create plot files for open edges */ plot_mode = PLOT_ON; @@ -3343,17 +3350,17 @@ } if (mode_option != 'b') { - if (stop_on_nmg_bomb_flag) { - bu_log("\tStop on nmg bomb enabled\n"); + if (cont_on_nmg_bomb_flag) { + bu_log("\tContinue on nmg-bomb enabled\n"); } else { - bu_log("\tStop on nmg bomb disabled\n"); + bu_log("\tContinue on nmg-bomb disabled\n"); } } if (plot_mode == PLOT_ON) { - bu_log("\tOpen edges plotted\n"); + bu_log("\tPlot open edges enabled\n"); } else { - bu_log("\tOpen edges NOT plotted\n"); + bu_log("\tPlot open edges disabled\n"); } if (verbose) { @@ -3452,7 +3459,7 @@ case 'v': stop_processing_flag = process_nv_mode_option(&ga, gfi, fd_out, conv_factor, tol, bot_thickness, nmg_output_mode, plot_mode, open_bot_output_mode, - nmg_face_test_type, native_face_test_type, stop_on_nmg_bomb_flag); + nmg_face_test_type, native_face_test_type, cont_on_nmg_bomb_flag); break; } @@ -3494,7 +3501,7 @@ case 'v': stop_processing_flag = process_nv_mode_option(&ga, gfi, fd_out, conv_factor, tol, bot_thickness, nmg_output_mode, plot_mode, open_bot_output_mode, - nmg_face_test_type, native_face_test_type, stop_on_nmg_bomb_flag); + nmg_face_test_type, native_face_test_type, cont_on_nmg_bomb_flag); break; } @@ -3539,7 +3546,7 @@ case 'v': stop_processing_flag = process_nv_mode_option(&ga, gfi, fd_out, conv_factor, tol, bot_thickness, nmg_output_mode, plot_mode, open_bot_output_mode, - nmg_face_test_type, native_face_test_type, stop_on_nmg_bomb_flag); + nmg_face_test_type, native_face_test_type, cont_on_nmg_bomb_flag); break; } @@ -3584,7 +3591,7 @@ case 'v': stop_processing_flag = process_nv_mode_option(&ga, gfi, fd_out, conv_factor, tol, bot_thickness, nmg_output_mode, plot_mode, open_bot_output_mode, - nmg_face_test_type, native_face_test_type, stop_on_nmg_bomb_flag); + nmg_face_test_type, native_face_test_type, cont_on_nmg_bomb_flag); break; } @@ -3629,7 +3636,7 @@ case 'v': stop_processing_flag = process_nv_mode_option(&ga, gfi, fd_out, conv_factor, tol, bot_thickness, nmg_output_mode, plot_mode, open_bot_output_mode, - nmg_face_test_type, native_face_test_type, stop_on_nmg_bomb_flag); + nmg_face_test_type, native_face_test_type, cont_on_nmg_bomb_flag); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |