[brlcad-commits] SF.net SVN: brlcad:[51678] brlcad/trunk/src
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2012-07-26 01:25:09
|
Revision: 51678 http://brlcad.svn.sourceforge.net/brlcad/?rev=51678&view=rev Author: brlcad Date: 2012-07-26 01:25:01 +0000 (Thu, 26 Jul 2012) Log Message: ----------- ws Modified Paths: -------------- brlcad/trunk/src/libbn/bntester.c brlcad/trunk/src/libbn/plane.c brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c brlcad/trunk/src/libbu/tests/bu_basename.c brlcad/trunk/src/libbu/tests/bu_bitv_or.c brlcad/trunk/src/libbu/tests/bu_booleanize.c brlcad/trunk/src/libbu/tests/bu_dirname.c brlcad/trunk/src/libbu/tests/bu_escape.c brlcad/trunk/src/libbu/tests/bu_progname.c brlcad/trunk/src/libbu/tests/bu_str_isprint.c brlcad/trunk/src/libbu/tests/bu_vls_vprintf.c Modified: brlcad/trunk/src/libbn/bntester.c =================================================================== --- brlcad/trunk/src/libbn/bntester.c 2012-07-26 01:17:30 UTC (rev 51677) +++ brlcad/trunk/src/libbn/bntester.c 2012-07-26 01:25:01 UTC (rev 51678) @@ -47,87 +47,87 @@ fmt_str_len = strlen(fmt_str); for (idx = 0 ; idx < fmt_str_len ; idx++) { - buf_p = strtok(NULL, ", "); + buf_p = strtok(NULL, ", "); - /* The variable buf_p should never become NULL since the for loop - * will exit just before we run out of data if all the required - * data is supplied in the data file. - */ - if (buf_p == NULL) { - (void)fprintf(stream, "ERROR: Missing parameter(s) for test case on line %lu, skipping test case.\n", line_num); - return EXIT_FAILURE; - } + /* The variable buf_p should never become NULL since the for loop + * will exit just before we run out of data if all the required + * data is supplied in the data file. + */ + if (buf_p == NULL) { + (void)fprintf(stream, "ERROR: Missing parameter(s) for test case on line %lu, skipping test case.\n", line_num); + return EXIT_FAILURE; + } - errno = 0; - switch (fmt_str[idx]) { - case 'd' : /* double */ - d[d_idx] = strtod(buf_p, &endp); - if (errno) { - (void)fprintf(stream, "Convert to double failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", + errno = 0; + switch (fmt_str[idx]) { + case 'd' : /* double */ + d[d_idx] = strtod(buf_p, &endp); + if (errno) { + (void)fprintf(stream, "Convert to double failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", u[0], line_num, idx+2, strerror(errno), buf_p); - return EXIT_FAILURE; - } - if ((*endp != '\0') || (buf_p == endp)) { - (void)fprintf(stream, "Convert to double failed, function %lu test case on line %lu parameter %d string '%s'\n", + return EXIT_FAILURE; + } + if ((*endp != '\0') || (buf_p == endp)) { + (void)fprintf(stream, "Convert to double failed, function %lu test case on line %lu parameter %d string '%s'\n", u[0], line_num, idx+2, buf_p); - return EXIT_FAILURE; - } - d_idx++; - break; - case 'l' : /* long int */ - l[l_idx] = strtol(buf_p, &endp, 10); - if (errno) { - (void)fprintf(stream, "Convert to long int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", + return EXIT_FAILURE; + } + d_idx++; + break; + case 'l' : /* long int */ + l[l_idx] = strtol(buf_p, &endp, 10); + if (errno) { + (void)fprintf(stream, "Convert to long int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", u[0], line_num, idx+2, strerror(errno), buf_p); - return EXIT_FAILURE; - } - if ((*endp != '\0') || (buf_p == endp)) { - (void)fprintf(stream, "Convert to long int failed, function %lu test case on line %lu parameter %d string '%s'\n", + return EXIT_FAILURE; + } + if ((*endp != '\0') || (buf_p == endp)) { + (void)fprintf(stream, "Convert to long int failed, function %lu test case on line %lu parameter %d string '%s'\n", u[0], line_num, idx+2, buf_p); - return EXIT_FAILURE; - } - l_idx++; - break; - case 'i' : /* int */ - l_tmp = strtol(buf_p, &endp, 10); - if (errno) { - (void)fprintf(stream, "Convert to int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", + return EXIT_FAILURE; + } + l_idx++; + break; + case 'i' : /* int */ + l_tmp = strtol(buf_p, &endp, 10); + if (errno) { + (void)fprintf(stream, "Convert to int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", u[0], line_num, idx+2, strerror(errno), buf_p); - return EXIT_FAILURE; - } - if ((*endp != '\0') || (buf_p == endp)) { - (void)fprintf(stream, "Convert to int failed, function %lu test case on line %lu parameter %d string '%s'\n", + return EXIT_FAILURE; + } + if ((*endp != '\0') || (buf_p == endp)) { + (void)fprintf(stream, "Convert to int failed, function %lu test case on line %lu parameter %d string '%s'\n", u[0], line_num, idx+2, buf_p); - return EXIT_FAILURE; - } - if (l_tmp > INT_MAX || l_tmp < INT_MIN) { - (void)fprintf(stream, "Convert to int failed (under/over flow), function %lu test case on line %lu parameter %d string '%s'\n", + return EXIT_FAILURE; + } + if (l_tmp > INT_MAX || l_tmp < INT_MIN) { + (void)fprintf(stream, "Convert to int failed (under/over flow), function %lu test case on line %lu parameter %d string '%s'\n", u[0], line_num, idx+2, buf_p); - return EXIT_FAILURE; - } - i[i_idx] = (int)l_tmp; - i_idx++; - break; - case 'u' : /* unsigned long */ - u[u_idx] = strtoul(buf_p, &endp, 10); - if (errno) { - (void)fprintf(stream, "Convert to unsigned long int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", + return EXIT_FAILURE; + } + i[i_idx] = (int)l_tmp; + i_idx++; + break; + case 'u' : /* unsigned long */ + u[u_idx] = strtoul(buf_p, &endp, 10); + if (errno) { + (void)fprintf(stream, "Convert to unsigned long int failed, function %lu test case on line %lu parameter %d error msg: '%s' string '%s'\n", u[0], line_num, idx+2, strerror(errno), buf_p); - return EXIT_FAILURE; - } - if ((*endp != '\0') || (buf_p == endp) || (strchr(buf_p, '-') != '\0')) { - (void)fprintf(stream, "Convert to unsigned long int failed, function %lu test case on line %lu parameter %d string '%s'\n", + return EXIT_FAILURE; + } + if ((*endp != '\0') || (buf_p == endp) || (strchr(buf_p, '-') != '\0')) { + (void)fprintf(stream, "Convert to unsigned long int failed, function %lu test case on line %lu parameter %d string '%s'\n", u[0], line_num, idx+2, buf_p); - return EXIT_FAILURE; - } - u_idx++; - break; - default: - (void)fprintf(stream, "INTERNAL ERROR: Unknown data type '%c' for function %lu test case on line %lu, skipping test case.\n", + return EXIT_FAILURE; + } + u_idx++; + break; + default: + (void)fprintf(stream, "INTERNAL ERROR: Unknown data type '%c' for function %lu test case on line %lu, skipping test case.\n", fmt_str[idx], u[0], line_num); - return EXIT_FAILURE; - break; - } /* End of data format switch */ + return EXIT_FAILURE; + break; + } /* End of data format switch */ } /* End of for loop traversing data format string */ return 0; @@ -187,140 +187,140 @@ if (argc < 2) { - bu_log("Too few parameters, %d specified, at least 1 required\n", argc - 1); - bu_exit(EXIT_FAILURE, USAGE); + bu_log("Too few parameters, %d specified, at least 1 required\n", argc - 1); + bu_exit(EXIT_FAILURE, USAGE); } while ((c = bu_getopt(argc, argv, "l:f:i:o:")) != -1) { - switch (c) { - case 'l': /* test case line number */ - errno = 0; - test_case_line_num = strtoul(bu_optarg, &endp, 10); - if (errno) { - bu_log("Invalid test case line number '%s' '%s'\n", bu_optarg, strerror(errno)); - bu_exit(EXIT_FAILURE, USAGE); - } - if ((*endp != '\0') || (bu_optarg == endp) || (strchr(bu_optarg, '-') != '\0')) { - bu_log("Invalid test case line number '%s'\n", bu_optarg); - bu_exit(EXIT_FAILURE, USAGE); - } - process_single_test_case = 1; - break; - case 'f': /* function number */ - errno = 0; - function_num = strtoul(bu_optarg, &endp, 10); - if (errno) { - bu_log("Invalid function number '%s' '%s'\n", bu_optarg, strerror(errno)); - bu_exit(EXIT_FAILURE, USAGE); - } - if ((*endp != '\0') || (bu_optarg == endp) || (strchr(bu_optarg, '-') != '\0')) { - bu_log("Invalid function number '%s'\n", bu_optarg); - bu_exit(EXIT_FAILURE, USAGE); - } - process_single_function = 1; - break; - case 'i': /* input file name */ - string_length = strlen(bu_optarg); - if (string_length >= BUFSIZ) { - bu_log("Input file name too long, length was %d but must be less than %d\n", + switch (c) { + case 'l': /* test case line number */ + errno = 0; + test_case_line_num = strtoul(bu_optarg, &endp, 10); + if (errno) { + bu_log("Invalid test case line number '%s' '%s'\n", bu_optarg, strerror(errno)); + bu_exit(EXIT_FAILURE, USAGE); + } + if ((*endp != '\0') || (bu_optarg == endp) || (strchr(bu_optarg, '-') != '\0')) { + bu_log("Invalid test case line number '%s'\n", bu_optarg); + bu_exit(EXIT_FAILURE, USAGE); + } + process_single_test_case = 1; + break; + case 'f': /* function number */ + errno = 0; + function_num = strtoul(bu_optarg, &endp, 10); + if (errno) { + bu_log("Invalid function number '%s' '%s'\n", bu_optarg, strerror(errno)); + bu_exit(EXIT_FAILURE, USAGE); + } + if ((*endp != '\0') || (bu_optarg == endp) || (strchr(bu_optarg, '-') != '\0')) { + bu_log("Invalid function number '%s'\n", bu_optarg); + bu_exit(EXIT_FAILURE, USAGE); + } + process_single_function = 1; + break; + case 'i': /* input file name */ + string_length = strlen(bu_optarg); + if (string_length >= BUFSIZ) { + bu_log("Input file name too long, length was %d but must be less than %d\n", string_length, BUFSIZ); - bu_exit(EXIT_FAILURE, USAGE); - } - bu_vls_strcpy(&input_file_name, bu_optarg); - input_file_name_defined = 1; - break; - case 'o': /* output file name */ - string_length = strlen(bu_optarg); - if (string_length >= BUFSIZ) { - bu_log("Output file name too long, length was %d but must be less than %d\n", + bu_exit(EXIT_FAILURE, USAGE); + } + bu_vls_strcpy(&input_file_name, bu_optarg); + input_file_name_defined = 1; + break; + case 'o': /* output file name */ + string_length = strlen(bu_optarg); + if (string_length >= BUFSIZ) { + bu_log("Output file name too long, length was %d but must be less than %d\n", string_length, BUFSIZ); - bu_exit(EXIT_FAILURE, USAGE); - } - bu_vls_strcpy(&output_file_name, bu_optarg); - output_file_name_defined = 1; - break; - default: - bu_log("Invalid option '%c'.\n", c); - bu_exit(EXIT_FAILURE, USAGE); - break; - } + bu_exit(EXIT_FAILURE, USAGE); + } + bu_vls_strcpy(&output_file_name, bu_optarg); + output_file_name_defined = 1; + break; + default: + bu_log("Invalid option '%c'.\n", c); + bu_exit(EXIT_FAILURE, USAGE); + break; + } } if (process_single_test_case && process_single_function) { - bu_log("Can not specify both test case line number and function number.\n"); - early_exit = 1; + bu_log("Can not specify both test case line number and function number.\n"); + early_exit = 1; } if (!input_file_name_defined) { - bu_log("Input file name is required but was not specified.\n"); - early_exit = 1; + bu_log("Input file name is required but was not specified.\n"); + early_exit = 1; } if (early_exit) { bu_vls_free(&input_file_name); bu_vls_free(&output_file_name); - bu_exit(EXIT_FAILURE, USAGE); + bu_exit(EXIT_FAILURE, USAGE); } if ((fp_in = fopen(bu_vls_addr(&input_file_name), "r")) == NULL) { - bu_log("Cannot open input file (%V)\n", &input_file_name); + bu_log("Cannot open input file (%V)\n", &input_file_name); bu_vls_free(&input_file_name); bu_vls_free(&output_file_name); - return EXIT_FAILURE; + return EXIT_FAILURE; } if (output_file_name_defined) { - if ((stream = fopen(bu_vls_addr(&output_file_name), "w")) == NULL) { - bu_log("Cannot create output file (%V)\n", &output_file_name); - if (fclose(fp_in) != 0) { - bu_log("Unable to close input file.\n"); - } + if ((stream = fopen(bu_vls_addr(&output_file_name), "w")) == NULL) { + bu_log("Cannot create output file (%V)\n", &output_file_name); + if (fclose(fp_in) != 0) { + bu_log("Unable to close input file.\n"); + } bu_vls_free(&input_file_name); bu_vls_free(&output_file_name); - return EXIT_FAILURE; - } + return EXIT_FAILURE; + } } else { - stream = stderr; + stream = stderr; } /* all output after this point is sent to stream */ (void)fprintf(stream, "Command line parameters: bntester "); for (argv_idx = 1 ; argv_idx < argc ; argv_idx++) { - (void)fprintf(stream, "%s ", argv[argv_idx]); + (void)fprintf(stream, "%s ", argv[argv_idx]); } (void)fprintf(stream, "\n"); if (process_single_test_case) { - (void)fprintf(stream, "Processing only test case on line number: %lu\n", test_case_line_num); + (void)fprintf(stream, "Processing only test case on line number: %lu\n", test_case_line_num); } if (process_single_function) { - (void)fprintf(stream, "Processing all test cases for function number: %lu\n", function_num); + (void)fprintf(stream, "Processing all test cases for function number: %lu\n", function_num); } if (!process_single_test_case && !process_single_function) { - (void)fprintf(stream, "Processing all test cases.\n"); + (void)fprintf(stream, "Processing all test cases.\n"); } while (!found_eof) { - if (line_num == ULONG_MAX) { - (void)fprintf(stream, "ERROR: Input data file exceeded max %lu number of lines.\n", ULONG_MAX); - if (fclose(fp_in) != 0) { - (void)fprintf(stream, "Unable to close input file.\n"); - } - if (output_file_name_defined) { - if (fclose(stream) != 0) { - bu_log("Unable to close output file.\n"); - } - } + if (line_num == ULONG_MAX) { + (void)fprintf(stream, "ERROR: Input data file exceeded max %lu number of lines.\n", ULONG_MAX); + if (fclose(fp_in) != 0) { + (void)fprintf(stream, "Unable to close input file.\n"); + } + if (output_file_name_defined) { + if (fclose(stream) != 0) { + bu_log("Unable to close output file.\n"); + } + } bu_vls_free(&input_file_name); bu_vls_free(&output_file_name); - return EXIT_FAILURE; - } - line_num++; + return EXIT_FAILURE; + } + line_num++; if (bu_fgets(buf, BUFSIZ, fp_in) == NULL) { if (feof(fp_in)) { found_eof = 1; @@ -338,238 +338,238 @@ bu_vls_free(&output_file_name); return EXIT_FAILURE; } else { - /* Skip input data file lines which start with a '#' character - * or a new line character. - */ - if ((buf[0] != '#') && (buf[0] != '\n')) { - buf_p1 = strtok(buf, "\n"); - buf_p = strtok(buf_p1, ", "); + /* Skip input data file lines which start with a '#' character + * or a new line character. + */ + if ((buf[0] != '#') && (buf[0] != '\n')) { + buf_p1 = strtok(buf, "\n"); + buf_p = strtok(buf_p1, ", "); - /* The 1st parameter of the test case is alway an unsigned - * long int which represents the function number. This logic - * validates the test case function number to ensure it is - * an unsigned long int. - */ - valid_function_number = 1; - errno = 0; - u[0] = strtoul(buf_p, &endp, 10); - if (errno) { - (void)fprintf(stream, "Read function number failed, line %lu error msg: '%s' string '%s'\n", + /* The 1st parameter of the test case is alway an unsigned + * long int which represents the function number. This logic + * validates the test case function number to ensure it is + * an unsigned long int. + */ + valid_function_number = 1; + errno = 0; + u[0] = strtoul(buf_p, &endp, 10); + if (errno) { + (void)fprintf(stream, "Read function number failed, line %lu error msg: '%s' string '%s'\n", line_num, strerror(errno), buf_p); - valid_function_number = 0; - } else if ((*endp != '\0') || (buf_p == endp) || (strchr(buf_p, '-') != '\0')) { - (void)fprintf(stream, "Read function number failed, line %lu string '%s'\n", line_num, buf_p); - valid_function_number = 0; - } + valid_function_number = 0; + } else if ((*endp != '\0') || (buf_p == endp) || (strchr(buf_p, '-') != '\0')) { + (void)fprintf(stream, "Read function number failed, line %lu string '%s'\n", line_num, buf_p); + valid_function_number = 0; + } - /* This logic restricts processing of the test case(s) to - * only those specified by the bntester input parameters. - */ - process_test_case = 0; - if (valid_function_number && process_single_test_case && (test_case_line_num == line_num)) { - process_test_case = 1; - } else if (valid_function_number && process_single_function && (function_num == u[0])) { - process_test_case = 1; - } else if (valid_function_number && !process_single_test_case && !process_single_function) { - process_test_case = 1; - } + /* This logic restricts processing of the test case(s) to + * only those specified by the bntester input parameters. + */ + process_test_case = 0; + if (valid_function_number && process_single_test_case && (test_case_line_num == line_num)) { + process_test_case = 1; + } else if (valid_function_number && process_single_function && (function_num == u[0])) { + process_test_case = 1; + } else if (valid_function_number && !process_single_test_case && !process_single_function) { + process_test_case = 1; + } - if (process_test_case) { - /* Each case within this switch corresponds to each - * function to be tested. - */ - switch (u[0]) { - case 1: /* function 'bn_distsq_line3_pt3' */ - bu_strlcpy(dt_fmt, "dddddddddd", sizeof(dt_fmt)); /* defines parameter data types */ - if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { - /* Parse failed, skipping test case */ - ret = 1; - } else { - double result; - if (!BU_SETJUMP) { - /* try */ - result = bn_distsq_line3_pt3(&d[0], &d[3], &d[6]); - if (!NEAR_EQUAL(result, d[9], VUNITIZE_TOL)) { - ret = 1; - failed_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %.15f result = %.15f\n", - u[0], line_num, d[9], result); - } else { - success_cnt++; - } - } else { - /* catch */ - BU_UNSETJUMP; - ret = 1; - bomb_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); - } BU_UNSETJUMP; - } - break; - case 2: /* function 'bn_2line3_colinear' */ - bu_strlcpy(dt_fmt, "ddddddddddddduddddi", sizeof(dt_fmt)); - if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { - /* Parse failed, skipping test case */ - ret = 1; - } else { - int result; - if (!BU_SETJUMP) { - /* try */ - tol.magic = u[1]; - tol.dist = d[13]; - tol.dist_sq = d[14]; - tol.perp = d[15]; - tol.para = d[16]; - result = bn_2line3_colinear(&d[0], &d[3], &d[6], &d[9], d[12], &tol); - if (result != i[0]) { - ret = 1; - failed_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", - u[0], line_num, i[0], result); - } else { - success_cnt++; - } - } else { - /* catch */ - BU_UNSETJUMP; - ret = 1; - bomb_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); - } BU_UNSETJUMP; - } - break; - case 3: /* function 'bn_isect_line3_line3' */ - bu_strlcpy(dt_fmt, "dddddddddddddduddddi", sizeof(dt_fmt)); - if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { - /* Parse failed, skipping test case */ - ret = 1; - } else { - int result; - double t_out = 0.0; - double u_out = 0.0; - int t_fail = 0; - int u_fail = 0; + if (process_test_case) { + /* Each case within this switch corresponds to each + * function to be tested. + */ + switch (u[0]) { + case 1: /* function 'bn_distsq_line3_pt3' */ + bu_strlcpy(dt_fmt, "dddddddddd", sizeof(dt_fmt)); /* defines parameter data types */ + if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { + /* Parse failed, skipping test case */ + ret = 1; + } else { + double result; + if (!BU_SETJUMP) { + /* try */ + result = bn_distsq_line3_pt3(&d[0], &d[3], &d[6]); + if (!NEAR_EQUAL(result, d[9], VUNITIZE_TOL)) { + ret = 1; + failed_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %.15f result = %.15f\n", + u[0], line_num, d[9], result); + } else { + success_cnt++; + } + } else { + /* catch */ + BU_UNSETJUMP; + ret = 1; + bomb_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); + } BU_UNSETJUMP; + } + break; + case 2: /* function 'bn_2line3_colinear' */ + bu_strlcpy(dt_fmt, "ddddddddddddduddddi", sizeof(dt_fmt)); + if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { + /* Parse failed, skipping test case */ + ret = 1; + } else { + int result; + if (!BU_SETJUMP) { + /* try */ + tol.magic = u[1]; + tol.dist = d[13]; + tol.dist_sq = d[14]; + tol.perp = d[15]; + tol.para = d[16]; + result = bn_2line3_colinear(&d[0], &d[3], &d[6], &d[9], d[12], &tol); + if (result != i[0]) { + ret = 1; + failed_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", + u[0], line_num, i[0], result); + } else { + success_cnt++; + } + } else { + /* catch */ + BU_UNSETJUMP; + ret = 1; + bomb_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); + } BU_UNSETJUMP; + } + break; + case 3: /* function 'bn_isect_line3_line3' */ + bu_strlcpy(dt_fmt, "dddddddddddddduddddi", sizeof(dt_fmt)); + if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { + /* Parse failed, skipping test case */ + ret = 1; + } else { + int result; + double t_out = 0.0; + double u_out = 0.0; + int t_fail = 0; + int u_fail = 0; - if (!BU_SETJUMP) { - /* try */ - tol.magic = u[1]; - tol.dist = d[14]; - tol.dist_sq = d[15]; - tol.perp = d[16]; - tol.para = d[17]; - result = bn_isect_line3_line3(&t_out, &u_out, &d[2], &d[5], &d[8], &d[11], &tol); - if (result != i[0]) { - ret = 1; - failed_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", - u[0], line_num, i[0], result); - } else if (result == 0) { - if (!NEAR_EQUAL(t_out, d[0], tol.dist)) { - ret = 1; - failed_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected t = %.15f result t = %.15f\n", - u[0], line_num, result, d[0], t_out); - } else { - success_cnt++; - } - } else if (result == 1) { - t_fail = !NEAR_EQUAL(t_out, d[0], tol.dist); - u_fail = !NEAR_EQUAL(u_out, d[1], tol.dist); - if (t_fail) { - (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected t = %.15f result t = %.15f\n", - u[0], line_num, result, d[0], t_out); - } - if (u_fail) { - (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected u = %.15f result u = %.15f\n", - u[0], line_num, result, d[1], u_out); - } - if (t_fail || u_fail) { - ret = 1; - failed_cnt++; - } else { - /* No other output to validate when result matches expected and - * result is not 0 and not 1. - */ - success_cnt++; - } - } else { - success_cnt++; - } - } else { - /* catch */ - BU_UNSETJUMP; - ret = 1; - bomb_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); - } BU_UNSETJUMP; - } - break; - case 4: /* function 'bn_isect_lseg3_lseg3' */ - bu_strlcpy(dt_fmt, "dddddddddddddduddddi", sizeof(dt_fmt)); - if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { - /* Parse failed, skipping test case */ - ret = 1; - } else { - int result; - double dist[2] = {0.0, 0.0}; - int d0_fail = 0; - int d1_fail = 0; + if (!BU_SETJUMP) { + /* try */ + tol.magic = u[1]; + tol.dist = d[14]; + tol.dist_sq = d[15]; + tol.perp = d[16]; + tol.para = d[17]; + result = bn_isect_line3_line3(&t_out, &u_out, &d[2], &d[5], &d[8], &d[11], &tol); + if (result != i[0]) { + ret = 1; + failed_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", + u[0], line_num, i[0], result); + } else if (result == 0) { + if (!NEAR_EQUAL(t_out, d[0], tol.dist)) { + ret = 1; + failed_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected t = %.15f result t = %.15f\n", + u[0], line_num, result, d[0], t_out); + } else { + success_cnt++; + } + } else if (result == 1) { + t_fail = !NEAR_EQUAL(t_out, d[0], tol.dist); + u_fail = !NEAR_EQUAL(u_out, d[1], tol.dist); + if (t_fail) { + (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected t = %.15f result t = %.15f\n", + u[0], line_num, result, d[0], t_out); + } + if (u_fail) { + (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected u = %.15f result u = %.15f\n", + u[0], line_num, result, d[1], u_out); + } + if (t_fail || u_fail) { + ret = 1; + failed_cnt++; + } else { + /* No other output to validate when result matches expected and + * result is not 0 and not 1. + */ + success_cnt++; + } + } else { + success_cnt++; + } + } else { + /* catch */ + BU_UNSETJUMP; + ret = 1; + bomb_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); + } BU_UNSETJUMP; + } + break; + case 4: /* function 'bn_isect_lseg3_lseg3' */ + bu_strlcpy(dt_fmt, "dddddddddddddduddddi", sizeof(dt_fmt)); + if (parse_case(buf_p, i, l, d, u, dt_fmt, line_num, stream)) { + /* Parse failed, skipping test case */ + ret = 1; + } else { + int result; + double dist[2] = {0.0, 0.0}; + int d0_fail = 0; + int d1_fail = 0; - if (!BU_SETJUMP) { - /* try */ - tol.magic = u[1]; - tol.dist = d[14]; - tol.dist_sq = d[15]; - tol.perp = d[16]; - tol.para = d[17]; - result = bn_isect_lseg3_lseg3(&dist[0], &d[2], &d[5], &d[8], &d[11], &tol); - if (result != i[0]) { - ret = 1; - failed_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", - u[0], line_num, i[0], result); - } else if (result == 0 || result == 1) { - d0_fail = !NEAR_EQUAL(dist[0], d[0], VUNITIZE_TOL); - d1_fail = !NEAR_EQUAL(dist[1], d[1], VUNITIZE_TOL); - if (d0_fail) { - (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected dist[0] = %.15f result dist[0] = %.15f\n", - u[0], line_num, result, d[0], dist[0]); - } - if (d1_fail) { - (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected dist[1] = %.15f result dist[1] = %.15f\n", - u[0], line_num, result, d[1], dist[1]); - } - if (d0_fail || d1_fail) { - ret = 1; - failed_cnt++; - } else { - /* No other output to validate when result matches expected and - * result is not 0 and not 1. - */ - success_cnt++; - } - } else { - success_cnt++; - } - } else { - /* catch */ - BU_UNSETJUMP; - ret = 1; - bomb_cnt++; - (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); - } BU_UNSETJUMP; - } - break; - default: - (void)fprintf(stream, "ERROR: Unknown function number %lu test case on line %lu, skipping test case.\n", u[0], line_num); + if (!BU_SETJUMP) { + /* try */ + tol.magic = u[1]; + tol.dist = d[14]; + tol.dist_sq = d[15]; + tol.perp = d[16]; + tol.para = d[17]; + result = bn_isect_lseg3_lseg3(&dist[0], &d[2], &d[5], &d[8], &d[11], &tol); + if (result != i[0]) { + ret = 1; + failed_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu expected = %d result = %d\n", + u[0], line_num, i[0], result); + } else if (result == 0 || result == 1) { + d0_fail = !NEAR_EQUAL(dist[0], d[0], VUNITIZE_TOL); + d1_fail = !NEAR_EQUAL(dist[1], d[1], VUNITIZE_TOL); + if (d0_fail) { + (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected dist[0] = %.15f result dist[0] = %.15f\n", + u[0], line_num, result, d[0], dist[0]); + } + if (d1_fail) { + (void)fprintf(stream, "Failed function %lu test case on line %lu result = %d expected dist[1] = %.15f result dist[1] = %.15f\n", + u[0], line_num, result, d[1], dist[1]); + } + if (d0_fail || d1_fail) { + ret = 1; + failed_cnt++; + } else { + /* No other output to validate when result matches expected and + * result is not 0 and not 1. + */ + success_cnt++; + } + } else { + success_cnt++; + } + } else { + /* catch */ + BU_UNSETJUMP; + ret = 1; + bomb_cnt++; + (void)fprintf(stream, "Failed function %lu test case on line %lu bu_bomb encountered.\n", u[0], line_num); + } BU_UNSETJUMP; + } + break; + default: + (void)fprintf(stream, "ERROR: Unknown function number %lu test case on line %lu, skipping test case.\n", u[0], line_num); bu_vls_free(&input_file_name); bu_vls_free(&output_file_name); - return EXIT_FAILURE; - break; - } /* End of function number switch */ - } - } /* End of if statement skipping lines starting with '#' or new line */ - } + return EXIT_FAILURE; + break; + } /* End of function number switch */ + } + } /* End of if statement skipping lines starting with '#' or new line */ + } } /* End of while loop reading lines from data file */ (void)fprintf(stream, "Summary: %lu total test cases success.\n", success_cnt); @@ -577,25 +577,25 @@ (void)fprintf(stream, "Summary: %lu total test cases bomb.\n", bomb_cnt); if (output_file_name_defined) { - bu_log("Summary: %lu total test cases success.\n", success_cnt); - bu_log("Summary: %lu total test cases failed.\n", failed_cnt); - bu_log("Summary: %lu total test cases bomb.\n", bomb_cnt); + bu_log("Summary: %lu total test cases success.\n", success_cnt); + bu_log("Summary: %lu total test cases failed.\n", failed_cnt); + bu_log("Summary: %lu total test cases bomb.\n", bomb_cnt); } (void)fprintf(stream, "Done.\n"); if (output_file_name_defined) { - bu_log("Done.\n"); + bu_log("Done.\n"); } if (fclose(fp_in) != 0) { - (void)fprintf(stream, "Unable to close input file.\n"); + (void)fprintf(stream, "Unable to close input file.\n"); } if (output_file_name_defined) { - if (fclose(stream) != 0) { - bu_log("Unable to close output file.\n"); - } + if (fclose(stream) != 0) { + bu_log("Unable to close output file.\n"); + } } bu_vls_free(&input_file_name); Modified: brlcad/trunk/src/libbn/plane.c =================================================================== --- brlcad/trunk/src/libbn/plane.c 2012-07-26 01:17:30 UTC (rev 51677) +++ brlcad/trunk/src/libbn/plane.c 2012-07-26 01:25:01 UTC (rev 51678) @@ -68,17 +68,17 @@ abx = a[X]-b[X]; ab = abx * abx; if (ab > tmp) { - return 0; + return 0; } aby = a[Y]-b[Y]; ab += (aby * aby); if (ab > tmp) { - return 0; + return 0; } abz = a[Z]-b[Z]; ab += (abz * abz); if (ab > tmp) { - return 0; + return 0; } return 1; @@ -361,19 +361,19 @@ VCROSS(v3, a, b); /* Since this algorithm assumes unit-length direction vectors, we need - * to calculate the scale factors associated with the unitized - * equivalents of the planes. - */ - aH = MAGNITUDE(a) * a[H]; - bH = MAGNITUDE(b) * b[H]; - cH = MAGNITUDE(c) * c[H]; + * to calculate the scale factors associated with the unitized + * equivalents of the planes. + */ + aH = MAGNITUDE(a) * a[H]; + bH = MAGNITUDE(b) * b[H]; + cH = MAGNITUDE(c) * c[H]; - /* We use the fact that det(M) = 1 / det(M^T) to calculate the - * determinant of matrix M: - * [ a[X] b[X] c[X] ] - * [ a[Y] b[Y] c[Y] ] - * [ a[Z] b[Z] c[Z] ] - */ + /* We use the fact that det(M) = 1 / det(M^T) to calculate the + * determinant of matrix M: + * [ a[X] b[X] c[X] ] + * [ a[Y] b[Y] c[Y] ] + * [ a[Z] b[Z] c[Z] ] + */ det = 1 / dot; pt[X] = det * (aH * v1[X] - bH * v2[X] + cH * v3[X]); @@ -448,16 +448,16 @@ * (PCA). * @code - P - * - /. - / . - / . - / . (dist) - / . - / . - *------*--------> - A PCA dir + P + * + /. + / . + / . + / . (dist) + / . + / . + *------*--------> + A PCA dir @endcode * There are three distinct cases, with these return codes - * 0 => P is within tolerance of point A. *dist = 0, pca=A. @@ -787,13 +787,13 @@ abs_dir[Z] = fabs(dir[Z]); if (ZERO(abs_dir[X])) { - abs_dir[X] = 0.0; + abs_dir[X] = 0.0; } if (ZERO(abs_dir[Y])) { - abs_dir[Y] = 0.0; + abs_dir[Y] = 0.0; } if (ZERO(abs_dir[Z])) { - abs_dir[Z] = 0.0; + abs_dir[Z] = 0.0; } if (abs_dir[X] >= abs_dir[Y]) { @@ -1412,14 +1412,14 @@ /* sanity check */ if (UNLIKELY(status < -2 || status > 1)) { - bu_bomb("bn_isect_lseg3_lseg3() function 'bn_isect_line3_line3' returned an invalid status\n"); + bu_bomb("bn_isect_lseg3_lseg3() function 'bn_isect_line3_line3' returned an invalid status\n"); } if (status == -1) { - /* Infinite lines do not intersect and are not parallel - * therefore line segments do not intersect and are not - * parallel. - */ + /* Infinite lines do not intersect and are not parallel + * therefore line segments do not intersect and are not + * parallel. + */ if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { bu_log("bn_isect_lseg3_lseg3(): MISS, line segments do not intersect and are not parallel\n"); } @@ -1427,7 +1427,7 @@ } if (status == -2) { - /* infinite lines do not intersect, they are parallel */ + /* infinite lines do not intersect, they are parallel */ if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { bu_log("bn_isect_lseg3_lseg3(): MISS, line segments are parallel, i.e. do not intersect\n"); } @@ -1449,13 +1449,13 @@ qtol = tol->dist / qmag; dist[0] = dist[0] / pmag; if (status == 0) { /* infinite lines are colinear */ - /* When line segments are colinear, dist[1] has an alternate - * interpretation: it's the parameter along p (not q) - * therefore dist[1] must be scaled by pmag not qmag. - */ - dist[1] = dist[1] / pmag; + /* When line segments are colinear, dist[1] has an alternate + * interpretation: it's the parameter along p (not q) + * therefore dist[1] must be scaled by pmag not qmag. + */ + dist[1] = dist[1] / pmag; } else { - dist[1] = dist[1] / qmag; + dist[1] = dist[1] / qmag; } if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { @@ -1464,16 +1464,16 @@ /* If 'p' within tol of either endpoint (0.0, 1.0), make exact. */ if (dist[0] > -ptol && dist[0] < ptol) { - dist[0] = 0.0; + dist[0] = 0.0; } else if (dist[0] > 1.0-ptol && dist[0] < 1.0+ptol) { - dist[0] = 1.0; + dist[0] = 1.0; } if (status == 0) { /* infinite lines are colinear */ - /* When line segments are colinear, dist[1] has an alternate - * interpretation: it's the parameter along p (not q) - * therefore dist[1] must use tolerance ptol not qtol. - * If 'q' within tol of either endpoint (0.0, 1.0), make exact. + /* When line segments are colinear, dist[1] has an alternate + * interpretation: it's the parameter along p (not q) + * therefore dist[1] must use tolerance ptol not qtol. + * If 'q' within tol of either endpoint (0.0, 1.0), make exact. */ if (dist[1] > -ptol && dist[1] < ptol) { dist[1] = 0.0; @@ -1491,12 +1491,12 @@ if (status == 0) { /* infinite lines are colinear */ /* Lines are colinear */ - if ((dist[0] > 1.0+ptol && dist[1] > 1.0+ptol) || (dist[0] < -ptol && dist[1] < -ptol)) { + if ((dist[0] > 1.0+ptol && dist[1] > 1.0+ptol) || (dist[0] < -ptol && dist[1] < -ptol)) { if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { - bu_log("bn_isect_lseg3_lseg3(): MISS, line segments are colinear but not overlapping!\n"); + bu_log("bn_isect_lseg3_lseg3(): MISS, line segments are colinear but not overlapping!\n"); } - return -1; /* line segments are colinear but not overlapping */ - } + return -1; /* line segments are colinear but not overlapping */ + } if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { bu_log("bn_isect_lseg3_lseg3(): HIT, line segments are colinear and overlapping!\n"); @@ -1509,10 +1509,10 @@ if (dist[0] < -ptol || dist[0] > 1.0+ptol || dist[1] < -qtol || dist[1] > 1.0+qtol) { - if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { + if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { bu_log("bn_isect_lseg3_lseg3(): MISS, infinite lines intersect but line segments do not!\n"); - } - return -3; /* missed, infinite lines intersect but line segments do not */ + } + return -3; /* missed, infinite lines intersect but line segments do not */ } if (UNLIKELY(bu_debug & BU_DEBUG_MATH)) { @@ -1521,7 +1521,7 @@ /* sanity check */ if (UNLIKELY(dist[0] < -SMALL_FASTF || dist[0] > 1.0 || dist[1] < -SMALL_FASTF || dist[1] > 1.0)) { - bu_bomb("bn_isect_lseg3_lseg3(): INTERNAL ERROR, intersect distance values must be in the range 0-1\n"); + bu_bomb("bn_isect_lseg3_lseg3(): INTERNAL ERROR, intersect distance values must be in the range 0-1\n"); } return 1; /* hit, line segments intersect */ @@ -1597,11 +1597,11 @@ qdir_mag_sq = MAGSQ(qdir); if (UNLIKELY((pdir_mag_sq < tol->dist_sq) || (qdir_mag_sq < tol->dist_sq))) { - bu_log(" p0 = %g %g %g\n", V3ARGS(p0)); - bu_log("pdir = %g %g %g\n", V3ARGS(pdir)); - bu_log(" q0 = %g %g %g\n", V3ARGS(q0)); - bu_log("qdir = %g %g %g\n", V3ARGS(qdir)); - bu_bomb("bn_isect_line3_line3(): input vector(s) 'pdir' and/or 'qdir' is zero magnitude.\n"); + bu_log(" p0 = %g %g %g\n", V3ARGS(p0)); + bu_log("pdir = %g %g %g\n", V3ARGS(pdir)); + bu_log(" q0 = %g %g %g\n", V3ARGS(q0)); + bu_log("qdir = %g %g %g\n", V3ARGS(qdir)); + bu_bomb("bn_isect_line3_line3(): input vector(s) 'pdir' and/or 'qdir' is zero magnitude.\n"); } *pdist = 0.0; @@ -1619,22 +1619,22 @@ d4 = bn_distsq_line3_pt3(p0,pdir,q1); /* if all distances are within distance tolerance of each - * other then they a parallel + * other then they a parallel */ if (NEAR_EQUAL(d1, d2, tol->dist_sq) && - NEAR_EQUAL(d1, d3, tol->dist_sq) && - NEAR_EQUAL(d1, d4, tol->dist_sq) && - NEAR_EQUAL(d2, d3, tol->dist_sq) && - NEAR_EQUAL(d2, d4, tol->dist_sq) && - NEAR_EQUAL(d3, d4, tol->dist_sq)) { - parallel = 1; + NEAR_EQUAL(d1, d3, tol->dist_sq) && + NEAR_EQUAL(d1, d4, tol->dist_sq) && + NEAR_EQUAL(d2, d3, tol->dist_sq) && + NEAR_EQUAL(d2, d4, tol->dist_sq) && + NEAR_EQUAL(d3, d4, tol->dist_sq)) { + parallel = 1; } if (NEAR_ZERO(d1, tol->dist_sq) && - NEAR_ZERO(d2, tol->dist_sq) && - NEAR_ZERO(d3, tol->dist_sq) && - NEAR_ZERO(d4, tol->dist_sq)) { - colinear = 1; + NEAR_ZERO(d2, tol->dist_sq) && + NEAR_ZERO(d3, tol->dist_sq) && + NEAR_ZERO(d4, tol->dist_sq)) { + colinear = 1; } VSUB2(w0, p0, q0); @@ -1644,41 +1644,41 @@ denominator = pdir_mag_sq * qdir_mag_sq - b * b; if (UNLIKELY(!parallel && colinear)) { - bu_bomb("bn_isect_line3_line3(): logic error, lines colinear but not parallel\n"); + bu_bomb("bn_isect_line3_line3(): logic error, lines colinear but not parallel\n"); } if (parallel && !colinear) { - /* lines are parallel */ - sc = d / pdir_mag_sq; - tc = 0.0; - return -2; /* no intersection, lines are parallel */ + /* lines are parallel */ + sc = d / pdir_mag_sq; + tc = 0.0; + return -2; /* no intersection, lines are parallel */ } if (parallel && colinear) { - /* when colinear pdist has a different meaning, it is the - * distance from p0 to q0 - */ - *pdist = MAGNITUDE(w0); /* w0 is opposite direction of p0 to q0 */ - dot = VDOT(pdir, w0); - if (dot > SMALL_FASTF) { - *pdist = -(*pdist); - } + /* when colinear pdist has a different meaning, it is the + * distance from p0 to q0 + */ + *pdist = MAGNITUDE(w0); /* w0 is opposite direction of p0 to q0 */ + dot = VDOT(pdir, w0); + if (dot > SMALL_FASTF) { + *pdist = -(*pdist); + } - /* when colinear qdist has a different meaning, it is the - * distance from p0 to q1 - */ - *qdist = MAGNITUDE(p0_to_q1); + /* when colinear qdist has a different meaning, it is the + * distance from p0 to q1 + */ + *qdist = MAGNITUDE(p0_to_q1); - /* if vectors pdir and p0_to_q1 are not the same direction - * then make the distance negative - */ - dot = VDOT(pdir, p0_to_q1); - if (dot < -SMALL_FASTF) { - *qdist = -(*qdist); - } + /* if vectors pdir and p0_to_q1 are not the same direction + * then make the distance negative + */ + dot = VDOT(pdir, p0_to_q1); + if (dot < -SMALL_FASTF) { + *qdist = -(*qdist); + } - return 0; /* colinear intersection */ + return 0; /* colinear intersection */ } sc_numerator = (b * e - qdir_mag_sq * d); @@ -1693,11 +1693,11 @@ VADD2(qc_to_pc, w0, tmp_vec); if (MAGSQ(qc_to_pc) <= tol->dist_sq) { - *pdist = sc * sqrt(pdir_mag_sq); - *qdist = tc * sqrt(qdir_mag_sq); - return 1; /* intersection */ + *pdist = sc * sqrt(pdir_mag_sq); + *qdist = tc * sqrt(qdir_mag_sq); + return 1; /* intersection */ } else { - return -1; /* no intersection */ + return -1; /* no intersection */ } } @@ -1753,7 +1753,7 @@ d_mag_sq = MAGSQ(d); if (UNLIKELY(NEAR_ZERO(d_mag_sq, tol->dist_sq))) { - bu_bomb("bn_isect_line_lseg(): ray direction vector zero magnitude\n"); + bu_bomb("bn_isect_line_lseg(): ray direction vector zero magnitude\n"); } VSUB2(ab, b, a); @@ -1766,17 +1766,17 @@ VSUB2(pa, a, p); pa_mag_sq = MAGSQ(pa); if (pa_mag_sq < tol->dist_sq) { - /* Intersection at vertex A */ - *t = sqrt(pa_mag_sq); - return 1; + /* Intersection at vertex A */ + *t = sqrt(pa_mag_sq); + return 1; } VSUB2(pb, b, p); pb_mag_sq = MAGSQ(pb); if (pb_mag_sq < tol->dist_sq) { - /* Intersection at vertex B */ - *t = sqrt(pb_mag_sq); - return 2; + /* Intersection at vertex B */ + *t = sqrt(pb_mag_sq); + return 2; } /* just check that the vertices of the line segement are @@ -1790,58 +1790,58 @@ colinear = 0; if (NEAR_ZERO(d1, tol->dist_sq) && NEAR_ZERO(d2, tol->dist_sq)) { - colinear = 1; + colinear = 1; - dist1 = sqrt(pa_mag_sq); - dist2 = sqrt(pb_mag_sq); + dist1 = sqrt(pa_mag_sq); + dist2 = sqrt(pb_mag_sq); - /* if the direction of the pa vector is in the - * opposite direction of the ray, then make the - * distance negative - */ - dot = VDOT(pa, d); - if (dot < -SMALL_FASTF) { - dist1 = -dist1; - } + /* if the direction of the pa vector is in the + * opposite direction of the ray, then make the + * distance negative + */ + dot = VDOT(pa, d); + if (dot < -SMALL_FASTF) { + dist1 = -dist1; + } - /* if the direction of the pb vector is in the - * opposite direction of the ray, then make the - * distance negative - */ - dot = VDOT(pb, d); - if (dot < -SMALL_FASTF) { - dist2 = -dist2; - } + /* if the direction of the pb vector is in the + * opposite direction of the ray, then make the + * distance negative + */ + dot = VDOT(pb, d); + if (dot < -SMALL_FASTF) { + dist2 = -dist2; + } } if (colinear && dist1 < SMALL_FASTF && dist2 < SMALL_FASTF) { - /* lines are colinear but 'a' and 'b' are not on the ray */ - return -1; /* no intersection */ + /* lines are colinear but 'a' and 'b' are not on the ray */ + return -1; /* no intersection */ } if (colinear && (dist1 > SMALL_FASTF) && (dist2 > SMALL_FASTF)) { - /* lines are colinear and both points 'a' and 'b' are on the ray. */ - /* return the distance to the closest point */ - if (dist2 > dist1) { - *t = dist1; - } else { - *t = dist2; - } - return 0; + /* lines are colinear and both points 'a' and 'b' are on the ray. */ + /* return the distance to the closest point */ + if (dist2 > dist1) { + *t = dist1; + } else { + *t = dist2; + } + return 0; } if (colinear && (dist1 > SMALL_FASTF) && (dist2 < SMALL_FASTF)) { - /* lines are colinear and 'a' is on the ray but 'b' is not. */ - /* return the distance to 'a' */ - *t = dist1; - return 0; + /* lines are colinear and 'a' is on the ray but 'b' is not. */ + /* return the distance to 'a' */ + *t = dist1; + return 0; } if (colinear && (dist1 < SMALL_FASTF) && (dist2 > SMALL_FASTF)) { - /* lines are colinear and 'b' is on the ray but 'a' is not. */ - /* return the distance to 'b' */ - *t = dist2; - return 0; + /* lines are colinear and 'b' is on the ray but 'a' is not. */ + /* return the distance to 'b' */ + *t = dist2; + return 0; } dist1 = 0.0; /* sanity */ @@ -1849,75 +1849,75 @@ code = bn_isect_line3_line3(&dist1, &dist2, p, d, a, ab, tol); if (UNLIKELY(code == 0)) { - bu_bomb("bn_isect_line_lseg(): we should have already detected a colinear condition\n"); + bu_bomb("bn_isect_line_lseg(): we should have already detected a colinear condition\n"); } if (code < 0) { - return -1; /* no intersection */ + return -1; /* no intersection */ } if (code == 1) { - if (dist1 < -(tol->dist)) { - /* the ray did isect the line segment but in the - * negative direction so this is not really a hit - */ - return -1; /* no intersection */ - } + if (dist1 < -(tol->dist)) { + /* the ray did isect the line segment but in the + * negative direction so this is not really a hit + */ + return -1; /* no intersection */ + } } if (code == 1) { - /* determine if isect was before a, between a & b or after b */ - vect_t d_unit; - vect_t a_to_isect_pt, b_to_isect_pt; - point_t isect_pt; - fastf_t a_to_isect_pt_mag_sq, b_to_isect_pt_mag_sq; + /* determine if isect was before a, between a & b or after b */ + vect_t d_unit; + vect_t a_to_isect_pt, b_to_isect_pt; + point_t isect_pt; + fastf_t a_to_isect_pt_mag_sq, b_to_isect_pt_mag_sq; - VMOVE(d_unit, d); - VUNITIZE(d_unit); + VMOVE(d_unit, d); + VUNITIZE(d_unit); - dist1 = fabs(dist1); /* sanity */ - VSCALE(isect_pt, d_unit, dist1); - VSUB2(a_to_isect_pt, isect_pt, a); - VSUB2(b_to_isect_pt, isect_pt, b); + dist1 = fabs(dist1); /* sanity */ + VSCALE(isect_pt, d_unit, dist1); + VSUB2(a_to_isect_pt, isect_pt, a); + VSUB2(b_to_isect_pt, isect_pt, b); - a_to_isect_pt_mag_sq = MAGSQ(a_to_isect_pt); - b_to_isect_pt_mag_sq = MAGSQ(b_to_isect_pt); + a_to_isect_pt_mag_sq = MAGSQ(a_to_isect_pt); + b_to_isect_pt_mag_sq = MAGSQ(b_to_isect_pt); - *t = dist1; + *t = dist1; - if (a_to_isect_pt_mag_sq < tol->dist_sq) { - /* isect at point a of line segement */ - return 1; - } + if (a_to_isect_pt_mag_sq < tol->dist_sq) { + /* isect at point a of line segement */ + return 1; + } - if (b_to_isect_pt_mag_sq < tol->dist_sq) { - /* isect at point b of line segement */ - return 2; - } + if (b_to_isect_pt_mag_sq < tol->dist_sq) { + /* isect at point b of line segement */ + return 2; + } - if (UNLIKELY((a_to_isect_pt_mag_sq < tol->dist_sq) && (b_to_isect_pt_mag_sq < tol->dist_sq))) { - bu_bomb("bn_isect_line_lseg(): this case should already been caught. i.e. zero length line segment\n"); - } + if (UNLIKELY((a_to_isect_pt_mag_sq < tol->dist_sq) && (b_to_isect_pt_mag_sq < tol->dist_sq))) { + bu_bomb("bn_isect_line_lseg(): this case should already been caught. i.e. zero length line segment\n"); + } - dot = VDOT(a_to_isect_pt, ab); - if (dot < -SMALL_FASTF) { - /* isect before point a of infinite line associated - * with the line segment a->b - */ - return -3; - } + dot = VDOT(a_to_isect_pt, ab); + if (dot < -SMALL_FASTF) { + /* isect before point a of infinite line associated + * with the line segment a->b + */ + return -3; + } - dot = VDOT(b_to_isect_pt, ab); - if (dot > SMALL_FASTF) { - /* isect after point b of infinite line associated - * with the line segment a->b - */ - return -2; - } + dot = VDOT(b_to_isect_pt, ab); + if (dot > SMALL_FASTF) { + /* isect after point b of infinite line associated + * with the line segment a->b + */ + return -2; + } - return 3; /* isect on line segement a->b but - * not on the end points - */ + return 3; /* isect on line segement a->b but + * not on the end points + */ } bu_bomb("bn_isect_line_lseg(): logic error, should not be here\n"); @@ -2632,7 +2632,7 @@ if (dot >= SMALL_FASTF) { /* true when plane normals in same direction */ return 1; - } else { + } else { /* true when plane normals in opposite direction */ return 2; } @@ -3236,4 +3236,3 @@ * End: * ex: shiftwidth=4 tabstop=8 */ - Modified: brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c =================================================================== --- brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c 2012-07-26 01:17:30 UTC (rev 51677) +++ brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c 2012-07-26 01:25:01 UTC (rev 51678) @@ -59,7 +59,7 @@ U2[0] = f1; U2[1] = f2; U2[2] = f3; sscanf(argv[7], "%d", &area_flag); sscanf(argv[8], "%d", &expected_result); - + actual_result = bn_coplanar_tri_tri_isect(V0,V1,V2,U0,U1,U2,area_flag); bu_log("result: %d\n", actual_result); Modified: brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c =================================================================== --- brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c 2012-07-26 01:17:30 UTC (rev 51677) +++ brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c 2012-07-26 01:25:01 UTC (rev 51678) @@ -57,7 +57,7 @@ sscanf(argv[6], "%f,%f,%f", &f1, &f2, &f3); U2[0] = f1; U2[1] = f2; U2[2] = f3; sscanf(argv[7], "%d", &expected_result); - + actual_result = bn_tri_tri_i... [truncated message content] |