[brlcad-commits] SF.net SVN: brlcad:[32587] brlcad/trunk/src/libged
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2008-09-06 06:12:50
|
Revision: 32587 http://brlcad.svn.sourceforge.net/brlcad/?rev=32587&view=rev Author: starseeker Date: 2008-09-06 06:13:00 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Add stdattr option which takes 0 or 1 and sorts based on whether attributes are standard - 1 returns objects with one or more standard attributes and no non-standard, 0 returns objects with one or more non-standard. Between the zero setting for this option and the attr option it should now be possible to achieve the effects desired in feature request 1177374. Modified Paths: -------------- brlcad/trunk/src/libged/nfind.c brlcad/trunk/src/libged/nfind.h Modified: brlcad/trunk/src/libged/nfind.c =================================================================== --- brlcad/trunk/src/libged/nfind.c 2008-09-06 05:45:44 UTC (rev 32586) +++ brlcad/trunk/src/libged/nfind.c 2008-09-06 06:13:00 UTC (rev 32587) @@ -76,6 +76,7 @@ { "-o", N_OR, c_or, O_ZERO }, { "-print", N_PRINT, c_print, O_ZERO }, { "-print0", N_PRINT0, c_print0, O_ZERO }, + { "-stdattr", N_STDATTR, c_stdattr, O_ARGV }, }; static PLAN * @@ -372,9 +373,72 @@ return BRLCAD_OK; } +/* + * -stdattr function -- + * + * Report based on the presence or absence of the + * "standard" attributes - supply a "1" argument and + * objects with ONLY "standard" attribute flags + * and NO non-standard flags are + * reported - supply a "0" and only objects with + * one or more non-standard flags are reported. + */ +int +f_stdattr(PLAN *plan, struct db_full_path *entry, struct db_i *dbip) +{ + struct bu_attribute_value_set avs; + struct bu_attribute_value_pair *avpp; + int i; + int found_nonstd_attr = 0; + int found_attr = 0; + /* Get attributes for object and check all of + * them to see if there is not a match to the + * standard attributes. If any is found return + * failure, otherwise success. + */ + + bu_avs_init_empty(&avs); + db5_get_attributes( dbip, &avs, DB_FULL_PATH_CUR_DIR(entry)); + avpp = avs.avp; + for (i = 0; i < avs.count; i++, avpp++) { + found_attr = 1; + if (strcmp(avpp->name, "region") != 0 && + strcmp(avpp->name, "region_id") != 0 && + strcmp(avpp->name, "material_id") != 0 && + strcmp(avpp->name, "los") != 0 && + strcmp(avpp->name, "aircode") != 0 && + strcmp(avpp->name, "oshader") != 0 && + strcmp(avpp->name, "rgb") != 0){ + + found_nonstd_attr = 1; + } + } + bu_avs_free( &avs); + + if (plan->stdflag && found_nonstd_attr) return 0; + if (plan->stdflag && !found_nonstd_attr && found_attr) return 1; + if (!(plan->stdflag) && found_nonstd_attr) return 1; + if (!(plan->stdflag) && !found_nonstd_attr) return 0; + return 0; +} + +int +c_stdattr(char *pattern, char ***ignored, int unused, PLAN **resultplan) +{ + PLAN *new; + + new = palloc(N_STDATTR, f_stdattr); + new->stdflag = atoi(pattern); + (*resultplan) = new; + return BRLCAD_OK; +} + + + + /* * -print functions -- * Modified: brlcad/trunk/src/libged/nfind.h =================================================================== --- brlcad/trunk/src/libged/nfind.h 2008-09-06 05:45:44 UTC (rev 32586) +++ brlcad/trunk/src/libged/nfind.h 2008-09-06 06:13:00 UTC (rev 32587) @@ -61,7 +61,7 @@ N_CLOSEPAREN, N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXPR, N_FLAGS, N_INAME, N_LS, N_MAXDEPTH, N_MINDEPTH, N_NAME, N_NATTR, N_NOT, N_OK, N_OPENPAREN, N_OR, N_PATH, - N_PRINT, N_PRINT0, N_PRUNE, N_TYPE + N_PRINT, N_PRINT0, N_PRUNE, N_STDATTR, N_TYPE }; @@ -95,6 +95,7 @@ char *_c_data; /* char pointer */ char *_attr_data; /* char pointer */ char *_nattr_data; /* char pointer */ + int _stdflag; /* t/f flag for std reporting */ int _max_data; /* tree depth */ int _min_data; /* tree depth */ } p_un; @@ -112,6 +113,7 @@ #define e_argv p_un.ex._e_argv #define e_orig p_un.ex._e_orig #define e_len p_un.ex._e_len +#define stdflag p_un._stdflag typedef struct _option { char *name; /* option name */ @@ -150,6 +152,7 @@ PLAN *c_mindepth(char *, char ***, int); int c_name(char *, char ***, int, PLAN **); int c_nattr(char *, char ***, int, PLAN **); +int c_stdattr(char *, char ***, int, PLAN **); PLAN *c_path(char *, char ***, int); int c_print(char *, char ***, int, PLAN **); int c_print0(char *, char ***, int, PLAN **); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |