예제 #1
0
/**
 * Sorts the region list according to the sort parameter (1 - 5) passed in.
 */
static int
sort_regions(const void *a, const void *b, void *arg)
{
    struct region_record *r1 = (struct region_record *)a;
    struct region_record *r2 = (struct region_record *)b;
    int *sort_type = (int *)arg;
    int temp1,temp2;

    switch (*sort_type) {
	case 1:
	    temp1=atoi(r1->region_id);
	    temp2=atoi(r2->region_id);
	    goto continue_run;
	case 2:
	    temp1=atoi(r1->material_id);
	    temp2=atoi(r2->material_id);
	    goto continue_run;
	case 3:
	    temp1=atoi(r1->los);
	    temp2=atoi(r2->los);
continue_run:
	    if ( temp1 > temp2 )
    		return 1;
	    if ( temp1 == temp2 )
		return 0;
	    return -1;
	case 4:
	    return bu_strcmp(r1->obj_name, r2->obj_name);
	case 5:
	    return bu_strcmp(r1->obj_parent, r2->obj_parent);
    }
    /* This should never be executed */
    return 0;
}
예제 #2
0
파일: voxels.c 프로젝트: kanzure/brlcad
/**
 * Function to get the corresponding region entry to a region name.
 */
HIDDEN struct voxelRegion *
getRegionByName(struct voxelRegion *head, const char *regionName) {
    struct voxelRegion *ret = NULL;

    BU_ASSERT(regionName != NULL);

    if (head->regionName == NULL) { /* the first region on this voxel */
	head->regionName = bu_strdup(regionName);
	ret = head;
    }
    else {
	while (head->nextRegion != NULL) {
	    if (bu_strcmp(head->regionName, regionName) == 0) {
		ret = head;
		break;
	    }

	    head = head->nextRegion;
	}

	if (ret == NULL) { /* not found until here */
	    if (bu_strcmp(head->regionName ,regionName) == 0) /* is it the last one on the list? */
		ret = head;
	    else {
		BU_ALLOC(ret, struct voxelRegion);
		head->nextRegion = ret;
		ret->regionName  = bu_strdup(regionName);
	    }
	}
    }

    return ret;
}
예제 #3
0
/**
 * Sorts the region lists such that identical entries are next to each
 * other; used to remove duplicates.
 */
static int
cmp_regions(const void *a, const void *b, void *UNUSED(arg))
{
    struct region_record *r1 = (struct region_record *)a;
    struct region_record *r2 = (struct region_record *)b;
    int cmp;

    cmp = bu_strcmp(r1->region_id, r2->region_id);
    if (cmp) { return cmp; }
    cmp = bu_strcmp(r1->material_id, r2->material_id);
    if (cmp) { return cmp; }
    cmp = bu_strcmp(r1->los, r2->los);
    return cmp;
}
예제 #4
0
int
test_bu_bitv_and(char *inp1 , char *inp2 , char *exp)
{
    struct bu_bitv *res_bitv , *res_bitv1 , *result;
    struct bu_vls *a , *b;
    int pass;

    a = bu_vls_vlsinit();
    b = bu_vls_vlsinit();

    res_bitv1 = bu_hex_to_bitv(inp1);
    res_bitv  = bu_hex_to_bitv(inp2);
    result    = bu_hex_to_bitv(exp);

    bu_bitv_and(res_bitv1,res_bitv);
    bu_bitv_vls(a,res_bitv1);
    bu_bitv_vls(b,result);

    if (!bu_strcmp(a->vls_str , b->vls_str)) {
	printf("\nbu_bitv_and test PASSED Input1:%s Input2:%s Output:%s", inp1, inp2, exp);
	pass = 1;
    } else {
	printf("\nbu_bitv_and test FAILED Input1:%s Input2:%s Expected:%s", inp1, inp2, exp);
	pass = 0;
    }

    bu_bitv_free(res_bitv);
    bu_bitv_free(res_bitv1);
    bu_bitv_free(result);

    return pass;
}
예제 #5
0
파일: exists.c 프로젝트: kanzure/brlcad
static int
compare3(const void *va, const void *vb)
{
    const char *a = (const char *)va;
    const char *b = (const char *)VTOC(vb);
    return bu_strcmp(a, b);
}
HIDDEN int
edcodes_reg_compare(const void *p1, const void *p2, void *UNUSED(arg))
{
    char *reg1, *reg2;

    reg1 = strchr(*(char **)p1, '/');
    reg2 = strchr(*(char **)p2, '/');

    return bu_strcmp(reg1, reg2);
}
예제 #7
0
파일: overlaps.c 프로젝트: kanzure/brlcad
struct region_pair *
add_unique_pair(struct region_pair *list, /* list to add into */
		struct region *r1,        /* first region involved */
		struct region *r2,        /* second region involved */
		double dist,              /* distance/thickness metric value */
		point_t pt)               /* location where this takes place */
{
    struct region_pair *rp, *rpair;

    /* look for it in our list */
    bu_semaphore_acquire(GED_SEM_LIST);
    for (BU_LIST_FOR (rp, region_pair, &list->l)) {

	if ((r1 == rp->r.r1 && r2 == rp->r2) || (r1 == rp->r2 && r2 == rp->r.r1)) {
	    /* we already have an entry for this region pair, we
	     * increase the counter, check the depth and update
	     * thickness maximum and entry point if need be and
	     * return.
	     */
	    rp->count++;

	    if (dist > rp->max_dist) {
		rp->max_dist = dist;
		VMOVE(rp->coord, pt);
	    }
	    rpair = rp;
	    goto found;
	}
    }
    /* didn't find it in the list.  Add it */
    BU_ALLOC(rpair, struct region_pair);
    rpair->r.r1 = r1;
    rpair->r2 = r2;
    rpair->count = 1;
    rpair->max_dist = dist;
    VMOVE(rpair->coord, pt);
    list->max_dist ++; /* really a count */

    /* insert in the list at the "nice" place */
    for (BU_LIST_FOR (rp, region_pair, &list->l)) {
	if (bu_strcmp(rp->r.r1->reg_name, r1->reg_name) <= 0)
	    break;
    }
    BU_LIST_INSERT(&rp->l, &rpair->l);
 found:
    bu_semaphore_release(GED_SEM_LIST);
    return rpair;
}
예제 #8
0
int
ged_lc(struct ged *gedp, int argc, const char *argv[])
{
    char *file_name = NULL;
    int file_name_flag_cnt = 0;
    int sort_column = 1;
    int sort_column_flag_cnt = 0;
    int find_duplicates_flag = 0;
    int skip_special_duplicates_flag = 0;
    int skip_subtracted_regions_flag = 0;
    int descending_sort_flag = 0;
    int unrecognized_flag_cnt = 0;

    int orig_argc;
    const char **orig_argv;

    static const char *usage = "[-d|-s] [-r] [-z] [-0|-1|-2|-3|-4|-5] [-f {FileName}] {GroupName}";

    int c;
    int error_cnt = 0;

    FILE *outfile = NULL;
    struct bu_vls *output;

    const char *group_name;

    size_t i,j;
    struct bu_ptbl results1 = BU_PTBL_INIT_ZERO;
    struct bu_ptbl results2 = BU_PTBL_INIT_ZERO;
    char *path;
    char *plan;
    struct db_full_path root;
    int matches;
    struct region_record *regions;
    size_t ignored_cnt = 0;

    /* The defaults are the minimum widths to accommodate column headers */
    size_t region_id_len_max = 2;
    size_t material_id_len_max = 3;
    size_t los_len_max = 3;
    size_t obj_len_max = 6;

    /* For the output at the end */
    size_t start, end, incr;

    /* initialize result */
    bu_vls_trunc(gedp->ged_result_str, 0);

    if (argc == 1) {
	bu_vls_printf(gedp->ged_result_str, "Usage: %s\n", usage);
	return GED_HELP;
    }

    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);

    bu_optind = 1; /* re-init bu_getopt() */
    while ((c = bu_getopt(argc, (char * const *)argv, "dsrz012345f:")) != -1) {
	switch (c) {
	    case '0':
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
		sort_column_flag_cnt++;
		sort_column = c - '0';
		break;
	    case 'f':
		file_name_flag_cnt++;
		file_name = bu_optarg;
		break;
	    case 's':
		skip_special_duplicates_flag = 1;
		/* FALLTHROUGH */
	    case 'd':
		find_duplicates_flag = 1;
		break;
	    case 'r':
		skip_subtracted_regions_flag = 1;
		break;
	    case 'z':
		descending_sort_flag = 1;
		break;
	    default:
		unrecognized_flag_cnt++;
	}
    }
    orig_argc = argc;
    orig_argv = argv;
    argc -= (bu_optind - 1);
    argv += (bu_optind - 1);

    /* Attempt to recreate the exact error messages from the original lc.tcl */

    if (file_name_flag_cnt > 1) {
	bu_vls_printf(gedp->ged_result_str, "Error: '-f' used more than once.\n");
	error_cnt++;
    }

    if (sort_column_flag_cnt > 1) {
	bu_vls_printf(gedp->ged_result_str, "Error: Sort column defined more than once.\n");
	error_cnt++;
    }

    if (file_name_flag_cnt + argc + unrecognized_flag_cnt > 3) {
	bu_vls_printf(gedp->ged_result_str, "Error: More than one group name and/or file name was specified.\n");
	error_cnt++;
    } else if (argc < 2) {
	if (file_name_flag_cnt && !file_name) {
	    bu_vls_printf(gedp->ged_result_str, "Error: Group name and file name not specified\n");
	} else {
	    bu_vls_printf(gedp->ged_result_str, "Error: Group name not specified.\n");
	}
        error_cnt++;
    } else if (argc + unrecognized_flag_cnt > 2) {
	bu_vls_printf(gedp->ged_result_str, "Error: More than one group name was specified.\n");
	error_cnt++;
    } else if (file_name_flag_cnt && !file_name) {
	bu_vls_printf(gedp->ged_result_str, "Error: File name not specified.\n");
	error_cnt++;
    }

    if (file_name) {
	char *norm_name;
	norm_name = bu_realpath(file_name, NULL);
	if (file_name[0] == '-') {
	    bu_vls_printf(gedp->ged_result_str, "Error: File name can not start with '-'.\n");
	    error_cnt++;
	} else if (bu_file_exists(file_name, NULL)) {
	    bu_vls_printf(gedp->ged_result_str, "Error: Output file %s already exists.\n",norm_name);
	    error_cnt++;
	} else {
	    outfile = fopen(file_name, "w");
	    if (!outfile) {
		bu_vls_printf(gedp->ged_result_str, "Error: %d\n", errno);
		error_cnt++;
	    }
	}
	bu_vls_printf(gedp->ged_result_str, "Output filename: %s\n", norm_name);
	bu_free(norm_name, "ged_lc");
	output = bu_vls_vlsinit();
    } else {
	output = gedp->ged_result_str;
    }

    if (error_cnt > 0) { return GED_ERROR; }

    group_name = argv[1];

    /* The 7 is for the "-name" and '\0' */
    plan = (char *) bu_malloc(sizeof(char) * (strlen(group_name) + 7), "ged_lc");
    sprintf(plan, "-name %s", group_name);
    matches = db_search(&results1, DB_SEARCH_TREE, plan, 0, NULL, gedp->ged_wdbp->dbip);
    if (matches < 1) {
	bu_vls_printf(gedp->ged_result_str, "Error: Group '%s' does not exist.\n", group_name);
	return GED_ERROR;
    }
    bu_free(plan, "ged_lc");
    db_search_free(&results1);

    if (skip_subtracted_regions_flag) {
	plan = "-type region ! -bool -";
    } else {
	plan = "-type region";
    }
    path = (char *) bu_malloc(sizeof(char) * (strlen(group_name) + 2), "ged_lc");
    sprintf(path, "/%s", group_name);
    db_string_to_path(&root, gedp->ged_wdbp->dbip, path);
    matches = db_search(&results2, DB_SEARCH_TREE, plan, root.fp_len, root.fp_names, gedp->ged_wdbp->dbip);
    bu_free(path, "ged_lc");
    if (matches < 1) { return GED_ERROR; }
    regions = (struct region_record *) bu_malloc(sizeof(struct region_record) * BU_PTBL_LEN(&results2), "ged_lc");
    for (i = 0; i < BU_PTBL_LEN(&results2); i++) {
	struct db_full_path *entry = (struct db_full_path *)BU_PTBL_GET(&results2, i);
	struct directory *dp_curr_dir = DB_FULL_PATH_CUR_DIR(entry);
	struct bu_attribute_value_set avs;

    	j = BU_PTBL_LEN(&results2) - i - 1 ;
	regions[j].ignore = 0;

	bu_avs_init_empty(&avs);
	db5_get_attributes(gedp->ged_wdbp->dbip, &avs, dp_curr_dir);

	regions[j].region_id = get_attr(&avs, "region_id");
	V_MAX(region_id_len_max, strlen(regions[j].region_id));
	regions[j].material_id = get_attr(&avs, "material_id");
	V_MAX(material_id_len_max, strlen(regions[j].material_id));
	regions[j].los = get_attr(&avs, "los");
	V_MAX(los_len_max, strlen(regions[j].los));
	regions[j].obj_name = dp_curr_dir->d_namep;
	V_MAX(obj_len_max, strlen(regions[j].obj_name));

	if (entry->fp_len > 1) {
	    struct directory *dp_parent = DB_FULL_PATH_GET(entry, entry->fp_len - 2);
	    regions[j].obj_parent = dp_parent->d_namep;
	} else {
	    regions[j].obj_parent = "--";
	}
    }

    if (find_duplicates_flag) {

	bu_sort((void *) regions, BU_PTBL_LEN(&results2), sizeof(struct region_record), cmp_regions, NULL);

	for (i = 1;  i < BU_PTBL_LEN(&results2); i++) {
	    int same;
	    if (skip_special_duplicates_flag) {
		same = !cmp_regions((void *)&(regions[i - 1]), (void *)&(regions[i]), NULL);
	    } else {
		same = !bu_strcmp(regions[i - 1].region_id, regions[i].region_id);
	    }
	    if (same) {
		regions[i].ignore = 1;
		ignored_cnt++;
	    }
	}

	if (ignored_cnt == BU_PTBL_LEN(&results2)) {
	    if (file_name) {
		print_cmd_args(output, orig_argc, orig_argv);
		bu_vls_printf(output, "No duplicate region_id\n");
		bu_vls_fwrite(outfile, output);
		fclose(outfile);
	    }
	    bu_vls_printf(gedp->ged_result_str, "No duplicate region_id\n");
	    bu_vls_printf(gedp->ged_result_str, "Done.\n");
	    bu_free(regions, "ged_lc");
	    return GED_ERROR;
	}
    }

    if (sort_column > 0) {
	bu_sort((void *) regions, BU_PTBL_LEN(&results2), sizeof(struct region_record), sort_regions, (void *)&sort_column);
    }

    if (file_name) {
	print_cmd_args(output, orig_argc, orig_argv);
    }

    bu_vls_printf(output, "List length: %d\n", BU_PTBL_LEN(&results2) - ignored_cnt);
    bu_vls_printf(output, "%-*s %-*s %-*s %-*s %s\n",
		  region_id_len_max + 1, "ID",
		  material_id_len_max + 1, "MAT",
		  los_len_max, "LOS",
		  obj_len_max,  "REGION",
		  "PARENT");
    end = BU_PTBL_LEN(&results2);
    if (descending_sort_flag) {
	start = end - 1; end = -1; incr = -1;
    } else {
	start = 0; incr = 1;
    }
    for (i = start; i != end; i += incr) {
	if (regions[i].ignore) { continue; }
	bu_vls_printf(output, "%-*s %-*s %-*s %-*s %s\n",
		      region_id_len_max + 1, regions[i].region_id,
		      material_id_len_max + 1, regions[i].material_id,
		      los_len_max, regions[i].los,
		      obj_len_max, regions[i].obj_name,
		      regions[i].obj_parent);
    }
    bu_vls_printf(gedp->ged_result_str, "Done.\n");

    if (file_name) {
	bu_vls_fwrite(outfile, output);
	fclose(outfile);
    }

    bu_free(regions, "ged_lc");

    return GED_OK;
}
STEPentity *
Create_Rational_Surface_Aggregate(ON_NurbsSurface *nsurface, ON_Brep_Info_AP203 *info) {
    STEPattribute *attr;
    STEPcomplex *stepcomplex;
    const char *entNmArr[8] = {"bounded_surface", "b_spline_surface", "b_spline_surface_with_knots",
	"surface", "geometric_representation_item", "rational_b_spline_surface", "representation_item", "*"};
    STEPcomplex *complex_entity = new STEPcomplex(info->registry, (const char **)entNmArr, info->registry->GetEntityCnt() + 1);
/*
    stepcomplex = complex_entity->head;
    stepcomplex->ResetAttributes();
    while (stepcomplex) {
	std::cout << stepcomplex->EntityName() << "\n";
	while ((attr = stepcomplex->NextAttribute()) != NULL) {
	    std::cout << "  " << attr->Name() << "," << attr->NonRefType() << "\n";
	}
	stepcomplex = stepcomplex->sc;
	stepcomplex->ResetAttributes();
    }
*/
    /* Set b_spline_surface data */
    stepcomplex = complex_entity->EntityPart("b_spline_surface");
    stepcomplex->ResetAttributes();
    while ((attr = stepcomplex->NextAttribute()) != NULL) {
	if (!bu_strcmp(attr->Name(), "u_degree")) attr->ptr.i = new SDAI_Integer(nsurface->Degree(0));
	if (!bu_strcmp(attr->Name(), "v_degree")) attr->ptr.i = new SDAI_Integer(nsurface->Degree(1));

	if (!bu_strcmp(attr->Name(), "control_points_list")) {
	    GenericAggregate *control_pnts= new GenericAggregate();
	    ON_NurbsSurfaceCV_Initialize(nsurface, complex_entity, info);
	    attr->ptr.a = control_pnts;
	    info->surf_genagg[(STEPentity*)complex_entity] = control_pnts;
	}
	if (!bu_strcmp(attr->Name(), "surface_form")) attr->ptr.e = new SdaiB_spline_surface_form_var(B_spline_surface_form__unspecified);
	if (!bu_strcmp(attr->Name(), "u_closed")) attr->ptr.e = new SDAI_LOGICAL((Logical)(nsurface->IsClosed(0)));
	if (!bu_strcmp(attr->Name(), "v_closed")) attr->ptr.e = new SDAI_LOGICAL((Logical)(nsurface->IsClosed(1)));
	if (!bu_strcmp(attr->Name(), "self_intersect")) attr->ptr.e = new SDAI_LOGICAL(LFalse);
    }

    /* Set knots */
    stepcomplex = complex_entity->EntityPart("b_spline_surface_with_knots");
    stepcomplex->ResetAttributes();
    IntAggregate *u_multiplicities = new IntAggregate();
    IntAggregate *v_multiplicities = new IntAggregate();
    RealAggregate *u_knots = new RealAggregate();
    RealAggregate *v_knots = new RealAggregate();

    ON_NurbsSurfaceKnots_to_Aggregates(u_multiplicities, v_multiplicities, u_knots, v_knots, nsurface);

    while ((attr = stepcomplex->NextAttribute()) != NULL) {

	if (!bu_strcmp(attr->Name(), "u_multiplicities")) attr->ptr.a = u_multiplicities;
	if (!bu_strcmp(attr->Name(), "v_multiplicities")) attr->ptr.a = v_multiplicities;

	if (!bu_strcmp(attr->Name(), "u_knots")) attr->ptr.a = u_knots;
	if (!bu_strcmp(attr->Name(), "v_knots")) attr->ptr.a = v_knots;

	if (!bu_strcmp(attr->Name(), "knot_spec")) attr->ptr.e = new SdaiKnot_type_var(Knot_type__unspecified);
    }

    /* Set weights */
    stepcomplex = complex_entity->EntityPart("rational_b_spline_surface");
    stepcomplex->ResetAttributes();
    while ((attr = stepcomplex->NextAttribute()) != NULL) {
	if (!bu_strcmp(attr->Name(), "weights_data")) {
	    GenericAggregate *weights = new GenericAggregate();
	    for (int i = 0; i < nsurface->CVCount(0); i++) {
		std::ostringstream ss;
		ss << "(";
		for (int j = 0; j < nsurface->CVCount(1); j++) {
		    if (j != 0) ss << ", ";
		    ss << nsurface->Weight(i,j);
		}
		ss << ")";
		std::string str = ss.str();
		weights->AddNode(new GenericAggrNode(str.c_str()));

	    }
	    attr->ptr.a = weights;
	}
    }

    /* Representation item */
    stepcomplex = complex_entity->EntityPart("representation_item");
    stepcomplex->ResetAttributes();
    while ((attr = stepcomplex->NextAttribute()) != NULL) {
	//std::cout << "  " << attr->Name() << "," << attr->NonRefType() << "\n";
	if (!bu_strcmp(attr->Name(), "name")) attr->StrToVal("''");
    }

    return (STEPentity *)complex_entity;
}
예제 #10
0
파일: fnmatch.c 프로젝트: cogitokat/brlcad
static int
classcompare(const void *a, const void *b)
{
    return bu_strcmp(((CHARCLASS *)a)->idstring, ((CHARCLASS *)b)->idstring);
}
예제 #11
0
파일: bu_sort.c 프로젝트: kanzure/brlcad
int
main(int argc, char **argv)
{
    int arg_1[6] = {5, 2, 6, -15, 168, 3};
    int exp_1[6] = {-15, 2, 3, 5, 6, 168};
    unsigned int arg_2[8] = {56, 4, 7, 156, 2, 0, 23, 8};
    unsigned int exp_2[8] = {0, 2, 4, 7, 8, 23, 56, 156};
    fastf_t arg_3[5] = {5.5, 3.8, -5.5, 1, -7};
    fastf_t exp_3[5] = {-7, -5.5, 1, 3.8, 5.5};
    fastf_t arg_4[7] = {7.42, -5.2, -5.9, 7.36, 7.0, 0, 7.36};
    fastf_t exp_4[7] = {-5.9, -5.2, 0, 7.0, 7.36, 7.36, 7.42};
    char arg_5[4][256] = {"Zfg", "ZFg", "azf", "bzf"};
    char exp_5[4][256] = {"ZFg", "Zfg", "azf", "bzf"};
    char arg_6[3][256] = {"test", "BAB", "aab"};
    char exp_6[3][256] = {"BAB", "aab", "test"};
    fastf_t cmp_7 = -2;
    fastf_t arg_7[9] = {-3, 7, -9, 34, 33, -34, 0, -12, 6};
    fastf_t exp_7[9] = {-3, 0, -9, 6, 7, -12, -34, 33, 34};
    fastf_t cmp_8 = 3;
    fastf_t arg_8[5] = {-5, 23, 5.5, 0, 2};
    fastf_t exp_8[5] = {2, 5.5, 0, -5, 23};
    fastf_t arg_9[5] = {0, 0, 0, 0, 0};
    fastf_t exp_9[5] = {0, 0, 0, 0, 0};
    fastf_t arg_10[5] = {INFINITY, 5, 5.2, 0, -INFINITY};
    fastf_t exp_10[5] = {-INFINITY, 0, 5, 5.2, INFINITY};
    int i, function_num;

    if (argc != 2)
	bu_exit(1, "ERROR: wrong number of parameters");
    sscanf(argv[1], "%d", &function_num);
    switch (function_num) {
	case 1:
	    bu_sort(&arg_1, 6, sizeof(int), comp_1, NULL);
	    for (i = 0; i < 6; i++)
		if (arg_1[i] != exp_1[i])
		    return 1;
	    break;
	case 2:
	    bu_sort(&arg_2, 8, sizeof(int), comp_1, NULL);
	    for (i = 0; i < 8; i++)
		if (arg_2[i] != exp_2[i])
		    return 1;
	    break;
	case 3:
	    bu_sort(&arg_3, 5, sizeof(fastf_t), comp_2, NULL);
	    for (i = 0; i < 5; i++)
		if (!EQUAL(arg_3[i], exp_3[i]))
		    return 1;
	    break;
	case 4:
	    bu_sort(&arg_4, 7, sizeof(fastf_t), comp_2, NULL);
	    for (i = 0; i < 7; i++)
		if (!EQUAL(arg_4[i], exp_4[i]))
		    return 1;
	    break;
	case 5:
	    bu_sort(&arg_5, 4, sizeof(char[256]), comp_3, NULL);
	    for (i = 0; i < 4; i++)
		if (bu_strcmp(arg_5[i], exp_5[i]) != 0)
		    return 1;
	    break;
	case 6:
	    bu_sort(&arg_6, 3, sizeof(char[256]), comp_3, NULL);
	    for (i = 0; i < 3; i++)
		if (bu_strcmp(arg_6[i], exp_6[i]) != 0)
		    return 1;
	    break;
	case 7:
	    bu_sort(&arg_7, 9, sizeof(fastf_t), comp_4, &cmp_7);
	    for (i = 0; i < 9; i++)
		if (!EQUAL(arg_7[i], exp_7[i]))
		    return 1;
	    break;
	case 8:
	    bu_sort(&arg_8, 5, sizeof(fastf_t), comp_4, &cmp_8);
	    for (i = 0; i < 5; i++)
		if (!EQUAL(arg_8[i], exp_8[i]))
		    return 1;
	    break;
	case 9:
	    bu_sort(&arg_9, 5, sizeof(fastf_t), comp_2, NULL);
	    for (i = 0; i < 5; i++)
		if (!EQUAL(arg_9[i], exp_9[i]))
		    return 1;
	    break;
	case 10:
	    bu_sort(&arg_10, 5, sizeof(fastf_t), comp_2, NULL);
	    for (i = 0; i < 5; i++)
		if ((!EQUAL(arg_10[i], exp_10[i]) && (!isinf(arg_10[i]) || !isinf(exp_10[i]))) || ((exp_10[i] < 0) != (arg_10[i] < 0)))
		    return 1;
	    break;
    }
    return 0;
}
예제 #12
0
파일: bu_sort.c 프로젝트: kanzure/brlcad
/* sort strings based on ASCII-table */
int
comp_3(const void *str1, const void *str2, void *UNUSED(arg))
{
    return bu_strcmp((char *)str1, (char *)str2);
}